Mercurial > traipse_dev
comparison orpg/gametree/gametree.py @ 133:37d26a98883f alpha
Traipse Alpha 'OpenRPG' {091010-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 | Tue, 10 Nov 2009 12:11:13 -0600 |
parents | fe4dc5817d5e |
children | b4e02e8cd314 |
comparison
equal
deleted
inserted
replaced
132:fe4dc5817d5e | 133:37d26a98883f |
---|---|
368 else: ret_string = ret_string + player[0][x] | 368 else: ret_string = ret_string + player[0][x] |
369 logger.debug(ret_string) | 369 logger.debug(ret_string) |
370 return ret_string | 370 return ret_string |
371 | 371 |
372 | 372 |
373 def on_receive_data(self, data, player): | 373 def on_receive_data(self, data): |
374 if iselement(data): | |
375 tostring(data) | |
376 beg = string.find(data,"<tree>") | |
377 end = string.rfind(data,"</tree>") | |
378 data = data[6:end] | |
379 self.insert_xml(data) | 374 self.insert_xml(data) |
380 | 375 |
381 def on_send_to_chat(self, evt): | 376 def on_send_to_chat(self, evt): |
382 item = self.GetSelection() | 377 item = self.GetSelection() |
383 obj = self.GetPyData(item) | 378 obj = self.GetPyData(item) |
529 filename = self.settings.get_setting("gametree") | 524 filename = self.settings.get_setting("gametree") |
530 self.save_tree(filename) | 525 self.save_tree(filename) |
531 | 526 |
532 | 527 |
533 def save_tree(self, filename=dir_struct["user"]+'tree.xml'): | 528 def save_tree(self, filename=dir_struct["user"]+'tree.xml'): |
534 self.xml_root.set("version",GAMETREE_VERSION) | 529 self.xml_root.set("version", GAMETREE_VERSION) |
535 settings.change("gametree",filename) | 530 settings.change("gametree", filename) |
536 ElementTree(self.xml_root).write(filename) | 531 ElementTree(self.xml_root).write(filename) |
537 | 532 |
538 | 533 |
539 def on_load_new_tree(self, evt): | 534 def on_load_new_tree(self, evt): |
540 f = wx.FileDialog(self,"Select a file", self.last_save_dir,"","*.xml",wx.OPEN) | 535 f = wx.FileDialog(self,"Select a file", self.last_save_dir,"","*.xml",wx.OPEN) |
632 item = self.GetSelection() | 627 item = self.GetSelection() |
633 obj = self.GetPyData(item) | 628 obj = self.GetPyData(item) |
634 about = MyAboutBox(self,obj.about()) | 629 about = MyAboutBox(self,obj.about()) |
635 about.ShowModal() | 630 about.ShowModal() |
636 about.Destroy() | 631 about.Destroy() |
637 | |
638 | 632 |
639 def on_send_to_map(self, evt): | 633 def on_send_to_map(self, evt): |
640 item = self.GetSelection() | 634 item = self.GetSelection() |
641 obj = self.GetPyData(item) | 635 obj = self.GetPyData(item) |
642 if hasattr(obj,"on_send_to_map"): obj.on_send_to_map(evt) | 636 if hasattr(obj,"on_send_to_map"): obj.on_send_to_map(evt) |
643 | |
644 | 637 |
645 def insert_xml(self, txt): | 638 def insert_xml(self, txt): |
646 #Updated to allow safe merging of gametree files | 639 #Updated to allow safe merging of gametree files |
647 #without leaving an unusable and undeletable node. | 640 #without leaving an unusable and undeletable node. |
648 # -- Snowdog 8/03 | 641 # -- Snowdog 8/03 |
659 if new_xml.tag == "gametree": | 652 if new_xml.tag == "gametree": |
660 for xml_child in new_xml: | 653 for xml_child in new_xml: |
661 self.load_xml(xml_child, self.root) | 654 self.load_xml(xml_child, self.root) |
662 return | 655 return |
663 | 656 |
657 if new_xml.tag == "tree": | |
658 self.xml_root.append(new_xml.find('nodehandler')) | |
659 for xml_child in new_xml: | |
660 self.load_xml(xml_child, self.root) | |
661 return | |
662 | |
664 self.xml_root.append(new_xml) | 663 self.xml_root.append(new_xml) |
665 self.load_xml(new_xml, self.root, self.root) | 664 self.load_xml(new_xml, self.root, self.root) |
666 | |
667 | 665 |
668 def build_img_list(self): | 666 def build_img_list(self): |
669 """make image list""" | 667 """make image list""" |
670 helper = img_helper() | 668 helper = img_helper() |
671 self.icons = { } | 669 self.icons = { } |
688 family_tree.append(parent) | 686 family_tree.append(parent) |
689 return family_tree | 687 return family_tree |
690 | 688 |
691 def load_xml(self, xml_element, parent_node, prev_node=None): | 689 def load_xml(self, xml_element, parent_node, prev_node=None): |
692 if parent_node != self.root: | 690 if parent_node != self.root: |
693 ## Loading XML seems to lag on Grids ## | 691 ## Loading XML seems to lag on Grids and Images need a cache for load speed ## |
694 family_tree = self.get_tree_map(parent_node) | 692 family_tree = self.get_tree_map(parent_node) |
695 family_tree.reverse() | 693 family_tree.reverse() |
696 map_str = '' #'!@' | 694 map_str = '' #'!@' |
697 for member in family_tree: | 695 for member in family_tree: |
698 map_str += member +'::' | 696 map_str += member +'::' |
725 if bmp: self.cached_load_of_image(bmp,new_tree_node,) | 723 if bmp: self.cached_load_of_image(bmp,new_tree_node,) |
726 logger.debug("Node Icon loaded") | 724 logger.debug("Node Icon loaded") |
727 self.id = self.id + 1 | 725 self.id = self.id + 1 |
728 except Exception, er: | 726 except Exception, er: |
729 logger.exception(traceback.format_exc()) | 727 logger.exception(traceback.format_exc()) |
730 | |
731 # was deleted -- should we delete non-nodehandler nodes then? | 728 # was deleted -- should we delete non-nodehandler nodes then? |
732 #self.Delete(new_tree_node) | 729 #self.Delete(new_tree_node) |
733 #parent = xml_dom._get_parentNode() | 730 #parent = xml_dom._get_parentNode() |
734 #parent.removeChild(xml_dom) | 731 #parent.removeChild(xml_dom) |
735 | |
736 return new_tree_node | 732 return new_tree_node |
737 | 733 |
738 def cached_load_of_image(self, bmp_in, new_tree_node): | 734 def cached_load_of_image(self, bmp_in, new_tree_node): |
739 image_list = self.GetImageList() | 735 image_list = self.GetImageList() |
740 img = wx.ImageFromBitmap(bmp_in) | 736 img = wx.ImageFromBitmap(bmp_in) |
758 obj = self.GetPyData(item) | 754 obj = self.GetPyData(item) |
759 self.SelectItem(item) | 755 self.SelectItem(item) |
760 if(isinstance(obj,core.node_handler)): obj.on_rclick(evt) | 756 if(isinstance(obj,core.node_handler)): obj.on_rclick(evt) |
761 else: self.PopupMenu(self.top_menu) | 757 else: self.PopupMenu(self.top_menu) |
762 else: self.PopupMenu(self.top_menu,pt) | 758 else: self.PopupMenu(self.top_menu,pt) |
763 | |
764 | 759 |
765 def on_ldclick(self, evt): | 760 def on_ldclick(self, evt): |
766 self.rename_flag = 0 | 761 self.rename_flag = 0 |
767 pt = evt.GetPosition() | 762 pt = evt.GetPosition() |
768 (item, flag) = self.HitTest(pt) | 763 (item, flag) = self.HitTest(pt) |
774 action = self.settings.get_setting("treedclick") | 769 action = self.settings.get_setting("treedclick") |
775 if action == "use": obj.on_use(evt) | 770 if action == "use": obj.on_use(evt) |
776 elif action == "design": obj.on_design(evt) | 771 elif action == "design": obj.on_design(evt) |
777 elif action == "print": obj.on_html_view(evt) | 772 elif action == "print": obj.on_html_view(evt) |
778 elif action == "chat": self.on_send_to_chat(evt) | 773 elif action == "chat": self.on_send_to_chat(evt) |
779 | |
780 | 774 |
781 def on_left_down(self, evt): | 775 def on_left_down(self, evt): |
782 pt = evt.GetPosition() | 776 pt = evt.GetPosition() |
783 (item, flag) = self.HitTest(pt) | 777 (item, flag) = self.HitTest(pt) |
784 if item.IsOk() and self.was_labeling: | 778 if item.IsOk() and self.was_labeling: |
788 elif (flag & wx.TREE_HITTEST_ONITEMLABEL) == wx.TREE_HITTEST_ONITEMLABEL and self.IsSelected(item): | 782 elif (flag & wx.TREE_HITTEST_ONITEMLABEL) == wx.TREE_HITTEST_ONITEMLABEL and self.IsSelected(item): |
789 # this next if tests to ensure that the mouse up occurred over a label, and not the icon | 783 # this next if tests to ensure that the mouse up occurred over a label, and not the icon |
790 self.rename_flag = 1 | 784 self.rename_flag = 1 |
791 else: self.SelectItem(item) | 785 else: self.SelectItem(item) |
792 evt.Skip() | 786 evt.Skip() |
793 | |
794 | 787 |
795 def on_left_up(self, evt): | 788 def on_left_up(self, evt): |
796 if self.dragging: | 789 if self.dragging: |
797 cur = wx.StockCursor(wx.CURSOR_ARROW) | 790 cur = wx.StockCursor(wx.CURSOR_ARROW) |
798 self.SetCursor(cur) | 791 self.SetCursor(cur) |
811 while child.IsOk(): | 804 while child.IsOk(): |
812 function(child, data) | 805 function(child, data) |
813 if recurse: | 806 if recurse: |
814 self.traverse(child, function, data) | 807 self.traverse(child, function, data) |
815 child, cookie = self.GetNextChild(root, cookie) | 808 child, cookie = self.GetNextChild(root, cookie) |
816 | |
817 | 809 |
818 def on_label_change(self, evt): | 810 def on_label_change(self, evt): |
819 item = evt.GetItem() | 811 item = evt.GetItem() |
820 txt = evt.GetLabel() | 812 txt = evt.GetLabel() |
821 self.was_labeling = 0 | 813 self.was_labeling = 0 |
822 self.rename_flag = 0 | 814 self.rename_flag = 0 |
823 if txt != "": | 815 if txt != "": |
824 obj = self.GetPyData(item) | 816 obj = self.GetPyData(item) |
825 obj.xml_root.setAttribute('name',txt) | 817 obj.xml_root.setAttribute('name',txt) |
826 else: evt.Veto() | 818 else: evt.Veto() |
827 | |
828 | 819 |
829 def on_label_begin(self, evt): | 820 def on_label_begin(self, evt): |
830 if not self.rename_flag: evt.Veto() | 821 if not self.rename_flag: evt.Veto() |
831 else: | 822 else: |
832 self.was_labeling = 1 | 823 self.was_labeling = 1 |
833 item = evt.GetItem() | 824 item = evt.GetItem() |
834 if item == self.GetRootItem(): | 825 if item == self.GetRootItem(): |
835 evt.Veto() | 826 evt.Veto() |
836 | |
837 | 827 |
838 def on_drag(self, evt): | 828 def on_drag(self, evt): |
839 self.rename_flag = 0 | 829 self.rename_flag = 0 |
840 item = self.GetSelection() | 830 item = self.GetSelection() |
841 obj = self.GetPyData(item) | 831 obj = self.GetPyData(item) |
843 if(isinstance(obj,core.node_handler) and obj.drag): | 833 if(isinstance(obj,core.node_handler) and obj.drag): |
844 self.dragging = True | 834 self.dragging = True |
845 cur = wx.StockCursor(wx.CURSOR_HAND) | 835 cur = wx.StockCursor(wx.CURSOR_HAND) |
846 self.SetCursor(cur) | 836 self.SetCursor(cur) |
847 self.drag_obj = obj | 837 self.drag_obj = obj |
848 | |
849 | 838 |
850 def is_parent_node(self, node, compare_node): | 839 def is_parent_node(self, node, compare_node): |
851 parent_node = self.GetItemParent(node) | 840 parent_node = self.GetItemParent(node) |
852 if compare_node == parent_node: | 841 if compare_node == parent_node: |
853 logger.debug("parent node") | 842 logger.debug("parent node") |