mirror of
https://github.com/freedoom/freedoom.git
synced 2025-09-01 13:25:46 -04:00
start rebuilding tmp_* in MVC format, first, model
This commit is contained in:
parent
5efaa7e2be
commit
a2ac1d5777
2 changed files with 64 additions and 1 deletions
|
@ -1,5 +1,42 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
# cleanroom.py: a clean-room IWAD texture1 lump constructor
|
||||
from doom import Patch, Texture
|
||||
|
||||
print "hello world"
|
||||
class Model:
|
||||
"""The Model represents the original texture list,
|
||||
the WIP texture list, and various bits of state.
|
||||
"""
|
||||
def parse_texture_file(self,fname):
|
||||
texture1 = file(fname, "r").read()
|
||||
textures = {}
|
||||
current = None
|
||||
for line in texture1.split("\n"):
|
||||
if len(line) == 0 or line[0] == ";" or line[0] == "#":
|
||||
continue
|
||||
elif line[0] == "*" and current:
|
||||
junk,name,y,x= line.split()
|
||||
current.patches.append(Patch(name,int(x),int(y)))
|
||||
else:
|
||||
line = line.split()
|
||||
current = Texture(line[0],line[1],line[2])
|
||||
textures[line[0]] = current
|
||||
return textures
|
||||
|
||||
def new_wip_textures(self):
|
||||
for texture in self.orig_textures.values():
|
||||
self.wip_textures[texture.name] = \
|
||||
Texture(texture.name, texture.width, texture.height)
|
||||
|
||||
def __init__(self):
|
||||
self.orig_textures = \
|
||||
self.parse_texture_file("../../textures/combined.txt")
|
||||
self.wip_textures = {}
|
||||
|
||||
model = Model()
|
||||
print "\n\n\torig\n\n"
|
||||
print "".join(map(str, model.orig_textures.values()))
|
||||
|
||||
print "\n\n\tnew\n\n"
|
||||
model.new_wip_textures()
|
||||
print "".join(map(str, model.wip_textures.values()))
|
||||
|
|
26
tools/cleanroom/doom.py
Normal file
26
tools/cleanroom/doom.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
"""A module for manipulating Doom data structures."""
|
||||
|
||||
class Patch:
|
||||
def __init__(self, n,x,y):
|
||||
self.name = n
|
||||
self.yoff = x
|
||||
self.xoff =y
|
||||
|
||||
def __str__(self):
|
||||
return "*\t%8s\t\t%d\t%d" % (self.name,self.xoff,self.yoff)
|
||||
|
||||
class Texture:
|
||||
def __init__(self,name,width,height):
|
||||
self.name = name
|
||||
self.width = width
|
||||
self.height = height
|
||||
self.patches = []
|
||||
self.pixbuf = None
|
||||
|
||||
def __str__(self):
|
||||
me = "%8s\t\t%d\t%d\n" % (self.name,int(self.width),int(self.height))
|
||||
kids = "\n".join(map(str, self.patches))
|
||||
if kids:
|
||||
kids += "\n"
|
||||
return (me + kids)
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue