Mercurial > traipse_dev
comparison orpg/mapper/whiteboard.py @ 152:6081bdc2b8d5 beta
Traipse Beta 'OpenRPG' {091125-00}
Traipse is a distribution of OpenRPG that is designed to be easy to setup and go.
Traipse also makes it easy for developers to work on code without fear of
sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the
code. 'Ornery-Orc's main goal is to offer more advanced features and enhance the
productivity of the user.
Update Summary (Beta)
Added Bookmarks
Fix to Remote Admin Commands
Minor fix to text based Server
Fix to Pretty Print, from Core
Fix to Splitter Nodes not being created
Fix to massive amounts of images loading, from Core
Added 'boot' command to remote admin
Added confirmation window for sent nodes
Minor changes to allow for portability to an OpenSUSE linux OS
Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG
Zoom Mouse plugin added
Images added to Plugin UI
Switching to Element Tree
Map efficiency, from FlexiRPG
Added Status Bar to Update Manager
default_manifest.xml renamed to default_upmana.xml
Cleaner clode for saved repositories
New TrueDebug Class in orpg_log (See documentation for usage)
Mercurial's hgweb folder is ported to upmana
Pretty important update that can help remove thousands of dead children from your
gametree.
Children, <forms />, <group_atts />, <horizontal />, <cols />, <rows />, <height
/>, etc... are all tags now. Check your gametree and look for dead children!!
New Gametree Recursion method, mapping, and context sensitivity. !Infinite Loops
return error instead of freezing the software!
New Syntax added for custom PC sheets
Tip of the Day added, from Core and community
Fixed Whiteboard ID to prevent random line or text deleting. Modified ID's to
prevent non updated clients from ruining the fix.
author | sirebral |
---|---|
date | Wed, 25 Nov 2009 06:16:35 -0600 |
parents | e842a5f1b775 |
children | d263c8ff4d7c |
comparison
equal
deleted
inserted
replaced
150:6c5f46a5924b | 152:6081bdc2b8d5 |
---|---|
119 else: return '' | 119 else: return '' |
120 | 120 |
121 def takedom(self, xml_dom): | 121 def takedom(self, xml_dom): |
122 self.text_string = xml_dom.getAttribute("text_string") | 122 self.text_string = xml_dom.getAttribute("text_string") |
123 self.id = xml_dom.getAttribute("id") | 123 self.id = xml_dom.getAttribute("id") |
124 if xml_dom.hasAttribute("posy"): | 124 if xml_dom.hasAttribute("posy"): self.posy = int(xml_dom.getAttribute("posy")) |
125 self.posy = int(xml_dom.getAttribute("posy")) | 125 if xml_dom.hasAttribute("posx"): self.posx = int(xml_dom.getAttribute("posx")) |
126 if xml_dom.hasAttribute("posx"): | |
127 self.posx = int(xml_dom.getAttribute("posx")) | |
128 if xml_dom.hasAttribute("weight"): | 126 if xml_dom.hasAttribute("weight"): |
129 self.weight = int(xml_dom.getAttribute("weight")) | 127 self.weight = int(xml_dom.getAttribute("weight")) |
130 self.font.SetWeight(self.weight) | 128 self.font.SetWeight(self.weight) |
131 if xml_dom.hasAttribute("style"): | 129 if xml_dom.hasAttribute("style"): |
132 self.style = int(xml_dom.getAttribute("style")) | 130 self.style = int(xml_dom.getAttribute("style")) |
173 coords = self.line_string.split(";") | 171 coords = self.line_string.split(";") |
174 stcords = coords[0].split(",") | 172 stcords = coords[0].split(",") |
175 oldicords = (int(stcords[0]),int(stcords[1])) | 173 oldicords = (int(stcords[0]),int(stcords[1])) |
176 for coordinate_string_counter in range(1, len(coords)): | 174 for coordinate_string_counter in range(1, len(coords)): |
177 stcords = coords[coordinate_string_counter].split(",") | 175 stcords = coords[coordinate_string_counter].split(",") |
178 if stcords[0] == "": | 176 if stcords[0] == "": return False |
179 return False | |
180 icords = (int(stcords[0]),int(stcords[1])) | 177 icords = (int(stcords[0]),int(stcords[1])) |
181 if orpg.mapper.map_utils.proximity_test(oldicords,icords,pt,12): | 178 if orpg.mapper.map_utils.proximity_test(oldicords,icords,pt,12): return True |
182 return True | |
183 oldicords = icords | 179 oldicords = icords |
184 return False | 180 return False |
185 | 181 |
186 def draw(self, parent, dc, op=wx.COPY): | 182 def draw(self, parent, dc, op=wx.COPY): |
187 self.scale = parent.canvas.layers['grid'].mapscale | 183 self.scale = parent.canvas.layers['grid'].mapscale |
235 return '' | 231 return '' |
236 | 232 |
237 def takedom(self, xml_dom): | 233 def takedom(self, xml_dom): |
238 self.line_string = xml_dom.getAttribute("line_string") | 234 self.line_string = xml_dom.getAttribute("line_string") |
239 self.id = xml_dom.getAttribute("id") | 235 self.id = xml_dom.getAttribute("id") |
240 if xml_dom.hasAttribute("upperleftx"): | 236 if xml_dom.hasAttribute("upperleftx"): self.upperleft.x = int(xml_dom.getAttribute("upperleftx")) |
241 self.upperleft.x = int(xml_dom.getAttribute("upperleftx")) | 237 if xml_dom.hasAttribute("upperlefty"): self.upperleft.y = int(xml_dom.getAttribute("upperlefty")) |
242 if xml_dom.hasAttribute("upperlefty"): | 238 if xml_dom.hasAttribute("lowerrightx"): self.lowerright.x = int(xml_dom.getAttribute("lowerrightx")) |
243 self.upperleft.y = int(xml_dom.getAttribute("upperlefty")) | 239 if xml_dom.hasAttribute("lowerrighty"): self.lowerright.y = int(xml_dom.getAttribute("lowerrighty")) |
244 if xml_dom.hasAttribute("lowerrightx"): | |
245 self.lowerright.x = int(xml_dom.getAttribute("lowerrightx")) | |
246 if xml_dom.hasAttribute("lowerrighty"): | |
247 self.lowerright.y = int(xml_dom.getAttribute("lowerrighty")) | |
248 if xml_dom.hasAttribute("color") and xml_dom.getAttribute("color") != '': | 240 if xml_dom.hasAttribute("color") and xml_dom.getAttribute("color") != '': |
249 self.linecolor = xml_dom.getAttribute("color") | 241 self.linecolor = xml_dom.getAttribute("color") |
250 if self.linecolor == '#0000000': | 242 if self.linecolor == '#0000000': self.linecolor = '#000000' |
251 self.linecolor = '#000000' | 243 if xml_dom.hasAttribute("width"): self.linewidth = int(xml_dom.getAttribute("width")) |
252 if xml_dom.hasAttribute("width"): | |
253 self.linewidth = int(xml_dom.getAttribute("width")) | |
254 | 244 |
255 ##----------------------------- | 245 ##----------------------------- |
256 ## whiteboard layer | 246 ## whiteboard layer |
257 ##----------------------------- | 247 ##----------------------------- |
258 class whiteboard_layer(layer_base): | 248 class whiteboard_layer(layer_base): |
297 self.canvas.Refresh(True) | 287 self.canvas.Refresh(True) |
298 return line | 288 return line |
299 | 289 |
300 def get_line_by_id(self, id): | 290 def get_line_by_id(self, id): |
301 for line in self.lines: | 291 for line in self.lines: |
302 if str(line.id) == str(id): | 292 if str(line.id) == str(id): return line |
303 return line | |
304 return None | 293 return None |
305 | 294 |
306 def get_text_by_id(self, id): | 295 def get_text_by_id(self, id): |
307 for text in self.texts: | 296 for text in self.texts: |
308 if str(text.id) == str(id): | 297 if str(text.id) == str(id): return text |
309 return text | |
310 return None | 298 return None |
311 | 299 |
312 def del_line(self, line): | 300 def del_line(self, line): |
313 xml_str = "<map><whiteboard>" | 301 xml_str = "<map><whiteboard>" |
314 xml_str += line.toxml("del") | 302 xml_str += line.toxml("del") |
325 self.removedLines.remove(line) | 313 self.removedLines.remove(line) |
326 self.add_line(line.line_string, line.upperleft, line.lowerright, line.linecolor, line.linewidth) | 314 self.add_line(line.line_string, line.upperleft, line.lowerright, line.linecolor, line.linewidth) |
327 self.canvas.Refresh(True) | 315 self.canvas.Refresh(True) |
328 | 316 |
329 def del_all_lines(self): | 317 def del_all_lines(self): |
330 for i in xrange(len(self.lines)): | 318 for i in xrange(len(self.lines)): self.del_line(self.lines[0]) |
331 self.del_line(self.lines[0]) | |
332 print self.lines | |
333 | 319 |
334 def del_text(self, text): | 320 def del_text(self, text): |
335 xml_str = "<map><whiteboard>" | 321 xml_str = "<map><whiteboard>" |
336 xml_str += text.toxml("del") | 322 xml_str += text.toxml("del") |
337 xml_str += "</whiteboard></map>" | 323 xml_str += "</whiteboard></map>" |
338 self.canvas.frame.session.send(xml_str) | 324 self.canvas.frame.session.send(xml_str) |
339 if text: | 325 if text: self.texts.remove(text) |
340 self.texts.remove(text) | |
341 self.canvas.Refresh(True) | 326 self.canvas.Refresh(True) |
342 | 327 |
343 def layerDraw(self, dc): | 328 def layerDraw(self, dc): |
344 for m in self.lines: m.draw(self, dc) | 329 for m in self.lines: m.draw(self, dc) |
345 for m in self.texts: m.draw(self,dc) | 330 for m in self.texts: m.draw(self,dc) |
346 | 331 |
347 def hit_test_text(self, pos, dc): | 332 def hit_test_text(self, pos, dc): |
348 list_of_texts_matching = [] | 333 list_of_texts_matching = [] |
349 if self.canvas.layers['fog'].use_fog == 1: | 334 if self.canvas.layers['fog'].use_fog == 1: |
350 if self.canvas.frame.session.role != "GM": | 335 if self.canvas.frame.session.role != "GM": return list_of_texts_matching |
351 return list_of_texts_matching | |
352 for m in self.texts: | 336 for m in self.texts: |
353 if m.hit_test(pos,dc): list_of_texts_matching.append(m) | 337 if m.hit_test(pos,dc): list_of_texts_matching.append(m) |
354 return list_of_texts_matching | 338 return list_of_texts_matching |
355 | 339 |
356 def hit_test_lines(self, pos, dc): | 340 def hit_test_lines(self, pos, dc): |
357 list_of_lines_matching = [] | 341 list_of_lines_matching = [] |
358 if self.canvas.layers['fog'].use_fog == 1: | 342 if self.canvas.layers['fog'].use_fog == 1: |
359 if self.canvas.frame.session.role != "GM": | 343 if self.canvas.frame.session.role != "GM": return list_of_lines_matching |
360 return list_of_lines_matching | |
361 for m in self.lines: | 344 for m in self.lines: |
362 if m.hit_test(pos): list_of_lines_matching.append(m) | 345 if m.hit_test(pos): list_of_lines_matching.append(m) |
363 return list_of_lines_matching | 346 return list_of_lines_matching |
364 | 347 |
365 def find_line(self, pt): | 348 def find_line(self, pt): |
366 scale = self.canvas.layers['grid'].mapscale | 349 scale = self.canvas.layers['grid'].mapscale |
367 dc = wx.ClientDC( self.canvas ) | 350 dc = wx.ClientDC( self.canvas ) |
368 self.canvas.PrepareDC( dc ) | 351 self.canvas.PrepareDC( dc ) |
369 dc.SetUserScale(scale,scale) | 352 dc.SetUserScale(scale,scale) |
370 line_list = self.hit_test_lines(pt,dc) | 353 line_list = self.hit_test_lines(pt,dc) |
371 if line_list: | 354 if line_list: return line_list[0] |
372 return line_list[0] | 355 else: return None |
373 else: | |
374 return None | |
375 | 356 |
376 def setcolor(self, color): | 357 def setcolor(self, color): |
377 r,g,b = color.Get() | 358 r,g,b = color.Get() |
378 self.color = self.r_h.hexstring(r,g,b) | 359 self.color = self.r_h.hexstring(r,g,b) |
379 | 360 |
410 for m in range(len(pointArray)-1): | 391 for m in range(len(pointArray)-1): |
411 x = pointArray[m] | 392 x = pointArray[m] |
412 points = x.split(",") | 393 points = x.split(",") |
413 x1 = int(points[0]) | 394 x1 = int(points[0]) |
414 y1 = int(points[1]) | 395 y1 = int(points[1]) |
415 if x2 != -999: | 396 if x2 != -999: dc.DrawLine(x2,y2,x1,y1) |
416 dc.DrawLine(x2,y2,x1,y1) | |
417 x2 = x1 | 397 x2 = x1 |
418 y2 = y1 | 398 y2 = y1 |
419 dc.SetPen(wx.NullPen) | 399 dc.SetPen(wx.NullPen) |
420 dc.SetBrush(wx.NullBrush) | 400 dc.SetBrush(wx.NullBrush) |
421 | 401 |
422 def layerToXML(self, action="update"): | 402 def layerToXML(self, action="update"): |
423 """ format """ | 403 """ format """ |
424 white_string = "" | 404 white_string = "" |
425 if self.lines: | 405 if self.lines: |
426 for l in self.lines: white_string += l.toxml(action) | 406 for l in self.lines: white_string += l.toxml(action) |
427 if self.texts: | 407 if self.texts: |
428 for l in self.texts: white_string += l.toxml(action) | 408 for l in self.texts: white_string += l.toxml(action) |
429 if len(white_string): | 409 if len(white_string): |
430 s = "<whiteboard" | 410 s = "<whiteboard" |
431 s += " serial='" + str(self.serial_number) + "'" | 411 s += " serial='" + str(self.serial_number) + "'" |
432 s += ">" | 412 s += ">" |
433 s += white_string | 413 s += white_string |
434 s += "</whiteboard>" | 414 s += "</whiteboard>" |
435 return s | 415 return s |
436 else: | 416 else: return "" |
437 return "" | |
438 | 417 |
439 def layerTakeDOM(self, xml_dom): | 418 def layerTakeDOM(self, xml_dom): |
440 serial_number = xml_dom.getAttribute('serial') | 419 serial_number = xml_dom.getAttribute('serial') |
441 if serial_number != "": self.serial_number = int(serial_number) | 420 if serial_number != "": self.serial_number = int(serial_number) |
442 children = xml_dom._get_childNodes() | 421 children = xml_dom._get_childNodes() |
483 posx = l.getAttribute('posx') | 462 posx = l.getAttribute('posx') |
484 posy = l.getAttribute('posy') | 463 posy = l.getAttribute('posy') |
485 pos = wx.Point(0,0) | 464 pos = wx.Point(0,0) |
486 pos.x = int(posx) | 465 pos.x = int(posx) |
487 pos.y = int(posy) | 466 pos.y = int(posy) |
488 except: | 467 except: continue |
489 continue | |
490 text = WhiteboardText(id, text_string, pos, style, pointsize, weight, color) | 468 text = WhiteboardText(id, text_string, pos, style, pointsize, weight, color) |
491 self.texts.append(text) | 469 self.texts.append(text) |
492 else: | 470 else: |
493 if nodename == "line": | 471 if nodename == "line": |
494 line = self.get_line_by_id(id) | 472 line = self.get_line_by_id(id) |