diff orpg/gametree/nodehandlers/minilib.py @ 214:4dc11df853bf alpha

Traipse Alpha 'OpenRPG' {100429-0} Traipse is a distribution of OpenRPG that is designed to be easy to setup and go. Traipse also makes it easy for developers to work on code without fear of sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the code. 'Ornery-Orc's main goal is to offer more advanced features and enhance the productivity of the user. Update Summary (Patch-2) New Features: New Namespace method with two new syntaxes New Namespace Internal is context sensitive, always! New Namespace External is 'as narrow as you make it' New Namespace FutureCheck helps ensure you don't receive an incorrect node New PluginDB access for URL2Link plugin New to Forms, they now show their content in Design Mode New to Update Manager, checks Repo for updates on software start New to Mini Lin node, change title in design mode Fixes: Fix to Server GUI startup errors Fix to Server GUI Rooms tab updating Fix to Chat and Settings if non existant die roller is picked Fix to Dieroller and .open() used with .vs(). Successes are correctly calculated Fix to Alias Lib's Export to Tree, Open, Save features Fix to alias node, now works properly Fix to Splitter node, minor GUI cleanup Fix to Backgrounds not loading through remote loader Fix to Node name errors Fix to rolling dice in chat Whispers Fix to Splitters Sizing issues Fix to URL2Link plugin, modified regex compilation should remove memory leak Fix to mapy.py, a roll back due to zoomed grid issues Fix to whiteboard_handler, Circles work by you clicking the center of the circle Fix to Servers parse_incoming_dom which was outdated and did not respect XML Fix to a broken link in the server welcome message Fix to InterParse and logger requiring traceback Fix to Update Manager Status Bar Fix to failed image and erroneous pop up Fix to Mini Lib node that was preventing use Fix to plugins that parce dice but did not call InterParse Fix to nodes for name changing by double click
author sirebral
date Thu, 29 Apr 2010 23:33:53 -0500
parents b633f4c64aae
children 24769389a7ba
line wrap: on
line diff
--- a/orpg/gametree/nodehandlers/minilib.py	Wed Apr 28 07:54:19 2010 -0500
+++ b/orpg/gametree/nodehandlers/minilib.py	Thu Apr 29 23:33:53 2010 -0500
@@ -142,7 +142,7 @@
         mini = Element( TAG_MINIATURE )
         for key in data.keys(): mini.set( key, data[ key ] )
         for key in CORE_ATTRIBUTES:
-            if mini.get( key ) == '': mini.set( key, '0' )
+            if mini.get( key ) == ('' or None): mini.set( key, '0' )
         if add:
             self.add_mini( mini )
             self.add_leaf( mini )
@@ -314,6 +314,11 @@
         self.frame = frame
 
         self.sizer = wx.BoxSizer( wx.VERTICAL )
+
+        self.text = wx.TextCtrl(self, 3, handler.xml.get('name'))
+        self.sizer.Add(wx.StaticText(self, -1, "Title:"), 0, wx.EXPAND)
+        self.sizer.Add(self.text, 0, wx.EXPAND)
+
         self.grid = minilib_grid( self, handler )
 
         bbox = wx.BoxSizer( wx.HORIZONTAL )
@@ -333,6 +338,7 @@
         self.SetAutoLayout(True)
         self.Fit()
 
+        self.Bind(wx.EVT_TEXT, self.on_text, id=3)
         self.Bind(wx.EVT_BUTTON, self.add_mini, newMiniBtn)
         self.Bind(wx.EVT_BUTTON, self.del_mini, delMiniBtn)
         self.Bind(wx.EVT_BUTTON, self.send_to_map, addMiniBtn)
@@ -354,7 +360,7 @@
         """Event handler for the 'Add 1' button.  Sends the
         miniature defined by the currently selected row to the map, once.
         """
-        index = self.grid.GetGridCursorRow()
+        index = self.grid.GetSelectedRows()[0] if len(self.grid.GetSelectedRows()) > 0 else 0
         self.handler.send_mini_to_map( self.handler.get_mini( index ) )
 
     def send_group_to_map( self, evt=None ):
@@ -370,10 +376,16 @@
                 try: value = eval( dlg.GetValue() )
                 except: value = 0
                 print 'getting selected index for batch send'
-                index = self.grid.GetGridCursorRow()
+                index = self.grid.GetSelectedRows()[0] if len(self.grid.GetSelectedRows()) > 0 else 0
                 print 'sending batch to map'
                 self.handler.send_mini_to_map( self.handler.get_mini( index ), value )
 
+    def on_text(self, evt):
+        txt = self.text.GetValue()
+        if txt != "":
+            self.handler.xml.set('name',txt)
+            self.handler.rename(txt)
+
 class minilib_grid(wx.grid.Grid):
     """A wxGrid subclass designed for editing game tree miniature library
     nodes.
@@ -392,6 +404,7 @@
         self.AutoSizeColumns()
         self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change)
         self.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.select_cell)
+        self.Bind(wx.grid.EVT_GRID_LABEL_LEFT_CLICK, self.select_cell)
 
     def update_cols( self ):
         for n in self.handler.xml.findall(TAG_MINIATURE):
@@ -436,8 +449,6 @@
             list = self.handler.xml.findall(TAG_MINIATURE)
             self.handler.xml.remove( list[pos] )
             self.DeleteRows( pos, 1 )
-            list = self.getList()
-            del list[ pos ]
 
     def on_cell_change( self, evt ):
         """Event handler for cell selection changes. selected row is used