comparison orpg/gametree/nodehandlers/minilib.py @ 216:a00b40ee92fc beta

Traipse Beta 'OpenRPG' {100430-00} 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 Fix to Game Tree, node ordering on drag and drop corrected
author sirebral
date Fri, 30 Apr 2010 05:40:52 -0500
parents dcae32e219f1
children 24769389a7ba
comparison
equal deleted inserted replaced
213:8b7bb1d72c1c 216:a00b40ee92fc
140 140
141 def new_mini( self, data={}, add=1 ): 141 def new_mini( self, data={}, add=1 ):
142 mini = Element( TAG_MINIATURE ) 142 mini = Element( TAG_MINIATURE )
143 for key in data.keys(): mini.set( key, data[ key ] ) 143 for key in data.keys(): mini.set( key, data[ key ] )
144 for key in CORE_ATTRIBUTES: 144 for key in CORE_ATTRIBUTES:
145 if mini.get( key ) == '': mini.set( key, '0' ) 145 if mini.get( key ) == ('' or None): mini.set( key, '0' )
146 if add: 146 if add:
147 self.add_mini( mini ) 147 self.add_mini( mini )
148 self.add_leaf( mini ) 148 self.add_leaf( mini )
149 return mini 149 return mini
150 150
312 wx.Panel.__init__( self, frame, -1 ) 312 wx.Panel.__init__( self, frame, -1 )
313 self.handler = handler 313 self.handler = handler
314 self.frame = frame 314 self.frame = frame
315 315
316 self.sizer = wx.BoxSizer( wx.VERTICAL ) 316 self.sizer = wx.BoxSizer( wx.VERTICAL )
317
318 self.text = wx.TextCtrl(self, 3, handler.xml.get('name'))
319 self.sizer.Add(wx.StaticText(self, -1, "Title:"), 0, wx.EXPAND)
320 self.sizer.Add(self.text, 0, wx.EXPAND)
321
317 self.grid = minilib_grid( self, handler ) 322 self.grid = minilib_grid( self, handler )
318 323
319 bbox = wx.BoxSizer( wx.HORIZONTAL ) 324 bbox = wx.BoxSizer( wx.HORIZONTAL )
320 newMiniBtn = wx.Button( self, wx.ID_ANY, "New mini" ) 325 newMiniBtn = wx.Button( self, wx.ID_ANY, "New mini" )
321 delMiniBtn = wx.Button( self, wx.ID_ANY, "Del mini" ) 326 delMiniBtn = wx.Button( self, wx.ID_ANY, "Del mini" )
331 self.sizer.Add( bbox, 0) 336 self.sizer.Add( bbox, 0)
332 self.SetSizer(self.sizer) 337 self.SetSizer(self.sizer)
333 self.SetAutoLayout(True) 338 self.SetAutoLayout(True)
334 self.Fit() 339 self.Fit()
335 340
341 self.Bind(wx.EVT_TEXT, self.on_text, id=3)
336 self.Bind(wx.EVT_BUTTON, self.add_mini, newMiniBtn) 342 self.Bind(wx.EVT_BUTTON, self.add_mini, newMiniBtn)
337 self.Bind(wx.EVT_BUTTON, self.del_mini, delMiniBtn) 343 self.Bind(wx.EVT_BUTTON, self.del_mini, delMiniBtn)
338 self.Bind(wx.EVT_BUTTON, self.send_to_map, addMiniBtn) 344 self.Bind(wx.EVT_BUTTON, self.send_to_map, addMiniBtn)
339 self.Bind(wx.EVT_BUTTON, self.send_group_to_map, addBatchBtn) 345 self.Bind(wx.EVT_BUTTON, self.send_group_to_map, addBatchBtn)
340 346
352 358
353 def send_to_map( self, evt=None ): 359 def send_to_map( self, evt=None ):
354 """Event handler for the 'Add 1' button. Sends the 360 """Event handler for the 'Add 1' button. Sends the
355 miniature defined by the currently selected row to the map, once. 361 miniature defined by the currently selected row to the map, once.
356 """ 362 """
357 index = self.grid.GetGridCursorRow() 363 index = self.grid.GetSelectedRows()[0] if len(self.grid.GetSelectedRows()) > 0 else 0
358 self.handler.send_mini_to_map( self.handler.get_mini( index ) ) 364 self.handler.send_mini_to_map( self.handler.get_mini( index ) )
359 365
360 def send_group_to_map( self, evt=None ): 366 def send_group_to_map( self, evt=None ):
361 """Event handler for the 'Add batch' button. Querys the user 367 """Event handler for the 'Add batch' button. Querys the user
362 for a mini count and sends the miniature defined by the currently 368 for a mini count and sends the miniature defined by the currently
368 ( self.grid.getSelectedLabel() ), 'Batch mini add', '2' ) 374 ( self.grid.getSelectedLabel() ), 'Batch mini add', '2' )
369 if dlg.ShowModal() == wx.ID_OK: 375 if dlg.ShowModal() == wx.ID_OK:
370 try: value = eval( dlg.GetValue() ) 376 try: value = eval( dlg.GetValue() )
371 except: value = 0 377 except: value = 0
372 print 'getting selected index for batch send' 378 print 'getting selected index for batch send'
373 index = self.grid.GetGridCursorRow() 379 index = self.grid.GetSelectedRows()[0] if len(self.grid.GetSelectedRows()) > 0 else 0
374 print 'sending batch to map' 380 print 'sending batch to map'
375 self.handler.send_mini_to_map( self.handler.get_mini( index ), value ) 381 self.handler.send_mini_to_map( self.handler.get_mini( index ), value )
382
383 def on_text(self, evt):
384 txt = self.text.GetValue()
385 if txt != "":
386 self.handler.xml.set('name',txt)
387 self.handler.rename(txt)
376 388
377 class minilib_grid(wx.grid.Grid): 389 class minilib_grid(wx.grid.Grid):
378 """A wxGrid subclass designed for editing game tree miniature library 390 """A wxGrid subclass designed for editing game tree miniature library
379 nodes. 391 nodes.
380 """ 392 """
390 self.update_all() 402 self.update_all()
391 self.selectedRow = 0 403 self.selectedRow = 0
392 self.AutoSizeColumns() 404 self.AutoSizeColumns()
393 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) 405 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change)
394 self.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.select_cell) 406 self.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.select_cell)
407 self.Bind(wx.grid.EVT_GRID_LABEL_LEFT_CLICK, self.select_cell)
395 408
396 def update_cols( self ): 409 def update_cols( self ):
397 for n in self.handler.xml.findall(TAG_MINIATURE): 410 for n in self.handler.xml.findall(TAG_MINIATURE):
398 for k in n.keys(): 411 for k in n.keys():
399 if k not in self.keys: self.keys.append( k ) 412 if k not in self.keys: self.keys.append( k )
434 if self.selectedRow > -1: 447 if self.selectedRow > -1:
435 pos = self.selectedRow 448 pos = self.selectedRow
436 list = self.handler.xml.findall(TAG_MINIATURE) 449 list = self.handler.xml.findall(TAG_MINIATURE)
437 self.handler.xml.remove( list[pos] ) 450 self.handler.xml.remove( list[pos] )
438 self.DeleteRows( pos, 1 ) 451 self.DeleteRows( pos, 1 )
439 list = self.getList()
440 del list[ pos ]
441 452
442 def on_cell_change( self, evt ): 453 def on_cell_change( self, evt ):
443 """Event handler for cell selection changes. selected row is used 454 """Event handler for cell selection changes. selected row is used
444 to update data for that row. 455 to update data for that row.
445 """ 456 """