changeset 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 90d19eb43830
children 37d26a98883f
files orpg/chat/chatwnd.py orpg/gametree/gametree.py orpg/gametree/nodehandlers/core.py orpg/gametree/nodehandlers/forms.py orpg/orpg_version.py
diffstat 5 files changed, 82 insertions(+), 104 deletions(-) [+]
line wrap: on
line diff
--- a/orpg/chat/chatwnd.py	Tue Nov 03 21:30:36 2009 -0600
+++ b/orpg/chat/chatwnd.py	Thu Nov 05 12:15:19 2009 -0600
@@ -1836,7 +1836,6 @@
     def ParseFilter(self, s):
         s = self.GetFilteredText(s)
         return s
-
     
     def ParseNode(self, s):
         """Parses player input for embedded nodes rolls"""
@@ -1957,7 +1956,20 @@
             else: self.data = 'Nodehandler for '+ node.get('class') + ' not done!' or 'No Data!'
         else:
             self.data = ''
-            pass
+            pass
+        self.data = self.ParseMap(self.data, node)
+
+    def ParseMap(self, s, node):
+        """Parses player input for embedded nodes rolls"""
+        cur_loc = 0
+        reg = re.compile("(!!(.*?)!!)")
+        matches = reg.findall(s)
+        print matches
+        for i in xrange(0,len(matches)):
+            newstr = txt = '!@' + node.get('map') + '::' + matches[i][1] + '@!'
+            s = s.replace(matches[i][0], newstr, 1)
+            s = self.ParseNode(s)
+        return s
 
     def resolve_nodes(self, s):
         self.passed = False
--- a/orpg/gametree/gametree.py	Tue Nov 03 21:30:36 2009 -0600
+++ b/orpg/gametree/gametree.py	Thu Nov 05 12:15:19 2009 -0600
@@ -109,6 +109,7 @@
         self.id = 1
         self.dragging = False
         self.last_save_dir = dir_struct["user"]
+        self.tree_map = []
 
         #Create tree from default if it does not exist
         validate.config_file("tree.xml","default_tree.xml")
@@ -120,19 +121,16 @@
         self.rename_flag = 0
         self.image_cache = {}
         logger.debug("Exit game_tree")
-
     
     def add_nodehandler(self, nodehandler, nodeclass):
         if not self.nodehandlers.has_key(nodehandler): self.nodehandlers[nodehandler] = nodeclass
         else: logger.debug("Nodehandler for " + nodehandler + " already exists!")
-
     
     def remove_nodehandler(self, nodehandler):
         if self.nodehandlers.has_key(nodehandler):
             del self.nodehandlers[nodehandler]
         else: logger.debug("No nodehandler for " + nodehandler + " exists!")
 
-    
     def init_nodehandlers(self):
         self.add_nodehandler('group_handler', containers.group_handler)
         self.add_nodehandler('tabber_handler', containers.tabber_handler)
@@ -173,7 +171,6 @@
                 obj.on_drop(evt)
                 self.drag_obj = None
         evt.Skip()
-
     
     def on_char(self, evt):
         key_code = evt.GetKeyCode()
@@ -200,7 +197,6 @@
             self.EditLabel(curSelection)
         evt.Skip()
    
-    
     def locate_valid_tree(self, error, msg): ## --Snowdog 3/05
         """prompts the user to locate a new tree file or create a new one"""
         response = wx.MessageDialog(self, msg, error, wx.YES|wx.NO|wx.ICON_ERROR)
@@ -381,13 +377,11 @@
         end = string.rfind(data,"</tree>")
         data = data[6:end]
         self.insert_xml(data)
-
     
     def on_send_to_chat(self, evt):
         item = self.GetSelection()
         obj = self.GetPyData(item)
         obj.on_send_to_chat(evt)
-
     
     def on_whisper_to(self, evt):
         players = self.session.get_players()
@@ -487,7 +481,6 @@
     
     def on_wizard(self, evt):
         item = self.GetSelection()
-        debug((item))
         obj = self.GetPyData(item)
         name = "New " + obj.xml_root.get("name")
         icon = obj.xml_root.get("icon")
@@ -657,9 +650,7 @@
             wx.MessageBox("Import Failed: Invalid or missing node data")
             logger.general("Import Failed: Invalid or missing node data")
             return
-
-        try:
-            new_xml = XML(txt)
+        try: new_xml = XML(txt)
         except ExpatError:
             wx.MessageBox("Error Importing Node or Tree")
             logger.general("Error Importing Node or Tree")
@@ -671,7 +662,7 @@
             return
 
         self.xml_root.append(new_xml)
-        self.load_xml(new_xml,self.root,self.root)
+        self.load_xml(new_xml, self.root, self.root)
 
     
     def build_img_list(self):
@@ -687,8 +678,27 @@
             self.icons[key] = self._imageList.Add(img)
         self.SetImageList(self._imageList)
 
+    def get_tree_map(self, parent):
+        ## Could be a little cleaner ##
+        family_tree = []
+        test = parent
+        while test != self.root:
+            parent = self.GetItemText(test)
+            test = self.GetItemParent(test)
+            family_tree.append(parent)
+        return family_tree
     
     def load_xml(self, xml_element, parent_node, prev_node=None):
+        if parent_node != self.root:
+            ## Loading XML seems to lag on Grids ##
+            family_tree = self.get_tree_map(parent_node)
+            family_tree.reverse()
+            map_str = '' #'!@'
+            for member in family_tree:
+                map_str += member +'::'
+            map_str = map_str[:len(map_str)-2] #+'@!'
+            xml_element.set('map', map_str)
+
         #add the first tree node
         i = 0
         name = xml_element.get("name")
@@ -697,7 +707,7 @@
 
         if prev_node:
             if prev_node == parent_node: new_tree_node = self.PrependItem(parent_node, name, i, i)
-            else: new_tree_node = self.InsertItem(parent_node,prev_node, name, i, i)
+            else: new_tree_node = self.InsertItem(parent_node, prev_node, name, i, i)
         else: new_tree_node = self.AppendItem(parent_node, name, i, i)
 
         logger.debug("Node Added to tree")
@@ -724,7 +734,6 @@
                 #parent.removeChild(xml_dom)
 
         return new_tree_node
-
     
     def cached_load_of_image(self, bmp_in, new_tree_node):
         image_list = self.GetImageList()
@@ -735,7 +744,6 @@
             if self.image_cache[key] == str(img_data):
                 image_index = key
                 break
-
         if image_index is None:
             image_index = image_list.Add(bmp_in)
             self.image_cache[image_index] = img_data
@@ -743,7 +751,6 @@
         self.SetItemImage(new_tree_node,image_index, wx.TreeItemIcon_Selected)
         return image_index
 
-    
     def on_rclick(self, evt):
         pt = evt.GetPosition()
         (item, flag) = self.HitTest(pt)
--- a/orpg/gametree/nodehandlers/core.py	Tue Nov 03 21:30:36 2009 -0600
+++ b/orpg/gametree/nodehandlers/core.py	Thu Nov 05 12:15:19 2009 -0600
@@ -41,7 +41,8 @@
 except:
     import wx
 
-from xml.etree.ElementTree import ElementTree, Element, tostring, XML
+from xml.etree.ElementTree import ElementTree, Element, tostring, XML
+from orpg.tools.orpg_log import debug
 
 #html defaults
 TH_BG = "#E9E9E9"
@@ -106,11 +107,9 @@
             if self.create_designframe():
                 self.myeditor.Show()
                 self.myeditor.Raise()
-            else:
-                return
+            else: return
         wx.CallAfter(self.myeditor.Layout)
 
-
     def create_designframe(self):
         title = self.xml.get('name') + " Editor"
         self.myeditor = wx.Frame(None, -1, title)
@@ -131,15 +130,12 @@
         self.myeditor.SetAutoLayout(True)
 
         (x, y) = self.myeditor.GetSize()
-        if x < 400:
-            x = 400
-        if y < 400:
-            y = 400
+        if x < 400: x = 400
+        if y < 400: y = 400
 
         self.myeditor.SetSize((x, y))
         self.myeditor.Layout()
         self.myeditor.Thaw()
-
         return True
 
     def on_use(self,evt):
@@ -158,7 +154,6 @@
                 return
         wx.CallAfter(self.mywindow.Layout)
 
-
     def create_useframe(self):
         caption = self.xml.get('name', '')
         self.mywindow = wx.Frame(None, -1, caption)
@@ -180,16 +175,12 @@
 
         if self.frame_size is None:
             self.frame_size = self.mywindow.GetSize()
-            if self.frame_size.x < 400:
-                self.frame_size.x = 400
-            if self.frame_size.y < 400:
-                self.frame_size.y = 400
+            if self.frame_size.x < 400: self.frame_size.x = 400
+            if self.frame_size.y < 400: self.frame_size.y = 400
 
         self.mywindow.Layout()
         self.mywindow.Thaw()
-
         self.mywindow.Bind(wx.EVT_CLOSE, self.close_useframe)
-
         return True
 
     def close_useframe(self, evt):
@@ -201,8 +192,7 @@
 
 
     def on_html_view(self,evt):
-        try:
-            self.myviewer.Raise()
+        try: self.myviewer.Raise()
         except:
             caption = self.xml.get('name')
             self.myviewer = wx.Frame(None, -1, caption)
@@ -234,26 +224,31 @@
     def on_send_to_chat(self,evt):
         self.chat.ParsePost(self.tohtml(),True,True)
 
-    def on_drop(self,evt):
-        drag_obj = self.tree.drag_obj
-        if drag_obj == self or self.tree.is_parent_node(self.mytree_node,drag_obj.mytree_node):
+    def on_drop(self, evt):
+        drag_obj = self.tree.drag_obj
+        if drag_obj == self or self.tree.is_parent_node(self.mytree_node, drag_obj.mytree_node):
             return
-        #if self.is_my_child(self.mytree_node,drag_obj.mytree_node):
-        #    return
         drop_xml = self.tree.drag_obj.delete()
         parent_node = self.tree.GetItemParent(self.mytree_node)
         prev_sib = self.tree.GetPrevSibling(self.mytree_node)
-        if parent_node == self.tree.root:
-            parent_xml = self.tree.GetPyData(parent_node)
-        else:
-            parent_xml = self.tree.GetPyData(parent_node).xml
+        if parent_node == self.tree.root: parent_xml = self.tree.GetPyData(parent_node)
+        else: parent_xml = self.tree.GetPyData(parent_node).xml
         for i in range(len(parent_xml)):
             if parent_xml[i] is self.xml:
                 parent_xml.insert(i, drop_xml)
                 break
         if not prev_sib.IsOk():
             prev_sib = parent_node
-        self.tree.load_xml(drop_xml, parent_node, prev_sib)
+        self.tree.load_xml(drop_xml, parent_node, prev_sib)
+
+    def get_tree(self):
+        family = []
+        test = treenode
+        while test != self.tree.root:
+            test = self.tree.GetItemParent(test)
+            parent = self.tree.GetItemText(test)
+            family.append(parent)
+        return family
 
     def toxml(self,pretty=0):
         return tostring(self.xml) #toxml(self.master_dom,pretty)
@@ -308,33 +303,10 @@
     def about(self):
         html_str = "<b>"+ self.xml.get('class')
         html_str += " Applet</b><br />by Chris Davis<br />chris@rpgarchive.com"
-        return html_str
-
-    def set_referenceable(self, value):
-        if value:
-            self.xml.set('referenceable', '1')
-        else:
-            self.xml.set('referenceable', '0')
-
-    def get_referenceable(self):
-        if 'referenceable' in self.xml.attrib and self.xml.get('referenceable')=="0":
-            return False
-        return True
-
-    def set_namespace(self, value):
-        if value:
-            self.xml.set('namespace', '1')
-        else:
-            self.xml.set('namespace', '0')
-
-    def get_namespace(self):
-        if 'namespace' in self.xml.attrib and self.xml.get('namespace')=="1":
-            return True
-        return False
-
-    def get_value(self):
+        return html_str
+
+    def get_value(self):
         return None
-        
 
 
 P_TITLE = 10
@@ -347,8 +319,6 @@
         self.text = {   P_TITLE : wx.TextCtrl(self, P_TITLE, handler.xml.get('name')),
                         P_BODY : html_text_edit(self,P_BODY,handler.text,self.on_text)
                       }
-        #P_BODY : wx.TextCtrl(self, P_BODY,handler.text, style=wx.TE_MULTILINE)
-
         sizer.Add(wx.StaticText(self, -1, "Title:"), 0, wx.EXPAND)
         sizer.Add(self.text[P_TITLE], 0, wx.EXPAND)
         sizer.Add(wx.StaticText(self, -1, "Text Body:"), 0, wx.EXPAND)
--- a/orpg/gametree/nodehandlers/forms.py	Tue Nov 03 21:30:36 2009 -0600
+++ b/orpg/gametree/nodehandlers/forms.py	Thu Nov 05 12:15:19 2009 -0600
@@ -183,12 +183,9 @@
     def __init__(self,xml,tree_node):
         node_handler.__init__(self,xml,tree_node)
         self.text_elem = self.xml.find('text')
-        if self.text_elem.get("send_button") == "":
-            self.text_elem.set("send_button","0")
-        if self.text_elem.get("raw_mode") == "":
-            self.text_elem.set("raw_mode","0")
-        if self.text_elem.get("hide_title") == "":
-            self.text_elem.set("hide_title","0")
+        if self.text_elem.get("send_button") == "": self.text_elem.set("send_button","0")
+        if self.text_elem.get("raw_mode") == "": self.text_elem.set("raw_mode","0")
+        if self.text_elem.get("hide_title") == "": self.text_elem.set("hide_title","0")
 
     def get_design_panel(self,parent):
         return textctrl_edit_panel(parent,self)
@@ -257,24 +254,25 @@
 
         parent.SetSize(self.GetBestSize())
         self.Bind(wx.EVT_TEXT, self.on_text, id=FORM_TEXT_CTRL)
-        self.Bind(wx.EVT_BUTTON, self.on_send, id=FORM_SEND_BUTTON)
-
-    def on_text(self,evt):
+        self.Bind(wx.EVT_BUTTON, self.on_send, id=FORM_SEND_BUTTON)
+
+    def on_text(self, evt):
+        debug()
         txt = self.text.GetValue()
         #txt = strip_text(txt) ##Does not seem to exist.
         self.handler.text_elem.text = txt
 
-    def on_send(self,evt):
-        txt = self.text.GetValue()
+    def on_send(self, evt):
+        txt = self.text.GetValue()
+        txt = self.chat.ParseMap(txt, self.handler.xml)
         if not self.handler.is_raw_send():
-            #self.chat.ParsePost(self.tohtml(),True,True)
-            self.chat.ParsePost(self.handler.tohtml(),True,True)
+            self.chat.ParsePost(self.handler.tohtml(), True, True)
             return 1
         actionlist = txt.split("\n")
         for line in actionlist:
             if(line != ""):
                 if line[0] != "/": ## it's not a slash command
-                    self.chat.ParsePost(line,True,True)
+                    self.chat.ParsePost(line, True, True)
                 else:
                     action = line
                     self.chat.chat_cmds.docmd(action)
@@ -426,7 +424,6 @@
 
 
     # mult selection methods
-
     def get_selections(self):
         opts = []
         for opt in self.options:
@@ -451,7 +448,6 @@
         return opts
 
     # setting selection method
-
     def set_selected_node(self,index,selected=1):
         if self.get_type() != L_CHECK:
             self.clear_selections()
@@ -462,11 +458,9 @@
             opt.set("selected","0")
 
     # misc methods
-
     def get_options(self):
         opts = []
-        for opt in self.options:
-            opts.append(opt.text)
+        for opt in self.options: opts.append(opt.text)
         return opts
 
     def get_option(self,index):
@@ -488,22 +482,17 @@
         self.options[index].text = value
 
     def has_send_button(self):
-        if self.list.get("send_button") == '0':
-            return False
-        else:
-            return True
+        if self.list.get("send_button") == '0': return False
+        else: return True
 
     def get_size_constraint(self):
-        if self.get_type() == L_DROP:
-            return 0
-        else:
-            return 1
+        if self.get_type() == L_DROP: return 0
+        else: return 1
 
     def tohtml(self):
         opts = self.get_selections_text()
         text = ""
-        if not self.is_hide_title():
-            text = "<b>"+self.xml.get("name")+":</b> "
+        if not self.is_hide_title(): text = "<b>"+self.xml.get("name")+":</b> "
         comma = ", "
         text += comma.join(opts)
         return text
--- a/orpg/orpg_version.py	Tue Nov 03 21:30:36 2009 -0600
+++ b/orpg/orpg_version.py	Thu Nov 05 12:15:19 2009 -0600
@@ -4,7 +4,7 @@
 #BUILD NUMBER FORMAT: "YYMMDD-##" where ## is the incremental daily build index (if needed)
 DISTRO = "Traipse Alpha"
 DIS_VER = "Ornery Orc"
-BUILD = "091003-03"
+BUILD = "091005-00"
 
 # This version is for network capability.
 PROTOCOL_VERSION = "1.2"