annotate orpg/mapper/whiteboard.py @ 138:1ed2feab0db9 alpha

Traipse Alpha 'OpenRPG' {091021-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. !!Alpha Still- Watch out for infinite loops!! 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. Appended tr_ to ID's to prevent non updated clients from ruining the fix.
author sirebral
date Sat, 21 Nov 2009 03:19:34 -0600
parents 54446a995007
children 8e07c1a2c69b
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/whiteboard.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:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
24 # $Id: whiteboard.py,v 1.47 2007/03/09 14:11:55 digitalxero Exp $
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 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
29 __version__ = "$Id: whiteboard.py,v 1.47 2007/03/09 14:11:55 digitalxero Exp $"
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 *
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
32 from orpg.mapper.map_utils import *
137
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
33 from orpg.tools.orpg_log import debug
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
34 from xml.etree.ElementTree import ElementTree, Element, tostring
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
35
138
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 137
diff changeset
36 ## I added tr_ to the line and text ID. This should help prevent Traipse's lines from being randomly deleted. ##
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 137
diff changeset
37
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
38 def cmp_zorder(first,second):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
39 f = first.zorder
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
40 s = second.zorder
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
41 if f == None: f = 0
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
42 if s == None: s = 0
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
43 if f == s: value = 0
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
44 elif f < s: value = -1
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
45 else: value = 1
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
46 return value
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
47
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
48 class WhiteboardText:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
49 def __init__(self, id, text_string, pos, style, pointsize, weight, color="#000000", log=None):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
50 self.scale = 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
51 self.r_h = RGBHex()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
52 self.selected = False
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
53 self.text_string = text_string
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
54 self.id = id
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
55 self.weight = int(weight)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
56 self.pointsize = int(pointsize)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
57 self.style = int(style)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
58 self.textcolor = color
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
59 self.posx = pos.x
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
60 self.posy = pos.y
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
61 self.font = wx.Font(self.pointsize, wx.DEFAULT, self.style, self.weight)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
62 self.highlighted = False
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
63 r,g,b = self.r_h.rgb_tuple(self.textcolor)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
64 self.highlight_color = self.r_h.hexstring(r^255, g^255, b^255)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
65 self.isUpdated = False
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
66
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
67 def highlight(self, highlight=True):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
68 self.highlighted = highlight
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
69
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
70 def set_text_props(self, text_string, style, point, weight, color="#000000"):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
71 self.text_string = text_string
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
72 self.textcolor = color
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
73 self.style = int(style)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
74 self.font.SetStyle(self.style)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
75 self.pointsize = int(point)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
76 self.font.SetPointSize(self.pointsize)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
77 self.weight = int(weight)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
78 self.font.SetWeight(self.weight)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
79 self.isUpdated = True
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
80
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
81 def hit_test(self, pt, dc):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
82 rect = self.get_rect(dc)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
83 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
84 return result
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
85
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
86 def get_rect(self, dc):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
87 dc.SetFont(self.font)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
88 (w,x,y,z) = dc.GetFullTextExtent(self.text_string)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
89 return wx.Rect(self.posx,self.posy,w,(x+y+z))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
90
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
91 def draw(self, parent, dc, op=wx.COPY):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
92 self.scale = parent.canvas.layers['grid'].mapscale
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
93 if self.highlighted: textcolor = self.highlight_color
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
94 else: textcolor = self.textcolor
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
95 try: dc.SetTextForeground(textcolor)
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
96 except Exception,e: dc.SetTextForeground('#000000')
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
97 dc.SetUserScale(self.scale, self.scale)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
98
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
99 # Draw text
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
100 (w,x,y,z) = self.get_rect(dc)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
101 dc.SetFont(self.font)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
102 dc.DrawText(self.text_string, self.posx, self.posy)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
103 dc.SetTextForeground(wx.Colour(0,0,0))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
104
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
105 def toxml(self, action="update"):
137
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
106 xml = Element('text')
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
107 xml.set('action', action)
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
108 xml.set('id', str(self.id))
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
109 if action == 'del': return tostring(xml)
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
110 if self.pointsize != None: xml.set('pointsize', str(self.pointsize))
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
111 if self.style != None: xml.set('style', str(self.style))
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
112 if self.weight != None: xml.set('weight', str(self.weight))
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
113 if self.posx != None: xml.set('posx', str(self.posx))
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
114 if not (self.posy is None): xml.set('posy', str(self.posy))
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
115 if self.text_string != None: xml.set('text_string', self.text_string)
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
116 if self.textcolor != None: xml.set('color', self.textcolor)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
117 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
118 self.isUpdated = False
137
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
119 return tostring(xml)
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
120 else: return ''
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
121
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
122 def takedom(self, xml_dom):
137
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
123 self.text_string = xml_dom.get("text_string")
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
124 self.id = xml_dom.get("id")
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
125 if xml_dom.get("posy"): self.posy = int(xml_dom.get("posy"))
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
126 if xml_dom.get("posx"): self.posx = int(xml_dom.get("posx"))
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
127 if xml_dom.get("weight"):
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
128 self.weight = int(xml_dom.get("weight"))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
129 self.font.SetWeight(self.weight)
137
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
130 if xml_dom.get("style"):
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
131 self.style = int(xml_dom.get("style"))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
132 self.font.SetStyle(self.style)
137
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
133 if xml_dom.get("pointsize"):
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
134 self.pointsize = int(xml_dom.get("pointsize"))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
135 self.font.SetPointSize(self.pointsize)
137
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
136 if xml_dom.get("color") and xml_dom.get("color") != '':
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
137 self.textcolor = xml_dom.get("color")
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
138 if self.textcolor == '#0000000': self.textcolor = '#000000'
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
139
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
140 class WhiteboardLine:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
141 def __init__(self, id, line_string, upperleft, lowerright, color="#000000", width=1, log=None):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
142 self.scale = 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
143 self.r_h = RGBHex()
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
144 if color == '': color = "#000000"
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
145 self.linecolor = color
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
146 self.linewidth = width
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
147 self.lowerright = lowerright
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
148 self.upperleft = upperleft
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
149 self.selected = False
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
150 self.line_string = line_string
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
151 self.id = id
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
152 self.highlighted = False
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
153 r,g,b = self.r_h.rgb_tuple(self.linecolor)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
154 self.highlight_color = self.r_h.hexstring(r^255, g^255, b^255)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
155
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
156 def highlight(self, highlight=True):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
157 self.highlighted = highlight
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
158
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: 20
diff changeset
159 def set_line_props(self, line_string="",
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: 20
diff changeset
160 upperleftx=0, upperlefty=0,
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: 20
diff changeset
161 lowerrightx=0, lowerrighty=0,
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: 20
diff changeset
162 color="#000000", width=1):
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
163 self.line_string = line_string
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
164 self.upperleft.x = upperleftx
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
165 self.upperleft.y = upperlefty
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
166 self.lowerright.x = lowerrightx
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
167 self.lowerright.y = lowerrighty
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
168 self.linecolor = color
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
169 self.linewidth = width
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
170
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
171 def hit_test(self, pt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
172 coords = self.line_string.split(";")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
173 stcords = coords[0].split(",")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
174 oldicords = (int(stcords[0]),int(stcords[1]))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
175 for coordinate_string_counter in range(1, len(coords)):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
176 stcords = coords[coordinate_string_counter].split(",")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
177 if stcords[0] == "":
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
178 return False
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
179 icords = (int(stcords[0]),int(stcords[1]))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
180 if orpg.mapper.map_utils.proximity_test(oldicords,icords,pt,12):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
181 return True
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
182 oldicords = icords
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
183 return False
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
184
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
185 def draw(self, parent, dc, op=wx.COPY):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
186 self.scale = parent.canvas.layers['grid'].mapscale
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
187 if self.highlighted: linecolor = self.highlight_color
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
188 else: linecolor = self.linecolor
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
189 pen = wx.BLACK_PEN
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
190 try: pen.SetColour(linecolor)
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
191 except Exception,e: pen.SetColour('#000000')
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
192 pen.SetWidth( self.linewidth )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
193 dc.SetPen( pen )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
194 dc.SetBrush(wx.BLACK_BRUSH)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
195 # draw lines
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
196 dc.SetUserScale(self.scale,self.scale)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
197 pointArray = self.line_string.split(";")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
198 x2 = y2 = -999
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
199 for m in range(len(pointArray)-1):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
200 x = pointArray[m]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
201 points = x.split(",")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
202 x1 = int(points[0])
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
203 y1 = int(points[1])
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
204 if x2 != -999: dc.DrawLine(x2,y2,x1,y1)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
205 x2 = x1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
206 y2 = y1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
207 pen.SetColour(wx.Colour(0,0,0))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
208 dc.SetPen(pen)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
209 dc.SetPen(wx.NullPen)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
210 dc.SetBrush(wx.NullBrush)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
211 #selected outline
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
212
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
213 def toxml(self, action="update"):
137
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
214 xml = Element('line')
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
215 xml.set('action', action)
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
216 xml.set('id', str(self.id))
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
217 if action == "del": return tostring(xml)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
218 # if there are any changes, make sure id is one of them
137
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
219 xml.set('line_string', self.line_string)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
220 if self.upperleft != None:
137
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
221 xml.set('upperleftx', str(self.upperleft.x))
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
222 xml.set('upperlefty', str(self.upperleft.y))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
223 if self.lowerright != None:
137
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
224 xml.set('lowerrightx', str(self.lowerright.x))
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
225 xml.set('lowerrighty', str(self.lowerright.y))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
226 if self.linecolor != None:
137
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
227 xml.set('color', str(self.linecolor))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
228 if self.linewidth != None:
137
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
229 xml.set('width', str(self.linewidth))
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
230 if action == "new": return tostring(xml)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
231 return ''
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
232
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
233 def takedom(self, xml_dom):
137
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
234 self.line_string = xml_dom.get("line_string")
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
235 self.id = xml_dom.get("id")
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
236 if xml_dom.get("upperleftx"):
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
237 self.upperleft.x = int(xml_dom.get("upperleftx"))
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
238 if xml_dom.get("upperlefty"):
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
239 self.upperleft.y = int(xml_dom.get("upperlefty"))
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
240 if xml_dom.get("lowerrightx"):
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
241 self.lowerright.x = int(xml_dom.get("lowerrightx"))
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
242 if xml_dom.get("lowerrighty"):
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
243 self.lowerright.y = int(xml_dom.get("lowerrighty"))
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
244 if xml_dom.get("color") and xml_dom.get("color") != '':
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
245 self.linecolor = xml_dom.get("color")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
246 if self.linecolor == '#0000000':
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
247 self.linecolor = '#000000'
137
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
248 if xml_dom.get("width"):
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
249 self.linewidth = int(xml_dom.get("width"))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
250
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
251 ##-----------------------------
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
252 ## whiteboard layer
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
253 ##-----------------------------
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
254 class whiteboard_layer(layer_base):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
255
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
256 def __init__(self, canvas):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
257 self.canvas = canvas
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
258 layer_base.__init__(self)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
259 self.r_h = RGBHex()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
260 self.id = -1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
261 self.lines = []
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
262 self.texts = []
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
263 self.serial_number = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
264 self.color = "#000000"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
265 self.width = 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
266 self.removedLines = []
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
267
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
268 def next_serial(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
269 self.serial_number += 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
270 return self.serial_number
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
271
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
272 def get_next_highest_z(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
273 z = len(self.lines)+1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
274 return z
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
275
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
276 def cleanly_collapse_zorder(self):
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: 20
diff changeset
277 pass
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
278
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
279 def collapse_zorder(self):
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: 20
diff changeset
280 pass
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
281
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
282 def rollback_serial(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
283 self.serial_number -= 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
284
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
285 def add_line(self, line_string="", upperleft=cmpPoint(0,0), lowerright=cmpPoint(0,0), color="#000000", width=1):
138
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 137
diff changeset
286 id = 'tr_line-' + str(self.next_serial())
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: 20
diff changeset
287 line = WhiteboardLine(id, line_string, upperleft, lowerright, color=self.color, width=self.width)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
288 self.lines.append(line)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
289 xml_str = "<map><whiteboard>"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
290 xml_str += line.toxml("new")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
291 xml_str += "</whiteboard></map>"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
292 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
293 self.canvas.Refresh(True)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
294 return line
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
295
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
296 def get_line_by_id(self, id):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
297 for line in self.lines:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
298 if str(line.id) == str(id):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
299 return line
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
300 return None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
301
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
302 def get_text_by_id(self, id):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
303 for text in self.texts:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
304 if str(text.id) == str(id):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
305 return text
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
306 return None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
307
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
308 def del_line(self, line):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
309 xml_str = "<map><whiteboard>"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
310 xml_str += line.toxml("del")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
311 xml_str += "</whiteboard></map>"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
312 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
313 if line:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
314 self.lines.remove(line)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
315 self.removedLines.append(line)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
316 self.canvas.Refresh(True)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
317
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
318 def undo_line(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
319 if len(self.removedLines)>0:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
320 line = self.removedLines[len(self.removedLines)-1]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
321 self.removedLines.remove(line)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
322 self.add_line(line.line_string, line.upperleft, line.lowerright, line.linecolor, line.linewidth)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
323 self.canvas.Refresh(True)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
324
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
325 def del_all_lines(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
326 for i in xrange(len(self.lines)):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
327 self.del_line(self.lines[0])
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
328
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
329 def del_text(self, text):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
330 xml_str = "<map><whiteboard>"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
331 xml_str += text.toxml("del")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
332 xml_str += "</whiteboard></map>"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
333 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
334 if text:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
335 self.texts.remove(text)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
336 self.canvas.Refresh(True)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
337
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
338 def layerDraw(self, dc):
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
339 for m in self.lines: m.draw(self, dc)
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
340 for m in self.texts: m.draw(self,dc)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
341
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
342 def hit_test_text(self, pos, dc):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
343 list_of_texts_matching = []
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
344 if self.canvas.layers['fog'].use_fog == 1:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
345 if self.canvas.frame.session.role != "GM":
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
346 return list_of_texts_matching
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
347 for m in self.texts:
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
348 if m.hit_test(pos,dc): list_of_texts_matching.append(m)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
349 return list_of_texts_matching
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
350
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
351 def hit_test_lines(self, pos, dc):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
352 list_of_lines_matching = []
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
353 if self.canvas.layers['fog'].use_fog == 1:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
354 if self.canvas.frame.session.role != "GM":
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
355 return list_of_lines_matching
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
356 for m in self.lines:
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
357 if m.hit_test(pos): list_of_lines_matching.append(m)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
358 return list_of_lines_matching
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
359
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
360 def find_line(self, pt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
361 scale = self.canvas.layers['grid'].mapscale
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
362 dc = wx.ClientDC( self.canvas )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
363 self.canvas.PrepareDC( dc )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
364 dc.SetUserScale(scale,scale)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
365 line_list = self.hit_test_lines(pt,dc)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
366 if line_list:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
367 return line_list[0]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
368 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
369 return None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
370
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
371 def setcolor(self, color):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
372 r,g,b = color.Get()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
373 self.color = self.r_h.hexstring(r,g,b)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
374
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
375 def sethexcolor(self, hexcolor):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
376 self.color = hexcolor
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
377
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
378 def setwidth(self, width):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
379 self.width = int(width)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
380
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
381 def set_font(self, font):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
382 self.font = font
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
383
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
384 def add_text(self, text_string, pos, style, pointsize, weight, color="#000000"):
138
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 137
diff changeset
385 id = 'tr_text-' + str(self.next_serial())
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: 20
diff changeset
386 text = WhiteboardText(id,text_string, pos, style, pointsize, weight, color)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
387 self.texts.append(text)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
388 xml_str = "<map><whiteboard>"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
389 xml_str += text.toxml("new")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
390 xml_str += "</whiteboard></map>"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
391 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
392 self.canvas.Refresh(True)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
393
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
394 def draw_working_line(self, dc, line_string):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
395 scale = self.canvas.layers['grid'].mapscale
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
396 dc.SetPen(wx.BLACK_PEN)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
397 dc.SetBrush(wx.BLACK_BRUSH)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
398 pen = wx.BLACK_PEN
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
399 pen.SetColour(self.color)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
400 pen.SetWidth(self.width)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
401 dc.SetPen(pen)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
402 dc.SetUserScale(scale,scale)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
403 pointArray = line_string.split(";")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
404 x2 = y2 = -999
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
405 for m in range(len(pointArray)-1):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
406 x = pointArray[m]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
407 points = x.split(",")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
408 x1 = int(points[0])
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
409 y1 = int(points[1])
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
410 if x2 != -999:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
411 dc.DrawLine(x2,y2,x1,y1)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
412 x2 = x1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
413 y2 = y1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
414 dc.SetPen(wx.NullPen)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
415 dc.SetBrush(wx.NullBrush)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
416
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
417 def layerToXML(self, action="update"):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
418 """ format """
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
419 white_string = ""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
420 if self.lines:
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
421 for l in self.lines: white_string += l.toxml(action)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
422 if self.texts:
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
423 for l in self.texts: white_string += l.toxml(action)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
424 if len(white_string):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
425 s = "<whiteboard"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
426 s += " serial='" + str(self.serial_number) + "'"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
427 s += ">"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
428 s += white_string
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
429 s += "</whiteboard>"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
430 return s
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
431 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
432 return ""
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 layerTakeDOM(self, xml_dom):
137
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
435 serial_number = xml_dom.get('serial')
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
436 if serial_number != "": self.serial_number = int(serial_number)
137
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
437 children = xml_dom.getchildren()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
438 for l in children:
137
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
439 nodename = l.tag
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
440 action = l.get("action")
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
441 id = l.get('id')
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
442 if self.serial_number < int(id[5:]): self.serial_number = int(id[5:])
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
443 if action == "del":
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
444 if nodename == 'line':
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
445 line = self.get_line_by_id(id)
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
446 if line != None: self.lines.remove(line)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
447 elif nodename == 'text':
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
448 text = self.get_text_by_id(id)
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
449 if text != None: self.texts.remove(text)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
450 elif action == "new":
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
451 if nodename == "line":
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
452 try:
137
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
453 line_string = l.get('line_string')
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
454 upperleftx = l.get('upperleftx')
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
455 upperlefty = l.get('upperlefty')
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
456 lowerrightx = l.get('lowerrightx')
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
457 lowerrighty = l.get('lowerrighty')
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
458 upperleft = wx.Point(int(upperleftx),int(upperlefty))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
459 lowerright = wx.Point(int(lowerrightx),int(lowerrighty))
137
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
460 color = l.get('color')
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
461 if color == '#0000000': color = '#000000'
137
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
462 id = l.get('id')
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
463 width = int(l.get('width'))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
464 except:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
465 line_string = upperleftx = upperlefty = lowerrightx = lowerrighty = color = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
466 continue
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: 20
diff changeset
467 line = WhiteboardLine(id, line_string, upperleft, lowerright, color, width)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
468 self.lines.append(line)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
469 elif nodename == "text":
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
470 try:
137
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
471 text_string = l.get('text_string')
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
472 style = l.get('style')
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
473 pointsize = l.get('pointsize')
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
474 weight = l.get('weight')
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
475 color = l.get('color')
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
476 if color == '#0000000': color = '#000000'
137
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
477 id = l.get('id')
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
478 posx = l.get('posx')
54446a995007 Traipse Alpha 'OpenRPG' {091018-00}
sirebral
parents: 71
diff changeset
479 posy = l.get('posy')
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
480 pos = wx.Point(0,0)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
481 pos.x = int(posx)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
482 pos.y = int(posy)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
483 except:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
484 continue
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: 20
diff changeset
485 text = WhiteboardText(id, text_string, pos, style, pointsize, weight, color)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
486 self.texts.append(text)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
487 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
488 if nodename == "line":
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
489 line = self.get_line_by_id(id)
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
490 if line: line.takedom(l)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
491 if nodename == "text":
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
492 text = self.get_text_by_id(id)
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
493 if text: text.takedom(l)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
494 #self.canvas.send_map_data()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
495
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
496 def add_temp_line(self, line_string):
19
78407d627cba Beginning of Code Clean-up. Some code untested, may break!
sirebral
parents: 0
diff changeset
497 line = WhiteboardLine(0, line_string, wx.Point(0,0), wx.Point(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: 20
diff changeset
498 color=self.color, width=self.width)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
499 self.lines.append(line)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
500 return line
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
501
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
502 def del_temp_line(self, line):
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
503 if line: self.lines.remove(line)