comparison orpg/gametree/nodehandlers/core.py @ 132:fe4dc5817d5e alpha

Traipse Alpha 'OpenRPG' {091005-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 Gamtree Recusion method, mapping, and context sensitivity. !!Alpha - Watch out for infinite loops!! Dead Node Children, now that's a O O -v-v- Happy Halloween!
author sirebral
date Thu, 05 Nov 2009 12:15:19 -0600
parents 217fb049bd00
children 06f10429eedc
comparison
equal deleted inserted replaced
131:90d19eb43830 132:fe4dc5817d5e
40 from wx import DisplaySize 40 from wx import DisplaySize
41 except: 41 except:
42 import wx 42 import wx
43 43
44 from xml.etree.ElementTree import ElementTree, Element, tostring, XML 44 from xml.etree.ElementTree import ElementTree, Element, tostring, XML
45 from orpg.tools.orpg_log import debug
45 46
46 #html defaults 47 #html defaults
47 TH_BG = "#E9E9E9" 48 TH_BG = "#E9E9E9"
48 ########################## 49 ##########################
49 ## base node handler 50 ## base node handler
104 except: 105 except:
105 del self.myeditor 106 del self.myeditor
106 if self.create_designframe(): 107 if self.create_designframe():
107 self.myeditor.Show() 108 self.myeditor.Show()
108 self.myeditor.Raise() 109 self.myeditor.Raise()
109 else: 110 else: return
110 return
111 wx.CallAfter(self.myeditor.Layout) 111 wx.CallAfter(self.myeditor.Layout)
112
113 112
114 def create_designframe(self): 113 def create_designframe(self):
115 title = self.xml.get('name') + " Editor" 114 title = self.xml.get('name') + " Editor"
116 self.myeditor = wx.Frame(None, -1, title) 115 self.myeditor = wx.Frame(None, -1, title)
117 self.myeditor.Freeze() 116 self.myeditor.Freeze()
129 128
130 self.myeditor.SetSizer(sizer) 129 self.myeditor.SetSizer(sizer)
131 self.myeditor.SetAutoLayout(True) 130 self.myeditor.SetAutoLayout(True)
132 131
133 (x, y) = self.myeditor.GetSize() 132 (x, y) = self.myeditor.GetSize()
134 if x < 400: 133 if x < 400: x = 400
135 x = 400 134 if y < 400: y = 400
136 if y < 400:
137 y = 400
138 135
139 self.myeditor.SetSize((x, y)) 136 self.myeditor.SetSize((x, y))
140 self.myeditor.Layout() 137 self.myeditor.Layout()
141 self.myeditor.Thaw() 138 self.myeditor.Thaw()
142
143 return True 139 return True
144 140
145 def on_use(self,evt): 141 def on_use(self,evt):
146 try: 142 try:
147 self.mywindow.Show() 143 self.mywindow.Show()
156 self.mywindow.Raise() 152 self.mywindow.Raise()
157 else: 153 else:
158 return 154 return
159 wx.CallAfter(self.mywindow.Layout) 155 wx.CallAfter(self.mywindow.Layout)
160 156
161
162 def create_useframe(self): 157 def create_useframe(self):
163 caption = self.xml.get('name', '') 158 caption = self.xml.get('name', '')
164 self.mywindow = wx.Frame(None, -1, caption) 159 self.mywindow = wx.Frame(None, -1, caption)
165 self.mywindow.Freeze() 160 self.mywindow.Freeze()
166 161
178 self.mywindow.SetSizer(sizer) 173 self.mywindow.SetSizer(sizer)
179 self.mywindow.SetAutoLayout(True) 174 self.mywindow.SetAutoLayout(True)
180 175
181 if self.frame_size is None: 176 if self.frame_size is None:
182 self.frame_size = self.mywindow.GetSize() 177 self.frame_size = self.mywindow.GetSize()
183 if self.frame_size.x < 400: 178 if self.frame_size.x < 400: self.frame_size.x = 400
184 self.frame_size.x = 400 179 if self.frame_size.y < 400: self.frame_size.y = 400
185 if self.frame_size.y < 400:
186 self.frame_size.y = 400
187 180
188 self.mywindow.Layout() 181 self.mywindow.Layout()
189 self.mywindow.Thaw() 182 self.mywindow.Thaw()
190
191 self.mywindow.Bind(wx.EVT_CLOSE, self.close_useframe) 183 self.mywindow.Bind(wx.EVT_CLOSE, self.close_useframe)
192
193 return True 184 return True
194 185
195 def close_useframe(self, evt): 186 def close_useframe(self, evt):
196 self.frame_size = self.mywindow.GetSize() 187 self.frame_size = self.mywindow.GetSize()
197 self.frame_pos = self.mywindow.GetPosition() 188 self.frame_pos = self.mywindow.GetPosition()
199 self.xml.set("frame", frame_values) 190 self.xml.set("frame", frame_values)
200 self.mywindow.Destroy() 191 self.mywindow.Destroy()
201 192
202 193
203 def on_html_view(self,evt): 194 def on_html_view(self,evt):
204 try: 195 try: self.myviewer.Raise()
205 self.myviewer.Raise()
206 except: 196 except:
207 caption = self.xml.get('name') 197 caption = self.xml.get('name')
208 self.myviewer = wx.Frame(None, -1, caption) 198 self.myviewer = wx.Frame(None, -1, caption)
209 if wx.Platform == '__WXMSW__': 199 if wx.Platform == '__WXMSW__':
210 icon = wx.Icon(orpg.dirpath.dir_struct["icon"] + 'grid.ico', wx.BITMAP_TYPE_ICO) 200 icon = wx.Icon(orpg.dirpath.dir_struct["icon"] + 'grid.ico', wx.BITMAP_TYPE_ICO)
232 pass 222 pass
233 223
234 def on_send_to_chat(self,evt): 224 def on_send_to_chat(self,evt):
235 self.chat.ParsePost(self.tohtml(),True,True) 225 self.chat.ParsePost(self.tohtml(),True,True)
236 226
237 def on_drop(self,evt): 227 def on_drop(self, evt):
238 drag_obj = self.tree.drag_obj 228 drag_obj = self.tree.drag_obj
239 if drag_obj == self or self.tree.is_parent_node(self.mytree_node,drag_obj.mytree_node): 229 if drag_obj == self or self.tree.is_parent_node(self.mytree_node, drag_obj.mytree_node):
240 return 230 return
241 #if self.is_my_child(self.mytree_node,drag_obj.mytree_node):
242 # return
243 drop_xml = self.tree.drag_obj.delete() 231 drop_xml = self.tree.drag_obj.delete()
244 parent_node = self.tree.GetItemParent(self.mytree_node) 232 parent_node = self.tree.GetItemParent(self.mytree_node)
245 prev_sib = self.tree.GetPrevSibling(self.mytree_node) 233 prev_sib = self.tree.GetPrevSibling(self.mytree_node)
246 if parent_node == self.tree.root: 234 if parent_node == self.tree.root: parent_xml = self.tree.GetPyData(parent_node)
247 parent_xml = self.tree.GetPyData(parent_node) 235 else: parent_xml = self.tree.GetPyData(parent_node).xml
248 else:
249 parent_xml = self.tree.GetPyData(parent_node).xml
250 for i in range(len(parent_xml)): 236 for i in range(len(parent_xml)):
251 if parent_xml[i] is self.xml: 237 if parent_xml[i] is self.xml:
252 parent_xml.insert(i, drop_xml) 238 parent_xml.insert(i, drop_xml)
253 break 239 break
254 if not prev_sib.IsOk(): 240 if not prev_sib.IsOk():
255 prev_sib = parent_node 241 prev_sib = parent_node
256 self.tree.load_xml(drop_xml, parent_node, prev_sib) 242 self.tree.load_xml(drop_xml, parent_node, prev_sib)
243
244 def get_tree(self):
245 family = []
246 test = treenode
247 while test != self.tree.root:
248 test = self.tree.GetItemParent(test)
249 parent = self.tree.GetItemText(test)
250 family.append(parent)
251 return family
257 252
258 def toxml(self,pretty=0): 253 def toxml(self,pretty=0):
259 return tostring(self.xml) #toxml(self.master_dom,pretty) 254 return tostring(self.xml) #toxml(self.master_dom,pretty)
260 255
261 def tohtml(self): 256 def tohtml(self):
308 def about(self): 303 def about(self):
309 html_str = "<b>"+ self.xml.get('class') 304 html_str = "<b>"+ self.xml.get('class')
310 html_str += " Applet</b><br />by Chris Davis<br />chris@rpgarchive.com" 305 html_str += " Applet</b><br />by Chris Davis<br />chris@rpgarchive.com"
311 return html_str 306 return html_str
312 307
313 def set_referenceable(self, value):
314 if value:
315 self.xml.set('referenceable', '1')
316 else:
317 self.xml.set('referenceable', '0')
318
319 def get_referenceable(self):
320 if 'referenceable' in self.xml.attrib and self.xml.get('referenceable')=="0":
321 return False
322 return True
323
324 def set_namespace(self, value):
325 if value:
326 self.xml.set('namespace', '1')
327 else:
328 self.xml.set('namespace', '0')
329
330 def get_namespace(self):
331 if 'namespace' in self.xml.attrib and self.xml.get('namespace')=="1":
332 return True
333 return False
334
335 def get_value(self): 308 def get_value(self):
336 return None 309 return None
337
338 310
339 311
340 P_TITLE = 10 312 P_TITLE = 10
341 P_BODY = 20 313 P_BODY = 20
342 class text_edit_panel(wx.Panel): 314 class text_edit_panel(wx.Panel):
345 self.handler = handler 317 self.handler = handler
346 sizer = wx.BoxSizer(wx.VERTICAL) 318 sizer = wx.BoxSizer(wx.VERTICAL)
347 self.text = { P_TITLE : wx.TextCtrl(self, P_TITLE, handler.xml.get('name')), 319 self.text = { P_TITLE : wx.TextCtrl(self, P_TITLE, handler.xml.get('name')),
348 P_BODY : html_text_edit(self,P_BODY,handler.text,self.on_text) 320 P_BODY : html_text_edit(self,P_BODY,handler.text,self.on_text)
349 } 321 }
350 #P_BODY : wx.TextCtrl(self, P_BODY,handler.text, style=wx.TE_MULTILINE)
351
352 sizer.Add(wx.StaticText(self, -1, "Title:"), 0, wx.EXPAND) 322 sizer.Add(wx.StaticText(self, -1, "Title:"), 0, wx.EXPAND)
353 sizer.Add(self.text[P_TITLE], 0, wx.EXPAND) 323 sizer.Add(self.text[P_TITLE], 0, wx.EXPAND)
354 sizer.Add(wx.StaticText(self, -1, "Text Body:"), 0, wx.EXPAND) 324 sizer.Add(wx.StaticText(self, -1, "Text Body:"), 0, wx.EXPAND)
355 sizer.Add(self.text[P_BODY], 1, wx.EXPAND) 325 sizer.Add(self.text[P_BODY], 1, wx.EXPAND)
356 self.sizer = sizer 326 self.sizer = sizer