Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions omg/wad.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand All @@ -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']

Expand All @@ -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
Expand All @@ -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:]))
Expand Down Expand Up @@ -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:
Expand Down