comparison orpg/main.py @ 28:ff154cf3350c ornery-orc

Traipse 'OpenRPG' {100203-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 (Stable) New Features: New Bookmarks Feature New 'boot' command to remote admin New confirmation window for sent nodes Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG New Zoom Mouse plugin added New Images added to Plugin UI Switching to Element Tree New Map efficiency, from FlexiRPG New Status Bar to Update Manager New TrueDebug Class in orpg_log (See documentation for usage) New Portable Mercurial New Tip of the Day, from Core and community New Reference Syntax added for custom PC sheets New Child Reference for gametree New Parent Reference for gametree New Gametree Recursion method, mapping, context sensitivity, and effeciency.. New Features node with bonus nodes and Node Referencing help added New Dieroller structure from Core New DieRoller portability for odd Dice New 7th Sea die roller; ie [7k3] = [7d10.takeHighest(3).open(10)] New 'Mythos' System die roller added New vs. die roller method for WoD; ie [3v3] = [3d10.vs(3)]. Included for Mythos roller also New Warhammer FRPG Die Roller (Special thanks to Puu-san for the support) New EZ_Tree Reference system. Push a button, Traipse the tree, get a reference (Beta!) New Grids act more like Spreadsheets in Use mode, with Auto Calc Fixes: Fix to allow for portability to an OpenSUSE linux OS Fix to mplay_client for Fedora and OpenSUSE 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 Fix to Whiteboard ID to prevent random line or text deleting. Fixes to Server, Remote Server, and Server GUI Fix to Update Manager; cleaner clode for saved repositories Fixes made to Settings Panel and now reactive settings when Ok is pressed Fixes to Alternity roller's attack roll. Uses a simple Tuple instead of a Splice Fix to Use panel of Forms and Tabbers. Now longer enters design mode Fix made Image Fetching. New fetching image and new failed image Fix to whiteboard ID's to prevent non updated clients from ruining the fix. default_manifest.xml renamed to default_upmana.xml
author sirebral
date Wed, 03 Feb 2010 22:16:49 -0600
parents 51428d30c59e
children fc48380f0c9f
comparison
equal deleted inserted replaced
27:51428d30c59e 28:ff154cf3350c
19 # -- 19 # --
20 # 20 #
21 # File: main.py 21 # File: main.py
22 # Author: Chris Davis 22 # Author: Chris Davis
23 # Maintainer: 23 # Maintainer:
24 # Version: 24 # Version: Traipse 'Ornery-Orc'
25 # $Id: main.py,v 1.153 2008/01/24 03:52:03 digitalxero Exp $ 25 # $Id: main.py,v Traipse 'Ornery-Orc' prof.ebral Exp $
26 # 26 #
27 # Description: This is the main entry point of the oprg application 27 # Description: This is the main entry point of the oprg application
28 # 28 #
29 29
30 __version__ = "$Id: main.py,v 1.154 2009/07/19 03:52:03 madmathlabs Exp $" 30 __version__ = "$Id: main.py,v Traipse 'Ornery-Orc' prof.ebral Exp $"
31 31
32 from orpg.orpg_wx import * 32 from orpg.orpg_wx import *
33 from orpg.orpgCore import * 33 from orpg.orpgCore import *
34 from orpg_version import * 34 from orpg_version import *
35 from orpg.orpg_windows import * 35 from orpg.orpg_windows import *
36 36
37 import wx.py 37 import wx.py
38 from orpg import minidom 38
39 import orpg.player_list 39 import orpg.player_list
40 import orpg.tools.pluginui as pluginUI 40 import orpg.tools.pluginui as pluginUI
41 import orpg.tools.aliaslib 41 import orpg.tools.aliaslib
42 import orpg.tools.toolBars 42 import orpg.tools.toolBars
43 import orpg.tools.orpg_sound 43 import orpg.tools.orpg_sound
47 import orpg.networking.gsclient 47 import orpg.networking.gsclient
48 import orpg.networking.mplay_client 48 import orpg.networking.mplay_client
49 import orpg.mapper.map 49 import orpg.mapper.map
50 import orpg.mapper.images 50 import orpg.mapper.images
51 51
52 import orpg.dieroller.utils
52 import upmana.updatemana 53 import upmana.updatemana
53 import upmana.manifest as manifest 54 from upmana.manifest import manifest
54 55
55 from orpg.dirpath import dir_struct 56 from orpg.dirpath import dir_struct
56 from orpg.dieroller.utils import DiceManager 57 from orpg.tools.settings import settings
57 from orpg.tools.orpg_settings import settings
58 from orpg.tools.validate import validate 58 from orpg.tools.validate import validate
59 from orpg.tools.passtool import PassTool 59 from orpg.tools.passtool import PassTool
60 from orpg.tools.orpg_log import logger, crash 60 from orpg.tools.orpg_log import logger, crash, debug
61 from orpg.tools.decorators import debugging
62 from orpg.tools.metamenus import MenuBarEx 61 from orpg.tools.metamenus import MenuBarEx
63 62 from orpg.tools.InterParse import Parse
64 #from xml.etree.ElementTree import ElementTree, Element 63
65 #from xml.etree.ElementTree import fromstring, tostring 64 from xml.etree.ElementTree import ElementTree, Element, parse
65 from xml.etree.ElementTree import fromstring, tostring
66 from orpg.orpg_xml import xml #to be replaced by etree 66 from orpg.orpg_xml import xml #to be replaced by etree
67 67
68 68
69 #################################### 69 ####################################
70 ## Main Frame 70 ## Main Frame
71 #################################### 71 ####################################
72 72
73 73
74 class orpgFrame(wx.Frame): 74 class orpgFrame(wx.Frame):
75 @debugging 75
76 def __init__(self, parent, id, title): 76 def __init__(self, parent, id, title):
77 wx.Frame.__init__(self, parent, id, title, wx.Point(100, 100), wx.Size(600,420), style=wx.DEFAULT_FRAME_STYLE) 77 wx.Frame.__init__(self, parent, id, title, wx.Point(100, 100), wx.Size(600,420), style=wx.DEFAULT_FRAME_STYLE)
78 self.validate = component.get("validate") 78 self.validate = component.get("validate")
79 logger.debug("Enter orpgFrame") 79 logger.debug("Enter orpgFrame")
80 self.rgb = orpg.tools.rgbhex.RGBHex() 80 self.rgb = orpg.tools.rgbhex.RGBHex()
92 "on_group_event":self.on_group_event, 92 "on_group_event":self.on_group_event,
93 "on_player_event":self.on_player_event, 93 "on_player_event":self.on_player_event,
94 "on_status_event":self.on_status_event, 94 "on_status_event":self.on_status_event,
95 "on_password_signal":self.on_password_signal, 95 "on_password_signal":self.on_password_signal,
96 "orpgFrame":self} 96 "orpgFrame":self}
97 self.settings = component.get('settings') #Arbitrary until settings updated with Core. 97 self.session = orpg.networking.mplay_client.mplay_client(settings.get("player"), call_backs)
98 self.session = orpg.networking.mplay_client.mplay_client(self.settings.get_setting("player"), call_backs) 98 component.add("session", self.session)
99 self.poll_timer = wx.Timer(self, wx.NewId()) 99 self.poll_timer = wx.Timer(self, wx.NewId())
100 self.Bind(wx.EVT_TIMER, self.session.poll, self.poll_timer) 100 self.Bind(wx.EVT_TIMER, self.session.poll, self.poll_timer)
101 self.poll_timer.Start(100) 101 self.poll_timer.Start(100)
102 self.ping_timer = wx.Timer(self, wx.NewId()) 102 self.ping_timer = wx.Timer(self, wx.NewId())
103 self.Bind(wx.EVT_TIMER, self.session.update, self.ping_timer) 103 self.Bind(wx.EVT_TIMER, self.session.update, self.ping_timer)
104 104
105 # create roller manager 105 # create roller manager
106 self.DiceManager = DiceManager(settings.get_setting("dieroller")) 106 self.DiceManager = orpg.dieroller.utils.roller_manager()
107 self.DiceManager.setRoller(settings.get("dieroller"))
107 component.add('DiceManager', self.DiceManager) 108 component.add('DiceManager', self.DiceManager)
108 109
109 #create password manager --SD 8/03 110 #create password manager --SD 8/03
110 self.password_manager = component.get('password_manager') 111 self.password_manager = component.get('password_manager')
111 component.add("session", self.session) 112
113 # build frame windows
112 component.add('frame', self) 114 component.add('frame', self)
113
114 # build frame windows
115 self.build_menu() 115 self.build_menu()
116 self.build_gui() 116 self.build_gui()
117 self.build_hotkeys() 117 self.build_hotkeys()
118
119 logger.debug("GUI Built") 118 logger.debug("GUI Built")
120 component.add("chat",self.chat)
121 component.add("map",self.map)
122 component.add("alias", self.aliaslib)
123
124 logger.debug("openrpg components all added") 119 logger.debug("openrpg components all added")
125 self.tree.load_tree(settings.get_setting("gametree")) 120 self.tree.load_tree(settings.get("gametree"))
126 logger.debug("Tree Loaded") 121 logger.debug("Tree Loaded")
127 self.players.size_cols() 122 self.players.size_cols()
128 123
129 #Load the Plugins This has to be after the chat component has been added 124 #Load the Plugins This has to be after the chat component has been added
130 component.add('pluginmenu', self.pluginMenu) 125 component.add('pluginmenu', self.pluginMenu)
131 self.pluginsFrame.Start() 126 self.pluginsFrame.Start()
132 logger.debug("plugins reloaded and startup plugins launched") 127 logger.debug("plugins reloaded and startup plugins launched")
133 self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) 128 self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
134 129
130 tipotday_start = settings.get('tipotday_start')
131 try: tipotday_start = int(tipotday_start)
132 except TypeError: tipotday_start = 0
133
134 self.TipOfTheDay = wx.CreateFileTipProvider(dir_struct['data']+'tips.txt', tipotday_start)
135 #Load Update Manager 135 #Load Update Manager
136 component.add('updatemana', self.updateMana) 136 component.add('updatemana', self.updateMana)
137 logger.debug("update manager reloaded") 137 logger.debug("update manager reloaded")
138 self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) 138 self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
139 139
140 #Load Update Manager 140 #Load Debug Console
141 component.add('debugconsole', self.debugger) 141 component.add('debugconsole', self.debugger)
142 logger.debug("debugger window") 142 logger.debug("debugger window")
143 self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) 143 self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
144 144
145 @debugging 145 def ShowTipOfTheDay(self):
146 if wx.ShowTip(self, self.TipOfTheDay, settings.get('tipotday_enabled') != '0'):
147 settings.change('tipotday_enabled', '1')
148 else: settings.change('tipotday_enabled', '0')
149 settings.change('tipotday_start', str(self.TipOfTheDay.CurrentTip))
150
146 def post_show_init(self): 151 def post_show_init(self):
147 """Some Actions need to be done after the main fram is drawn""" 152 """Some Actions need to be done after the main frame is drawn"""
148 self.players.size_cols() 153 self.players.size_cols()
149 154 try:
150 @debugging 155 if settings.get('tipotday_enabled').lower() != '0': self.ShowTipOfTheDay()
156 except: self.add_setting('Tip of the Day')
157
158 def add_setting(self, setting):
159 if setting == 'Tip of the Day':
160 settings.add_tab('General', 'Tip of the Day', 'grid')
161 settings.add('Tip of the Day', 'tipotday_start', '0', 'int', 'Current Tip of the Day')
162 settings.add('Tip of the Day', 'tipotday_enabled', '1', '0|1', 'Show Tip of the Day on startup')
163 logger.info('New Settings added', True)
164 self.TraipseSuiteWarn('debug')
165
151 def get_activeplugins(self): 166 def get_activeplugins(self):
152 try: tmp = self.pluginsFrame.get_activeplugins() 167 try: tmp = self.pluginsFrame.get_activeplugins()
153 except: tmp = {} 168 except: tmp = {}
154 return tmp 169 return tmp
155 170
156 @debugging
157 def get_startplugins(self): 171 def get_startplugins(self):
158 try: tmp = self.pluginsFrame.get_startplugins() 172 try: tmp = self.pluginsFrame.get_startplugins()
159 except: tmp = {} 173 except: tmp = {}
160 return tmp 174 return tmp
161 175
162 @debugging
163 def on_password_signal(self,signal,type,id,data): 176 def on_password_signal(self,signal,type,id,data):
164 try: 177 try:
165 msg = ["DEBUG: password response= ", 178 msg = ["DEBUG: password response= ",
166 str(signal), 179 str(signal),
167 " (T:", 180 " (T:",
179 elif type == "admin": self.password_manager.ClearPassword("admin", int(id)) 192 elif type == "admin": self.password_manager.ClearPassword("admin", int(id))
180 elif type == "room": self.password_manager.ClearPassword("room", int(id)) 193 elif type == "room": self.password_manager.ClearPassword("room", int(id))
181 else: pass 194 else: pass
182 except: traceback.print_exc() 195 except: traceback.print_exc()
183 196
184 @debugging
185 def build_menu(self): 197 def build_menu(self):
186 menu = \ 198 menu = \
187 [[ 199 [[
188 ['&OpenRPG'], 200 ['&OpenRPG'],
189 [' &Settings\tCtrl-S'], 201 [' &Settings\tCtrl-S'],
228 [ 240 [
229 ['&Help'], 241 ['&Help'],
230 [' &About'], 242 [' &About'],
231 [' Online User Guide'], 243 [' Online User Guide'],
232 [' Change Log'], 244 [' Change Log'],
233 [' Report a Bug'] 245 [' Report a Bug'],
246 [' Tip of the Day']
234 ]] 247 ]]
235 248
236 self.mainmenu = MenuBarEx(self, menu) 249 self.mainmenu = MenuBarEx(self, menu)
237 if settings.get_setting('Heartbeat') == '1': 250 if settings.get('Heartbeat') == '1':
238 self.mainmenu.SetMenuState("GameServerServerHeartbeat", True) 251 self.mainmenu.SetMenuState("GameServerServerHeartbeat", True)
239 252
240 tabtheme = settings.get_setting('TabTheme') #This change is stable. TaS. 253 self.mainmenu.SetMenuState('ToolsPasswordManager', True if settings.get('PWMannager') == 'On' else False)
254 tabtheme = settings.get('TabTheme') #This change is stable. TaS.
241 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedColorful", tabtheme == 'slanted&colorful') 255 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedColorful", tabtheme == 'slanted&colorful')
242 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedBlackandWhite", tabtheme == 'slanted&bw') 256 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedBlackandWhite", tabtheme == 'slanted&bw')
243 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedAqua", tabtheme == 'slanted&aqua') 257 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedAqua", tabtheme == 'slanted&aqua')
244 self.mainmenu.SetMenuState("OpenRPGTabStylesFlatBlackandWhite", tabtheme == 'flat&bw') 258 self.mainmenu.SetMenuState("OpenRPGTabStylesFlatBlackandWhite", tabtheme == 'flat&bw')
245 self.mainmenu.SetMenuState("OpenRPGTabStylesFlatAqua", tabtheme == 'flat&aqua') 259 self.mainmenu.SetMenuState("OpenRPGTabStylesFlatAqua", tabtheme == 'flat&aqua')
246 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedCustom", tabtheme == 'customslant') 260 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedCustom", tabtheme == 'customslant')
247 self.mainmenu.SetMenuState("OpenRPGTabStylesFlatCustom", tabtheme == 'customflat') 261 self.mainmenu.SetMenuState("OpenRPGTabStylesFlatCustom", tabtheme == 'customflat')
248 262
249 lvl = int(settings.get_setting('LoggingLevel')) 263 lvl = int(settings.get('LoggingLevel'))
250 if lvl & ORPG_DEBUG: self.mainmenu.SetMenuState("ToolsLoggingLevelDebug", True) 264 if lvl & ORPG_DEBUG: self.mainmenu.SetMenuState("ToolsLoggingLevelDebug", True)
251 if lvl & ORPG_DEBUG: self.mainmenu.SetMenuState("ToolsLoggingLevelNote", True) 265 if lvl & ORPG_DEBUG: self.mainmenu.SetMenuState("ToolsLoggingLevelNote", True)
252 if lvl & ORPG_INFO: self.mainmenu.SetMenuState("ToolsLoggingLevelInfo", True) 266 if lvl & ORPG_INFO: self.mainmenu.SetMenuState("ToolsLoggingLevelInfo", True)
253 if lvl & ORPG_GENERAL: self.mainmenu.SetMenuState("ToolsLoggingLevelGeneral", True) 267 if lvl & ORPG_GENERAL: self.mainmenu.SetMenuState("ToolsLoggingLevelGeneral", True)
254 268
262 276
263 # Traipse Suite of Additions. 277 # Traipse Suite of Additions.
264 self.traipseSuite = wx.Menu() 278 self.traipseSuite = wx.Menu()
265 self.mainmenu.Insert(5, self.traipseSuite, "&Traipse Suite") 279 self.mainmenu.Insert(5, self.traipseSuite, "&Traipse Suite")
266 280
281 #Update Manager
267 mana = wx.MenuItem(self.traipseSuite, wx.ID_ANY, "Update Manager", "Update Manager") 282 mana = wx.MenuItem(self.traipseSuite, wx.ID_ANY, "Update Manager", "Update Manager")
268 self.Bind(wx.EVT_MENU, self.OnMB_UpdateManagerPanel, mana) 283 self.Bind(wx.EVT_MENU, self.OnMB_UpdateManagerPanel, mana)
269 self.traipseSuite.AppendItem(mana) 284 self.traipseSuite.AppendItem(mana)
270 285
271 self.debugConsole = wx.MenuItem(self.traipseSuite, -1, "Debug Console", "Debug Console") 286 self.debugConsole = wx.MenuItem(self.traipseSuite, -1, "Debug Console", "Debug Console")
272 self.Bind(wx.EVT_MENU, self.OnMB_DebugConsole, self.debugConsole) 287 self.Bind(wx.EVT_MENU, self.OnMB_DebugConsole, self.debugConsole)
273 self.traipseSuite.AppendItem(self.debugConsole) 288 self.traipseSuite.AppendItem(self.debugConsole)
274 289
275 def TraipseSuiteWarn(self, menuitem): 290 def TraipseSuiteWarn(self, menuitem):
276 ### Beta ### Allows for the reuse of the 'Attention' menu. 291 ### Allows for the reuse of the 'Attention' menu.
277 ### component.get('frame').TraipseSuiteWarn('item') ### Portable 292 ### component.get('frame').TraipseSuiteWarn('item') ### Portable
278 self.mainmenu.Replace(8, self.traipseSuite, '&Traipse Suite!') 293 self.mainmenu.Remove(8)
294 self.mainmenu.Insert(8, self.traipseSuite, "&Traipse Suite!")
279 if menuitem == 'debug': 295 if menuitem == 'debug':
280 if self.debugger.IsShown() == True: 296 if self.debugger.IsShown() == True:
281 self.mainmenu.Replace(8, self.traipseSuite, '&Traipse Suite') 297 self.mainmenu.Remove(8)
298 self.mainmenu.Insert(8, self.traipseSuite, "&Traipse Suite")
282 else: 299 else:
283 self.debugConsole.SetBitmap(wx.Bitmap(dir_struct["icon"] + 'spotlight.png')) 300 self.debugConsole.SetBitmap(wx.Bitmap(dir_struct["icon"] + 'spotlight.png'))
284 self.traipseSuite.RemoveItem(self.debugConsole) 301 self.traipseSuite.RemoveItem(self.debugConsole)
285 self.traipseSuite.AppendItem(self.debugConsole) 302 self.traipseSuite.AppendItem(self.debugConsole)
286 303
287 def TraipseSuiteWarnCleanup(self, menuitem): 304 def TraipseSuiteWarnCleanup(self, menuitem):
288 ### Beta ### Allows for portable cleanup of the 'Attention' menu. 305 ### Allows for portable cleanup of the 'Attention' menu.
289 ### component.get('frame').TraipseSuiteWarnCleanup('item') ### Portable 306 ### component.get('frame').TraipseSuiteWarnCleanup('item') ### Portable
290 self.mainmenu.Replace(8, self.traipseSuite, '&Traipse Suite') 307 self.mainmenu.Remove(8)
308 self.mainmenu.Insert(8, self.traipseSuite, "&Traipse Suite")
291 if menuitem == 'debug': 309 if menuitem == 'debug':
292 self.traipseSuite.RemoveItem(self.debugConsole) 310 self.traipseSuite.RemoveItem(self.debugConsole)
293 self.debugConsole.SetBitmap(wx.Bitmap(dir_struct["icon"] + 'clear.gif')) 311 self.debugConsole.SetBitmap(wx.Bitmap(dir_struct["icon"] + 'clear.gif'))
294 self.traipseSuite.AppendItem(self.debugConsole) 312 self.traipseSuite.AppendItem(self.debugConsole)
295 313
296 314
297 ################################# 315 #################################
298 ## All Menu Events 316 ## All Menu Events
299 ################################# 317 #################################
300 #Tab Styles Menus 318 #Tab Styles Menus
301 @debugging 319
302 def SetTabStyles(self, *args, **kwargs): 320 def SetTabStyles(self, *args, **kwargs):
303 321
304 tabtheme = settings.get_setting('TabTheme') #This change is stable. TaS. 322 tabtheme = settings.get('TabTheme') #This change is stable. TaS.
305 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedColorful", tabtheme == 'slanted&colorful') 323 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedColorful", tabtheme == 'slanted&colorful')
306 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedBlackandWhite", tabtheme == 'slanted&bw') 324 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedBlackandWhite", tabtheme == 'slanted&bw')
307 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedAqua", tabtheme == 'slanted&aqua') 325 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedAqua", tabtheme == 'slanted&aqua')
308 self.mainmenu.SetMenuState("OpenRPGTabStylesFlatBlackandWhite", tabtheme == 'flat&bw') 326 self.mainmenu.SetMenuState("OpenRPGTabStylesFlatBlackandWhite", tabtheme == 'flat&bw')
309 self.mainmenu.SetMenuState("OpenRPGTabStylesFlatAqua", tabtheme == 'flat&aqua') 327 self.mainmenu.SetMenuState("OpenRPGTabStylesFlatAqua", tabtheme == 'flat&aqua')
334 except: pass 352 except: pass
335 tabbedwindows = new 353 tabbedwindows = new
336 component.add("tabbedWindows", tabbedwindows) 354 component.add("tabbedWindows", tabbedwindows)
337 355
338 #Run though the new list and set the proper styles 356 #Run though the new list and set the proper styles
339 tabbg = settings.get_setting('TabBackgroundGradient') 357 tabbg = settings.get('TabBackgroundGradient')
340 (red, green, blue) = self.rgb.rgb_tuple(tabbg) 358 (red, green, blue) = self.rgb.rgb_tuple(tabbg)
341 359
342 for wnd in tabbedwindows: 360 for wnd in tabbedwindows:
343 style = wnd.GetWindowStyleFlag() 361 style = wnd.GetWindowStyleFlag()
344 # remove old tabs style 362 # remove old tabs style
350 if graidentTo != None: wnd.SetGradientColourTo(graidentTo) 368 if graidentTo != None: wnd.SetGradientColourTo(graidentTo)
351 if graidentFrom != None: wnd.SetGradientColourFrom(graidentFrom) 369 if graidentFrom != None: wnd.SetGradientColourFrom(graidentFrom)
352 if textColor != None: wnd.SetNonActiveTabTextColour(textColor) 370 if textColor != None: wnd.SetNonActiveTabTextColour(textColor)
353 wnd.Refresh() 371 wnd.Refresh()
354 372
355 @debugging
356 def OnMB_OpenRPGNewMap(self): 373 def OnMB_OpenRPGNewMap(self):
357 pass #Not Implemented yet! 374 pass #Not Implemented yet!
358 375
359 @debugging
360 def OnMB_OpenRPGTabStylesSlantedColorful(self): 376 def OnMB_OpenRPGTabStylesSlantedColorful(self):
361 if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedColorful"): 377 if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedColorful"):
362 settings.set_setting('TabTheme', 'slanted&colorful') 378 settings.change('TabTheme', 'slanted&colorful')
363 self.SetTabStyles("OpenRPGTabStylesSlantedColorful", FNB.FNB_VC8|FNB.FNB_COLORFUL_TABS) 379 self.SetTabStyles("OpenRPGTabStylesSlantedColorful", FNB.FNB_VC8|FNB.FNB_COLORFUL_TABS)
364 else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedColorful", True) 380 else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedColorful", True)
365 381
366 @debugging
367 def OnMB_OpenRPGTabStylesSlantedBlackandWhite(self): 382 def OnMB_OpenRPGTabStylesSlantedBlackandWhite(self):
368 if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedBlackandWhite"): 383 if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedBlackandWhite"):
369 settings.set_setting('TabTheme', 'slanted&bw') 384 settings.change('TabTheme', 'slanted&bw')
370 self.SetTabStyles("OpenRPGTabStylesSlantedBlackandWhite", 385 self.SetTabStyles("OpenRPGTabStylesSlantedBlackandWhite",
371 FNB.FNB_VC8, graidentTo=wx.WHITE, graidentFrom=wx.WHITE, textColor=wx.BLACK) 386 FNB.FNB_VC8, graidentTo=wx.WHITE, graidentFrom=wx.WHITE, textColor=wx.BLACK)
372 else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedBlackandWhite", True) 387 else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedBlackandWhite", True)
373 388
374 @debugging
375 def OnMB_OpenRPGTabStylesSlantedAqua(self): 389 def OnMB_OpenRPGTabStylesSlantedAqua(self):
376 if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedAqua"): 390 if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedAqua"):
377 settings.set_setting('TabTheme', 'slanted&aqua') 391 settings.change('TabTheme', 'slanted&aqua')
378 self.SetTabStyles("OpenRPGTabStylesSlantedAqua", FNB.FNB_VC8, 392 self.SetTabStyles("OpenRPGTabStylesSlantedAqua", FNB.FNB_VC8,
379 graidentTo=wx.Color(0, 128, 255), graidentFrom=wx.WHITE, textColor=wx.BLACK) 393 graidentTo=wx.Color(0, 128, 255), graidentFrom=wx.WHITE, textColor=wx.BLACK)
380 else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedAqua", True) 394 else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedAqua", True)
381 395
382 @debugging
383 def OnMB_OpenRPGTabStylesSlantedCustom(self): 396 def OnMB_OpenRPGTabStylesSlantedCustom(self):
384 if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedCustom"): 397 if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedCustom"):
385 settings.set_setting('TabTheme', 'customslant') 398 settings.change('TabTheme', 'customslant')
386 gfrom = settings.get_setting('TabGradientFrom') 399 gfrom = settings.get('TabGradientFrom')
387 (fred, fgreen, fblue) = self.rgb.rgb_tuple(gfrom) 400 (fred, fgreen, fblue) = self.rgb.rgb_tuple(gfrom)
388 gto = settings.get_setting('TabGradientTo') 401 gto = settings.get('TabGradientTo')
389 (tored, togreen, toblue) = self.rgb.rgb_tuple(gto) 402 (tored, togreen, toblue) = self.rgb.rgb_tuple(gto)
390 tabtext = settings.get_setting('TabTextColor') 403 tabtext = settings.get('TabTextColor')
391 (tred, tgreen, tblue) = self.rgb.rgb_tuple(tabtext) 404 (tred, tgreen, tblue) = self.rgb.rgb_tuple(tabtext)
392 tabbg = settings.get_setting('TabBackgroundGradient') 405 tabbg = settings.get('TabBackgroundGradient')
393 (red, green, blue) = self.rgb.rgb_tuple(tabbg) 406 (red, green, blue) = self.rgb.rgb_tuple(tabbg)
394 self.SetTabStyles("OpenRPGTabStylesSlantedCustom", FNB.FNB_VC8, 407 self.SetTabStyles("OpenRPGTabStylesSlantedCustom", FNB.FNB_VC8,
395 graidentTo=wx.Color(tored, togreen, toblue), graidentFrom=wx.Color(fred, fgreen, fblue), 408 graidentTo=wx.Color(tored, togreen, toblue), graidentFrom=wx.Color(fred, fgreen, fblue),
396 textColor=wx.Color(tred, tgreen, tblue)) 409 textColor=wx.Color(tred, tgreen, tblue))
397 else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedCustom", True) 410 else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedCustom", True)
398 411
399 @debugging
400 def OnMB_OpenRPGTabStylesFlatBlackandWhite(self): 412 def OnMB_OpenRPGTabStylesFlatBlackandWhite(self):
401 if self.mainmenu.GetMenuState("OpenRPGTabStylesFlatBlackandWhite"): 413 if self.mainmenu.GetMenuState("OpenRPGTabStylesFlatBlackandWhite"):
402 settings.set_setting('TabTheme', 'flat&bw') 414 settings.change('TabTheme', 'flat&bw')
403 self.SetTabStyles("OpenRPGTabStylesFlatBlackandWhite", FNB.FNB_FANCY_TABS, 415 self.SetTabStyles("OpenRPGTabStylesFlatBlackandWhite", FNB.FNB_FANCY_TABS,
404 graidentTo=wx.WHITE, graidentFrom=wx.WHITE, textColor=wx.BLACK) 416 graidentTo=wx.WHITE, graidentFrom=wx.WHITE, textColor=wx.BLACK)
405 else: self.mainmenu.SetMenuState("OpenRPGTabStylesFlatBlackandWhite", True) 417 else: self.mainmenu.SetMenuState("OpenRPGTabStylesFlatBlackandWhite", True)
406 418
407 @debugging
408 def OnMB_OpenRPGTabStylesFlatAqua(self): 419 def OnMB_OpenRPGTabStylesFlatAqua(self):
409 if self.mainmenu.GetMenuState("OpenRPGTabStylesFlatAqua"): 420 if self.mainmenu.GetMenuState("OpenRPGTabStylesFlatAqua"):
410 settings.set_setting('TabTheme', 'flat&aqua') 421 settings.change('TabTheme', 'flat&aqua')
411 self.SetTabStyles("OpenRPGTabStylesFlatAqua", FNB.FNB_FANCY_TABS, 422 self.SetTabStyles("OpenRPGTabStylesFlatAqua", FNB.FNB_FANCY_TABS,
412 graidentTo=wx.Color(0, 128, 255), graidentFrom=wx.WHITE, textColor=wx.BLACK) 423 graidentTo=wx.Color(0, 128, 255), graidentFrom=wx.WHITE, textColor=wx.BLACK)
413 else: self.mainmenu.SetMenuState("OpenRPGTabStylesFlatAqua", True) 424 else: self.mainmenu.SetMenuState("OpenRPGTabStylesFlatAqua", True)
414 425
415 @debugging
416 def OnMB_OpenRPGTabStylesFlatCustom(self): 426 def OnMB_OpenRPGTabStylesFlatCustom(self):
417 if self.mainmenu.GetMenuState("OpenRPGTabStylesFlatCustom"): 427 if self.mainmenu.GetMenuState("OpenRPGTabStylesFlatCustom"):
418 settings.set_setting('TabTheme', 'customflat') 428 settings.change('TabTheme', 'customflat')
419 gfrom = settings.get_setting('TabGradientFrom') 429 gfrom = settings.get('TabGradientFrom')
420 (fred, fgreen, fblue) = self.rgb.rgb_tuple(gfrom) 430 (fred, fgreen, fblue) = self.rgb.rgb_tuple(gfrom)
421 gto = settings.get_setting('TabGradientTo') 431 gto = settings.get('TabGradientTo')
422 (tored, togreen, toblue) = self.rgb.rgb_tuple(gto) 432 (tored, togreen, toblue) = self.rgb.rgb_tuple(gto)
423 tabtext = settings.get_setting('TabTextColor') 433 tabtext = settings.get('TabTextColor')
424 (tred, tgreen, tblue) = self.rgb.rgb_tuple(tabtext) 434 (tred, tgreen, tblue) = self.rgb.rgb_tuple(tabtext)
425 tabbg = settings.get_setting('TabBackgroundGradient') 435 tabbg = settings.get('TabBackgroundGradient')
426 (red, green, blue) = self.rgb.rgb_tuple(tabbg) 436 (red, green, blue) = self.rgb.rgb_tuple(tabbg)
427 self.SetTabStyles("OpenRPGTabStylesFlatCustom", FNB.FNB_FANCY_TABS, 437 self.SetTabStyles("OpenRPGTabStylesFlatCustom", FNB.FNB_FANCY_TABS,
428 graidentTo=wx.Color(tored, togreen, toblue), graidentFrom=wx.Color(fred, fgreen, fblue), 438 graidentTo=wx.Color(tored, togreen, toblue), graidentFrom=wx.Color(fred, fgreen, fblue),
429 textColor=wx.Color(tred, tgreen, tblue)) 439 textColor=wx.Color(tred, tgreen, tblue))
430 else: self.mainmenu.SetMenuState("OpenRPGTabStylesFlatCustom", True) 440 else: self.mainmenu.SetMenuState("OpenRPGTabStylesFlatCustom", True)
431 441
432 #Window Menu 442 #Window Menu
433 @debugging
434 def OnMB_WindowsMenu(self, event): 443 def OnMB_WindowsMenu(self, event):
435 menuid = event.GetId() 444 menuid = event.GetId()
436 name = self.mainwindows[menuid] 445 name = self.mainwindows[menuid]
437 if name == 'Alias Lib': 446 if name == 'Alias Lib':
438 if self.aliaslib.IsShown(): self.aliaslib.Hide() 447 if self.aliaslib.IsShown(): self.aliaslib.Hide()
441 if self._mgr.GetPane(name).IsShown(): self._mgr.GetPane(name).Hide() 450 if self._mgr.GetPane(name).IsShown(): self._mgr.GetPane(name).Hide()
442 else: self._mgr.GetPane(name).Show() 451 else: self._mgr.GetPane(name).Show()
443 self._mgr.Update() 452 self._mgr.Update()
444 453
445 #OpenRPG Menu 454 #OpenRPG Menu
446 @debugging
447 def OnMB_OpenRPGSettings(self): 455 def OnMB_OpenRPGSettings(self):
448 dlg = orpg.tools.orpg_settings.orpgSettingsWnd(self) 456 dlg = orpg.tools.orpg_settings.orpgSettingsWnd(self)
449 dlg.Centre() 457 dlg.Centre()
450 dlg.ShowModal() 458 dlg.ShowModal()
451 459
452 def OnMB_OpenRPGExit(self): 460 def OnMB_OpenRPGExit(self):
453 self.OnCloseWindow(0) 461 self.OnCloseWindow(0)
454 462
455 #Game Server Menu 463 #Game Server Menu
456 @debugging
457 def OnMB_GameServerBrowseServers(self): 464 def OnMB_GameServerBrowseServers(self):
458 if self._mgr.GetPane("Browse Server Window").IsShown() == True: self._mgr.GetPane("Browse Server Window").Hide() 465 if self._mgr.GetPane("Browse Server Window").IsShown() == True: self._mgr.GetPane("Browse Server Window").Hide()
459 else: self._mgr.GetPane("Browse Server Window").Show() 466 else: self._mgr.GetPane("Browse Server Window").Show()
460 self._mgr.Update() 467 self._mgr.Update()
461 468
462 @debugging
463 def OnMB_GameServerServerHeartbeat(self): 469 def OnMB_GameServerServerHeartbeat(self):
464 if self.mainmenu.GetMenuState("GameServerServerHeartbeat"): settings.set_setting('Heartbeat', '1') 470 if self.mainmenu.GetMenuState("GameServerServerHeartbeat"): settings.change('Heartbeat', '1')
465 else: settings.set_setting('Heartbeat', '0') 471 else: settings.change('Heartbeat', '0')
466 472
467 @debugging
468 def OnMB_GameServerStartServer(self): 473 def OnMB_GameServerStartServer(self):
469 start_dialog = wx.ProgressDialog( "Server Loading", "Server Loading, Please Wait...", 1, self ) 474 start_dialog = wx.ProgressDialog( "Server Loading", "Server Loading, Please Wait...", 1, self )
470 # Spawn the new process and close the stdout handle from it 475 # Spawn the new process and close the stdout handle from it
471 start_dialog.Update( 0 ) 476 start_dialog.Update( 0 )
472 # Adjusted following code to work with win32, can't test for Unix 477 # Adjusted following code to work with win32, can't test for Unix
481 start_dialog.Update( 1 ) 486 start_dialog.Update( 1 )
482 start_dialog.Show(False) 487 start_dialog.Show(False)
483 start_dialog.Destroy() 488 start_dialog.Destroy()
484 489
485 # Tools Menu 490 # Tools Menu
486 @debugging
487 def OnMB_PluginControlPanel(self, evt): 491 def OnMB_PluginControlPanel(self, evt):
488 if self.pluginsFrame.IsShown() == True: self.pluginsFrame.Hide() 492 if self.pluginsFrame.IsShown() == True: self.pluginsFrame.Hide()
489 else: self.pluginsFrame.Show() 493 else: self.pluginsFrame.Show()
490 494
491 @debugging
492 def OnMB_UpdateManagerPanel(self, evt): 495 def OnMB_UpdateManagerPanel(self, evt):
493 if self.updateMana.IsShown() == True: self.updateMana.Hide() 496 if self.updateMana.IsShown() == True: self.updateMana.Hide()
494 else: self.updateMana.Show() 497 else: self.updateMana.Show()
495 498
496 @debugging
497 def OnMB_DebugConsole(self, evt): 499 def OnMB_DebugConsole(self, evt):
498 self.TraipseSuiteWarnCleanup('debug') ### Beta ### 500 self.TraipseSuiteWarnCleanup('debug')
499 if self.debugger.IsShown() == True: self.debugger.Hide() 501 if self.debugger.IsShown() == True: self.debugger.Hide()
500 else: self.debugger.Show() 502 else: self.debugger.Show()
501 503
502 @debugging
503 def OnMB_ToolsLoggingLevelDebug(self): 504 def OnMB_ToolsLoggingLevelDebug(self):
504 lvl = logger.log_level 505 lvl = logger.log_level
505 if self.mainmenu.GetMenuState("ToolsLoggingLevelDebug"): lvl |= ORPG_DEBUG 506 if self.mainmenu.GetMenuState("ToolsLoggingLevelDebug"): lvl |= ORPG_DEBUG
506 else: lvl &= ~ORPG_DEBUG 507 else: lvl &= ~ORPG_DEBUG
507 logger.log_level = lvl 508 logger.log_level = lvl
508 settings.set('LoggingLevel', lvl) 509 settings.change('LoggingLevel', lvl)
509 510
510 @debugging
511 def OnMB_ToolsLoggingLevelNote(self): 511 def OnMB_ToolsLoggingLevelNote(self):
512 lvl = logger.log_level 512 lvl = logger.log_level
513 if self.mainmenu.GetMenuState("ToolsLoggingLevelNote"): lvl |= ORPG_DEBUG 513 if self.mainmenu.GetMenuState("ToolsLoggingLevelNote"): lvl |= ORPG_DEBUG
514 else: lvl &= ~ORPG_DEBUG 514 else: lvl &= ~ORPG_DEBUG
515 logger.log_level = lvl 515 logger.log_level = lvl
516 settings.set('LoggingLevel', lvl) 516 settings.change('LoggingLevel', lvl)
517 517
518 @debugging
519 def OnMB_ToolsLoggingLevelInfo(self): 518 def OnMB_ToolsLoggingLevelInfo(self):
520 lvl = logger.log_level 519 lvl = logger.log_level
521 if self.mainmenu.GetMenuState("ToolsLoggingLevelInfo"): lvl |= ORPG_INFO 520 if self.mainmenu.GetMenuState("ToolsLoggingLevelInfo"): lvl |= ORPG_INFO
522 else: lvl &= ~ORPG_INFO 521 else: lvl &= ~ORPG_INFO
523 logger.log_level = lvl 522 logger.log_level = lvl
524 settings.set('LoggingLevel', lvl) 523 settings.change('LoggingLevel', lvl)
525 524
526 @debugging
527 def OnMB_ToolsLoggingLevelGeneral(self): 525 def OnMB_ToolsLoggingLevelGeneral(self):
528 lvl = logger.log_level 526 lvl = logger.log_level
529 if self.mainmenu.GetMenuState("ToolsLoggingLevelGeneral"): lvl |= ORPG_GENERAL 527 if self.mainmenu.GetMenuState("ToolsLoggingLevelGeneral"): lvl |= ORPG_GENERAL
530 else: lvl &= ~ORPG_GENERAL 528 else: lvl &= ~ORPG_GENERAL
531 logger.log_level = lvl 529 logger.log_level = lvl
532 settings.set('LoggingLevel', lvl) 530 settings.change('LoggingLevel', lvl)
533 531
534 @debugging
535 def OnMB_ToolsPasswordManager(self): 532 def OnMB_ToolsPasswordManager(self):
536 if self.mainmenu.GetMenuState("ToolsPasswordManager"): self.password_manager.Enable() 533 if self.mainmenu.GetMenuState("ToolsPasswordManager"): self.password_manager.Enable()
537 else: self.password_manager.Disable() 534 else: self.password_manager.Disable()
538 535
539 @debugging
540 def OnMB_ToolsStatusBar(self): 536 def OnMB_ToolsStatusBar(self):
541 if self._mgr.GetPane("Status Window").IsShown() == True: 537 if self._mgr.GetPane("Status Window").IsShown() == True:
542 self.mainmenu.SetMenuState("ToolsStatusBar", False) 538 self.mainmenu.SetMenuState("ToolsStatusBar", False)
543 self._mgr.GetPane("Status Window").Hide() 539 self._mgr.GetPane("Status Window").Hide()
544 else: 540 else:
545 self.mainmenu.SetMenuState("ToolsStatusBar", True) 541 self.mainmenu.SetMenuState("ToolsStatusBar", True)
546 self._mgr.GetPane("Status Window").Show() 542 self._mgr.GetPane("Status Window").Show()
547 self._mgr.Update() 543 self._mgr.Update()
548 544
549 @debugging
550 def OnMB_ToolsSoundToolbar(self): 545 def OnMB_ToolsSoundToolbar(self):
551 if self._mgr.GetPane("Sound Control Toolbar").IsShown() == True: 546 if self._mgr.GetPane("Sound Control Toolbar").IsShown() == True:
552 self.mainmenu.SetMenuState("ToolsSoundToolbar", False) 547 self.mainmenu.SetMenuState("ToolsSoundToolbar", False)
553 self._mgr.GetPane("Sound Control Toolbar").Hide() 548 self._mgr.GetPane("Sound Control Toolbar").Hide()
554 else: 549 else:
555 self.mainmenu.SetMenuState("ToolsSoundToolbar", True) 550 self.mainmenu.SetMenuState("ToolsSoundToolbar", True)
556 self._mgr.GetPane("Sound Control Toolbar").Show() 551 self._mgr.GetPane("Sound Control Toolbar").Show()
557 self._mgr.Update() 552 self._mgr.Update()
558 553
559 @debugging
560 def OnMB_ToolsDiceBar(self): 554 def OnMB_ToolsDiceBar(self):
561 if self._mgr.GetPane("Dice Tool Bar").IsShown() == True: 555 if self._mgr.GetPane("Dice Tool Bar").IsShown() == True:
562 self.mainmenu.SetMenuState("ToolsDiceBar", False) 556 self.mainmenu.SetMenuState("ToolsDiceBar", False)
563 self._mgr.GetPane("Dice Tool Bar").Hide() 557 self._mgr.GetPane("Dice Tool Bar").Hide()
564 else: 558 else:
565 self.mainmenu.SetMenuState("ToolsDiceBar", True) 559 self.mainmenu.SetMenuState("ToolsDiceBar", True)
566 self._mgr.GetPane("Dice Tool Bar").Show() 560 self._mgr.GetPane("Dice Tool Bar").Show()
567 self._mgr.Update() 561 self._mgr.Update()
568 562
569 @debugging
570 def OnMB_ToolsMapBar(self): 563 def OnMB_ToolsMapBar(self):
571 if self._mgr.GetPane("Map Tool Bar").IsShown() == True: 564 if self._mgr.GetPane("Map Tool Bar").IsShown() == True:
572 self.mainmenu.SetMenuState("ToolsMapBar", False) 565 self.mainmenu.SetMenuState("ToolsMapBar", False)
573 self._mgr.GetPane("Map Tool Bar").Hide() 566 self._mgr.GetPane("Map Tool Bar").Hide()
574 else: 567 else:
575 self.mainmenu.SetMenuState("ToolsMapBar", True) 568 self.mainmenu.SetMenuState("ToolsMapBar", True)
576 self._mgr.GetPane("Map Tool Bar").Show() 569 self._mgr.GetPane("Map Tool Bar").Show()
577 self._mgr.Update() 570 self._mgr.Update()
578 571
579 #Help Menu #Needs a custom Dialog because it is ugly on Windows
580 @debugging
581 def OnMB_HelpAbout(self): 572 def OnMB_HelpAbout(self):
582 if self.AboutORPG.IsShown() == True: self.AboutORPG.Hide() 573 if self.AboutORPG.IsShown() == True: self.AboutORPG.Hide()
583 else: self.AboutORPG.Show() 574 else: self.AboutORPG.Show()
584 575
585 @debugging
586 def OnMB_HelpOnlineUserGuide(self): 576 def OnMB_HelpOnlineUserGuide(self):
587 wb = webbrowser.get() 577 wb = webbrowser.get()
588 wb.open("http://www.assembla.com/wiki/show/traipse/User_Manual") 578 wb.open("http://www.assembla.com/wiki/show/traipse/User_Manual")
589 579
590 @debugging
591 def OnMB_HelpChangeLog(self): 580 def OnMB_HelpChangeLog(self):
592 wb = webbrowser.get() 581 wb = webbrowser.get()
593 wb.open("http://www.assembla.com/spaces/milestones/index/traipse?spaces_tool_id=Milestones") 582 wb.open("http://www.assembla.com/spaces/milestones/index/traipse?spaces_tool_id=Milestones")
594 583
595 @debugging
596 def OnMB_HelpReportaBug(self): 584 def OnMB_HelpReportaBug(self):
597 wb = webbrowser.get() 585 wb = webbrowser.get()
598 wb.open("http://www.assembla.com/spaces/tickets/index/traipse_dev?spaces_tool_id=Tickets") 586 wb.open("http://www.assembla.com/spaces/tickets/index/traipse_dev?spaces_tool_id=Tickets")
599 587
588 def OnMB_HelpTipoftheDay(self):
589 self.ShowTipOfTheDay()
590
600 591
601 ################################# 592 #################################
602 ## Build the GUI 593 ## Build the GUI
603 ################################# 594 #################################
604 @debugging 595
605 def build_gui(self): 596 def build_gui(self):
606 self.Freeze() 597 self.Freeze()
607 self.validate.config_file("layout.xml","default_layout.xml") 598 self.validate.config_file("layout.xml","default_layout.xml")
608 599
609 filename = dir_struct["user"] + "layout.xml" 600 layout = parse(dir_struct["user"] + "layout.xml")
610 temp_file = open(filename) 601 xml_dom = layout.getroot()
611 txt = temp_file.read() 602
612 xml_dom = xml.parseXml(txt)._get_documentElement()
613 temp_file.close()
614
615 """ Would a component work better?
616 etree = ElementTree()
617 with open(dir_struct['user'] + 'layout.xml') as f:
618 etree.parse(f)
619
620 base = etree.getroot()
621 """
622 self.windowsmenu = wx.Menu() 603 self.windowsmenu = wx.Menu()
623 self.mainwindows = {} 604 self.mainwindows = {}
624 605
625 # About Window 606 # About Window
626 self.AboutORPG = AboutORPG(self) 607 self.AboutORPG = AboutORPG(self)
628 #Plugins Window 609 #Plugins Window
629 self.pluginsFrame = pluginUI.PluginFrame(self) 610 self.pluginsFrame = pluginUI.PluginFrame(self)
630 component.add("plugins", self.get_activeplugins()) 611 component.add("plugins", self.get_activeplugins())
631 component.add("startplugs", self.get_startplugins()) 612 component.add("startplugs", self.get_startplugins())
632 logger.debug("Menu Created") 613 logger.debug("Menu Created")
633 h = int(xml_dom.getAttribute("height")) 614 h = int(xml_dom.get("height"))
634 w = int(xml_dom.getAttribute("width")) 615 w = int(xml_dom.get("width"))
635 posx = int(xml_dom.getAttribute("posx")) 616 posx = int(xml_dom.get("posx"))
636 posy = int(xml_dom.getAttribute("posy")) 617 posy = int(xml_dom.get("posy"))
637 maximized = int(xml_dom.getAttribute("maximized")) 618 maximized = int(xml_dom.get("maximized"))
638 self.SetDimensions(posx, posy, w, h) 619 self.SetDimensions(posx, posy, w, h)
639 logger.debug("Dimensions Set") 620 logger.debug("Dimensions Set")
640 621
641 # Update Manager 622 # Update Manager
642 self.manifest = manifest.ManifestChanges() 623 #self.manifest = manifest.ManifestChanges()
643 self.updateMana = upmana.updatemana.updaterFrame(self, 624 self.updateMana = upmana.updatemana.updaterFrame(self,
644 "OpenRPG Update Manager Beta 0.8", component, self.manifest, True) 625 "OpenRPG Update Manager 1.0", component, manifest, True)
626 component.add('upmana-win', self.updateMana)
645 logger.debug("Menu Created") 627 logger.debug("Menu Created")
646 h = int(xml_dom.getAttribute("height")) 628 h = int(xml_dom.get("height"))
647 w = int(xml_dom.getAttribute("width")) 629 w = int(xml_dom.get("width"))
648 posx = int(xml_dom.getAttribute("posx")) 630 posx = int(xml_dom.get("posx"))
649 posy = int(xml_dom.getAttribute("posy")) 631 posy = int(xml_dom.get("posy"))
650 maximized = int(xml_dom.getAttribute("maximized")) 632 maximized = int(xml_dom.get("maximized"))
651 self.SetDimensions(posx, posy, w, h) 633 self.SetDimensions(posx, posy, w, h)
652 logger.debug("Dimensions Set") 634 logger.debug("Dimensions Set")
653 635
654 # Debug Console 636 # Debug Console
655 self.debugger = orpg.tools.orpg_log.DebugConsole(self) 637 self.debugger = orpg.tools.orpg_log.DebugConsole(self)
656 logger.debug("Menu Created") 638 logger.debug("Menu Created")
657 h = int(xml_dom.getAttribute("height")) 639 h = int(xml_dom.get("height"))
658 w = int(xml_dom.getAttribute("width")) 640 w = int(xml_dom.get("width"))
659 posx = int(xml_dom.getAttribute("posx")) 641 posx = int(xml_dom.get("posx"))
660 posy = int(xml_dom.getAttribute("posy")) 642 posy = int(xml_dom.get("posy"))
661 maximized = int(xml_dom.getAttribute("maximized")) 643 maximized = int(xml_dom.get("maximized"))
662 self.SetDimensions(posx, posy, w, h) 644 self.SetDimensions(posx, posy, w, h)
663 logger.debug("Dimensions Set") 645 logger.debug("Dimensions Set")
664 646
665 # Sound Manager 647 # Sound Manager
666 self.sound_player = orpg.tools.orpg_sound.orpgSound(self) 648 self.sound_player = orpg.tools.orpg_sound.orpgSound(self)
673 wndinfo.Caption("Sound Control Toolbar") 655 wndinfo.Caption("Sound Control Toolbar")
674 wndinfo.Float() 656 wndinfo.Float()
675 wndinfo.ToolbarPane() 657 wndinfo.ToolbarPane()
676 wndinfo.Hide() 658 wndinfo.Hide()
677 self._mgr.AddPane(self.sound_player, wndinfo) 659 self._mgr.AddPane(self.sound_player, wndinfo)
678 children = xml_dom._get_childNodes() 660 children = xml_dom.getchildren()
679 for c in children: self.build_window(c, self) 661 for c in children: self.build_window(c, self)
680 662
681 # status window 663 # status window
682 self.status = status_bar(self) 664 self.status = status_bar(self)
683 wndinfo = AUI.AuiPaneInfo() 665 wndinfo = AUI.AuiPaneInfo()
691 wndinfo.Hide() 673 wndinfo.Hide()
692 self._mgr.AddPane(self.status, wndinfo) 674 self._mgr.AddPane(self.status, wndinfo)
693 logger.debug("Status Window Created") 675 logger.debug("Status Window Created")
694 676
695 # Create and show the floating dice toolbar 677 # Create and show the floating dice toolbar
696 self.dieToolBar = orpg.tools.toolBars.DiceToolBar(self, callBack = self.chat.ParsePost) 678 self.dieToolBar = orpg.tools.toolBars.DiceToolBar(self, callBack = Parse.Post)
697 wndinfo = AUI.AuiPaneInfo() 679 wndinfo = AUI.AuiPaneInfo()
698 menuid = wx.NewId() 680 menuid = wx.NewId()
699 self.mainwindows[menuid] = "Dice Tool Bar" 681 self.mainwindows[menuid] = "Dice Tool Bar"
700 wndinfo.DestroyOnClose(False) 682 wndinfo.DestroyOnClose(False)
701 wndinfo.Name("Dice Tool Bar") 683 wndinfo.Name("Dice Tool Bar")
734 self._mgr.AddPane(self.gs, wndinfo) 716 self._mgr.AddPane(self.gs, wndinfo)
735 logger.debug("Game Server Window Created") 717 logger.debug("Game Server Window Created")
736 718
737 #Create the Alias Lib Window 719 #Create the Alias Lib Window
738 self.aliaslib = orpg.tools.aliaslib.AliasLib() 720 self.aliaslib = orpg.tools.aliaslib.AliasLib()
721 component.add("alias", self.aliaslib)
739 self.aliaslib.Hide() 722 self.aliaslib.Hide()
740 logger.debug("Alias Window Created") 723 logger.debug("Alias Window Created")
741 menuid = wx.NewId() 724 menuid = wx.NewId()
742 self.windowsmenu.Append(menuid, "Alias Lib", kind=wx.ITEM_CHECK) 725 self.windowsmenu.Append(menuid, "Alias Lib", kind=wx.ITEM_CHECK)
743 self.windowsmenu.Check(menuid, False) 726 self.windowsmenu.Check(menuid, False)
749 if wx.VERSION_STRING > "2.8": self.Bind(AUI.EVT_AUI_PANE_CLOSE, self.onPaneClose) 732 if wx.VERSION_STRING > "2.8": self.Bind(AUI.EVT_AUI_PANE_CLOSE, self.onPaneClose)
750 else: self.Bind(AUI.EVT_AUI_PANECLOSE, self.onPaneClose) 733 else: self.Bind(AUI.EVT_AUI_PANECLOSE, self.onPaneClose)
751 logger.debug("AUI Bindings Done") 734 logger.debug("AUI Bindings Done")
752 735
753 #Load the layout if one exists 736 #Load the layout if one exists
754 layout = xml_dom.getElementsByTagName("DockLayout")
755 try: 737 try:
756 textnode = xml.safe_get_text_node(layout[0]) 738 layout = xml_dom.find("DockLayout")
757 self._mgr.LoadPerspective(textnode._get_nodeValue()) 739 self._mgr.LoadPerspective(layout.text)
740 logger.debug("Perspective Loaded")
758 except: pass 741 except: pass
759 xml_dom.unlink()
760 logger.debug("Perspective Loaded")
761 self._mgr.GetPane("Browse Server Window").Hide() 742 self._mgr.GetPane("Browse Server Window").Hide()
762 self._mgr.Update() 743 self._mgr.Update()
763 self.Maximize(maximized) 744 self.Maximize(maximized)
764 logger.debug("GUI is all created") 745 logger.debug("GUI is all created")
765 self.Thaw() 746 self.Thaw()
766 747
767 @debugging 748 def do_tab_window(self, xml_dom, parent_wnd):
768 def do_tab_window(self,xml_dom,parent_wnd):
769 #def do_tab_window(self, etreeEl, parent_wnd):
770 # if container window loop through childern and do a recursive call 749 # if container window loop through childern and do a recursive call
771 temp_wnd = orpgTabberWnd(parent_wnd, style=FNB.FNB_ALLOW_FOREIGN_DND) 750 temp_wnd = orpgTabberWnd(parent_wnd, style=FNB.FNB_ALLOW_FOREIGN_DND)
772 751
773 children = xml_dom._get_childNodes() 752 children = xml_dom.getchildren()
774 for c in children: 753 for c in children:
775 wnd = self.build_window(c,temp_wnd) 754 wnd = self.build_window(c,temp_wnd)
776 name = c.getAttribute("name") 755 name = c.get("name")
777 temp_wnd.AddPage(wnd, name, False) 756 temp_wnd.AddPage(wnd, name, False)
778
779 """
780 for c in etreeEl.getchildren():
781 wnd = self.build_window(c, temp_wnd)
782 temp_wnd.AddPage(wnd, c.get('name'), False)
783 """
784 return temp_wnd 757 return temp_wnd
785 758
786 @debugging
787 def build_window(self, xml_dom, parent_wnd): 759 def build_window(self, xml_dom, parent_wnd):
788 name = xml_dom._get_nodeName() 760 name = xml_dom.tag
789 if name == "DockLayout" or name == "dock": return 761 if name == "DockLayout" or name == "dock": return
790 dirc = xml_dom.getAttribute("direction") #should NOT use dir, it is a built in function. 762 dirc = xml_dom.get("direction") #should NOT use dir, it is a built in function.
791 pos = xml_dom.getAttribute("pos") 763 pos = xml_dom.get("pos")
792 height = xml_dom.getAttribute("height") 764 height = xml_dom.get("height")
793 width = xml_dom.getAttribute("width") 765 width = xml_dom.get("width")
794 cap = xml_dom.getAttribute("caption") 766 cap = xml_dom.get("caption")
795 dockable = xml_dom.getAttribute("dockable") 767 dockable = xml_dom.get("dockable")
796 layer = xml_dom.getAttribute("layer") 768 layer = xml_dom.get("layer")
797 769
798 try: layer = int(layer); dockable = int(dockable) 770 try: layer = int(layer); dockable = int(dockable)
799 except: layer = 0; dockable = 1 771 except: layer = 0; dockable = 1
800 772
801 if name == "tab": temp_wnd = self.do_tab_window(xml_dom, parent_wnd) 773 if name == "tab": temp_wnd = self.do_tab_window(xml_dom, parent_wnd)
802 elif name == "map": 774 elif name == "map":
803 temp_wnd = orpg.mapper.map.map_wnd(parent_wnd, -1) 775 temp_wnd = orpg.mapper.map.map_wnd(parent_wnd, -1)
804 self.map = temp_wnd 776 self.map = temp_wnd
777 component.add("map",self.map)
778
805 elif name == "tree": 779 elif name == "tree":
806 temp_wnd = orpg.gametree.gametree.game_tree(parent_wnd, -1) 780 temp_wnd = orpg.gametree.gametree.game_tree(parent_wnd, -1)
807 self.tree = temp_wnd 781 self.tree = temp_wnd
808 if settings.get_setting('ColorTree') == '1': 782 if settings.get('ColorTree') == '1':
809 self.tree.SetBackgroundColour(settings.get_setting('bgcolor')) 783 self.tree.SetBackgroundColour(settings.get('bgcolor'))
810 self.tree.SetForegroundColour(settings.get_setting('textcolor')) 784 self.tree.SetForegroundColour(settings.get('textcolor'))
811 else: 785 else:
812 self.tree.SetBackgroundColour('white') 786 self.tree.SetBackgroundColour('white')
813 self.tree.SetForegroundColour('black') 787 self.tree.SetForegroundColour('black')
814 788
815 elif name == "chat": 789 elif name == "chat":
816 temp_wnd = orpg.chat.chatwnd.chat_notebook(parent_wnd, wx.DefaultSize) 790 temp_wnd = orpg.chat.chatwnd.chat_notebook(parent_wnd, wx.DefaultSize)
817 self.chattabs = temp_wnd 791 self.chattabs = temp_wnd
818 self.chat = temp_wnd.MainChatPanel 792 self.chat = temp_wnd.MainChatPanel
793 component.add("chat",self.chat)
819 794
820 elif name == "player": 795 elif name == "player":
821 temp_wnd = orpg.player_list.player_list(parent_wnd) 796 temp_wnd = orpg.player_list.player_list(parent_wnd)
822 self.players = temp_wnd 797 self.players = temp_wnd
823 if settings.get_setting('ColorTree') == '1': 798 if settings.get('ColorTree') == '1':
824 self.players.SetBackgroundColour(settings.get_setting('bgcolor')) 799 self.players.SetBackgroundColour(settings.get('bgcolor'))
825 self.players.SetForegroundColour(settings.get_setting('textcolor')) 800 self.players.SetForegroundColour(settings.get('textcolor'))
826 else: 801 else:
827 self.players.SetBackgroundColour('white') 802 self.players.SetBackgroundColour('white')
828 self.players.SetForegroundColour('black') 803 self.players.SetForegroundColour('black')
829 804
830 if parent_wnd != self: return temp_wnd 805 if parent_wnd != self: return temp_wnd
855 wndinfo.Position(int(pos)) 830 wndinfo.Position(int(pos))
856 wndinfo.Show() 831 wndinfo.Show()
857 self._mgr.AddPane(temp_wnd, wndinfo) 832 self._mgr.AddPane(temp_wnd, wndinfo)
858 return temp_wnd 833 return temp_wnd
859 834
860 @debugging
861 def onPaneClose(self, evt): 835 def onPaneClose(self, evt):
862 pane = evt.GetPane() 836 pane = evt.GetPane()
863 #Arbitrary If ELIF fix. Items had incorrect ID's set. Finding correct ID will fix it for the iteration. 837 #Arbitrary If ELIF fix. Items had incorrect ID's set. Finding correct ID will fix it for the iteration.
864 #Adding ID also fixed docking. Go figure. 838 #Adding ID also fixed docking. Go figure.
865 if pane.name == 'Sound Control Toolbar': self.mainmenu.SetMenuState('ToolsSoundToolbar', False) 839 if pane.name == 'Sound Control Toolbar': self.mainmenu.SetMenuState('ToolsSoundToolbar', False)
866 elif pane.name == 'Status Window': self.mainmenu.SetMenuState('ToolsStatusBar', False) 840 elif pane.name == 'Status Window': self.mainmenu.SetMenuState('ToolsStatusBar', False)
867 elif pane.name == 'Dice Tool Bar': self.mainmenu.SetMenuState('ToolsDiceBar', False) 841 elif pane.name == 'Dice Tool Bar': self.mainmenu.SetMenuState('ToolsDiceBar', False)
868 elif pane.name == 'Map Tool Bar': self.mainmenu.SetMenuState('ToolsMapBar', False) 842 elif pane.name == 'Map Tool Bar': self.mainmenu.SetMenuState('ToolsMapBar', False)
869 else: 843 else:
870 for wndid, wname in self.mainwindows.iteritems(): 844 for wndid, wname in self.mainwindows.iteritems():
871 #print pane.name, wname, wndid
872 if pane.name == wname: self.windowsmenu.Check(wndid, False); break 845 if pane.name == wname: self.windowsmenu.Check(wndid, False); break
873 evt.Skip() 846 evt.Skip()
874 self._mgr.Update() 847 self._mgr.Update()
875 848
876 @debugging
877 def saveLayout(self): 849 def saveLayout(self):
878 filename = dir_struct["user"] + "layout.xml" 850 filename = dir_struct["user"] + "layout.xml"
879 temp_file = open(filename) 851 layout = parse(filename)
880 txt = temp_file.read() 852 xml_dom = layout.getroot()
881 xml_dom = xml.parseXml(txt)._get_documentElement()
882 temp_file.close()
883 (x_size,y_size) = self.GetClientSize() 853 (x_size,y_size) = self.GetClientSize()
884 (x_pos,y_pos) = self.GetPositionTuple() 854 (x_pos,y_pos) = self.GetPositionTuple()
885 if self.IsMaximized(): max = 1 855 if self.IsMaximized(): max = 1
886 else: max = 0 856 else: max = 0
887 xml_dom.setAttribute("height", str(y_size)) 857 xml_dom.set("height", str(y_size))
888 xml_dom.setAttribute("width", str(x_size)) 858 xml_dom.set("width", str(x_size))
889 xml_dom.setAttribute("posx", str(x_pos)) 859 xml_dom.set("posx", str(x_pos))
890 xml_dom.setAttribute("posy", str(y_pos)) 860 xml_dom.set("posy", str(y_pos))
891 xml_dom.setAttribute("maximized", str(max)) 861 xml_dom.set("maximized", str(max))
892 layout = xml_dom.getElementsByTagName("DockLayout") 862 try: xml_dom.find("DockLayout").text = str(self._mgr.SavePerspective())
893 try:
894 textnode = xml.safe_get_text_node(layout[0])
895 textnode._set_nodeValue(str(self._mgr.SavePerspective()))
896 except: 863 except:
897 elem = minidom.Element('DockLayout') 864 elem = Element('DockLayout')
898 elem.setAttribute("DO_NO_EDIT","True") 865 elem.set("DO_NO_EDIT","True")
899 textnode = xml.safe_get_text_node(elem) 866 elem.text = str(self._mgr.SavePerspective())
900 textnode._set_nodeValue(str(self._mgr.SavePerspective())) 867 xml_dom.append(elem)
901 xml_dom.appendChild(elem) 868 layout.write(filename)
902 temp_file = open(filename, "w") 869
903 temp_file.write(xml_dom.toxml(1))
904 temp_file.close()
905
906 @debugging
907 def build_hotkeys(self): 870 def build_hotkeys(self):
908 self.mainmenu.accel.xaccel.extend(self.chat.get_hot_keys()) 871 self.mainmenu.accel.xaccel.extend(self.chat.get_hot_keys())
909 self.mainmenu.accel.xaccel.extend(self.map.get_hot_keys()) 872 self.mainmenu.accel.xaccel.extend(self.map.get_hot_keys())
910 873
911 @debugging
912 def start_timer(self): 874 def start_timer(self):
913 self.poll_timer.Start(100) 875 self.poll_timer.Start(100)
914 s = component.get('settings') 876 if settings.get("Heartbeat") == "1":
915 if s.get_setting("Heartbeat") == "1":
916 self.ping_timer.Start(1000*60) 877 self.ping_timer.Start(1000*60)
917 logger.debug("starting heartbeat...", True) 878 logger.debug("starting heartbeat...", True)
918 879
919 @debugging
920 def kill_mplay_session(self): 880 def kill_mplay_session(self):
921 self.game_name = "" 881 self.game_name = ""
922 self.session.start_disconnect() 882 self.session.start_disconnect()
923 883
924 @debugging
925 def quit_game(self, evt): 884 def quit_game(self, evt):
926 dlg = wx.MessageDialog(self,"Exit gaming session?","Game Session",wx.YES_NO) 885 dlg = wx.MessageDialog(self,"Exit gaming session?","Game Session",wx.YES_NO)
927 if dlg.ShowModal() == wx.ID_YES: 886 if dlg.ShowModal() == wx.ID_YES:
928 self.session.exitCondition.notifyAll() 887 self.session.exitCondition.notifyAll()
929 dlg.Destroy() 888 dlg.Destroy()
930 self.kill_mplay_session() 889 self.kill_mplay_session()
931 890
932 @debugging
933 def on_status_event(self, evt): 891 def on_status_event(self, evt):
934 id = evt.get_id() 892 id = evt.get_id()
935 status = evt.get_data() 893 status = evt.get_data()
936 if id == orpg.networking.mplay_client.STATUS_SET_URL: self.status.set_url(status) 894 if id == orpg.networking.mplay_client.STATUS_SET_URL: self.status.set_url(status)
937 895
938 @debugging
939 def on_player_event(self, evt): 896 def on_player_event(self, evt):
940 id = evt.get_id() 897 id = evt.get_id()
941 player = evt.get_data() 898 player = evt.get_data()
942 display_name = self.chat.chat_display_name(player) 899 display_name = self.chat.chat_display_name(player)
943 time_str = time.strftime("%H:%M", time.localtime()) 900 time_str = time.strftime("%H:%M", time.localtime())
949 self.chat.InfoPost(display_name + " (exit): " + time_str) 906 self.chat.InfoPost(display_name + " (exit): " + time_str)
950 elif id == orpg.networking.mplay_client.PLAYER_UPDATE: 907 elif id == orpg.networking.mplay_client.PLAYER_UPDATE:
951 self.players.update_player(player) 908 self.players.update_player(player)
952 self.players.Refresh() 909 self.players.Refresh()
953 910
954 @debugging
955 def on_group_event(self, evt): 911 def on_group_event(self, evt):
956 id = evt.get_id() 912 id = evt.get_id()
957 data = evt.get_data() 913 data = evt.get_data()
958 if id == orpg.networking.mplay_client.GROUP_NEW: self.gs.add_room(data) 914 if id == orpg.networking.mplay_client.GROUP_NEW: self.gs.add_room(data)
959 elif id == orpg.networking.mplay_client.GROUP_DEL: 915 elif id == orpg.networking.mplay_client.GROUP_DEL:
960 self.password_manager.RemoveGroupData(data) 916 # self.password_manager.RemoveGroupData(data) #Removed for debugging.
961 self.gs.del_room(data) 917 self.gs.del_room(data)
962 elif id == orpg.networking.mplay_client.GROUP_UPDATE: self.gs.update_room(data) 918 elif id == orpg.networking.mplay_client.GROUP_UPDATE: self.gs.update_room(data)
963 919
964 @debugging
965 def on_receive(self, data, player): 920 def on_receive(self, data, player):
966 # see if we are ignoring this user 921 # see if we are ignoring this user
967 (ignore_id,ignore_name) = self.session.get_ignore_list() 922 (ignore_id, ignore_name) = self.session.get_ignore_list()
968 for m in ignore_id: 923 for m in ignore_id:
969 if m == player[2]: logger.debug("ignoring message from player:" + player[0], True); return 924 if m == player[2]: logger.debug("ignoring message from player:" + player[0], True); return
970 925
971 # ok we are not ignoring this message 926 # ok we are not ignoring this message
972 #recvSound = "RecvSound" # this will be the default sound. Whisper will change this below 927 #recvSound = "RecvSound" # this will be the default sound. Whisper will change this below
928
929 etreeEl = Element('msg')
930 try: etreeEl.append(fromstring(data))
931 except: etreeEl.text = data
973 if player: display_name = self.chat.chat_display_name(player) 932 if player: display_name = self.chat.chat_display_name(player)
974 else: display_name = "Server Administrator" 933 else: display_name = "Server Administrator"
975 934
976 if data[:5] == "<tree": 935 if etreeEl.text: self.chat.Post(etreeEl.text)
977 self.tree.on_receive_data(data,player) 936
978 self.chat.InfoPost(display_name + " has sent you a tree node...") 937 for child in etreeEl.getchildren():
979 938 if child.tag == 'tree':
980 elif data[:4] == "<map": self.map.new_data(data) 939 dlg = wx.MessageDialog(None, component.strip_html(display_name) + ' is trying to send you a tree node. Accept?', 'Question',
981 940 wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)
982 elif data[:5] == "<chat": 941 if dlg.ShowModal() == wx.ID_YES:
983 msg = orpg.chat.chat_msg.chat_msg(data) 942 dlg.Destroy()
984 self.chat.post_incoming_msg(msg,player) 943 self.tree.on_receive_data(tostring(child))
985 else: 944 self.chat.InfoPost(display_name + " has sent you a tree node...")
986 """ 945 elif child.tag == 'map':
987 all this below code is for comptiablity with older clients and can 946 #TODO: Fix map to accepts elements
988 be removed after a bit 947 self.map.new_data(tostring(child))
989 """ 948 elif child.tag == 'chat':
990 import warnings 949 msg = orpg.chat.chat_msg.chat_msg(tostring(child))
991 warnings.warn("Getting here is bad, find out how and fix it", 950 self.chat.post_incoming_msg(msg, player)
992 DeprecationWarning, 2) 951
993 if data[:3] == "/me":
994 """
995 This fixes the emote coloring to comply with what has been
996 asked for by the user population, not to mention, what I
997 committed to many moons ago. In doing so, Woody's scheme has
998 been tossed out. I'm sure Woody won't be happy but I'm
999 invoking developer priveledge to satisfy user request, not to
1000 mention, this scheme actually makes more sense. In Woody's
1001 scheme, a user could over-ride another users emote color. This
1002 doesn't make sense, rather, people dictate their OWN colors...
1003 which is as it should be in the first place and is as it has
1004 been with normal text. In short, this makes sense and is
1005 consistent.
1006 """
1007 data = data.replace( "/me", "" )
1008 """
1009 Check to see if we find the closing '>' for the font within the
1010 first 22 values
1011 """
1012 index = data[:22].find( ">" )
1013 if index == -1:
1014 data = "** " + self.chat.colorize( self.chat.infocolor, display_name + data ) + " **"
1015
1016 else:
1017 """
1018 This means that we found a valid font string, so we can
1019 simply plug the name into the string between the start and
1020 stop font delimiter
1021 """
1022 print "pre data = " + data
1023 data = data[:22] + "** " + display_name + " " + data[22:] + " **"
1024 print "post data = " + data
1025
1026 elif data[:2] == "/w":
1027 data = data.replace("/w","")
1028 data = "<b>" + display_name + "</b> (whispering): " + data
1029
1030 else:
1031 # Normal text
1032 if player: data = "<b>" + display_name + "</b>: " + data
1033 else: data = "<b><i><u>" + display_name + "</u>-></i></b> " + data
1034 self.chat.Post(data)
1035
1036 @debugging
1037 def on_mplay_event(self, evt): 952 def on_mplay_event(self, evt):
1038 id = evt.get_id() 953 id = evt.get_id()
1039 if id == orpg.networking.mplay_client.MPLAY_CONNECTED: 954 if id == orpg.networking.mplay_client.MPLAY_CONNECTED:
1040 self.chat.InfoPost("Game connected!") 955 self.chat.InfoPost("Game connected!")
1041 self.gs.set_connected(1) 956 self.gs.set_connected(1)
1049 self.gs.set_connected(0) 964 self.gs.set_connected(0)
1050 self.status.set_connect_status("Not Connected") 965 self.status.set_connect_status("Not Connected")
1051 966
1052 ####Begin changes for Custom Exit Message by mDuo13###### 967 ####Begin changes for Custom Exit Message by mDuo13######
1053 elif id == orpg.networking.mplay_client.MPLAY_DISCONNECTING: 968 elif id == orpg.networking.mplay_client.MPLAY_DISCONNECTING:
1054 settings = component.get('settings') 969 custom_msg = settings.get("dcmsg")
1055 custom_msg = settings.get_setting("dcmsg")
1056 custom_msg=custom_msg[:80] 970 custom_msg=custom_msg[:80]
1057 if custom_msg[:3]=="/me": self.chat.send_chat_message(custom_msg[3:], 3) 971 if custom_msg[:3]=="/me": self.chat.send_chat_message(custom_msg[3:], 3)
1058 else: self.chat.system_message(custom_msg) 972 else: self.chat.system_message(custom_msg)
1059 #####End Changes for Custom Exit Message by mDuo13 973 #####End Changes for Custom Exit Message by mDuo13
1060 974
1061 elif id== orpg.networking.mplay_client.MPLAY_GROUP_CHANGE: 975 elif id == orpg.networking.mplay_client.MPLAY_GROUP_CHANGE:
1062 group = evt.get_data() 976 group = evt.get_data()
1063 self.chat.InfoPost("Moving to room '"+group[1]+"'..") 977 self.chat.InfoPost("Moving to room '"+group[1]+"'..")
1064 if self.gs : self.gs.set_cur_room_text(group[1]) 978 if self.gs : self.gs.set_cur_room_text(group[1])
1065 self.players.reset() 979 self.players.reset()
1066 elif id== orpg.networking.mplay_client.MPLAY_GROUP_CHANGE_F: 980 elif id == orpg.networking.mplay_client.MPLAY_GROUP_CHANGE_F:
1067 self.chat.SystemPost("Room access denied!") 981 self.chat.SystemPost("Room access denied!")
1068 982
1069 @debugging
1070 def OnCloseWindow(self, event): 983 def OnCloseWindow(self, event):
1071 dlg = wx.MessageDialog(self, "Quit OpenRPG?", "OpenRPG", wx.YES_NO) 984 dlg = wx.MessageDialog(self, "Quit OpenRPG?", "OpenRPG", wx.YES_NO)
1072 if dlg.ShowModal() == wx.ID_YES: 985 if dlg.ShowModal() == wx.ID_YES:
1073 dlg.Destroy() 986 dlg.Destroy()
1074 self.closed_confirmed() 987 self.closed_confirmed()
1075 988
1076 @debugging
1077 def closed_confirmed(self): 989 def closed_confirmed(self):
1078 self.activeplugins = component.get('plugins') 990 self.activeplugins = component.get('plugins')
1079 self.aliaslib.OnMB_FileSave(None) 991 self.aliaslib.OnMB_FileSave(None)
1080 992
1081 #following lines added by mDuo13 993 #following lines added by mDuo13
1088 #end mDuo13 added code 1000 #end mDuo13 added code
1089 self.saveLayout() 1001 self.saveLayout()
1090 try: settings.save() 1002 try: settings.save()
1091 except Exception: 1003 except Exception:
1092 logger.general("[WARNING] Error saving 'settings' component", True) 1004 logger.general("[WARNING] Error saving 'settings' component", True)
1093
1094 try: self.map.pre_exit_cleanup() 1005 try: self.map.pre_exit_cleanup()
1095 except Exception: 1006 except Exception:
1096 logger.general("[WARNING] Map error pre_exit_cleanup()", True) 1007 logger.general("[WARNING] Map error pre_exit_cleanup()", True)
1097
1098 try: 1008 try:
1099 save_tree = string.upper(settings.get_setting("SaveGameTreeOnExit")) 1009 save_tree = string.upper(settings.get("SaveGameTreeOnExit"))
1100 if (save_tree != "0") and (save_tree != "False") and (save_tree != "NO"): 1010 if (save_tree != "0") and (save_tree != "False") and (save_tree != "NO"):
1101 self.tree.save_tree(settings.get_setting("gametree")) 1011 self.tree.save_tree(settings.get("gametree"))
1102 except Exception: 1012 except Exception:
1103 logger.general("[WARNING] Error saving gametree", True) 1013 logger.general("[WARNING] Error saving gametree", True)
1104 1014
1105 if self.session.get_status() == orpg.networking.mplay_client.MPLAY_CONNECTED: self.kill_mplay_session() 1015 if self.session.get_status() == orpg.networking.mplay_client.MPLAY_CONNECTED: self.kill_mplay_session()
1106 1016
1147 1057
1148 ######################################## 1058 ########################################
1149 ## About Dialog class 1059 ## About Dialog class
1150 ######################################## 1060 ########################################
1151 class AboutORPG(wx.Frame): 1061 class AboutORPG(wx.Frame):
1152 def __init__(self, parent): 1062 def __init__(self, parent, description=''):
1153 super(AboutORPG, self).__init__(parent, -1, "About 'Traipse' OpenRPG") 1063 super(AboutORPG, self).__init__(parent, -1, "About 'Traipse' OpenRPG")
1154 icon = None 1064 icon = None
1155 icon = wx.Icon(dir_struct["icon"]+'d20.ico', wx.BITMAP_TYPE_ICO) 1065 icon = wx.Icon(dir_struct["icon"]+'d20.ico', wx.BITMAP_TYPE_ICO)
1156 self.SetIcon( icon ) 1066 self.SetIcon( icon )
1157 sizer = wx.GridBagSizer(hgap=1, vgap=1) 1067 sizer = wx.GridBagSizer(hgap=1, vgap=1)
1168 sizer.AddGrowableCol(1) 1078 sizer.AddGrowableCol(1)
1169 sizer.AddGrowableRow(1) 1079 sizer.AddGrowableRow(1)
1170 self.Bind(wx.EVT_CLOSE, self.Min) 1080 self.Bind(wx.EVT_CLOSE, self.Min)
1171 self.Min(None) 1081 self.Min(None)
1172 1082
1173 description = "OpenRPG is a Virtual Game Table that allows users to connect via a network and play table " 1083 description += "OpenRPG is a Virtual Game Table that allows users to connect via a network and play table "
1174 description += "top games with friends. 'Traipse' is an OpenRPG distro that is easy to setup and provides superb " 1084 description += "top games with friends. 'Traipse' is an OpenRPG distro that is easy to setup and provides superb "
1175 description += "functionality. OpenRPG is originally designed by Chris Davis." 1085 description += "functionality. OpenRPG is originally designed by Chris Davis."
1176 1086
1177 license = "OpenRPG is free software; you can redistribute it and/or modify it " 1087 license = "OpenRPG is free software; you can redistribute it and/or modify it "
1178 license += "under the terms of the GNU General Public License as published by the Free Software Foundation; " 1088 license += "under the terms of the GNU General Public License as published by the Free Software Foundation; "
1189 self.About.AppendText('OpenRPG Developers:\n') 1099 self.About.AppendText('OpenRPG Developers:\n')
1190 orpg_devs = ['Thomas Baleno', 'Andrew Bennett', 'Lex Berezhny', 'Ted Berg', 1100 orpg_devs = ['Thomas Baleno', 'Andrew Bennett', 'Lex Berezhny', 'Ted Berg',
1191 'Bernhard Bergbauer', 'Chris Blocher', 'David Byron', 'Ben Collins-Sussman', 'Robin Cook', 'Greg Copeland', 1101 'Bernhard Bergbauer', 'Chris Blocher', 'David Byron', 'Ben Collins-Sussman', 'Robin Cook', 'Greg Copeland',
1192 'Chris Davis', 'Michael Edwards', 'Andrew Ettinger', 'Todd Faris', 'Dj Gilcrease', 1102 'Chris Davis', 'Michael Edwards', 'Andrew Ettinger', 'Todd Faris', 'Dj Gilcrease',
1193 'Christopher Hickman', 'Paul Hosking', 'Brian Manning', 'Scott Mackay', 'Jesse McConnell', 1103 'Christopher Hickman', 'Paul Hosking', 'Brian Manning', 'Scott Mackay', 'Jesse McConnell',
1194 'Brian Osman', 'Rome Reginelli', 'Christopher Rouse', 'Dave Sanders', 'Tyler Starke', 'Mark Tarrabain'] 1104 'Brian Osman', 'Rome Reginelli', 'Christopher Rouse', 'Dave Sanders', 'Tyler Starke', 'Mark Tarrabain',
1105 'David Vrabel']
1195 for dev in orpg_devs: 1106 for dev in orpg_devs:
1196 self.About.AppendText(dev+'\n') 1107 self.About.AppendText(dev+'\n')
1197 1108
1198 def Min(self, evt): 1109 def Min(self, evt):
1199 self.Hide() 1110 self.Hide()
1200 1111
1201 ######################################## 1112 ########################################
1202 ## Application class 1113 ## Application class
1203 ######################################## 1114 ########################################
1204 class orpgSplashScreen(wx.SplashScreen): 1115 class orpgSplashScreen(wx.SplashScreen):
1205 @debugging 1116
1206 def __init__(self, parent, bitmapfile, duration, callback): 1117 def __init__(self, parent, bitmapfile, duration, callback):
1207 wx.SplashScreen.__init__(self, wx.Bitmap(bitmapfile), 1118 wx.SplashScreen.__init__(self, wx.Bitmap(bitmapfile),
1208 wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT, duration, None, -1) 1119 wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT, duration, None, -1)
1209 self.callback = callback 1120 self.callback = callback
1210 self.closing = False 1121 self.closing = False
1211 self.Bind(wx.EVT_CLOSE, self.callback) 1122 self.Bind(wx.EVT_CLOSE, self.callback)
1212 1123
1213 class orpgApp(wx.App): 1124 class orpgApp(wx.App):
1214 @debugging 1125
1215 def OnInit(self): 1126 def OnInit(self):
1216
1217 component.add('log', logger) 1127 component.add('log', logger)
1218 component.add('xml', xml) 1128 component.add('xml', xml)
1219 component.add('settings', settings) 1129 component.add('settings', settings)
1220 component.add('validate', validate) 1130 component.add('validate', validate)
1221 component.add("tabbedWindows", []) 1131 component.add("tabbedWindows", [])
1222
1223 logger._set_log_level = int(settings.get_setting('LoggingLevel'))
1224 logger._set_log_to_console(False)
1225
1226 self.manifest = manifest.ManifestChanges()
1227 1132
1228 self.called = False 1133 self.called = False
1229 wx.InitAllImageHandlers() 1134 wx.InitAllImageHandlers()
1230 self.splash = orpgSplashScreen(None, dir_struct["icon"] + 'splash13.jpg', 3000, self.AfterSplash) 1135 self.splash = orpgSplashScreen(None, dir_struct["icon"] + 'splash13.jpg', 3000, self.AfterSplash)
1231 self.Bind(wx.EVT_KEY_DOWN, self.OnKeyPress) 1136 self.Bind(wx.EVT_KEY_DOWN, self.OnKeyPress)
1232 self._crust = None 1137 self._crust = None
1233 wx.Yield() 1138 wx.Yield()
1234 return True 1139 return True
1235 1140
1236 @debugging
1237 def OnKeyPress(self, evt): 1141 def OnKeyPress(self, evt):
1238 #Event handler 1142 #Event handler
1239 if evt.AltDown() and evt.CmdDown() and evt.KeyCode == ord('I'): self.ShowShell() 1143 if evt.AltDown() and evt.CmdDown() and evt.KeyCode == ord('I'): self.ShowShell()
1240 else: evt.Skip() 1144 else: evt.Skip()
1241 1145
1242 @debugging
1243 def ShowShell(self): 1146 def ShowShell(self):
1244 #Show the PyCrust window. 1147 #Show the PyCrust window.
1245 if not self._crust: 1148 if not self._crust:
1246 self._crust = wx.py.crust.CrustFrame(self.GetTopWindow()) 1149 self._crust = wx.py.crust.CrustFrame(self.GetTopWindow())
1247 self._crust.shell.interp.locals['app'] = self 1150 self._crust.shell.interp.locals['app'] = self
1248 win = wx.FindWindowAtPointer() 1151 win = wx.FindWindowAtPointer()
1249 self._crust.shell.interp.locals['win'] = win 1152 self._crust.shell.interp.locals['win'] = win
1250 self._crust.Show() 1153 self._crust.Show()
1251 1154
1252 @debugging
1253 def AfterSplash(self,evt): 1155 def AfterSplash(self,evt):
1254 if not self.called: 1156 if not self.called:
1255 self.splash.Hide() 1157 self.splash.Hide()
1256 self.called = True 1158 self.called = True
1257 self.frame = orpgFrame(None, wx.ID_ANY, MENU_TITLE) 1159 self.frame = orpgFrame(None, wx.ID_ANY, MENU_TITLE)
1262 #self.frame.show_dlgs() 1164 #self.frame.show_dlgs()
1263 self.frame.post_show_init() 1165 self.frame.post_show_init()
1264 wx.CallAfter(self.splash.Close) 1166 wx.CallAfter(self.splash.Close)
1265 return True 1167 return True
1266 1168
1267 @debugging
1268 def OnExit_CleanUp(self): 1169 def OnExit_CleanUp(self):
1269 logger.debug("Preforming cleanup\n") 1170 logger.debug("Preforming cleanup\n")
1270 try: del os.environ["OPENRPG_BASE"] 1171 try: del os.environ["OPENRPG_BASE"]
1271 except: pass 1172 except: pass
1272 try: os.remove(os.environ["OPENRPG_BASE"] + os.sep + 'orpg' + os.sep + 'dirpath' + os.sep + 'approot.py') 1173 try: os.remove(os.environ["OPENRPG_BASE"] + os.sep + 'orpg' + os.sep + 'dirpath' + os.sep + 'approot.py')
1273 except: pass 1174 except: pass
1274 try: os.remove(os.environ["OPENRPG_BASE"] + os.sep + 'orpg' + os.sep + 'dirpath' + os.sep + 'approot.pyc') 1175 try: os.remove(os.environ["OPENRPG_BASE"] + os.sep + 'orpg' + os.sep + 'dirpath' + os.sep + 'approot.pyc')
1275 except: pass 1176 except: pass
1276 1177
1277 @debugging
1278 def OnExit(self): 1178 def OnExit(self):
1279 self.OnExit_CleanUp() 1179 self.OnExit_CleanUp()
1280 #Exit 1180 #Exit
1281 logger.debug("Main Application Exit\n\n") 1181 logger.debug("Main Application Exit\n\n")