comparison orpg/mapper/min_dialogs.py @ 19:78407d627cba traipse_dev

Beginning of Code Clean-up. Some code untested, may break!
author sirebral
date Sat, 25 Jul 2009 17:24:40 -0500
parents 4385a7d0efd1
children 072ffc1d466f
comparison
equal deleted inserted replaced
18:67b900deb35c 19:78407d627cba
149 break 149 break
150 min_list.append(self.min[item]) 150 min_list.append(self.min[item])
151 min_index.append(item-loop_count+1) 151 min_index.append(item-loop_count+1)
152 if len(min_list) > 0: 152 if len(min_list) > 0:
153 for sel_rmin in min_list: 153 for sel_rmin in min_list:
154 ############# 154 #############
155 min_xml = sel_rmin.toxml(action="new") 155 min_xml = sel_rmin.toxml(action="new")
156 node_begin = "<nodehandler module='map_miniature_nodehandler' class='map_miniature_handler' name='" 156 node_begin = "<nodehandler module='map_miniature_nodehandler' class='map_miniature_handler' name='"
157 157
158 if sel_rmin.label: 158 if sel_rmin.label:
159 node_begin += sel_rmin.label + "'" 159 node_begin += sel_rmin.label + "'"
163 node_begin += ">" 163 node_begin += ">"
164 gametree = open_rpg.get_component('tree') 164 gametree = open_rpg.get_component('tree')
165 node_xml = node_begin + min_xml + '</nodehandler>' 165 node_xml = node_begin + min_xml + '</nodehandler>'
166 print "Sending this XML to insert_xml:" + node_xml 166 print "Sending this XML to insert_xml:" + node_xml
167 gametree.insert_xml(node_xml) 167 gametree.insert_xml(node_xml)
168 ########## 168 #############
169 self.listctrl.DeleteAllItems() 169 self.listctrl.DeleteAllItems()
170 self.refresh() 170 self.refresh()
171 event.Skip() 171 event.Skip()
172 172
173 def OnRightDown(self,event): 173 def OnRightDown(self,event):
242 self.pathcombo.Append(min_list[min_list.index(m)].path) 242 self.pathcombo.Append(min_list[min_list.index(m)].path)
243 self.positioncombo.Append(`min_list[min_list.index(m)].pos`) 243 self.positioncombo.Append(`min_list[min_list.index(m)].pos`)
244 listsizer.Add(wx.StaticText(self, -1, "Path:"), 0, wx.EXPAND) 244 listsizer.Add(wx.StaticText(self, -1, "Path:"), 0, wx.EXPAND)
245 listsizer.Add(self.pathcombo, 0, wx.EXPAND) 245 listsizer.Add(self.pathcombo, 0, wx.EXPAND)
246 listsizer.Add(wx.Size(10,10)) 246 listsizer.Add(wx.Size(10,10))
247 self.heading = wx.RadioBox(self, MIN_HEADING, "Heading", choices=["None","N","NE","E","SE","S","SW","W","NW","no change"], majorDimension=5, style=wx.RA_SPECIFY_COLS) 247 self.heading = wx.RadioBox(self, MIN_HEADING, "Heading",
248 choices=["None","N","NE","E","SE","S","SW","W","NW","no change"], majorDimension=5, style=wx.RA_SPECIFY_COLS)
248 self.heading.SetSelection( 9 ) 249 self.heading.SetSelection( 9 )
249 listsizer.Add( self.heading, 0, wx.EXPAND ) 250 listsizer.Add( self.heading, 0, wx.EXPAND )
250 listsizer.Add(wx.Size(10,10)) 251 listsizer.Add(wx.Size(10,10))
251 self.face = wx.RadioBox(self, MIN_FACE, "Facing", choices=["None","N","NE","E","SE","S","SW","W","NW","no change"], majorDimension=5, style=wx.RA_SPECIFY_COLS) 252 self.face = wx.RadioBox(self, MIN_FACE, "Facing",
253 choices=["None","N","NE","E","SE","S","SW","W","NW","no change"], majorDimension=5, style=wx.RA_SPECIFY_COLS)
252 self.face.SetSelection(9) 254 self.face.SetSelection(9)
253 listsizer.Add(self.face, 0, wx.EXPAND) 255 listsizer.Add(self.face, 0, wx.EXPAND)
254 ### 256 ###
255 ### Group together locked, Hide, and snap radioboxes in group2 box 257 ###Group together locked, Hide, and snap radioboxes in group2 box
256 ### 258 ###
257 group2 = wx.BoxSizer(wx.HORIZONTAL) 259 group2 = wx.BoxSizer(wx.HORIZONTAL)
258 self.locked = wx.RadioBox(self, MIN_LOCK, "Lock", choices=["Don't lock","Lock","no change"],majorDimension=1,style=wx.RA_SPECIFY_COLS) 260 self.locked = wx.RadioBox(self, MIN_LOCK, "Lock",
261 choices=["Don't lock","Lock","no change"],majorDimension=1,style=wx.RA_SPECIFY_COLS)
259 self.locked.SetSelection(2) 262 self.locked.SetSelection(2)
260 self.hide = wx.RadioBox(self, MIN_HIDE, "Hide", choices=["Don't hide", "Hide", "no change"],majorDimension=1,style=wx.RA_SPECIFY_COLS) 263 self.hide = wx.RadioBox(self, MIN_HIDE, "Hide",
264 choices=["Don't hide", "Hide", "no change"],majorDimension=1,style=wx.RA_SPECIFY_COLS)
261 self.hide.SetSelection(2) 265 self.hide.SetSelection(2)
262 self.snap = wx.RadioBox(self,MIN_ALIGN,"Snap",choices=["Center","Top left","no change"],majorDimension=1,style=wx.RA_SPECIFY_COLS) 266 self.snap = wx.RadioBox(self,MIN_ALIGN,"Snap",
267 choices=["Center","Top left","no change"],majorDimension=1,style=wx.RA_SPECIFY_COLS)
263 self.snap.SetSelection(2) 268 self.snap.SetSelection(2)
264 group2.Add(self.locked, 0, wx.EXPAND) 269 group2.Add(self.locked, 0, wx.EXPAND)
265 group2.Add(wx.Size(10,0)) 270 group2.Add(wx.Size(10,0))
266 group2.Add(self.hide, 0, wx.EXPAND) 271 group2.Add(self.hide, 0, wx.EXPAND)
267 group2.Add(wx.Size(10,0)) 272 group2.Add(wx.Size(10,0))
268 group2.Add(self.snap, 0, wx.EXPAND) 273 group2.Add(self.snap, 0, wx.EXPAND)
269 group2.Add(wx.Size(10,0)) 274 group2.Add(wx.Size(10,0))
270 listsizer.Add(group2,0,0) 275 listsizer.Add(group2,0,0)
271 ### 276 ###
272 ### group together the postion radiobox and the and its selection elements 277 ###Group together the postion radiobox and the and its selection elements
273 ### 278 ###
274 xpos = int(min_list[0].pos[0]) 279 xpos = int(min_list[0].pos[0])
275 #xpos = int(`min_list[0].pos`[1:`min_list[0].pos`.index(',')]) 280 #xpos = int(`min_list[0].pos`[1:`min_list[0].pos`.index(',')])
276 ypos = int(min_list[0].pos[1]) 281 ypos = int(min_list[0].pos[1])
277 #ypos = int(`min_list[0].pos`[`min_list[0].pos`.rfind(',')+1:len(`min_list[0].pos`)-1]) 282 #ypos = int(`min_list[0].pos`[`min_list[0].pos`.rfind(',')+1:len(`min_list[0].pos`)-1])
278 self.scx = wx.SpinCtrl(self, POS_SPIN, "", (-1,-1), wx.Size(75,25)) 283 self.scx = wx.SpinCtrl(self, POS_SPIN, "", (-1,-1), wx.Size(75,25))
281 self.scy = wx.SpinCtrl(self, POS_SPIN, "", (-1,-1), wx.Size(75,25)) 286 self.scy = wx.SpinCtrl(self, POS_SPIN, "", (-1,-1), wx.Size(75,25))
282 self.scy.SetRange(0,self.grid.return_grid()[1]) 287 self.scy.SetRange(0,self.grid.return_grid()[1])
283 self.scy.SetValue(1) 288 self.scy.SetValue(1)
284 self.scy.SetValue(ypos) 289 self.scy.SetValue(ypos)
285 positionbox = wx.BoxSizer(wx.HORIZONTAL) 290 positionbox = wx.BoxSizer(wx.HORIZONTAL)
286 self.poschoice = wx.RadioBox(self,MIN_POS,"Position",choices=["Manual", "Existing", "no change"],majorDimension=1,style=wx.RA_SPECIFY_COLS) 291 self.poschoice = wx.RadioBox(self,MIN_POS,"Position",
292 choices=["Manual", "Existing", "no change"],majorDimension=1,style=wx.RA_SPECIFY_COLS)
287 self.poschoice.SetSelection(2) 293 self.poschoice.SetSelection(2)
288 positionbox.Add(self.poschoice,0,0) 294 positionbox.Add(self.poschoice,0,0)
289 ### 295 ###
290 ### group together choices under position choice boxsizer 296 ### group together choices under position choice boxsizer
291 ### 297 ###
301 ypos = wx.StaticText(self, -1,"YPOS: ") 307 ypos = wx.StaticText(self, -1,"YPOS: ")
302 spinbox.Add(ypos,0, 0) 308 spinbox.Add(ypos,0, 0)
303 spinbox.Add(self.scy, 0, 0) 309 spinbox.Add(self.scy, 0, 0)
304 poschoicebox.Add(wx.Size(0,15)) 310 poschoicebox.Add(wx.Size(0,15))
305 poschoicebox.Add(spinbox,0,0) 311 poschoicebox.Add(spinbox,0,0)
306 ### 312 ###
307 ### kludge is just a way to horizontaly position text. .Add doesn't seem to work. 313 ### kludge is just a way to horizontaly position text. .Add doesn't seem to work.
308 ### 314 ###
309 kluge = wx.BoxSizer(wx.HORIZONTAL) 315 kluge = wx.BoxSizer(wx.HORIZONTAL)
310 klugetext = wx.StaticText(self, -1, " ") 316 klugetext = wx.StaticText(self, -1, " ")
311 kluge.Add(klugetext,0,0) 317 kluge.Add(klugetext,0,0)
312 kluge.Add(self.positioncombo,0,0) 318 kluge.Add(self.positioncombo,0,0)
313 poschoicebox.Add(wx.Size(0,1)) 319 poschoicebox.Add(wx.Size(0,1))
354 m.bmp = image[1] 360 m.bmp = image[1]
355 else: 361 else:
356 image[-1] = -1 362 image[-1] = -1
357 while image[1] == -1: 363 while image[1] == -1:
358 image = 0 364 image = 0
359 self.dlg = wx.TextEntryDialog(self, 'You entered an invalid URL for the image path. Please Enter a valid URL or cancel to leave the old url unchanged') 365 self.dlg = wx.TextEntryDialog(self,
366 'You entered an invalid URL for the image path. Please Enter a valid URL or cancel to leave the old url unchanged')
360 if self.dlg.ShowModal() == wx.ID_OK: 367 if self.dlg.ShowModal() == wx.ID_OK:
361 path = self.dlg.GetValue() 368 path = self.dlg.GetValue()
362 image = self.evaluate(path) 369 image = self.evaluate(path)
363 if image[1] != -1: 370 if image[1] != -1:
364 m.path = image[0] 371 m.path = image[0]
430 hSizer = wx.BoxSizer(wx.HORIZONTAL) 437 hSizer = wx.BoxSizer(wx.HORIZONTAL)
431 self.label = wx.TextCtrl(self, MIN_LABEL, min.label) 438 self.label = wx.TextCtrl(self, MIN_LABEL, min.label)
432 sizer.Add(wx.StaticText(self, -1, "Label:"), 0, wx.EXPAND) 439 sizer.Add(wx.StaticText(self, -1, "Label:"), 0, wx.EXPAND)
433 sizer.Add(self.label, 0, wx.EXPAND) 440 sizer.Add(self.label, 0, wx.EXPAND)
434 sizer.Add(wx.Size(10,10)) 441 sizer.Add(wx.Size(10,10))
435 self.heading = wx.RadioBox(self, MIN_HEADING, "Heading", choices=["None","N","NE","E","SE","S","SW","W","NW"],majorDimension=5,style=wx.RA_SPECIFY_COLS) 442 self.heading = wx.RadioBox(self, MIN_HEADING, "Heading",
443 choices=["None","N","NE","E","SE","S","SW","W","NW"],majorDimension=5,style=wx.RA_SPECIFY_COLS)
436 self.heading.SetSelection(min.heading) 444 self.heading.SetSelection(min.heading)
437 self.face = wx.RadioBox(self, MIN_FACE, "Facing", choices=["None","N","NE","E","SE","S","SW","W","NW"],majorDimension=5,style=wx.RA_SPECIFY_COLS) 445 self.face = wx.RadioBox(self, MIN_FACE, "Facing",
446 choices=["None","N","NE","E","SE","S","SW","W","NW"],majorDimension=5,style=wx.RA_SPECIFY_COLS)
438 self.face.SetSelection(min.face) 447 self.face.SetSelection(min.face)
439 self.locked = wx.CheckBox(self, MIN_LOCK, " Lock") 448 self.locked = wx.CheckBox(self, MIN_LOCK, " Lock")
440 self.locked.SetValue(min.locked) 449 self.locked.SetValue(min.locked)
441 self.hide = wx.CheckBox(self, MIN_HIDE, " Hide") 450 self.hide = wx.CheckBox(self, MIN_HIDE, " Hide")
442 self.hide.SetValue(min.hide) 451 self.hide.SetValue(min.hide)
485 494
486 def on_scaling(self, evt): 495 def on_scaling(self, evt):
487 if self.min_scaling.GetValue() == False: 496 if self.min_scaling.GetValue() == False:
488 return 497 return
489 elif self.min_width.GetValue() and wxID_MIN_WIDTH == evt.GetId() and self.min_width.GetInsertionPoint(): 498 elif self.min_width.GetValue() and wxID_MIN_WIDTH == evt.GetId() and self.min_width.GetInsertionPoint():
490 self.min_height.SetValue ( str(int((float(self.min_width.GetValue()) / float(self.min_width_old_value)) * float(self.min_height_old_value))) ) 499 self.min_height.SetValue(str(int((float(self.min_width.GetValue()) / float(self.min_width_old_value)) * float(self.min_height_old_value))) )
491 elif self.min_height.GetValue() and wxID_MIN_HEIGHT == evt.GetId() and self.min_height.GetInsertionPoint(): 500 elif self.min_height.GetValue() and wxID_MIN_HEIGHT == evt.GetId() and self.min_height.GetInsertionPoint():
492 self.min_width.SetValue ( str(int((float(self.min_height.GetValue()) / float(self.min_height_old_value)) * float(self.min_width_old_value))) ) 501 self.min_width.SetValue(str(int((float(self.min_height.GetValue()) / float(self.min_height_old_value)) * float(self.min_width_old_value))) )
493 502
494 def update_min(self): 503 def update_min(self):
495 self.min.set_min_props(self.heading.GetSelection(), 504 self.min.set_min_props(self.heading.GetSelection(),
496 self.face.GetSelection(), 505 self.face.GetSelection(),
497 self.label.GetValue(), 506 self.label.GetValue(),
512 self.sizer.SetDimension(20,20,s[0]-40,s[1]-40) 521 self.sizer.SetDimension(20,20,s[0]-40,s[1]-40)
513 self.outline.SetDimensions(5,5,s[0]-10,s[1]-10) 522 self.outline.SetDimensions(5,5,s[0]-10,s[1]-10)
514 523
515 class min_edit_dialog(wx.Dialog): 524 class min_edit_dialog(wx.Dialog):
516 def __init__(self,parent,min): 525 def __init__(self,parent,min):
517 #520,265 526 #520,265
518 wx.Dialog.__init__(self,parent,-1,"Miniature",wx.DefaultPosition,wx.Size(520,350)) 527 wx.Dialog.__init__(self,parent,-1,"Miniature",wx.DefaultPosition,wx.Size(520,350))
519 (w,h) = self.GetClientSizeTuple() 528 (w,h) = self.GetClientSizeTuple()
520 mastersizer = wx.BoxSizer(wx.VERTICAL) 529 mastersizer = wx.BoxSizer(wx.VERTICAL)
521 editor = min_edit_panel(self,min) 530 editor = min_edit_panel(self,min)
522 #editor.SetDimensions(0,0,w,h-25) 531 #editor.SetDimensions(0,0,w,h-25)