mirror of
https://github.com/freedoom/freedoom.git
synced 2025-08-30 17:16:55 -04:00
tools: Remove cleanroom script.
This was written by Jon a long time ago to do a "clean room" recreation of the Freedoom texture lumps. I'm not sure it was ever actually finished or the result used, but regardless, it doesn't seem necessary to keep the script around any more.
This commit is contained in:
parent
e650048bce
commit
0ba0dbaa84
9 changed files with 0 additions and 2366 deletions
|
@ -1,13 +0,0 @@
|
|||
TODO
|
||||
|
||||
for freedoom purpose:
|
||||
patch re-ordering
|
||||
mark patch as done
|
||||
hide "done" patches
|
||||
load in WIP file
|
||||
update progress bar
|
||||
perhaps nice:
|
||||
drag arrange patches
|
||||
patch gallery
|
||||
for general use:
|
||||
doom WAD IO
|
|
@ -1,287 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
|
||||
<!--Generated with glade3 3.4.1 on Mon Feb 18 19:07:52 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>
|
||||
<widget class="GtkMenuBar" id="menubar1">
|
||||
<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="GtkMenuItem" id="menuitem1">
|
||||
<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="label" translatable="yes">_File</property>
|
||||
<property name="use_underline">True</property>
|
||||
<child>
|
||||
<widget class="GtkMenu" id="menu1">
|
||||
<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="GtkImageMenuItem" id="imagemenuitem1">
|
||||
<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="label" translatable="yes">gtk-new</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkImageMenuItem" id="open_menu_item">
|
||||
<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="label" translatable="yes">gtk-open</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkImageMenuItem" id="save_menu_item">
|
||||
<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="label" translatable="yes">gtk-save</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkImageMenuItem" id="saveas_menu_item">
|
||||
<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="label" translatable="yes">gtk-save-as</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkSeparatorMenuItem" id="separatormenuitem1">
|
||||
<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>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkImageMenuItem" id="quit_menu_item">
|
||||
<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="label" translatable="yes">gtk-quit</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkMenuItem" id="menuitem2">
|
||||
<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="label" translatable="yes">_Edit</property>
|
||||
<property name="use_underline">True</property>
|
||||
<child>
|
||||
<widget class="GtkMenu" id="menu2">
|
||||
<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="GtkImageMenuItem" id="imagemenuitem6">
|
||||
<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="label" translatable="yes">gtk-cut</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkImageMenuItem" id="imagemenuitem7">
|
||||
<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="label" translatable="yes">gtk-copy</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkImageMenuItem" id="imagemenuitem8">
|
||||
<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="label" translatable="yes">gtk-paste</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkImageMenuItem" id="imagemenuitem9">
|
||||
<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="label" translatable="yes">gtk-delete</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkMenuItem" id="menuitem4">
|
||||
<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="label" translatable="yes">_Help</property>
|
||||
<property name="use_underline">True</property>
|
||||
<child>
|
||||
<widget class="GtkMenu" id="menu3">
|
||||
<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="GtkImageMenuItem" id="imagemenuitem10">
|
||||
<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="label" translatable="yes">gtk-about</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkProgressBar" id="progressbar1">
|
||||
<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="text" translatable="yes"></property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</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="GtkScrolledWindow" id="scrolledwindow2">
|
||||
<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="texture_list">
|
||||
<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>
|
||||
</child>
|
||||
<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>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</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">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox2">
|
||||
<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="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="all_patch_tree">
|
||||
<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>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkImage" id="current_patch">
|
||||
<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>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkTreeView" id="this_patch_tree">
|
||||
<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>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkScrolledWindow" id="scrolledwindow3">
|
||||
<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="selected_patches">
|
||||
<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">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</glade-interface>
|
|
@ -1,42 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
# cleanroom.py: a clean-room IWAD texture1 lump constructor
|
||||
from doom import Patch, Texture
|
||||
|
||||
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()))
|
|
@ -1,54 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
from doom import Patch, Texture
|
||||
|
||||
import sys,re
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
sys.stderr.write("usage: sw1_sw2.py <infile>\n")
|
||||
sys.exit()
|
||||
|
||||
infile = sys.argv[1]
|
||||
|
||||
# TODO: a generalized form of this para should probably be moved into the
|
||||
# Texture class
|
||||
texture1 = file(infile, "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
|
||||
|
||||
oldtex = file("../../textures/combined.txt", "r").read()
|
||||
patches = []
|
||||
texline = ''
|
||||
for line in oldtex.split("\n"):
|
||||
# start of a patch line
|
||||
if len(line) > 0 and line[0] == "*":
|
||||
patches.append(line)
|
||||
else:
|
||||
# end of a texture definition and we had just one patch
|
||||
if 1 == len(patches):
|
||||
print patches[0]
|
||||
patches = []
|
||||
texline = ''
|
||||
# end of a texture definition,look up the patches
|
||||
elif texline != '':
|
||||
bits = texline.split()
|
||||
if bits[0] in textures:
|
||||
texture = textures[bits[0]]
|
||||
print '\n'.join(map(str,texture.patches))
|
||||
texline = ''
|
||||
else:
|
||||
sys.stderr.write("uh oh, no idea of patches for %s"%bits[0])
|
||||
|
||||
# start of a texture definition
|
||||
if re.match(r'^[A-Z]', line):
|
||||
texline = line
|
||||
print line
|
|
@ -1,26 +0,0 @@
|
|||
"""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)
|
||||
|
|
@ -1,90 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# example images.py
|
||||
|
||||
import pygtk
|
||||
pygtk.require('2.0')
|
||||
import gtk
|
||||
|
||||
class ImagesExample:
|
||||
# when invoked (via signal delete_event), terminates the application.
|
||||
def close_application(self, widget, event, data=None):
|
||||
gtk.main_quit()
|
||||
return False
|
||||
|
||||
def __init__(self):
|
||||
# create the main window, and attach delete_event signal to terminating
|
||||
# the application
|
||||
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
|
||||
window.connect("delete_event", self.close_application)
|
||||
window.set_border_width(10)
|
||||
window.show()
|
||||
|
||||
# a horizontal box to hold the buttons
|
||||
hbox = gtk.HBox()
|
||||
hbox.show()
|
||||
window.add(hbox)
|
||||
|
||||
# create several images with data from files and load images into
|
||||
# buttons
|
||||
baseimage = gtk.Image()
|
||||
baseimage.set_from_file("../../patches/wall40_1.gif")
|
||||
pixbuf = baseimage.get_pixbuf()
|
||||
if pixbuf:
|
||||
scale = 1
|
||||
baseimage.set_from_pixbuf(pixbuf.scale_simple(
|
||||
pixbuf.get_width() * scale,
|
||||
pixbuf.get_height() * scale,
|
||||
gtk.gdk.INTERP_NEAREST
|
||||
))
|
||||
baseimage.show()
|
||||
|
||||
basepatch = gtk.Image()
|
||||
basepatch.set_from_file("../../patches/ps20a0.gif")
|
||||
pb = basepatch.get_pixbuf()
|
||||
basepatch.set_from_pixbuf(pb.scale_simple(
|
||||
pb.get_width() * scale,
|
||||
pb.get_height() * scale,
|
||||
gtk.gdk.INTERP_NEAREST
|
||||
))
|
||||
pb = basepatch.get_pixbuf()
|
||||
pb = pb.add_alpha(True,chr(0),chr(255),chr(255))
|
||||
|
||||
for x,y in [(0,0), (24,24), (104,16), (24,104), (-16,0), (0,-16)]:
|
||||
x *= scale
|
||||
y *= scale
|
||||
image = gtk.Image()
|
||||
image.set_from_pixbuf(baseimage.get_pixbuf().copy())
|
||||
image.show()
|
||||
|
||||
dest_x = max(0, x)
|
||||
dest_y = max(0, y)
|
||||
dest_height = min(pb.get_height(), image.get_pixbuf().get_height() - dest_y)
|
||||
dest_width = min(pb.get_width(), image.get_pixbuf().get_width() - dest_x)
|
||||
if x < 0:
|
||||
dest_width += x
|
||||
if y < 0:
|
||||
dest_height += y
|
||||
offset_x = x
|
||||
offset_y = y
|
||||
|
||||
pb.composite(
|
||||
image.get_pixbuf(),
|
||||
dest_x, dest_y, dest_width, dest_height,
|
||||
offset_x, offset_y, 1, 1, # scale
|
||||
gtk.gdk.INTERP_NEAREST, 255
|
||||
)
|
||||
|
||||
# a button to contain the image widget
|
||||
button = gtk.Button()
|
||||
button.add(image)
|
||||
button.show()
|
||||
hbox.pack_start(button)
|
||||
|
||||
def main():
|
||||
gtk.main()
|
||||
return 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
ImagesExample()
|
||||
main()
|
File diff suppressed because it is too large
Load diff
|
@ -1,63 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
from doom import Patch, Texture
|
||||
import sys,re
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
sys.stderr.write("usage: sw1_sw2.py <infile>\n")
|
||||
sys.exit()
|
||||
|
||||
infile = sys.argv[1]
|
||||
|
||||
# TODO: a generalized form of this para should probably be moved into the
|
||||
# Texture class
|
||||
texture1 = file(infile, "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
|
||||
|
||||
# a list of known switch textures
|
||||
switches = {
|
||||
"SW1S0": "SW1S1",
|
||||
"SW2_1": "SW2_2",
|
||||
"SW2_3": "SW2_4",
|
||||
"SW2_5": "SW2_6",
|
||||
"SW2_7": "SW2_8",
|
||||
"SW2S0": "SW2S1",
|
||||
"SW3S0": "SW3S1",
|
||||
"SW4S0": "SW4S1"
|
||||
}
|
||||
# include the opposites
|
||||
switches.update(dict([ (v,k) for k,v in switches.items() ]))
|
||||
|
||||
for sw1 in [x for x in textures.values() if re.match("^SW1", x.name)]:
|
||||
sw2n = sw1.name.replace("SW1","SW2")
|
||||
if not textures.has_key(sw2n):
|
||||
sys.stderr.write("error: %s not defined, skipping\n" % sw2n)
|
||||
continue
|
||||
sw2 = textures[sw2n]
|
||||
if len(sw2.patches) != 0:
|
||||
sys.stderr.write("error: %s has patches (%s)\n" % \
|
||||
(sw2.name, map(lambda x: x.name,sw2.patches)))
|
||||
continue
|
||||
|
||||
# now the magic happens
|
||||
for patch in sw1.patches:
|
||||
name = patch.name
|
||||
if switches.has_key(patch.name):
|
||||
name = switches[patch.name]
|
||||
sw2.patches.append(Patch(name, patch.yoff,patch.xoff))
|
||||
textures[sw2n] = sw2
|
||||
|
||||
a = textures.values()
|
||||
a.sort(lambda a,b: cmp(a.name,b.name))
|
||||
sys.stdout.write(''.join(map(str,a)))
|
|
@ -1,362 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
import sys
|
||||
import gtk
|
||||
import gtk.glade
|
||||
|
||||
from doom import Patch, Texture
|
||||
|
||||
class HellowWorldGTK:
|
||||
"""This is an Hello World GTK application"""
|
||||
|
||||
def parse_texture_file(self,fname):
|
||||
texture1 = file(fname, "r").read()
|
||||
self.textures = {}
|
||||
self.wip_textures = {}
|
||||
textures = self.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])
|
||||
self.wip_textures[line[0]] = Texture(line[0],line[1],line[2])
|
||||
textures[line[0]] = current
|
||||
# now weed out the 1-patch ones
|
||||
keys = self.textures.keys()
|
||||
for key in keys:
|
||||
if 1 == len(self.textures[key].patches):
|
||||
del self.textures[key]
|
||||
del self.wip_textures[key]
|
||||
|
||||
def lhs_callback(self, treeview):
|
||||
offs,col = treeview.get_cursor()
|
||||
# TODO: sanity check the insane subscripting here
|
||||
row = treeview.get_model()[offs[0]][0]
|
||||
self.set_texture(row)
|
||||
# clear out the patch-list for this texture
|
||||
selected_patches = self.wTree.get_widget("selected_patches")
|
||||
model = selected_patches.get_model()
|
||||
model.clear()
|
||||
wip_texture = self.wip_textures[row]
|
||||
for patch in wip_texture.patches:
|
||||
model.append(None, [ patch.name, patch.xoff, patch.yoff ])
|
||||
|
||||
|
||||
def rhs_drag_data_get(self,widget,ctx,selection,targettype,eventtime):
|
||||
print "ZOMG"
|
||||
|
||||
# patch selected on rhs
|
||||
def rhs_select_cb(self, rhs, path, view_column):
|
||||
model = rhs.get_model()
|
||||
row = model[path[0]][0]
|
||||
selected_patches = self.wTree.get_widget("selected_patches")
|
||||
model = selected_patches.get_model()
|
||||
model.append(None, [ row, 0, 0 ])
|
||||
# redraw the rhs. a bit hacky
|
||||
current_texture_name = self.current_texture()
|
||||
current_texture = self.wip_textures[current_texture_name]
|
||||
current_texture.patches.append(Patch(row,0,0))
|
||||
self.init_texture_pixbuf(self.wip_textures[current_texture_name])
|
||||
# this redraws the lhs too, unnecessarily
|
||||
self.set_texture(current_texture_name)
|
||||
|
||||
def current_texture(self):
|
||||
"""return the name of the currently selected texture"""
|
||||
lhs = self.wTree.get_widget("texture_list")
|
||||
offs,col = lhs.get_cursor()
|
||||
lhs_model = lhs.get_model()
|
||||
return lhs_model[offs[0]][0]
|
||||
|
||||
def rhs_cursor_cb(self, rhs):
|
||||
offs,col = rhs.get_cursor()
|
||||
rhs_model = rhs.get_model()
|
||||
row = rhs_model[offs[0]][0]
|
||||
|
||||
image = self.wTree.get_widget("current_patch")
|
||||
image.set_from_file("../../patches/" + row.lower() + ".gif")
|
||||
# scale the texture up
|
||||
pixbuf = image.get_pixbuf()
|
||||
if pixbuf:
|
||||
scale = 2
|
||||
image.set_from_pixbuf(pixbuf.scale_simple(
|
||||
pixbuf.get_width() * scale,
|
||||
pixbuf.get_height() * scale,
|
||||
gtk.gdk.INTERP_NEAREST
|
||||
))
|
||||
|
||||
def init_texture_pixbuf(self, texture):
|
||||
for patch in texture.patches:
|
||||
# read the patches into pixbufs
|
||||
# a horrid hack to get them client->server side
|
||||
image = gtk.Image()
|
||||
if not self.patch_pixbufs.has_key(patch.name):
|
||||
image.set_from_file("../../patches/" + patch.name.lower() + ".gif")
|
||||
pb = image.get_pixbuf()
|
||||
self.patch_pixbufs[patch.name] = pb.add_alpha(True,chr(0),chr(255),chr(255))
|
||||
|
||||
texbuf = gtk.gdk.Pixbuf(
|
||||
self.patch_pixbufs.values()[0].get_colorspace(),
|
||||
self.patch_pixbufs.values()[0].get_has_alpha(),
|
||||
self.patch_pixbufs.values()[0].get_bits_per_sample(),
|
||||
int(texture.width),
|
||||
int(texture.height))
|
||||
|
||||
texbuf.fill(0x00ffffff)
|
||||
texbuf = texbuf.add_alpha(True,chr(0),chr(255),chr(255))
|
||||
texture.pixbuf = texbuf
|
||||
|
||||
# copy each patch into the texture pixbuf
|
||||
for patch in texture.patches:
|
||||
|
||||
dest_x = max(0, patch.xoff)
|
||||
dest_y = max(0, patch.yoff)
|
||||
dest_height = min(
|
||||
self.patch_pixbufs[patch.name].get_height(),
|
||||
texbuf.get_height() - dest_y
|
||||
)
|
||||
dest_width = min(
|
||||
self.patch_pixbufs[patch.name].get_width(),
|
||||
texbuf.get_width() - dest_x
|
||||
)
|
||||
if patch.xoff < 0:
|
||||
dest_width += patch.xoff
|
||||
if patch.yoff < 0:
|
||||
dest_height += patch.yoff
|
||||
offset_x = patch.xoff
|
||||
offset_y = patch.yoff
|
||||
pb = self.patch_pixbufs[patch.name]
|
||||
pb.composite(
|
||||
texbuf,
|
||||
dest_x, dest_y, dest_width, dest_height,
|
||||
offset_x, offset_y, 1, 1, # scale
|
||||
gtk.gdk.INTERP_NEAREST, 255)
|
||||
|
||||
def set_texture(self, name):
|
||||
# parse the example texture, fetch the width,height;
|
||||
# create Patch objects and stuff them into a list
|
||||
texture = self.textures[name]
|
||||
image = self.wTree.get_widget("orig_texture")
|
||||
|
||||
if not texture.pixbuf:
|
||||
self.init_texture_pixbuf(texture)
|
||||
|
||||
image.set_from_pixbuf(texture.pixbuf)
|
||||
self.scale_up_texture(image)
|
||||
|
||||
# now for the wip side
|
||||
wip_image = self.wTree.get_widget("wip_texture")
|
||||
wip_texture = self.wip_textures[name]
|
||||
if not wip_texture.pixbuf:
|
||||
self.init_texture_pixbuf(wip_texture)
|
||||
wip_image.set_from_pixbuf(wip_texture.pixbuf)
|
||||
self.scale_up_texture(wip_image)
|
||||
|
||||
|
||||
def scale_up_texture(self, image):
|
||||
# scale the texture up
|
||||
pixbuf = image.get_pixbuf()
|
||||
if pixbuf:
|
||||
scale = 2
|
||||
image.set_from_pixbuf(pixbuf.scale_simple(
|
||||
pixbuf.get_width() * scale,
|
||||
pixbuf.get_height() * scale,
|
||||
gtk.gdk.INTERP_NEAREST
|
||||
))
|
||||
|
||||
def patch_list_key(self,treeview,event):
|
||||
"""handle key press events on the patch list"""
|
||||
if gtk.keysyms.Delete == event.keyval:
|
||||
offs,col = treeview.get_cursor()
|
||||
# remove from data structure
|
||||
texture = self.wip_textures[self.current_texture()]
|
||||
del texture.patches[offs[0]]
|
||||
# remove from UI
|
||||
model = treeview.get_model()
|
||||
iter = model.get_iter(offs)
|
||||
model.remove(iter)
|
||||
# redraw RHS
|
||||
self.init_texture_pixbuf(texture)
|
||||
wip_image = self.wTree.get_widget("wip_texture")
|
||||
wip_image.set_from_pixbuf(texture.pixbuf)
|
||||
self.scale_up_texture(wip_image)
|
||||
|
||||
def cell_callback(self, cellrenderertext, path, new_text):
|
||||
"""cell edited in patch list"""
|
||||
current_texture = self.wip_textures[self.current_texture()]
|
||||
path = int(path)
|
||||
new_text = int(new_text)
|
||||
if self.cellrendererwidth == cellrenderertext:
|
||||
current_texture.patches[path].xoff = new_text
|
||||
column = 1
|
||||
else:
|
||||
current_texture.patches[path].yoff = new_text
|
||||
column = 2
|
||||
self.init_texture_pixbuf(current_texture)
|
||||
wip_image = self.wTree.get_widget("wip_texture")
|
||||
wip_image.set_from_pixbuf(current_texture.pixbuf)
|
||||
self.scale_up_texture(wip_image)
|
||||
|
||||
# update the model now
|
||||
selected_patches = self.wTree.get_widget("selected_patches")
|
||||
model = selected_patches.get_model()
|
||||
iter = model.get_iter(path)
|
||||
model.set_value(iter, column, new_text)
|
||||
|
||||
|
||||
def patch_list_reordered(self,treemodel,path,iter,new_order):
|
||||
print "ZOMG"
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.gladefile = "cleanroom.glade"
|
||||
self.wTree = gtk.glade.XML(self.gladefile,"window1")
|
||||
self.image1 = self.wTree.get_widget("orig_texture")
|
||||
|
||||
window = self.wTree.get_widget("window1")
|
||||
window.resize(1024,768)
|
||||
|
||||
self.patch_pixbufs = {}
|
||||
|
||||
# read in the IWAD texture1 lump and populate our LHS list
|
||||
self.parse_texture_file("../../textures/combined.txt")
|
||||
lhs = self.wTree.get_widget("texture_list")
|
||||
treestore = gtk.TreeStore(str)
|
||||
tmp_texnames = self.textures.keys()
|
||||
tmp_texnames.sort()
|
||||
for name in tmp_texnames:
|
||||
if len(self.textures[name].patches) > 1:
|
||||
treestore.append(None, [ name ])
|
||||
column = gtk.TreeViewColumn('Texture name ')
|
||||
lhs.set_model(treestore)
|
||||
lhs.append_column(column)
|
||||
cell = gtk.CellRendererText()
|
||||
column.pack_start(cell, False)
|
||||
column.add_attribute(cell, "text", 0)
|
||||
lhs.connect("cursor-changed", self.lhs_callback)
|
||||
|
||||
# prepare the patch list
|
||||
patch_list = self.wTree.get_widget("selected_patches")
|
||||
treestore = gtk.TreeStore(str,int,int)
|
||||
column = gtk.TreeViewColumn('Patch name')
|
||||
patch_list.set_model(treestore)
|
||||
patch_list.append_column(column)
|
||||
cell = gtk.CellRendererText()
|
||||
column.pack_start(cell, False)
|
||||
column.add_attribute(cell, "text", 0)
|
||||
|
||||
cell = gtk.CellRendererText()
|
||||
self.cellrendererwidth = cell
|
||||
cell.set_property("editable", True)
|
||||
cell.connect("edited", self.cell_callback)
|
||||
column = gtk.TreeViewColumn('X offset')
|
||||
patch_list.append_column(column)
|
||||
column.pack_start(cell, False)
|
||||
column.add_attribute(cell, "text", 1)
|
||||
|
||||
cell = gtk.CellRendererText()
|
||||
cell.set_property("editable", True)
|
||||
cell.connect("edited", self.cell_callback)
|
||||
column = gtk.TreeViewColumn('Y offset')
|
||||
patch_list.append_column(column)
|
||||
column.pack_start(cell, False)
|
||||
column.add_attribute(cell, "text", 2)
|
||||
|
||||
patch_list.connect("key-press-event", self.patch_list_key)
|
||||
patch_list.set_reorderable(True)
|
||||
treestore.connect("rows-reordered", self.patch_list_reordered)
|
||||
|
||||
# populate the RHS list with patch names
|
||||
# yes, I learnt perl once.
|
||||
patches = {}
|
||||
for texture in self.textures.values():
|
||||
for patch in texture.patches:
|
||||
patches[patch.name] = 1
|
||||
patches = patches.keys()
|
||||
rhs = self.wTree.get_widget("all_patch_tree")
|
||||
treestore = gtk.TreeStore(str)
|
||||
patches.sort()
|
||||
for name in patches:
|
||||
treestore.append(None, [ name ])
|
||||
column = gtk.TreeViewColumn('Patch name')
|
||||
rhs.set_model(treestore)
|
||||
rhs.append_column(column)
|
||||
cell = gtk.CellRendererText()
|
||||
column.pack_start(cell, False)
|
||||
column.add_attribute(cell, "text", 0)
|
||||
rhs.connect("cursor-changed", self.rhs_cursor_cb)
|
||||
rhs.connect("row-activated", self.rhs_select_cb)
|
||||
|
||||
image = self.wTree.get_widget("current_patch")
|
||||
image.drag_source_set(gtk.gdk.BUTTON1_MASK, [('text/plain', 0,
|
||||
80)], 0) # 80 = target type text
|
||||
image.connect("drag_data_get", self.rhs_drag_data_get)
|
||||
|
||||
self.set_up_progressbar()
|
||||
|
||||
self.wTree.get_widget("window1").connect("destroy", gtk.main_quit)
|
||||
self.wTree.get_widget("quit_menu_item").connect("activate", gtk.main_quit)
|
||||
self.wTree.get_widget("saveas_menu_item").connect("activate", self.saveas_activated)
|
||||
self.wTree.get_widget("save_menu_item").connect("activate", self.save_activated)
|
||||
self.wTree.get_widget("open_menu_item").connect("activate", self.open_activated)
|
||||
|
||||
# select the top-most texture
|
||||
lhs.set_cursor( (0,) , None, False)
|
||||
|
||||
def set_up_progressbar(self):
|
||||
"""We've "done" any textures in wip set with >0 patches"""
|
||||
bar = self.wTree.get_widget("progressbar1")
|
||||
done = len(filter(lambda x: len(x.patches) > 0, self.wip_textures.values()))
|
||||
bar.set_fraction(float(done) / len(self.textures))
|
||||
bar.set_text("%d/%d" % (done, len(self.textures)))
|
||||
|
||||
def saveas_activated(self, arg):
|
||||
filesel = gtk.FileChooserDialog(action=gtk.FILE_CHOOSER_ACTION_SAVE,
|
||||
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
||||
gtk.STOCK_SAVE, gtk.RESPONSE_OK))
|
||||
if filesel.run() == gtk.RESPONSE_OK:
|
||||
self.filename = filesel.get_filename()
|
||||
filesel.destroy()
|
||||
self.save_activated(arg)
|
||||
|
||||
def save_activated(self, arg):
|
||||
if not hasattr(self, "filename"):
|
||||
self.saveas_activated(arg)
|
||||
saveme = self.wip_textures.values()
|
||||
saveme.sort(lambda a,b: cmp(a.name,b.name))
|
||||
writetome = open(self.filename,"w")
|
||||
writetome.write("".join(map(str,saveme)))
|
||||
writetome.close()
|
||||
|
||||
def open_activated(self,arg):
|
||||
filesel = \
|
||||
gtk.FileChooserDialog(action=gtk.FILE_CHOOSER_ACTION_OPEN,
|
||||
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
||||
gtk.STOCK_OPEN, gtk.RESPONSE_OK))
|
||||
if filesel.run() == gtk.RESPONSE_OK:
|
||||
self.filename = filesel.get_filename()
|
||||
filesel.destroy()
|
||||
print self.filename
|
||||
|
||||
texture1 = file(self.filename, "r").read()
|
||||
self.wip_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])
|
||||
self.wip_textures[line[0]] = current
|
||||
self.set_up_progressbar()
|
||||
|
||||
if __name__ == "__main__":
|
||||
hwg = HellowWorldGTK()
|
||||
gtk.main()
|
Loading…
Add table
Add a link
Reference in a new issue