Mercurial > traipse_dev
comparison orpg/mapper/min_dialogs.py @ 20:072ffc1d466f traipse_dev
2nd attempt. Still untested.
author | sirebral |
---|---|
date | Sat, 25 Jul 2009 19:23:25 -0500 |
parents | 78407d627cba |
children | c54768cffbd4 |
comparison
equal
deleted
inserted
replaced
19:78407d627cba | 20:072ffc1d466f |
---|---|
95 self.listctrl.SetStringItem(self.min.index(m),3,`self.min[self.min.index(m)].face`) | 95 self.listctrl.SetStringItem(self.min.index(m),3,`self.min[self.min.index(m)].face`) |
96 self.listctrl.SetStringItem(self.min.index(m),4,`self.min[self.min.index(m)].locked`) | 96 self.listctrl.SetStringItem(self.min.index(m),4,`self.min[self.min.index(m)].locked`) |
97 self.listctrl.SetStringItem(self.min.index(m),5,`self.min[self.min.index(m)].pos`) | 97 self.listctrl.SetStringItem(self.min.index(m),5,`self.min[self.min.index(m)].pos`) |
98 oldcolumnwidth = self.listctrl.GetColumnWidth(0) | 98 oldcolumnwidth = self.listctrl.GetColumnWidth(0) |
99 self.listctrl.SetColumnWidth(0, wx.LIST_AUTOSIZE) | 99 self.listctrl.SetColumnWidth(0, wx.LIST_AUTOSIZE) |
100 if oldcolumnwidth < self.listctrl.GetColumnWidth(0): | 100 if oldcolumnwidth < self.listctrl.GetColumnWidth(0): self.listctrl.SetColumnWidth(0, wx.LIST_AUTOSIZE) |
101 self.listctrl.SetColumnWidth(0, wx.LIST_AUTOSIZE) | 101 else: self.listctrl.SetColumnWidth(0, oldcolumnwidth) |
102 else: | |
103 self.listctrl.SetColumnWidth(0, oldcolumnwidth) | |
104 self.list_sizer=self.list_sizer | 102 self.list_sizer=self.list_sizer |
105 | 103 |
106 def onEdit(self,event): | 104 def onEdit(self,event): |
107 min_list = [] | 105 min_list = [] |
108 min_index = [] | 106 min_index = [] |
109 loop_count = 0 | 107 loop_count = 0 |
110 item =-1 | 108 item =-1 |
111 while True: | 109 while True: |
112 loop_count += 1 | 110 loop_count += 1 |
113 item = self.listctrl.GetNextItem(item,wx.LIST_NEXT_ALL, wx.LIST_STATE_SELECTED) | 111 item = self.listctrl.GetNextItem(item,wx.LIST_NEXT_ALL, wx.LIST_STATE_SELECTED) |
114 if item == -1: | 112 if item == -1: break |
115 break | |
116 min_list.append(self.min[item]) | 113 min_list.append(self.min[item]) |
117 min_index.append(item-loop_count+1) | 114 min_index.append(item-loop_count+1) |
118 if len(min_list) > 0: | 115 if len(min_list) > 0: dlg = min_list_edit_dialog(self.parent,min_index, min_list,self.layers) |
119 dlg = min_list_edit_dialog(self.parent,min_index, min_list,self.layers) | 116 if dlg.ShowModal() == wx.ID_OK: pass |
120 if dlg.ShowModal() == wx.ID_OK: | |
121 pass | |
122 self.listctrl.DeleteAllItems() | 117 self.listctrl.DeleteAllItems() |
123 self.refresh() | 118 self.refresh() |
124 event.Skip() | 119 event.Skip() |
125 | 120 |
126 def onDelete(self,event): | 121 def onDelete(self,event): |
127 loop_count = 0 | 122 loop_count = 0 |
128 item = -1 | 123 item = -1 |
129 while True: | 124 while True: |
130 loop_count += 1 | 125 loop_count += 1 |
131 item = self.listctrl.GetNextItem(item,wx.LIST_NEXT_ALL, wx.LIST_STATE_SELECTED) | 126 item = self.listctrl.GetNextItem(item,wx.LIST_NEXT_ALL, wx.LIST_STATE_SELECTED) |
132 if item == -1: | 127 if item == -1: break |
133 break | |
134 #self.min.remove(self.min[item-loop_count+1]) | |
135 self.layers["miniatures"].del_miniature(self.min[item-loop_count+1]) | 128 self.layers["miniatures"].del_miniature(self.min[item-loop_count+1]) |
136 self.listctrl.DeleteAllItems() | 129 self.listctrl.DeleteAllItems() |
137 self.refresh() | 130 self.refresh() |
138 event.Skip() | 131 event.Skip() |
139 | 132 |
143 loop_count = 0 | 136 loop_count = 0 |
144 item =-1 | 137 item =-1 |
145 while True: | 138 while True: |
146 loop_count += 1 | 139 loop_count += 1 |
147 item = self.listctrl.GetNextItem(item,wx.LIST_NEXT_ALL, wx.LIST_STATE_SELECTED) | 140 item = self.listctrl.GetNextItem(item,wx.LIST_NEXT_ALL, wx.LIST_STATE_SELECTED) |
148 if item == -1: | 141 if item == -1: break |
149 break | |
150 min_list.append(self.min[item]) | 142 min_list.append(self.min[item]) |
151 min_index.append(item-loop_count+1) | 143 min_index.append(item-loop_count+1) |
152 if len(min_list) > 0: | 144 if len(min_list) > 0: |
153 for sel_rmin in min_list: | 145 for sel_rmin in min_list: |
154 ############# | 146 ############# |
155 min_xml = sel_rmin.toxml(action="new") | 147 min_xml = sel_rmin.toxml(action="new") |
156 node_begin = "<nodehandler module='map_miniature_nodehandler' class='map_miniature_handler' name='" | 148 node_begin = "<nodehandler module='map_miniature_nodehandler' class='map_miniature_handler' name='" |
157 | 149 |
158 if sel_rmin.label: | 150 if sel_rmin.label: node_begin += sel_rmin.label + "'" |
159 node_begin += sel_rmin.label + "'" | 151 else: node_begin += "Unnamed Miniature'" |
160 else: | |
161 node_begin += "Unnamed Miniature'" | |
162 | 152 |
163 node_begin += ">" | 153 node_begin += ">" |
164 gametree = open_rpg.get_component('tree') | 154 gametree = open_rpg.get_component('tree') |
165 node_xml = node_begin + min_xml + '</nodehandler>' | 155 node_xml = node_begin + min_xml + '</nodehandler>' |
166 print "Sending this XML to insert_xml:" + node_xml | 156 print "Sending this XML to insert_xml:" + node_xml |
334 self.Bind(wx.EVT_RADIOBOX, self.on_radio_box, id=MIN_FACE) | 324 self.Bind(wx.EVT_RADIOBOX, self.on_radio_box, id=MIN_FACE) |
335 | 325 |
336 def on_ok(self,min): | 326 def on_ok(self,min): |
337 self.min = min | 327 self.min = min |
338 for m in self.min_list: | 328 for m in self.min_list: |
339 if self.hide.GetSelection() !=2: | 329 if self.hide.GetSelection() !=2: m.hide = self.hide.GetSelection() |
340 m.hide = self.hide.GetSelection() | 330 if self.heading.GetSelection() !=9: m.heading = self.heading.GetSelection() |
341 if self.heading.GetSelection() !=9: | 331 if self.face.GetSelection() !=9: m.face = self.face.GetSelection() |
342 m.heading = self.heading.GetSelection() | 332 if self.locked.GetSelection() !=2: m.locked = self.locked.GetSelection() |
343 if self.face.GetSelection() !=9: | 333 if self.snap.GetSelection() !=2: m.snap_to_align = self.snap.GetSelection() |
344 m.face = self.face.GetSelection() | |
345 if self.locked.GetSelection() !=2: | |
346 m.locked = self.locked.GetSelection() | |
347 if self.snap.GetSelection() !=2: | |
348 m.snap_to_align = self.snap.GetSelection() | |
349 if self.labelcombo.GetValue() != "no change": | 334 if self.labelcombo.GetValue() != "no change": |
350 m.label = self.labelcombo.GetValue() | 335 m.label = self.labelcombo.GetValue() |
351 if self.labelcheck.GetValue(): | 336 if self.labelcheck.GetValue(): m.label += " " + `self.layers['miniatures'].next_serial()` |
352 m.label += " " + `self.layers['miniatures'].next_serial()` | |
353 # self.layers['miniatures'].serial_number +=1 | |
354 # m.label += " " + `self.layers['miniatures'].serial_number` | |
355 if self.pathcombo.GetValue() != "no change": | 337 if self.pathcombo.GetValue() != "no change": |
356 path = self.pathcombo.GetValue() | 338 path = self.pathcombo.GetValue() |
357 image = self.evaluate(path) | 339 image = self.evaluate(path) |
358 if str(image[1]) != '-1': | 340 if str(image[1]) != '-1': |
359 m.path = image[0] | 341 m.path = image[0] |
369 image = self.evaluate(path) | 351 image = self.evaluate(path) |
370 if image[1] != -1: | 352 if image[1] != -1: |
371 m.path = image[0] | 353 m.path = image[0] |
372 m.bmp = image[1] | 354 m.bmp = image[1] |
373 self.dlg.Destroy() | 355 self.dlg.Destroy() |
374 else: | 356 else: break |
375 break | |
376 if self.poschoice.GetSelection() !=2: | 357 if self.poschoice.GetSelection() !=2: |
377 if self.poschoice.GetSelection() == 0: | 358 if self.poschoice.GetSelection() == 0: m.pos = cmpPoint(self.scx.GetValue(),self.scy.GetValue()) |
378 m.pos = cmpPoint(self.scx.GetValue(),self.scy.GetValue()) | |
379 else: | 359 else: |
380 pos = self.positioncombo.GetValue() | 360 pos = self.positioncombo.GetValue() |
381 m.pos = cmpPoint(int(`pos`[2:`pos`.index(",")]),int(`pos`[`pos`.rfind(',')+1:len(`pos`)-2])) | 361 m.pos = cmpPoint(int(`pos`[2:`pos`.index(",")]),int(`pos`[`pos`.rfind(',')+1:len(`pos`)-2])) |
382 self.layers["miniatures"].canvas.send_map_data() | 362 self.layers["miniatures"].canvas.send_map_data() |
383 | 363 |
384 def evaluate(self, ckpath): | 364 def evaluate(self, ckpath): |
385 path = [] | 365 path = [] |
386 if ckpath[:7] != "http://": | 366 if ckpath[:7] != "http://": ckpath = "http://" + ckpath |
387 ckpath = "http://" + ckpath | |
388 path = self.check_path(ckpath) | 367 path = self.check_path(ckpath) |
389 return [ckpath, path] | 368 return [ckpath, path] |
390 | 369 |
391 def check_path(self, path): | 370 def check_path(self, path): |
392 if ImageHandler.Cache.has_key(path): | 371 if ImageHandler.Cache.has_key(path): return ImageHandler.Cache[path] |
393 return ImageHandler.Cache[path] | |
394 img = ImageHandler.directLoad(path) | 372 img = ImageHandler.directLoad(path) |
395 if img is None: | 373 if img is None: return -1 |
396 return -1 | |
397 return img | 374 return img |
398 | 375 |
399 def on_text(self,evt): | 376 def on_text(self,evt): |
400 id=evt.GetId() | 377 id=evt.GetId() |
401 | 378 |
491 self.Bind(wx.EVT_TEXT, self.on_scaling, id=wxID_MIN_HEIGHT) | 468 self.Bind(wx.EVT_TEXT, self.on_scaling, id=wxID_MIN_HEIGHT) |
492 self.Bind(wx.EVT_RADIOBOX, self.on_radio_box, id=MIN_HEADING) | 469 self.Bind(wx.EVT_RADIOBOX, self.on_radio_box, id=MIN_HEADING) |
493 self.Bind(wx.EVT_RADIOBOX, self.on_radio_box, id=MIN_FACE) | 470 self.Bind(wx.EVT_RADIOBOX, self.on_radio_box, id=MIN_FACE) |
494 | 471 |
495 def on_scaling(self, evt): | 472 def on_scaling(self, evt): |
496 if self.min_scaling.GetValue() == False: | 473 if self.min_scaling.GetValue() == False: return |
497 return | |
498 elif self.min_width.GetValue() and wxID_MIN_WIDTH == evt.GetId() and self.min_width.GetInsertionPoint(): | 474 elif self.min_width.GetValue() and wxID_MIN_WIDTH == evt.GetId() and self.min_width.GetInsertionPoint(): |
499 self.min_height.SetValue(str(int((float(self.min_width.GetValue()) / float(self.min_width_old_value)) * float(self.min_height_old_value))) ) | 475 self.min_height.SetValue(str(int((float(self.min_width.GetValue()) / float(self.min_width_old_value)) * float(self.min_height_old_value))) ) |
500 elif self.min_height.GetValue() and wxID_MIN_HEIGHT == evt.GetId() and self.min_height.GetInsertionPoint(): | 476 elif self.min_height.GetValue() and wxID_MIN_HEIGHT == evt.GetId() and self.min_height.GetInsertionPoint(): |
501 self.min_width.SetValue(str(int((float(self.min_height.GetValue()) / float(self.min_height_old_value)) * float(self.min_width_old_value))) ) | 477 self.min_width.SetValue(str(int((float(self.min_height.GetValue()) / float(self.min_height_old_value)) * float(self.min_width_old_value))) ) |
502 | 478 |