comparison orpg/mapper/map.py @ 137:54446a995007 alpha

Traipse Alpha 'OpenRPG' {091018-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 Recusion method, mapping, and context sensitivity. !!Alpha - Watch out for infinite loops!!
author sirebral
date Wed, 18 Nov 2009 19:57:52 -0600
parents 217fb049bd00
children 1ed2feab0db9
comparison
equal deleted inserted replaced
136:b4e02e8cd314 137:54446a995007
33 from map_prop_dialog import * 33 from map_prop_dialog import *
34 34
35 import random 35 import random
36 import os 36 import os
37 import thread 37 import thread
38 #import gc #Garbage Collecter Needed?
39 import traceback 38 import traceback
40 39
41 from miniatures_handler import * 40 from miniatures_handler import *
42 from whiteboard_handler import * 41 from whiteboard_handler import *
43 from background_handler import * 42 from background_handler import *
47 46
48 from orpg.dirpath import dir_struct 47 from orpg.dirpath import dir_struct
49 from images import ImageHandler 48 from images import ImageHandler
50 from orpg.orpgCore import component 49 from orpg.orpgCore import component
51 from orpg.tools.orpg_settings import settings 50 from orpg.tools.orpg_settings import settings
51 from xml.etree.ElementTree import ElementTree, Element, tostring, parse
52 52
53 # Various marker modes for player tools on the map 53 # Various marker modes for player tools on the map
54 MARKER_MODE_NONE = 0 54 MARKER_MODE_NONE = 0
55 MARKER_MODE_MEASURE = 1 55 MARKER_MODE_MEASURE = 1
56 MARKER_MODE_TARGET = 2 56 MARKER_MODE_TARGET = 2
111 111
112 #self.Bind(wx.EVT_MOUSEWHEEL, self.MouseWheel) 112 #self.Bind(wx.EVT_MOUSEWHEEL, self.MouseWheel)
113 113
114 def MouseWheel(self, evt): 114 def MouseWheel(self, evt):
115 if evt.CmdDown(): 115 if evt.CmdDown():
116 print evt.GetWheelRotation()
117 if evt.GetWheelRotation() > 0: self.on_zoom_in(None) 116 if evt.GetWheelRotation() > 0: self.on_zoom_in(None)
118 elif evt.GetWheelRotation() < 0: self.on_zoom_out(None) 117 elif evt.GetWheelRotation() < 0: self.on_zoom_out(None)
119 else: pass 118 else: pass
120 119
121 def better_refresh(self, event=None): 120 def better_refresh(self, event=None):
604 else: 603 else:
605 if changed: return xml_str + " action='" + action + "'/>" 604 if changed: return xml_str + " action='" + action + "'/>"
606 else: return "" 605 else: return ""
607 606
608 def takexml(self, xml): 607 def takexml(self, xml):
609 """
610 Added Process Dialog to display during long map parsings
611 as well as a try block with an exception traceback to try
612 and isolate some of the map related problems users have been
613 experiencing --Snowdog 5/15/03
614
615 Apparently Process Dialog causes problems with linux.. commenting it out. sheez.
616 --Snowdog 5/27/03
617 """
618 try: 608 try:
619 #parse the map DOM 609 xml_dom = fromstring(xml)
620 xml_dom = parseXml(xml)
621 if xml_dom == None: return 610 if xml_dom == None: return
622 node_list = xml_dom.getElementsByTagName("map") 611 if xml_dom.tag != 'map': node_list = xml_dom.find("map")
623 if len(node_list) < 1: pass 612 else: node_list = xml_dom
624 else: 613 # set map version to incoming data so layers can convert
625 # set map version to incoming data so layers can convert 614 self.map_version = node_list.get("version")
626 self.map_version = node_list[0].getAttribute("version") 615 action = node_list.get("action")
627 action = node_list[0].getAttribute("action") 616 if action == "new":
628 if action == "new": 617 self.layers = {}
629 self.layers = {} 618 try: self.layers['bg'] = layer_back_ground(self)
630 try: self.layers['bg'] = layer_back_ground(self) 619 except: pass
631 except: pass 620 try: self.layers['grid'] = grid_layer(self)
632 try: self.layers['grid'] = grid_layer(self) 621 except: pass
633 except: pass 622 try: self.layers['miniatures'] = miniature_layer(self)
634 try: self.layers['miniatures'] = miniature_layer(self) 623 except: pass
635 except: pass 624 try: self.layers['whiteboard'] = whiteboard_layer(self)
636 try: self.layers['whiteboard'] = whiteboard_layer(self) 625 except: pass
637 except: pass 626 try: self.layers['fog'] = fog_layer(self)
638 try: self.layers['fog'] = fog_layer(self) 627 except: pass
639 except: pass 628 sizex = node_list.get("sizex") if node_list.get("sizex") != None else ''
640 sizex = node_list[0].getAttribute("sizex") 629 if sizex != "":
641 if sizex != "": 630 sizex = int(float(sizex))
642 sizex = int(float(sizex)) 631 sizey = self.size[1]
643 sizey = self.size[1] 632 self.set_size((sizex,sizey))
644 self.set_size((sizex,sizey)) 633 self.size_changed = 0
645 self.size_changed = 0 634 sizey = node_list.get("sizey") if node_list.get('sizey') != None else ''
646 sizey = node_list[0].getAttribute("sizey") 635 if sizey != "":
647 if sizey != "": 636 sizey = int(float(sizey))
648 sizey = int(float(sizey)) 637 sizex = self.size[0]
649 sizex = self.size[0] 638 self.set_size((sizex,sizey))
650 self.set_size((sizex,sizey)) 639 self.size_changed = 0
651 self.size_changed = 0 640 children = node_list.getchildren()
652 children = node_list[0]._get_childNodes() 641 #fog layer must be computed first, so that no data is inadvertently revealed
653 #fog layer must be computed first, so that no data is inadvertently revealed 642 for c in children:
654 for c in children: 643 if c.tag == "fog": self.layers[c.tag].layerTakeDOM(c)
655 name = c._get_nodeName() 644 for c in children:
656 if name == "fog": self.layers[name].layerTakeDOM(c) 645 if c.tag != "fog": self.layers[c.tag].layerTakeDOM(c)
657 for c in children: 646 # all map data should be converted, set map version to current version
658 name = c._get_nodeName() 647 self.map_version = MAP_VERSION
659 if name != "fog": self.layers[name].layerTakeDOM(c) 648 self.Refresh(False)
660 # all map data should be converted, set map version to current version 649 except Exception, e: print 'failed', e; pass
661 self.map_version = MAP_VERSION
662 self.Refresh(False)
663 xml_dom.unlink() # eliminate circular refs
664 except: pass
665 650
666 def re_ids_in_xml(self, xml): 651 def re_ids_in_xml(self, xml):
667 new_xml = "" 652 new_xml = ""
668 tmp_map = map_msg() 653 tmp_map = map_msg()
669 xml_dom = parseXml(str(xml)) 654 xml_dom = fromstring(str(xml))
670 node_list = xml_dom.getElementsByTagName("map") 655 node_list = xml_dom.findall("map")
671 if len(node_list) < 1: pass 656 if len(node_list) < 1: pass
672 else: 657 else:
673 tmp_map.init_from_dom(node_list[0]) 658 tmp_map.init_from_dom(node_list[0])
674 if tmp_map.children.has_key("miniatures"): 659 if tmp_map.children.has_key("miniatures"):
675 miniatures_layer = tmp_map.children["miniatures"] 660 miniatures_layer = tmp_map.children["miniatures"]
688 if whiteboard_layer: 673 if whiteboard_layer:
689 lines = whiteboard_layer.get_children().keys() 674 lines = whiteboard_layer.get_children().keys()
690 if lines: 675 if lines:
691 for line in lines: 676 for line in lines:
692 l = whiteboard_layer.children[line] 677 l = whiteboard_layer.children[line]
693 if l.tagname == 'line': id = 'line-' + self.frame.session.get_next_id() 678 if l.tag == 'line': id = 'line-' + self.frame.session.get_next_id()
694 elif l.tagname == 'text': id = 'text-' + self.frame.session.get_next_id() 679 elif l.tag == 'text': id = 'text-' + self.frame.session.get_next_id()
695 elif l.tagname == 'circle': id = 'circle-' + self.frame.session.get_next_id() 680 elif l.tag == 'circle': id = 'circle-' + self.frame.session.get_next_id()
696 l.init_prop("id", id) 681 l.init_prop("id", id)
697 new_xml = tmp_map.get_all_xml() 682 new_xml = tmp_map.get_all_xml()
698 if xml_dom: xml_dom.unlink() 683 if xml_dom: xml_dom.unlink()
699 return str(new_xml) 684 return str(new_xml)
700 685