annotate orpg/mapper/miniatures.py @ 220:9611ba80cf99 alpha

Traipse Alpha 'OpenRPG' {100501-01} 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 (Patch-2) Moving to Beta!! New Features: New Namespace method with two new syntaxes New Namespace Internal is context sensitive, always! New Namespace External is 'as narrow as you make it' New Namespace FutureCheck helps ensure you don't receive an incorrect node New PluginDB access for URL2Link plugin New to Forms, they now show their content in Design Mode New to Update Manager, checks Repo for updates on software start New to Mini Lin node, change title in design mode New to Game Tree, never lose a node, appends a number to the end of corrupted trees New to Server GUI, Traipse Suite's Debug Console Updates: Update to White Board layer, uses a pencil image for color button Update to Grid Layer, uses a grid image for color button Update to Chat Window, size of drop down menus Update to default lobby message Update to template Text node Update to 4e PC Sheet node Fixes: Fix to Server GUI startup errors Fix to Server GUI Rooms tab updating Fix to Chat and Settings if non existant die roller is picked Fix to Dieroller and .open() used with .vs(). Successes are correctly calculated Fix to Alias Lib's Export to Tree, Open, Save features Fix to alias node, now works properly Fix to Splitter node, minor GUI cleanup Fix to Backgrounds not loading through remote loader Fix to Node name errors Fix to rolling dice in chat Whispers Fix to Splitters Sizing issues Fix to URL2Link plugin, modified regex compilation should remove memory leak Fix to mapy.py, a roll back due to zoomed grid issues Fix to whiteboard_handler, Circles work by you clicking the center of the circle Fix to Servers parse_incoming_dom which was outdated and did not respect XML Fix to a broken link in the server welcome message Fix to InterParse and logger requiring traceback Fix to Update Manager Status Bar Fix to failed image and erroneous pop up Fix to Mini Lib node that was preventing use Fix to plugins that parce dice but did not call InterParse Fix to nodes for name changing by double click Fix to Game Tree, node ordering on drag and drop corrected Fix to Game Tree, corrupted error message was not showing Fix to Update Manager, checks for internet connection Fix to Update Manager, Auto Update corrections
author sirebral
date Sat, 01 May 2010 03:21:26 -0500
parents b633f4c64aae
children 24769389a7ba
rev   line source
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1 # Copyright (C) 2000-2001 The OpenRPG Project
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
3 # openrpg-dev@lists.sourceforge.net
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
4 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
5 # This program is free software; you can redistribute it and/or modify
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
6 # it under the terms of the GNU General Public License as published by
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
7 # the Free Software Foundation; either version 2 of the License, or
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
8 # (at your option) any later version.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
9 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
10 # This program is distributed in the hope that it will be useful,
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
13 # GNU General Public License for more details.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
14 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
15 # You should have received a copy of the GNU General Public License
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
16 # along with this program; if not, write to the Free Software
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
18 # --
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
19 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
20 # File: mapper/miniatures.py
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
21 # Author: Chris Davis
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
22 # Maintainer:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
23 # Version:
195
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents: 159
diff changeset
24 # $Id: miniatures.py,v Traipse 'Ornery-Orc' prof.ebral Exp $
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
25 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
26 # Description: This file contains some of the basic definitions for the chat
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
27 # utilities in the orpg project.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
28 #
195
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents: 159
diff changeset
29 __version__ = "$Id: miniatures.py,v Traipse 'Ornery-Orc' prof.ebral Exp $"
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
30
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
31 from base import *
151
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 139
diff changeset
32 import thread, time, urllib, os.path, mimetypes
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
33
88
763a04270cf6 Traipse Alpha 'OpenRPG' {090917-02}
sirebral
parents: 76
diff changeset
34 import xml.dom.minidom as minidom
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
35 from orpg.tools.orpg_settings import settings
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
36
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
37 from xml.etree.ElementTree import ElementTree, Element
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
38 from xml.etree.ElementTree import fromstring, tostring
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
39
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
40 MIN_STICKY_BACK = -0XFFFFFF
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
41 MIN_STICKY_FRONT = 0xFFFFFF
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
42
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
43 ##----------------------------------------
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
44 ## miniature object
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
45 ##----------------------------------------
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
46
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
47 FACE_NONE = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
48 FACE_NORTH = 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
49 FACE_NORTHEAST = 2
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
50 FACE_EAST = 3
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
51 FACE_SOUTHEAST = 4
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
52 FACE_SOUTH = 5
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
53 FACE_SOUTHWEST = 6
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
54 FACE_WEST = 7
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
55 FACE_NORTHWEST = 8
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
56 SNAPTO_ALIGN_CENTER = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
57 SNAPTO_ALIGN_TL = 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
58
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
59 def cmp_zorder(first,second):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
60 f = first.zorder
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
61 s = second.zorder
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
62 if f == None: f = 0
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
63 if s == None: s = 0
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
64 if f == s: value = 0
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
65 elif f < s: value = -1
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
66 else: value = 1
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
67 return value
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
68
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
69 class BmpMiniature:
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
70 def __init__(self, id, path, bmp, pos=cmpPoint(0,0),
71
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 21
diff changeset
71 heading=FACE_NONE, face=FACE_NONE, label="",
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 21
diff changeset
72 locked=False, hide=False, snap_to_align=SNAPTO_ALIGN_CENTER,
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
73 zorder=0, width=0, height=0, log=None, local=False, localPath='', localTime=-1, func='none'):
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
74 self.heading = heading
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
75 self.face = face
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
76 self.label = label
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
77 self.path = path
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
78 self.pos = pos
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
79 self.selected = False
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
80 self.locked = locked
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
81 self.snap_to_align = snap_to_align
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
82 self.hide = hide
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
83 self.id = id
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
84 self.zorder = zorder
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
85 self.left = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
86 self.local = local
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
87 self.localPath = localPath
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
88 self.localTime = localTime
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
89 if not width: self.width = 0
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
90 else: self.width = width
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
91 if not height: self.height = 0
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
92 else: self.height = height
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
93 self.right = bmp.GetWidth()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
94 self.top = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
95 self.bottom = bmp.GetHeight()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
96 self.isUpdated = False
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
97 self.gray = False
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
98 self.set_bmp(bmp)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
99
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
100 def __del__(self):
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
101 del self.image
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
102 self.image = None
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
103
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
104 def set_bmp(self, bmp):
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
105 self.image = bmp
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
106 self.image.ConvertAlphaToMask()
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
107 self.generate_bmps()
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
108
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
109 def generate_bmps(self):
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
110 if self.width:
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
111 bmp = self.image.Copy()
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
112 bmp.Rescale(int(self.width), int(self.height))
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
113 else:
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
114 bmp = self.image
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
115 self.bmp = bmp.ConvertToBitmap()
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
116 self.bmp_gray = bmp.ConvertToGreyscale().ConvertToBitmap()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
117
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
118 def set_min_props(self, heading=FACE_NONE, face=FACE_NONE, label="", locked=False, hide=False, width=0, height=0):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
119 self.heading = heading
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
120 self.face = face
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
121 self.label = label
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
122 if locked: self.locked = True
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
123 else: self.locked = False
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
124 if hide: self.hide = True
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
125 else: self.hide = False
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
126 self.width = int(width)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
127 self.height = int(height)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
128 self.isUpdated = True
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
129 self.generate_bmps()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
130
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
131 def hit_test(self, pt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
132 rect = self.get_rect()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
133 result = None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
134 result = rect.InsideXY(pt.x, pt.y)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
135 return result
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
136
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
137 def get_rect(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
138 ret = wx.Rect(self.pos.x, self.pos.y, self.bmp.GetWidth(), self.bmp.GetHeight())
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
139 return ret
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
140
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
141 def draw(self, dc, mini_layer, op=wx.COPY):
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
142 if self.hide and mini_layer.canvas.frame.session.my_role() == mini_layer.canvas.frame.session.ROLE_GM:
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
143 # set the width and height of the image
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
144 self.left = 0
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
145 self.right = self.bmp.GetWidth()
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
146 self.top = 0
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
147 self.bottom = self.bmp.GetHeight()
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
148 # grey outline
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
149 graypen = wx.Pen("gray", 1, wx.DOT)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
150 dc.SetPen(graypen)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
151 dc.SetBrush(wx.TRANSPARENT_BRUSH)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
152 #if width or height < 20 then offset = 1
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
153 if self.bmp.GetWidth() <= 20: xoffset = 1
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
154 else: xoffset = 5
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
155 if self.bmp.GetHeight() <= 20: yoffset = 1
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
156 else: yoffset = 5
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
157 dc.DrawRectangle(self.pos.x + xoffset,
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
158 self.pos.y + yoffset, self.bmp.GetWidth(),
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
159 self.bmp.GetHeight())
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
160 dc.SetBrush(wx.NullBrush)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
161 dc.SetPen(wx.NullPen)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
162 if mini_layer.show_labels:
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
163 ## draw label in the center of the mini
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
164 label = mini_layer.get_mini_label(self)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
165 if len(label):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
166 dc.SetTextForeground(wx.RED)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
167 (textWidth,textHeight) = dc.GetTextExtent(label)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
168 x = self.pos.x +((self.bmp.GetWidth() - textWidth) /2) - 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
169 y = self.pos.y + (self.bmp.GetHeight() / 2)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
170 dc.SetPen(wx.GREY_PEN)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
171 dc.SetBrush(wx.LIGHT_GREY_BRUSH)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
172 dc.DrawRectangle(x, y, textWidth+2, textHeight+2)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
173 if (textWidth+2 > self.right):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
174 self.right += int((textWidth+2-self.right)/2)+1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
175 self.left -= int((textWidth+2-self.right)/2)+1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
176 self.bottom = y+textHeight+2-self.pos.y
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
177 dc.SetPen(wx.NullPen)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
178 dc.SetBrush(wx.NullBrush)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
179 dc.DrawText(label, x+1, y+1)
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
180
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
181 #selected outline
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
182 if self.selected:
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
183 dc.SetPen(wx.RED_PEN)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
184 dc.SetBrush(wx.TRANSPARENT_BRUSH)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
185 dc.DrawRectangle(self.pos.x, self.pos.y, self.bmp.GetWidth(), self.bmp.GetHeight())
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
186 dc.SetBrush(wx.NullBrush)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
187 dc.SetPen(wx.NullPen)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
188 return True
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
189 elif self.hide: return True
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
190
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
191 else:
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
192 bmp = self.bmp_gray if self.gray else self.bmp
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
193 try: dc.DrawBitmap(bmp, self.pos.x, self.pos.y, True)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
194 except: print bmp
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
195 self.left = 0
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
196 self.right = self.bmp.GetWidth()
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
197 self.top = 0
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
198 self.bottom = self.bmp.GetHeight()
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
199 # Draw the facing marker if needed
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
200 if self.face != 0:
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
201 x_mid = self.pos.x + (self.bmp.GetWidth()/2)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
202 x_right = self.pos.x + self.bmp.GetWidth()
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
203 y_mid = self.pos.y + (self.bmp.GetHeight()/2)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
204 y_bottom = self.pos.y + self.bmp.GetHeight()
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
205 dc.SetPen(wx.WHITE_PEN)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
206 dc.SetBrush(wx.RED_BRUSH)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
207 triangle = []
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
208 # Figure out which direction to draw the marker!!
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
209 tri_list = {
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
210 FACE_WEST: [cmpPoint(self.pos.x, self.pos.y), cmpPoint(self.pos.x-5, y_mid), cmpPoint(self.pos.x, y_bottom)],
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
211 FACE_EAST: [cmpPoint(x_right, self.pos.y), cmpPoint(x_right + 5, y_mid), cmpPoint(x_right, y_bottom)],
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
212 FACE_SOUTH: [cmpPoint(self.pos.x, y_bottom), cmpPoint(x_mid, y_bottom + 5), cmpPoint(x_right, y_bottom)],
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
213 FACE_NORTH: [cmpPoint(self.pos.x, self.pos.y), cmpPoint(x_mid, self.pos.y - 5), cmpPoint(x_right, self.pos.y)],
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
214 FACE_NORTHEAST: [cmpPoint(x_mid, self.pos.y), cmpPoint(x_right + 5, self.pos.y - 5), cmpPoint(x_right, y_mid), cmpPoint(x_right, self.pos.y)],
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
215 FACE_SOUTHEAST: [cmpPoint(x_right, y_mid), cmpPoint(x_right + 5, y_bottom + 5), cmpPoint(x_mid, y_bottom), cmpPoint(x_right, y_bottom)],
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
216 FACE_SOUTHWEST: [cmpPoint(x_mid, y_bottom), cmpPoint(self.pos.x - 5, y_bottom + 5),
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
217 cmpPoint(self.pos.x, y_mid), cmpPoint(self.pos.x, y_bottom)],
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
218 FACE_NORTHWEST: [cmpPoint(self.pos.x, y_mid), cmpPoint(self.pos.x - 5, self.pos.y - 5), cmpPoint(x_mid, self.pos.y), cmpPoint(self.pos.x, self.pos.y)]
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
219 }
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
220 for tri in tri_list[self.face]:
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
221 triangle.append(tri)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
222 del tri_list
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
223 dc.DrawPolygon(triangle)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
224 dc.SetBrush(wx.NullBrush)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
225 dc.SetPen(wx.NullPen)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
226 # Draw the heading if needed
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
227 if self.heading:
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
228 x_adjust = 0
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
229 y_adjust = 4
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
230 x_half = self.bmp.GetWidth()/2
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
231 y_half = self.bmp.GetHeight()/2
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
232 x_quarter = self.bmp.GetWidth()/4
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
233 y_quarter = self.bmp.GetHeight()/4
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
234 x_3quarter = x_quarter*3
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
235 y_3quarter = y_quarter*3
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
236 x_full = self.bmp.GetWidth()
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
237 y_full = self.bmp.GetHeight()
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
238 x_center = self.pos.x + x_half
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
239 y_center = self.pos.y + y_half
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
240 # Remember, the pen/brush must be a different color than the
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
241 # facing marker!!!! We'll use black/cyan for starters.
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
242 # Also notice that we will draw the heading on top of the
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
243 # larger facing marker.
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
244 dc.SetPen(wx.BLACK_PEN)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
245 dc.SetBrush(wx.CYAN_BRUSH)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
246 triangle = []
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
247 # Figure out which direction to draw the marker!!
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
248 tri_list = {
151
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 139
diff changeset
249 FACE_NORTH: [cmpPoint(x_center - x_quarter, y_center - y_half ),
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 139
diff changeset
250 cmpPoint(x_center, y_center - y_3quarter ),
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 139
diff changeset
251 cmpPoint(x_center + x_quarter, y_center - y_half)],
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 139
diff changeset
252 FACE_SOUTH: [cmpPoint(x_center - x_quarter, y_center + y_half ),
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 139
diff changeset
253 cmpPoint(x_center, y_center + y_3quarter ),
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 139
diff changeset
254 cmpPoint(x_center + x_quarter, y_center + y_half )],
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 139
diff changeset
255 FACE_NORTHEAST: [cmpPoint(x_center + x_quarter, y_center - y_half ),
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 139
diff changeset
256 cmpPoint(x_center + x_3quarter, y_center - y_3quarter ),
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 139
diff changeset
257 cmpPoint(x_center + x_half, y_center - y_quarter)],
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 139
diff changeset
258 FACE_EAST: [cmpPoint(x_center + x_half, y_center - y_quarter ),
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 139
diff changeset
259 cmpPoint(x_center + x_3quarter, y_center ),
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 139
diff changeset
260 cmpPoint(x_center + x_half, y_center + y_quarter )],
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 139
diff changeset
261 FACE_SOUTHEAST: [cmpPoint(x_center + x_half, y_center + y_quarter ),
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 139
diff changeset
262 cmpPoint(x_center + x_3quarter, y_center + y_3quarter ),
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 139
diff changeset
263 cmpPoint(x_center + x_quarter, y_center + y_half )],
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 139
diff changeset
264 FACE_SOUTHWEST: [cmpPoint(x_center - x_quarter, y_center + y_half ),
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 139
diff changeset
265 cmpPoint(x_center - x_3quarter, y_center + y_3quarter ),
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 139
diff changeset
266 cmpPoint(x_center - x_half, y_center + y_quarter )],
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 139
diff changeset
267 FACE_WEST: [cmpPoint(x_center - x_half, y_center + y_quarter ),
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 139
diff changeset
268 cmpPoint(x_center - x_3quarter, y_center ),
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 139
diff changeset
269 cmpPoint(x_center - x_half, y_center - y_quarter )],
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 139
diff changeset
270 FACE_NORTHWEST: [cmpPoint(x_center - x_half, y_center - y_quarter ),
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 139
diff changeset
271 cmpPoint(x_center - x_3quarter, y_center - y_3quarter ),
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 139
diff changeset
272 cmpPoint(x_center - x_quarter, y_center - y_half )]}
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
273 for tri in tri_list[self.heading]:
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
274 triangle.append(tri)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
275 del tri_list
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
276 dc.DrawPolygon(triangle)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
277 dc.SetBrush(wx.NullBrush)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
278 dc.SetPen(wx.NullPen)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
279 #selected outline
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
280 if self.selected:
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
281 dc.SetPen(wx.RED_PEN)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
282 dc.SetBrush(wx.TRANSPARENT_BRUSH)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
283 dc.DrawRectangle(self.pos.x, self.pos.y, self.bmp.GetWidth(), self.bmp.GetHeight())
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
284 dc.SetBrush(wx.NullBrush)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
285 dc.SetPen(wx.NullPen)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
286 if mini_layer.show_labels:
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
287 # draw label
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
288 self.mini_label(mini_layer, dc)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
289 self.top-=5
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
290 self.bottom+=5
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
291 self.left-=5
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
292 self.right+=5
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
293 return True
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
294
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
295
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
296 def mini_label(self, mini_layer, dc):
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
297 label = mini_layer.get_mini_label(self)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
298 if len(label):
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
299 dc.SetTextForeground(wx.RED)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
300 (textWidth,textHeight) = dc.GetTextExtent(label)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
301 x = self.pos.x +((self.bmp.GetWidth() - textWidth) /2) - 1
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
302 y = self.pos.y + self.bmp.GetHeight() + 6
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
303 dc.SetPen(wx.WHITE_PEN)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
304 dc.SetBrush(wx.WHITE_BRUSH)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
305 dc.DrawRectangle(x,y,textWidth+2,textHeight+2)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
306 if (textWidth+2 > self.right):
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
307 self.right += int((textWidth+2-self.right)/2)+1
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
308 self.left -= int((textWidth+2-self.right)/2)+1
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
309 self.bottom = y+textHeight+2-self.pos.y
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
310 dc.SetPen(wx.NullPen)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
311 dc.SetBrush(wx.NullBrush)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
312 dc.DrawText(label,x+1,y+1)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
313
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
314 def toxml(self, action="update"):
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
315 if action == "del":
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
316 xml_str = "<miniature action='del' id='" + self.id + "'/>"
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
317 return xml_str
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
318 xml_str = "<miniature"
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
319 xml_str += " action='" + action + "'"
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
320 xml_str += " label='" + self.label + "'"
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
321 xml_str+= " id='" + self.id + "'"
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
322 if self.pos != None:
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
323 xml_str += " posx='" + str(self.pos.x) + "'"
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
324 xml_str += " posy='" + str(self.pos.y) + "'"
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
325 if self.heading != None: xml_str += " heading='" + str(self.heading) + "'"
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
326 if self.face != None: xml_str += " face='" + str(self.face) + "'"
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
327 if self.path != None: xml_str += " path='" + urllib.quote(self.path).replace('%3A', ':') + "'"
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
328 if self.locked: xml_str += " locked='1'"
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
329 else: xml_str += " locked='0'"
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
330 if self.hide: xml_str += " hide='1'"
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
331 else: xml_str += " hide='0'"
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
332 if self.snap_to_align != None: xml_str += " align='" + str(self.snap_to_align) + "'"
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
333 if self.id != None: xml_str += " zorder='" + str(self.zorder) + "'"
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
334 if self.width != None: xml_str += " width='" + str(self.width) + "'"
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
335 if self.height != None: xml_str += " height='" + str(self.height) + "'"
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
336 if self.local:
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
337 xml_str += ' local="' + str(self.local) + '"'
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
338 xml_str += ' localPath="' + str(urllib.quote(self.localPath).replace('%3A', ':')) + '"'
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
339 xml_str += ' localTime="' + str(self.localTime) + '"'
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
340 xml_str += " />"
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
341 if (action == "update" and self.isUpdated) or action == "new":
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
342 self.isUpdated = False
195
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents: 159
diff changeset
343 return xml_str
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
344 else: return ''
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
345
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
346 def takedom(self, xml_dom):
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
347 self.id = xml_dom.getAttribute("id")
151
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 139
diff changeset
348 if xml_dom.hasAttribute("posx"): self.pos.x = int(xml_dom.getAttribute("posx"))
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 139
diff changeset
349 if xml_dom.hasAttribute("posy"): self.pos.y = int(xml_dom.getAttribute("posy"))
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 139
diff changeset
350 if xml_dom.hasAttribute("heading"): self.heading = int(xml_dom.getAttribute("heading"))
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 139
diff changeset
351 if xml_dom.hasAttribute("face"): self.face = int(xml_dom.getAttribute("face"))
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
352 if xml_dom.hasAttribute("path"):
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
353 self.path = urllib.unquote(xml_dom.getAttribute("path"))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
354 self.set_bmp(ImageHandler.load(self.path, 'miniature', self.id))
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
355 if xml_dom.hasAttribute("locked"):
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
356 if xml_dom.getAttribute("locked") == '1' or xml_dom.getAttribute("locked") == 'True': self.locked = True
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
357 else: self.locked = False
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
358 if xml_dom.hasAttribute("hide"):
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
359 if xml_dom.getAttribute("hide") == '1' or xml_dom.getAttribute("hide") == 'True': self.hide = True
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
360 else: self.hide = False
151
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 139
diff changeset
361 if xml_dom.hasAttribute("label"): self.label = xml_dom.getAttribute("label")
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 139
diff changeset
362 if xml_dom.hasAttribute("zorder"): self.zorder = int(xml_dom.getAttribute("zorder"))
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
363 if xml_dom.hasAttribute("align"):
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
364 if xml_dom.getAttribute("align") == '1' or xml_dom.getAttribute("align") == 'True': self.snap_to_align = 1
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
365 else: self.snap_to_align = 0
151
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 139
diff changeset
366 if xml_dom.hasAttribute("width"): self.width = int(xml_dom.getAttribute("width"))
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 139
diff changeset
367 if xml_dom.hasAttribute("height"): self.height = int(xml_dom.getAttribute("height"))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
368
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
369 ##-----------------------------
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
370 ## miniature layer
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
371 ##-----------------------------
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
372 class miniature_layer(layer_base):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
373 def __init__(self, canvas):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
374 self.canvas = canvas
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
375 layer_base.__init__(self)
195
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents: 159
diff changeset
376 self.id = -1
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
377 self.miniatures = []
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
378 self.serial_number = 0
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
379 self.show_labels = True
7
2b9e766f9dee Tests fixes issues with Linux GUI effecting miniatures
sirebral
parents: 0
diff changeset
380 # Set the font of the labels to be the same as the chat window
2b9e766f9dee Tests fixes issues with Linux GUI effecting miniatures
sirebral
parents: 0
diff changeset
381 # only smaller.
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
382 font_size = int(settings.get_setting('defaultfontsize'))
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
383 if (font_size >= 10): font_size -= 2
137
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 119
diff changeset
384 self.label_font = wx.Font(font_size,
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 119
diff changeset
385 wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL,
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 119
diff changeset
386 wx.FONTWEIGHT_NORMAL,
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
387 False, settings.get_setting('defaultfont'))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
388
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
389 def next_serial(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
390 self.serial_number += 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
391 return self.serial_number
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
392
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
393 def get_next_highest_z(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
394 z = len(self.miniatures)+1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
395 return z
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
396
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
397 def cleanly_collapse_zorder(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
398 # lock the zorder stuff
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
399 sorted_miniatures = self.miniatures[:]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
400 sorted_miniatures.sort(cmp_zorder)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
401 i = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
402 for mini in sorted_miniatures:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
403 mini.zorder = i
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
404 i = i + 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
405 # unlock the zorder stuff
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
406
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
407 def collapse_zorder(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
408 # lock the zorder stuff
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
409 sorted_miniatures = self.miniatures[:]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
410 sorted_miniatures.sort(cmp_zorder)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
411 i = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
412 for mini in sorted_miniatures:
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
413 if (mini.zorder != MIN_STICKY_BACK) and (mini.zorder != MIN_STICKY_FRONT): mini.zorder = i
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
414 else: pass
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
415 i = i + 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
416 # unlock the zorder stuff
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
417
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
418 def rollback_serial(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
419 self.serial_number -= 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
420
19
78407d627cba Beginning of Code Clean-up. Some code untested, may break!
sirebral
parents: 7
diff changeset
421 def add_miniature(self, id, path, pos=cmpPoint(0,0), label="", heading=FACE_NONE,
78407d627cba Beginning of Code Clean-up. Some code untested, may break!
sirebral
parents: 7
diff changeset
422 face=FACE_NONE, width=0, height=0, local=False, localPath='', localTime=-1):
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
423 bmp = ImageHandler.load(path, 'miniature', id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
424 if bmp:
19
78407d627cba Beginning of Code Clean-up. Some code untested, may break!
sirebral
parents: 7
diff changeset
425 mini = BmpMiniature(id, path, bmp, pos, heading, face, label,
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 88
diff changeset
426 zorder=self.get_next_highest_z(), width=width,
71
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 21
diff changeset
427 height=height, local=local, localPath=localPath, localTime=localTime)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
428 self.miniatures.append(mini)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
429 xml_str = "<map><miniatures>"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
430 xml_str += mini.toxml("new")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
431 xml_str += "</miniatures></map>"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
432 self.canvas.frame.session.send(xml_str)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
433
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
434 def get_miniature_by_id(self, id):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
435 for mini in self.miniatures:
151
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 139
diff changeset
436 if str(mini.id) == str(id): return mini
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
437 return None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
438
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
439 def del_miniature(self, min):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
440 xml_str = "<map><miniatures>"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
441 xml_str += min.toxml("del")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
442 xml_str += "</miniatures></map>"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
443 self.canvas.frame.session.send(xml_str)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
444 self.miniatures.remove(min)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
445 del min
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
446 self.collapse_zorder()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
447
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
448 def del_all_miniatures(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
449 while len(self.miniatures):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
450 min = self.miniatures.pop()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
451 del min
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
452 self.collapse_zorder()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
453
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
454 def layerDraw(self, dc, topleft, size):
7
2b9e766f9dee Tests fixes issues with Linux GUI effecting miniatures
sirebral
parents: 0
diff changeset
455 dc.SetFont(self.label_font)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
456 sorted_miniatures = self.miniatures[:]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
457 sorted_miniatures.sort(cmp_zorder)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
458 for m in sorted_miniatures:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
459 if (m.pos.x>topleft[0]-m.right and
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
460 m.pos.y>topleft[1]-m.bottom and
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
461 m.pos.x<topleft[0]+size[0]-m.left and
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
462 m.pos.y<topleft[1]+size[1]-m.top):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
463 m.draw(dc, self)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
464
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
465 def find_miniature(self, pt, only_unlocked=False):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
466 min_list = []
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
467 for m in self.miniatures:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
468 if m.hit_test(pt):
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
469 if m.hide and self.canvas.frame.session.my_role() != self.canvas.frame.session.ROLE_GM: continue
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
470 if only_unlocked and not m.locked: min_list.append(m)
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
471 elif not only_unlocked and m.locked: min_list.append(m)
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
472 else: continue
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
473 if len(min_list) > 0:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
474 return min_list
71
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 21
diff changeset
475 else: return None
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
476
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
477 def layerToXML(self, action="update"):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
478 """ format """
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
479 minis_string = ""
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
480 if self.miniatures:
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
481 for m in self.miniatures: minis_string += m.toxml(action)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
482 if minis_string != '':
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
483 s = "<miniatures"
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
484 s += " serial='" + str(self.serial_number) + "'"
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
485 s += ">"
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
486 s += minis_string
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
487 s += "</miniatures>"
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
488 return s
71
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 21
diff changeset
489 else: return ""
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
490
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
491 def layerTakeDOM(self, xml_dom):
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
492 if xml_dom.hasAttribute('serial'):
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
493 self.serial_number = int(xml_dom.getAttribute('serial'))
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
494 children = xml_dom._get_childNodes()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
495 for c in children:
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
496 action = c.getAttribute("action")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
497 id = c.getAttribute('id')
21
fdd70f11bc7e One too many deletes last time. This run tested on Linux and working
sirebral
parents: 20
diff changeset
498 if action == "del":
fdd70f11bc7e One too many deletes last time. This run tested on Linux and working
sirebral
parents: 20
diff changeset
499 mini = self.get_miniature_by_id(id)
151
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 139
diff changeset
500 if mini: self.miniatures.remove(mini); del mini
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
501 elif action == "new":
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
502 pos = cmpPoint(int(c.getAttribute('posx')),int(c.getAttribute('posy')))
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
503 path = urllib.unquote(c.getAttribute('path'))
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
504 label = c.getAttribute('label')
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
505 height = width = heading = face = snap_to_align = zorder = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
506 locked = hide = False
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
507 if c.hasAttribute('height'): height = int(c.getAttribute('height'))
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
508 if c.hasAttribute('width'): width = int(c.getAttribute('width'))
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
509 if c.getAttribute('locked') == 'True' or c.getAttribute('locked') == '1': locked = True
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
510 if c.getAttribute('hide') == 'True' or c.getAttribute('hide') == '1': hide = True
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
511 if c.getAttribute('heading'): heading = int(c.getAttribute('heading'))
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
512 if c.hasAttribute('face'): face = int(c.getAttribute('face'))
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
513 if c.hasAttribute('align'): snap_to_align = int(c.getAttribute('align'))
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
514 if c.getAttribute('zorder'): zorder = int(c.getAttribute('zorder'))
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
515 min = BmpMiniature(id, path, ImageHandler.load(path, 'miniature', id), pos, heading,
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
516 face, label, locked, hide, snap_to_align, zorder, width, height)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
517 self.miniatures.append(min)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
518 if c.hasAttribute('local') and c.getAttribute('local') == 'True' and os.path.exists(urllib.unquote(c.getAttribute('localPath'))):
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
519 localPath = urllib.unquote(c.getAttribute('localPath'))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
520 local = True
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 137
diff changeset
521 localTime = float(c.getAttribute('localTime'))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
522 if localTime-time.time() <= 144000:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
523 file = open(localPath, "rb")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
524 imgdata = file.read()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
525 file.close()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
526 filename = os.path.split(localPath)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
527 (imgtype,j) = mimetypes.guess_type(filename[1])
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
528 postdata = urllib.urlencode({'filename':filename[1], 'imgdata':imgdata, 'imgtype':imgtype})
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
529 thread.start_new_thread(self.upload, (postdata, localPath, True))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
530 # collapse the zorder. If the client behaved well, then nothing should change.
151
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 139
diff changeset
531 # Otherwise, this will ensure that there's some kind of z-order
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
532 self.collapse_zorder()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
533 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
534 mini = self.get_miniature_by_id(id)
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
535 if mini: mini.takedom(c)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
536
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
537 def upload(self, postdata, filename, modify=False, pos=cmpPoint(0,0)):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
538 self.lock.acquire()
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
539 url = settings.get_setting('ImageServerBaseURL')
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
540 file = urllib.urlopen(url, postdata)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
541 recvdata = file.read()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
542 file.close()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
543 try:
137
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 119
diff changeset
544 xml_dom = fromstring(recvdata)
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 119
diff changeset
545 if xml_dom.tag == 'path':
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 119
diff changeset
546 path = xml_dom.get('url')
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
547 path = urllib.unquote(path)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
548 if not modify:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
549 start = path.rfind("/") + 1
159
033887bb8a86 Traipse Alpha 'OpenRPG' {091126-00}
sirebral
parents: 151
diff changeset
550 if self.canvas.parent.layer_handlers[2].auto_label: min_label = path[start:len(path)-4]
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
551 else: min_label = ""
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
552 id = 'mini-' + self.canvas.frame.session.get_next_id()
19
78407d627cba Beginning of Code Clean-up. Some code untested, may break!
sirebral
parents: 7
diff changeset
553 self.add_miniature(id, path, pos=pos, label=min_label, local=True,
78407d627cba Beginning of Code Clean-up. Some code untested, may break!
sirebral
parents: 7
diff changeset
554 localPath=filename, localTime=time.time())
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
555 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
556 self.miniatures[len(self.miniatures)-1].local = True
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
557 self.miniatures[len(self.miniatures)-1].localPath = filename
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
558 self.miniatures[len(self.miniatures)-1].localTime = time.time()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
559 self.miniatures[len(self.miniatures)-1].path = path
151
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 139
diff changeset
560 else: print xml_dom.get('msg')
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
561 except Exception, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
562 print e
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
563 print recvdata
88
763a04270cf6 Traipse Alpha 'OpenRPG' {090917-02}
sirebral
parents: 76
diff changeset
564 finally:
763a04270cf6 Traipse Alpha 'OpenRPG' {090917-02}
sirebral
parents: 76
diff changeset
565 urllib.urlcleanup()
763a04270cf6 Traipse Alpha 'OpenRPG' {090917-02}
sirebral
parents: 76
diff changeset
566 self.lock.release()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
567 ####################################################################
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
568 ## helper function
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
569
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
570 def get_mini_label(self, mini):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
571 # override this to change the label displayed under each mini (and the label on hidden minis)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
572 return mini.label