From: <Ult...@us...> - 2009-03-14 10:08:21
|
Revision: 1092 http://opengate.svn.sourceforge.net/opengate/?rev=1092&view=rev Author: Ultrasick Date: 2009-03-14 10:08:03 +0000 (Sat, 14 Mar 2009) Log Message: ----------- adding function to add and remove textures to a face Modified Paths: -------------- branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/edit_the_face.py branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/textures.py Modified: branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/edit_the_face.py =================================================================== --- branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/edit_the_face.py 2009-03-14 09:27:32 UTC (rev 1091) +++ branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/edit_the_face.py 2009-03-14 10:08:03 UTC (rev 1092) @@ -214,7 +214,7 @@ # get the relative x coordinate x_relative = x_pixel_number/x_end - for y_pixel_number in range(0, y_end * (1 - x_relative)): + for y_pixel_number in range(0, y_end * (1 - x_relative) + 10): # get the relative y coordinate y_relative = y_pixel_number/y_end Modified: branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/textures.py =================================================================== --- branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/textures.py 2009-03-14 09:27:32 UTC (rev 1091) +++ branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/textures.py 2009-03-14 10:08:03 UTC (rev 1092) @@ -27,61 +27,55 @@ def refresh(self, source): texture = source.get_cursor()[0] + textures = source.get_model().textures - try: - texture[1] - except: - # clear the preview image - self.preview.clear() + if '-' in textures[texture[0]]: + temp = textures[texture[0]].split(' - ') - # a category has been selected, return - return + self.category_name = temp[0] + self.texture_name = temp[1] + else: + try: + texture[1] + except: + # clear the preview image + self.preview.clear() - textures = source.get_model().textures + # a category has been selected, return + return - self.category_name = textures[texture[0]]['name'] - self.texture_name = textures[texture[0]]['textures'][texture[1]] + self.category_name = textures[texture[0]]['name'] + self.texture_name = textures[texture[0]]['textures'][texture[1]] # update the preview image self.preview.set_from_file(path[0] + '/graphic/textures/preview/' + self.category_name + '/' + self.texture_name + '.png') screen.texture_preview = texture_preview(table) -class textures_available: +class textures_used: def __init__(self, parent): + # grab the face + self.face = model['faces'][window.face_number] + # create a TreeStore with one string column to use as the model self.treestore = gtk.TreeStore(str) # create an array for the textures self.treestore.textures = [] - # add the texture categories and the textures - for category_name, category_textures in textures.items(): - category = self.treestore.append(none, [category_name]) - - # insert the category name in the array - self.treestore.textures.append({'name' : category_name, 'textures' : []}) - - # get the category id - category_id = len(self.treestore.textures) - 1 - - for texture_name, texture_function in category_textures.items(): - self.treestore.append(category, [texture_name]) - - # add the texture to the array - self.treestore.textures[category_id]['textures'].append(texture_name) - # create the TreeView self.treeview = gtk.TreeView(self.treestore) - self.treeview.set_size_request(-1, 100) - parent.attach(self.treeview, 0, 1, 1, 2, xpadding = 3) + self.treeview.set_size_request(-1, 155) + parent.attach(self.treeview, 0, 1, 2, 3, xpadding = 3) + self.treeview.set_reorderable(true) self.treeview.show() - # connect the function to refresh the preview image + # connect the functions self.treeview.connect('cursor-changed', screen.texture_preview.refresh) + self.treeview.connect('row-activated', self.remove) - # show "available textures:" - self.tvcolumn = gtk.TreeViewColumn('available textures:') + # show "used textures:" + self.tvcolumn = gtk.TreeViewColumn('used textures:') self.treeview.append_column(self.tvcolumn) # create a CellRendererText to render the data @@ -89,16 +83,51 @@ self.tvcolumn.pack_start(self.cell, true) self.tvcolumn.add_attribute(self.cell, 'text', 0) - def add(self, widget): - pass + # refresh the list + self.refresh() -screen.textures_available = textures_available(table) + def add(self, nonsence1 = none, nonsence2 = none, nonsence3 = none): + try: + screen.texture_preview.category_name + except: + # no texture has been selected jet, return + return -class textures_used: + # add the texture + self.face['textures'].append(screen.texture_preview.category_name + ' - ' + screen.texture_preview.texture_name) + + # refresh the list + self.refresh() + + def remove(self, nonsence1 = none, nonsence2 = none, nonsence3 = none): + try: + screen.texture_preview.category_name + except: + # no texture has been selected jet, return + return + + if (screen.texture_preview.category_name + ' - ' + screen.texture_preview.texture_name) in self.face['textures']: + # remove the texture + del(self.face['textures'][self.face['textures'].index(screen.texture_preview.category_name + ' - ' + screen.texture_preview.texture_name)]) + + # refresh the list + self.refresh() + + def refresh(self): + # clear the list + self.treestore.clear() + + # add the texture categories and the textures + for texture in self.face['textures']: + self.treestore.append(none, [texture]) + + # add the texture to the array + self.treestore.textures.append(texture) + +screen.textures_used = textures_used(table) + +class textures_available: def __init__(self, parent): - # grab the face - self.face = model['faces'][window.face_number] - # create a TreeStore with one string column to use as the model self.treestore = gtk.TreeStore(str) @@ -106,7 +135,7 @@ self.treestore.textures = [] # add the texture categories and the textures - for category_name, category_textures in self.face['textures'].items(): + for category_name, category_textures in textures.items(): category = self.treestore.append(none, [category_name]) # insert the category name in the array @@ -123,16 +152,16 @@ # create the TreeView self.treeview = gtk.TreeView(self.treestore) - self.treeview.set_size_request(-1, 100) - parent.attach(self.treeview, 0, 1, 2, 3, xpadding = 3) - self.treeview.set_reorderable(true) + self.treeview.set_size_request(-1, 155) + parent.attach(self.treeview, 0, 1, 1, 2, xpadding = 3) self.treeview.show() - # connect the function to refresh the preview image + # connect the functions self.treeview.connect('cursor-changed', screen.texture_preview.refresh) + self.treeview.connect('row-activated', screen.textures_used.add) # show "available textures:" - self.tvcolumn = gtk.TreeViewColumn('used textures:') + self.tvcolumn = gtk.TreeViewColumn('available textures:') self.treeview.append_column(self.tvcolumn) # create a CellRendererText to render the data @@ -140,11 +169,8 @@ self.tvcolumn.pack_start(self.cell, true) self.tvcolumn.add_attribute(self.cell, 'text', 0) - def remove(self, widget): - pass +screen.textures_available = textures_available(table) -screen.textures_used = textures_used(table) - class tools: def __init__(self, parent): # create an container to limit the height of the toolbar @@ -169,7 +195,7 @@ image.set_from_file(path[0] + '/graphic/buttons/textures/add.png') # add the "add texture" button - self.bar.append_item('add texture', 'add the selected texture to the face', '', image, screen.textures_available.add) + self.bar.append_item('add texture', 'add the selected texture to the face', '', image, screen.textures_used.add) # insert a spacer #self.bar.append_space() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |