Mercurial > traipse_dev
comparison orpg/main.py @ 135:dcf4fbe09b70 beta
Traipse Beta 'OpenRPG' {091010-00}
Traipse is a distribution of OpenRPG that is designed to be easy to setup and go. Traipse also makes it easy for developers to work on
code without fear of sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the code. 'Ornery-Orc's main goal is to
offer more advanced features and enhance the productivity of the user.
Update Summary (Beta)
Added Bookmarks
Fix to Remote Admin Commands
Minor fix to text based Server
Fix to Pretty Print, from Core
Fix to Splitter Nodes not being created
Fix to massive amounts of images loading, from Core
Added 'boot' command to remote admin
Added confirmation window for sent nodes
Minor changes to allow for portability to an OpenSUSE linux OS
Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG
Zoom Mouse plugin added
Images added to Plugin UI
Switching to Element Tree
Map efficiency, from FlexiRPG
Added Status Bar to Update Manager
default_manifest.xml renamed to default_upmana.xml
Cleaner clode for saved repositories
New TrueDebug Class in orpg_log (See documentation for usage)
Mercurial's hgweb folder is ported to upmana
**Pretty important update that can help remove thousands of dead children from your gametree.
**Children, <forms />, <group_atts />, <horizontal />, <cols />, <rows />, <height />, etc... are all tags now. Check your gametree and
look for dead children!!
**New Gamtree Recusion method, mapping, and context sensitivity. !!Alpha - Watch out for infinite loops!!
author | sirebral |
---|---|
date | Tue, 10 Nov 2009 14:11:28 -0600 |
parents | 7ed4979cc1cf |
children | e842a5f1b775 |
comparison
equal
deleted
inserted
replaced
101:394ebb3b6a0f | 135:dcf4fbe09b70 |
---|---|
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 #Update Manager# Un remark if you have Mercurial installed | |
52 import upmana.updatemana | 53 import upmana.updatemana |
53 import upmana.manifest as manifest | 54 import upmana.manifest as 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.dieroller.utils import DiceManager |
57 from orpg.tools.orpg_settings import settings | 58 from orpg.tools.settings import settings |
58 from orpg.tools.validate import validate | 59 from orpg.tools.validate import validate |
59 from orpg.tools.passtool import PassTool | 60 from orpg.tools.passtool import PassTool |
60 from orpg.tools.orpg_log import logger, crash | 61 from orpg.tools.orpg_log import logger, crash, debug |
61 from orpg.tools.decorators import debugging | |
62 from orpg.tools.metamenus import MenuBarEx | 62 from orpg.tools.metamenus import MenuBarEx |
63 | 63 |
64 #from xml.etree.ElementTree import ElementTree, Element | 64 from xml.etree.ElementTree import ElementTree, Element, parse |
65 #from xml.etree.ElementTree import fromstring, tostring | 65 from xml.etree.ElementTree import fromstring, tostring |
66 ## Element Tree usage will require users to convert to and from string data quite often until users of older versions update. | |
67 ## This is a problem that users of older versions will need to cross as it is both Core and Traipse that will make the change. | |
68 ## Older versions have a problem with correct XML. | |
66 from orpg.orpg_xml import xml #to be replaced by etree | 69 from orpg.orpg_xml import xml #to be replaced by etree |
67 | 70 |
68 | 71 |
69 #################################### | 72 #################################### |
70 ## Main Frame | 73 ## Main Frame |
71 #################################### | 74 #################################### |
72 | 75 |
73 | 76 |
74 class orpgFrame(wx.Frame): | 77 class orpgFrame(wx.Frame): |
75 @debugging | 78 |
76 def __init__(self, parent, id, title): | 79 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) | 80 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") | 81 self.validate = component.get("validate") |
79 logger.debug("Enter orpgFrame") | 82 logger.debug("Enter orpgFrame") |
80 self.rgb = orpg.tools.rgbhex.RGBHex() | 83 self.rgb = orpg.tools.rgbhex.RGBHex() |
93 "on_player_event":self.on_player_event, | 96 "on_player_event":self.on_player_event, |
94 "on_status_event":self.on_status_event, | 97 "on_status_event":self.on_status_event, |
95 "on_password_signal":self.on_password_signal, | 98 "on_password_signal":self.on_password_signal, |
96 "orpgFrame":self} | 99 "orpgFrame":self} |
97 self.settings = component.get('settings') #Arbitrary until settings updated with Core. | 100 self.settings = component.get('settings') #Arbitrary until settings updated with Core. |
98 self.session = orpg.networking.mplay_client.mplay_client(self.settings.get_setting("player"), call_backs) | 101 self.session = orpg.networking.mplay_client.mplay_client(self.settings.get("player"), call_backs) |
99 self.poll_timer = wx.Timer(self, wx.NewId()) | 102 self.poll_timer = wx.Timer(self, wx.NewId()) |
100 self.Bind(wx.EVT_TIMER, self.session.poll, self.poll_timer) | 103 self.Bind(wx.EVT_TIMER, self.session.poll, self.poll_timer) |
101 self.poll_timer.Start(100) | 104 self.poll_timer.Start(100) |
102 self.ping_timer = wx.Timer(self, wx.NewId()) | 105 self.ping_timer = wx.Timer(self, wx.NewId()) |
103 self.Bind(wx.EVT_TIMER, self.session.update, self.ping_timer) | 106 self.Bind(wx.EVT_TIMER, self.session.update, self.ping_timer) |
104 | 107 |
105 # create roller manager | 108 # create roller manager |
106 self.DiceManager = DiceManager(settings.get_setting("dieroller")) | 109 self.DiceManager = DiceManager(settings.get("dieroller")) |
107 component.add('DiceManager', self.DiceManager) | 110 component.add('DiceManager', self.DiceManager) |
108 | 111 |
109 #create password manager --SD 8/03 | 112 #create password manager --SD 8/03 |
110 self.password_manager = component.get('password_manager') | 113 self.password_manager = component.get('password_manager') |
111 component.add("session", self.session) | 114 component.add("session", self.session) |
120 component.add("chat",self.chat) | 123 component.add("chat",self.chat) |
121 component.add("map",self.map) | 124 component.add("map",self.map) |
122 component.add("alias", self.aliaslib) | 125 component.add("alias", self.aliaslib) |
123 | 126 |
124 logger.debug("openrpg components all added") | 127 logger.debug("openrpg components all added") |
125 self.tree.load_tree(settings.get_setting("gametree")) | 128 self.tree.load_tree(settings.get("gametree")) |
126 logger.debug("Tree Loaded") | 129 logger.debug("Tree Loaded") |
127 self.players.size_cols() | 130 self.players.size_cols() |
128 | 131 |
129 #Load the Plugins This has to be after the chat component has been added | 132 #Load the Plugins This has to be after the chat component has been added |
130 component.add('pluginmenu', self.pluginMenu) | 133 component.add('pluginmenu', self.pluginMenu) |
135 #Load Update Manager | 138 #Load Update Manager |
136 component.add('updatemana', self.updateMana) | 139 component.add('updatemana', self.updateMana) |
137 logger.debug("update manager reloaded") | 140 logger.debug("update manager reloaded") |
138 self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) | 141 self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) |
139 | 142 |
140 #Load Update Manager | 143 #Load Debug Console |
141 component.add('debugconsole', self.debugger) | 144 component.add('debugconsole', self.debugger) |
142 logger.debug("debugger window") | 145 logger.debug("debugger window") |
143 self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) | 146 self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) |
144 | 147 |
145 @debugging | 148 |
146 def post_show_init(self): | 149 def post_show_init(self): |
147 """Some Actions need to be done after the main fram is drawn""" | 150 """Some Actions need to be done after the main fram is drawn""" |
148 self.players.size_cols() | 151 self.players.size_cols() |
149 | 152 |
150 @debugging | 153 |
151 def get_activeplugins(self): | 154 def get_activeplugins(self): |
152 try: tmp = self.pluginsFrame.get_activeplugins() | 155 try: tmp = self.pluginsFrame.get_activeplugins() |
153 except: tmp = {} | 156 except: tmp = {} |
154 return tmp | 157 return tmp |
155 | 158 |
156 @debugging | 159 |
157 def get_startplugins(self): | 160 def get_startplugins(self): |
158 try: tmp = self.pluginsFrame.get_startplugins() | 161 try: tmp = self.pluginsFrame.get_startplugins() |
159 except: tmp = {} | 162 except: tmp = {} |
160 return tmp | 163 return tmp |
161 | 164 |
162 @debugging | 165 |
163 def on_password_signal(self,signal,type,id,data): | 166 def on_password_signal(self,signal,type,id,data): |
164 try: | 167 try: |
165 msg = ["DEBUG: password response= ", | 168 msg = ["DEBUG: password response= ", |
166 str(signal), | 169 str(signal), |
167 " (T:", | 170 " (T:", |
179 elif type == "admin": self.password_manager.ClearPassword("admin", int(id)) | 182 elif type == "admin": self.password_manager.ClearPassword("admin", int(id)) |
180 elif type == "room": self.password_manager.ClearPassword("room", int(id)) | 183 elif type == "room": self.password_manager.ClearPassword("room", int(id)) |
181 else: pass | 184 else: pass |
182 except: traceback.print_exc() | 185 except: traceback.print_exc() |
183 | 186 |
184 @debugging | 187 |
185 def build_menu(self): | 188 def build_menu(self): |
186 menu = \ | 189 menu = \ |
187 [[ | 190 [[ |
188 ['&OpenRPG'], | 191 ['&OpenRPG'], |
189 [' &Settings\tCtrl-S'], | 192 [' &Settings\tCtrl-S'], |
232 [' Change Log'], | 235 [' Change Log'], |
233 [' Report a Bug'] | 236 [' Report a Bug'] |
234 ]] | 237 ]] |
235 | 238 |
236 self.mainmenu = MenuBarEx(self, menu) | 239 self.mainmenu = MenuBarEx(self, menu) |
237 if settings.get_setting('Heartbeat') == '1': | 240 if settings.get('Heartbeat') == '1': |
238 self.mainmenu.SetMenuState("GameServerServerHeartbeat", True) | 241 self.mainmenu.SetMenuState("GameServerServerHeartbeat", True) |
239 | 242 |
240 tabtheme = settings.get_setting('TabTheme') #This change is stable. TaS. | 243 self.mainmenu.SetMenuState('ToolsPasswordManager', True if settings.get('PWMannager') == 'On' else False) |
244 tabtheme = settings.get('TabTheme') #This change is stable. TaS. | |
241 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedColorful", tabtheme == 'slanted&colorful') | 245 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedColorful", tabtheme == 'slanted&colorful') |
242 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedBlackandWhite", tabtheme == 'slanted&bw') | 246 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedBlackandWhite", tabtheme == 'slanted&bw') |
243 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedAqua", tabtheme == 'slanted&aqua') | 247 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedAqua", tabtheme == 'slanted&aqua') |
244 self.mainmenu.SetMenuState("OpenRPGTabStylesFlatBlackandWhite", tabtheme == 'flat&bw') | 248 self.mainmenu.SetMenuState("OpenRPGTabStylesFlatBlackandWhite", tabtheme == 'flat&bw') |
245 self.mainmenu.SetMenuState("OpenRPGTabStylesFlatAqua", tabtheme == 'flat&aqua') | 249 self.mainmenu.SetMenuState("OpenRPGTabStylesFlatAqua", tabtheme == 'flat&aqua') |
246 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedCustom", tabtheme == 'customslant') | 250 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedCustom", tabtheme == 'customslant') |
247 self.mainmenu.SetMenuState("OpenRPGTabStylesFlatCustom", tabtheme == 'customflat') | 251 self.mainmenu.SetMenuState("OpenRPGTabStylesFlatCustom", tabtheme == 'customflat') |
248 | 252 |
249 lvl = int(settings.get_setting('LoggingLevel')) | 253 lvl = int(settings.get('LoggingLevel')) |
250 if lvl & ORPG_DEBUG: self.mainmenu.SetMenuState("ToolsLoggingLevelDebug", True) | 254 if lvl & ORPG_DEBUG: self.mainmenu.SetMenuState("ToolsLoggingLevelDebug", True) |
251 if lvl & ORPG_DEBUG: self.mainmenu.SetMenuState("ToolsLoggingLevelNote", True) | 255 if lvl & ORPG_DEBUG: self.mainmenu.SetMenuState("ToolsLoggingLevelNote", True) |
252 if lvl & ORPG_INFO: self.mainmenu.SetMenuState("ToolsLoggingLevelInfo", True) | 256 if lvl & ORPG_INFO: self.mainmenu.SetMenuState("ToolsLoggingLevelInfo", True) |
253 if lvl & ORPG_GENERAL: self.mainmenu.SetMenuState("ToolsLoggingLevelGeneral", True) | 257 if lvl & ORPG_GENERAL: self.mainmenu.SetMenuState("ToolsLoggingLevelGeneral", True) |
254 | 258 |
262 | 266 |
263 # Traipse Suite of Additions. | 267 # Traipse Suite of Additions. |
264 self.traipseSuite = wx.Menu() | 268 self.traipseSuite = wx.Menu() |
265 self.mainmenu.Insert(5, self.traipseSuite, "&Traipse Suite") | 269 self.mainmenu.Insert(5, self.traipseSuite, "&Traipse Suite") |
266 | 270 |
271 #Update Manager | |
267 mana = wx.MenuItem(self.traipseSuite, wx.ID_ANY, "Update Manager", "Update Manager") | 272 mana = wx.MenuItem(self.traipseSuite, wx.ID_ANY, "Update Manager", "Update Manager") |
268 self.Bind(wx.EVT_MENU, self.OnMB_UpdateManagerPanel, mana) | 273 self.Bind(wx.EVT_MENU, self.OnMB_UpdateManagerPanel, mana) |
269 self.traipseSuite.AppendItem(mana) | 274 self.traipseSuite.AppendItem(mana) |
270 | 275 |
271 self.debugConsole = wx.MenuItem(self.traipseSuite, -1, "Debug Console", "Debug Console") | 276 self.debugConsole = wx.MenuItem(self.traipseSuite, -1, "Debug Console", "Debug Console") |
273 self.traipseSuite.AppendItem(self.debugConsole) | 278 self.traipseSuite.AppendItem(self.debugConsole) |
274 | 279 |
275 def TraipseSuiteWarn(self, menuitem): | 280 def TraipseSuiteWarn(self, menuitem): |
276 ### Beta ### Allows for the reuse of the 'Attention' menu. | 281 ### Beta ### Allows for the reuse of the 'Attention' menu. |
277 ### component.get('frame').TraipseSuiteWarn('item') ### Portable | 282 ### component.get('frame').TraipseSuiteWarn('item') ### Portable |
278 self.mainmenu.Replace(8, self.traipseSuite, '&Traipse Suite!') | 283 self.mainmenu.Remove(8) |
284 self.mainmenu.Insert(8, self.traipseSuite, "&Traipse Suite!") | |
285 #self.mainmenu.Replace(8, self.traipseSuite, '&Traipse Suite!') | |
279 if menuitem == 'debug': | 286 if menuitem == 'debug': |
280 if self.debugger.IsShown() == True: | 287 if self.debugger.IsShown() == True: |
281 self.mainmenu.Replace(8, self.traipseSuite, '&Traipse Suite') | 288 self.mainmenu.Replace(8, self.traipseSuite, '&Traipse Suite') |
282 else: | 289 else: |
283 self.debugConsole.SetBitmap(wx.Bitmap(dir_struct["icon"] + 'spotlight.png')) | 290 self.debugConsole.SetBitmap(wx.Bitmap(dir_struct["icon"] + 'spotlight.png')) |
285 self.traipseSuite.AppendItem(self.debugConsole) | 292 self.traipseSuite.AppendItem(self.debugConsole) |
286 | 293 |
287 def TraipseSuiteWarnCleanup(self, menuitem): | 294 def TraipseSuiteWarnCleanup(self, menuitem): |
288 ### Beta ### Allows for portable cleanup of the 'Attention' menu. | 295 ### Beta ### Allows for portable cleanup of the 'Attention' menu. |
289 ### component.get('frame').TraipseSuiteWarnCleanup('item') ### Portable | 296 ### component.get('frame').TraipseSuiteWarnCleanup('item') ### Portable |
290 self.mainmenu.Replace(8, self.traipseSuite, '&Traipse Suite') | 297 self.mainmenu.Remove(8) |
298 self.mainmenu.Insert(8, self.traipseSuite, "&Traipse Suite") | |
299 #self.mainmenu.Replace(8, self.traipseSuite, '&Traipse Suite') | |
291 if menuitem == 'debug': | 300 if menuitem == 'debug': |
292 self.traipseSuite.RemoveItem(self.debugConsole) | 301 self.traipseSuite.RemoveItem(self.debugConsole) |
293 self.debugConsole.SetBitmap(wx.Bitmap(dir_struct["icon"] + 'clear.gif')) | 302 self.debugConsole.SetBitmap(wx.Bitmap(dir_struct["icon"] + 'clear.gif')) |
294 self.traipseSuite.AppendItem(self.debugConsole) | 303 self.traipseSuite.AppendItem(self.debugConsole) |
295 | 304 |
296 | 305 |
297 ################################# | 306 ################################# |
298 ## All Menu Events | 307 ## All Menu Events |
299 ################################# | 308 ################################# |
300 #Tab Styles Menus | 309 #Tab Styles Menus |
301 @debugging | 310 |
302 def SetTabStyles(self, *args, **kwargs): | 311 def SetTabStyles(self, *args, **kwargs): |
303 | 312 |
304 tabtheme = settings.get_setting('TabTheme') #This change is stable. TaS. | 313 tabtheme = settings.get('TabTheme') #This change is stable. TaS. |
305 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedColorful", tabtheme == 'slanted&colorful') | 314 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedColorful", tabtheme == 'slanted&colorful') |
306 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedBlackandWhite", tabtheme == 'slanted&bw') | 315 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedBlackandWhite", tabtheme == 'slanted&bw') |
307 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedAqua", tabtheme == 'slanted&aqua') | 316 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedAqua", tabtheme == 'slanted&aqua') |
308 self.mainmenu.SetMenuState("OpenRPGTabStylesFlatBlackandWhite", tabtheme == 'flat&bw') | 317 self.mainmenu.SetMenuState("OpenRPGTabStylesFlatBlackandWhite", tabtheme == 'flat&bw') |
309 self.mainmenu.SetMenuState("OpenRPGTabStylesFlatAqua", tabtheme == 'flat&aqua') | 318 self.mainmenu.SetMenuState("OpenRPGTabStylesFlatAqua", tabtheme == 'flat&aqua') |
334 except: pass | 343 except: pass |
335 tabbedwindows = new | 344 tabbedwindows = new |
336 component.add("tabbedWindows", tabbedwindows) | 345 component.add("tabbedWindows", tabbedwindows) |
337 | 346 |
338 #Run though the new list and set the proper styles | 347 #Run though the new list and set the proper styles |
339 tabbg = settings.get_setting('TabBackgroundGradient') | 348 tabbg = settings.get('TabBackgroundGradient') |
340 (red, green, blue) = self.rgb.rgb_tuple(tabbg) | 349 (red, green, blue) = self.rgb.rgb_tuple(tabbg) |
341 | 350 |
342 for wnd in tabbedwindows: | 351 for wnd in tabbedwindows: |
343 style = wnd.GetWindowStyleFlag() | 352 style = wnd.GetWindowStyleFlag() |
344 # remove old tabs style | 353 # remove old tabs style |
350 if graidentTo != None: wnd.SetGradientColourTo(graidentTo) | 359 if graidentTo != None: wnd.SetGradientColourTo(graidentTo) |
351 if graidentFrom != None: wnd.SetGradientColourFrom(graidentFrom) | 360 if graidentFrom != None: wnd.SetGradientColourFrom(graidentFrom) |
352 if textColor != None: wnd.SetNonActiveTabTextColour(textColor) | 361 if textColor != None: wnd.SetNonActiveTabTextColour(textColor) |
353 wnd.Refresh() | 362 wnd.Refresh() |
354 | 363 |
355 @debugging | 364 |
356 def OnMB_OpenRPGNewMap(self): | 365 def OnMB_OpenRPGNewMap(self): |
357 pass #Not Implemented yet! | 366 pass #Not Implemented yet! |
358 | 367 |
359 @debugging | 368 |
360 def OnMB_OpenRPGTabStylesSlantedColorful(self): | 369 def OnMB_OpenRPGTabStylesSlantedColorful(self): |
361 if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedColorful"): | 370 if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedColorful"): |
362 settings.set_setting('TabTheme', 'slanted&colorful') | 371 settings.change('TabTheme', 'slanted&colorful') |
363 self.SetTabStyles("OpenRPGTabStylesSlantedColorful", FNB.FNB_VC8|FNB.FNB_COLORFUL_TABS) | 372 self.SetTabStyles("OpenRPGTabStylesSlantedColorful", FNB.FNB_VC8|FNB.FNB_COLORFUL_TABS) |
364 else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedColorful", True) | 373 else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedColorful", True) |
365 | 374 |
366 @debugging | 375 |
367 def OnMB_OpenRPGTabStylesSlantedBlackandWhite(self): | 376 def OnMB_OpenRPGTabStylesSlantedBlackandWhite(self): |
368 if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedBlackandWhite"): | 377 if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedBlackandWhite"): |
369 settings.set_setting('TabTheme', 'slanted&bw') | 378 settings.change('TabTheme', 'slanted&bw') |
370 self.SetTabStyles("OpenRPGTabStylesSlantedBlackandWhite", | 379 self.SetTabStyles("OpenRPGTabStylesSlantedBlackandWhite", |
371 FNB.FNB_VC8, graidentTo=wx.WHITE, graidentFrom=wx.WHITE, textColor=wx.BLACK) | 380 FNB.FNB_VC8, graidentTo=wx.WHITE, graidentFrom=wx.WHITE, textColor=wx.BLACK) |
372 else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedBlackandWhite", True) | 381 else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedBlackandWhite", True) |
373 | 382 |
374 @debugging | 383 |
375 def OnMB_OpenRPGTabStylesSlantedAqua(self): | 384 def OnMB_OpenRPGTabStylesSlantedAqua(self): |
376 if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedAqua"): | 385 if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedAqua"): |
377 settings.set_setting('TabTheme', 'slanted&aqua') | 386 settings.change('TabTheme', 'slanted&aqua') |
378 self.SetTabStyles("OpenRPGTabStylesSlantedAqua", FNB.FNB_VC8, | 387 self.SetTabStyles("OpenRPGTabStylesSlantedAqua", FNB.FNB_VC8, |
379 graidentTo=wx.Color(0, 128, 255), graidentFrom=wx.WHITE, textColor=wx.BLACK) | 388 graidentTo=wx.Color(0, 128, 255), graidentFrom=wx.WHITE, textColor=wx.BLACK) |
380 else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedAqua", True) | 389 else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedAqua", True) |
381 | 390 |
382 @debugging | 391 |
383 def OnMB_OpenRPGTabStylesSlantedCustom(self): | 392 def OnMB_OpenRPGTabStylesSlantedCustom(self): |
384 if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedCustom"): | 393 if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedCustom"): |
385 settings.set_setting('TabTheme', 'customslant') | 394 settings.change('TabTheme', 'customslant') |
386 gfrom = settings.get_setting('TabGradientFrom') | 395 gfrom = settings.get('TabGradientFrom') |
387 (fred, fgreen, fblue) = self.rgb.rgb_tuple(gfrom) | 396 (fred, fgreen, fblue) = self.rgb.rgb_tuple(gfrom) |
388 gto = settings.get_setting('TabGradientTo') | 397 gto = settings.get('TabGradientTo') |
389 (tored, togreen, toblue) = self.rgb.rgb_tuple(gto) | 398 (tored, togreen, toblue) = self.rgb.rgb_tuple(gto) |
390 tabtext = settings.get_setting('TabTextColor') | 399 tabtext = settings.get('TabTextColor') |
391 (tred, tgreen, tblue) = self.rgb.rgb_tuple(tabtext) | 400 (tred, tgreen, tblue) = self.rgb.rgb_tuple(tabtext) |
392 tabbg = settings.get_setting('TabBackgroundGradient') | 401 tabbg = settings.get('TabBackgroundGradient') |
393 (red, green, blue) = self.rgb.rgb_tuple(tabbg) | 402 (red, green, blue) = self.rgb.rgb_tuple(tabbg) |
394 self.SetTabStyles("OpenRPGTabStylesSlantedCustom", FNB.FNB_VC8, | 403 self.SetTabStyles("OpenRPGTabStylesSlantedCustom", FNB.FNB_VC8, |
395 graidentTo=wx.Color(tored, togreen, toblue), graidentFrom=wx.Color(fred, fgreen, fblue), | 404 graidentTo=wx.Color(tored, togreen, toblue), graidentFrom=wx.Color(fred, fgreen, fblue), |
396 textColor=wx.Color(tred, tgreen, tblue)) | 405 textColor=wx.Color(tred, tgreen, tblue)) |
397 else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedCustom", True) | 406 else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedCustom", True) |
398 | 407 |
399 @debugging | 408 |
400 def OnMB_OpenRPGTabStylesFlatBlackandWhite(self): | 409 def OnMB_OpenRPGTabStylesFlatBlackandWhite(self): |
401 if self.mainmenu.GetMenuState("OpenRPGTabStylesFlatBlackandWhite"): | 410 if self.mainmenu.GetMenuState("OpenRPGTabStylesFlatBlackandWhite"): |
402 settings.set_setting('TabTheme', 'flat&bw') | 411 settings.change('TabTheme', 'flat&bw') |
403 self.SetTabStyles("OpenRPGTabStylesFlatBlackandWhite", FNB.FNB_FANCY_TABS, | 412 self.SetTabStyles("OpenRPGTabStylesFlatBlackandWhite", FNB.FNB_FANCY_TABS, |
404 graidentTo=wx.WHITE, graidentFrom=wx.WHITE, textColor=wx.BLACK) | 413 graidentTo=wx.WHITE, graidentFrom=wx.WHITE, textColor=wx.BLACK) |
405 else: self.mainmenu.SetMenuState("OpenRPGTabStylesFlatBlackandWhite", True) | 414 else: self.mainmenu.SetMenuState("OpenRPGTabStylesFlatBlackandWhite", True) |
406 | 415 |
407 @debugging | 416 |
408 def OnMB_OpenRPGTabStylesFlatAqua(self): | 417 def OnMB_OpenRPGTabStylesFlatAqua(self): |
409 if self.mainmenu.GetMenuState("OpenRPGTabStylesFlatAqua"): | 418 if self.mainmenu.GetMenuState("OpenRPGTabStylesFlatAqua"): |
410 settings.set_setting('TabTheme', 'flat&aqua') | 419 settings.change('TabTheme', 'flat&aqua') |
411 self.SetTabStyles("OpenRPGTabStylesFlatAqua", FNB.FNB_FANCY_TABS, | 420 self.SetTabStyles("OpenRPGTabStylesFlatAqua", FNB.FNB_FANCY_TABS, |
412 graidentTo=wx.Color(0, 128, 255), graidentFrom=wx.WHITE, textColor=wx.BLACK) | 421 graidentTo=wx.Color(0, 128, 255), graidentFrom=wx.WHITE, textColor=wx.BLACK) |
413 else: self.mainmenu.SetMenuState("OpenRPGTabStylesFlatAqua", True) | 422 else: self.mainmenu.SetMenuState("OpenRPGTabStylesFlatAqua", True) |
414 | 423 |
415 @debugging | 424 |
416 def OnMB_OpenRPGTabStylesFlatCustom(self): | 425 def OnMB_OpenRPGTabStylesFlatCustom(self): |
417 if self.mainmenu.GetMenuState("OpenRPGTabStylesFlatCustom"): | 426 if self.mainmenu.GetMenuState("OpenRPGTabStylesFlatCustom"): |
418 settings.set_setting('TabTheme', 'customflat') | 427 settings.change('TabTheme', 'customflat') |
419 gfrom = settings.get_setting('TabGradientFrom') | 428 gfrom = settings.get('TabGradientFrom') |
420 (fred, fgreen, fblue) = self.rgb.rgb_tuple(gfrom) | 429 (fred, fgreen, fblue) = self.rgb.rgb_tuple(gfrom) |
421 gto = settings.get_setting('TabGradientTo') | 430 gto = settings.get('TabGradientTo') |
422 (tored, togreen, toblue) = self.rgb.rgb_tuple(gto) | 431 (tored, togreen, toblue) = self.rgb.rgb_tuple(gto) |
423 tabtext = settings.get_setting('TabTextColor') | 432 tabtext = settings.get('TabTextColor') |
424 (tred, tgreen, tblue) = self.rgb.rgb_tuple(tabtext) | 433 (tred, tgreen, tblue) = self.rgb.rgb_tuple(tabtext) |
425 tabbg = settings.get_setting('TabBackgroundGradient') | 434 tabbg = settings.get('TabBackgroundGradient') |
426 (red, green, blue) = self.rgb.rgb_tuple(tabbg) | 435 (red, green, blue) = self.rgb.rgb_tuple(tabbg) |
427 self.SetTabStyles("OpenRPGTabStylesFlatCustom", FNB.FNB_FANCY_TABS, | 436 self.SetTabStyles("OpenRPGTabStylesFlatCustom", FNB.FNB_FANCY_TABS, |
428 graidentTo=wx.Color(tored, togreen, toblue), graidentFrom=wx.Color(fred, fgreen, fblue), | 437 graidentTo=wx.Color(tored, togreen, toblue), graidentFrom=wx.Color(fred, fgreen, fblue), |
429 textColor=wx.Color(tred, tgreen, tblue)) | 438 textColor=wx.Color(tred, tgreen, tblue)) |
430 else: self.mainmenu.SetMenuState("OpenRPGTabStylesFlatCustom", True) | 439 else: self.mainmenu.SetMenuState("OpenRPGTabStylesFlatCustom", True) |
431 | 440 |
432 #Window Menu | 441 #Window Menu |
433 @debugging | 442 |
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 | 455 |
447 def OnMB_OpenRPGSettings(self): | 456 def OnMB_OpenRPGSettings(self): |
448 dlg = orpg.tools.orpg_settings.orpgSettingsWnd(self) | 457 dlg = orpg.tools.orpg_settings.orpgSettingsWnd(self) |
449 dlg.Centre() | 458 dlg.Centre() |
450 dlg.ShowModal() | 459 dlg.ShowModal() |
451 | 460 |
452 def OnMB_OpenRPGExit(self): | 461 def OnMB_OpenRPGExit(self): |
453 self.OnCloseWindow(0) | 462 self.OnCloseWindow(0) |
454 | 463 |
455 #Game Server Menu | 464 #Game Server Menu |
456 @debugging | 465 |
457 def OnMB_GameServerBrowseServers(self): | 466 def OnMB_GameServerBrowseServers(self): |
458 if self._mgr.GetPane("Browse Server Window").IsShown() == True: self._mgr.GetPane("Browse Server Window").Hide() | 467 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() | 468 else: self._mgr.GetPane("Browse Server Window").Show() |
460 self._mgr.Update() | 469 self._mgr.Update() |
461 | 470 |
462 @debugging | 471 |
463 def OnMB_GameServerServerHeartbeat(self): | 472 def OnMB_GameServerServerHeartbeat(self): |
464 if self.mainmenu.GetMenuState("GameServerServerHeartbeat"): settings.set_setting('Heartbeat', '1') | 473 if self.mainmenu.GetMenuState("GameServerServerHeartbeat"): settings.change('Heartbeat', '1') |
465 else: settings.set_setting('Heartbeat', '0') | 474 else: settings.change('Heartbeat', '0') |
466 | 475 |
467 @debugging | 476 |
468 def OnMB_GameServerStartServer(self): | 477 def OnMB_GameServerStartServer(self): |
469 start_dialog = wx.ProgressDialog( "Server Loading", "Server Loading, Please Wait...", 1, self ) | 478 start_dialog = wx.ProgressDialog( "Server Loading", "Server Loading, Please Wait...", 1, self ) |
470 # Spawn the new process and close the stdout handle from it | 479 # Spawn the new process and close the stdout handle from it |
471 start_dialog.Update( 0 ) | 480 start_dialog.Update( 0 ) |
472 # Adjusted following code to work with win32, can't test for Unix | 481 # Adjusted following code to work with win32, can't test for Unix |
481 start_dialog.Update( 1 ) | 490 start_dialog.Update( 1 ) |
482 start_dialog.Show(False) | 491 start_dialog.Show(False) |
483 start_dialog.Destroy() | 492 start_dialog.Destroy() |
484 | 493 |
485 # Tools Menu | 494 # Tools Menu |
486 @debugging | 495 |
487 def OnMB_PluginControlPanel(self, evt): | 496 def OnMB_PluginControlPanel(self, evt): |
488 if self.pluginsFrame.IsShown() == True: self.pluginsFrame.Hide() | 497 if self.pluginsFrame.IsShown() == True: self.pluginsFrame.Hide() |
489 else: self.pluginsFrame.Show() | 498 else: self.pluginsFrame.Show() |
490 | 499 |
491 @debugging | 500 |
492 def OnMB_UpdateManagerPanel(self, evt): | 501 def OnMB_UpdateManagerPanel(self, evt): |
493 if self.updateMana.IsShown() == True: self.updateMana.Hide() | 502 if self.updateMana.IsShown() == True: self.updateMana.Hide() |
494 else: self.updateMana.Show() | 503 else: self.updateMana.Show() |
495 | 504 |
496 @debugging | 505 |
497 def OnMB_DebugConsole(self, evt): | 506 def OnMB_DebugConsole(self, evt): |
498 self.TraipseSuiteWarnCleanup('debug') ### Beta ### | 507 self.TraipseSuiteWarnCleanup('debug') ### Beta ### |
499 if self.debugger.IsShown() == True: self.debugger.Hide() | 508 if self.debugger.IsShown() == True: self.debugger.Hide() |
500 else: self.debugger.Show() | 509 else: self.debugger.Show() |
501 | 510 |
502 @debugging | 511 |
503 def OnMB_ToolsLoggingLevelDebug(self): | 512 def OnMB_ToolsLoggingLevelDebug(self): |
504 lvl = logger.log_level | 513 lvl = logger.log_level |
505 if self.mainmenu.GetMenuState("ToolsLoggingLevelDebug"): lvl |= ORPG_DEBUG | 514 if self.mainmenu.GetMenuState("ToolsLoggingLevelDebug"): lvl |= ORPG_DEBUG |
506 else: lvl &= ~ORPG_DEBUG | 515 else: lvl &= ~ORPG_DEBUG |
507 logger.log_level = lvl | 516 logger.log_level = lvl |
508 settings.set('LoggingLevel', lvl) | 517 settings.set('LoggingLevel', lvl) |
509 | 518 |
510 @debugging | 519 |
511 def OnMB_ToolsLoggingLevelNote(self): | 520 def OnMB_ToolsLoggingLevelNote(self): |
512 lvl = logger.log_level | 521 lvl = logger.log_level |
513 if self.mainmenu.GetMenuState("ToolsLoggingLevelNote"): lvl |= ORPG_DEBUG | 522 if self.mainmenu.GetMenuState("ToolsLoggingLevelNote"): lvl |= ORPG_DEBUG |
514 else: lvl &= ~ORPG_DEBUG | 523 else: lvl &= ~ORPG_DEBUG |
515 logger.log_level = lvl | 524 logger.log_level = lvl |
516 settings.set('LoggingLevel', lvl) | 525 settings.set('LoggingLevel', lvl) |
517 | 526 |
518 @debugging | 527 |
519 def OnMB_ToolsLoggingLevelInfo(self): | 528 def OnMB_ToolsLoggingLevelInfo(self): |
520 lvl = logger.log_level | 529 lvl = logger.log_level |
521 if self.mainmenu.GetMenuState("ToolsLoggingLevelInfo"): lvl |= ORPG_INFO | 530 if self.mainmenu.GetMenuState("ToolsLoggingLevelInfo"): lvl |= ORPG_INFO |
522 else: lvl &= ~ORPG_INFO | 531 else: lvl &= ~ORPG_INFO |
523 logger.log_level = lvl | 532 logger.log_level = lvl |
524 settings.set('LoggingLevel', lvl) | 533 settings.set('LoggingLevel', lvl) |
525 | 534 |
526 @debugging | 535 |
527 def OnMB_ToolsLoggingLevelGeneral(self): | 536 def OnMB_ToolsLoggingLevelGeneral(self): |
528 lvl = logger.log_level | 537 lvl = logger.log_level |
529 if self.mainmenu.GetMenuState("ToolsLoggingLevelGeneral"): lvl |= ORPG_GENERAL | 538 if self.mainmenu.GetMenuState("ToolsLoggingLevelGeneral"): lvl |= ORPG_GENERAL |
530 else: lvl &= ~ORPG_GENERAL | 539 else: lvl &= ~ORPG_GENERAL |
531 logger.log_level = lvl | 540 logger.log_level = lvl |
532 settings.set('LoggingLevel', lvl) | 541 settings.set('LoggingLevel', lvl) |
533 | 542 |
534 @debugging | 543 |
535 def OnMB_ToolsPasswordManager(self): | 544 def OnMB_ToolsPasswordManager(self): |
536 if self.mainmenu.GetMenuState("ToolsPasswordManager"): self.password_manager.Enable() | 545 if self.mainmenu.GetMenuState("ToolsPasswordManager"): self.password_manager.Enable() |
537 else: self.password_manager.Disable() | 546 else: self.password_manager.Disable() |
538 | 547 |
539 @debugging | 548 |
540 def OnMB_ToolsStatusBar(self): | 549 def OnMB_ToolsStatusBar(self): |
541 if self._mgr.GetPane("Status Window").IsShown() == True: | 550 if self._mgr.GetPane("Status Window").IsShown() == True: |
542 self.mainmenu.SetMenuState("ToolsStatusBar", False) | 551 self.mainmenu.SetMenuState("ToolsStatusBar", False) |
543 self._mgr.GetPane("Status Window").Hide() | 552 self._mgr.GetPane("Status Window").Hide() |
544 else: | 553 else: |
545 self.mainmenu.SetMenuState("ToolsStatusBar", True) | 554 self.mainmenu.SetMenuState("ToolsStatusBar", True) |
546 self._mgr.GetPane("Status Window").Show() | 555 self._mgr.GetPane("Status Window").Show() |
547 self._mgr.Update() | 556 self._mgr.Update() |
548 | 557 |
549 @debugging | 558 |
550 def OnMB_ToolsSoundToolbar(self): | 559 def OnMB_ToolsSoundToolbar(self): |
551 if self._mgr.GetPane("Sound Control Toolbar").IsShown() == True: | 560 if self._mgr.GetPane("Sound Control Toolbar").IsShown() == True: |
552 self.mainmenu.SetMenuState("ToolsSoundToolbar", False) | 561 self.mainmenu.SetMenuState("ToolsSoundToolbar", False) |
553 self._mgr.GetPane("Sound Control Toolbar").Hide() | 562 self._mgr.GetPane("Sound Control Toolbar").Hide() |
554 else: | 563 else: |
555 self.mainmenu.SetMenuState("ToolsSoundToolbar", True) | 564 self.mainmenu.SetMenuState("ToolsSoundToolbar", True) |
556 self._mgr.GetPane("Sound Control Toolbar").Show() | 565 self._mgr.GetPane("Sound Control Toolbar").Show() |
557 self._mgr.Update() | 566 self._mgr.Update() |
558 | 567 |
559 @debugging | 568 |
560 def OnMB_ToolsDiceBar(self): | 569 def OnMB_ToolsDiceBar(self): |
561 if self._mgr.GetPane("Dice Tool Bar").IsShown() == True: | 570 if self._mgr.GetPane("Dice Tool Bar").IsShown() == True: |
562 self.mainmenu.SetMenuState("ToolsDiceBar", False) | 571 self.mainmenu.SetMenuState("ToolsDiceBar", False) |
563 self._mgr.GetPane("Dice Tool Bar").Hide() | 572 self._mgr.GetPane("Dice Tool Bar").Hide() |
564 else: | 573 else: |
565 self.mainmenu.SetMenuState("ToolsDiceBar", True) | 574 self.mainmenu.SetMenuState("ToolsDiceBar", True) |
566 self._mgr.GetPane("Dice Tool Bar").Show() | 575 self._mgr.GetPane("Dice Tool Bar").Show() |
567 self._mgr.Update() | 576 self._mgr.Update() |
568 | 577 |
569 @debugging | 578 |
570 def OnMB_ToolsMapBar(self): | 579 def OnMB_ToolsMapBar(self): |
571 if self._mgr.GetPane("Map Tool Bar").IsShown() == True: | 580 if self._mgr.GetPane("Map Tool Bar").IsShown() == True: |
572 self.mainmenu.SetMenuState("ToolsMapBar", False) | 581 self.mainmenu.SetMenuState("ToolsMapBar", False) |
573 self._mgr.GetPane("Map Tool Bar").Hide() | 582 self._mgr.GetPane("Map Tool Bar").Hide() |
574 else: | 583 else: |
575 self.mainmenu.SetMenuState("ToolsMapBar", True) | 584 self.mainmenu.SetMenuState("ToolsMapBar", True) |
576 self._mgr.GetPane("Map Tool Bar").Show() | 585 self._mgr.GetPane("Map Tool Bar").Show() |
577 self._mgr.Update() | 586 self._mgr.Update() |
578 | 587 |
579 #Help Menu #Needs a custom Dialog because it is ugly on Windows | 588 #Help Menu #Needs a custom Dialog because it is ugly on Windows |
580 @debugging | 589 |
581 def OnMB_HelpAbout(self): | 590 def OnMB_HelpAbout(self): |
582 if self.AboutORPG.IsShown() == True: self.AboutORPG.Hide() | 591 if self.AboutORPG.IsShown() == True: self.AboutORPG.Hide() |
583 else: self.AboutORPG.Show() | 592 else: self.AboutORPG.Show() |
584 | 593 |
585 @debugging | 594 |
586 def OnMB_HelpOnlineUserGuide(self): | 595 def OnMB_HelpOnlineUserGuide(self): |
587 wb = webbrowser.get() | 596 wb = webbrowser.get() |
588 wb.open("http://www.assembla.com/wiki/show/traipse/User_Manual") | 597 wb.open("http://www.assembla.com/wiki/show/traipse/User_Manual") |
589 | 598 |
590 @debugging | 599 |
591 def OnMB_HelpChangeLog(self): | 600 def OnMB_HelpChangeLog(self): |
592 wb = webbrowser.get() | 601 wb = webbrowser.get() |
593 wb.open("http://www.assembla.com/spaces/milestones/index/traipse?spaces_tool_id=Milestones") | 602 wb.open("http://www.assembla.com/spaces/milestones/index/traipse?spaces_tool_id=Milestones") |
594 | 603 |
595 @debugging | 604 |
596 def OnMB_HelpReportaBug(self): | 605 def OnMB_HelpReportaBug(self): |
597 wb = webbrowser.get() | 606 wb = webbrowser.get() |
598 wb.open("http://www.assembla.com/spaces/tickets/index/traipse_dev?spaces_tool_id=Tickets") | 607 wb.open("http://www.assembla.com/spaces/tickets/index/traipse_dev?spaces_tool_id=Tickets") |
599 | 608 |
600 | 609 |
601 ################################# | 610 ################################# |
602 ## Build the GUI | 611 ## Build the GUI |
603 ################################# | 612 ################################# |
604 @debugging | 613 |
605 def build_gui(self): | 614 def build_gui(self): |
606 self.Freeze() | 615 self.Freeze() |
607 self.validate.config_file("layout.xml","default_layout.xml") | 616 self.validate.config_file("layout.xml","default_layout.xml") |
608 | 617 |
609 filename = dir_struct["user"] + "layout.xml" | 618 layout = parse(dir_struct["user"] + "layout.xml") |
610 temp_file = open(filename) | 619 xml_dom = layout.getroot() |
611 txt = temp_file.read() | 620 |
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() | 621 self.windowsmenu = wx.Menu() |
623 self.mainwindows = {} | 622 self.mainwindows = {} |
624 | 623 |
625 # About Window | 624 # About Window |
626 self.AboutORPG = AboutORPG(self) | 625 self.AboutORPG = AboutORPG(self) |
628 #Plugins Window | 627 #Plugins Window |
629 self.pluginsFrame = pluginUI.PluginFrame(self) | 628 self.pluginsFrame = pluginUI.PluginFrame(self) |
630 component.add("plugins", self.get_activeplugins()) | 629 component.add("plugins", self.get_activeplugins()) |
631 component.add("startplugs", self.get_startplugins()) | 630 component.add("startplugs", self.get_startplugins()) |
632 logger.debug("Menu Created") | 631 logger.debug("Menu Created") |
633 h = int(xml_dom.getAttribute("height")) | 632 h = int(xml_dom.get("height")) |
634 w = int(xml_dom.getAttribute("width")) | 633 w = int(xml_dom.get("width")) |
635 posx = int(xml_dom.getAttribute("posx")) | 634 posx = int(xml_dom.get("posx")) |
636 posy = int(xml_dom.getAttribute("posy")) | 635 posy = int(xml_dom.get("posy")) |
637 maximized = int(xml_dom.getAttribute("maximized")) | 636 maximized = int(xml_dom.get("maximized")) |
638 self.SetDimensions(posx, posy, w, h) | 637 self.SetDimensions(posx, posy, w, h) |
639 logger.debug("Dimensions Set") | 638 logger.debug("Dimensions Set") |
640 | 639 |
641 # Update Manager | 640 # Update Manager |
642 self.manifest = manifest.ManifestChanges() | 641 self.manifest = manifest.ManifestChanges() |
643 self.updateMana = upmana.updatemana.updaterFrame(self, | 642 self.updateMana = upmana.updatemana.updaterFrame(self, |
644 "OpenRPG Update Manager Beta 0.8", component, self.manifest, True) | 643 "OpenRPG Update Manager Beta 0.8", component, self.manifest, True) |
645 logger.debug("Menu Created") | 644 logger.debug("Menu Created") |
646 h = int(xml_dom.getAttribute("height")) | 645 h = int(xml_dom.get("height")) |
647 w = int(xml_dom.getAttribute("width")) | 646 w = int(xml_dom.get("width")) |
648 posx = int(xml_dom.getAttribute("posx")) | 647 posx = int(xml_dom.get("posx")) |
649 posy = int(xml_dom.getAttribute("posy")) | 648 posy = int(xml_dom.get("posy")) |
650 maximized = int(xml_dom.getAttribute("maximized")) | 649 maximized = int(xml_dom.get("maximized")) |
651 self.SetDimensions(posx, posy, w, h) | 650 self.SetDimensions(posx, posy, w, h) |
652 logger.debug("Dimensions Set") | 651 logger.debug("Dimensions Set") |
653 | 652 |
654 # Debug Console | 653 # Debug Console |
655 self.debugger = orpg.tools.orpg_log.DebugConsole(self) | 654 self.debugger = orpg.tools.orpg_log.DebugConsole(self) |
656 logger.debug("Menu Created") | 655 logger.debug("Menu Created") |
657 h = int(xml_dom.getAttribute("height")) | 656 h = int(xml_dom.get("height")) |
658 w = int(xml_dom.getAttribute("width")) | 657 w = int(xml_dom.get("width")) |
659 posx = int(xml_dom.getAttribute("posx")) | 658 posx = int(xml_dom.get("posx")) |
660 posy = int(xml_dom.getAttribute("posy")) | 659 posy = int(xml_dom.get("posy")) |
661 maximized = int(xml_dom.getAttribute("maximized")) | 660 maximized = int(xml_dom.get("maximized")) |
662 self.SetDimensions(posx, posy, w, h) | 661 self.SetDimensions(posx, posy, w, h) |
663 logger.debug("Dimensions Set") | 662 logger.debug("Dimensions Set") |
664 | 663 |
665 # Sound Manager | 664 # Sound Manager |
666 self.sound_player = orpg.tools.orpg_sound.orpgSound(self) | 665 self.sound_player = orpg.tools.orpg_sound.orpgSound(self) |
673 wndinfo.Caption("Sound Control Toolbar") | 672 wndinfo.Caption("Sound Control Toolbar") |
674 wndinfo.Float() | 673 wndinfo.Float() |
675 wndinfo.ToolbarPane() | 674 wndinfo.ToolbarPane() |
676 wndinfo.Hide() | 675 wndinfo.Hide() |
677 self._mgr.AddPane(self.sound_player, wndinfo) | 676 self._mgr.AddPane(self.sound_player, wndinfo) |
678 children = xml_dom._get_childNodes() | 677 children = xml_dom.getchildren() |
679 for c in children: self.build_window(c, self) | 678 for c in children: self.build_window(c, self) |
680 | 679 |
681 # status window | 680 # status window |
682 self.status = status_bar(self) | 681 self.status = status_bar(self) |
683 wndinfo = AUI.AuiPaneInfo() | 682 wndinfo = AUI.AuiPaneInfo() |
749 if wx.VERSION_STRING > "2.8": self.Bind(AUI.EVT_AUI_PANE_CLOSE, self.onPaneClose) | 748 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) | 749 else: self.Bind(AUI.EVT_AUI_PANECLOSE, self.onPaneClose) |
751 logger.debug("AUI Bindings Done") | 750 logger.debug("AUI Bindings Done") |
752 | 751 |
753 #Load the layout if one exists | 752 #Load the layout if one exists |
754 layout = xml_dom.getElementsByTagName("DockLayout") | 753 layout = xml_dom.find("DockLayout") |
755 try: | 754 try: |
756 textnode = xml.safe_get_text_node(layout[0]) | 755 self._mgr.LoadPerspective(layout.text) |
757 self._mgr.LoadPerspective(textnode._get_nodeValue()) | |
758 except: pass | 756 except: pass |
759 xml_dom.unlink() | |
760 logger.debug("Perspective Loaded") | 757 logger.debug("Perspective Loaded") |
761 self._mgr.GetPane("Browse Server Window").Hide() | 758 self._mgr.GetPane("Browse Server Window").Hide() |
762 self._mgr.Update() | 759 self._mgr.Update() |
763 self.Maximize(maximized) | 760 self.Maximize(maximized) |
764 logger.debug("GUI is all created") | 761 logger.debug("GUI is all created") |
765 self.Thaw() | 762 self.Thaw() |
766 | 763 |
767 @debugging | 764 |
768 def do_tab_window(self,xml_dom,parent_wnd): | 765 def do_tab_window(self,xml_dom,parent_wnd): |
769 #def do_tab_window(self, etreeEl, parent_wnd): | 766 #def do_tab_window(self, etreeEl, parent_wnd): |
770 # if container window loop through childern and do a recursive call | 767 # if container window loop through childern and do a recursive call |
771 temp_wnd = orpgTabberWnd(parent_wnd, style=FNB.FNB_ALLOW_FOREIGN_DND) | 768 temp_wnd = orpgTabberWnd(parent_wnd, style=FNB.FNB_ALLOW_FOREIGN_DND) |
772 | 769 |
773 children = xml_dom._get_childNodes() | 770 children = xml_dom.getchildren() |
774 for c in children: | 771 for c in children: |
775 wnd = self.build_window(c,temp_wnd) | 772 wnd = self.build_window(c,temp_wnd) |
776 name = c.getAttribute("name") | 773 name = c.get("name") |
777 temp_wnd.AddPage(wnd, name, False) | 774 temp_wnd.AddPage(wnd, name, False) |
778 | 775 |
779 """ | 776 """ |
780 for c in etreeEl.getchildren(): | 777 for c in etreeEl.getchildren(): |
781 wnd = self.build_window(c, temp_wnd) | 778 wnd = self.build_window(c, temp_wnd) |
782 temp_wnd.AddPage(wnd, c.get('name'), False) | 779 temp_wnd.AddPage(wnd, c.get('name'), False) |
783 """ | 780 """ |
784 return temp_wnd | 781 return temp_wnd |
785 | 782 |
786 @debugging | 783 |
787 def build_window(self, xml_dom, parent_wnd): | 784 def build_window(self, xml_dom, parent_wnd): |
788 name = xml_dom._get_nodeName() | 785 name = xml_dom.tag |
789 if name == "DockLayout" or name == "dock": return | 786 if name == "DockLayout" or name == "dock": return |
790 dirc = xml_dom.getAttribute("direction") #should NOT use dir, it is a built in function. | 787 dirc = xml_dom.get("direction") #should NOT use dir, it is a built in function. |
791 pos = xml_dom.getAttribute("pos") | 788 pos = xml_dom.get("pos") |
792 height = xml_dom.getAttribute("height") | 789 height = xml_dom.get("height") |
793 width = xml_dom.getAttribute("width") | 790 width = xml_dom.get("width") |
794 cap = xml_dom.getAttribute("caption") | 791 cap = xml_dom.get("caption") |
795 dockable = xml_dom.getAttribute("dockable") | 792 dockable = xml_dom.get("dockable") |
796 layer = xml_dom.getAttribute("layer") | 793 layer = xml_dom.get("layer") |
797 | 794 |
798 try: layer = int(layer); dockable = int(dockable) | 795 try: layer = int(layer); dockable = int(dockable) |
799 except: layer = 0; dockable = 1 | 796 except: layer = 0; dockable = 1 |
800 | 797 |
801 if name == "tab": temp_wnd = self.do_tab_window(xml_dom, parent_wnd) | 798 if name == "tab": temp_wnd = self.do_tab_window(xml_dom, parent_wnd) |
803 temp_wnd = orpg.mapper.map.map_wnd(parent_wnd, -1) | 800 temp_wnd = orpg.mapper.map.map_wnd(parent_wnd, -1) |
804 self.map = temp_wnd | 801 self.map = temp_wnd |
805 elif name == "tree": | 802 elif name == "tree": |
806 temp_wnd = orpg.gametree.gametree.game_tree(parent_wnd, -1) | 803 temp_wnd = orpg.gametree.gametree.game_tree(parent_wnd, -1) |
807 self.tree = temp_wnd | 804 self.tree = temp_wnd |
808 if settings.get_setting('ColorTree') == '1': | 805 if settings.get('ColorTree') == '1': |
809 self.tree.SetBackgroundColour(settings.get_setting('bgcolor')) | 806 self.tree.SetBackgroundColour(settings.get('bgcolor')) |
810 self.tree.SetForegroundColour(settings.get_setting('textcolor')) | 807 self.tree.SetForegroundColour(settings.get('textcolor')) |
811 else: | 808 else: |
812 self.tree.SetBackgroundColour('white') | 809 self.tree.SetBackgroundColour('white') |
813 self.tree.SetForegroundColour('black') | 810 self.tree.SetForegroundColour('black') |
814 | 811 |
815 elif name == "chat": | 812 elif name == "chat": |
818 self.chat = temp_wnd.MainChatPanel | 815 self.chat = temp_wnd.MainChatPanel |
819 | 816 |
820 elif name == "player": | 817 elif name == "player": |
821 temp_wnd = orpg.player_list.player_list(parent_wnd) | 818 temp_wnd = orpg.player_list.player_list(parent_wnd) |
822 self.players = temp_wnd | 819 self.players = temp_wnd |
823 if settings.get_setting('ColorTree') == '1': | 820 if settings.get('ColorTree') == '1': |
824 self.players.SetBackgroundColour(settings.get_setting('bgcolor')) | 821 self.players.SetBackgroundColour(settings.get('bgcolor')) |
825 self.players.SetForegroundColour(settings.get_setting('textcolor')) | 822 self.players.SetForegroundColour(settings.get('textcolor')) |
826 else: | 823 else: |
827 self.players.SetBackgroundColour('white') | 824 self.players.SetBackgroundColour('white') |
828 self.players.SetForegroundColour('black') | 825 self.players.SetForegroundColour('black') |
829 | 826 |
830 if parent_wnd != self: return temp_wnd | 827 if parent_wnd != self: return temp_wnd |
855 wndinfo.Position(int(pos)) | 852 wndinfo.Position(int(pos)) |
856 wndinfo.Show() | 853 wndinfo.Show() |
857 self._mgr.AddPane(temp_wnd, wndinfo) | 854 self._mgr.AddPane(temp_wnd, wndinfo) |
858 return temp_wnd | 855 return temp_wnd |
859 | 856 |
860 @debugging | 857 |
861 def onPaneClose(self, evt): | 858 def onPaneClose(self, evt): |
862 pane = evt.GetPane() | 859 pane = evt.GetPane() |
863 #Arbitrary If ELIF fix. Items had incorrect ID's set. Finding correct ID will fix it for the iteration. | 860 #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. | 861 #Adding ID also fixed docking. Go figure. |
865 if pane.name == 'Sound Control Toolbar': self.mainmenu.SetMenuState('ToolsSoundToolbar', False) | 862 if pane.name == 'Sound Control Toolbar': self.mainmenu.SetMenuState('ToolsSoundToolbar', False) |
871 #print pane.name, wname, wndid | 868 #print pane.name, wname, wndid |
872 if pane.name == wname: self.windowsmenu.Check(wndid, False); break | 869 if pane.name == wname: self.windowsmenu.Check(wndid, False); break |
873 evt.Skip() | 870 evt.Skip() |
874 self._mgr.Update() | 871 self._mgr.Update() |
875 | 872 |
876 @debugging | 873 |
877 def saveLayout(self): | 874 def saveLayout(self): |
878 filename = dir_struct["user"] + "layout.xml" | 875 filename = dir_struct["user"] + "layout.xml" |
879 temp_file = open(filename) | 876 layout = parse(filename) |
880 txt = temp_file.read() | 877 xml_dom = layout.getroot() |
881 xml_dom = xml.parseXml(txt)._get_documentElement() | |
882 temp_file.close() | |
883 (x_size,y_size) = self.GetClientSize() | 878 (x_size,y_size) = self.GetClientSize() |
884 (x_pos,y_pos) = self.GetPositionTuple() | 879 (x_pos,y_pos) = self.GetPositionTuple() |
885 if self.IsMaximized(): max = 1 | 880 if self.IsMaximized(): max = 1 |
886 else: max = 0 | 881 else: max = 0 |
887 xml_dom.setAttribute("height", str(y_size)) | 882 xml_dom.set("height", str(y_size)) |
888 xml_dom.setAttribute("width", str(x_size)) | 883 xml_dom.set("width", str(x_size)) |
889 xml_dom.setAttribute("posx", str(x_pos)) | 884 xml_dom.set("posx", str(x_pos)) |
890 xml_dom.setAttribute("posy", str(y_pos)) | 885 xml_dom.set("posy", str(y_pos)) |
891 xml_dom.setAttribute("maximized", str(max)) | 886 xml_dom.set("maximized", str(max)) |
892 layout = xml_dom.getElementsByTagName("DockLayout") | |
893 try: | 887 try: |
894 textnode = xml.safe_get_text_node(layout[0]) | 888 xml_dom.find("DockLayout").text = str(self._mgr.SavePerspective()) |
895 textnode._set_nodeValue(str(self._mgr.SavePerspective())) | |
896 except: | 889 except: |
897 elem = minidom.Element('DockLayout') | 890 elem = Element('DockLayout') |
898 elem.setAttribute("DO_NO_EDIT","True") | 891 elem.set("DO_NO_EDIT","True") |
899 textnode = xml.safe_get_text_node(elem) | 892 elem.text = str(self._mgr.SavePerspective()) |
900 textnode._set_nodeValue(str(self._mgr.SavePerspective())) | 893 xml_dom.append(elem) |
901 xml_dom.appendChild(elem) | 894 |
895 layout.write(filename) | |
896 """ | |
902 temp_file = open(filename, "w") | 897 temp_file = open(filename, "w") |
903 temp_file.write(xml_dom.toxml(1)) | 898 temp_file.write(tostring(xml_dom)) |
904 temp_file.close() | 899 temp_file.close()""" |
905 | 900 |
906 @debugging | 901 |
907 def build_hotkeys(self): | 902 def build_hotkeys(self): |
908 self.mainmenu.accel.xaccel.extend(self.chat.get_hot_keys()) | 903 self.mainmenu.accel.xaccel.extend(self.chat.get_hot_keys()) |
909 self.mainmenu.accel.xaccel.extend(self.map.get_hot_keys()) | 904 self.mainmenu.accel.xaccel.extend(self.map.get_hot_keys()) |
910 | 905 |
911 @debugging | 906 |
912 def start_timer(self): | 907 def start_timer(self): |
913 self.poll_timer.Start(100) | 908 self.poll_timer.Start(100) |
914 s = component.get('settings') | 909 s = component.get('settings') |
915 if s.get_setting("Heartbeat") == "1": | 910 if s.get("Heartbeat") == "1": |
916 self.ping_timer.Start(1000*60) | 911 self.ping_timer.Start(1000*60) |
917 logger.debug("starting heartbeat...", True) | 912 logger.debug("starting heartbeat...", True) |
918 | 913 |
919 @debugging | 914 |
920 def kill_mplay_session(self): | 915 def kill_mplay_session(self): |
921 self.game_name = "" | 916 self.game_name = "" |
922 self.session.start_disconnect() | 917 self.session.start_disconnect() |
923 | 918 |
924 @debugging | 919 |
925 def quit_game(self, evt): | 920 def quit_game(self, evt): |
926 dlg = wx.MessageDialog(self,"Exit gaming session?","Game Session",wx.YES_NO) | 921 dlg = wx.MessageDialog(self,"Exit gaming session?","Game Session",wx.YES_NO) |
927 if dlg.ShowModal() == wx.ID_YES: | 922 if dlg.ShowModal() == wx.ID_YES: |
928 self.session.exitCondition.notifyAll() | 923 self.session.exitCondition.notifyAll() |
929 dlg.Destroy() | 924 dlg.Destroy() |
930 self.kill_mplay_session() | 925 self.kill_mplay_session() |
931 | 926 |
932 @debugging | 927 |
933 def on_status_event(self, evt): | 928 def on_status_event(self, evt): |
934 id = evt.get_id() | 929 id = evt.get_id() |
935 status = evt.get_data() | 930 status = evt.get_data() |
936 if id == orpg.networking.mplay_client.STATUS_SET_URL: self.status.set_url(status) | 931 if id == orpg.networking.mplay_client.STATUS_SET_URL: self.status.set_url(status) |
937 | 932 |
938 @debugging | 933 |
939 def on_player_event(self, evt): | 934 def on_player_event(self, evt): |
940 id = evt.get_id() | 935 id = evt.get_id() |
941 player = evt.get_data() | 936 player = evt.get_data() |
942 display_name = self.chat.chat_display_name(player) | 937 display_name = self.chat.chat_display_name(player) |
943 time_str = time.strftime("%H:%M", time.localtime()) | 938 time_str = time.strftime("%H:%M", time.localtime()) |
949 self.chat.InfoPost(display_name + " (exit): " + time_str) | 944 self.chat.InfoPost(display_name + " (exit): " + time_str) |
950 elif id == orpg.networking.mplay_client.PLAYER_UPDATE: | 945 elif id == orpg.networking.mplay_client.PLAYER_UPDATE: |
951 self.players.update_player(player) | 946 self.players.update_player(player) |
952 self.players.Refresh() | 947 self.players.Refresh() |
953 | 948 |
954 @debugging | 949 |
955 def on_group_event(self, evt): | 950 def on_group_event(self, evt): |
956 id = evt.get_id() | 951 id = evt.get_id() |
957 data = evt.get_data() | 952 data = evt.get_data() |
958 if id == orpg.networking.mplay_client.GROUP_NEW: self.gs.add_room(data) | 953 if id == orpg.networking.mplay_client.GROUP_NEW: self.gs.add_room(data) |
959 elif id == orpg.networking.mplay_client.GROUP_DEL: | 954 elif id == orpg.networking.mplay_client.GROUP_DEL: |
960 self.password_manager.RemoveGroupData(data) | 955 # self.password_manager.RemoveGroupData(data) #Removed for debugging. |
961 self.gs.del_room(data) | 956 self.gs.del_room(data) |
962 elif id == orpg.networking.mplay_client.GROUP_UPDATE: self.gs.update_room(data) | 957 elif id == orpg.networking.mplay_client.GROUP_UPDATE: self.gs.update_room(data) |
963 | 958 |
964 @debugging | 959 |
965 def on_receive(self, data, player): | 960 def on_receive(self, data, player): |
966 # see if we are ignoring this user | 961 # see if we are ignoring this user |
967 (ignore_id,ignore_name) = self.session.get_ignore_list() | 962 (ignore_id, ignore_name) = self.session.get_ignore_list() |
968 for m in ignore_id: | 963 for m in ignore_id: |
969 if m == player[2]: logger.debug("ignoring message from player:" + player[0], True); return | 964 if m == player[2]: logger.debug("ignoring message from player:" + player[0], True); return |
970 | 965 |
971 # ok we are not ignoring this message | 966 # ok we are not ignoring this message |
972 #recvSound = "RecvSound" # this will be the default sound. Whisper will change this below | 967 #recvSound = "RecvSound" # this will be the default sound. Whisper will change this below |
968 | |
969 ### Alpha ### | |
970 etreeEl = Element('msg') | |
971 try: etreeEl.append(fromstring(data)) | |
972 except: etreeEl.text = data | |
973 ### Remove after Element Tree is integrated further ### | |
973 if player: display_name = self.chat.chat_display_name(player) | 974 if player: display_name = self.chat.chat_display_name(player) |
974 else: display_name = "Server Administrator" | 975 else: display_name = "Server Administrator" |
975 | 976 |
976 if data[:5] == "<tree": | 977 if etreeEl.text: self.chat.Post(etreeEl.text) |
977 self.tree.on_receive_data(data,player) | 978 |
978 self.chat.InfoPost(display_name + " has sent you a tree node...") | 979 for child in etreeEl.getchildren(): |
979 | 980 if child.tag == 'tree': |
980 elif data[:4] == "<map": self.map.new_data(data) | 981 ### Alpha ### Allows users to decide if they want the node or not. |
981 | 982 dlg = wx.MessageDialog(None, display_name + ' is trying to send you a tree node. Accept?', 'Question', |
982 elif data[:5] == "<chat": | 983 wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION) |
983 msg = orpg.chat.chat_msg.chat_msg(data) | 984 if dlg.ShowModal() == wx.ID_YES: |
984 self.chat.post_incoming_msg(msg,player) | 985 dlg.Destroy() |
985 else: | 986 debug(child) |
986 """ | 987 self.tree.on_receive_data(tostring(child)) #Removed player object because it was unused. |
987 all this below code is for comptiablity with older clients and can | 988 self.chat.InfoPost(display_name + " has sent you a tree node...") |
988 be removed after a bit | 989 elif child.tag == 'map': |
989 """ | 990 #TODO: Fix map to accepts elements |
990 import warnings | 991 self.map.new_data(tostring(child)) |
991 warnings.warn("Getting here is bad, find out how and fix it", | 992 elif child.tag == 'chat': |
992 DeprecationWarning, 2) | 993 msg = orpg.chat.chat_msg.chat_msg(tostring(child)) |
993 if data[:3] == "/me": | 994 self.chat.post_incoming_msg(msg, player) |
994 """ | 995 |
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): | 996 def on_mplay_event(self, evt): |
1038 id = evt.get_id() | 997 id = evt.get_id() |
1039 if id == orpg.networking.mplay_client.MPLAY_CONNECTED: | 998 if id == orpg.networking.mplay_client.MPLAY_CONNECTED: |
1040 self.chat.InfoPost("Game connected!") | 999 self.chat.InfoPost("Game connected!") |
1041 self.gs.set_connected(1) | 1000 self.gs.set_connected(1) |
1050 self.status.set_connect_status("Not Connected") | 1009 self.status.set_connect_status("Not Connected") |
1051 | 1010 |
1052 ####Begin changes for Custom Exit Message by mDuo13###### | 1011 ####Begin changes for Custom Exit Message by mDuo13###### |
1053 elif id == orpg.networking.mplay_client.MPLAY_DISCONNECTING: | 1012 elif id == orpg.networking.mplay_client.MPLAY_DISCONNECTING: |
1054 settings = component.get('settings') | 1013 settings = component.get('settings') |
1055 custom_msg = settings.get_setting("dcmsg") | 1014 custom_msg = settings.get("dcmsg") |
1056 custom_msg=custom_msg[:80] | 1015 custom_msg=custom_msg[:80] |
1057 if custom_msg[:3]=="/me": self.chat.send_chat_message(custom_msg[3:], 3) | 1016 if custom_msg[:3]=="/me": self.chat.send_chat_message(custom_msg[3:], 3) |
1058 else: self.chat.system_message(custom_msg) | 1017 else: self.chat.system_message(custom_msg) |
1059 #####End Changes for Custom Exit Message by mDuo13 | 1018 #####End Changes for Custom Exit Message by mDuo13 |
1060 | 1019 |
1061 elif id== orpg.networking.mplay_client.MPLAY_GROUP_CHANGE: | 1020 elif id == orpg.networking.mplay_client.MPLAY_GROUP_CHANGE: |
1062 group = evt.get_data() | 1021 group = evt.get_data() |
1063 self.chat.InfoPost("Moving to room '"+group[1]+"'..") | 1022 self.chat.InfoPost("Moving to room '"+group[1]+"'..") |
1064 if self.gs : self.gs.set_cur_room_text(group[1]) | 1023 if self.gs : self.gs.set_cur_room_text(group[1]) |
1065 self.players.reset() | 1024 self.players.reset() |
1066 elif id== orpg.networking.mplay_client.MPLAY_GROUP_CHANGE_F: | 1025 elif id == orpg.networking.mplay_client.MPLAY_GROUP_CHANGE_F: |
1067 self.chat.SystemPost("Room access denied!") | 1026 self.chat.SystemPost("Room access denied!") |
1068 | 1027 |
1069 @debugging | 1028 |
1070 def OnCloseWindow(self, event): | 1029 def OnCloseWindow(self, event): |
1071 dlg = wx.MessageDialog(self, "Quit OpenRPG?", "OpenRPG", wx.YES_NO) | 1030 dlg = wx.MessageDialog(self, "Quit OpenRPG?", "OpenRPG", wx.YES_NO) |
1072 if dlg.ShowModal() == wx.ID_YES: | 1031 if dlg.ShowModal() == wx.ID_YES: |
1073 dlg.Destroy() | 1032 dlg.Destroy() |
1074 self.closed_confirmed() | 1033 self.closed_confirmed() |
1075 | 1034 |
1076 @debugging | 1035 |
1077 def closed_confirmed(self): | 1036 def closed_confirmed(self): |
1078 self.activeplugins = component.get('plugins') | 1037 self.activeplugins = component.get('plugins') |
1079 self.aliaslib.OnMB_FileSave(None) | 1038 self.aliaslib.OnMB_FileSave(None) |
1080 | 1039 |
1081 #following lines added by mDuo13 | 1040 #following lines added by mDuo13 |
1094 try: self.map.pre_exit_cleanup() | 1053 try: self.map.pre_exit_cleanup() |
1095 except Exception: | 1054 except Exception: |
1096 logger.general("[WARNING] Map error pre_exit_cleanup()", True) | 1055 logger.general("[WARNING] Map error pre_exit_cleanup()", True) |
1097 | 1056 |
1098 try: | 1057 try: |
1099 save_tree = string.upper(settings.get_setting("SaveGameTreeOnExit")) | 1058 save_tree = string.upper(settings.get("SaveGameTreeOnExit")) |
1100 if (save_tree != "0") and (save_tree != "False") and (save_tree != "NO"): | 1059 if (save_tree != "0") and (save_tree != "False") and (save_tree != "NO"): |
1101 self.tree.save_tree(settings.get_setting("gametree")) | 1060 self.tree.save_tree(settings.get("gametree")) |
1102 except Exception: | 1061 except Exception: |
1103 logger.general("[WARNING] Error saving gametree", True) | 1062 logger.general("[WARNING] Error saving gametree", True) |
1104 | 1063 |
1105 if self.session.get_status() == orpg.networking.mplay_client.MPLAY_CONNECTED: self.kill_mplay_session() | 1064 if self.session.get_status() == orpg.networking.mplay_client.MPLAY_CONNECTED: self.kill_mplay_session() |
1106 | 1065 |
1200 | 1159 |
1201 ######################################## | 1160 ######################################## |
1202 ## Application class | 1161 ## Application class |
1203 ######################################## | 1162 ######################################## |
1204 class orpgSplashScreen(wx.SplashScreen): | 1163 class orpgSplashScreen(wx.SplashScreen): |
1205 @debugging | 1164 |
1206 def __init__(self, parent, bitmapfile, duration, callback): | 1165 def __init__(self, parent, bitmapfile, duration, callback): |
1207 wx.SplashScreen.__init__(self, wx.Bitmap(bitmapfile), | 1166 wx.SplashScreen.__init__(self, wx.Bitmap(bitmapfile), |
1208 wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT, duration, None, -1) | 1167 wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT, duration, None, -1) |
1209 self.callback = callback | 1168 self.callback = callback |
1210 self.closing = False | 1169 self.closing = False |
1211 self.Bind(wx.EVT_CLOSE, self.callback) | 1170 self.Bind(wx.EVT_CLOSE, self.callback) |
1212 | 1171 |
1213 class orpgApp(wx.App): | 1172 class orpgApp(wx.App): |
1214 @debugging | 1173 |
1215 def OnInit(self): | 1174 def OnInit(self): |
1216 | |
1217 component.add('log', logger) | 1175 component.add('log', logger) |
1218 component.add('xml', xml) | 1176 component.add('xml', xml) |
1219 component.add('settings', settings) | 1177 component.add('settings', settings) |
1220 component.add('validate', validate) | 1178 component.add('validate', validate) |
1221 component.add("tabbedWindows", []) | 1179 component.add("tabbedWindows", []) |
1222 | 1180 |
1223 logger._set_log_level = int(settings.get_setting('LoggingLevel')) | 1181 #Update Manager |
1224 logger._set_log_to_console(False) | |
1225 | |
1226 self.manifest = manifest.ManifestChanges() | 1182 self.manifest = manifest.ManifestChanges() |
1227 | 1183 |
1228 self.called = False | 1184 self.called = False |
1229 wx.InitAllImageHandlers() | 1185 wx.InitAllImageHandlers() |
1230 self.splash = orpgSplashScreen(None, dir_struct["icon"] + 'splash13.jpg', 3000, self.AfterSplash) | 1186 self.splash = orpgSplashScreen(None, dir_struct["icon"] + 'splash13.jpg', 3000, self.AfterSplash) |
1231 self.Bind(wx.EVT_KEY_DOWN, self.OnKeyPress) | 1187 self.Bind(wx.EVT_KEY_DOWN, self.OnKeyPress) |
1232 self._crust = None | 1188 self._crust = None |
1233 wx.Yield() | 1189 wx.Yield() |
1234 return True | 1190 return True |
1235 | 1191 |
1236 @debugging | 1192 |
1237 def OnKeyPress(self, evt): | 1193 def OnKeyPress(self, evt): |
1238 #Event handler | 1194 #Event handler |
1239 if evt.AltDown() and evt.CmdDown() and evt.KeyCode == ord('I'): self.ShowShell() | 1195 if evt.AltDown() and evt.CmdDown() and evt.KeyCode == ord('I'): self.ShowShell() |
1240 else: evt.Skip() | 1196 else: evt.Skip() |
1241 | 1197 |
1242 @debugging | 1198 |
1243 def ShowShell(self): | 1199 def ShowShell(self): |
1244 #Show the PyCrust window. | 1200 #Show the PyCrust window. |
1245 if not self._crust: | 1201 if not self._crust: |
1246 self._crust = wx.py.crust.CrustFrame(self.GetTopWindow()) | 1202 self._crust = wx.py.crust.CrustFrame(self.GetTopWindow()) |
1247 self._crust.shell.interp.locals['app'] = self | 1203 self._crust.shell.interp.locals['app'] = self |
1248 win = wx.FindWindowAtPointer() | 1204 win = wx.FindWindowAtPointer() |
1249 self._crust.shell.interp.locals['win'] = win | 1205 self._crust.shell.interp.locals['win'] = win |
1250 self._crust.Show() | 1206 self._crust.Show() |
1251 | 1207 |
1252 @debugging | 1208 |
1253 def AfterSplash(self,evt): | 1209 def AfterSplash(self,evt): |
1254 if not self.called: | 1210 if not self.called: |
1255 self.splash.Hide() | 1211 self.splash.Hide() |
1256 self.called = True | 1212 self.called = True |
1257 self.frame = orpgFrame(None, wx.ID_ANY, MENU_TITLE) | 1213 self.frame = orpgFrame(None, wx.ID_ANY, MENU_TITLE) |
1262 #self.frame.show_dlgs() | 1218 #self.frame.show_dlgs() |
1263 self.frame.post_show_init() | 1219 self.frame.post_show_init() |
1264 wx.CallAfter(self.splash.Close) | 1220 wx.CallAfter(self.splash.Close) |
1265 return True | 1221 return True |
1266 | 1222 |
1267 @debugging | 1223 |
1268 def OnExit_CleanUp(self): | 1224 def OnExit_CleanUp(self): |
1269 logger.debug("Preforming cleanup\n") | 1225 logger.debug("Preforming cleanup\n") |
1270 try: del os.environ["OPENRPG_BASE"] | 1226 try: del os.environ["OPENRPG_BASE"] |
1271 except: pass | 1227 except: pass |
1272 try: os.remove(os.environ["OPENRPG_BASE"] + os.sep + 'orpg' + os.sep + 'dirpath' + os.sep + 'approot.py') | 1228 try: os.remove(os.environ["OPENRPG_BASE"] + os.sep + 'orpg' + os.sep + 'dirpath' + os.sep + 'approot.py') |
1273 except: pass | 1229 except: pass |
1274 try: os.remove(os.environ["OPENRPG_BASE"] + os.sep + 'orpg' + os.sep + 'dirpath' + os.sep + 'approot.pyc') | 1230 try: os.remove(os.environ["OPENRPG_BASE"] + os.sep + 'orpg' + os.sep + 'dirpath' + os.sep + 'approot.pyc') |
1275 except: pass | 1231 except: pass |
1276 | 1232 |
1277 @debugging | 1233 |
1278 def OnExit(self): | 1234 def OnExit(self): |
1279 self.OnExit_CleanUp() | 1235 self.OnExit_CleanUp() |
1280 #Exit | 1236 #Exit |
1281 logger.debug("Main Application Exit\n\n") | 1237 logger.debug("Main Application Exit\n\n") |