Mercurial > traipse_dev
comparison orpg/gametree/nodehandlers/rpg_grid.py @ 189:7c1a8b36b729 beta
Traipse Beta 'OpenRPG' {100125-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)
New Features:
Added Bookmarks
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
New TrueDebug Class in orpg_log (See documentation for usage)
Portable Mercurial
Tip of the Day added, from Core and community
New Reference Syntax added for custom PC sheets
New Child Reference for gametree
New Parent Reference for gametree
New Gametree Recursion method, mapping, context sensitivity, and
effeciency..
New Features node with bonus nodes and Node Referencing help added
Dieroller structure from Core
New DieRoller portability for odd Dice
Added 7th Sea die roller; ie [7k3] = [7d10.takeHighest(3).open(10)]
New 'Mythos' System die roller added
Added new vs. die roller method for WoD; ie [3v3] = [3d10.vs(3)].
Included for Mythos roller also
New Warhammer FRPG Die Roller (Special thanks to Puu-san for the
support)
New EZ_Tree Reference system. Push a button, Traipse the tree, get a
reference (Beta!)
Fixes:
Fix to Text based Server
Fix to Remote Admin Commands
Fix to Pretty Print, from Core
Fix to Splitter Nodes not being created
Fix to massive amounts of images loading, from Core
Fix to Map from gametree not showing to all clients
Fix to gametree about menus
Fix to Password Manager check on startup
Fix to PC Sheets from tool nodes. They now use the tabber_panel
Fix to Whiteboard ID to prevent random line or text deleting.
Fixes to Server, Remote Server, and Server GUI
Fix to Update Manager; cleaner clode for saved repositories
Fixes made to Settings Panel and now reactive settings when Ok is
pressed
Fixes to Alternity roller's attack roll. Uses a simple Tuple instead of
a Splice
Fix to Use panel of Forms and Tabbers. Now longer enters design mode
Fix made Image Fetching. New fetching image and new failed image
Modified ID's to prevent non updated clients from ruining the fix.
default_manifest.xml renamed to default_upmana.xml
author | sirebral |
---|---|
date | Mon, 25 Jan 2010 10:03:16 -0600 |
parents | dcae32e219f1 |
children | 15488fe94f52 |
comparison
equal
deleted
inserted
replaced
188:043ce9a25b20 | 189:7c1a8b36b729 |
---|---|
28 | 28 |
29 __version__ = "$Id: rpg_grid.py,v Traipse 'Ornery-Orc' prof.ebral Exp $" | 29 __version__ = "$Id: rpg_grid.py,v Traipse 'Ornery-Orc' prof.ebral Exp $" |
30 | 30 |
31 from core import * | 31 from core import * |
32 from forms import * | 32 from forms import * |
33 from orpg.tools.orpg_log import debug | |
33 | 34 |
34 class rpg_grid_handler(node_handler): | 35 class rpg_grid_handler(node_handler): |
35 """ Node handler for rpg grid tool | 36 """ Node handler for rpg grid tool |
36 <nodehandler module='rpg_grid' class='rpg_grid_handler' name='sample'> | 37 <nodehandler module='rpg_grid' class='rpg_grid_handler' name='sample'> |
37 <grid border='' autosize='1' > | 38 <grid border='' autosize='1' > |
85 html_str += "<tr>" | 86 html_str += "<tr>" |
86 for c in cells: | 87 for c in cells: |
87 html_str += "<td >" | 88 html_str += "<td >" |
88 text = c.text | 89 text = c.text |
89 if text == None or text == '': text = '<br />' | 90 if text == None or text == '': text = '<br />' |
91 s = component.get('chat').ParseMap(text, self.xml) | |
92 s = component.get('chat').NormalizeParse(s) | |
93 try: text = str(eval(s)) | |
94 except: text = s | |
90 html_str += text + "</td>" | 95 html_str += text + "</td>" |
91 html_str += "</tr>" | 96 html_str += "</tr>" |
92 html_str += "</table>" | 97 html_str += "</table>" |
93 return html_str | 98 return html_str |
94 | 99 |
95 def get_design_panel(self,parent): | 100 def get_design_panel(self,parent): |
96 return rpg_grid_edit_panel(parent,self) | 101 return rpg_grid_edit_panel(parent, self) |
97 | 102 |
98 def get_use_panel(self,parent): | 103 def get_use_panel(self,parent): |
99 return rpg_grid_panel(parent,self) | 104 return rpg_grid_panel(parent, self) |
100 | 105 |
101 def get_size_constraint(self): | 106 def get_size_constraint(self): |
102 return 1 | 107 return 1 |
103 | 108 |
104 def is_autosized(self): | 109 def is_autosized(self): |
192 """ | 197 """ |
193 Fetch the value from the table and prepare the edit control | 198 Fetch the value from the table and prepare the edit control |
194 to begin editing. Set the focus to the edit control. | 199 to begin editing. Set the focus to the edit control. |
195 *Must Override* | 200 *Must Override* |
196 """ | 201 """ |
197 self.startValue = grid.GetTable().GetValue(row, col) | 202 #self.startValue = grid.GetTable().GetValue(row, col) |
203 self.startValue = grid.get_value(row, col) | |
198 self._tc.SetValue(self.startValue) | 204 self._tc.SetValue(self.startValue) |
199 self._tc.SetInsertionPointEnd() | 205 self._tc.SetInsertionPointEnd() |
200 self._tc.SetFocus() | 206 self._tc.SetFocus() |
201 | 207 |
202 # For this example, select the text | 208 # For this example, select the text |
211 changed = False | 217 changed = False |
212 val = self._tc.GetValue() | 218 val = self._tc.GetValue() |
213 if val != self.startValue: | 219 if val != self.startValue: |
214 changed = True | 220 changed = True |
215 grid.GetTable().SetValue(row, col, val) # update the table | 221 grid.GetTable().SetValue(row, col, val) # update the table |
216 | |
217 self.startValue = '' | 222 self.startValue = '' |
218 self._tc.SetValue('') | 223 self._tc.SetValue('') |
219 return changed | 224 return changed |
220 | 225 |
221 def Reset(self): | 226 def Reset(self): |
263 return MyCellEditor() | 268 return MyCellEditor() |
264 | 269 |
265 | 270 |
266 class rpg_grid(wx.grid.Grid): | 271 class rpg_grid(wx.grid.Grid): |
267 """grid for attacks""" | 272 """grid for attacks""" |
268 def __init__(self, parent, handler): | 273 def __init__(self, parent, handler, mode): |
269 wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) | 274 wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) |
270 self.parent = parent | 275 self.parent = parent |
271 self.handler = handler | 276 self.handler = handler |
272 | 277 self.mode = mode |
273 self.RegisterDataType(wx.grid.GRID_VALUE_STRING, wx.grid.GridCellStringRenderer(),MyCellEditor()) | 278 self.RegisterDataType(wx.grid.GRID_VALUE_STRING, wx.grid.GridCellStringRenderer(),MyCellEditor()) |
274 | 279 |
275 self.rows = handler.grid.findall('row') | 280 self.rows = handler.grid.findall('row') |
276 rows = len(self.rows) | 281 rows = len(self.rows) |
277 cols = len(self.rows[0].findall('cell')) | 282 cols = len(self.rows[0].findall('cell')) |
284 | 289 |
285 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) | 290 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) |
286 self.Bind(wx.grid.EVT_GRID_COL_SIZE, self.on_col_size) | 291 self.Bind(wx.grid.EVT_GRID_COL_SIZE, self.on_col_size) |
287 self.Bind(wx.grid.EVT_GRID_CELL_LEFT_DCLICK, self.on_leftdclick) | 292 self.Bind(wx.grid.EVT_GRID_CELL_LEFT_DCLICK, self.on_leftdclick) |
288 | 293 |
289 | |
290 def on_leftdclick(self,evt): | 294 def on_leftdclick(self,evt): |
291 if self.CanEnableCellControl(): self.EnableCellEditControl() | 295 if self.CanEnableCellControl(): self.EnableCellEditControl() |
292 | 296 |
293 def on_col_size(self, evt): | 297 def on_col_size(self, evt): |
294 col = evt.GetRowOrCol() | 298 col = evt.GetRowOrCol() |
302 col = evt.GetCol() | 306 col = evt.GetCol() |
303 value = self.GetCellValue(row,col) | 307 value = self.GetCellValue(row,col) |
304 cells = self.rows[row].findall('cell') | 308 cells = self.rows[row].findall('cell') |
305 cells[col].text = value | 309 cells[col].text = value |
306 if col == 0: self.handler.refresh_rows() | 310 if col == 0: self.handler.refresh_rows() |
311 for i in range(0,len(self.rows)): self.refresh_row(i) | |
307 | 312 |
308 def set_col_widths(self): | 313 def set_col_widths(self): |
309 cells = self.rows[0].findall('cell') | 314 cells = self.rows[0].findall('cell') |
310 for i in range(0,len(cells)): | 315 for i in range(0,len(cells)): |
311 try: | 316 try: |
312 size = int(cells[i].get('size')) | 317 size = int(cells[i].get('size')) |
313 self.SetColSize(i,size) | 318 self.SetColSize(i,size) |
314 except: continue | 319 except: continue |
315 | 320 |
316 def refresh_row(self,rowi): | 321 def refresh_row(self, rowi): |
317 cells = self.rows[rowi].findall('cell') | 322 cells = self.rows[rowi].findall('cell') |
318 for i in range(0,len(cells)): | 323 for i in range(0,len(cells)): |
319 text = cells[i].text | 324 text = cells[i].text |
320 if text == None or text == '': | 325 if text == None or text == '': |
321 text = '' | 326 text = '' |
322 cells[i].text = text | 327 cells[i].text = text |
328 if self.mode == 0: | |
329 s = component.get('chat').ParseMap(text, self.handler.xml) | |
330 try: text = str(eval(s)) | |
331 except: text = s | |
323 self.SetCellValue(rowi,i,text) | 332 self.SetCellValue(rowi,i,text) |
324 | 333 |
325 def add_row(self,evt=None): | 334 def add_row(self,evt=None): |
326 cols = self.GetNumberCols() | 335 cols = self.GetNumberCols() |
327 row = Element('row') | 336 row = Element('row') |
357 cells = r.findall('cell') | 366 cells = r.findall('cell') |
358 r.remove(r[num-1]) # always remove the last column -- nasty | 367 r.remove(r[num-1]) # always remove the last column -- nasty |
359 self.DeleteCols(num-1,1) | 368 self.DeleteCols(num-1,1) |
360 self.set_col_widths() | 369 self.set_col_widths() |
361 | 370 |
371 def get_value(self, row, col): | |
372 cells = self.rows[row].findall('cell') | |
373 return cells[col].text | |
374 | |
362 | 375 |
363 G_TITLE = wx.NewId() | 376 G_TITLE = wx.NewId() |
364 GRID_BOR = wx.NewId() | 377 GRID_BOR = wx.NewId() |
365 class rpg_grid_panel(wx.Panel): | 378 class rpg_grid_panel(wx.Panel): |
366 def __init__(self, parent, handler): | 379 def __init__(self, parent, handler): |
367 wx.Panel.__init__(self, parent, -1) | 380 wx.Panel.__init__(self, parent, -1) |
368 self.handler = handler | 381 self.handler = handler |
369 self.grid = rpg_grid(self, handler) | 382 self.grid = rpg_grid(self, handler, mode=0) |
370 label = handler.xml.get('name') | 383 label = handler.xml.get('name') |
371 self.main_sizer = wx.BoxSizer(wx.VERTICAL) | 384 self.main_sizer = wx.BoxSizer(wx.VERTICAL) |
372 self.main_sizer.Add(wx.StaticText(self, -1, label+": "), 0, wx.EXPAND) | 385 self.main_sizer.Add(wx.StaticText(self, -1, label+": "), 0, wx.EXPAND) |
373 self.main_sizer.Add(self.grid,1,wx.EXPAND) | 386 self.main_sizer.Add(self.grid,1,wx.EXPAND) |
374 self.SetSizer(self.main_sizer) | 387 self.SetSizer(self.main_sizer) |
386 class rpg_grid_edit_panel(wx.Panel): | 399 class rpg_grid_edit_panel(wx.Panel): |
387 def __init__(self, parent, handler): | 400 def __init__(self, parent, handler): |
388 wx.Panel.__init__(self, parent, -1) | 401 wx.Panel.__init__(self, parent, -1) |
389 self.handler = handler | 402 self.handler = handler |
390 self.parent = parent | 403 self.parent = parent |
391 self.grid = rpg_grid(self,handler) | 404 self.grid = rpg_grid(self,handler, mode=1) |
392 self.main_sizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Grid"), wx.VERTICAL) | 405 self.main_sizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Grid"), wx.VERTICAL) |
393 | 406 |
394 self.title = wx.TextCtrl(self, G_TITLE, handler.xml.get('name')) | 407 self.title = wx.TextCtrl(self, G_TITLE, handler.xml.get('name')) |
395 | 408 |
396 radio_b = wx.RadioBox(self, GRID_BOR, "Border (HTML)", choices=["no","yes"]) | 409 radio_b = wx.RadioBox(self, GRID_BOR, "Border (HTML)", choices=["no","yes"]) |
460 row = str(evt.GetRow()+1) | 473 row = str(evt.GetRow()+1) |
461 col = str(evt.GetCol()+1) | 474 col = str(evt.GetCol()+1) |
462 complete = complete[:len(complete)-2] + '::'+'('+row+','+col+')'+complete[len(complete)-2:] | 475 complete = complete[:len(complete)-2] + '::'+'('+row+','+col+')'+complete[len(complete)-2:] |
463 col = self.grid.GetGridCursorCol() | 476 col = self.grid.GetGridCursorCol() |
464 row = self.grid.GetGridCursorRow() | 477 row = self.grid.GetGridCursorRow() |
478 temp_value = self.grid.GetCellValue(row, col) | |
479 complete = temp_value + complete | |
465 self.grid.SetCellValue(row, col, complete) | 480 self.grid.SetCellValue(row, col, complete) |
466 cells = self.grid.rows[row].findall('cell') | 481 cells = self.grid.rows[row].findall('cell') |
467 cells[col].text = complete | 482 cells[col].text = complete |
468 self.mini_grid.Destroy() | 483 self.mini_grid.Destroy() |
469 | 484 |
503 if obj.xml.get('class') == 'rpg_grid_handler': | 518 if obj.xml.get('class') == 'rpg_grid_handler': |
504 self.get_grid_ref(obj, complete) | 519 self.get_grid_ref(obj, complete) |
505 else: | 520 else: |
506 col = self.grid.GetGridCursorCol() | 521 col = self.grid.GetGridCursorCol() |
507 row = self.grid.GetGridCursorRow() | 522 row = self.grid.GetGridCursorRow() |
523 temp_value = self.grid.GetCellValue(row, col) | |
524 complete = temp_value + complete | |
508 self.grid.SetCellValue(row, col, complete) | 525 self.grid.SetCellValue(row, col, complete) |
509 cells = self.grid.rows[row].findall('cell') | 526 cells = self.grid.rows[row].findall('cell') |
510 cells[col].text = complete | 527 cells[col].text = complete |
511 self.do_tree.Destroy() | 528 self.do_tree.Destroy() |
512 if do == 'None': | 529 if do == 'None': |
525 def on_text(self,evt): | 542 def on_text(self,evt): |
526 txt = self.title.GetValue() | 543 txt = self.title.GetValue() |
527 if txt != "": | 544 if txt != "": |
528 self.handler.xml.set('name',txt) | 545 self.handler.xml.set('name',txt) |
529 self.handler.rename(txt) | 546 self.handler.rename(txt) |
547 | |
548 def refresh_row(self,rowi): | |
549 cells = self.rows[rowi].findall('cell') | |
550 for i in range(0,len(cells)): | |
551 text = cells[i].text | |
552 #s = component.get('chat').ParseMap(s, self.handler.xml) | |
553 #try: text = str(eval(s)) | |
554 #except: text = s | |
555 if text == None or text == '': | |
556 text = '' | |
557 cells[i].text = text | |
558 self.SetCellValue(rowi,i,text) |