Mercurial > traipse_dev
comparison orpg/mapper/miniatures_handler.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 | 0b8b7e3ed78d |
children | 072ffc1d466f |
comparison
equal
deleted
inserted
replaced
18:67b900deb35c | 19:78407d627cba |
---|---|
166 else: | 166 else: |
167 try: | 167 try: |
168 min_url = open_rpg.get_component("cherrypy") + filename | 168 min_url = open_rpg.get_component("cherrypy") + filename |
169 except: | 169 except: |
170 return | 170 return |
171 min_url = dlg.GetDirectory().replace(orpg.dirpath.dir_struct["user"]+'webfiles' + os.sep, open_rpg.get_component("cherrypy")) + '/' + filename | 171 min_url = dlg.GetDirectory().replace(orpg.dirpath.dir_struct["user"]+'webfiles' + os.sep, |
172 open_rpg.get_component("cherrypy")) + '/' + filename | |
172 # build url | 173 # build url |
173 if min_url == "" or min_url == "http://": | 174 if min_url == "" or min_url == "http://": |
174 return | 175 return |
175 if min_url[:7] != "http://" : | 176 if min_url[:7] != "http://" : |
176 min_url = "http://" + min_url | 177 min_url = "http://" + min_url |
386 # when we lock / unlock the selected mini make sure it isn't still selected | 387 # when we lock / unlock the selected mini make sure it isn't still selected |
387 # or it might easily get moved by accident and be hard to move back | 388 # or it might easily get moved by accident and be hard to move back |
388 self.sel_min.selected = False | 389 self.sel_min.selected = False |
389 self.sel_min.isUpdated = True | 390 self.sel_min.isUpdated = True |
390 self.sel_min = None | 391 self.sel_min = None |
391 recycle_bin = {MIN_HEADING_NONE: FACE_NONE, MIN_HEADING_NORTH: FACE_NORTH, MIN_HEADING_NORTHWEST: FACE_NORTHWEST, MIN_HEADING_NORTHEAST: FACE_NORTHEAST, MIN_HEADING_EAST: FACE_EAST, MIN_HEADING_SOUTHEAST: FACE_SOUTHEAST, MIN_HEADING_SOUTHWEST: FACE_SOUTHWEST, MIN_HEADING_SOUTH: FACE_SOUTH, MIN_HEADING_WEST: FACE_WEST} | 392 recycle_bin = {MIN_HEADING_NONE: FACE_NONE, MIN_HEADING_NORTH: FACE_NORTH, |
393 MIN_HEADING_NORTHWEST: FACE_NORTHWEST, MIN_HEADING_NORTHEAST: FACE_NORTHEAST, | |
394 MIN_HEADING_EAST: FACE_EAST, MIN_HEADING_SOUTHEAST: FACE_SOUTHEAST, MIN_HEADING_SOUTHWEST: FACE_SOUTHWEST, | |
395 MIN_HEADING_SOUTH: FACE_SOUTH, MIN_HEADING_WEST: FACE_WEST} | |
392 if recycle_bin.has_key(id): | 396 if recycle_bin.has_key(id): |
393 self.sel_rmin.heading = recycle_bin[id] | 397 self.sel_rmin.heading = recycle_bin[id] |
394 recycle_bin = {} | 398 recycle_bin = {} |
395 recycle_bin = {MIN_FACING_NONE: FACE_NONE, MIN_FACING_NORTH: FACE_NORTH, MIN_FACING_NORTHWEST: FACE_NORTHWEST, MIN_FACING_NORTHEAST: FACE_NORTHEAST, MIN_FACING_EAST: FACE_EAST, MIN_FACING_SOUTHEAST: FACE_SOUTHEAST, MIN_FACING_SOUTHWEST: FACE_SOUTHWEST, MIN_FACING_SOUTH: FACE_SOUTH, MIN_FACING_WEST: FACE_WEST} | 399 recycle_bin = {MIN_FACING_NONE: FACE_NONE, MIN_FACING_NORTH: FACE_NORTH, |
400 MIN_FACING_NORTHWEST: FACE_NORTHWEST, MIN_FACING_NORTHEAST: FACE_NORTHEAST, | |
401 MIN_FACING_EAST: FACE_EAST, MIN_FACING_SOUTHEAST: FACE_SOUTHEAST, MIN_FACING_SOUTHWEST: FACE_SOUTHWEST, | |
402 MIN_FACING_SOUTH: FACE_SOUTH, MIN_FACING_WEST: FACE_WEST} | |
396 if recycle_bin.has_key(id): | 403 if recycle_bin.has_key(id): |
397 self.sel_rmin.face = recycle_bin[id] | 404 self.sel_rmin.face = recycle_bin[id] |
398 recycle_bin = {} | 405 recycle_bin = {} |
399 elif id == MIN_ALIGN_GRID_CENTER: | 406 elif id == MIN_ALIGN_GRID_CENTER: |
400 self.sel_rmin.snap_to_align = SNAPTO_ALIGN_CENTER | 407 self.sel_rmin.snap_to_align = SNAPTO_ALIGN_CENTER |
587 self.drag_mini = mini | 594 self.drag_mini = mini |
588 if deselecting_selected_mini: | 595 if deselecting_selected_mini: |
589 return | 596 return |
590 self.sel_min = mini | 597 self.sel_min = mini |
591 self.sel_min.selected = True | 598 self.sel_min.selected = True |
592 """ | |
593 dc = wx.ClientDC(self.canvas) | |
594 self.canvas.PrepareDC(dc) | |
595 dc.SetUserScale(self.canvas.layers['grid'].mapscale,self.canvas.layers['grid'].mapscale) | |
596 self.sel_min.draw(dc, self.canvas.layers['miniatures']) | |
597 """ | |
598 self.canvas.Refresh() | 599 self.canvas.Refresh() |
599 else: | 600 else: |
600 self.drag_mini = None | 601 self.drag_mini = None |
601 pos = self.getLogicalPosition(evt) | 602 pos = self.getLogicalPosition(evt) |
602 self.moveSelectedMini(pos) | 603 self.moveSelectedMini(pos) |
634 if start1 < start2: | 635 if start1 < start2: |
635 start1 = start2 | 636 start1 = start2 |
636 filename = filepath[start1:] | 637 filename = filepath[start1:] |
637 pos = filename.rfind('.') | 638 pos = filename.rfind('.') |
638 ext = filename[pos:].lower() | 639 ext = filename[pos:].lower() |
639 # ext = filename[-4:].lower() | 640 #ext = filename[-4:].lower() |
640 if(ext != ".bmp" and ext != ".gif" and ext != ".jpg" and ext != ".jpeg" and ext != ".png"): | 641 if(ext != ".bmp" and ext != ".gif" and ext != ".jpg" and ext != ".jpeg" and ext != ".png"): |
641 self.infoPost("Supported file extensions are: *.bmp, *.gif, *.jpg, *.jpeg, *.png") | 642 self.infoPost("Supported file extensions are: *.bmp, *.gif, *.jpg, *.jpeg, *.png") |
642 return | 643 return |
643 file = open(filepath, "rb") | 644 file = open(filepath, "rb") |
644 imgdata = file.read() | 645 imgdata = file.read() |
669 if evt.Dragging() and evt.LeftIsDown(): | 670 if evt.Dragging() and evt.LeftIsDown(): |
670 if self.canvas.drag is None and self.drag_mini is not None: | 671 if self.canvas.drag is None and self.drag_mini is not None: |
671 drag_bmp = self.drag_mini.bmp | 672 drag_bmp = self.drag_mini.bmp |
672 if self.drag_mini.width and self.drag_mini.height: | 673 if self.drag_mini.width and self.drag_mini.height: |
673 tmp_image = drag_bmp.ConvertToImage() | 674 tmp_image = drag_bmp.ConvertToImage() |
674 tmp_image.Rescale(int(self.drag_mini.width * self.canvas.layers['grid'].mapscale), int(self.drag_mini.height * self.canvas.layers['grid'].mapscale)) | 675 tmp_image.Rescale(int(self.drag_mini.width * self.canvas.layers['grid'].mapscale), |
676 int(self.drag_mini.height * self.canvas.layers['grid'].mapscale)) | |
675 tmp_image.ConvertAlphaToMask() | 677 tmp_image.ConvertAlphaToMask() |
676 drag_bmp = tmp_image.ConvertToBitmap() | 678 drag_bmp = tmp_image.ConvertToBitmap() |
677 mask = wx.Mask(drag_bmp, wx.Colour(tmp_image.GetMaskRed(), tmp_image.GetMaskGreen(), tmp_image.GetMaskBlue())) | 679 mask = wx.Mask(drag_bmp, wx.Colour(tmp_image.GetMaskRed(), |
680 tmp_image.GetMaskGreen(), tmp_image.GetMaskBlue())) | |
678 drag_bmp.SetMask(mask) | 681 drag_bmp.SetMask(mask) |
679 tmp_image = tmp_image.ConvertToGreyscale() | 682 tmp_image = tmp_image.ConvertToGreyscale() |
680 self.drag_mini.gray = True | 683 self.drag_mini.gray = True |
681 self.drag_mini.isUpdated = True | 684 self.drag_mini.isUpdated = True |
682 def refresh(): | 685 def refresh(): |
683 self.canvas.drag.Hide() | 686 self.canvas.drag.Hide() |
684 self.canvas.Refresh(False) | 687 self.canvas.Refresh(False) |
685 wx.CallAfter(refresh) | 688 wx.CallAfter(refresh) |
686 self.canvas.drag = wx.DragImage(drag_bmp) | 689 self.canvas.drag = wx.DragImage(drag_bmp) |
687 self.drag_offset = self.getLogicalPosition(evt)- self.drag_mini.pos | 690 self.drag_offset = self.getLogicalPosition(evt)- self.drag_mini.pos |
688 self.canvas.drag.BeginDrag((int(self.drag_offset.x * self.canvas.layers['grid'].mapscale), int(self.drag_offset.y * self.canvas.layers['grid'].mapscale)), self.canvas, False) | 691 self.canvas.drag.BeginDrag((int(self.drag_offset.x * self.canvas.layers['grid'].mapscale), |
692 int(self.drag_offset.y * self.canvas.layers['grid'].mapscale)), self.canvas, False) | |
689 elif self.canvas.drag is not None: | 693 elif self.canvas.drag is not None: |
690 self.canvas.drag.Move(evt.GetPosition()) | 694 self.canvas.drag.Move(evt.GetPosition()) |
691 self.canvas.drag.Show() | 695 self.canvas.drag.Show() |
692 # reset tool tip timer | 696 # reset tool tip timer |
693 self.canvas.SetToolTipString("") | 697 self.canvas.SetToolTipString("") |