From ea21f0ccc45d02160db06ba9714754922a88135e Mon Sep 17 00:00:00 2001 From: alex404 Date: Fri, 9 Jun 2023 15:43:43 +0200 Subject: [PATCH] Allowed access to WAD write_order (so that new groups can be saved properly when added to WAD structure), and added group for ACS libraries (see https://zdoom.org/wiki/Namespace) --- omg/wad.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/omg/wad.py b/omg/wad.py index bebcba2..e17a5ae 100644 --- a/omg/wad.py +++ b/omg/wad.py @@ -218,6 +218,7 @@ def __add__(self, other): # Must be in order: markers first, ['*'] name group last defstruct = [ [MarkerGroup, 'sprites', Graphic, 'S'], + [MarkerGroup, 'libraries', Graphic, 'A'], [MarkerGroup, 'patches', Graphic, 'P'], [MarkerGroup, 'flats', Flat, 'F'], [MarkerGroup, 'colormaps', Lump, 'C'], @@ -232,7 +233,7 @@ def __add__(self, other): [NameGroup, 'data', Lump, ['*']] ] -write_order = ['data', 'colormaps', 'maps', 'glmaps', 'udmfmaps', 'txdefs', +deforder = ['data', 'colormaps', 'maps', 'glmaps', 'libraries', 'udmfmaps', 'txdefs', 'sounds', 'music', 'graphics', 'sprites', 'patches', 'flats', 'ztextures'] @@ -257,7 +258,7 @@ class WAD: the structure definition """ - def __init__(self, from_file=None, structure=defstruct): + def __init__(self, from_file=None, structure=defstruct, write_order=deforder): """Create a new WAD. The optional `source` argument may be a string specifying a path to a file or a WadIO object. If omitted, an empty WAD is created. A WADStructure object @@ -267,6 +268,7 @@ def __init__(self, from_file=None, structure=defstruct): self.__category = 'root' self.palette = omg.palette.default self.structure = structure + self.write_order = write_order self.groups = [] for group_def in self.structure: instance = group_def[0](*tuple(group_def[1:])) @@ -300,7 +302,7 @@ def to_file(self, filename): os.remove(tmpfilename) os.rename(filename, tmpfilename) w = WadIO(filename) - for group in write_order: + for group in self.write_order: self.__dict__[group].save_wadio(w, use_free=False) w.save() if use_backup: