Commit eb031dc5 authored by Simon McVittie's avatar Simon McVittie

Plugins: move package-specific quirks into Package subclasses

parent c05b86c4
......@@ -23,6 +23,7 @@ import subprocess
from .. import GameData
from ..build import (PackagingTask)
from ..data import (Package)
from ..paths import DATADIR
from ..util import (copy_with_substitutions, mkdir_p)
......@@ -72,26 +73,43 @@ class DoomGameData(GameData):
self.genre = 'First-person shooter'
for package in self.packages.values():
package.install_to = '$assets/doom'
if 'main_wads' in self.data['packages'][package.name]:
package.main_wads = self.data['packages'][package.name]['main_wads']
else:
assert package.only_file
package.main_wads = {package.only_file: {}}
assert type(package.main_wads) == dict
for main_wad in package.main_wads.values():
assert type(main_wad) == dict
if 'args' in main_wad:
main_wad['args'] % 'deadbeef'
elif package.expansion_for:
if 'args' not in main_wad and package.expansion_for:
assert self.packages[package.expansion_for].only_file
package.data_type = 'PWAD' if (package.expansion_for
or package.expansion_for_ext) else 'IWAD'
def construct_package(self, binary, data):
return DoomPackage(binary, data)
def construct_task(self, **kwargs):
return DoomTask(self, **kwargs)
class DoomPackage(Package):
def __init__(self, binary, data):
super(DoomPackage, self).__init__(binary, data)
assert 'install_to' not in data, self.name
assert 'data_type' not in data, self.name
self.install_to = '$assets/doom'
if self.expansion_for or self.expansion_for_ext:
self.data_type = 'PWAD'
else:
self.data_type = 'IWAD'
if 'main_wads' in data:
self.main_wads = data['main_wads']
else:
assert self.only_file
self.main_wads = { self.only_file: {} }
assert type(self.main_wads) == dict
for main_wad in self.main_wads.values():
assert type(main_wad) == dict
if 'args' in main_wad:
# assert that it has one string placeholder
main_wad['args'] % 'deadbeef'
class DoomTask(PackagingTask):
def fill_extra_files(self, package, destdir):
super(DoomTask, self).fill_extra_files(package, destdir)
......
......@@ -24,6 +24,7 @@ import os
from .. import GameData
from ..build import (PackagingTask)
from ..data import (Package)
from ..util import (mkdir_p)
logger = logging.getLogger(__name__)
......@@ -39,24 +40,33 @@ class DosboxGameData(GameData):
super(DosboxGameData, self).__init__(shortname, data)
self.binary_executables = 'all'
for p in self.packages.values():
p.install_to = '$assets/dosbox/' + p.name[:len(p.name)-5]
p.depends = 'dosgame'
p.main_exe = None
if 'main_exe' in self.data['packages'][p.name]:
p.main_exe = self.data['packages'][p.name]['main_exe']
else:
for wanted in p.install:
filename, ext = os.path.splitext(wanted)
if (filename not in ('config', 'install', 'setup')
and ext in ('.com','.exe')):
assert p.main_exe is None
p.main_exe = filename
assert p.main_exe
def construct_package(self, binary, data):
return DosboxPackage(binary, data)
def construct_task(self, **kwargs):
return DosboxTask(self, **kwargs)
class DosboxPackage(Package):
def __init__(self, binary, data):
super(DosboxPackage, self).__init__(binary, data)
assert 'install_to' not in data
assert 'depends' not in data
self.install_to = '$assets/dosbox/' + self.name[:len(self.name)-5]
self.depends = 'dosgame'
self.main_exe = None
if 'main_exe' in data:
self.main_exe = data['main_exe']
else:
for wanted in self.install:
filename, ext = os.path.splitext(wanted)
if (filename not in ('config', 'install', 'setup')
and ext in ('.com','.exe')):
assert self.main_exe is None
self.main_exe = filename
assert self.main_exe
class DosboxTask(PackagingTask):
def fill_extra_files(self, package, destdir):
super(DosboxTask, self).fill_extra_files(package, destdir)
......
......@@ -23,6 +23,7 @@ import subprocess
from .. import GameData
from ..build import (PackagingTask)
from ..data import (Package)
from ..paths import DATADIR
from ..util import (mkdir_p)
......@@ -46,15 +47,21 @@ class EcwolfGameData(GameData):
if self.genre is None:
self.genre = 'First-person shooter'
for package in self.packages.values():
if 'quirks' in self.data['packages'][package.name]:
package.quirks = ' ' + self.data['packages'][package.name]['quirks']
else:
package.quirks = ''
def construct_package(self, binary, data):
return EcwolfPackage(binary, data)
def construct_task(self, **kwargs):
return EcwolfTask(self, **kwargs)
class EcwolfPackage(Package):
def __init__(self, binary, data):
super(EcwolfPackage, self).__init__(binary, data)
if 'quirks' in data:
self.quirks = ' ' + data['quirks']
else:
self.quirks = ''
class EcwolfTask(PackagingTask):
def fill_extra_files(self, package, destdir):
super(EcwolfTask, self).fill_extra_files(package, destdir)
......
......@@ -24,6 +24,7 @@ import re
from .. import GameData
from ..build import (PackagingTask)
from ..data import (Package)
from ..util import (TemporaryUmask,
which,
mkdir_p)
......@@ -33,13 +34,6 @@ logger = logging.getLogger(__name__)
class ZCodeGameData(GameData):
def __init__(self, shortname, data):
super(ZCodeGameData, self).__init__(shortname, data)
for package in self.packages.values():
package.z_file = None
for install in package.install:
if re.match('^.z[12345678]$', os.path.splitext(install)[1]):
assert package.z_file is None
package.z_file = install
assert package.z_file
if self.engine is None:
self.engine = { 'deb': 'gargoyle-free | zcode-interpreter' }
......@@ -47,9 +41,24 @@ class ZCodeGameData(GameData):
if self.genre is None:
self.genre = 'Adventure'
def construct_package(self, binary, data):
return ZCodePackage(binary, data)
def construct_task(self, **kwargs):
return ZCodeTask(self, **kwargs)
class ZCodePackage(Package):
def __init__(self, binary, data):
super(ZCodePackage, self).__init__(binary, data)
self.z_file = None
for install in self.install:
if re.match('^.z[12345678]$', os.path.splitext(install)[1]):
assert self.z_file is None
self.z_file = install
assert self.z_file
class ZCodeTask(PackagingTask):
def fill_extra_files(self, package, destdir):
super(ZCodeTask, self).fill_extra_files(package, destdir)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment