コード例 #1
0
import os, md5, time, fnmatch

from omg import util

Header = util.make_struct(
  "Header",
  """Class for WAD file headers""",
  [["type",    '4s', "PWAD"],
   ["dir_len", 'l',  0     ],
   ["dir_ptr", 'l',  12    ]]
)

Entry = util.make_struct(
  "Entry",
  """Class for WAD entries""",
  [["ptr",       'l',  0 ],
   ["size",      'l',  0 ],
   ["name",      '8s', ""],
   ["been_read", 'x',  False]]   # Used by WAD loader
)


# WadIO.open() behaves just like open(). Sometimes it is
# useful to specifically either open an existing file
# or create a new one.

def open_wad():
    """Open an existing WAD, raise IOError if not found"""
    if not os.path.exists(util.location):
        raise IOError
    return WadIO(util.location)
コード例 #2
0
ファイル: txdef.py プロジェクト: jminor/omgifol
import collections

from omg import util, lump, wad

TextureDef = util.make_struct(
  "TextureDef",
  """Class for texture definitions""",
  [["name",     '8s', "-"],
   ["dummy1",   'l',  0  ],
   ["width",    'h',  0  ],
   ["height",   'h',  0  ],
   ["dummy2",   'l',  0  ],
   ["npatches", 'h',  0  ]],
  init_exec = "self.patches = []"
)

PatchDef = util.make_struct(
  "PatchDef",
  """Class for patches""",
  [["x",      'h',  0],
   ["y",      'h',  0],
   ["id",     'h',  -1],
   ["dummy1", 'h',  1],
   ["dummy2", 'h',  0],
   ["name",   'x',  "-"]]
)


# TODO: integrate with textures lump group instead?

class Textures(collections.OrderedDict):
コード例 #3
0
from omg import util, lump
from omg.wad import NameGroup

Vertex = util.make_struct(
  "Vertex", """Represents a map vertex""",
  [["x", "h", 0],
   ["y", "h", 0]]
)

GLVertex = util.make_struct(
  "GLVertex", """Represents a map GL vertex""",
  [["x", "l", 0],
   ["y", "l", 0]]
)

Sidedef = util.make_struct(
  "Sidedef", """Represents a map sidedef""",
  [["off_x",  'h',  0  ],
   ["off_y",  'h',  0  ],
   ["tx_up",  '8s', "-"],
   ["tx_low", '8s', "-"],
   ["tx_mid", '8s', "-"],
   ["sector", 'h',  -1 ]]
)

Linedef = util.make_struct(
  "Linedef", """Represents a map linedef""",
  [["vx_a",   'h', -1],
   ["vx_b",   'h', -1],
   ["flags",  'h',  0],
   ["action", 'h',  0],
コード例 #4
0
import collections

from omg import util, lump, wad

TextureDef = util.make_struct(
    "TextureDef",
    """Class for texture definitions""",
    [["name", '8s', "-"], ["dummy1", 'l', 0], ["width", 'h', 0],
     ["height", 'h', 0], ["dummy2", 'l', 0], ["npatches", 'h', 0]],
    init_exec="self.patches = []")

PatchDef = util.make_struct(
    "PatchDef", """Class for patches""",
    [["x", 'h', 0], ["y", 'h', 0], ["id", 'h', -1], ["dummy1", 'h', 1],
     ["dummy2", 'h', 0], ["name", 'x', "-"]])

# TODO: integrate with textures lump group instead?


class Textures(collections.OrderedDict):
    """An editor for Doom's TEXTURE1, TEXTURE2 and PNAMES lumps."""
    def __init__(self, *args):
        """Create new, optionally loading content from given
        TEXTURE1/2 and PNAMES lumps or a txdefs group. E.g.:

            Textures(texture1, pnames)
            Textures(txdefs)
        """
        collections.OrderedDict.__init__(self)
        if len(args):
            self.from_lumps(*args)