Mercurial > traipse_dev
comparison orpg/mapper/background.py @ 151:06f10429eedc alpha
Traipse Alpha 'OpenRPG' {091125-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 (Cleaning up for Beta)
Added Bookmarks
Fix to Remote Admin Commands
Minor fix to text based Server
Fix to Pretty Print, from Core
Fix to Splitter Nodes not being created
Fix to massive amounts of images loading, from Core
Added 'boot' command to remote admin
Added confirmation window for sent nodes
Minor changes to allow for portability to an OpenSUSE linux OS
Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG
Zoom Mouse plugin added
Images added to Plugin UI
Switching to Element Tree
Map efficiency, from FlexiRPG
Added Status Bar to Update Manager
default_manifest.xml renamed to default_upmana.xml
Cleaner clode for saved repositories
New TrueDebug Class in orpg_log (See documentation for usage)
Mercurial's hgweb folder is ported to upmana
Pretty important update that can help remove thousands of dead children from your
gametree.
Children, <forms />, <group_atts />, <horizontal />, <cols />, <rows />, <height
/>, etc... are all tags now. Check your gametree and look for dead children!!
New Gametree Recursion method, mapping, and context sensitivity. !Infinite Loops
return error instead of freezing the software!
New Syntax added for custom PC sheets
Tip of the Day added, from Core and community
Fixed Whiteboard ID to prevent random line or text deleting. Modified ID's to
prevent non updated clients from ruining the fix.
author | sirebral |
---|---|
date | Wed, 25 Nov 2009 06:15:49 -0600 |
parents | 8e07c1a2c69b |
children | b633f4c64aae 81d0bfd5e800 |
comparison
equal
deleted
inserted
replaced
149:c2caca988a11 | 151:06f10429eedc |
---|---|
27 # utilities in the orpg project. | 27 # utilities in the orpg project. |
28 # | 28 # |
29 __version__ = "$Id: background.py,v 1.29 2007/03/09 14:11:55 digitalxero Exp $" | 29 __version__ = "$Id: background.py,v 1.29 2007/03/09 14:11:55 digitalxero Exp $" |
30 | 30 |
31 from base import * | 31 from base import * |
32 import thread | 32 import thread, urllib, os.path, time, mimetypes |
33 import urllib | |
34 import os.path | |
35 import time | |
36 import mimetypes | |
37 | 33 |
38 from orpg.orpgCore import component | 34 from orpg.orpgCore import component |
39 from orpg.tools.orpg_log import logger | 35 from orpg.tools.orpg_log import logger |
40 from orpg.tools.decorators import debugging | |
41 from orpg.tools.orpg_settings import settings | 36 from orpg.tools.orpg_settings import settings |
42 | 37 |
43 ##----------------------------- | 38 ##----------------------------- |
44 ## background layer | 39 ## background layer |
45 ##----------------------------- | 40 ##----------------------------- |
57 layer_base.__init__(self) | 52 layer_base.__init__(self) |
58 self.canvas = canvas | 53 self.canvas = canvas |
59 self.r_h = RGBHex() | 54 self.r_h = RGBHex() |
60 self.clear() | 55 self.clear() |
61 | 56 |
62 | |
63 def error_loading_image(self, image): | 57 def error_loading_image(self, image): |
64 msg = "Unable to load image:" + `image` | 58 msg = "Unable to load image:" + `image` |
65 dlg = wx.MessageDialog(self.canvas,msg,'File not Found',wx.ICON_EXCLAMATION) | 59 dlg = wx.MessageDialog(self.canvas,msg,'File not Found',wx.ICON_EXCLAMATION) |
66 dlg.ShowModal() | 60 dlg.ShowModal() |
67 dlg.Destroy() | 61 dlg.Destroy() |
68 | |
69 | 62 |
70 def clear(self): | 63 def clear(self): |
71 self.type = BG_NONE | 64 self.type = BG_NONE |
72 self.bg_bmp = None | 65 self.bg_bmp = None |
73 self.bg_color = None | 66 self.bg_color = None |
75 self.local = False | 68 self.local = False |
76 self.localPath = '' | 69 self.localPath = '' |
77 self.localTime = -1 | 70 self.localTime = -1 |
78 self.isUpdated = True | 71 self.isUpdated = True |
79 | 72 |
80 | |
81 def get_type(self): | 73 def get_type(self): |
82 return self.type | 74 return self.type |
83 | |
84 | 75 |
85 def get_img_path(self): | 76 def get_img_path(self): |
86 if self.img_path: return self.img_path | 77 if self.img_path: return self.img_path |
87 else: return "" | 78 else: return "" |
88 | |
89 | 79 |
90 def get_color(self): | 80 def get_color(self): |
91 hexcolor = "#FFFFFF" | 81 hexcolor = "#FFFFFF" |
92 if self.bg_color: | 82 if self.bg_color: |
93 (red,green,blue) = self.bg_color.Get() | 83 (red,green,blue) = self.bg_color.Get() |
94 hexcolor = self.r_h.hexstring(red, green, blue) | 84 hexcolor = self.r_h.hexstring(red, green, blue) |
95 return hexcolor | 85 return hexcolor |
96 | |
97 | 86 |
98 def set_texture(self, path): | 87 def set_texture(self, path): |
99 self.isUpdated = True | 88 self.isUpdated = True |
100 self.type = BG_TEXTURE | 89 self.type = BG_TEXTURE |
101 if self.img_path != path: | 90 if self.img_path != path: |
104 if self.bg_bmp == None: | 93 if self.bg_bmp == None: |
105 logger.general("Invalid image type!") | 94 logger.general("Invalid image type!") |
106 raise Exception, "Invalid image type!" | 95 raise Exception, "Invalid image type!" |
107 except: self.error_loading_image(path) | 96 except: self.error_loading_image(path) |
108 self.img_path = path | 97 self.img_path = path |
109 | |
110 | 98 |
111 def set_image(self, path, scale): | 99 def set_image(self, path, scale): |
112 self.isUpdated = True | 100 self.isUpdated = True |
113 self.type = BG_IMAGE | 101 self.type = BG_IMAGE |
114 if self.img_path != path: | 102 if self.img_path != path: |
119 raise Exception, "Invalid image type!" | 107 raise Exception, "Invalid image type!" |
120 except: self.error_loading_image(path) | 108 except: self.error_loading_image(path) |
121 self.img_path = path | 109 self.img_path = path |
122 return (self.bg_bmp.GetWidth(),self.bg_bmp.GetHeight()) | 110 return (self.bg_bmp.GetWidth(),self.bg_bmp.GetHeight()) |
123 | 111 |
124 | |
125 def set_color(self, color): | 112 def set_color(self, color): |
126 self.isUpdated = True | 113 self.isUpdated = True |
127 self.type = BG_COLOR | 114 self.type = BG_COLOR |
128 (r,g,b) = color.Get() | 115 (r,g,b) = color.Get() |
129 self.bg_color = cmpColour(r,g,b) | 116 self.bg_color = cmpColour(r,g,b) |
130 self.canvas.SetBackgroundColour(self.bg_color) | 117 self.canvas.SetBackgroundColour(self.bg_color) |
131 | |
132 | 118 |
133 def layerDraw(self, dc, scale, topleft, size): | 119 def layerDraw(self, dc, scale, topleft, size): |
134 if self.bg_bmp == None or not self.bg_bmp.Ok() or ((self.type != BG_TEXTURE) and (self.type != BG_IMAGE)): | 120 if self.bg_bmp == None or not self.bg_bmp.Ok() or ((self.type != BG_TEXTURE) and (self.type != BG_IMAGE)): |
135 return False | 121 return False |
136 dc2 = wx.MemoryDC() | 122 dc2 = wx.MemoryDC() |
202 dc.Blit(posx, posy, newW, newH, dc2, cl, ct) | 188 dc.Blit(posx, posy, newW, newH, dc2, cl, ct) |
203 dc2.SelectObject(wx.NullBitmap) | 189 dc2.SelectObject(wx.NullBitmap) |
204 del dc2 | 190 del dc2 |
205 return True | 191 return True |
206 | 192 |
207 | |
208 def layerToXML(self, action="update"): | 193 def layerToXML(self, action="update"): |
209 xml_str = "<bg" | 194 xml_str = "<bg" |
210 if self.bg_color != None: | 195 if self.bg_color != None: |
211 (red,green,blue) = self.bg_color.Get() | 196 (red,green,blue) = self.bg_color.Get() |
212 hexcolor = self.r_h.hexstring(red, green, blue) | 197 hexcolor = self.r_h.hexstring(red, green, blue) |
221 logger.debug(xml_str) | 206 logger.debug(xml_str) |
222 if (action == "update" and self.isUpdated) or action == "new": | 207 if (action == "update" and self.isUpdated) or action == "new": |
223 self.isUpdated = False | 208 self.isUpdated = False |
224 return xml_str | 209 return xml_str |
225 else: return '' | 210 else: return '' |
226 | |
227 | 211 |
228 def layerTakeDOM(self, xml_dom): | 212 def layerTakeDOM(self, xml_dom): |
229 type = BG_COLOR | 213 type = BG_COLOR |
230 color = xml_dom.getAttribute("color") | 214 color = xml_dom.getAttribute("color") |
231 logger.debug("color=" + color) | 215 logger.debug("color=" + color) |
255 filename = os.path.split(self.localPath) | 239 filename = os.path.split(self.localPath) |
256 (imgtype,j) = mimetypes.guess_type(filename[1]) | 240 (imgtype,j) = mimetypes.guess_type(filename[1]) |
257 postdata = urllib.urlencode({'filename':filename[1], 'imgdata':imgdata, 'imgtype':imgtype}) | 241 postdata = urllib.urlencode({'filename':filename[1], 'imgdata':imgdata, 'imgtype':imgtype}) |
258 thread.start_new_thread(self.upload, (postdata, self.localPath, type)) | 242 thread.start_new_thread(self.upload, (postdata, self.localPath, type)) |
259 | 243 |
260 | |
261 def upload(self, postdata, filename, type): | 244 def upload(self, postdata, filename, type): |
262 self.lock.acquire() | 245 self.lock.acquire() |
263 if type == 'Image' or type == 'Texture': | 246 if type == 'Image' or type == 'Texture': |
264 url = component.get('settings').get_setting('ImageServerBaseURL') | 247 url = component.get('settings').get_setting('ImageServerBaseURL') |
265 file = urllib.urlopen(url, postdata) | 248 file = urllib.urlopen(url, postdata) |