comparison orpg/gametree/nodehandlers/forms.py @ 212:13054be69834 beta

Traipse Beta 'OpenRPG' {100428-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 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
author sirebral
date Wed, 28 Apr 2010 08:08:09 -0500
parents a3d7e05085da
children 9230a33defd9
comparison
equal deleted inserted replaced
194:44ef45e77880 212:13054be69834
107 self.main_sizer.Add(panel, size, wx.EXPAND) 107 self.main_sizer.Add(panel, size, wx.EXPAND)
108 self.main_sizer.Add(wx.Size(10,10)) 108 self.main_sizer.Add(wx.Size(10,10))
109 109
110 F_HEIGHT = wx.NewId() 110 F_HEIGHT = wx.NewId()
111 F_WIDTH = wx.NewId() 111 F_WIDTH = wx.NewId()
112 class form_edit_panel(wx.Panel): 112 class form_edit_panel(ScrolledPanel):
113 def __init__(self, parent, handler): 113 def __init__(self, parent, handler):
114 wx.Panel.__init__(self, parent, -1) 114 ScrolledPanel.__init__(self, parent, wx.ID_ANY, style=wx.NO_BORDER|wx.VSCROLL|wx.HSCROLL)
115 self.handler = handler 115 self.handler = handler
116 sizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Form Properties"), wx.VERTICAL) 116 self.main_sizer = wx.BoxSizer(wx.VERTICAL)
117 wh_sizer = wx.BoxSizer(wx.HORIZONTAL) 117 wh_sizer = wx.BoxSizer(wx.HORIZONTAL)
118 self.text = { P_TITLE : wx.TextCtrl(self, P_TITLE, handler.xml.get('name')), 118 self.text = { P_TITLE : wx.TextCtrl(self, P_TITLE, handler.xml.get('name')),
119 F_HEIGHT : wx.TextCtrl(self, F_HEIGHT, handler.xml.get('height')), 119 F_HEIGHT : wx.TextCtrl(self, F_HEIGHT, handler.xml.get('height')),
120 F_WIDTH : wx.TextCtrl(self, F_WIDTH, handler.xml.get('width')) 120 F_WIDTH : wx.TextCtrl(self, F_WIDTH, handler.xml.get('width'))
121 } 121 }
126 wh_sizer.Add(wx.Size(10,10)) 126 wh_sizer.Add(wx.Size(10,10))
127 wh_sizer.Add(wx.StaticText(self, -1, "Height:"), 0, wx.ALIGN_CENTER) 127 wh_sizer.Add(wx.StaticText(self, -1, "Height:"), 0, wx.ALIGN_CENTER)
128 wh_sizer.Add(wx.Size(10,10)) 128 wh_sizer.Add(wx.Size(10,10))
129 wh_sizer.Add(self.text[F_HEIGHT], 0, wx.EXPAND) 129 wh_sizer.Add(self.text[F_HEIGHT], 0, wx.EXPAND)
130 130
131 sizer.Add(wx.StaticText(self, -1, "Title:"), 0, wx.EXPAND) 131 self.main_sizer.Add(wx.StaticText(self, -1, "Title:"), 0, wx.EXPAND)
132 sizer.Add(self.text[P_TITLE], 0, wx.EXPAND) 132 self.main_sizer.Add(self.text[P_TITLE], 0, wx.EXPAND)
133 sizer.Add(wx.Size(10,10)) 133 self.main_sizer.Add(wx.Size(10,10))
134 sizer.Add(wh_sizer,0,wx.EXPAND) 134 self.main_sizer.Add(wh_sizer,0,wx.EXPAND)
135 135 handler.tree.traverse(handler.mytree_node, self.create_child_wnd, None, False)
136 self.SetSizer(sizer) 136
137 self.SetSizer(self.main_sizer)
137 self.SetAutoLayout(True) 138 self.SetAutoLayout(True)
139 self.SetupScrolling()
140 parent.SetSize(self.GetSize())
138 self.Fit() 141 self.Fit()
139 parent.SetSize(self.GetBestSize())
140 142
141 self.Bind(wx.EVT_TEXT, self.on_text, id=P_TITLE) 143 self.Bind(wx.EVT_TEXT, self.on_text, id=P_TITLE)
142 self.Bind(wx.EVT_TEXT, self.on_text, id=F_HEIGHT) 144 self.Bind(wx.EVT_TEXT, self.on_text, id=F_HEIGHT)
143 self.Bind(wx.EVT_TEXT, self.on_text, id=F_WIDTH) 145 self.Bind(wx.EVT_TEXT, self.on_text, id=F_WIDTH)
144 146
152 elif id == F_HEIGHT or id == F_WIDTH: 154 elif id == F_HEIGHT or id == F_WIDTH:
153 try: int(txt) 155 try: int(txt)
154 except: return 0 156 except: return 0
155 if id == F_HEIGHT: self.handler.xml.set("height",txt) 157 if id == F_HEIGHT: self.handler.xml.set("height",txt)
156 elif id == F_WIDTH: self.handler.xml.set("width",txt) 158 elif id == F_WIDTH: self.handler.xml.set("width",txt)
159
160 def create_child_wnd(self, treenode, evt):
161 node = self.handler.tree.GetPyData(treenode)
162 panel = node.get_design_panel(self)
163 size = node.get_size_constraint()
164 if panel:
165 self.main_sizer.Add(panel, size, wx.EXPAND)
166 self.main_sizer.Add(wx.Size(10,10))
157 167
158 ########################## 168 ##########################
159 ## control handler 169 ## control handler
160 ########################## 170 ##########################
161 class control_handler(node_handler): 171 class control_handler(node_handler):
261 #txt = strip_text(txt) ##Does not seem to exist. 271 #txt = strip_text(txt) ##Does not seem to exist.
262 self.handler.text_elem.text = txt 272 self.handler.text_elem.text = txt
263 273
264 def on_send(self, evt): 274 def on_send(self, evt):
265 txt = self.text.GetValue() 275 txt = self.text.GetValue()
266 txt = Parse.NodeMap(txt, self.handler.xml) 276 txt = Parse.ParseLogic(txt, self.handler.xml)
267 txt = Parse.NodeParent(txt, self.handler.xml.get('map'))
268 if not self.handler.is_raw_send(): 277 if not self.handler.is_raw_send():
269 Parse.Post(self.handler.tohtml(), True, True) 278 Parse.Post(self.handler.tohtml(), self.chat, True, True)
270 return 1 279 return 1
271 actionlist = txt.split("\n") 280 actionlist = txt.split("\n")
272 for line in actionlist: 281 for line in actionlist:
282 line = Parse.ParseLogic(line, self.handler.xml)
273 if(line != ""): 283 if(line != ""):
274 if line[0] != "/": ## it's not a slash command 284 if line[0] != "/": ## it's not a slash command
275 Parse.Post(line, True, True) 285 Parse.Post(line, self.chat, True, True)
276 else: 286 else:
277 action = line 287 action = line
278 self.chat.chat_cmds.docmd(action) 288 self.chat.chat_cmds.docmd(action)
279 return 1 289 return 1
280 290
318 multi = 1 328 multi = 1
319 else: 329 else:
320 sizer_style=wx.EXPAND 330 sizer_style=wx.EXPAND
321 text_style = 0 331 text_style = 0
322 multi = 0 332 multi = 0
323 self.text = wx.TextCtrl(self, F_TEXT, handler.get_value(),style=text_style) 333 self.text = wx.TextCtrl(self, F_TEXT, handler.get_value() or '',style=text_style)
324 sizer.Add(wx.Size(5,0)) 334 sizer.Add(wx.Size(5,0))
325 sizer.Add(self.text, multi, sizer_style) 335 sizer.Add(self.text, multi, sizer_style)
326 self.SetSizer(sizer) 336 self.SetSizer(sizer)
327 self.SetAutoLayout(True) 337 self.SetAutoLayout(True)
328 338
594 def get_value(self): 604 def get_value(self):
595 return "\n".join(self.get_selections_text()) 605 return "\n".join(self.get_selections_text())
596 606
597 def on_send_to_chat(self, evt): 607 def on_send_to_chat(self, evt):
598 txt = self.get_selected_text() 608 txt = self.get_selected_text()
599 txt = Parse.NodeMap(txt, self.xml) 609 txt = Parse.ParseLogic(txt, self.xml)
600 txt = Parse.NodeParent(txt, self.xml.get('map'))
601 if not self.is_raw_send(): 610 if not self.is_raw_send():
602 Parse.Post(self.tohtml(), True, True) 611 Parse.Post(self.tohtml(), self.chat, True, True)
603 return 1 612 return 1
604 actionlist = self.get_selections_text() 613 actionlist = self.get_selections_text()
605 for line in actionlist: 614 for line in actionlist:
606 line = Parse.NodeMap(line, self.xml) 615 line = Parse.ParseLogic(line, self.xml)
607 line = Parse.NodeParent(line, self.xml.get('map'))
608 if(line != ""): 616 if(line != ""):
609 if line[0] != "/": ## it's not a slash command 617 if line[0] != "/": ## it's not a slash command
610 Parse.Post(line, True, True) 618 Parse.Post(line, self.chat, True, True)
611 else: 619 else:
612 action = line 620 action = line
613 self.chat.chat_cmds.docmd(action) 621 self.chat.chat_cmds.docmd(action)
614 return 1 622 return 1
615 623
619 627
620 628
621 class listbox_panel(wx.Panel): 629 class listbox_panel(wx.Panel):
622 def __init__(self, parent, handler): 630 def __init__(self, parent, handler):
623 wx.Panel.__init__(self, parent, -1) 631 wx.Panel.__init__(self, parent, -1)
632 #ScrolledPanel.__init__(self, parent, wx.ID_ANY, style=wx.NO_BORDER|wx.VSCROLL|wx.HSCROLL)
624 self.handler = handler 633 self.handler = handler
625 self.chat = handler.chat 634 self.chat = handler.chat
626 opts = [] 635 opts = []
627 values = handler.get_options() 636 values = handler.get_options()
628 captions = handler.get_captions() 637 captions = handler.get_captions()
636 if type == L_DROP: 645 if type == L_DROP:
637 self.list = wx.ComboBox(self, F_LIST, cur_opt, choices=opts, style=wx.CB_READONLY) 646 self.list = wx.ComboBox(self, F_LIST, cur_opt, choices=opts, style=wx.CB_READONLY)
638 if self.list.GetSize()[0] > 200: 647 if self.list.GetSize()[0] > 200:
639 self.list.Destroy() 648 self.list.Destroy()
640 self.list = wx.ComboBox(self, F_LIST, cur_opt, size=(200, -1), choices=opts, style=wx.CB_READONLY) 649 self.list = wx.ComboBox(self, F_LIST, cur_opt, size=(200, -1), choices=opts, style=wx.CB_READONLY)
641 elif type == L_LIST: self.list = wx.ListBox(self,F_LIST,choices=opts) 650 elif type == L_LIST: self.list = wx.ListBox(self, F_LIST, choices=opts)
642 elif type == L_RADIO: self.list = wx.RadioBox(self,F_LIST,label,choices=opts,majorDimension=3) 651 elif type == L_RADIO: self.list = wx.RadioBox(self, F_LIST, label, choices=opts, majorDimension=3)
643 elif type == L_CHECK: 652 elif type == L_CHECK:
644 self.list = wx.CheckListBox(self,F_LIST,choices=opts) 653 self.list = wx.CheckListBox(self,F_LIST,choices=opts)
645 self.set_checks() 654 self.set_checks()
646 655
647 for i in handler.get_selections_text(): 656 for i in handler.get_selections_text():
649 else: self.list.SetStringSelection( i ) 658 else: self.list.SetStringSelection( i )
650 if type == L_DROP: sizer = wx.BoxSizer(wx.HORIZONTAL) 659 if type == L_DROP: sizer = wx.BoxSizer(wx.HORIZONTAL)
651 else: sizer = wx.BoxSizer(wx.VERTICAL) 660 else: sizer = wx.BoxSizer(wx.VERTICAL)
652 661
653 if type != L_RADIO: 662 if type != L_RADIO:
654 sizer.Add(wx.StaticText(self, -1, label+": "), 0, wx.EXPAND) 663 sizer.Add(wx.StaticText(self, -1, label+": "), 0, wx.EXPAND|wx.ALL)
655 sizer.Add(wx.Size(5,0)) 664 sizer.Add(self.list, 1, wx.EXPAND|wx.ALL)
656 sizer.Add(self.list, 1, wx.EXPAND)
657 if handler.has_send_button(): 665 if handler.has_send_button():
658 sizer.Add(wx.Button(self, F_SEND, "Send"), 0, wx.EXPAND) 666 sizer.Add(wx.Button(self, F_SEND, "Send"), 0, wx.EXPAND|wx.ALL)
659 self.Bind(wx.EVT_BUTTON, self.handler.on_send_to_chat, id=F_SEND) 667 self.Bind(wx.EVT_BUTTON, self.handler.on_send_to_chat, id=F_SEND)
660 self.sizer = sizer 668 self.sizer = sizer
661 self.SetSizer(sizer) 669 self.SetSizer(sizer)
662 self.SetAutoLayout(True) 670 self.SetAutoLayout(True)
671 #self.SetupScrolling()
672 #parent.SetSize(self.GetBestSize())
663 self.Fit() 673 self.Fit()
664 parent.SetSize(self.GetBestSize())
665 674
666 if type == L_DROP: self.Bind(wx.EVT_COMBOBOX, self.on_change, id=F_LIST) 675 if type == L_DROP: self.Bind(wx.EVT_COMBOBOX, self.on_change, id=F_LIST)
667 elif type == L_LIST: self.Bind(wx.EVT_LISTBOX, self.on_change, id=F_LIST) 676 elif type == L_LIST: self.Bind(wx.EVT_LISTBOX, self.on_change, id=F_LIST)
668 elif type == L_RADIO: self.Bind(wx.EVT_RADIOBOX, self.on_change, id=F_LIST) 677 elif type == L_RADIO: self.Bind(wx.EVT_RADIOBOX, self.on_change, id=F_LIST)
669 elif type == L_CHECK:self.Bind(wx.EVT_CHECKLISTBOX, self.on_check, id=F_LIST) 678 elif type == L_CHECK:self.Bind(wx.EVT_CHECKLISTBOX, self.on_check, id=F_LIST)