Mercurial > traipse_dev
comparison orpg/gametree/nodehandlers/containers.py @ 151:06f10429eedc alpha
Traipse Alpha '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 (Cleaning up for 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:15:49 -0600 |
parents | 1ed2feab0db9 |
children | bf799efe7a8a |
comparison
equal
deleted
inserted
replaced
149:c2caca988a11 | 151:06f10429eedc |
---|---|
27 # | 27 # |
28 | 28 |
29 | 29 |
30 from core import * | 30 from core import * |
31 from wx.lib.splitter import MultiSplitterWindow | 31 from wx.lib.splitter import MultiSplitterWindow |
32 | 32 from orpg.tools.orpg_log import logger |
33 | 33 from orpg.orpgCore import component |
34 ########################## | 34 |
35 ## base contiainer | 35 ########################## |
36 ## base container | |
36 ########################## | 37 ########################## |
37 | 38 |
38 class container_handler(node_handler): | 39 class container_handler(node_handler): |
39 """ should not be used! only a base class! | 40 """ should not be used! only a base class! |
40 <nodehandler name='?' module='core' class='container_handler' /> | 41 <nodehandler name='?' module='core' class='container_handler' /> |
42 def __init__(self, xml, tree_node): | 43 def __init__(self, xml, tree_node): |
43 node_handler.__init__(self, xml, tree_node) | 44 node_handler.__init__(self, xml, tree_node) |
44 self.load_children() | 45 self.load_children() |
45 | 46 |
46 def load_children(self): | 47 def load_children(self): |
47 for child_xml in self.xml: | 48 for child_xml in self.xml: self.tree.load_xml(child_xml,self.mytree_node) |
48 self.tree.load_xml(child_xml,self.mytree_node) | |
49 | 49 |
50 def check_map_aware(self, treenode, evt): | 50 def check_map_aware(self, treenode, evt): |
51 node = self.tree.GetPyData(treenode) | 51 node = self.tree.GetPyData(treenode) |
52 if hasattr(node,"map_aware") and node.map_aware(): | 52 if hasattr(node,"map_aware") and node.map_aware(): node.on_send_to_map(evt) |
53 node.on_send_to_map(evt) | |
54 | 53 |
55 def on_send_to_map(self, evt): | 54 def on_send_to_map(self, evt): |
56 self.tree.traverse(self.mytree_node, self.check_map_aware, evt) | 55 self.tree.traverse(self.mytree_node, self.check_map_aware, evt) |
57 | 56 |
58 def checkChildToMap(self, treenode, evt): | 57 def checkChildToMap(self, treenode, evt): |
59 node = self.tree.GetPyData(treenode) | 58 node = self.tree.GetPyData(treenode) |
60 if hasattr(node,"map_aware") and node.map_aware(): | 59 if hasattr(node,"map_aware") and node.map_aware(): self.mapcheck = True |
61 self.mapcheck = True | |
62 | 60 |
63 def checkToMapMenu(self): | 61 def checkToMapMenu(self): |
64 self.mapcheck = False | 62 self.mapcheck = False |
65 self.tree.traverse(self.mytree_node, self.checkChildToMap) | 63 self.tree.traverse(self.mytree_node, self.checkChildToMap) |
66 return self.mapcheck | 64 return self.mapcheck |
67 | 65 |
68 def on_drop(self,evt): | 66 def on_drop(self,evt): |
69 drag_obj = self.tree.drag_obj | 67 drag_obj = self.tree.drag_obj |
70 if drag_obj == self or self.tree.is_parent_node(self.mytree_node,drag_obj.mytree_node): | 68 if drag_obj == self or self.tree.is_parent_node(self.mytree_node,drag_obj.mytree_node): return |
71 return | |
72 opt = wx.MessageBox("Add node as child?","Container Node",wx.YES_NO|wx.CANCEL) | 69 opt = wx.MessageBox("Add node as child?","Container Node",wx.YES_NO|wx.CANCEL) |
73 if opt == wx.YES: | 70 if opt == wx.YES: |
74 drop_xml = self.tree.drag_obj.delete() | 71 drop_xml = self.tree.drag_obj.delete() |
75 self.xml.insert(0, drop_xml) | 72 self.xml.insert(0, drop_xml) |
76 self.tree.load_xml(drop_xml, self.mytree_node) | 73 self.tree.load_xml(drop_xml, self.mytree_node) |
77 self.tree.Expand(self.mytree_node) | 74 self.tree.Expand(self.mytree_node) |
78 elif opt == wx.NO: | 75 elif opt == wx.NO: node_handler.on_drop(self,evt) |
79 node_handler.on_drop(self,evt) | |
80 | 76 |
81 def gen_html(self, treenode, evt): | 77 def gen_html(self, treenode, evt): |
82 node = self.tree.GetPyData(treenode) | 78 node = self.tree.GetPyData(treenode) |
83 self.html_str += "<p>" + node.tohtml() | 79 self.html_str += "<p>" + node.tohtml() |
84 | 80 |
85 def tohtml(self): | 81 def tohtml(self): |
86 self.html_str = "<table border=\"1\" ><tr><td>" | 82 self.html_str = "<table border='1' ><tr><td>" |
87 self.html_str += "<b>"+self.xml.get("name") + "</b>" | 83 self.html_str += "<b>"+self.xml.get("name") + "</b>" |
88 self.html_str += "</td></tr>\n" | 84 self.html_str += "</td></tr>\n" |
89 self.html_str += "<tr><td>" | 85 self.html_str += "<tr><td>" |
90 | |
91 self.tree.traverse(self.mytree_node, self.gen_html, recurse=False) | 86 self.tree.traverse(self.mytree_node, self.gen_html, recurse=False) |
92 | |
93 self.html_str += "</td></tr></table>" | 87 self.html_str += "</td></tr></table>" |
94 return self.html_str | 88 return self.html_str |
95 | 89 |
96 def get_size_constraint(self): | 90 def get_size_constraint(self): |
97 return 2 | 91 return 2 |
111 def load_children(self): | 105 def load_children(self): |
112 self.atts = None | 106 self.atts = None |
113 for child_xml in self.xml: | 107 for child_xml in self.xml: |
114 if child_xml.get == "group_atts": #having the group attributes as a child is bad! | 108 if child_xml.get == "group_atts": #having the group attributes as a child is bad! |
115 self.xml.remove(child_xml) | 109 self.xml.remove(child_xml) |
116 elif child_xml: | 110 elif child_xml: self.tree.load_xml(child_xml, self.mytree_node) |
117 self.tree.load_xml(child_xml, self.mytree_node) | |
118 if not self.xml.get('cols'): self.xml.set('cols', '1') | 111 if not self.xml.get('cols'): self.xml.set('cols', '1') |
119 if not self.xml.get('border'): self.xml.set('border', '1') | 112 if not self.xml.get('border'): self.xml.set('border', '1') |
120 """ | |
121 if not self.atts: | |
122 self.atts = Element('group_atts') | |
123 self.atts.set("cols","1") | |
124 self.atts.set("border","1") | |
125 self.xml.append(self.atts)""" | |
126 | 113 |
127 def get_design_panel(self,parent): | 114 def get_design_panel(self,parent): |
128 return group_edit_panel(parent,self) | 115 return group_edit_panel(parent,self) |
129 | 116 |
130 def on_use(self,evt): | 117 def on_use(self,evt): |
131 return | 118 return |
132 | 119 |
133 def gen_html(self, treenode, evt): | 120 def gen_html(self, treenode, evt): |
134 node = self.tree.GetPyData(treenode) | 121 node = self.tree.GetPyData(treenode) |
135 if self.i not in self.tdatas: | 122 if self.i not in self.tdatas: self.tdatas[self.i] = '' |
136 self.tdatas[self.i] = '' | |
137 self.tdatas[self.i] += "<P>" + node.tohtml() | 123 self.tdatas[self.i] += "<P>" + node.tohtml() |
138 self.i += 1 | 124 self.i += 1 |
139 if self.i >= self.cols: | 125 if self.i >= self.cols: self.i = 0 |
140 self.i = 0 | |
141 | 126 |
142 def tohtml(self): | 127 def tohtml(self): |
143 cols = self.xml.get("cols") | 128 cols = self.xml.get("cols") |
144 border = self.xml.get("border") | 129 border = self.xml.get("border") |
145 self.html_str = "<table border=\""+border+"\" ><tr><td colspan=\""+cols+"\">" | 130 self.html_str = "<table border='"+border+"' ><tr><td colspan='"+cols+"'>" |
146 self.html_str += "<font size=4>"+self.xml.get("name") + "</font>" | 131 self.html_str += "<font size=4>"+self.xml.get("name") + "</font>" |
147 self.html_str += "</td></tr>\n<tr>" | 132 self.html_str += "</td></tr>\n<tr>" |
148 self.cols = int(cols) | 133 self.cols = int(cols) |
149 self.i = 0 | 134 self.i = 0 |
150 self.tdatas = {} | 135 self.tdatas = {} |
151 self.tree.traverse(self.mytree_node, self.gen_html, recurse=False) | 136 self.tree.traverse(self.mytree_node, self.gen_html, recurse=False) |
152 for td in self.tdatas: | 137 for td in self.tdatas: self.html_str += "<td valign='top' >" + self.tdatas[td] + "</td>\n"; |
153 self.html_str += "<td valign=\"top\" >" + self.tdatas[td] + "</td>\n"; | |
154 self.html_str += "</tr></table>" | 138 self.html_str += "</tr></table>" |
155 return self.html_str | 139 return self.html_str |
156 | 140 |
157 GROUP_COLS = wx.NewId() | 141 GROUP_COLS = wx.NewId() |
158 GROUP_BOR = wx.NewId() | 142 GROUP_BOR = wx.NewId() |
169 sizer.Add(self.text[P_TITLE], 0, wx.EXPAND) | 153 sizer.Add(self.text[P_TITLE], 0, wx.EXPAND) |
170 sizer.Add(wx.Size(10,10)) | 154 sizer.Add(wx.Size(10,10)) |
171 | 155 |
172 radio_c = wx.RadioBox(self, GROUP_COLS, "Columns", choices=["1","2","3","4"]) | 156 radio_c = wx.RadioBox(self, GROUP_COLS, "Columns", choices=["1","2","3","4"]) |
173 cols = handler.xml.get("cols") | 157 cols = handler.xml.get("cols") |
174 if cols != "": | 158 if cols != "": radio_c.SetSelection(int(cols)-1) |
175 radio_c.SetSelection(int(cols)-1) | |
176 | 159 |
177 radio_b = wx.RadioBox(self, GROUP_BOR, "Border", choices=["no","yes"]) | 160 radio_b = wx.RadioBox(self, GROUP_BOR, "Border", choices=["no","yes"]) |
178 border = handler.xml.get("border") | 161 border = handler.xml.get("border") |
179 if border != "": | 162 if border != "": radio_b.SetSelection(int(border)) |
180 radio_b.SetSelection(int(border)) | |
181 | 163 |
182 sizer.Add(radio_c, 0, wx.EXPAND) | 164 sizer.Add(radio_c, 0, wx.EXPAND) |
183 sizer.Add(wx.Size(10,10)) | 165 sizer.Add(wx.Size(10,10)) |
184 sizer.Add(radio_b, 0, wx.EXPAND) | 166 sizer.Add(radio_b, 0, wx.EXPAND) |
185 | 167 |
194 self.Bind(wx.EVT_RADIOBOX, self.on_radio_box, id=GROUP_COLS) | 176 self.Bind(wx.EVT_RADIOBOX, self.on_radio_box, id=GROUP_COLS) |
195 | 177 |
196 def on_radio_box(self,evt): | 178 def on_radio_box(self,evt): |
197 id = evt.GetId() | 179 id = evt.GetId() |
198 index = evt.GetInt() | 180 index = evt.GetInt() |
199 if id == GROUP_COLS: | 181 if id == GROUP_COLS: self.handler.xml.set("cols",str(index+1)) |
200 self.handler.xml.set("cols",str(index+1)) | 182 elif id == GROUP_BOR: self.handler.xml.set("border",str(index)) |
201 elif id == GROUP_BOR: | |
202 self.handler.xml.set("border",str(index)) | |
203 | 183 |
204 def on_text(self,evt): | 184 def on_text(self,evt): |
205 id = evt.GetId() | 185 id = evt.GetId() |
206 if id == P_TITLE: | 186 if id == P_TITLE: |
207 txt = self.text[id].GetValue() | 187 txt = self.text[id].GetValue() |
238 def pick_panel(self, treenode, mode): | 218 def pick_panel(self, treenode, mode): |
239 node = self.handler.tree.GetPyData(treenode) | 219 node = self.handler.tree.GetPyData(treenode) |
240 if mode == 1: panel = node.get_design_panel(self) | 220 if mode == 1: panel = node.get_design_panel(self) |
241 else: panel = node.get_use_panel(self) | 221 else: panel = node.get_use_panel(self) |
242 name = node.xml.get("name") | 222 name = node.xml.get("name") |
223 if name == None: ## Fixes broken 3e Inventory child | |
224 if node.xml.tag == 'inventory': | |
225 node.xml.set('name', 'Inventory') | |
226 name = "Inventory" | |
227 logger.info('A corrective action was take to a 3e PC Sheet', True) | |
228 component.get('frame').TraipseSuiteWarn('item') | |
243 if panel: self.AddPage(panel, name, False) | 229 if panel: self.AddPage(panel, name, False) |
244 | 230 |
245 class tabbed_edit_panel(orpgTabberWnd): | 231 class tabbed_edit_panel(orpgTabberWnd): |
246 def __init__(self, parent, handler): | 232 def __init__(self, parent, handler): |
247 orpgTabberWnd.__init__(self, parent, style=FNB.FNB_NO_X_BUTTON) | 233 orpgTabberWnd.__init__(self, parent, style=FNB.FNB_NO_X_BUTTON) |
312 if mode == 1: tmp = node.get_design_panel(self.splitter) | 298 if mode == 1: tmp = node.get_design_panel(self.splitter) |
313 else: tmp = node.get_use_panel(self.splitter) | 299 else: tmp = node.get_use_panel(self.splitter) |
314 if self.split == '1': | 300 if self.split == '1': |
315 sash = tmp.GetBestSize()[1]+1 | 301 sash = tmp.GetBestSize()[1]+1 |
316 self.bestSizey += sash+11 | 302 self.bestSizey += sash+11 |
317 if self.bestSizex < tmp.GetBestSize()[0]: | 303 if self.bestSizex < tmp.GetBestSize()[0]: self.bestSizex = tmp.GetBestSize()[0]+10 |
318 self.bestSizex = tmp.GetBestSize()[0]+10 | |
319 else: | 304 else: |
320 sash = tmp.GetBestSize()[0]+1 | 305 sash = tmp.GetBestSize()[0]+1 |
321 self.bestSizex += sash | 306 self.bestSizex += sash |
322 if self.bestSizey < tmp.GetBestSize()[1]: | 307 if self.bestSizey < tmp.GetBestSize()[1]: self.bestSizey = tmp.GetBestSize()[1]+31 |
323 self.bestSizey = tmp.GetBestSize()[1]+31 | |
324 self.splitter.AppendWindow(tmp, sash) | 308 self.splitter.AppendWindow(tmp, sash) |
325 def get_size_constraint(self): | 309 def get_size_constraint(self): |
326 return 1 | 310 return 1 |
327 | 311 |
328 class splitter_panel(wx.Panel): | 312 class splitter_panel(wx.Panel): |
340 | 324 |
341 sizer.Add(wx.StaticText(self, -1, "Title:"), 0, wx.EXPAND) | 325 sizer.Add(wx.StaticText(self, -1, "Title:"), 0, wx.EXPAND) |
342 sizer.Add(self.title, 0) | 326 sizer.Add(self.title, 0) |
343 sizer.Add(self.hozCheck, 0, wx.EXPAND) | 327 sizer.Add(self.hozCheck, 0, wx.EXPAND) |
344 sizer.Add(wx.Size(10,0)) | 328 sizer.Add(wx.Size(10,0)) |
345 #sizer.Add(self.splitsize, 1, wx.EXPAND) | |
346 | 329 |
347 self.sizer = sizer | 330 self.sizer = sizer |
348 self.SetSizer(self.sizer) | 331 self.SetSizer(self.sizer) |
349 self.SetAutoLayout(True) | 332 self.SetAutoLayout(True) |
350 self.Bind(wx.EVT_TEXT, self.on_text, id=1) | 333 self.Bind(wx.EVT_TEXT, self.on_text, id=1) |