Mercurial > traipse_dev
comparison orpg/gametree/nodehandlers/minilib.py @ 152:6081bdc2b8d5 beta
Traipse Beta 'OpenRPG' {091125-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 (Beta)
Added Bookmarks
Fix to Remote Admin Commands
Minor fix to text based Server
Fix to Pretty Print, from Core
Fix to Splitter Nodes not being created
Fix to massive amounts of images loading, from Core
Added 'boot' command to remote admin
Added confirmation window for sent nodes
Minor changes to allow for portability to an OpenSUSE linux OS
Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG
Zoom Mouse plugin added
Images added to Plugin UI
Switching to Element Tree
Map efficiency, from FlexiRPG
Added Status Bar to Update Manager
default_manifest.xml renamed to default_upmana.xml
Cleaner clode for saved repositories
New TrueDebug Class in orpg_log (See documentation for usage)
Mercurial's hgweb folder is ported to upmana
Pretty important update that can help remove thousands of dead children from your
gametree.
Children, <forms />, <group_atts />, <horizontal />, <cols />, <rows />, <height
/>, etc... are all tags now. Check your gametree and look for dead children!!
New Gametree Recursion method, mapping, and context sensitivity. !Infinite Loops
return error instead of freezing the software!
New Syntax added for custom PC sheets
Tip of the Day added, from Core and community
Fixed Whiteboard ID to prevent random line or text deleting. Modified ID's to
prevent non updated clients from ruining the fix.
author | sirebral |
---|---|
date | Wed, 25 Nov 2009 06:16:35 -0600 |
parents | dcf4fbe09b70 |
children | bf799efe7a8a |
comparison
equal
deleted
inserted
replaced
150:6c5f46a5924b | 152:6081bdc2b8d5 |
---|---|
102 str += "<tr><th width='20%'>Label</th><th>Image</th><th width='65%'>URL</th><th>Unique</th></tr>" | 102 str += "<tr><th width='20%'>Label</th><th>Image</th><th width='65%'>URL</th><th>Unique</th></tr>" |
103 for mini in self.xml.findall(TAG_MINIATURE): | 103 for mini in self.xml.findall(TAG_MINIATURE): |
104 url = mini.get(ATTRIBUTE_URL) | 104 url = mini.get(ATTRIBUTE_URL) |
105 label = mini.get(ATTRIBUTE_NAME) | 105 label = mini.get(ATTRIBUTE_NAME) |
106 flag = 0 | 106 flag = 0 |
107 try: | 107 try: flag = eval( mini.get(ATTRIBUTE_UNIQUE) ) |
108 flag = eval( mini.get(ATTRIBUTE_UNIQUE) ) | 108 except: pass |
109 except: | |
110 pass | |
111 show = 'yes' | 109 show = 'yes' |
112 if flag: | 110 if flag: show = 'no' |
113 show = 'no' | |
114 | |
115 str += """<tr> | 111 str += """<tr> |
116 <td> %s </td> | 112 <td> %s </td> |
117 <td><img src="%s"></td> | 113 <td><img src="%s"></td> |
118 <td> %s </td> | 114 <td> %s </td> |
119 <td> %s </td> | 115 <td> %s </td> |
120 </tr>""" % ( label, url, url, show ) | 116 </tr>""" % ( label, url, url, show ) |
121 | |
122 str += "</table>" | 117 str += "</table>" |
123 return str | 118 return str |
124 | 119 |
125 def html_view( self ): | 120 def html_view( self ): |
126 """see to_html | 121 """see to_html |
127 """ | 122 """ |
128 return self.tohtml() | 123 return self.tohtml() |
129 | 124 |
130 def on_drop(self, evt): | 125 def on_drop(self, evt): |
131 drag_obj = self.tree.drag_obj | 126 drag_obj = self.tree.drag_obj |
132 if drag_obj == self or self.tree.is_parent_node( self.mytree_node, drag_obj.mytree_node ): | 127 if drag_obj == self or self.tree.is_parent_node( self.mytree_node, drag_obj.mytree_node ): return |
133 return | |
134 elif isinstance( drag_obj, map_miniature_nodehandler.map_miniature_handler ): | 128 elif isinstance( drag_obj, map_miniature_nodehandler.map_miniature_handler ): |
135 drop_xml = self.tree.drag_obj.xml#.delete() | 129 drop_xml = self.tree.drag_obj.xml#.delete() |
136 obj = drop_xml[0] | 130 obj = drop_xml[0] |
137 dict = {} | 131 dict = {} |
138 unique = '' | 132 unique = '' |
139 for attrib in obj.keys(): | 133 for attrib in obj.keys(): |
140 key = TO_MINILIB_MAP.get( attrib, attrib ) | 134 key = TO_MINILIB_MAP.get( attrib, attrib ) |
141 if key != None: | 135 if key != None: dict[ key ] = obj.get( attrib ) |
142 dict[ key ] = obj.get( attrib ) | |
143 dict[ ATTRIBUTE_UNIQUE ] = unique | 136 dict[ ATTRIBUTE_UNIQUE ] = unique |
144 self.new_mini( dict ) | 137 self.new_mini( dict ) |
145 else: | 138 else: node_handler.on_drop(self, evt) |
146 node_handler.on_drop(self, evt) | |
147 | 139 |
148 | 140 |
149 def new_mini( self, data={}, add=1 ): | 141 def new_mini( self, data={}, add=1 ): |
150 mini = Element( TAG_MINIATURE ) | 142 mini = Element( TAG_MINIATURE ) |
151 for key in data.keys(): | 143 for key in data.keys(): mini.set( key, data[ key ] ) |
152 mini.set( key, data[ key ] ) | |
153 for key in CORE_ATTRIBUTES: | 144 for key in CORE_ATTRIBUTES: |
154 if mini.get( key ) == '': | 145 if mini.get( key ) == '': mini.set( key, '0' ) |
155 mini.set( key, '0' ) | |
156 if add: | 146 if add: |
157 self.add_mini( mini ) | 147 self.add_mini( mini ) |
158 self.add_leaf( mini ) | 148 self.add_leaf( mini ) |
159 return mini | 149 return mini |
160 | 150 |
167 key = mini.get( ATTRIBUTE_NAME ) | 157 key = mini.get( ATTRIBUTE_NAME ) |
168 self.mydata.append( mini ) | 158 self.mydata.append( mini ) |
169 | 159 |
170 def update_leaves( self ): | 160 def update_leaves( self ): |
171 self.mydata = [] | 161 self.mydata = [] |
172 for n in self.xml.findall(TAG_MINIATURE): | 162 for n in self.xml.findall(TAG_MINIATURE): self.add_leaf( n ) |
173 self.add_leaf( n ) | |
174 | 163 |
175 def on_drag( self, evt ): | 164 def on_drag( self, evt ): |
176 print 'drag event caught' | 165 print 'drag event caught' |
177 | 166 |
178 def send_mini_to_map( self, mini, count=1, addName=True ): | 167 def send_mini_to_map( self, mini, count=1, addName=True ): |
179 if mini == None: | 168 if mini == None: return |
180 return | |
181 if mini.get( ATTRIBUTE_URL ) == '' or mini.get( ATTRIBUTE_URL ) == 'http://': | 169 if mini.get( ATTRIBUTE_URL ) == '' or mini.get( ATTRIBUTE_URL ) == 'http://': |
182 self.chat.ParsePost( self.chat.colorize(self.chat.syscolor, '"%s" is not a valid URL, the mini "%s" will not be added to the map' % ( mini.get( ATTRIBUTE_URL ), mini.get( ATTRIBUTE_NAME ) )) ) | 170 self.chat.ParsePost( self.chat.colorize(self.chat.syscolor, '"%s" is not a valid URL, the mini "%s" will not be added to the map' % ( mini.get( ATTRIBUTE_URL ), mini.get( ATTRIBUTE_NAME ) )) ) |
183 return | 171 return |
184 session = component.get( COMPONENT_SESSION ) | 172 session = component.get( COMPONENT_SESSION ) |
185 if (session.my_role() != session.ROLE_GM) and (session.my_role() != session.ROLE_PLAYER): | 173 if (session.my_role() != session.ROLE_GM) and (session.my_role() != session.ROLE_PLAYER): |
200 msg.init_prop('selected', '1')# this will make the mini initially selected | 188 msg.init_prop('selected', '1')# this will make the mini initially selected |
201 for k in mini_xml.keys(): | 189 for k in mini_xml.keys(): |
202 # translate our attributes to map attributes | 190 # translate our attributes to map attributes |
203 key = FROM_MINILIB_MAP.get( k, k ) | 191 key = FROM_MINILIB_MAP.get( k, k ) |
204 if key != None: | 192 if key != None: |
205 if not addName and k == 'name': | 193 if not addName and k == 'name': pass |
206 pass | 194 else: msg.init_prop( key, mini_xml.get( k ) ) |
207 else: | |
208 msg.init_prop( key, mini_xml.get( k ) ) | |
209 unique = self.is_unique( mini_xml ) | 195 unique = self.is_unique( mini_xml ) |
210 if addName: | 196 if addName: label = mini_xml.get( ATTRIBUTE_NAME ) |
211 label = mini_xml.get( ATTRIBUTE_NAME ) | 197 else: label = '' |
212 else: | |
213 label = '' | |
214 return msg.get_all_xml() | 198 return msg.get_all_xml() |
215 | 199 |
216 def is_unique( self, mini ): | 200 def is_unique( self, mini ): |
217 unique = mini.get( ATTRIBUTE_UNIQUE ) | 201 unique = mini.get( ATTRIBUTE_UNIQUE ) |
218 val = 0 | 202 val = 0 |
257 self.handler = handler | 241 self.handler = handler |
258 self.frame = frame | 242 self.frame = frame |
259 | 243 |
260 self.map = component.get('map') | 244 self.map = component.get('map') |
261 names = self.buildList() | 245 names = self.buildList() |
262 # self.keys = self.list.keys() | |
263 # self.keys.sort() | |
264 | |
265 | 246 |
266 s = self.GetClientSizeTuple() | 247 s = self.GetClientSizeTuple() |
267 | 248 |
268 self.sizer = wx.BoxSizer(wx.VERTICAL) | 249 self.sizer = wx.BoxSizer(wx.VERTICAL) |
269 box = wx.BoxSizer(wx.HORIZONTAL) | 250 box = wx.BoxSizer(wx.HORIZONTAL) |
296 | 277 |
297 def buildList( self ): | 278 def buildList( self ): |
298 """Returns a dictionary of label => game tree miniature DOM node mappings. | 279 """Returns a dictionary of label => game tree miniature DOM node mappings. |
299 """ | 280 """ |
300 self.list = [] | 281 self.list = [] |
301 for mini in self.handler.xml.findall(TAG_MINIATURE): | 282 for mini in self.handler.xml.findall(TAG_MINIATURE): self.list.append( mini.get( ATTRIBUTE_NAME ) ) |
302 self.list.append( mini.get( ATTRIBUTE_NAME ) ) | |
303 return self.list | 283 return self.list |
304 | 284 |
305 def on_close(self, evt): | 285 def on_close(self, evt): |
306 self.frame.Close() | 286 self.frame.Close() |
307 | 287 |
308 def on_ok( self, evt ): | 288 def on_ok( self, evt ): |
309 """Event handler for the 'add' button. | 289 """Event handler for the 'add' button. |
310 """ | 290 """ |
311 btn = self.FindWindowById(evt.GetId()) | 291 btn = self.FindWindowById(evt.GetId()) |
312 sendName = True | 292 sendName = True |
293 try: count = eval( self.count.GetValue() ) | |
294 except: count = 1 | |
313 try: | 295 try: |
314 count = eval( self.count.GetValue() ) | 296 if eval( unique ): count = 1 |
315 except: | |
316 count = 1 | |
317 | |
318 try: | |
319 if eval( unique ): | |
320 count = 1 | |
321 unique = eval( unique ) | 297 unique = eval( unique ) |
322 except: | 298 except: pass |
323 pass | 299 |
324 | 300 if btn.GetLabel() == 'Add No Label': sendName = False |
325 if btn.GetLabel() == 'Add No Label': | 301 for index in self.listbox.GetSelections(): self.handler.send_mini_to_map( self.handler.get_mini( index ), count, sendName ) |
326 sendName = False | |
327 for index in self.listbox.GetSelections(): | |
328 self.handler.send_mini_to_map( self.handler.get_mini( index ), count, sendName ) | |
329 | 302 |
330 | 303 |
331 class minpedit(wx.Panel): | 304 class minpedit(wx.Panel): |
332 """Panel for editing game tree miniature nodes. Node information | 305 """Panel for editing game tree miniature nodes. Node information |
333 is displayed in a grid, and buttons are provided for adding, deleting | 306 is displayed in a grid, and buttons are provided for adding, deleting |
392 if self.grid.GetNumberRows() > 0: | 365 if self.grid.GetNumberRows() > 0: |
393 dlg = wx.TextEntryDialog( self.frame, | 366 dlg = wx.TextEntryDialog( self.frame, |
394 'How many %s\'s do you want to add?' % | 367 'How many %s\'s do you want to add?' % |
395 ( self.grid.getSelectedLabel() ), 'Batch mini add', '2' ) | 368 ( self.grid.getSelectedLabel() ), 'Batch mini add', '2' ) |
396 if dlg.ShowModal() == wx.ID_OK: | 369 if dlg.ShowModal() == wx.ID_OK: |
397 try: | 370 try: value = eval( dlg.GetValue() ) |
398 value = eval( dlg.GetValue() ) | 371 except: value = 0 |
399 except: | |
400 value = 0 | |
401 # for loop in range( 0, value ): | |
402 # self.send_to_map() | |
403 print 'getting selected index for batch send' | 372 print 'getting selected index for batch send' |
404 index = self.grid.GetGridCursorRow() | 373 index = self.grid.GetGridCursorRow() |
405 print 'sending batch to map' | 374 print 'sending batch to map' |
406 self.handler.send_mini_to_map( self.handler.get_mini( index ), value ) | 375 self.handler.send_mini_to_map( self.handler.get_mini( index ), value ) |
407 | 376 |
413 """Constructor. | 382 """Constructor. |
414 """ | 383 """ |
415 wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS ) | 384 wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS ) |
416 self.parent = parent | 385 self.parent = parent |
417 self.handler = handler | 386 self.handler = handler |
418 #self.keys = [ ATTRIBUTE_NAME, ATTRIBUTE_URL, ATTRIBUTE_UNIQUE ] | |
419 self.keys = CORE_ATTRIBUTES | 387 self.keys = CORE_ATTRIBUTES |
420 self.CreateGrid( 1, len( self.keys ) ) | 388 self.CreateGrid( 1, len( self.keys ) ) |
421 # self.SetColLabelValue( 0, 'Name' ) | 389 for key in self.keys: self.SetColLabelValue( self.keys.index( key ), key ) |
422 # self.SetColLabelValue( 1, 'URL' ) | |
423 # self.SetColSize( 1, 250 ) | |
424 # self.SetColLabelValue( 2, 'Unique' ) | |
425 for key in self.keys: | |
426 self.SetColLabelValue( self.keys.index( key ), key ) | |
427 self.update_all() | 390 self.update_all() |
428 self.selectedRow = 0 | 391 self.selectedRow = 0 |
429 self.AutoSizeColumns() | 392 self.AutoSizeColumns() |
430 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) | 393 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) |
431 self.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.select_cell) | 394 self.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.select_cell) |
432 | 395 |
433 def update_cols( self ): | 396 def update_cols( self ): |
434 for n in self.handler.xml.findall(TAG_MINIATURE): | 397 for n in self.handler.xml.findall(TAG_MINIATURE): |
435 for k in n.keys(): | 398 for k in n.keys(): |
436 if k not in self.keys: | 399 if k not in self.keys: self.keys.append( k ) |
437 self.keys.append( k ) | |
438 | 400 |
439 def select_cell( self, evt ): | 401 def select_cell( self, evt ): |
440 """Event handler for grid cell selection changes. It stores the | 402 """Event handler for grid cell selection changes. It stores the |
441 last selected row in a variable for use by the add[*] and del_row | 403 last selected row in a variable for use by the add[*] and del_row |
442 operations. | 404 operations. |
490 """ | 452 """ |
491 list = self.getList() | 453 list = self.getList() |
492 count = 0 | 454 count = 0 |
493 for n in list: | 455 for n in list: |
494 for k in n.keys(): | 456 for k in n.keys(): |
495 if k not in self.keys: | 457 if k not in self.keys: self.keys.append( k ) |
496 self.keys.append( k ) | |
497 count = len( self.keys ) | 458 count = len( self.keys ) |
498 if self.GetNumberCols() < count: | 459 if self.GetNumberCols() < count: |
499 self.AppendCols( count - self.GetNumberCols() ) | 460 self.AppendCols( count - self.GetNumberCols() ) |
500 for k in self.keys: | 461 for k in self.keys: self.SetColLabelValue( self.keys.index( k ), k ) |
501 self.SetColLabelValue( self.keys.index( k ), k ) | |
502 count = len( list ) | 462 count = len( list ) |
503 rowcount = self.GetNumberRows() | 463 rowcount = self.GetNumberRows() |
504 if ( count > rowcount ): | 464 if ( count > rowcount ): |
505 total = count - rowcount | 465 total = count - rowcount |
506 self.AppendRows( total ) | 466 self.AppendRows( total ) |
529 """Updates the specified grid row with data from the DOM node | 489 """Updates the specified grid row with data from the DOM node |
530 specified by 'row' | 490 specified by 'row' |
531 """ | 491 """ |
532 list = self.getList() | 492 list = self.getList() |
533 item = list[ row ] | 493 item = list[ row ] |
534 for key in self.keys: | 494 for key in self.keys: self.GetTable().SetValue( row, self.keys.index( key ), item.get( key ) ) |
535 self.GetTable().SetValue( row, self.keys.index( key ), item.get( key ) ) | |
536 | 495 |
537 def update_data_row( self, row ): | 496 def update_data_row( self, row ): |
538 """Updates the DOM nodw 'row' with grid data from 'row' | 497 """Updates the DOM nodw 'row' with grid data from 'row' |
539 """ | 498 """ |
540 list = self.getList() | 499 list = self.getList() |
541 item = list[ row ] | 500 item = list[ row ] |
542 for key in self.keys: | 501 for key in self.keys: item.set( key, string.strip( self.GetTable().GetValue( row, self.keys.index( key ) ) ) ) |
543 item.set( key, string.strip( self.GetTable().GetValue( row, self.keys.index( key ) ) ) ) |