comparison orpg/gametree/nodehandlers/forms.py @ 183:0d9b746b5751 beta

Traipse Beta 'OpenRPG' {100115-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 Fri, 15 Jan 2010 23:01:42 -0600
parents 3b6888bb53b5
children dcae32e219f1
comparison
equal deleted inserted replaced
172:8834425a85b0 183:0d9b746b5751
30 30
31 from containers import * 31 from containers import *
32 import orpg.minidom as minidom 32 import orpg.minidom as minidom
33 from orpg.orpg_xml import xml 33 from orpg.orpg_xml import xml
34 from wx.lib.scrolledpanel import ScrolledPanel 34 from wx.lib.scrolledpanel import ScrolledPanel
35 from orpg.tools.settings import settings
35 36
36 def bool2int(b): 37 def bool2int(b):
37 #in wxPython 2.5+, evt.Checked() returns True or False instead of 1.0 or 0. 38 #in wxPython 2.5+, evt.Checked() returns True or False instead of 1.0 or 0.
38 #by running the results of that through this function, we convert it. 39 #by running the results of that through this function, we convert it.
39 #if it was an int already, nothing changes. The difference between 1.0 40 #if it was an int already, nothing changes. The difference between 1.0
253 parent.SetSize(self.GetBestSize()) 254 parent.SetSize(self.GetBestSize())
254 self.Bind(wx.EVT_TEXT, self.on_text, id=FORM_TEXT_CTRL) 255 self.Bind(wx.EVT_TEXT, self.on_text, id=FORM_TEXT_CTRL)
255 self.Bind(wx.EVT_BUTTON, self.on_send, id=FORM_SEND_BUTTON) 256 self.Bind(wx.EVT_BUTTON, self.on_send, id=FORM_SEND_BUTTON)
256 257
257 def on_text(self, evt): 258 def on_text(self, evt):
258 debug()
259 txt = self.text.GetValue() 259 txt = self.text.GetValue()
260 #txt = strip_text(txt) ##Does not seem to exist. 260 #txt = strip_text(txt) ##Does not seem to exist.
261 self.handler.text_elem.text = txt 261 self.handler.text_elem.text = txt
262 262
263 def on_send(self, evt): 263 def on_send(self, evt):
264 txt = self.text.GetValue() 264 txt = self.text.GetValue()
265 txt = self.chat.ParseMap(txt, self.handler.xml) 265 txt = self.chat.ParseMap(txt, self.handler.xml)
266 txt = self.chat.ParseParent(txt, self.handler.xml.get('map'))
266 if not self.handler.is_raw_send(): 267 if not self.handler.is_raw_send():
267 self.chat.ParsePost(self.handler.tohtml(), True, True) 268 self.chat.ParsePost(self.handler.tohtml(), True, True)
268 return 1 269 return 1
269 actionlist = txt.split("\n") 270 actionlist = txt.split("\n")
270 for line in actionlist: 271 for line in actionlist:
279 F_MULTI = wx.NewId() 280 F_MULTI = wx.NewId()
280 F_SEND_BUTTON = wx.NewId() 281 F_SEND_BUTTON = wx.NewId()
281 F_RAW_SEND = wx.NewId() 282 F_RAW_SEND = wx.NewId()
282 F_HIDE_TITLE = wx.NewId() 283 F_HIDE_TITLE = wx.NewId()
283 F_TEXT = wx.NewId() 284 F_TEXT = wx.NewId()
285 T_BUT_REF = wx.NewId()
284 286
285 class textctrl_edit_panel(wx.Panel): 287 class textctrl_edit_panel(wx.Panel):
286 def __init__(self, parent, handler): 288 def __init__(self, parent, handler):
287 wx.Panel.__init__(self, parent, -1) 289 wx.Panel.__init__(self, parent, -1)
288 self.handler = handler 290 self.handler = handler
291 self.parent = parent
289 sizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Text Properties"), wx.VERTICAL) 292 sizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Text Properties"), wx.VERTICAL)
290 293
291 self.title = wx.TextCtrl(self, P_TITLE, handler.xml.get('name')) 294 self.title = wx.TextCtrl(self, P_TITLE, handler.xml.get('name'))
292 self.multi = wx.CheckBox(self, F_MULTI, " Multi-Line") 295 self.multi = wx.CheckBox(self, F_MULTI, " Multi-Line")
293 self.multi.SetValue(handler.is_multi_line()) 296 self.multi.SetValue(handler.is_multi_line())
295 self.raw_send.SetValue(handler.is_raw_send()) 298 self.raw_send.SetValue(handler.is_raw_send())
296 self.hide_title = wx.CheckBox(self, F_HIDE_TITLE, " Hide Title") 299 self.hide_title = wx.CheckBox(self, F_HIDE_TITLE, " Hide Title")
297 self.hide_title.SetValue(handler.is_hide_title()) 300 self.hide_title.SetValue(handler.is_hide_title())
298 self.send_button = wx.CheckBox(self, F_SEND_BUTTON, " Send Button") 301 self.send_button = wx.CheckBox(self, F_SEND_BUTTON, " Send Button")
299 self.send_button.SetValue(handler.has_send_button()) 302 self.send_button.SetValue(handler.has_send_button())
303 button_ref = wx.Button(self, T_BUT_REF, "Reference")
300 304
301 sizer.Add(wx.StaticText(self, P_TITLE, "Title:"), 0, wx.EXPAND) 305 sizer.Add(wx.StaticText(self, P_TITLE, "Title:"), 0, wx.EXPAND)
302 sizer.Add(self.title, 0, wx.EXPAND) 306 sizer.Add(self.title, 0, wx.EXPAND)
303 sizer.Add(wx.Size(10,10)) 307 sizer.Add(wx.Size(10,10))
304 sizer.Add(self.multi, 0, wx.EXPAND) 308 sizer.Add(self.multi, 0, wx.EXPAND)
305 sizer.Add(self.raw_send, 0, wx.EXPAND) 309 sizer.Add(self.raw_send, 0, wx.EXPAND)
306 sizer.Add(self.hide_title, 0, wx.EXPAND) 310 sizer.Add(self.hide_title, 0, wx.EXPAND)
307 sizer.Add(self.send_button, 0 , wx.EXPAND) 311 sizer.Add(self.send_button, 0 , wx.EXPAND)
312 sizer.Add(button_ref, 0)
308 sizer.Add(wx.Size(10,10)) 313 sizer.Add(wx.Size(10,10))
309 if handler.is_multi_line(): 314 if handler.is_multi_line():
310 sizer_style = wx.EXPAND 315 sizer_style = wx.EXPAND
311 text_style = wx.TE_MULTILINE 316 text_style = wx.TE_MULTILINE
312 multi = 1 317 multi = 1
324 self.Bind(wx.EVT_TEXT, self.on_text, id=F_TEXT) 329 self.Bind(wx.EVT_TEXT, self.on_text, id=F_TEXT)
325 self.Bind(wx.EVT_CHECKBOX, self.on_button, id=F_MULTI) 330 self.Bind(wx.EVT_CHECKBOX, self.on_button, id=F_MULTI)
326 self.Bind(wx.EVT_CHECKBOX, self.on_raw_button, id=F_RAW_SEND) 331 self.Bind(wx.EVT_CHECKBOX, self.on_raw_button, id=F_RAW_SEND)
327 self.Bind(wx.EVT_CHECKBOX, self.on_hide_button, id=F_HIDE_TITLE) 332 self.Bind(wx.EVT_CHECKBOX, self.on_hide_button, id=F_HIDE_TITLE)
328 self.Bind(wx.EVT_CHECKBOX, self.on_send_button, id=F_SEND_BUTTON) 333 self.Bind(wx.EVT_CHECKBOX, self.on_send_button, id=F_SEND_BUTTON)
334 self.Bind(wx.EVT_BUTTON, self.on_reference, id=T_BUT_REF)
335 self.parent.Bind(wx.EVT_CLOSE, self.tree_failsafe)
336
337 ## EZ_Tree Core TaS - Prof.Ebral ##
338 def on_reference(self, evt, car=None):
339 self.do_tree = wx.Frame(self, -1, 'EZ Tree')
340 self.ez_tree = orpg.gametree.gametree
341 self.temp_wnd = self.ez_tree.game_tree(self.do_tree, self.ez_tree.EZ_REF)
342 self.temp_wnd.Bind(wx.EVT_LEFT_DCLICK, self.on_ldclick)
343 component.get('tree_fs').save_tree(settings.get("gametree"))
344 self.temp_wnd.load_tree(settings.get("gametree"))
345 self.do_tree.Show()
346
347 def tree_failsafe(self, evt):
348 self.parent.Destroy()
349 component.add('tree', component.get('tree_fs')) ## Backup
350
351 def get_grid_ref(self, obj, complete):
352 self.temp_wnd.Freeze()
353 self.grid_ref = complete
354 self.mini_grid = wx.Frame(self, -1, 'EZ Tree Mini Grid')
355 self.temp_grid = obj.get_use_panel(self.mini_grid)
356 self.temp_grid.grid.Bind(wx.grid.EVT_GRID_CELL_LEFT_DCLICK, self.on_grid_ldclick)
357 self.mini_grid.Show()
358
359 def on_grid_ldclick(self, evt):
360 complete = self.grid_ref
361 row = str(evt.GetRow()+1)
362 col = str(evt.GetCol()+1)
363 complete = complete[:len(complete)-2] + '::'+'('+row+','+col+')'+complete[len(complete)-2:]
364 self.text.AppendText(complete); self.on_text(evt)
365 self.mini_grid.Destroy()
366
367 def on_ldclick(self, evt):
368 self.rename_flag = 0
369 pt = evt.GetPosition()
370 (item, flag) = self.temp_wnd.HitTest(pt)
371 if item.IsOk():
372 obj = self.temp_wnd.GetPyData(item)
373 self.temp_wnd.SelectItem(item)
374 start = self.handler.xml.get('map').split('::')
375 end = obj.xml.get('map').split('::')
376 if obj.xml.get('class') not in ['rpg_grid_handler', 'textctrl_handler']: do = 'None'
377 elif end[0] == '' or start[0] != end[0]: do = 'Root'
378 elif start == end: do = 'Child'
379 elif start != end: do = 'Parent'
380 if do == 'Root':
381 complete = "!@"
382 for e in end:
383 if e != '': complete += e +'::'
384 complete = complete + obj.xml.get('name') + '@!'
385 elif do == 'Parent':
386 while start[0] == end[0]:
387 del end[0], start[0]
388 if len(start) == 0 or len(end) == 0: break
389 complete = "!#"
390 for e in end: complete += e +'::'
391 complete = complete + obj.xml.get('name') + '#!'
392 elif do == 'Child':
393 while start[0] == end[0]:
394 del end[0], start[0]
395 if len(start) == 0 or len(end) == 0: break
396 complete = "!!"
397 for e in end: complete += e +'::'
398 complete = complete + obj.xml.get('name') + '!!'
399 if do != 'None':
400 if obj.xml.get('class') == 'rpg_grid_handler':
401 self.get_grid_ref(obj, complete)
402 else: self.text.AppendText(complete); self.on_text(evt)
403 self.do_tree.Destroy()
404 if do == 'None':
405 wx.MessageBox('Invalid Reference', 'Error')
406 ##### #####
329 407
330 def on_text(self,evt): 408 def on_text(self,evt):
331 id = evt.GetId() 409 id = evt.GetId()
332 if id == P_TITLE: 410 if id == P_TITLE:
333 txt = self.title.GetValue() 411 txt = self.title.GetValue()
375 </list> 453 </list>
376 </nodehandler> 454 </nodehandler>
377 """ 455 """
378 def __init__(self,xml,tree_node): 456 def __init__(self,xml,tree_node):
379 node_handler.__init__(self,xml,tree_node) 457 node_handler.__init__(self,xml,tree_node)
380 self.list = self.xml.find('list') 458 self.list_reload()
381 self.options = self.list.findall('option') 459 #print xml
460 #print self.tree.GetItemParent(tree_node)
382 if self.list.get("send_button") == "": self.list.set("send_button","0") 461 if self.list.get("send_button") == "": self.list.set("send_button","0")
383 if self.list.get("hide_title") == "": self.list.set("hide_title","0") 462 if self.list.get("hide_title") == "": self.list.set("hide_title","0")
384 if self.list.get("raw_mode") == "": self.list.set("raw_mode","0") 463 if self.list.get("raw_mode") == "": self.list.set("raw_mode","0")
464
465 def list_reload(self):
466 self.list = self.xml.find('list')
467 self.options = self.list.findall('option')
468 self.captions = []
469 for opt in self.options:
470 if opt.get('caption') == None: opt.set('caption', '')
471 self.captions.append(opt.get('caption'))
385 472
386 def get_design_panel(self,parent): 473 def get_design_panel(self,parent):
387 return listbox_edit_panel(parent,self) 474 return listbox_edit_panel(parent,self)
388 475
389 def get_use_panel(self,parent): 476 def get_use_panel(self,parent):
452 def get_options(self): 539 def get_options(self):
453 opts = [] 540 opts = []
454 for opt in self.options: opts.append(opt.text) 541 for opt in self.options: opts.append(opt.text)
455 return opts 542 return opts
456 543
457 def get_option(self,index): 544 def get_captions(self):
545 captions = []
546 for opt in self.options: captions.append(opt.get("caption"))
547 self.captions = captions
548 return captions
549
550 def get_option(self, index):
458 return self.options[index].text 551 return self.options[index].text
459 552
460 def add_option(self,opt): 553 def get_caption(self, index):
554 captions = self.get_captions()
555 return captions[index] or ''
556
557 def add_option(self, caption, value):
461 elem = Element('option') 558 elem = Element('option')
462 elem.set("value","0") 559 elem.set("value","0")
560 elem.set('caption', caption)
463 elem.set("selected","0") 561 elem.set("selected","0")
464 elem.text = opt 562 elem.text = value
465 self.list.append(elem) 563 self.list.append(elem)
466 self.options = self.list.findall('option') 564 self.list_reload()
467 565
468 def remove_option(self,index): 566 def remove_option(self,index):
469 self.list.remove(self.options[index]) 567 self.list.remove(self.options[index])
470 self.options = self.list.findall('option') 568 self.list_reload()
471 569
472 def edit_option(self,index,value): 570 def edit_option(self, index, value):
473 self.options[index].text = value 571 self.options[index].text = value
572
573 def edit_caption(self, index, value):
574 self.options[index].set('caption', value)
575 self.captions[index] = value
474 576
475 def has_send_button(self): 577 def has_send_button(self):
476 if self.list.get("send_button") == '0': return False 578 if self.list.get("send_button") == '0': return False
477 else: return True 579 else: return True
478 580
492 return "\n".join(self.get_selections_text()) 594 return "\n".join(self.get_selections_text())
493 595
494 def on_send_to_chat(self, evt): 596 def on_send_to_chat(self, evt):
495 txt = self.get_selected_text() 597 txt = self.get_selected_text()
496 txt = self.chat.ParseMap(txt, self.xml) 598 txt = self.chat.ParseMap(txt, self.xml)
599 txt = self.chat.ParseParent(txt, self.xml.get('map'))
497 if not self.is_raw_send(): 600 if not self.is_raw_send():
498 self.chat.ParsePost(self.tohtml(), True, True) 601 self.chat.ParsePost(self.tohtml(), True, True)
499 return 1 602 return 1
500 actionlist = self.get_selections_text() 603 actionlist = self.get_selections_text()
501 for line in actionlist: 604 for line in actionlist:
502 line = self.chat.ParseMap(line, self.xml) 605 line = self.chat.ParseMap(line, self.xml)
606 line = self.chat.ParseParent(line, self.xml.get('map'))
503 if(line != ""): 607 if(line != ""):
504 if line[0] != "/": ## it's not a slash command 608 if line[0] != "/": ## it's not a slash command
505 self.chat.ParsePost(line, True, True) 609 self.chat.ParsePost(line, True, True)
506 else: 610 else:
507 action = line 611 action = line
516 class listbox_panel(wx.Panel): 620 class listbox_panel(wx.Panel):
517 def __init__(self, parent, handler): 621 def __init__(self, parent, handler):
518 wx.Panel.__init__(self, parent, -1) 622 wx.Panel.__init__(self, parent, -1)
519 self.handler = handler 623 self.handler = handler
520 self.chat = handler.chat 624 self.chat = handler.chat
521 opts = handler.get_options() 625 opts = []
626 values = handler.get_options()
627 captions = handler.get_captions()
628 for value in values:
629 if captions[values.index(value)] != '': opts.append(captions[values.index(value)])
630 else: opts.append(value)
522 cur_opt = handler.get_selected_text() 631 cur_opt = handler.get_selected_text()
523 type = handler.get_type() 632 type = handler.get_type()
524 label = handler.xml.get('name') 633 label = handler.xml.get('name')
525 634
526 if type == L_DROP: 635 if type == L_DROP:
569 for i in self.handler.get_selections_index(): self.list.Check(i) 678 for i in self.handler.get_selections_index(): self.list.Check(i)
570 679
571 680
572 BUT_ADD = wx.NewId() 681 BUT_ADD = wx.NewId()
573 BUT_REM = wx.NewId() 682 BUT_REM = wx.NewId()
683 BUT_REF = wx.NewId()
574 BUT_EDIT = wx.NewId() 684 BUT_EDIT = wx.NewId()
575 F_TYPE = wx.NewId() 685 F_TYPE = wx.NewId()
576 F_NO_TITLE = wx.NewId() 686 F_NO_TITLE = wx.NewId()
687 LIST_CTRL = wx.NewId()
577 688
578 class listbox_edit_panel(wx.Panel): 689 class listbox_edit_panel(wx.Panel):
579 def __init__(self, parent, handler): 690 def __init__(self, parent, handler):
580 wx.Panel.__init__(self, parent, -1) 691 wx.Panel.__init__(self, parent, -1)
581 self.handler = handler 692 self.handler = handler
693 self.parent = parent
582 sizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "List Box Properties"), wx.VERTICAL) 694 sizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "List Box Properties"), wx.VERTICAL)
583 695
584 self.text = wx.TextCtrl(self, P_TITLE, handler.xml.get('name')) 696 self.text = wx.TextCtrl(self, P_TITLE, handler.xml.get('name'))
585 697 self.listbox = wx.ListCtrl(self, LIST_CTRL, style=wx.LC_REPORT)
586 opts = handler.get_options() 698 self.listbox.InsertColumn(0, 'Caption')
587 self.listbox = wx.ListBox(self, F_LIST, choices=opts, style=wx.LB_HSCROLL|wx.LB_SINGLE|wx.LB_NEEDED_SB) 699 self.listbox.InsertColumn(1, 'Value')
700 self.listbox.SetColumnWidth(0, 75)
701 self.listbox.SetColumnWidth(1, 300)
702 self.reload_options()
703
588 opts = ['Drop Down', 'List Box', 'Radio Box', 'Check List'] 704 opts = ['Drop Down', 'List Box', 'Radio Box', 'Check List']
589 self.type_radios = wx.RadioBox(self,F_TYPE,"List Type",choices=opts) 705 self.type_radios = wx.RadioBox(self,F_TYPE,"List Type",choices=opts)
590 self.type_radios.SetSelection(handler.get_type()) 706 self.type_radios.SetSelection(handler.get_type())
591 707
592 self.send_button = wx.CheckBox(self, F_SEND_BUTTON, " Send Button") 708 self.send_button = wx.CheckBox(self, F_SEND_BUTTON, " Send Button")
634 750
635 def on_type(self,evt): 751 def on_type(self,evt):
636 self.handler.set_type(evt.GetInt()) 752 self.handler.set_type(evt.GetInt())
637 753
638 def on_add(self,evt): 754 def on_add(self,evt):
639 dlg = wx.TextEntryDialog(self, 'Enter option?','Add Option', '') 755 self.dlg = wx.Frame(self, -1, 'Text', size=(300,150))
640 if dlg.ShowModal() == wx.ID_OK: 756 edit_panel = wx.Panel(self.dlg, -1)
641 self.handler.add_option(dlg.GetValue()) 757 sizer = wx.GridBagSizer(1, 2)
642 dlg.Destroy() 758 edit_panel.SetSizer(sizer)
759 caption_text = wx.StaticText(edit_panel, -1, 'Caption')
760 self.caption_entry = wx.TextCtrl(edit_panel, -1, '')
761 value_text = wx.StaticText(edit_panel, -1, 'Value')
762 self.value_entry = wx.TextCtrl(edit_panel, -1, '')
763 button_ok = wx.Button(edit_panel, wx.ID_OK)
764 button_cancel = wx.Button(edit_panel, wx.ID_CANCEL)
765 button_ref = wx.Button(edit_panel, BUT_REF, "Reference")
766 sizer.Add(caption_text, (0,0))
767 sizer.Add(self.caption_entry, (0,1), span=(1,3), flag=wx.EXPAND)
768 sizer.Add(value_text, (1,0))
769 sizer.Add(self.value_entry, (1,1), span=(1,3), flag=wx.EXPAND)
770 sizer.Add(button_ok, (3,0))
771 sizer.Add(button_cancel, (3,1))
772 sizer.Add(button_ref, (3,2), flag=wx.EXPAND)
773 self.Bind(wx.EVT_BUTTON, self.on_reference, id=BUT_REF)
774 self.Bind(wx.EVT_BUTTON, self.on_add_option, id=wx.ID_OK)
775 self.Bind(wx.EVT_BUTTON, self.on_edit_cancel, id=wx.ID_CANCEL)
776 self.dlg.Show()
777
778 def on_add_option(self, evt):
779 self.handler.add_option(self.caption_entry.GetValue(), self.value_entry.GetValue())
643 self.reload_options() 780 self.reload_options()
781 self.dlg.Destroy()
782 component.add('tree', component.get('tree_fs')) ## Backup
783 return
784
785 ## EZ_Tree Core TaS - Prof.Ebral ##
786 def on_reference(self, evt, car=None):
787 self.do_tree = wx.Frame(self, -1, 'EZ Tree')
788 self.ez_tree = orpg.gametree.gametree
789 self.temp_wnd = self.ez_tree.game_tree(self.do_tree, self.ez_tree.EZ_REF)
790 self.temp_wnd.Bind(wx.EVT_LEFT_DCLICK, self.on_ldclick)
791 component.get('tree_fs').save_tree(settings.get("gametree"))
792 self.temp_wnd.load_tree(settings.get("gametree"))
793 self.do_tree.Show()
794
795 def get_grid_ref(self, obj, complete):
796 self.temp_wnd.Freeze()
797 self.grid_ref = complete
798 self.mini_grid = wx.Frame(self, -1, 'EZ Tree Grid')
799 self.temp_grid = obj.get_use_panel(self.mini_grid)
800 self.temp_grid.grid.Bind(wx.grid.EVT_GRID_CELL_LEFT_DCLICK, self.on_grid_ldclick)
801 self.mini_grid.Show()
802
803 def on_grid_ldclick(self, evt):
804 complete = self.grid_ref
805 row = str(evt.GetRow()+1)
806 col = str(evt.GetCol()+1)
807 complete = complete[:len(complete)-2] + '::'+'('+row+','+col+')'+complete[len(complete)-2:]
808 self.value_entry.AppendText(complete)
809 self.mini_grid.Destroy()
810
811 def on_ldclick(self, evt):
812 self.rename_flag = 0
813 pt = evt.GetPosition()
814 (item, flag) = self.temp_wnd.HitTest(pt)
815 if item.IsOk():
816 obj = self.temp_wnd.GetPyData(item)
817 self.temp_wnd.SelectItem(item)
818 start = self.handler.xml.get('map').split('::')
819 end = obj.xml.get('map').split('::')
820 if obj.xml.get('class') not in ['rpg_grid_handler', 'textctrl_handler']: do = 'None'
821 elif end[0] == '' or start[0] != end[0]: do = 'Root'
822 elif start == end: do = 'Child'
823 elif start != end: do = 'Parent'
824 if do == 'Root':
825 complete = "!@"
826 for e in end:
827 if e != '': complete += e +'::'
828 complete = complete + obj.xml.get('name') + '@!'
829 elif do == 'Parent':
830 while start[0] == end[0]:
831 del end[0], start[0]
832 if len(start) == 0 or len(end) == 0: break
833 complete = "!#"
834 for e in end: complete += e +'::'
835 complete = complete + obj.xml.get('name') + '#!'
836 elif do == 'Child':
837 while start[0] == end[0]:
838 del end[0], start[0]
839 if len(start) == 0 or len(end) == 0: break
840 complete = "!!"
841 for e in end: complete += e +'::'
842 complete = complete + obj.xml.get('name') + '!!'
843 if do != 'None':
844 if obj.xml.get('class') == 'rpg_grid_handler':
845 self.get_grid_ref(obj, complete)
846 else: self.value_entry.AppendText(complete); self.reload_options()
847 self.do_tree.Destroy()
848 if do == 'None':
849 wx.MessageBox('Invalid Reference', 'Error')
850 ##### #####
851
852 def on_edit_ok(self, evt):
853 self.handler.edit_caption(self.index, self.caption_entry.GetValue())
854 self.handler.edit_option(self.index, self.value_entry.GetValue())
855 self.reload_options()
856 self.dlg.Destroy()
857 component.add('tree', component.get('tree_fs')) ## Backup
858 return
859
860 def on_edit_cancel(self, evt):
861 self.dlg.Destroy()
862 component.add('tree', component.get('tree_fs')) ## Backup
863 return
644 864
645 def on_remove(self,evt): 865 def on_remove(self,evt):
646 index = self.listbox.GetSelection() 866 index = self.listbox.GetFocusedItem()
647 if index >= 0: 867 if index >= 0:
648 self.handler.remove_option(index) 868 self.handler.remove_option(index)
649 self.reload_options() 869 self.reload_options()
650 870
651 def on_edit(self,evt): 871 def on_edit(self,evt):
652 index = self.listbox.GetSelection() 872 self.index = self.listbox.GetFocusedItem()
653 if index >= 0: 873 if self.index >= 0:
654 txt = self.handler.get_option(index) 874 self.dlg = wx.Frame(self, -1, 'Text', size=(300,150))
655 dlg = wx.TextEntryDialog(self, 'Enter option?','Edit Option', txt) 875 edit_panel = wx.Panel(self.dlg, -1)
656 if dlg.ShowModal() == wx.ID_OK: 876 sizer = wx.GridBagSizer(1, 2)
657 self.handler.edit_option(index,dlg.GetValue()) 877 edit_panel.SetSizer(sizer)
658 dlg.Destroy() 878 caption_text = wx.StaticText(edit_panel, -1, 'Caption')
659 self.reload_options() 879 self.caption_entry = wx.TextCtrl(edit_panel, -1, self.handler.get_caption(self.index))
880 value_text = wx.StaticText(edit_panel, -1, 'Value')
881 self.value_entry = wx.TextCtrl(edit_panel, -1, self.handler.get_option(self.index))
882 button_ok = wx.Button(edit_panel, wx.ID_OK)
883 button_cancel = wx.Button(edit_panel, wx.ID_CANCEL)
884 button_ref = wx.Button(edit_panel, BUT_REF, "Reference")
885 sizer.Add(caption_text, (0,0))
886 sizer.Add(self.caption_entry, (0,1), span=(1,3), flag=wx.EXPAND)
887 sizer.Add(value_text, (1,0))
888 sizer.Add(self.value_entry, (1,1), span=(1,3), flag=wx.EXPAND)
889 sizer.Add(button_ok, (3,0))
890 sizer.Add(button_cancel, (3,1))
891 sizer.Add(button_ref, (3,2), flag=wx.EXPAND)
892 self.Bind(wx.EVT_BUTTON, self.on_reference, id=BUT_REF)
893 self.Bind(wx.EVT_BUTTON, self.on_edit_ok, id=wx.ID_OK)
894 self.Bind(wx.EVT_BUTTON, self.on_edit_cancel, id=wx.ID_CANCEL)
895 self.dlg.Show()
660 896
661 def reload_options(self): 897 def reload_options(self):
662 self.listbox.Clear() 898 self.listbox.DeleteAllItems()
663 for opt in self.handler.get_options(): 899 values = self.handler.get_options()
664 self.listbox.Append(opt) 900 captions = self.handler.get_captions()
901 for index in range(len(values)):
902 self.listbox.Append((captions[index], values[index]))
665 903
666 def on_text(self,evt): 904 def on_text(self,evt):
667 id = evt.GetId() 905 id = evt.GetId()
668 txt = self.text.GetValue() 906 txt = self.text.GetValue()
669 if not len(txt): return 907 if not len(txt): return