annotate plugins/xxbcg.py @ 166:eef2463cd441 alpha

Traipse Alpha 'OpenRPG' {091203-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 (Keeping up with Beta) New Features: Added Bookmarks 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 New TrueDebug Class in orpg_log (See documentation for usage) Portable Mercurial Tip of the Day added, from Core and community New Reference Syntax added for custom PC sheets New Child Reference for gametree New Gametree Recursion method, mapping, context sensitivity, and effeciency.. New Features node with bonus nodes and Node Referencing help added Added 7th Sea die roller method; ie [7k3] = [7d10.takeHighest(3).open(10)] New 'Mythos' System die roller added Added new vs. die roller method for WoD; ie [3v3] = [3d10.vs(3)]. Includes support for Mythos roller. Fixes: Fix to Text based Server Fix to Remote Admin Commands Fix to Pretty Print, from Core Fix to Splitter Nodes not being created Fix to massive amounts of images loading, from Core Fix to Map from gametree not showing to all clients Fix to gametree about menus Fix to Password Manager check on startup Fix to PC Sheets from tool nodes. They now use the tabber_panel Fixed Whiteboard ID to prevent random line or text deleting. Modified ID's to prevent non updated clients from ruining the fix. default_manifest.xml renamed to default_upmana.xml Fix to Update Manager; cleaner clode for saved repositories Fixes made to Settings Panel and no reactive settings when Ok is pressed.
author sirebral
date Thu, 03 Dec 2009 00:50:44 -0600
parents 2f2bebe9c77f
children
rev   line source
105
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
1 import os
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
2 import sys
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
3 import orpg.pluginhandler
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
4 from orpg.mapper.map import *
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
5 from orpg.orpgCore import component
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
6 import wx
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
7
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
8 from orpg.mapper.images import ImageHandler
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
9 from orpg.mapper.whiteboard_handler import *
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
10 from orpg.mapper.background_handler import *
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
11 from orpg.mapper.grid_handler import *
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
12 from orpg.mapper.map_handler import *
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
13 from orpg.mapper.fog_handler import *
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
14
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
15 from bcg.token_handler import *
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
16 from bcg.tokens import *
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
17
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
18
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
19 class Plugin(orpg.pluginhandler.PluginHandler):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
20 # Initialization subroutine.
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
21 #
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
22 # !self : instance of self
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
23 # !openrpg : instance of the the base openrpg control
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
24 def __init__(self, plugindb, parent):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
25 orpg.pluginhandler.PluginHandler.__init__(self, plugindb, parent)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
26
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
27 # The Following code should be edited to contain the proper information
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
28 self.name = 'Board / Card Game'
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
29 self.author = 'Tyler Starke (Prof. Ebral)'
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
30 self.help = 'Start Here'
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
31 self.parent = parent
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
32 #You can set variables below here. Always set them to a blank value in this section. Use plugin_enabled
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
33 #to set their proper values.
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
34 self.sample_variable = {}
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
35
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
36 self.canvas = component.get('map').canvas ## Obtain MapCanvas
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
37
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
38 def plugin_enabled(self):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
39 tabs = component.get('map_tabs')
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
40 layers = component.get('map_layers')
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
41 map_wnd = component.get('map_wnd')
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
42 pages = tabs.GetPageCount()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
43 self.layers = []
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
44 while pages:
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
45 pages -= 1
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
46 if tabs.GetPageText(pages) != 'Background':
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
47 if tabs.GetPageText(pages) != 'Whiteboard':
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
48 tabs.RemovePage(pages)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
49 #tabs.InsertPage(2, layers[0], 'Tiles') # Removed for testing.
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
50 map_wnd.handlers[6]=(token_handler(tabs, -1, map_wnd.canvas))
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
51 tabs.InsertPage(3, map_wnd.handlers[6], 'Tokens')
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
52
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
53 ## Re Direct MapCanvas OnPaint event.
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
54 self.canvas.Disconnect(-1, -1, wx.wxEVT_PAINT)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
55 self.canvas.Bind(wx.EVT_PAINT, self.on_paint)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
56
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
57 ## Add to MapCanvas proccessImages
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
58 self.canvas.Bind(wx.EVT_TIMER, self.processImages, self.canvas.image_timer)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
59
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
60 ## Create Token Layer
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
61 self.canvas.layers['token'] = token_layer(self.canvas)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
62 #self.canvas.layers['tiles'] = tile_layer(self.canvas) #Not ready.
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
63
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
64 ### Define Grid / Background
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
65 self.canvas.layers['grid'].snap = False
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
66 self.canvas.layers['grid'].line = 0
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
67 #self.canvas.layers['bg'].set_texture(component.get('cherrypy')+'Textures/versa_anigre.jpg')
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
68 pass
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
69
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
70 def processImages(self, evt=None):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
71 self.session = component.get("session")
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
72 if self.session.my_role() == self.session.ROLE_LURKER or (str(self.session.group_id) == '0' and str(self.session.status) == '1'):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
73 cidx = self.canvas.parent.get_tab_index("Tiles")
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
74 self.canvas.parent.tabs.EnableTab(cidx, False)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
75 cidx = self.canvas.parent.get_tab_index("Tokens")
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
76 self.canvas.parent.tabs.EnableTab(cidx, False)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
77 else:
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
78 cidx = self.canvas.parent.get_tab_index("Tiles")
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
79 self.canvas.parent.tabs.EnableTab(cidx, True)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
80 cidx = self.canvas.parent.get_tab_index("Tokens")
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
81 self.canvas.parent.tabs.EnableTab(cidx, True)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
82 if not self.canvas.cacheSizeSet:
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
83 self.canvas.cacheSizeSet = True
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
84 cacheSize = component.get('settings').get_setting("ImageCacheSize")
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
85 if len(cacheSize): self.canvas.cacheSize = int(cacheSize)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
86 else: pass
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
87 if not ImageHandler.Queue.empty():
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
88 (path, image_type, imageId) = ImageHandler.Queue.get()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
89 img = wx.ImageFromMime(path[1], path[2]).ConvertToBitmap()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
90 try:
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
91 # Now, apply the image to the proper object
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
92 if image_type == "miniature":
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
93 min = self.canvas.layers['miniatures'].get_miniature_by_id(imageId)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
94 min.set_bmp(img)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
95 elif image_type == "background" or image_type == "texture":
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
96 self.canvas.layers['bg'].bg_bmp = img
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
97 if image_type == "background": self.canvas.set_size([img.GetWidth(), img.GetHeight()])
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
98 elif image_type == "token":
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
99 min = self.canvas.layers['token'].get_token_by_id(imageId)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
100 min.set_bmp(img)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
101 except: pass
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
102
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
103 def on_paint(self, evt):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
104 if self.canvas.layers.has_key('token') == False: self.canvas.layers['token'] = token_layer(self.canvas)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
105 print 'BCG onpaint'
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
106 scale = self.canvas.layers['grid'].mapscale
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
107 scrollsize = self.canvas.GetScrollPixelsPerUnit()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
108 clientsize = self.canvas.GetClientSize()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
109 topleft1 = self.canvas.GetViewStart()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
110 topleft = [topleft1[0]*scrollsize[0], topleft1[1]*scrollsize[1]]
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
111 if (clientsize[0] > 1) and (clientsize[1] > 1):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
112 dc = wx.MemoryDC()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
113 bmp = wx.EmptyBitmap(clientsize[0]+1, clientsize[1]+1)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
114 dc.SelectObject(bmp)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
115 dc.SetPen(wx.TRANSPARENT_PEN)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
116 dc.SetBrush(wx.Brush(self.canvas.GetBackgroundColour(), wx.SOLID))
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
117 dc.DrawRectangle(0,0,clientsize[0]+1,clientsize[1]+1)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
118 dc.SetDeviceOrigin(-topleft[0], -topleft[1])
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
119 dc.SetUserScale(scale, scale)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
120 self.canvas.layers['bg'].layerDraw(dc, scale, topleft, clientsize)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
121 self.canvas.layers['grid'].layerDraw(dc, [topleft[0]/scale, topleft[1]/scale],
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
122 [clientsize[0]/scale, clientsize[1]/scale])
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
123
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
124
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
125 self.canvas.layers['token'].layerDraw(dc, [topleft[0]/scale, topleft[1]/scale],
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
126 [clientsize[0]/scale, clientsize[1]/scale])
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
127
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
128
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
129 self.canvas.layers['whiteboard'].layerDraw(dc)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
130 self.canvas.layers['fog'].layerDraw(dc, topleft, clientsize)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
131 dc.SetPen(wx.NullPen)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
132 dc.SetBrush(wx.NullBrush)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
133 dc.SelectObject(wx.NullBitmap)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
134 del dc
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
135 wdc = self.canvas.preppaint()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
136 wdc.DrawBitmap(bmp, topleft[0], topleft[1])
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
137 if settings.get_setting("AlwaysShowMapScale") == "1":
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
138 self.canvas.showmapscale(wdc)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
139 try: evt.Skip()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
140 except: pass
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
141
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
142 def plugin_disabled(self):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
143 tabs = component.get('map_tabs')
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
144 map_wnd = component.get('map_wnd')
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
145 pages = tabs.GetPageCount()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
146 while pages:
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
147 pages -= 1
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
148 if tabs.GetPageText(pages) != 'Background':
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
149 if tabs.GetPageText(pages) != 'Whiteboard':
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
150 tabs.RemovePage(pages)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
151 layers = component.get('map_layers')
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
152 tabs.InsertPage(1, layers[1],"Grid")
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
153 tabs.InsertPage(2, layers[2],"Miniatures")
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
154 tabs.InsertPage(4, layers[4],"Fog")
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
155 tabs.InsertPage(5, layers[5],"General")
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
156 map_wnd.current_layer = 2
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
157 map_wnd.tabs.SetSelection(map_wnd.current_layer)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
158
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
159 ## Re Connect original MapCanvas OnPaint event.
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
160 self.canvas.Disconnect(-1, -1, wx.wxEVT_PAINT)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
161 self.canvas.Bind(wx.EVT_PAINT, self.canvas.on_paint)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
162
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
163 ## Disconnect new proccessImages addition
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
164 self.canvas.Disconnect(-1, -1, wx.wxEVT_TIMER)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
165 self.canvas.Bind(wx.EVT_TIMER, self.canvas.processImages, self.canvas.image_timer)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
166
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
167 self.canvas.layers['grid'].snap = True
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
168 self.canvas.layers['grid'].line = 1
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
169
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
170 #Here you need to remove any commands you added, and anything else you want to happen when you disable the plugin
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
171 #such as closing windows created by the plugin
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
172 #self.plugin_removecmd('/test')
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
173 #self.plugin_removecmd('/example')
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
174
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
175 #This is the command to delete a message handler
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
176 #self.plugin_delete_msg_handler('xxblank')
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
177
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
178 #This is how you should destroy a frame when the plugin is disabled
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
179 #This same method should be used in close_module as well
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
180 try:
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
181 self.frame.Destroy()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
182 except:
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
183 pass
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
184
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
185 def on_test(self, cmdargs):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
186 #this is just an example function for a command you create.
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
187 # cmdargs contains everything you typed after the command
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
188 # so if you typed /test this is a test, cmdargs = this is a test
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
189 # args are the individual arguments split. For the above example
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
190 # args[0] = this , args[1] = is , args[2] = a , args[3] = test
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
191 self.plugin_send_msg(cmdargs, '<xxblank>' + cmdargs + '</xxblank>')
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
192 args = cmdargs.split(None,-1)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
193 msg = 'cmdargs = %s' % (cmdargs)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
194 self.chat.InfoPost(msg)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
195
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
196 if len(args) == 0:
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
197 self.chat.InfoPost("You have no args")
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
198 else:
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
199 i = 0
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
200 for n in args:
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
201 msg = 'args[' + str(i) + '] = ' + n
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
202 self.chat.InfoPost(msg)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
203 i += 1
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
204
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
205 def on_xml_recive(self,id, data,xml_dom):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
206 self.chat.InfoPost(self.name + ":: Message recived<br />" + data.replace("<","&lt;").replace(">","&gt;") +'<br />From id:' + str(id))
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
207
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
208 def pre_parse(self, text):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
209 #This is called just before a message is parsed by openrpg
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
210 return text
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
211
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
212 def send_msg(self, text, send):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
213 #This is called when a message is about to be sent out.
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
214 #It covers all messages sent by the user, before they have been formatted.
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
215 #If send is set to 0, the message will not be sent out to other
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
216 #users, but it will still be posted to the user's chat normally.
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
217 #Otherwise, send defaults to 1. (The message is sent as normal)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
218 return text, send
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
219
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
220 def plugin_incoming_msg(self, text, type, name, player):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
221 #This is called whenever a message from someone else is received, no matter
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
222 #what type of message it is.
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
223 #The text variable is the text of the message. If the type is a regular
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
224 #message, it is already formatted. Otherwise, it's not.
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
225 #The type variable is an integer which tells you the type: 1=chat, 2=whisper
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
226 #3=emote, 4=info, and 5=system.
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
227 #The name variable is the name of the player who sent you the message.
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
228 #The player variable contains lots of info about the player sending the
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
229 #message, including name, ID#, and currently-set role.
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
230 #Uncomment the following line to see the format for the player variable.
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
231 #print player
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
232 return text, type, name
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
233
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
234 def post_msg(self, text, myself):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
235 #This is called whenever a message from anyone is about to be posted
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
236 #to chat; it doesn't affect the copy of the message that gets sent to others
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
237 #Be careful; system and info messages trigger this too.
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
238 return text
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
239
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
240 def refresh_counter(self):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
241 #This is called once per second. That's all you need to know.
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
242 pass