comparison orpg/main.py @ 124:8827271fbe1b alpha

Traipse Alpha 'OpenRPG' {091001-01} Traipse is a distribution of OpenRPG that is designed to be easy to setup and go. Traipse also makes it easy for developers to work on code without fear of sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the code. 'Ornery-Orc's main goal is to offer more advanced features and enhance the productivity of the user. Update Summary (Cleaning up for Beta) Added Bookmarks Fix to Remote Admin Commands Minor fix to text based Server Fix to Pretty Print, from Core Fix to Splitter Nodes not being created Fix to massive amounts of images loading, from Core Added 'boot' command to remote admin Added confirmation window for sent nodes Minor changes to allow for portability to an OpenSUSE linux OS Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG Zoom Mouse plugin added Images added to Plugin UI Switching to Element Tree Map efficiency, from FlexiRPG Added Status Bar to Update Manager default_manifest.xml renamed to default_upmana.xml Cleaner clode for saved repositories New TrueDebug Class in orpg_log (See documentation for usage) Mercurial's hgweb folder is ported to upmana Happy Halloween!
author sirebral
date Sun, 01 Nov 2009 11:36:14 -0600
parents 9314d63c0941
children e7f990be5075
comparison
equal deleted inserted replaced
123:174658f839c0 124:8827271fbe1b
56 from orpg.dirpath import dir_struct 56 from orpg.dirpath import dir_struct
57 from orpg.dieroller.utils import DiceManager 57 from orpg.dieroller.utils import DiceManager
58 from orpg.tools.orpg_settings import settings 58 from orpg.tools.orpg_settings import settings
59 from orpg.tools.validate import validate 59 from orpg.tools.validate import validate
60 from orpg.tools.passtool import PassTool 60 from orpg.tools.passtool import PassTool
61 from orpg.tools.orpg_log import logger, crash 61 from orpg.tools.orpg_log import logger, crash, debug
62 from orpg.tools.decorators import debugging
63 from orpg.tools.metamenus import MenuBarEx 62 from orpg.tools.metamenus import MenuBarEx
64 63
65 from xml.etree.ElementTree import ElementTree, Element, iselement 64 from xml.etree.ElementTree import ElementTree, Element, parse
66 from xml.etree.ElementTree import fromstring, tostring 65 from xml.etree.ElementTree import fromstring, tostring
67 from orpg.orpg_xml import xml #to be replaced by etree 66 from orpg.orpg_xml import xml #to be replaced by etree
68 67
69 68
70 #################################### 69 ####################################
71 ## Main Frame 70 ## Main Frame
72 #################################### 71 ####################################
73 72
74 73
75 class orpgFrame(wx.Frame): 74 class orpgFrame(wx.Frame):
76 @debugging 75
77 def __init__(self, parent, id, title): 76 def __init__(self, parent, id, title):
78 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)
79 self.validate = component.get("validate") 78 self.validate = component.get("validate")
80 logger.debug("Enter orpgFrame") 79 logger.debug("Enter orpgFrame")
81 self.rgb = orpg.tools.rgbhex.RGBHex() 80 self.rgb = orpg.tools.rgbhex.RGBHex()
141 #Load Debug Console 140 #Load Debug Console
142 component.add('debugconsole', self.debugger) 141 component.add('debugconsole', self.debugger)
143 logger.debug("debugger window") 142 logger.debug("debugger window")
144 self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) 143 self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
145 144
146 @debugging 145
147 def post_show_init(self): 146 def post_show_init(self):
148 """Some Actions need to be done after the main fram is drawn""" 147 """Some Actions need to be done after the main fram is drawn"""
149 self.players.size_cols() 148 self.players.size_cols()
150 149
151 @debugging 150
152 def get_activeplugins(self): 151 def get_activeplugins(self):
153 try: tmp = self.pluginsFrame.get_activeplugins() 152 try: tmp = self.pluginsFrame.get_activeplugins()
154 except: tmp = {} 153 except: tmp = {}
155 return tmp 154 return tmp
156 155
157 @debugging 156
158 def get_startplugins(self): 157 def get_startplugins(self):
159 try: tmp = self.pluginsFrame.get_startplugins() 158 try: tmp = self.pluginsFrame.get_startplugins()
160 except: tmp = {} 159 except: tmp = {}
161 return tmp 160 return tmp
162 161
163 @debugging 162
164 def on_password_signal(self,signal,type,id,data): 163 def on_password_signal(self,signal,type,id,data):
165 try: 164 try:
166 msg = ["DEBUG: password response= ", 165 msg = ["DEBUG: password response= ",
167 str(signal), 166 str(signal),
168 " (T:", 167 " (T:",
180 elif type == "admin": self.password_manager.ClearPassword("admin", int(id)) 179 elif type == "admin": self.password_manager.ClearPassword("admin", int(id))
181 elif type == "room": self.password_manager.ClearPassword("room", int(id)) 180 elif type == "room": self.password_manager.ClearPassword("room", int(id))
182 else: pass 181 else: pass
183 except: traceback.print_exc() 182 except: traceback.print_exc()
184 183
185 @debugging 184
186 def build_menu(self): 185 def build_menu(self):
187 menu = \ 186 menu = \
188 [[ 187 [[
189 ['&OpenRPG'], 188 ['&OpenRPG'],
190 [' &Settings\tCtrl-S'], 189 [' &Settings\tCtrl-S'],
298 297
299 ################################# 298 #################################
300 ## All Menu Events 299 ## All Menu Events
301 ################################# 300 #################################
302 #Tab Styles Menus 301 #Tab Styles Menus
303 @debugging 302
304 def SetTabStyles(self, *args, **kwargs): 303 def SetTabStyles(self, *args, **kwargs):
305 304
306 tabtheme = settings.get('TabTheme') #This change is stable. TaS. 305 tabtheme = settings.get('TabTheme') #This change is stable. TaS.
307 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedColorful", tabtheme == 'slanted&colorful') 306 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedColorful", tabtheme == 'slanted&colorful')
308 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedBlackandWhite", tabtheme == 'slanted&bw') 307 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedBlackandWhite", tabtheme == 'slanted&bw')
352 if graidentTo != None: wnd.SetGradientColourTo(graidentTo) 351 if graidentTo != None: wnd.SetGradientColourTo(graidentTo)
353 if graidentFrom != None: wnd.SetGradientColourFrom(graidentFrom) 352 if graidentFrom != None: wnd.SetGradientColourFrom(graidentFrom)
354 if textColor != None: wnd.SetNonActiveTabTextColour(textColor) 353 if textColor != None: wnd.SetNonActiveTabTextColour(textColor)
355 wnd.Refresh() 354 wnd.Refresh()
356 355
357 @debugging 356
358 def OnMB_OpenRPGNewMap(self): 357 def OnMB_OpenRPGNewMap(self):
359 pass #Not Implemented yet! 358 pass #Not Implemented yet!
360 359
361 @debugging 360
362 def OnMB_OpenRPGTabStylesSlantedColorful(self): 361 def OnMB_OpenRPGTabStylesSlantedColorful(self):
363 if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedColorful"): 362 if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedColorful"):
364 settings.change('TabTheme', 'slanted&colorful') 363 settings.change('TabTheme', 'slanted&colorful')
365 self.SetTabStyles("OpenRPGTabStylesSlantedColorful", FNB.FNB_VC8|FNB.FNB_COLORFUL_TABS) 364 self.SetTabStyles("OpenRPGTabStylesSlantedColorful", FNB.FNB_VC8|FNB.FNB_COLORFUL_TABS)
366 else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedColorful", True) 365 else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedColorful", True)
367 366
368 @debugging 367
369 def OnMB_OpenRPGTabStylesSlantedBlackandWhite(self): 368 def OnMB_OpenRPGTabStylesSlantedBlackandWhite(self):
370 if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedBlackandWhite"): 369 if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedBlackandWhite"):
371 settings.change('TabTheme', 'slanted&bw') 370 settings.change('TabTheme', 'slanted&bw')
372 self.SetTabStyles("OpenRPGTabStylesSlantedBlackandWhite", 371 self.SetTabStyles("OpenRPGTabStylesSlantedBlackandWhite",
373 FNB.FNB_VC8, graidentTo=wx.WHITE, graidentFrom=wx.WHITE, textColor=wx.BLACK) 372 FNB.FNB_VC8, graidentTo=wx.WHITE, graidentFrom=wx.WHITE, textColor=wx.BLACK)
374 else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedBlackandWhite", True) 373 else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedBlackandWhite", True)
375 374
376 @debugging 375
377 def OnMB_OpenRPGTabStylesSlantedAqua(self): 376 def OnMB_OpenRPGTabStylesSlantedAqua(self):
378 if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedAqua"): 377 if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedAqua"):
379 settings.change('TabTheme', 'slanted&aqua') 378 settings.change('TabTheme', 'slanted&aqua')
380 self.SetTabStyles("OpenRPGTabStylesSlantedAqua", FNB.FNB_VC8, 379 self.SetTabStyles("OpenRPGTabStylesSlantedAqua", FNB.FNB_VC8,
381 graidentTo=wx.Color(0, 128, 255), graidentFrom=wx.WHITE, textColor=wx.BLACK) 380 graidentTo=wx.Color(0, 128, 255), graidentFrom=wx.WHITE, textColor=wx.BLACK)
382 else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedAqua", True) 381 else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedAqua", True)
383 382
384 @debugging 383
385 def OnMB_OpenRPGTabStylesSlantedCustom(self): 384 def OnMB_OpenRPGTabStylesSlantedCustom(self):
386 if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedCustom"): 385 if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedCustom"):
387 settings.change('TabTheme', 'customslant') 386 settings.change('TabTheme', 'customslant')
388 gfrom = settings.get('TabGradientFrom') 387 gfrom = settings.get('TabGradientFrom')
389 (fred, fgreen, fblue) = self.rgb.rgb_tuple(gfrom) 388 (fred, fgreen, fblue) = self.rgb.rgb_tuple(gfrom)
396 self.SetTabStyles("OpenRPGTabStylesSlantedCustom", FNB.FNB_VC8, 395 self.SetTabStyles("OpenRPGTabStylesSlantedCustom", FNB.FNB_VC8,
397 graidentTo=wx.Color(tored, togreen, toblue), graidentFrom=wx.Color(fred, fgreen, fblue), 396 graidentTo=wx.Color(tored, togreen, toblue), graidentFrom=wx.Color(fred, fgreen, fblue),
398 textColor=wx.Color(tred, tgreen, tblue)) 397 textColor=wx.Color(tred, tgreen, tblue))
399 else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedCustom", True) 398 else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedCustom", True)
400 399
401 @debugging 400
402 def OnMB_OpenRPGTabStylesFlatBlackandWhite(self): 401 def OnMB_OpenRPGTabStylesFlatBlackandWhite(self):
403 if self.mainmenu.GetMenuState("OpenRPGTabStylesFlatBlackandWhite"): 402 if self.mainmenu.GetMenuState("OpenRPGTabStylesFlatBlackandWhite"):
404 settings.change('TabTheme', 'flat&bw') 403 settings.change('TabTheme', 'flat&bw')
405 self.SetTabStyles("OpenRPGTabStylesFlatBlackandWhite", FNB.FNB_FANCY_TABS, 404 self.SetTabStyles("OpenRPGTabStylesFlatBlackandWhite", FNB.FNB_FANCY_TABS,
406 graidentTo=wx.WHITE, graidentFrom=wx.WHITE, textColor=wx.BLACK) 405 graidentTo=wx.WHITE, graidentFrom=wx.WHITE, textColor=wx.BLACK)
407 else: self.mainmenu.SetMenuState("OpenRPGTabStylesFlatBlackandWhite", True) 406 else: self.mainmenu.SetMenuState("OpenRPGTabStylesFlatBlackandWhite", True)
408 407
409 @debugging 408
410 def OnMB_OpenRPGTabStylesFlatAqua(self): 409 def OnMB_OpenRPGTabStylesFlatAqua(self):
411 if self.mainmenu.GetMenuState("OpenRPGTabStylesFlatAqua"): 410 if self.mainmenu.GetMenuState("OpenRPGTabStylesFlatAqua"):
412 settings.change('TabTheme', 'flat&aqua') 411 settings.change('TabTheme', 'flat&aqua')
413 self.SetTabStyles("OpenRPGTabStylesFlatAqua", FNB.FNB_FANCY_TABS, 412 self.SetTabStyles("OpenRPGTabStylesFlatAqua", FNB.FNB_FANCY_TABS,
414 graidentTo=wx.Color(0, 128, 255), graidentFrom=wx.WHITE, textColor=wx.BLACK) 413 graidentTo=wx.Color(0, 128, 255), graidentFrom=wx.WHITE, textColor=wx.BLACK)
415 else: self.mainmenu.SetMenuState("OpenRPGTabStylesFlatAqua", True) 414 else: self.mainmenu.SetMenuState("OpenRPGTabStylesFlatAqua", True)
416 415
417 @debugging 416
418 def OnMB_OpenRPGTabStylesFlatCustom(self): 417 def OnMB_OpenRPGTabStylesFlatCustom(self):
419 if self.mainmenu.GetMenuState("OpenRPGTabStylesFlatCustom"): 418 if self.mainmenu.GetMenuState("OpenRPGTabStylesFlatCustom"):
420 settings.change('TabTheme', 'customflat') 419 settings.change('TabTheme', 'customflat')
421 gfrom = settings.get('TabGradientFrom') 420 gfrom = settings.get('TabGradientFrom')
422 (fred, fgreen, fblue) = self.rgb.rgb_tuple(gfrom) 421 (fred, fgreen, fblue) = self.rgb.rgb_tuple(gfrom)
430 graidentTo=wx.Color(tored, togreen, toblue), graidentFrom=wx.Color(fred, fgreen, fblue), 429 graidentTo=wx.Color(tored, togreen, toblue), graidentFrom=wx.Color(fred, fgreen, fblue),
431 textColor=wx.Color(tred, tgreen, tblue)) 430 textColor=wx.Color(tred, tgreen, tblue))
432 else: self.mainmenu.SetMenuState("OpenRPGTabStylesFlatCustom", True) 431 else: self.mainmenu.SetMenuState("OpenRPGTabStylesFlatCustom", True)
433 432
434 #Window Menu 433 #Window Menu
435 @debugging 434
436 def OnMB_WindowsMenu(self, event): 435 def OnMB_WindowsMenu(self, event):
437 menuid = event.GetId() 436 menuid = event.GetId()
438 name = self.mainwindows[menuid] 437 name = self.mainwindows[menuid]
439 if name == 'Alias Lib': 438 if name == 'Alias Lib':
440 if self.aliaslib.IsShown(): self.aliaslib.Hide() 439 if self.aliaslib.IsShown(): self.aliaslib.Hide()
443 if self._mgr.GetPane(name).IsShown(): self._mgr.GetPane(name).Hide() 442 if self._mgr.GetPane(name).IsShown(): self._mgr.GetPane(name).Hide()
444 else: self._mgr.GetPane(name).Show() 443 else: self._mgr.GetPane(name).Show()
445 self._mgr.Update() 444 self._mgr.Update()
446 445
447 #OpenRPG Menu 446 #OpenRPG Menu
448 @debugging 447
449 def OnMB_OpenRPGSettings(self): 448 def OnMB_OpenRPGSettings(self):
450 dlg = orpg.tools.orpg_settings.orpgSettingsWnd(self) 449 dlg = orpg.tools.orpg_settings.orpgSettingsWnd(self)
451 dlg.Centre() 450 dlg.Centre()
452 dlg.ShowModal() 451 dlg.ShowModal()
453 452
454 def OnMB_OpenRPGExit(self): 453 def OnMB_OpenRPGExit(self):
455 self.OnCloseWindow(0) 454 self.OnCloseWindow(0)
456 455
457 #Game Server Menu 456 #Game Server Menu
458 @debugging 457
459 def OnMB_GameServerBrowseServers(self): 458 def OnMB_GameServerBrowseServers(self):
460 if self._mgr.GetPane("Browse Server Window").IsShown() == True: self._mgr.GetPane("Browse Server Window").Hide() 459 if self._mgr.GetPane("Browse Server Window").IsShown() == True: self._mgr.GetPane("Browse Server Window").Hide()
461 else: self._mgr.GetPane("Browse Server Window").Show() 460 else: self._mgr.GetPane("Browse Server Window").Show()
462 self._mgr.Update() 461 self._mgr.Update()
463 462
464 @debugging 463
465 def OnMB_GameServerServerHeartbeat(self): 464 def OnMB_GameServerServerHeartbeat(self):
466 if self.mainmenu.GetMenuState("GameServerServerHeartbeat"): settings.change('Heartbeat', '1') 465 if self.mainmenu.GetMenuState("GameServerServerHeartbeat"): settings.change('Heartbeat', '1')
467 else: settings.change('Heartbeat', '0') 466 else: settings.change('Heartbeat', '0')
468 467
469 @debugging 468
470 def OnMB_GameServerStartServer(self): 469 def OnMB_GameServerStartServer(self):
471 start_dialog = wx.ProgressDialog( "Server Loading", "Server Loading, Please Wait...", 1, self ) 470 start_dialog = wx.ProgressDialog( "Server Loading", "Server Loading, Please Wait...", 1, self )
472 # Spawn the new process and close the stdout handle from it 471 # Spawn the new process and close the stdout handle from it
473 start_dialog.Update( 0 ) 472 start_dialog.Update( 0 )
474 # Adjusted following code to work with win32, can't test for Unix 473 # Adjusted following code to work with win32, can't test for Unix
483 start_dialog.Update( 1 ) 482 start_dialog.Update( 1 )
484 start_dialog.Show(False) 483 start_dialog.Show(False)
485 start_dialog.Destroy() 484 start_dialog.Destroy()
486 485
487 # Tools Menu 486 # Tools Menu
488 @debugging 487
489 def OnMB_PluginControlPanel(self, evt): 488 def OnMB_PluginControlPanel(self, evt):
490 if self.pluginsFrame.IsShown() == True: self.pluginsFrame.Hide() 489 if self.pluginsFrame.IsShown() == True: self.pluginsFrame.Hide()
491 else: self.pluginsFrame.Show() 490 else: self.pluginsFrame.Show()
492 491
493 @debugging 492
494 def OnMB_UpdateManagerPanel(self, evt): 493 def OnMB_UpdateManagerPanel(self, evt):
495 if self.updateMana.IsShown() == True: self.updateMana.Hide() 494 if self.updateMana.IsShown() == True: self.updateMana.Hide()
496 else: self.updateMana.Show() 495 else: self.updateMana.Show()
497 496
498 @debugging 497
499 def OnMB_DebugConsole(self, evt): 498 def OnMB_DebugConsole(self, evt):
500 self.TraipseSuiteWarnCleanup('debug') ### Beta ### 499 self.TraipseSuiteWarnCleanup('debug') ### Beta ###
501 if self.debugger.IsShown() == True: self.debugger.Hide() 500 if self.debugger.IsShown() == True: self.debugger.Hide()
502 else: self.debugger.Show() 501 else: self.debugger.Show()
503 502
504 @debugging 503
505 def OnMB_ToolsLoggingLevelDebug(self): 504 def OnMB_ToolsLoggingLevelDebug(self):
506 lvl = logger.log_level 505 lvl = logger.log_level
507 if self.mainmenu.GetMenuState("ToolsLoggingLevelDebug"): lvl |= ORPG_DEBUG 506 if self.mainmenu.GetMenuState("ToolsLoggingLevelDebug"): lvl |= ORPG_DEBUG
508 else: lvl &= ~ORPG_DEBUG 507 else: lvl &= ~ORPG_DEBUG
509 logger.log_level = lvl 508 logger.log_level = lvl
510 settings.set('LoggingLevel', lvl) 509 settings.set('LoggingLevel', lvl)
511 510
512 @debugging 511
513 def OnMB_ToolsLoggingLevelNote(self): 512 def OnMB_ToolsLoggingLevelNote(self):
514 lvl = logger.log_level 513 lvl = logger.log_level
515 if self.mainmenu.GetMenuState("ToolsLoggingLevelNote"): lvl |= ORPG_DEBUG 514 if self.mainmenu.GetMenuState("ToolsLoggingLevelNote"): lvl |= ORPG_DEBUG
516 else: lvl &= ~ORPG_DEBUG 515 else: lvl &= ~ORPG_DEBUG
517 logger.log_level = lvl 516 logger.log_level = lvl
518 settings.set('LoggingLevel', lvl) 517 settings.set('LoggingLevel', lvl)
519 518
520 @debugging 519
521 def OnMB_ToolsLoggingLevelInfo(self): 520 def OnMB_ToolsLoggingLevelInfo(self):
522 lvl = logger.log_level 521 lvl = logger.log_level
523 if self.mainmenu.GetMenuState("ToolsLoggingLevelInfo"): lvl |= ORPG_INFO 522 if self.mainmenu.GetMenuState("ToolsLoggingLevelInfo"): lvl |= ORPG_INFO
524 else: lvl &= ~ORPG_INFO 523 else: lvl &= ~ORPG_INFO
525 logger.log_level = lvl 524 logger.log_level = lvl
526 settings.set('LoggingLevel', lvl) 525 settings.set('LoggingLevel', lvl)
527 526
528 @debugging 527
529 def OnMB_ToolsLoggingLevelGeneral(self): 528 def OnMB_ToolsLoggingLevelGeneral(self):
530 lvl = logger.log_level 529 lvl = logger.log_level
531 if self.mainmenu.GetMenuState("ToolsLoggingLevelGeneral"): lvl |= ORPG_GENERAL 530 if self.mainmenu.GetMenuState("ToolsLoggingLevelGeneral"): lvl |= ORPG_GENERAL
532 else: lvl &= ~ORPG_GENERAL 531 else: lvl &= ~ORPG_GENERAL
533 logger.log_level = lvl 532 logger.log_level = lvl
534 settings.set('LoggingLevel', lvl) 533 settings.set('LoggingLevel', lvl)
535 534
536 @debugging 535
537 def OnMB_ToolsPasswordManager(self): 536 def OnMB_ToolsPasswordManager(self):
538 if self.mainmenu.GetMenuState("ToolsPasswordManager"): self.password_manager.Enable() 537 if self.mainmenu.GetMenuState("ToolsPasswordManager"): self.password_manager.Enable()
539 else: self.password_manager.Disable() 538 else: self.password_manager.Disable()
540 539
541 @debugging 540
542 def OnMB_ToolsStatusBar(self): 541 def OnMB_ToolsStatusBar(self):
543 if self._mgr.GetPane("Status Window").IsShown() == True: 542 if self._mgr.GetPane("Status Window").IsShown() == True:
544 self.mainmenu.SetMenuState("ToolsStatusBar", False) 543 self.mainmenu.SetMenuState("ToolsStatusBar", False)
545 self._mgr.GetPane("Status Window").Hide() 544 self._mgr.GetPane("Status Window").Hide()
546 else: 545 else:
547 self.mainmenu.SetMenuState("ToolsStatusBar", True) 546 self.mainmenu.SetMenuState("ToolsStatusBar", True)
548 self._mgr.GetPane("Status Window").Show() 547 self._mgr.GetPane("Status Window").Show()
549 self._mgr.Update() 548 self._mgr.Update()
550 549
551 @debugging 550
552 def OnMB_ToolsSoundToolbar(self): 551 def OnMB_ToolsSoundToolbar(self):
553 if self._mgr.GetPane("Sound Control Toolbar").IsShown() == True: 552 if self._mgr.GetPane("Sound Control Toolbar").IsShown() == True:
554 self.mainmenu.SetMenuState("ToolsSoundToolbar", False) 553 self.mainmenu.SetMenuState("ToolsSoundToolbar", False)
555 self._mgr.GetPane("Sound Control Toolbar").Hide() 554 self._mgr.GetPane("Sound Control Toolbar").Hide()
556 else: 555 else:
557 self.mainmenu.SetMenuState("ToolsSoundToolbar", True) 556 self.mainmenu.SetMenuState("ToolsSoundToolbar", True)
558 self._mgr.GetPane("Sound Control Toolbar").Show() 557 self._mgr.GetPane("Sound Control Toolbar").Show()
559 self._mgr.Update() 558 self._mgr.Update()
560 559
561 @debugging 560
562 def OnMB_ToolsDiceBar(self): 561 def OnMB_ToolsDiceBar(self):
563 if self._mgr.GetPane("Dice Tool Bar").IsShown() == True: 562 if self._mgr.GetPane("Dice Tool Bar").IsShown() == True:
564 self.mainmenu.SetMenuState("ToolsDiceBar", False) 563 self.mainmenu.SetMenuState("ToolsDiceBar", False)
565 self._mgr.GetPane("Dice Tool Bar").Hide() 564 self._mgr.GetPane("Dice Tool Bar").Hide()
566 else: 565 else:
567 self.mainmenu.SetMenuState("ToolsDiceBar", True) 566 self.mainmenu.SetMenuState("ToolsDiceBar", True)
568 self._mgr.GetPane("Dice Tool Bar").Show() 567 self._mgr.GetPane("Dice Tool Bar").Show()
569 self._mgr.Update() 568 self._mgr.Update()
570 569
571 @debugging 570
572 def OnMB_ToolsMapBar(self): 571 def OnMB_ToolsMapBar(self):
573 if self._mgr.GetPane("Map Tool Bar").IsShown() == True: 572 if self._mgr.GetPane("Map Tool Bar").IsShown() == True:
574 self.mainmenu.SetMenuState("ToolsMapBar", False) 573 self.mainmenu.SetMenuState("ToolsMapBar", False)
575 self._mgr.GetPane("Map Tool Bar").Hide() 574 self._mgr.GetPane("Map Tool Bar").Hide()
576 else: 575 else:
577 self.mainmenu.SetMenuState("ToolsMapBar", True) 576 self.mainmenu.SetMenuState("ToolsMapBar", True)
578 self._mgr.GetPane("Map Tool Bar").Show() 577 self._mgr.GetPane("Map Tool Bar").Show()
579 self._mgr.Update() 578 self._mgr.Update()
580 579
581 #Help Menu #Needs a custom Dialog because it is ugly on Windows 580 #Help Menu #Needs a custom Dialog because it is ugly on Windows
582 @debugging 581
583 def OnMB_HelpAbout(self): 582 def OnMB_HelpAbout(self):
584 if self.AboutORPG.IsShown() == True: self.AboutORPG.Hide() 583 if self.AboutORPG.IsShown() == True: self.AboutORPG.Hide()
585 else: self.AboutORPG.Show() 584 else: self.AboutORPG.Show()
586 585
587 @debugging 586
588 def OnMB_HelpOnlineUserGuide(self): 587 def OnMB_HelpOnlineUserGuide(self):
589 wb = webbrowser.get() 588 wb = webbrowser.get()
590 wb.open("http://www.assembla.com/wiki/show/traipse/User_Manual") 589 wb.open("http://www.assembla.com/wiki/show/traipse/User_Manual")
591 590
592 @debugging 591
593 def OnMB_HelpChangeLog(self): 592 def OnMB_HelpChangeLog(self):
594 wb = webbrowser.get() 593 wb = webbrowser.get()
595 wb.open("http://www.assembla.com/spaces/milestones/index/traipse?spaces_tool_id=Milestones") 594 wb.open("http://www.assembla.com/spaces/milestones/index/traipse?spaces_tool_id=Milestones")
596 595
597 @debugging 596
598 def OnMB_HelpReportaBug(self): 597 def OnMB_HelpReportaBug(self):
599 wb = webbrowser.get() 598 wb = webbrowser.get()
600 wb.open("http://www.assembla.com/spaces/tickets/index/traipse_dev?spaces_tool_id=Tickets") 599 wb.open("http://www.assembla.com/spaces/tickets/index/traipse_dev?spaces_tool_id=Tickets")
601 600
602 601
603 ################################# 602 #################################
604 ## Build the GUI 603 ## Build the GUI
605 ################################# 604 #################################
606 @debugging 605
607 def build_gui(self): 606 def build_gui(self):
608 self.Freeze() 607 self.Freeze()
609 self.validate.config_file("layout.xml","default_layout.xml") 608 self.validate.config_file("layout.xml","default_layout.xml")
610 609
611 filename = dir_struct["user"] + "layout.xml" 610 layout = parse(dir_struct["user"] + "layout.xml")
612 temp_file = open(filename) 611 xml_dom = layout.getroot()
613 txt = temp_file.read() 612
614 xml_dom = xml.parseXml(txt)._get_documentElement()
615 temp_file.close()
616
617 """ Would a component work better?
618 etree = ElementTree()
619 with open(dir_struct['user'] + 'layout.xml') as f:
620 etree.parse(f)
621
622 base = etree.getroot()
623 """
624 self.windowsmenu = wx.Menu() 613 self.windowsmenu = wx.Menu()
625 self.mainwindows = {} 614 self.mainwindows = {}
626 615
627 # About Window 616 # About Window
628 self.AboutORPG = AboutORPG(self) 617 self.AboutORPG = AboutORPG(self)
630 #Plugins Window 619 #Plugins Window
631 self.pluginsFrame = pluginUI.PluginFrame(self) 620 self.pluginsFrame = pluginUI.PluginFrame(self)
632 component.add("plugins", self.get_activeplugins()) 621 component.add("plugins", self.get_activeplugins())
633 component.add("startplugs", self.get_startplugins()) 622 component.add("startplugs", self.get_startplugins())
634 logger.debug("Menu Created") 623 logger.debug("Menu Created")
635 h = int(xml_dom.getAttribute("height")) 624 h = int(xml_dom.get("height"))
636 w = int(xml_dom.getAttribute("width")) 625 w = int(xml_dom.get("width"))
637 posx = int(xml_dom.getAttribute("posx")) 626 posx = int(xml_dom.get("posx"))
638 posy = int(xml_dom.getAttribute("posy")) 627 posy = int(xml_dom.get("posy"))
639 maximized = int(xml_dom.getAttribute("maximized")) 628 maximized = int(xml_dom.get("maximized"))
640 self.SetDimensions(posx, posy, w, h) 629 self.SetDimensions(posx, posy, w, h)
641 logger.debug("Dimensions Set") 630 logger.debug("Dimensions Set")
642 631
643 # Update Manager 632 # Update Manager
644 self.manifest = manifest.ManifestChanges() 633 self.manifest = manifest.ManifestChanges()
645 self.updateMana = upmana.updatemana.updaterFrame(self, 634 self.updateMana = upmana.updatemana.updaterFrame(self,
646 "OpenRPG Update Manager Beta 0.8", component, self.manifest, True) 635 "OpenRPG Update Manager Beta 0.8", component, self.manifest, True)
647 logger.debug("Menu Created") 636 logger.debug("Menu Created")
648 h = int(xml_dom.getAttribute("height")) 637 h = int(xml_dom.get("height"))
649 w = int(xml_dom.getAttribute("width")) 638 w = int(xml_dom.get("width"))
650 posx = int(xml_dom.getAttribute("posx")) 639 posx = int(xml_dom.get("posx"))
651 posy = int(xml_dom.getAttribute("posy")) 640 posy = int(xml_dom.get("posy"))
652 maximized = int(xml_dom.getAttribute("maximized")) 641 maximized = int(xml_dom.get("maximized"))
653 self.SetDimensions(posx, posy, w, h) 642 self.SetDimensions(posx, posy, w, h)
654 logger.debug("Dimensions Set") 643 logger.debug("Dimensions Set")
655 644
656 # Debug Console 645 # Debug Console
657 self.debugger = orpg.tools.orpg_log.DebugConsole(self) 646 self.debugger = orpg.tools.orpg_log.DebugConsole(self)
658 logger.debug("Menu Created") 647 logger.debug("Menu Created")
659 h = int(xml_dom.getAttribute("height")) 648 h = int(xml_dom.get("height"))
660 w = int(xml_dom.getAttribute("width")) 649 w = int(xml_dom.get("width"))
661 posx = int(xml_dom.getAttribute("posx")) 650 posx = int(xml_dom.get("posx"))
662 posy = int(xml_dom.getAttribute("posy")) 651 posy = int(xml_dom.get("posy"))
663 maximized = int(xml_dom.getAttribute("maximized")) 652 maximized = int(xml_dom.get("maximized"))
664 self.SetDimensions(posx, posy, w, h) 653 self.SetDimensions(posx, posy, w, h)
665 logger.debug("Dimensions Set") 654 logger.debug("Dimensions Set")
666 655
667 # Sound Manager 656 # Sound Manager
668 self.sound_player = orpg.tools.orpg_sound.orpgSound(self) 657 self.sound_player = orpg.tools.orpg_sound.orpgSound(self)
675 wndinfo.Caption("Sound Control Toolbar") 664 wndinfo.Caption("Sound Control Toolbar")
676 wndinfo.Float() 665 wndinfo.Float()
677 wndinfo.ToolbarPane() 666 wndinfo.ToolbarPane()
678 wndinfo.Hide() 667 wndinfo.Hide()
679 self._mgr.AddPane(self.sound_player, wndinfo) 668 self._mgr.AddPane(self.sound_player, wndinfo)
680 children = xml_dom._get_childNodes() 669 children = xml_dom.getchildren()
681 for c in children: self.build_window(c, self) 670 for c in children: self.build_window(c, self)
682 671
683 # status window 672 # status window
684 self.status = status_bar(self) 673 self.status = status_bar(self)
685 wndinfo = AUI.AuiPaneInfo() 674 wndinfo = AUI.AuiPaneInfo()
751 if wx.VERSION_STRING > "2.8": self.Bind(AUI.EVT_AUI_PANE_CLOSE, self.onPaneClose) 740 if wx.VERSION_STRING > "2.8": self.Bind(AUI.EVT_AUI_PANE_CLOSE, self.onPaneClose)
752 else: self.Bind(AUI.EVT_AUI_PANECLOSE, self.onPaneClose) 741 else: self.Bind(AUI.EVT_AUI_PANECLOSE, self.onPaneClose)
753 logger.debug("AUI Bindings Done") 742 logger.debug("AUI Bindings Done")
754 743
755 #Load the layout if one exists 744 #Load the layout if one exists
756 layout = xml_dom.getElementsByTagName("DockLayout") 745 layout = xml_dom.findall("DockLayout")
757 try: 746 try:
758 textnode = xml.safe_get_text_node(layout[0]) 747 textnode = xml.safe_get_text_node(layout[0])
759 self._mgr.LoadPerspective(textnode._get_nodeValue()) 748 self._mgr.LoadPerspective(textnode.text)
760 except: pass 749 except: pass
761 xml_dom.unlink()
762 logger.debug("Perspective Loaded") 750 logger.debug("Perspective Loaded")
763 self._mgr.GetPane("Browse Server Window").Hide() 751 self._mgr.GetPane("Browse Server Window").Hide()
764 self._mgr.Update() 752 self._mgr.Update()
765 self.Maximize(maximized) 753 self.Maximize(maximized)
766 logger.debug("GUI is all created") 754 logger.debug("GUI is all created")
767 self.Thaw() 755 self.Thaw()
768 756
769 @debugging 757
770 def do_tab_window(self,xml_dom,parent_wnd): 758 def do_tab_window(self,xml_dom,parent_wnd):
771 #def do_tab_window(self, etreeEl, parent_wnd): 759 #def do_tab_window(self, etreeEl, parent_wnd):
772 # if container window loop through childern and do a recursive call 760 # if container window loop through childern and do a recursive call
773 temp_wnd = orpgTabberWnd(parent_wnd, style=FNB.FNB_ALLOW_FOREIGN_DND) 761 temp_wnd = orpgTabberWnd(parent_wnd, style=FNB.FNB_ALLOW_FOREIGN_DND)
774 762
775 children = xml_dom._get_childNodes() 763 children = xml_dom.getchildren()
776 for c in children: 764 for c in children:
777 wnd = self.build_window(c,temp_wnd) 765 wnd = self.build_window(c,temp_wnd)
778 name = c.getAttribute("name") 766 name = c.get("name")
779 temp_wnd.AddPage(wnd, name, False) 767 temp_wnd.AddPage(wnd, name, False)
780 768
781 """ 769 """
782 for c in etreeEl.getchildren(): 770 for c in etreeEl.getchildren():
783 wnd = self.build_window(c, temp_wnd) 771 wnd = self.build_window(c, temp_wnd)
784 temp_wnd.AddPage(wnd, c.get('name'), False) 772 temp_wnd.AddPage(wnd, c.get('name'), False)
785 """ 773 """
786 return temp_wnd 774 return temp_wnd
787 775
788 @debugging 776
789 def build_window(self, xml_dom, parent_wnd): 777 def build_window(self, xml_dom, parent_wnd):
790 name = xml_dom._get_nodeName() 778 name = xml_dom.tag
791 if name == "DockLayout" or name == "dock": return 779 if name == "DockLayout" or name == "dock": return
792 dirc = xml_dom.getAttribute("direction") #should NOT use dir, it is a built in function. 780 dirc = xml_dom.get("direction") #should NOT use dir, it is a built in function.
793 pos = xml_dom.getAttribute("pos") 781 pos = xml_dom.get("pos")
794 height = xml_dom.getAttribute("height") 782 height = xml_dom.get("height")
795 width = xml_dom.getAttribute("width") 783 width = xml_dom.get("width")
796 cap = xml_dom.getAttribute("caption") 784 cap = xml_dom.get("caption")
797 dockable = xml_dom.getAttribute("dockable") 785 dockable = xml_dom.get("dockable")
798 layer = xml_dom.getAttribute("layer") 786 layer = xml_dom.get("layer")
799 787
800 try: layer = int(layer); dockable = int(dockable) 788 try: layer = int(layer); dockable = int(dockable)
801 except: layer = 0; dockable = 1 789 except: layer = 0; dockable = 1
802 790
803 if name == "tab": temp_wnd = self.do_tab_window(xml_dom, parent_wnd) 791 if name == "tab": temp_wnd = self.do_tab_window(xml_dom, parent_wnd)
857 wndinfo.Position(int(pos)) 845 wndinfo.Position(int(pos))
858 wndinfo.Show() 846 wndinfo.Show()
859 self._mgr.AddPane(temp_wnd, wndinfo) 847 self._mgr.AddPane(temp_wnd, wndinfo)
860 return temp_wnd 848 return temp_wnd
861 849
862 @debugging 850
863 def onPaneClose(self, evt): 851 def onPaneClose(self, evt):
864 pane = evt.GetPane() 852 pane = evt.GetPane()
865 #Arbitrary If ELIF fix. Items had incorrect ID's set. Finding correct ID will fix it for the iteration. 853 #Arbitrary If ELIF fix. Items had incorrect ID's set. Finding correct ID will fix it for the iteration.
866 #Adding ID also fixed docking. Go figure. 854 #Adding ID also fixed docking. Go figure.
867 if pane.name == 'Sound Control Toolbar': self.mainmenu.SetMenuState('ToolsSoundToolbar', False) 855 if pane.name == 'Sound Control Toolbar': self.mainmenu.SetMenuState('ToolsSoundToolbar', False)
873 #print pane.name, wname, wndid 861 #print pane.name, wname, wndid
874 if pane.name == wname: self.windowsmenu.Check(wndid, False); break 862 if pane.name == wname: self.windowsmenu.Check(wndid, False); break
875 evt.Skip() 863 evt.Skip()
876 self._mgr.Update() 864 self._mgr.Update()
877 865
878 @debugging 866
879 def saveLayout(self): 867 def saveLayout(self):
880 filename = dir_struct["user"] + "layout.xml" 868 layout = parse(dir_struct["user"] + "layout.xml")
881 temp_file = open(filename) 869 xml_dom = layout.getroot()
882 txt = temp_file.read()
883 xml_dom = xml.parseXml(txt)._get_documentElement()
884 temp_file.close()
885 (x_size,y_size) = self.GetClientSize() 870 (x_size,y_size) = self.GetClientSize()
886 (x_pos,y_pos) = self.GetPositionTuple() 871 (x_pos,y_pos) = self.GetPositionTuple()
887 if self.IsMaximized(): max = 1 872 if self.IsMaximized(): max = 1
888 else: max = 0 873 else: max = 0
889 xml_dom.setAttribute("height", str(y_size)) 874 xml_dom.set("height", str(y_size))
890 xml_dom.setAttribute("width", str(x_size)) 875 xml_dom.set("width", str(x_size))
891 xml_dom.setAttribute("posx", str(x_pos)) 876 xml_dom.set("posx", str(x_pos))
892 xml_dom.setAttribute("posy", str(y_pos)) 877 xml_dom.set("posy", str(y_pos))
893 xml_dom.setAttribute("maximized", str(max)) 878 xml_dom.set("maximized", str(max))
894 layout = xml_dom.getElementsByTagName("DockLayout") 879 layout = xml_dom.findall("DockLayout")
895 try: 880 try:
896 textnode = xml.safe_get_text_node(layout[0]) 881 textnode = xml.safe_get_text_node(layout[0])
897 textnode._set_nodeValue(str(self._mgr.SavePerspective())) 882 textnode._set_nodeValue(str(self._mgr.SavePerspective()))
898 except: 883 except:
899 elem = minidom.Element('DockLayout') 884 elem = minidom.Element('DockLayout')
900 elem.setAttribute("DO_NO_EDIT","True") 885 elem.set("DO_NO_EDIT","True")
901 textnode = xml.safe_get_text_node(elem) 886 textnode = xml.safe_get_text_node(elem)
902 textnode._set_nodeValue(str(self._mgr.SavePerspective())) 887 textnode._set_nodeValue(str(self._mgr.SavePerspective()))
903 xml_dom.appendChild(elem) 888 xml_dom.append(elem)
904 temp_file = open(filename, "w") 889 temp_file = open(filename, "w")
905 temp_file.write(xml_dom.toxml(1)) 890 temp_file.write(xml_dom.toxml(1))
906 temp_file.close() 891 temp_file.close()
907 892
908 @debugging 893
909 def build_hotkeys(self): 894 def build_hotkeys(self):
910 self.mainmenu.accel.xaccel.extend(self.chat.get_hot_keys()) 895 self.mainmenu.accel.xaccel.extend(self.chat.get_hot_keys())
911 self.mainmenu.accel.xaccel.extend(self.map.get_hot_keys()) 896 self.mainmenu.accel.xaccel.extend(self.map.get_hot_keys())
912 897
913 @debugging 898
914 def start_timer(self): 899 def start_timer(self):
915 self.poll_timer.Start(100) 900 self.poll_timer.Start(100)
916 s = component.get('settings') 901 s = component.get('settings')
917 if s.get("Heartbeat") == "1": 902 if s.get("Heartbeat") == "1":
918 self.ping_timer.Start(1000*60) 903 self.ping_timer.Start(1000*60)
919 logger.debug("starting heartbeat...", True) 904 logger.debug("starting heartbeat...", True)
920 905
921 @debugging 906
922 def kill_mplay_session(self): 907 def kill_mplay_session(self):
923 self.game_name = "" 908 self.game_name = ""
924 self.session.start_disconnect() 909 self.session.start_disconnect()
925 910
926 @debugging 911
927 def quit_game(self, evt): 912 def quit_game(self, evt):
928 dlg = wx.MessageDialog(self,"Exit gaming session?","Game Session",wx.YES_NO) 913 dlg = wx.MessageDialog(self,"Exit gaming session?","Game Session",wx.YES_NO)
929 if dlg.ShowModal() == wx.ID_YES: 914 if dlg.ShowModal() == wx.ID_YES:
930 self.session.exitCondition.notifyAll() 915 self.session.exitCondition.notifyAll()
931 dlg.Destroy() 916 dlg.Destroy()
932 self.kill_mplay_session() 917 self.kill_mplay_session()
933 918
934 @debugging 919
935 def on_status_event(self, evt): 920 def on_status_event(self, evt):
936 id = evt.get_id() 921 id = evt.get_id()
937 status = evt.get_data() 922 status = evt.get_data()
938 if id == orpg.networking.mplay_client.STATUS_SET_URL: self.status.set_url(status) 923 if id == orpg.networking.mplay_client.STATUS_SET_URL: self.status.set_url(status)
939 924
940 @debugging 925
941 def on_player_event(self, evt): 926 def on_player_event(self, evt):
942 id = evt.get_id() 927 id = evt.get_id()
943 player = evt.get_data() 928 player = evt.get_data()
944 display_name = self.chat.chat_display_name(player) 929 display_name = self.chat.chat_display_name(player)
945 time_str = time.strftime("%H:%M", time.localtime()) 930 time_str = time.strftime("%H:%M", time.localtime())
951 self.chat.InfoPost(display_name + " (exit): " + time_str) 936 self.chat.InfoPost(display_name + " (exit): " + time_str)
952 elif id == orpg.networking.mplay_client.PLAYER_UPDATE: 937 elif id == orpg.networking.mplay_client.PLAYER_UPDATE:
953 self.players.update_player(player) 938 self.players.update_player(player)
954 self.players.Refresh() 939 self.players.Refresh()
955 940
956 @debugging 941
957 def on_group_event(self, evt): 942 def on_group_event(self, evt):
958 id = evt.get_id() 943 id = evt.get_id()
959 data = evt.get_data() 944 data = evt.get_data()
960 if id == orpg.networking.mplay_client.GROUP_NEW: self.gs.add_room(data) 945 if id == orpg.networking.mplay_client.GROUP_NEW: self.gs.add_room(data)
961 elif id == orpg.networking.mplay_client.GROUP_DEL: 946 elif id == orpg.networking.mplay_client.GROUP_DEL:
962 self.password_manager.RemoveGroupData(data) 947 # self.password_manager.RemoveGroupData(data) #Removed for debugging.
963 self.gs.del_room(data) 948 self.gs.del_room(data)
964 elif id == orpg.networking.mplay_client.GROUP_UPDATE: self.gs.update_room(data) 949 elif id == orpg.networking.mplay_client.GROUP_UPDATE: self.gs.update_room(data)
965 950
966 @debugging 951
967 def on_receive(self, data, player): 952 def on_receive(self, data, player):
968 # see if we are ignoring this user 953 # see if we are ignoring this user
969 (ignore_id,ignore_name) = self.session.get_ignore_list() 954 (ignore_id, ignore_name) = self.session.get_ignore_list()
970 for m in ignore_id: 955 for m in ignore_id:
971 if m == player[2]: logger.debug("ignoring message from player:" + player[0], True); return 956 if m == player[2]: logger.debug("ignoring message from player:" + player[0], True); return
972 957
973 # ok we are not ignoring this message 958 # ok we are not ignoring this message
974 #recvSound = "RecvSound" # this will be the default sound. Whisper will change this below 959 #recvSound = "RecvSound" # this will be the default sound. Whisper will change this below
990 ### Alpha ### Allows users to decide if they want the node or not. 975 ### Alpha ### Allows users to decide if they want the node or not.
991 dlg = wx.MessageDialog(None, display_name + 'is trying to send you a tree node. Accept?', 'Question', 976 dlg = wx.MessageDialog(None, display_name + 'is trying to send you a tree node. Accept?', 'Question',
992 wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION) 977 wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)
993 if dlg.ShowModal() == wx.ID_YES: 978 if dlg.ShowModal() == wx.ID_YES:
994 dlg.Destroy() 979 dlg.Destroy()
995 self.tree.on_receive_data(data,player) 980 self.tree.on_receive_data(data, player)
996 self.chat.InfoPost(display_name + " has sent you a tree node...") 981 self.chat.InfoPost(display_name + " has sent you a tree node...")
997 ### Core ### to be milked in later. 982 ### Core ### to be milked in later.
998 #TODO: Fix game tree to accepts elements 983 #TODO: Fix game tree to accepts elements
999 #self.tree.on_receive_data(child, player) 984 #self.tree.on_receive_data(child, player)
1000 #self.chat.InfoPost(display_name + " has sent you a tree node...") 985 #self.chat.InfoPost(display_name + " has sent you a tree node...")
1004 #TODO: Fix map to accepts elements 989 #TODO: Fix map to accepts elements
1005 self.map.new_data(tostring(child)) 990 self.map.new_data(tostring(child))
1006 991
1007 elif child.tag == 'chat': 992 elif child.tag == 'chat':
1008 msg = orpg.chat.chat_msg.chat_msg(data) 993 msg = orpg.chat.chat_msg.chat_msg(data)
1009 self.chat.post_incoming_msg(msg,player) 994 self.chat.post_incoming_msg(msg, player)
1010 ### Core ### to be milked in later 995 ### Core ### to be milked in later
1011 #msg = orpg.chat.chat_msg.chat_msg() 996 #msg = orpg.chat.chat_msg.chat_msg()
1012 #msg.takedom(child) 997 #msg.takedom(child)
1013 #self.chat.post_incoming_msg(msg, player) 998 #self.chat.post_incoming_msg(msg, player)
1014 999
1015 1000
1016 @debugging 1001
1017 def on_mplay_event(self, evt): 1002 def on_mplay_event(self, evt):
1018 id = evt.get_id() 1003 id = evt.get_id()
1019 if id == orpg.networking.mplay_client.MPLAY_CONNECTED: 1004 if id == orpg.networking.mplay_client.MPLAY_CONNECTED:
1020 self.chat.InfoPost("Game connected!") 1005 self.chat.InfoPost("Game connected!")
1021 self.gs.set_connected(1) 1006 self.gs.set_connected(1)
1038 else: self.chat.system_message(custom_msg) 1023 else: self.chat.system_message(custom_msg)
1039 #####End Changes for Custom Exit Message by mDuo13 1024 #####End Changes for Custom Exit Message by mDuo13
1040 1025
1041 elif id == orpg.networking.mplay_client.MPLAY_GROUP_CHANGE: 1026 elif id == orpg.networking.mplay_client.MPLAY_GROUP_CHANGE:
1042 group = evt.get_data() 1027 group = evt.get_data()
1043 print 'main ', group
1044 self.chat.InfoPost("Moving to room '"+group[1]+"'..") 1028 self.chat.InfoPost("Moving to room '"+group[1]+"'..")
1045 if self.gs : self.gs.set_cur_room_text(group[1]) 1029 if self.gs : self.gs.set_cur_room_text(group[1])
1046 self.players.reset() 1030 self.players.reset()
1047 elif id == orpg.networking.mplay_client.MPLAY_GROUP_CHANGE_F: 1031 elif id == orpg.networking.mplay_client.MPLAY_GROUP_CHANGE_F:
1048 self.chat.SystemPost("Room access denied!") 1032 self.chat.SystemPost("Room access denied!")
1049 1033
1050 @debugging 1034
1051 def OnCloseWindow(self, event): 1035 def OnCloseWindow(self, event):
1052 dlg = wx.MessageDialog(self, "Quit OpenRPG?", "OpenRPG", wx.YES_NO) 1036 dlg = wx.MessageDialog(self, "Quit OpenRPG?", "OpenRPG", wx.YES_NO)
1053 if dlg.ShowModal() == wx.ID_YES: 1037 if dlg.ShowModal() == wx.ID_YES:
1054 dlg.Destroy() 1038 dlg.Destroy()
1055 self.closed_confirmed() 1039 self.closed_confirmed()
1056 1040
1057 @debugging 1041
1058 def closed_confirmed(self): 1042 def closed_confirmed(self):
1059 self.activeplugins = component.get('plugins') 1043 self.activeplugins = component.get('plugins')
1060 self.aliaslib.OnMB_FileSave(None) 1044 self.aliaslib.OnMB_FileSave(None)
1061 1045
1062 #following lines added by mDuo13 1046 #following lines added by mDuo13
1181 1165
1182 ######################################## 1166 ########################################
1183 ## Application class 1167 ## Application class
1184 ######################################## 1168 ########################################
1185 class orpgSplashScreen(wx.SplashScreen): 1169 class orpgSplashScreen(wx.SplashScreen):
1186 @debugging 1170
1187 def __init__(self, parent, bitmapfile, duration, callback): 1171 def __init__(self, parent, bitmapfile, duration, callback):
1188 wx.SplashScreen.__init__(self, wx.Bitmap(bitmapfile), 1172 wx.SplashScreen.__init__(self, wx.Bitmap(bitmapfile),
1189 wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT, duration, None, -1) 1173 wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT, duration, None, -1)
1190 self.callback = callback 1174 self.callback = callback
1191 self.closing = False 1175 self.closing = False
1192 self.Bind(wx.EVT_CLOSE, self.callback) 1176 self.Bind(wx.EVT_CLOSE, self.callback)
1193 1177
1194 class orpgApp(wx.App): 1178 class orpgApp(wx.App):
1195 @debugging 1179
1196 def OnInit(self): 1180 def OnInit(self):
1197
1198 component.add('log', logger) 1181 component.add('log', logger)
1199 component.add('xml', xml) 1182 component.add('xml', xml)
1200 component.add('settings', settings) 1183 component.add('settings', settings)
1201 component.add('validate', validate) 1184 component.add('validate', validate)
1202 component.add("tabbedWindows", []) 1185 component.add("tabbedWindows", [])
1203
1204 logger._set_log_level = int(settings.get('LoggingLevel'))
1205 logger._set_log_to_console(False)
1206 1186
1207 #Update Manager 1187 #Update Manager
1208 self.manifest = manifest.ManifestChanges() 1188 self.manifest = manifest.ManifestChanges()
1209 1189
1210 self.called = False 1190 self.called = False
1213 self.Bind(wx.EVT_KEY_DOWN, self.OnKeyPress) 1193 self.Bind(wx.EVT_KEY_DOWN, self.OnKeyPress)
1214 self._crust = None 1194 self._crust = None
1215 wx.Yield() 1195 wx.Yield()
1216 return True 1196 return True
1217 1197
1218 @debugging 1198
1219 def OnKeyPress(self, evt): 1199 def OnKeyPress(self, evt):
1220 #Event handler 1200 #Event handler
1221 if evt.AltDown() and evt.CmdDown() and evt.KeyCode == ord('I'): self.ShowShell() 1201 if evt.AltDown() and evt.CmdDown() and evt.KeyCode == ord('I'): self.ShowShell()
1222 else: evt.Skip() 1202 else: evt.Skip()
1223 1203
1224 @debugging 1204
1225 def ShowShell(self): 1205 def ShowShell(self):
1226 #Show the PyCrust window. 1206 #Show the PyCrust window.
1227 if not self._crust: 1207 if not self._crust:
1228 self._crust = wx.py.crust.CrustFrame(self.GetTopWindow()) 1208 self._crust = wx.py.crust.CrustFrame(self.GetTopWindow())
1229 self._crust.shell.interp.locals['app'] = self 1209 self._crust.shell.interp.locals['app'] = self
1230 win = wx.FindWindowAtPointer() 1210 win = wx.FindWindowAtPointer()
1231 self._crust.shell.interp.locals['win'] = win 1211 self._crust.shell.interp.locals['win'] = win
1232 self._crust.Show() 1212 self._crust.Show()
1233 1213
1234 @debugging 1214
1235 def AfterSplash(self,evt): 1215 def AfterSplash(self,evt):
1236 if not self.called: 1216 if not self.called:
1237 self.splash.Hide() 1217 self.splash.Hide()
1238 self.called = True 1218 self.called = True
1239 self.frame = orpgFrame(None, wx.ID_ANY, MENU_TITLE) 1219 self.frame = orpgFrame(None, wx.ID_ANY, MENU_TITLE)
1244 #self.frame.show_dlgs() 1224 #self.frame.show_dlgs()
1245 self.frame.post_show_init() 1225 self.frame.post_show_init()
1246 wx.CallAfter(self.splash.Close) 1226 wx.CallAfter(self.splash.Close)
1247 return True 1227 return True
1248 1228
1249 @debugging 1229
1250 def OnExit_CleanUp(self): 1230 def OnExit_CleanUp(self):
1251 logger.debug("Preforming cleanup\n") 1231 logger.debug("Preforming cleanup\n")
1252 try: del os.environ["OPENRPG_BASE"] 1232 try: del os.environ["OPENRPG_BASE"]
1253 except: pass 1233 except: pass
1254 try: os.remove(os.environ["OPENRPG_BASE"] + os.sep + 'orpg' + os.sep + 'dirpath' + os.sep + 'approot.py') 1234 try: os.remove(os.environ["OPENRPG_BASE"] + os.sep + 'orpg' + os.sep + 'dirpath' + os.sep + 'approot.py')
1255 except: pass 1235 except: pass
1256 try: os.remove(os.environ["OPENRPG_BASE"] + os.sep + 'orpg' + os.sep + 'dirpath' + os.sep + 'approot.pyc') 1236 try: os.remove(os.environ["OPENRPG_BASE"] + os.sep + 'orpg' + os.sep + 'dirpath' + os.sep + 'approot.pyc')
1257 except: pass 1237 except: pass
1258 1238
1259 @debugging 1239
1260 def OnExit(self): 1240 def OnExit(self):
1261 self.OnExit_CleanUp() 1241 self.OnExit_CleanUp()
1262 #Exit 1242 #Exit
1263 logger.debug("Main Application Exit\n\n") 1243 logger.debug("Main Application Exit\n\n")