Mercurial > traipse_dev
diff orpg/gametree/nodehandlers/forms.py @ 173:0dde29a41614 alpha
Traipse Alpha 'OpenRPG' {100107-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 (Keeping up with 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
Added 7th Sea die roller method; 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)].
Includes support for Mythos roller
New EZ_Tree Reference system. Push a button, Traipse the tree, get a
reference (Alpha!!)
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
Fixed Whiteboard ID to prevent random line or text deleting.
Modified ID's to prevent non updated clients from ruining the fix.
default_manifest.xml renamed to default_upmana.xml
Fix to Update Manager; cleaner clode for saved repositories
Fixes made to Settings Panel and no 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
author | sirebral |
---|---|
date | Thu, 07 Jan 2010 01:53:12 -0600 |
parents | bf799efe7a8a |
children | ff6cbd2b7620 |
line wrap: on
line diff
--- a/orpg/gametree/nodehandlers/forms.py Thu Dec 10 22:30:15 2009 -0600 +++ b/orpg/gametree/nodehandlers/forms.py Thu Jan 07 01:53:12 2010 -0600 @@ -32,6 +32,7 @@ import orpg.minidom as minidom from orpg.orpg_xml import xml from wx.lib.scrolledpanel import ScrolledPanel +from orpg.tools.settings import settings def bool2int(b): #in wxPython 2.5+, evt.Checked() returns True or False instead of 1.0 or 0. @@ -281,6 +282,7 @@ F_RAW_SEND = wx.NewId() F_HIDE_TITLE = wx.NewId() F_TEXT = wx.NewId() +T_BUT_REF = wx.NewId() class textctrl_edit_panel(wx.Panel): def __init__(self, parent, handler): @@ -297,6 +299,7 @@ self.hide_title.SetValue(handler.is_hide_title()) self.send_button = wx.CheckBox(self, F_SEND_BUTTON, " Send Button") self.send_button.SetValue(handler.has_send_button()) + button_ref = wx.Button(self, T_BUT_REF, "Reference") sizer.Add(wx.StaticText(self, P_TITLE, "Title:"), 0, wx.EXPAND) sizer.Add(self.title, 0, wx.EXPAND) @@ -305,6 +308,7 @@ sizer.Add(self.raw_send, 0, wx.EXPAND) sizer.Add(self.hide_title, 0, wx.EXPAND) sizer.Add(self.send_button, 0 , wx.EXPAND) + sizer.Add(button_ref, 0) sizer.Add(wx.Size(10,10)) if handler.is_multi_line(): sizer_style = wx.EXPAND @@ -326,6 +330,39 @@ self.Bind(wx.EVT_CHECKBOX, self.on_raw_button, id=F_RAW_SEND) self.Bind(wx.EVT_CHECKBOX, self.on_hide_button, id=F_HIDE_TITLE) self.Bind(wx.EVT_CHECKBOX, self.on_send_button, id=F_SEND_BUTTON) + self.Bind(wx.EVT_BUTTON, self.on_reference, id=T_BUT_REF) + + ## EZ_Tree Core TaS - Prof.Ebral ## + def on_reference(self, evt, car=None): + self.do_tree = wx.Frame(self, -1, 'Tree') + self.ez_tree = orpg.gametree.gametree + self.temp_wnd = self.ez_tree.game_tree(self.do_tree, self.ez_tree.EZ_REF) + self.temp_wnd.Bind(wx.EVT_LEFT_DCLICK, self.on_ldclick) + self.temp_wnd.load_tree(settings.get("gametree")) + self.do_tree.Show() + + def on_ldclick(self, evt): + self.rename_flag = 0 + pt = evt.GetPosition() + (item, flag) = self.temp_wnd.HitTest(pt) + if item.IsOk(): + obj = self.temp_wnd.GetPyData(item) + self.temp_wnd.SelectItem(item) + start = self.handler.xml.get('map').split('::') + end = obj.xml.get('map').split('::') + x = 0 + if start[x] == end[x]: + try: + while start[x] == end[x]: + del end[x], start[x] + x += 1 + except: + complete = "!!" + for e in end: complete += e +'::' + complete = complete + obj.xml.get('name') + '!!' + self.text.AppendText(complete); self.on_text(evt) + self.do_tree.Destroy() + ##### ##### def on_text(self,evt): id = evt.GetId() @@ -377,12 +414,21 @@ """ def __init__(self,xml,tree_node): node_handler.__init__(self,xml,tree_node) - self.list = self.xml.find('list') - self.options = self.list.findall('option') + self.list_reload() + #print xml + #print self.tree.GetItemParent(tree_node) if self.list.get("send_button") == "": self.list.set("send_button","0") if self.list.get("hide_title") == "": self.list.set("hide_title","0") if self.list.get("raw_mode") == "": self.list.set("raw_mode","0") + def list_reload(self): + self.list = self.xml.find('list') + self.options = self.list.findall('option') + self.captions = [] + for opt in self.options: + if opt.get('caption') == None: opt.set('caption', '') + self.captions.append(opt.get('caption')) + def get_design_panel(self,parent): return listbox_edit_panel(parent,self) @@ -454,24 +500,39 @@ for opt in self.options: opts.append(opt.text) return opts - def get_option(self,index): + def get_captions(self): + captions = [] + for opt in self.options: captions.append(opt.get("caption")) + self.captions = captions + return captions + + def get_option(self, index): return self.options[index].text - def add_option(self,opt): + def get_caption(self, index): + captions = self.get_captions() + return captions[index] or '' + + def add_option(self, caption, value): elem = Element('option') elem.set("value","0") + elem.set('caption', caption) elem.set("selected","0") - elem.text = opt + elem.text = value self.list.append(elem) - self.options = self.list.findall('option') + self.list_reload() def remove_option(self,index): self.list.remove(self.options[index]) - self.options = self.list.findall('option') + self.list_reload() - def edit_option(self,index,value): + def edit_option(self, index, value): self.options[index].text = value + def edit_caption(self, index, value): + self.options[index].set('caption', value) + self.captions[index] = value + def has_send_button(self): if self.list.get("send_button") == '0': return False else: return True @@ -518,7 +579,12 @@ wx.Panel.__init__(self, parent, -1) self.handler = handler self.chat = handler.chat - opts = handler.get_options() + opts = [] + values = handler.get_options() + captions = handler.get_captions() + for value in values: + if captions[values.index(value)] != '': opts.append(captions[values.index(value)]) + else: opts.append(value) cur_opt = handler.get_selected_text() type = handler.get_type() label = handler.xml.get('name') @@ -571,20 +637,28 @@ BUT_ADD = wx.NewId() BUT_REM = wx.NewId() +BUT_REF = wx.NewId() BUT_EDIT = wx.NewId() F_TYPE = wx.NewId() F_NO_TITLE = wx.NewId() +LIST_CTRL = wx.NewId() class listbox_edit_panel(wx.Panel): def __init__(self, parent, handler): wx.Panel.__init__(self, parent, -1) self.handler = handler + self.parent = parent sizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "List Box Properties"), wx.VERTICAL) self.text = wx.TextCtrl(self, P_TITLE, handler.xml.get('name')) - opts = handler.get_options() - self.listbox = wx.ListBox(self, F_LIST, choices=opts, style=wx.LB_HSCROLL|wx.LB_SINGLE|wx.LB_NEEDED_SB) + self.listbox = wx.ListCtrl(self, LIST_CTRL, style=wx.LC_REPORT) + self.listbox.InsertColumn(0, 'Caption') + self.listbox.InsertColumn(1, 'Value') + self.listbox.SetColumnWidth(0, 75) + self.listbox.SetColumnWidth(1, 300) + self.reload_options() + opts = ['Drop Down', 'List Box', 'Radio Box', 'Check List'] self.type_radios = wx.RadioBox(self,F_TYPE,"List Type",choices=opts) self.type_radios.SetSelection(handler.get_type()) @@ -636,11 +710,79 @@ self.handler.set_type(evt.GetInt()) def on_add(self,evt): - dlg = wx.TextEntryDialog(self, 'Enter option?','Add Option', '') - if dlg.ShowModal() == wx.ID_OK: - self.handler.add_option(dlg.GetValue()) - dlg.Destroy() + self.dlg = wx.Frame(self, -1, 'Text', size=(300,150)) + edit_panel = wx.Panel(self.dlg, -1) + sizer = wx.GridBagSizer(1, 2) + edit_panel.SetSizer(sizer) + caption_text = wx.StaticText(edit_panel, -1, 'Caption') + self.caption_entry = wx.TextCtrl(edit_panel, -1, '') + value_text = wx.StaticText(edit_panel, -1, 'Value') + self.value_entry = wx.TextCtrl(edit_panel, -1, '') + button_ok = wx.Button(edit_panel, wx.ID_OK) + button_cancel = wx.Button(edit_panel, wx.ID_CANCEL) + button_ref = wx.Button(edit_panel, BUT_REF, "Reference") + sizer.Add(caption_text, (0,0)) + sizer.Add(self.caption_entry, (0,1), span=(1,3), flag=wx.EXPAND) + sizer.Add(value_text, (1,0)) + sizer.Add(self.value_entry, (1,1), span=(1,3), flag=wx.EXPAND) + sizer.Add(button_ok, (3,0)) + sizer.Add(button_cancel, (3,1)) + sizer.Add(button_ref, (3,2), flag=wx.EXPAND) + self.Bind(wx.EVT_BUTTON, self.on_reference, id=BUT_REF) + self.Bind(wx.EVT_BUTTON, self.on_add_option, id=wx.ID_OK) + self.Bind(wx.EVT_BUTTON, self.on_edit_cancel, id=wx.ID_CANCEL) + self.dlg.Show() + + def on_add_option(self, evt): + self.handler.add_option(self.caption_entry.GetValue(), self.value_entry.GetValue()) self.reload_options() + self.dlg.Destroy() + return + + ## EZ_Tree Core TaS - Prof.Ebral ## + def on_reference(self, evt, car=None): + self.do_tree = wx.Frame(self, -1, 'Tree') + self.ez_tree = orpg.gametree.gametree + self.temp_wnd = self.ez_tree.game_tree(self.do_tree, self.ez_tree.EZ_REF) + self.temp_wnd.Bind(wx.EVT_LEFT_DCLICK, self.on_ldclick) + self.temp_wnd.load_tree(settings.get("gametree")) + self.do_tree.Show() + + def on_ldclick(self, evt): + self.rename_flag = 0 + pt = evt.GetPosition() + (item, flag) = self.temp_wnd.HitTest(pt) + if item.IsOk(): + obj = self.temp_wnd.GetPyData(item) + self.temp_wnd.SelectItem(item) + start = self.handler.xml.get('map').split('::') + end = obj.xml.get('map').split('::') + x = 0 + if start[x] == end[x]: + try: + while start[x] == end[x]: + del end[x], start[x] + x += 1 + except: + complete = "!!" + for e in end: complete += e +'::' + complete = complete + obj.xml.get('name') + '!!' + self.value_entry.SetValue(complete); self.reload_options() + self.do_tree.Destroy() + ##### ##### + + def on_edit_ok(self, evt): + self.handler.edit_caption(self.index, self.caption_entry.GetValue()) + self.handler.edit_option(self.index, self.value_entry.GetValue()) + self.reload_options() + self.dlg.Destroy() + component.add('tree', component.get('tree_back')) ## Backup + return + + def on_edit_cancel(self, evt): + self.dlg.Destroy() + component.add('tree', component.get('tree_back')) ## Backup + return def on_remove(self,evt): index = self.listbox.GetSelection() @@ -649,19 +791,37 @@ self.reload_options() def on_edit(self,evt): - index = self.listbox.GetSelection() - if index >= 0: - txt = self.handler.get_option(index) - dlg = wx.TextEntryDialog(self, 'Enter option?','Edit Option', txt) - if dlg.ShowModal() == wx.ID_OK: - self.handler.edit_option(index,dlg.GetValue()) - dlg.Destroy() - self.reload_options() + self.index = self.listbox.GetFocusedItem() + if self.index >= 0: + self.dlg = wx.Frame(self, -1, 'Text', size=(300,150)) + edit_panel = wx.Panel(self.dlg, -1) + sizer = wx.GridBagSizer(1, 2) + edit_panel.SetSizer(sizer) + caption_text = wx.StaticText(edit_panel, -1, 'Caption') + self.caption_entry = wx.TextCtrl(edit_panel, -1, self.handler.get_caption(self.index)) + value_text = wx.StaticText(edit_panel, -1, 'Value') + self.value_entry = wx.TextCtrl(edit_panel, -1, self.handler.get_option(self.index)) + button_ok = wx.Button(edit_panel, wx.ID_OK) + button_cancel = wx.Button(edit_panel, wx.ID_CANCEL) + button_ref = wx.Button(edit_panel, BUT_REF, "Reference") + sizer.Add(caption_text, (0,0)) + sizer.Add(self.caption_entry, (0,1), span=(1,3), flag=wx.EXPAND) + sizer.Add(value_text, (1,0)) + sizer.Add(self.value_entry, (1,1), span=(1,3), flag=wx.EXPAND) + sizer.Add(button_ok, (3,0)) + sizer.Add(button_cancel, (3,1)) + sizer.Add(button_ref, (3,2), flag=wx.EXPAND) + self.Bind(wx.EVT_BUTTON, self.on_reference, id=BUT_REF) + self.Bind(wx.EVT_BUTTON, self.on_edit_ok, id=wx.ID_OK) + self.Bind(wx.EVT_BUTTON, self.on_edit_cancel, id=wx.ID_CANCEL) + self.dlg.Show() def reload_options(self): - self.listbox.Clear() - for opt in self.handler.get_options(): - self.listbox.Append(opt) + self.listbox.DeleteAllItems() + values = self.handler.get_options() + captions = self.handler.get_captions() + for index in range(len(values)): + self.listbox.Append((captions[index], values[index])) def on_text(self,evt): id = evt.GetId()