comparison orpg/gametree/nodehandlers/map_miniature_nodehandler.py @ 118:217fb049bd00 alpha

Traipse Alpha 'OpenRPG' {091028-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: Adds Bookmarks (Alpha) with cool Smiley Star and Plus Symbol images! Changes made to the map for increased portability. SnowDog has changes planned in Core, though. Added an initial push to the BCG. Not much to see, just shows off how it is re-writing Main code. Fix to remote admin commands Minor fix to texted based server, works in /System/ folder Some Core changes to gametree to correctly disply Pretty Print, thanks David! Fix to Splitter Nodes not being created. Added images to Plugin Control panel for Autostart feature Fix to massive amounts of images loading; from Core fix to gsclient so with_statement imports Added 'boot' command to remote admin Prep work in Pass tool for remote admin rankings and different passwords, ei, Server, Admin, Moderator, etc. Remote Admin Commands more organized, more prep work. Added Confirmation window for sent nodes. Minor changes to allow for portability to an OpenSUSE linux OS (hopefully without breaking) {091028} 00: Made changes to gametree to start working with Element Tree, mostly from Core Minor changes to Map to start working with Element Tree, from Core Preliminary changes to map efficiency, from FlexiRPG Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG Changes to main.py to start working with Element Tree
author sirebral
date Wed, 28 Oct 2009 14:24:54 -0500
parents 449a8900f9ac
children 06f10429eedc
comparison
equal deleted inserted replaced
117:0f18d16f3fe7 118:217fb049bd00
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