initial import of cleanroom tool

This commit is contained in:
Jon Dowland 2008-01-24 23:18:17 +00:00
parent db75147c51
commit 14e44399a9
4 changed files with 144 additions and 0 deletions

View file

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.4.1 on Thu Jan 24 23:14:02 2008 -->
<glade-interface>
<widget class="GtkWindow" id="window1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<placeholder/>
</child>
<child>
<widget class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkImage" id="orig_texture">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="stock">gtk-missing-image</property>
</widget>
</child>
<child>
<widget class="GtkImage" id="wip_texture">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="stock">gtk-missing-image</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<child>
<widget class="GtkTreeView" id="treeview1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="headers_clickable">True</property>
</widget>
</child>
</widget>
<packing>
<property name="position">2</property>
</packing>
</child>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</widget>
</child>
</widget>
</glade-interface>

View file

@ -0,0 +1,57 @@
#!/usr/bin/python
# cleanroom.py: a clean-room IWAD texture1 lump constructor
from sys import argv, exit
from os import rmdir, mkdir, system, chdir, getcwd
from tempfile import mkdtemp
if len(argv) != 2:
print "usage: cleanroom.py IWAD"
exit(1)
if system("which deutex >/dev/null"):
print "you need to install deutex in the PATH"
exit(1)
iwad = argv[1]
origdir = getcwd()
if iwad[0] != "/":
iwad = origdir + "/" + iwad
tmpdir = mkdtemp()
chdir(tmpdir)
system("deutex -textures -extract " +iwad + " >/dev/null 2>&1")
system("deutex -patches -extract " +iwad + " >/dev/null 2>&1")
# parse the textures data
texture1 = file(tmpdir + "/textures/texture1.txt", "r").read()
class Texture:
def __init__(self,name,width,height):
self.name = name
self.width = width
self.height = height
self.patches = []
textures = []
current = None
for line in texture1.split("\n"):
if len(line) == 0 or line[0] == ";":
continue
elif line[0] == "*" and current:
current.patches.append(line)
else:
line = line.split()
current = Texture(line[0],line[1],line[2])
textures.append(current)
# we are not interested in 1-patch textures
textures = filter(lambda x: len(x.patches) > 1, textures)
print len(textures)
chdir(origdir)
rmdir(tmpdir)

BIN
tools/cleanroom/sw2_1.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 892 B

View file

@ -0,0 +1,20 @@
#!/usr/bin/python
import sys
import gtk
import gtk.glade
class HellowWorldGTK:
"""This is an Hello World GTK application"""
def __init__(self):
self.gladefile = "cleanroom.glade"
self.wTree = gtk.glade.XML(self.gladefile,"window1")
self.image1 = self.wTree.get_widget("orig_texture")
self.image1.set_from_file("sw2_1.gif")
self.wTree.get_widget("window1").connect("destroy", gtk.main_quit)
if __name__ == "__main__":
hwg = HellowWorldGTK()
gtk.main()