diff orpg/mapper/fog.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 f38df4bf9715
children 54446a995007 e842a5f1b775
line wrap: on
line diff
--- a/orpg/mapper/fog.py	Mon Oct 12 23:24:10 2009 -0500
+++ b/orpg/mapper/fog.py	Wed Oct 28 14:24:54 2009 -0500
@@ -82,8 +82,8 @@
         self.canvas = canvas
         self.log = component.get('log')
         layer_base.__init__(self)
-        self.color = wx.Color(128,128,128)
-        if "__WXGTK__" not in wx.PlatformInfo: self.color = wx.Color(128,128,128, 128)
+        self.color = wx.Color(128, 128, 128)
+        #if "__WXGTK__" not in wx.PlatformInfo: self.color = wx.Color(128,128,128, 128)
         self.fogregion = wx.Region()
         self.fogregion.Clear()
         self.fog_bmp = None
@@ -116,71 +116,40 @@
         if not self.use_fog:
             return
         size = self.canvas.size
-        self.width = size[0]/COURSE+1
-        self.height = size[1]/COURSE+1
-        self.fog_bmp = wx.EmptyBitmap(self.width+2,self.height+2)
+        self.width = size[0]
+        self.height = size[1]
+        self.fog_bmp = wx.EmptyBitmap(self.width,self.height)
         self.fill_fog()
 
     def fill_fog(self):
         if not self.use_fog:
             return
-        if "__WXGTK__" in wx.PlatformInfo:
-            mdc = wx.MemoryDC()
-            mdc.SelectObject(self.fog_bmp)
-            mdc.SetPen(wx.TRANSPARENT_PEN)
-            if (self.canvas.frame.session.role == "GM"): color = self.color
-            else: color = wx.BLACK
-            self.last_role = self.canvas.frame.session.role
-            mdc.SetBrush(wx.Brush(color,wx.SOLID))
-            mdc.DestroyClippingRegion()
+        mdc = wx.MemoryDC()
+        mdc.SelectObject(self.fog_bmp)
+        mdc.SetPen(wx.TRANSPARENT_PEN)
+        if (self.canvas.frame.session.role == "GM"): color = self.color
+        else: color = wx.BLACK
+        self.last_role = self.canvas.frame.session.role
+        mdc.SetBrush(wx.Brush(color,wx.SOLID))
+        mdc.DestroyClippingRegion()
+        mdc.DrawRectangle(0, 0, self.width+2, self.height+2)
+        mdc.SetBrush(wx.Brush(wx.WHITE, wx.SOLID))
+        if self.fogregion.GetBox().GetWidth()>0:
+            mdc.SetClippingRegionAsRegion(self.fogregion)
             mdc.DrawRectangle(0, 0, self.width+2, self.height+2)
-            mdc.SetBrush(wx.Brush(wx.WHITE, wx.SOLID))
-            if self.fogregion.GetBox().GetWidth()>0:
-                mdc.SetClippingRegionAsRegion(self.fogregion)
-                mdc.DrawRectangle(0, 0, self.width+2, self.height+2)
-            mdc.SelectObject(wx.NullBitmap)
-            del mdc
+        mdc.SelectObject(wx.NullBitmap)
+        del mdc
 
     def layerDraw(self, dc, topleft, size):
         if self.fog_bmp == None or not self.fog_bmp.Ok() or not self.use_fog:
             return
         if self.last_role != self.canvas.frame.session.role: self.fill_fog()
-        if "__WXGTK__" not in wx.PlatformInfo:
-            gc = wx.GraphicsContext.Create(dc)
-            gc.SetBrush(wx.Brush(wx.BLACK))
-            if (self.canvas.frame.session.role == "GM"):
-                gc.SetBrush(wx.Brush(self.color))
-            rgn = wx.Region(0, 0, self.canvas.size[0]+2, self.canvas.size[1]+2)
-            if not self.fogregion.IsEmpty(): rgn.SubtractRegion(self.fogregion)
-            gc.ClipRegion(rgn)
-            gc.DrawRectangle(0, 0, self.canvas.size[0]+2, self.canvas.size[1]+2)
-        else:
-            sc = dc.GetUserScale()
-            bmp = wx.EmptyBitmap(size[0],size[1])
-            mdc = wx.MemoryDC()
-            mdc.BeginDrawing()
-            mdc.SelectObject(bmp)
-            mdc.SetPen(wx.TRANSPARENT_PEN)
-            mdc.SetBrush(wx.Brush(wx.WHITE, wx.SOLID))
-            mdc.DrawRectangle(0,0,size[0],size[1])
-            srct = [int(topleft[0]/(sc[0]*COURSE)), int(topleft[1]/(sc[1]*COURSE))]
-            srcsz = [int((int(size[0]/COURSE+1)*COURSE)/(sc[0]*COURSE))+2, 
-                int((int(size[1]/COURSE+1)*COURSE)/(sc[1]*COURSE))+2]
-            if (srct[0]+srcsz[0] > self.width): srcsz[0] = self.width-srct[0]
-            if (srct[1]+srcsz[1] > self.height): srcsz[1] = self.height-srct[1]
-            img = wx.ImageFromBitmap(self.fog_bmp).GetSubImage(wx.Rect(srct[0], srct[1], srcsz[0], srcsz[1]))
-            img.Rescale(srcsz[0]*COURSE*sc[0], srcsz[1]*COURSE*sc[1])
-            fog = wx.BitmapFromImage(img)
-            mdc.SetDeviceOrigin(-topleft[0], -topleft[1])
-            mdc.DrawBitmap(fog, srct[0]*COURSE*sc[0], srct[1]*COURSE*sc[1])
-            mdc.SetDeviceOrigin(0,0)
-            mdc.SetUserScale(1,1)
-            mdc.EndDrawing()
-            dc.SetUserScale(1,1)
-            dc.Blit(topleft[0], topleft[1], size[0], size[1], mdc,0,0,wx.AND)
-            dc.SetUserScale(sc[0],sc[1])
-            mdc.SelectObject(wx.NullBitmap)
-            del mdc
+        
+        mdc = wx.MemoryDC()
+        mdc.SelectObject(self.fog_bmp)
+        dc.Blit(0, 0, self.canvas.size[0], self.canvas.size[1], mdc, 0, 0, wx.AND)
+        mdc.SelectObject(wx.NullBitmap)
+        del mdc
 
     def createregn2(self, polyline, mode, show):
         regn = self.scanConvert(polyline)
@@ -198,7 +167,7 @@
             if not self.fogregion.IsEmpty():
                 self.fogregion.SubtractRegion(regn)
             else:
-                self.fogregion = wx.Region(0, 0, self.canvas.size[0]+2, self.canvas.size[1]+2)
+                self.fogregion = wx.Region(0, 0, self.canvas.size[0], self.canvas.size[1])
                 self.fogregion.SubtractRegion(regn)
             self.del_area(area, show)
 
@@ -216,13 +185,13 @@
         list = IRegion().scan_Convert(polypt)
         for i in list:
             if regn.IsEmpty():
-                if "__WXGTK__" not in wx.PlatformInfo: regn = wx.Region(i.left*COURSE, i.y*COURSE, 
-                                                                        i.right*COURSE+1-i.left*COURSE, 1*COURSE)
-                else: regn = wx.Region(i.left, i.y, i.right+1-i.left, 1)
+                #if "__WXGTK__" not in wx.PlatformInfo: 
+                regn = wx.Region(i.left*COURSE, i.y*COURSE, i.right*COURSE+1-i.left*COURSE, 1*COURSE)
+                #else: regn = wx.Region(i.left, i.y, i.right+1-i.left, 1)
             else:
-                if "__WXGTK__" not in wx.PlatformInfo: regn.Union(i.left*COURSE, i.y*COURSE, 
-                                                                i.right*COURSE+1-i.left*COURSE, 1*COURSE)
-                else: regn.Union(i.left, i.y, i.right+1-i.left, 1)
+                #if "__WXGTK__" not in wx.PlatformInfo: 
+                regn.Union(i.left*COURSE, i.y*COURSE, i.right*COURSE+1-i.left*COURSE, 1*COURSE)
+                #else: regn.Union(i.left, i.y, i.right+1-i.left, 1)
         return regn
 
     def add_area(self, area="", show="Yes"):
@@ -246,16 +215,16 @@
         ri = wx.RegionIterator(self.fogregion)
         if not (ri.HaveRects()): fog_string = FogArea("all", self.log).toxml("del")
         while ri.HaveRects():
-            if "__WXGTK__" not in wx.PlatformInfo:
-                x1 = ri.GetX()/COURSE
-                x2 = x1+(ri.GetW()/COURSE)-1
-                y1 = ri.GetY()/COURSE
-                y2 = y1+(ri.GetH()/COURSE)-1
-            else:
-                x1 = ri.GetX()
-                x2 = x1+ri.GetW()-1
-                y1 = ri.GetY()
-                y2 = y1+ri.GetH()-1
+            #if "__WXGTK__" not in wx.PlatformInfo:
+            x1 = ri.GetX()/COURSE
+            x2 = x1+(ri.GetW()/COURSE)-1
+            y1 = ri.GetY()/COURSE
+            y2 = y1+(ri.GetH()/COURSE)-1
+            #else:
+            #    x1 = ri.GetX()
+            #    x2 = x1+ri.GetW()-1
+            #    y1 = ri.GetY()
+            #    y2 = y1+ri.GetH()-1
             poly = FogArea(str(x1) + "," + str(y1) + ";" +
                           str(x2) + "," + str(y1) + ";" +
                           str(x2) + "," + str(y2) + ";" +