From a2ac1d577712856f6253f650759241b7c1d72ef1 Mon Sep 17 00:00:00 2001 From: Jon Dowland Date: Sun, 3 Feb 2008 16:46:51 +0000 Subject: [PATCH] start rebuilding tmp_* in MVC format, first, model --- tools/cleanroom/cleanroom.py | 39 +++++++++++++++++++++++++++++++++++- tools/cleanroom/doom.py | 26 ++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 tools/cleanroom/doom.py diff --git a/tools/cleanroom/cleanroom.py b/tools/cleanroom/cleanroom.py index 71d1ff21..57810f83 100644 --- a/tools/cleanroom/cleanroom.py +++ b/tools/cleanroom/cleanroom.py @@ -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())) diff --git a/tools/cleanroom/doom.py b/tools/cleanroom/doom.py new file mode 100644 index 00000000..0e037d3d --- /dev/null +++ b/tools/cleanroom/doom.py @@ -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) +