comparison orpg/gametree/nodehandlers/map_miniature_nodehandler.py @ 135:dcf4fbe09b70 beta

Traipse Beta '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 (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!!
author sirebral
date Tue, 10 Nov 2009 14:11:28 -0600
parents 449a8900f9ac
children 06f10429eedc
comparison
equal deleted inserted replaced
101:394ebb3b6a0f 135:dcf4fbe09b70
40 <miniature id='' label='Elf-1' posx='' posy='' path='' ... /> 40 <miniature id='' label='Elf-1' posx='' posy='' path='' ... />
41 </nodehandler > 41 </nodehandler >
42 """ 42 """
43 43
44 44
45 def __init__(self,xml_dom,tree_node): 45 def __init__(self,xml,tree_node):
46 node_handler.__init__(self,xml_dom,tree_node) 46 node_handler.__init__(self,xml,tree_node)
47 self.mapper = component.get("map") 47 self.mapper = component.get("map")
48 self.session = component.get("session") 48 self.session = component.get("session")
49 self.miniature_dom = self.master_dom.getElementsByTagName("miniature") 49 self.miniature_xml = self.xml.find("miniature")
50 if self.miniature_dom: 50
51 self.miniature_dom = self.miniature_dom[0] # convert to scalar
52
53 def get_scaled_bitmap(self,x,y): 51 def get_scaled_bitmap(self,x,y):
54 my_mini_msg = mini_msg() 52 my_mini_msg = mini_msg()
55 my_mini_msg.init_from_dom(self.miniature_dom) 53 my_mini_msg.init_from_dom(self.miniature_xml)
56 bmp = None 54 bmp = None
57 path = my_mini_msg.get_prop("path") 55 path = my_mini_msg.get_prop("path")
58 56
59 if path: 57 if path:
60 path = urllib.unquote(path) 58 path = urllib.unquote(path)
87 def map_aware(self): 85 def map_aware(self):
88 return 1 86 return 1
89 87
90 def get_miniature_XML(self): 88 def get_miniature_XML(self):
91 my_mini_msg = mini_msg() 89 my_mini_msg = mini_msg()
92 my_mini_msg.init_from_dom(self.miniature_dom) 90 my_mini_msg.init_from_dom(self.miniature_xml)
93 my_mini_msg.init_prop("id",self.session.get_next_id()) 91 my_mini_msg.init_prop("id",self.session.get_next_id())
94 label = self.master_dom.getAttribute("name") 92 label = self.xml.get("name")
95 my_mini_msg.init_prop("label",label) 93 my_mini_msg.init_prop("label",label)
96 new_xml = my_mini_msg.get_all_xml() 94 new_xml = my_mini_msg.get_all_xml()
97 return new_xml 95 return new_xml
98 96
99 def get_to_map_XML(self): 97 def get_to_map_XML(self):
107 self.mapper.canvas.PrepareDC(dc) 105 self.mapper.canvas.PrepareDC(dc)
108 grid = self.mapper.canvas.layers['grid'] 106 grid = self.mapper.canvas.layers['grid']
109 dc.SetUserScale(grid.mapscale, grid.mapscale) 107 dc.SetUserScale(grid.mapscale, grid.mapscale)
110 pos = evt.GetLogicalPosition(dc) 108 pos = evt.GetLogicalPosition(dc)
111 try: 109 try:
112 align = int(self.miniature_dom.getAttribute("align")) 110 align = int(self.xml.get("align"))
113 width = int(self.miniature_dom.getAttribute("width")) 111 width = int(self.xml.get("width"))
114 height = int(self.miniature_dom.getAttribute("height")) 112 height = int(self.xml.get("height"))
115 pos = grid.get_snapped_to_pos(pos, align, width, height) 113 pos = grid.get_snapped_to_pos(pos, align, width, height)
116 except: 114 except:
117 pass 115 pass
118 self.miniature_dom.setAttribute("posx", str(pos.x)) 116 self.miniature_xml.set("posx", str(pos.x))
119 self.miniature_dom.setAttribute("posy", str(pos.y)) 117 self.miniature_xml.set("posy", str(pos.y))
120 new_xml = self.get_to_map_XML() 118 new_xml = self.get_to_map_XML()
121 if (self.session.my_role() != self.session.ROLE_GM) and (self.session.my_role() != self.session.ROLE_PLAYER): 119 if (self.session.my_role() != self.session.ROLE_GM) and (self.session.my_role() != self.session.ROLE_PLAYER):
122 component.get("chat").InfoPost("You must be either a player or GM to use the miniature Layer") 120 component.get("chat").InfoPost("You must be either a player or GM to use the miniature Layer")
123 return 121 return
124 122
131 def about(self): 129 def about(self):
132 return "Miniature node by Andrew Bennett" 130 return "Miniature node by Andrew Bennett"
133 131
134 def tohtml(self): 132 def tohtml(self):
135 html_str = "<table><tr><td>" 133 html_str = "<table><tr><td>"
136 html_str += "<center><img src='" + self.miniature_dom.getAttribute("path") + "'>" 134 html_str += "<center><img src='" + self.xml.get("path") + "'>"
137 html_str += "</center></td></tr>\n" 135 html_str += "</center></td></tr>\n"
138 html_str += "<tr><td><center>" + self.master_dom.getAttribute("name") + "</center></td></tr></table>" 136 html_str += "<tr><td><center>" + self.xml.get("name") + "</center></td></tr></table>"
139 return html_str 137 return html_str