Skip to content

Commit 6ddec5d

Browse files
authored
Merge pull request #42 from Xymph/doc-updates-etc
Documentation & formatting updates
2 parents 28277c0 + 46de024 commit 6ddec5d

File tree

4 files changed

+50
-50
lines changed

4 files changed

+50
-50
lines changed

LICENSE

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2005 Fredrik Johansson
1+
Copyright (c) 2005 Fredrik Johansson, 2017 Devin Acker
22

33
Permission is hereby granted, free of charge, to any person obtaining a
44
copy of this software and associated documentation files (the "Software"),
@@ -16,4 +16,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
1616
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
1717
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
1818
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
19-
USE OR OTHER DEALINGS IN THE SOFTWARE.
19+
USE OR OTHER DEALINGS IN THE SOFTWARE.

manual.html

+26-26
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@ <h1>Omgifol manual</h1>
3434
</div>
3535
</td></tr></table>
3636
<a name="Installation"></a><h2>Installation</h2>
37-
<ol><li> Install Python 3, which can be downloaded from <a href="http://python.org" class='external' title="http://python.org">http://python.org</a>
37+
<ol><li> Install Python 3, which can be downloaded from <a href="http://python.org" class="external" title="http://python.org">http://python.org</a>
3838
</li><li> Use pip to install Omgifol: <tt>pip install omgifol</tt>
3939
</li><li> Or, if pip is unavailable, extract the "omg" directory in the Omgifol package into <em>pythondir</em>/Lib/site-packages (replace <em>pythondir</em> with the directory where Python is installed).
4040
</li></ol>
4141
<p>Optionally:
4242

4343
</p>
44-
<ol><li> Install the <a href='https://python-pillow.github.io' class='external' title="https://python-pillow.github.io">Pillow library</a><span class='urlexpansion'> (<i>https://python-pillow.github.io</i>)</span>. This is required to import or export images.
44+
<ol><li> Install the <a href="https://python-pillow.github.io" class="external" title="https://python-pillow.github.io">Pillow library</a><span class="urlexpansion"> (<i>https://python-pillow.github.io</i>)</span>. This is required to import or export images.
4545
</li>
46-
<li> Install the <a href='https://pysoundfile.readthedocs.io' class='external' title="https://pysoundfile.readthedocs.io">PySoundFile library</a><span class='urlexpansion'> (<i>https://pysoundfile.readthedocs.io</i>)</span>. This is required to import or export sound files.
46+
<li> Install the <a href="https://pysoundfile.readthedocs.io" class="external" title="https://pysoundfile.readthedocs.io">PySoundFile library</a><span class="urlexpansion"> (<i>https://pysoundfile.readthedocs.io</i>)</span>. This is required to import or export sound files.
4747
</li>
4848
</ol>
4949

@@ -53,7 +53,7 @@ <h1>Omgifol manual</h1>
5353
<pre> from omg import *
5454
</pre>
5555
<a name="WAD_objects"></a><h2>WAD objects</h2>
56-
<p>A <tt >WAD</tt > is an abstract representation of a WAD file. A <tt >WAD</tt > object can load content from a WAD file, or save content to a WAD file, but is entirely memory-resident.
56+
<p>A <tt>WAD</tt> is an abstract representation of a WAD file. A <tt>WAD</tt> object can load content from a WAD file, or save content to a WAD file, but is entirely memory-resident.
5757

5858
</p>
5959
<a name="Loading_from_WAD_files"></a><h3>Loading from WAD files</h3>
@@ -85,20 +85,20 @@ <h1>Omgifol manual</h1>
8585
with the same name, etc.
8686
</p>
8787
<a name="Writing_to_WAD_files"></a><h3>Writing to WAD files</h3>
88-
<p>If <em>a</em> is a <tt >WAD</tt > instance:
88+
<p>If <em>a</em> is a <tt>WAD</tt> instance:
8989
</p>
9090
<pre> a.to_file('some_wad.wad')
9191
</pre>
9292
<a name="Accessing_lumps"></a><h3>Accessing lumps</h3>
9393

94-
<p>Lumps are stored in <em>groups</em>. Each <tt >WAD</tt > holds a number of groups, representing different categories of lumps. Each group is an ordered dictionary; that is, it works just like a Python <tt ><a href='http://docs.python.org/tut/node7.html#SECTION007500000000000000000' class='external' title="http://docs.python.org/tut/node7.html#SECTION007500000000000000000">dict</a><span class='urlexpansion'> (<i>http://docs.python.org/tut/node7.html#SECTION007500000000000000000</i>)</span></tt > object but remembers in which order lumps were inserted.
95-
</p><p>All lumps are instances of the <tt >Lump</tt > class; see below for its documentation.
94+
<p>Lumps are stored in <em>groups</em>. Each <tt>WAD</tt> holds a number of groups, representing different categories of lumps. Each group is an ordered dictionary; that is, it works just like a Python <tt><a href="https://docs.python.org/3/tutorial/datastructures.html#dictionaries" class="external" title="https://docs.python.org/3/tutorial/datastructures.html#dictionaries">dict</a><span class="urlexpansion"> (<i>https://docs.python.org/3/tutorial/datastructures.html#dictionaries</i>)</span></tt> object but remembers in which order lumps were inserted.
95+
</p><p>All lumps are instances of the <tt>Lump</tt> class; see below for its documentation.
9696

97-
</p><p>To retrieve the sprite called <tt >CYBR1A</tt > from the <tt >WAD</tt > object <em>a</em>, do:
97+
</p><p>To retrieve the sprite called <tt>CYBR1A</tt> from the <tt>WAD</tt> object <em>a</em>, do:
9898
</p>
9999
<pre> a.sprites['CYBR1A']
100100
</pre>
101-
<p>And to replace it with some other lump object called <tt >some_lump</tt >:
101+
<p>And to replace it with some other lump object called <tt>some_lump</tt>:
102102
</p>
103103

104104
<pre> a.sprites['CYBR1A'] = some_lump
@@ -127,7 +127,7 @@ <h1>Omgifol manual</h1>
127127
</pre>
128128
<p>This scheme can be modified if desired; refer to wad.py for the details.
129129

130-
</p><p>The <tt >maps</tt > and <tt >glmaps</tt > are special. These do not contain lumps, but additional groups of lumps, one for each map. So if you access E1M1:
130+
</p><p>The <tt>maps</tt> and <tt>glmaps</tt> are special. These do not contain lumps, but additional groups of lumps, one for each map. So if you access E1M1:
131131
</p>
132132
<pre> a.maps['E1M1']
133133
</pre>
@@ -140,7 +140,7 @@ <h1>Omgifol manual</h1>
140140

141141
</p>
142142
<a name="Merging"></a><h3>Merging</h3>
143-
<p>To merge two <tt >WAD</tt >s <em>a</em> and <em>b</em>:
143+
<p>To merge two <tt>WAD</tt>s <em>a</em> and <em>b</em>:
144144
</p>
145145
<pre> c = a + b
146146
</pre>
@@ -161,27 +161,27 @@ <h1>Omgifol manual</h1>
161161
<p>Use with care for sections of different types.
162162
</p><p>Note that some sections do more than just copy over the list of lumps
163163
when they merge. For example, adding two <em>txdefs</em> sections together
164-
will automagically merge the <tt >TEXTURE1</tt >, <tt >TEXTURE2</tt > and <tt >PNAMES</tt > lumps. <tt >txdefs</tt >
164+
will automagically merge the <tt>TEXTURE1</tt>, <tt>TEXTURE2</tt> and <tt>PNAMES</tt> lumps. <tt>txdefs</tt>
165165

166-
also get merged this way when two <tt >WAD</tt > objects are merged on the top level.
166+
also get merged this way when two <tt>WAD</tt> objects are merged on the top level.
167167
</p>
168168
<a name="Lumps"></a><h2>Lumps</h2>
169-
<p>The <tt >Lump</tt > class holds a single lump. The class provides the following data and methods:
169+
<p>The <tt>Lump</tt> class holds a single lump. The class provides the following data and methods:
170170
</p>
171171
<pre> .data The lump's raw data as a string
172172
.to_file(<em>filename</em>) Save from a file
173173
.from_file(<em>filename</em>) Load from a file
174174
.copy() Return a copy
175175

176176
</pre>
177-
<p>Creating a new lump called 'FOOF' containing the text 'Hello!' and inserting it into a <tt >WAD</tt > <em>w</em> would be done as follows:
177+
<p>Creating a new lump called 'FOOF' containing the text 'Hello!' and inserting it into a <tt>WAD</tt> <em>w</em> would be done as follows:
178178
</p>
179179
<pre> w.data['FOOF'] = Lump('Hello!')
180180
</pre>
181181
<a name="Graphic_lumps"></a><h3>Graphic lumps</h3>
182-
<p>There are subclasses of <tt >Lump</tt > for different types of lumps. Currently, only these provide special functionality: <tt >Graphic</tt >, <tt >Flat</tt >, and <tt>Sound</tt>.
182+
<p>There are subclasses of <tt>Lump</tt> for different types of lumps. Currently, only these provide special functionality: <tt>Graphic</tt>, <tt>Flat</tt>, and <tt>Sound</tt>.
183183

184-
</p><p><tt >Graphic</tt >, used to represent Doom format graphics, provides the following settable attributes:
184+
</p><p><tt>Graphic</tt>, used to represent Doom format graphics, provides the following settable attributes:
185185
</p>
186186
<pre> .offsets (x, y) offsets
187187
.x_offset x offset
@@ -190,7 +190,7 @@ <h1>Omgifol manual</h1>
190190
.width width in pixels
191191
.height height in pixels
192192
</pre>
193-
<p><tt >Graphic</tt > defines the following methods in adddition to those defined by <tt >Lump</tt >:
193+
<p><tt>Graphic</tt> defines the following methods in adddition to those defined by <tt>Lump</tt>:
194194
</p>
195195
<pre> .from_raw Load from a raw image
196196
.to_raw Return the image converted to raw pixels
@@ -199,17 +199,17 @@ <h1>Omgifol manual</h1>
199199
.translate Translate to another palette
200200
</pre>
201201
<p>For the argument lists used by these functions, refer to the code and the inline documenation in lump.py.
202-
</p><p><tt >Flat</tt > works similarly to <tt >Graphic</tt >, but handles format conversions slightly differently.
202+
</p><p><tt>Flat</tt> works similarly to <tt>Graphic</tt>, but handles format conversions slightly differently.
203203

204-
</p><p><tt >Sound</tt >, used to represent Doom format sounds, provides the following settable attributes:
204+
</p><p><tt>Sound</tt>, used to represent Doom format sounds, provides the following settable attributes:
205205
</p>
206206
<pre> .format Sound effect format (0-3)
207207
.length Length of sound in samples
208208
.sample_rate Sample rate for digitized sounds (defaults to 11025)
209209
.midi_bank MIDI patch bank number (formats 1-2 only)
210210
.midi_patch MIDI patch number (formats 1-2 only)
211211
</pre>
212-
<p><tt >Sound</tt > defines the following methods in adddition to those defined by <tt >Lump</tt >:
212+
<p><tt>Sound</tt> defines the following methods in adddition to those defined by <tt>Lump</tt>:
213213
</p>
214214
<pre> .from_raw Load from a raw sound file
215215
.to_raw Return the sound file converted to raw samples
@@ -222,11 +222,11 @@ <h1>Omgifol manual</h1>
222222
<a name="Editors"></a><h2>Editors</h2>
223223
<p><em>Editors</em> are used to edit lumps or lump groups. They represent lump data with high-level objects and structures, and provide methods to modify the data. The following editors have been implemented so far:
224224
</p>
225-
<ul><li> <tt >Colormap</tt > for the COLORMAP lump
226-
</li><li> <tt >Playpal</tt > for the PLAYPAL lump
227-
</li><li> <tt >Textures</tt > for TEXTURE1/TEXTURE2/PNAMES
225+
<ul><li> <tt>Colormap</tt> for the COLORMAP lump
226+
</li><li> <tt>Playpal</tt> for the PLAYPAL lump
227+
</li><li> <tt>Textures</tt> for TEXTURE1/TEXTURE2/PNAMES
228228

229-
</li><li> <tt >MapEditor</tt > for maps
229+
</li><li> <tt>MapEditor</tt> for maps
230230
</li></ul>
231231
<p>All editors provide the following methods:
232232
</p>
@@ -250,4 +250,4 @@ <h1>Omgifol manual</h1>
250250
</pre>
251251
<p>Refer to the source code for more information.</p>
252252
</body>
253-
</html>
253+
</html>

omg/udmf.py

+21-20
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class UParser:
5353
QUOTED_STRING_RE = re.compile(rb'"([^"\\]*(\\.[^"\\]*)*)"')
5454
KEYWORD_RE = re.compile(rb'[^{}();"\'\n\t ]+')
5555
WHITESPACE_RE = re.compile(rb'(\s|(\n|^)//[^\n]+|/\*(\*(?!\/)|[^*])*\*/)+')
56+
5657
def __init__(self, blocktypes):
5758
self.blocktypes = blocktypes
5859
self.src = None
@@ -162,6 +163,7 @@ def value(self):
162163

163164
class UVertex(UBlock):
164165
storage = 'vertexes'
166+
165167
def __init__(self, x=0.0, y=0.0, **kwargs):
166168
self.x = x
167169
self.y = y
@@ -171,6 +173,7 @@ class USidedef(UBlock):
171173
storage = 'sidedefs'
172174
defaults = {'texturetop': '-', 'texturebottom': '-', 'texturemiddle': '-',
173175
'offsetx': 0, 'offsety': 0}
176+
174177
def __init__(self, sector=None, **kwargs):
175178
self.sector = sector
176179
super().__init__(**kwargs)
@@ -180,10 +183,10 @@ class ULinedef(UBlock):
180183
defaults = {
181184
'special': 0, 'arg0': 0, 'arg1': 0, 'arg2': 0, 'arg3': 0, 'arg4': 0,
182185
'sideback': -1, 'id': -1}
183-
flags = {'_Base':[
184-
'blocking','blockmonsters','twosided',
185-
'dontpegtop','dontpegbottom','secret',
186-
'blocksound','dontdraw','mapped',]}
186+
flags = {'_Base': [
187+
'blocking','blockmonsters','twosided',
188+
'dontpegtop','dontpegbottom','secret',
189+
'blocksound','dontdraw','mapped',]}
187190
flags['Doom'] = flags['_Base'] + ['passuse']
188191
flags['Heretic'] = flags['_Base']
189192
flags['Hexen'] = flags['_Base'] + [
@@ -213,12 +216,9 @@ def __init__(self, v1=None, v2=None, sidefront=None, **kwargs):
213216
class USector(UBlock):
214217
storage = 'sectors'
215218
defaults = {
216-
'heightfloor': 0,
217-
'heightceiling': 0,
218-
'lightlevel': 160,
219-
'special': 0,
220-
'id': 0
221-
}
219+
'heightfloor': 0, 'heightceiling': 0,
220+
'lightlevel': 160, 'special': 0, 'id': 0}
221+
222222
def __init__(self, texturefloor='-', textureceiling='-', **kwargs):
223223
self.texturefloor = texturefloor
224224
self.textureceiling = textureceiling
@@ -325,19 +325,19 @@ def from_lump(self, lumpgroup, namespace=None):
325325
def from_oldformat(self, lumpgroup, namespace=None):
326326
"""Import a classic format (Doom or ZDoom/Hexen) map.
327327
328-
For ZDoom maps, deprecated line specials (such as Line_SetIdentification) will
329-
automatically be translated to the UDMF equivalent.
328+
For ZDoom maps, deprecated line specials (such as Line_SetIdentification)
329+
will automatically be translated to the UDMF equivalent.
330330
331-
If namespace is not specified, it will be given a default value based on the map's
332-
original format (vanilla or ZDoom/Hexen)."""
331+
If namespace is not specified, it will be given a default value based on
332+
the map's original format (vanilla or ZDoom/Hexen)."""
333333
m = MapEditor(lumpgroup)
334334
self.vertexes = []
335335
self.sidedefs = []
336336
self.linedefs = []
337337
self.sectors = []
338338
self.things = []
339339
self.namespace = namespace
340-
340+
341341
hexencompat = 'BEHAVIOR' in lumpgroup
342342
if namespace not in udmf_namespaces:
343343
namespace = 'ZDoom' if hexencompat else udmf_namespaces[0]
@@ -354,7 +354,7 @@ def from_oldformat(self, lumpgroup, namespace=None):
354354
for thing in m.things:
355355
block = UThing(float(thing.x), float(thing.y), thing.type)
356356
self.things.append(block)
357-
357+
358358
if thing.angle != 0:
359359
block.angle = thing.angle
360360

@@ -381,12 +381,12 @@ def from_oldformat(self, lumpgroup, namespace=None):
381381

382382
if linedef.back != Linedef.NONE:
383383
block.sideback = linedef.back
384-
384+
385385
for f in range(len(ULinedef.flags[namespace])):
386386
flag = ULinedef.flags[namespace][f]
387387
if flag:
388388
setattr(block, flag, bool(linedef.flags & (1 << f)))
389-
389+
390390
if hexencompat:
391391
if linedef.action == 121: # Line_SetIdentification
392392
block.id = linedef.arg0 + linedef.arg4 * 256
@@ -397,11 +397,11 @@ def from_oldformat(self, lumpgroup, namespace=None):
397397
for i in range(5):
398398
key = 'arg{0}'.format(i)
399399
setattr(block, key, getattr(linedef, key))
400-
400+
401401
trigger = ((linedef.flags & 0x1c00) >> 10)
402402
if trigger < len(ULinedef.triggers_hexen):
403403
setattr(block, ULinedef.triggers_hexen[trigger], True)
404-
404+
405405
# handle line specials that set a line ID, extended flags, etc. based on the zdoom udmf spec
406406
if linedef.action == 1: # Polyobj_StartLine
407407
block.id = linedef.arg3
@@ -482,6 +482,7 @@ def to_textmap(self):
482482
for sector in self.sectors:
483483
out += 'sector ' + sector.to_textmap(fallback)
484484
return out
485+
485486
def serialize_field(self, value):
486487
if isinstance(value, UVertex):
487488
return self.vertexes.index(value)

readme.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ Originally by Fredrik Johansson (http://fredrikj.net).
44
Maintained since 0.3.0 by Devin Acker (http://revenant1.net).
55

66
Use `pip install omgifol` to install. See manual.html (and module/class
7-
docstrings) for usage notes. Requires Python 2.7 or Python 3.x.
7+
docstrings) for usage notes. Requires Python 3.x.
88

99
Some planned things:
1010

11-
- UDMF map support
1211
- Basic Doom 0.4 / 0.5 wad support in master
1312
- Basic Doom 64 wad support
1413
- support for non-vanilla/Boom maps in lineinfo

0 commit comments

Comments
 (0)