1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
|
#!/usr/bin/python3
# encoding=utf-8
#
# Copyright © 2016 Alexandre Detiste <alexandre@detiste.be>
# Copyright © 2016 Simon McVittie <smcv@debian.org>
# SPDX-License-Identifier: GPL-2.0-or-later
import logging
import os
from ..build import (PackagingTask)
from ..game import (GameData)
from ..util import (check_call)
logger = logging.getLogger(__name__)
class MorrowindGameData(GameData):
def construct_task(self, **kwargs):
return MorrowindTask(self, **kwargs)
class MorrowindTask(PackagingTask):
def fill_extra_files(self, per_package_state):
super().fill_extra_files(per_package_state)
package = per_package_state.package
destdir = per_package_state.destdir
if package.expansion_for:
return
install_to = self.packaging.substitute(package.install_to,
package.name)
datadir = os.path.join(destdir, install_to.strip('/'))
assert datadir.startswith(destdir + '/'), (datadir, destdir)
subdir_expected_by_iniimporter = os.path.join(datadir, 'Data Files')
os.symlink(datadir, subdir_expected_by_iniimporter)
ini = os.path.join(datadir, 'Morrowind.ini')
if os.path.exists(ini + '.gog'):
# The GOG ini file already contains Tribunal and Bloodmoon
initext = open(ini + '.gog', encoding='latin-1').read()
open(ini, 'w', encoding='latin-1').write(initext)
elif os.path.exists(ini + '.orig'):
initext = open(ini + '.orig', encoding='latin-1').read()
if package.name.startswith( # either of:
('morrowind-tribunal', 'morrowind-complete')):
initext = initext + '\r\nGameFile1=Tribunal.esm\r\n'
if package.name.startswith('morrowind-bloodmoon'):
initext = initext + '\r\nGameFile1=Bloodmoon.esm\r\n'
if package.name.startswith('morrowind-complete'):
initext = initext + '\r\nGameFile2=Bloodmoon.esm\r\n'
open(ini, 'w', encoding='latin-1').write(initext)
cfg = os.path.join(datadir, 'openmw.cfg')
check_call(['openmw-iniimporter',
'--verbose',
'--game-files',
'--encoding', 'win1252',
'--ini', ini,
'--cfg', cfg])
os.unlink(subdir_expected_by_iniimporter)
with open(cfg, 'a', encoding='utf-8') as f:
f.write('data=%s\n' % os.path.join('/', install_to))
# then user needs to do this:
#
# $ mkdir -p ~/.config/openmw/
# $ cp /usr/share/games/morrowind-fr/openmw.cfg ~/.config/openmw/
# 1) sample output of openmw-iniimporter without "Data Files"
#cfg file does not exist
#load ini file: "/tmp/gdptmp.k5ig_6ps/morrowind-fr-data.deb.d/usr/share/games/morrowind-fr/Morrowind.ini"
#Warning: ignored empty value for key 'General:Beta Comment File'.
#Warning: ignored empty value for key 'General:Editor Starting Cell'.
#load cfg file: "/tmp/gdptmp.k5ig_6ps/morrowind-fr-data.deb.d/usr/share/games/morrowind-fr/openmw.cfg"
#content file: "/tmp/gdptmp.k5ig_6ps/morrowind-fr-data.deb.d/usr/share/games/morrowind-fr/Data Files/Morrowind.esm" not found
#write to: /tmp/gdptmp.k5ig_6ps/morrowind-fr-data.deb.d/usr/share/games/morrowind-fr/openmw.cfg
# 2) I can't 100% reproduce the openmw.cfg created by openmw
#$ diff -uw .config/openmw/openmw.cfg /usr/share/games/morrowind-fr/openmw.cfg
#--- .config/openmw/openmw.cfg 2016-01-19 14:46:28.522761855 +0100
#+++ /usr/share/games/morrowind-fr/openmw.cfg 2016-01-19 14:52:58.000000000 +0100
#@@ -1,5 +1,4 @@
#-no-sound=0
#-fallback-archive=Morrowind.bsa
#+content=Morrowind.esm
# fallback=LightAttenuation_UseConstant,0
# fallback=LightAttenuation_ConstantValue,0.0
# fallback=LightAttenuation_UseLinear,1
#@@ -494,6 +493,15 @@
# fallback=Moons_Masser_Fade_In_Finish,15
# fallback=Moons_Masser_Fade_Out_Start,7
# fallback=Moons_Masser_Fade_Out_Finish,10
#-encoding=win1252
#-data=/usr/share/games/morrowind-fr
#-content=Morrowind.esm
#+fallback=Blood_Model_0,BloodSplat.nif
#+fallback=Blood_Model_1,BloodSplat2.nif
#+fallback=Blood_Model_2,BloodSplat3.nif
#+fallback=Blood_Texture_0,Tx_Blood.tga
#+fallback=Blood_Texture_1,Tx_Blood_White.tga
#+fallback=Blood_Texture_2,Tx_Blood_Gold.tga
#+fallback=Blood_Texture_Name_0,Default (Red)
#+fallback=Blood_Texture_Name_1,Skeleton (White)
#+fallback=Blood_Texture_Name_2,Metal Sparks (Gold)
#+fallback-archive=Morrowind.bsa
#+no-sound=0
#+data=/usr/share/games/morrowind-fr
GAME_DATA_SUBCLASS = MorrowindGameData
|