comparison orpg/main.py @ 19:78407d627cba traipse_dev

Beginning of Code Clean-up. Some code untested, may break!
author sirebral
date Sat, 25 Jul 2009 17:24:40 -0500
parents 0b8b7e3ed78d
children 65c5cb9be59c
comparison
equal deleted inserted replaced
18:67b900deb35c 19:78407d627cba
72 self.rgbcovert = orpg.tools.rgbhex.RGBHex() 72 self.rgbcovert = orpg.tools.rgbhex.RGBHex()
73 self._mgr = AUI.AuiManager(self) 73 self._mgr = AUI.AuiManager(self)
74 74
75 # Determine which icon format to use 75 # Determine which icon format to use
76 icon = None 76 icon = None
77 if wx.Platform == '__WXMSW__': 77 if wx.Platform == '__WXMSW__': icon = wx.Icon(orpg.dirpath.dir_struct["icon"]+'d20.ico', wx.BITMAP_TYPE_ICO)
78 icon = wx.Icon(orpg.dirpath.dir_struct["icon"]+'d20.ico', wx.BITMAP_TYPE_ICO) 78 else: icon = wx.Icon(orpg.dirpath.dir_struct["icon"]+"d20.xpm", wx.BITMAP_TYPE_XPM)
79 else: 79 #if icon != None: self.SetIcon( icon ) worth 'less' now since it sets the icon either or.
80 icon = wx.Icon(orpg.dirpath.dir_struct["icon"]+"d20.xpm", wx.BITMAP_TYPE_XPM) # create the object, then determine if it needs to be replaced. It calculates 2 less calculations. 80 self.SetIcon( icon )
81
82 # Set it if we have it
83 if icon != None:
84 self.SetIcon( icon )
85 81
86 # create session 82 # create session
87 call_backs = {"on_receive":self.on_receive, 83 call_backs = {"on_receive":self.on_receive,
88 "on_mplay_event":self.on_mplay_event, 84 "on_mplay_event":self.on_mplay_event,
89 "on_group_event":self.on_group_event, 85 "on_group_event":self.on_group_event,
135 self.players.size_cols() 131 self.players.size_cols()
136 self.log.log("Exit orpgFrame->post_show_init(self)", ORPG_DEBUG) 132 self.log.log("Exit orpgFrame->post_show_init(self)", ORPG_DEBUG)
137 133
138 def get_activeplugins(self): 134 def get_activeplugins(self):
139 self.log.log("Enter orpgFrame->get_activeplugins(self)", ORPG_DEBUG) 135 self.log.log("Enter orpgFrame->get_activeplugins(self)", ORPG_DEBUG)
140 try: 136 try: tmp = self.pluginsFrame.get_activeplugins()
141 tmp = self.pluginsFrame.get_activeplugins() 137 except: tmp = {}
142 except:
143 tmp = {}
144 self.log.log("Exit orpgFrame->get_activeplugins(self)", ORPG_DEBUG) 138 self.log.log("Exit orpgFrame->get_activeplugins(self)", ORPG_DEBUG)
145 return tmp 139 return tmp
146 140
147 def get_startplugins(self): 141 def get_startplugins(self):
148 self.log.log("Enter orpgFrame->get_startplugins(self)", ORPG_DEBUG) 142 self.log.log("Enter orpgFrame->get_startplugins(self)", ORPG_DEBUG)
149 try: 143 try: tmp = self.pluginsFrame.get_startplugins()
150 tmp = self.pluginsFrame.get_startplugins() 144 except: tmp = {}
151 except:
152 tmp = {}
153 self.log.log("Exit orpgFrame->get_startplugins(self)", ORPG_DEBUG) 145 self.log.log("Exit orpgFrame->get_startplugins(self)", ORPG_DEBUG)
154 return tmp 146 return tmp
155 147
156 def on_password_signal(self,signal,type,id,data): 148 def on_password_signal(self,signal,type,id,data):
157 self.log.log("Enter orpgFrame->on_password_signal(self,signal,type,id,data)", ORPG_DEBUG) 149 self.log.log("Enter orpgFrame->on_password_signal(self,signal,type,id,data)", ORPG_DEBUG)
158
159 try: 150 try:
160 self.log.log("DEBUG: password response= "+str(signal)+" (T:"+str(type)+" #"+str(id)+")", ORPG_DEBUG) 151 self.log.log("DEBUG: password response= "+str(signal)+" (T:"+str(type)+" #"+str(id)+")", ORPG_DEBUG)
161 id = int(id) 152 id = int(id)
162 type = str(type) 153 type = str(type)
163 data = str(data) 154 data = str(data)
164 signal = str(signal) 155 signal = str(signal)
165 if signal == "fail": 156 if signal == "fail":
166 if type == "server": 157 if type == "server": self.password_manager.ClearPassword("server", 0)
167 self.password_manager.ClearPassword("server", 0) 158 elif type == "admin": self.password_manager.ClearPassword("admin", int(id))
168 elif type == "admin": 159 elif type == "room": self.password_manager.ClearPassword("room", int(id))
169 self.password_manager.ClearPassword("admin", int(id)) 160 else: pass
170 elif type == "room": 161 except: traceback.print_exc()
171 self.password_manager.ClearPassword("room", int(id))
172 else:
173 pass
174 except:
175 traceback.print_exc()
176 self.log.log("Exit orpgFrame->on_password_signal(self,signal,type,id,data)", ORPG_DEBUG) 162 self.log.log("Exit orpgFrame->on_password_signal(self,signal,type,id,data)", ORPG_DEBUG)
177 163
178 def build_menu(self): 164 def build_menu(self):
179 self.log.log("Enter orpgFrame->build_menu()", ORPG_DEBUG) 165 self.log.log("Enter orpgFrame->build_menu()", ORPG_DEBUG)
180 menu = \ 166 menu = \
240 self.mainmenu.SetMenuState("OpenRPGTabStylesFlatAqua", tabtheme == 'flat&aqua') 226 self.mainmenu.SetMenuState("OpenRPGTabStylesFlatAqua", tabtheme == 'flat&aqua')
241 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedCustom", tabtheme == 'customslant') 227 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedCustom", tabtheme == 'customslant')
242 self.mainmenu.SetMenuState("OpenRPGTabStylesFlatCustom", tabtheme == 'customflat') 228 self.mainmenu.SetMenuState("OpenRPGTabStylesFlatCustom", tabtheme == 'customflat')
243 229
244 lvl = int(self.settings.get_setting('LoggingLevel')) 230 lvl = int(self.settings.get_setting('LoggingLevel'))
245 if lvl & ORPG_DEBUG: 231 if lvl & ORPG_DEBUG: self.mainmenu.SetMenuState("ToolsLoggingLevelDebug", True)
246 self.mainmenu.SetMenuState("ToolsLoggingLevelDebug", True) 232 if lvl & ORPG_DEBUG: self.mainmenu.SetMenuState("ToolsLoggingLevelNote", True)
247 if lvl & ORPG_DEBUG: 233 if lvl & ORPG_INFO: self.mainmenu.SetMenuState("ToolsLoggingLevelInfo", True)
248 self.mainmenu.SetMenuState("ToolsLoggingLevelNote", True) 234 if lvl & ORPG_GENERAL: self.mainmenu.SetMenuState("ToolsLoggingLevelGeneral", True)
249 if lvl & ORPG_INFO: 235
250 self.mainmenu.SetMenuState("ToolsLoggingLevelInfo", True)
251 if lvl & ORPG_GENERAL:
252 self.mainmenu.SetMenuState("ToolsLoggingLevelGeneral", True)
253 self.pluginMenu = wx.Menu() 236 self.pluginMenu = wx.Menu()
254 item = wx.MenuItem(self.pluginMenu, wx.ID_ANY, "Control Panel", "Control Panel") 237 item = wx.MenuItem(self.pluginMenu, wx.ID_ANY, "Control Panel", "Control Panel")
255 self.Bind(wx.EVT_MENU, self.OnMB_PluginControlPanel, item) 238 self.Bind(wx.EVT_MENU, self.OnMB_PluginControlPanel, item)
256 self.pluginMenu.AppendItem(item) 239 self.pluginMenu.AppendItem(item)
257 self.pluginMenu.AppendSeparator() 240 self.pluginMenu.AppendSeparator()
262 ## All Menu Events 245 ## All Menu Events
263 ################################# 246 #################################
264 #Tab Styles Menus 247 #Tab Styles Menus
265 def SetTabStyles(self, *args, **kwargs): 248 def SetTabStyles(self, *args, **kwargs):
266 self.log.log("Enter orpgFrame->SetTabStyles(self, *args, **kwargs)", ORPG_DEBUG) 249 self.log.log("Enter orpgFrame->SetTabStyles(self, *args, **kwargs)", ORPG_DEBUG)
267 if kwargs.has_key('style'): 250 if kwargs.has_key('style'): newstyle = kwargs['style']
268 newstyle = kwargs['style']
269 else: 251 else:
270 try: 252 try: newstyle = args[1]
271 newstyle = args[1] 253 except: self.log.log('Invalid Syntax for orpgFrame->SetTabStyles(self, *args, **kwargs)', ORPG_GENERAL); return
272 except: 254 if kwargs.has_key('menu'): menu = kwargs['menu']
273 self.log.log('Invalid Syntax for orpgFrame->SetTabStyles(self, *args, **kwargs)', ORPG_GENERAL)
274 return
275 if kwargs.has_key('menu'):
276 menu = kwargs['menu']
277 else: 255 else:
278 try: 256 try: menu = args[0]
279 menu = args[0] 257 except: self.log.log('Invalid Syntax for orpgFrame->SetTabStyles(self, *args, **kwargs)', ORPG_GENERAL); return
280 except: 258
281 self.log.log('Invalid Syntax for orpgFrame->SetTabStyles(self, *args, **kwargs)', ORPG_GENERAL) 259 if kwargs.has_key('graidentTo'): graidentTo = kwargs['graidentTo']
282 return 260 else: graidentTo = None
283 if kwargs.has_key('graidentTo'): 261 if kwargs.has_key('graidentFrom'): graidentFrom = kwargs['graidentFrom']
284 graidentTo = kwargs['graidentTo'] 262 else: graidentFrom = None
285 else: 263 if kwargs.has_key('textColor'): textColor = kwargs['textColor']
286 graidentTo = None 264 else: textColor = None
287 if kwargs.has_key('graidentFrom'):
288 graidentFrom = kwargs['graidentFrom']
289 else:
290 graidentFrom = None
291 if kwargs.has_key('textColor'):
292 textColor = kwargs['textColor']
293 else:
294 textColor = None
295 265
296 #Set all menu's to unchecked 266 #Set all menu's to unchecked
297 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedColorful", False) 267 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedColorful", False)
298 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedBlackandWhite", False) 268 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedBlackandWhite", False)
299 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedAqua", False) 269 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedAqua", False)
308 #Run though the current tabbed window list and remove those that have been closed 278 #Run though the current tabbed window list and remove those that have been closed
309 tabbedwindows = open_rpg.get_component("tabbedWindows") 279 tabbedwindows = open_rpg.get_component("tabbedWindows")
310 rgbc = orpg.tools.rgbhex.RGBHex() 280 rgbc = orpg.tools.rgbhex.RGBHex()
311 new = [] 281 new = []
312 for wnd in tabbedwindows: 282 for wnd in tabbedwindows:
313 try: 283 try: style = wnd.GetWindowStyleFlag(); new.append(wnd)
314 style = wnd.GetWindowStyleFlag() 284 except: pass
315 new.append(wnd)
316 except:
317 pass
318 tabbedwindows = new 285 tabbedwindows = new
319 open_rpg.add_component("tabbedWindows", tabbedwindows) 286 open_rpg.add_component("tabbedWindows", tabbedwindows)
320 287
321 #Run though the new list and set the proper styles 288 #Run though the new list and set the proper styles
322 tabbg = self.settings.get_setting('TabBackgroundGradient') 289 tabbg = self.settings.get_setting('TabBackgroundGradient')
329 mirror = ~(FNB.FNB_VC71 | FNB.FNB_VC8 | FNB.FNB_FANCY_TABS | FNB.FNB_COLORFUL_TABS) 296 mirror = ~(FNB.FNB_VC71 | FNB.FNB_VC8 | FNB.FNB_FANCY_TABS | FNB.FNB_COLORFUL_TABS)
330 style &= mirror 297 style &= mirror
331 style |= newstyle 298 style |= newstyle
332 wnd.SetWindowStyleFlag(style) 299 wnd.SetWindowStyleFlag(style)
333 wnd.SetTabAreaColour(wx.Color(red, green, blue)) 300 wnd.SetTabAreaColour(wx.Color(red, green, blue))
334 if graidentTo != None: 301 if graidentTo != None: wnd.SetGradientColourTo(graidentTo)
335 wnd.SetGradientColourTo(graidentTo) 302 if graidentFrom != None: wnd.SetGradientColourFrom(graidentFrom)
336 if graidentFrom != None: 303 if textColor != None: wnd.SetNonActiveTabTextColour(textColor)
337 wnd.SetGradientColourFrom(graidentFrom)
338 if textColor != None:
339 wnd.SetNonActiveTabTextColour(textColor)
340 wnd.Refresh() 304 wnd.Refresh()
341 305
342 def OnMB_OpenRPGNewMap(self): 306 def OnMB_OpenRPGNewMap(self):
343 self.log.log("Enter orpgFrame->OnMB_OpenRPGNewMap(self)", ORPG_DEBUG) 307 self.log.log("Enter orpgFrame->OnMB_OpenRPGNewMap(self)", ORPG_DEBUG)
344 self.log.log("Exit orpgFrame->OnMB_OpenRPGNewMap(self)", ORPG_DEBUG) 308 self.log.log("Exit orpgFrame->OnMB_OpenRPGNewMap(self)", ORPG_DEBUG)
346 def OnMB_OpenRPGTabStylesSlantedColorful(self): 310 def OnMB_OpenRPGTabStylesSlantedColorful(self):
347 self.log.log("Enter orpgFrame->OnMB_OpenRPGTabStylesSlantedColorful(self)", ORPG_DEBUG) 311 self.log.log("Enter orpgFrame->OnMB_OpenRPGTabStylesSlantedColorful(self)", ORPG_DEBUG)
348 if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedColorful"): 312 if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedColorful"):
349 self.settings.set_setting('TabTheme', 'slanted&colorful') 313 self.settings.set_setting('TabTheme', 'slanted&colorful')
350 self.SetTabStyles("OpenRPGTabStylesSlantedColorful", FNB.FNB_VC8|FNB.FNB_COLORFUL_TABS) 314 self.SetTabStyles("OpenRPGTabStylesSlantedColorful", FNB.FNB_VC8|FNB.FNB_COLORFUL_TABS)
351 else: 315 else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedColorful", True)
352 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedColorful", True)
353 self.log.log("Exit orpgFrame->OnMB_OpenRPGTabStylesSlantedColorful(self)", ORPG_DEBUG) 316 self.log.log("Exit orpgFrame->OnMB_OpenRPGTabStylesSlantedColorful(self)", ORPG_DEBUG)
354 317
355 def OnMB_OpenRPGTabStylesSlantedBlackandWhite(self): 318 def OnMB_OpenRPGTabStylesSlantedBlackandWhite(self):
356 self.log.log("Enter orpgFrame->OnMB_OpenRPGTabStylesSlantedBlackandWhite(self)", ORPG_DEBUG) 319 self.log.log("Enter orpgFrame->OnMB_OpenRPGTabStylesSlantedBlackandWhite(self)", ORPG_DEBUG)
357 if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedBlackandWhite"): 320 if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedBlackandWhite"):
358 self.settings.set_setting('TabTheme', 'slanted&bw') 321 self.settings.set_setting('TabTheme', 'slanted&bw')
359 self.SetTabStyles("OpenRPGTabStylesSlantedBlackandWhite", FNB.FNB_VC8, graidentTo=wx.WHITE, graidentFrom=wx.WHITE, textColor=wx.BLACK) 322 self.SetTabStyles("OpenRPGTabStylesSlantedBlackandWhite", FNB.FNB_VC8, graidentTo=wx.WHITE, graidentFrom=wx.WHITE, textColor=wx.BLACK)
360 else: 323 else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedBlackandWhite", True)
361 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedBlackandWhite", True)
362 self.log.log("Exit orpgFrame->OnMB_OpenRPGTabStylesSlantedBlackandWhite(self)", ORPG_DEBUG) 324 self.log.log("Exit orpgFrame->OnMB_OpenRPGTabStylesSlantedBlackandWhite(self)", ORPG_DEBUG)
363 325
364 def OnMB_OpenRPGTabStylesSlantedAqua(self): 326 def OnMB_OpenRPGTabStylesSlantedAqua(self):
365 self.log.log("Enter orpgFrame->OnMB_OpenRPGTabStylesSlantedAqua(self)", ORPG_DEBUG) 327 self.log.log("Enter orpgFrame->OnMB_OpenRPGTabStylesSlantedAqua(self)", ORPG_DEBUG)
366 if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedAqua"): 328 if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedAqua"):
367 self.settings.set_setting('TabTheme', 'slanted&aqua') 329 self.settings.set_setting('TabTheme', 'slanted&aqua')
368 self.SetTabStyles("OpenRPGTabStylesSlantedAqua", FNB.FNB_VC8, graidentTo=wx.Color(0, 128, 255), graidentFrom=wx.WHITE, textColor=wx.BLACK) 330 self.SetTabStyles("OpenRPGTabStylesSlantedAqua", FNB.FNB_VC8, graidentTo=wx.Color(0, 128, 255), graidentFrom=wx.WHITE, textColor=wx.BLACK)
369 else: 331 else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedAqua", True)
370 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedAqua", True)
371 self.log.log("Exit orpgFrame->OnMB_OpenRPGTabStylesSlantedBlackandWhite(self)", ORPG_DEBUG) 332 self.log.log("Exit orpgFrame->OnMB_OpenRPGTabStylesSlantedBlackandWhite(self)", ORPG_DEBUG)
372 333
373 def OnMB_OpenRPGTabStylesSlantedCustom(self): 334 def OnMB_OpenRPGTabStylesSlantedCustom(self):
374 self.log.log("Enter orpgFrame->OnMB_OpenRPGTabStylesSlantedCustom(self)", ORPG_DEBUG) 335 self.log.log("Enter orpgFrame->OnMB_OpenRPGTabStylesSlantedCustom(self)", ORPG_DEBUG)
375 336
382 (tored, togreen, toblue) = rgbc.rgb_tuple(gto) 343 (tored, togreen, toblue) = rgbc.rgb_tuple(gto)
383 tabtext = self.settings.get_setting('TabTextColor') 344 tabtext = self.settings.get_setting('TabTextColor')
384 (tred, tgreen, tblue) = rgbc.rgb_tuple(tabtext) 345 (tred, tgreen, tblue) = rgbc.rgb_tuple(tabtext)
385 tabbg = self.settings.get_setting('TabBackgroundGradient') 346 tabbg = self.settings.get_setting('TabBackgroundGradient')
386 (red, green, blue) = rgbc.rgb_tuple(tabbg) 347 (red, green, blue) = rgbc.rgb_tuple(tabbg)
387 self.SetTabStyles("OpenRPGTabStylesSlantedCustom", FNB.FNB_VC8, graidentTo=wx.Color(tored, togreen, toblue), graidentFrom=wx.Color(fred, fgreen, fblue), textColor=wx.Color(tred, tgreen, tblue)) 348 self.SetTabStyles("OpenRPGTabStylesSlantedCustom", FNB.FNB_VC8,
388 else: 349 graidentTo=wx.Color(tored, togreen, toblue), graidentFrom=wx.Color(fred, fgreen, fblue),
389 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedCustom", True) 350 textColor=wx.Color(tred, tgreen, tblue))
351 else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedCustom", True)
390 self.log.log("Exit orpgFrame->OnMB_OpenRPGTabStylesSlantedCustom(self)", ORPG_DEBUG) 352 self.log.log("Exit orpgFrame->OnMB_OpenRPGTabStylesSlantedCustom(self)", ORPG_DEBUG)
391 353
392 def OnMB_OpenRPGTabStylesFlatBlackandWhite(self): 354 def OnMB_OpenRPGTabStylesFlatBlackandWhite(self):
393 self.log.log("Enter orpgFrame->OnMB_OpenRPGTabStylesFlatBlackandWhite(self)", ORPG_DEBUG) 355 self.log.log("Enter orpgFrame->OnMB_OpenRPGTabStylesFlatBlackandWhite(self)", ORPG_DEBUG)
394 if self.mainmenu.GetMenuState("OpenRPGTabStylesFlatBlackandWhite"): 356 if self.mainmenu.GetMenuState("OpenRPGTabStylesFlatBlackandWhite"):
395 self.settings.set_setting('TabTheme', 'flat&bw') 357 self.settings.set_setting('TabTheme', 'flat&bw')
396 self.SetTabStyles("OpenRPGTabStylesFlatBlackandWhite", FNB.FNB_FANCY_TABS, graidentTo=wx.WHITE, graidentFrom=wx.WHITE, textColor=wx.BLACK) 358 self.SetTabStyles("OpenRPGTabStylesFlatBlackandWhite", FNB.FNB_FANCY_TABS,
397 else: 359 graidentTo=wx.WHITE, graidentFrom=wx.WHITE, textColor=wx.BLACK)
398 self.mainmenu.SetMenuState("OpenRPGTabStylesFlatBlackandWhite", True) 360 else: self.mainmenu.SetMenuState("OpenRPGTabStylesFlatBlackandWhite", True)
399 self.log.log("Exit orpgFrame->OnMB_OpenRPGTabStylesFlatBlackandWhite(self)", ORPG_DEBUG) 361 self.log.log("Exit orpgFrame->OnMB_OpenRPGTabStylesFlatBlackandWhite(self)", ORPG_DEBUG)
400 362
401 def OnMB_OpenRPGTabStylesFlatAqua(self): 363 def OnMB_OpenRPGTabStylesFlatAqua(self):
402 self.log.log("Enter orpgFrame->OnMB_OpenRPGTabStylesFlatAqua(self)", ORPG_DEBUG) 364 self.log.log("Enter orpgFrame->OnMB_OpenRPGTabStylesFlatAqua(self)", ORPG_DEBUG)
403 if self.mainmenu.GetMenuState("OpenRPGTabStylesFlatAqua"): 365 if self.mainmenu.GetMenuState("OpenRPGTabStylesFlatAqua"):
404 self.settings.set_setting('TabTheme', 'flat&aqua') 366 self.settings.set_setting('TabTheme', 'flat&aqua')
405 self.SetTabStyles("OpenRPGTabStylesFlatAqua", FNB.FNB_FANCY_TABS, graidentTo=wx.Color(0, 128, 255), graidentFrom=wx.WHITE, textColor=wx.BLACK) 367 self.SetTabStyles("OpenRPGTabStylesFlatAqua", FNB.FNB_FANCY_TABS,
406 else: 368 graidentTo=wx.Color(0, 128, 255), graidentFrom=wx.WHITE, textColor=wx.BLACK)
407 self.mainmenu.SetMenuState("OpenRPGTabStylesFlatAqua", True) 369 else: self.mainmenu.SetMenuState("OpenRPGTabStylesFlatAqua", True)
408 self.log.log("Exit orpgFrame->OnMB_OpenRPGTabStylesFlatAqua(self)", ORPG_DEBUG) 370 self.log.log("Exit orpgFrame->OnMB_OpenRPGTabStylesFlatAqua(self)", ORPG_DEBUG)
409 371
410 def OnMB_OpenRPGTabStylesFlatCustom(self): 372 def OnMB_OpenRPGTabStylesFlatCustom(self):
411 self.log.log("Enter orpgFrame->OnMB_OpenRPGTabStylesFlatCustom(self)", ORPG_DEBUG) 373 self.log.log("Enter orpgFrame->OnMB_OpenRPGTabStylesFlatCustom(self)", ORPG_DEBUG)
412 if self.mainmenu.GetMenuState("OpenRPGTabStylesFlatCustom"): 374 if self.mainmenu.GetMenuState("OpenRPGTabStylesFlatCustom"):
418 (tored, togreen, toblue) = rgbc.rgb_tuple(gto) 380 (tored, togreen, toblue) = rgbc.rgb_tuple(gto)
419 tabtext = self.settings.get_setting('TabTextColor') 381 tabtext = self.settings.get_setting('TabTextColor')
420 (tred, tgreen, tblue) = rgbc.rgb_tuple(tabtext) 382 (tred, tgreen, tblue) = rgbc.rgb_tuple(tabtext)
421 tabbg = self.settings.get_setting('TabBackgroundGradient') 383 tabbg = self.settings.get_setting('TabBackgroundGradient')
422 (red, green, blue) = rgbc.rgb_tuple(tabbg) 384 (red, green, blue) = rgbc.rgb_tuple(tabbg)
423 self.SetTabStyles("OpenRPGTabStylesFlatCustom", FNB.FNB_FANCY_TABS, graidentTo=wx.Color(tored, togreen, toblue), graidentFrom=wx.Color(fred, fgreen, fblue), textColor=wx.Color(tred, tgreen, tblue)) 385 self.SetTabStyles("OpenRPGTabStylesFlatCustom", FNB.FNB_FANCY_TABS,
424 else: 386 graidentTo=wx.Color(tored, togreen, toblue), graidentFrom=wx.Color(fred, fgreen, fblue),
425 self.mainmenu.SetMenuState("OpenRPGTabStylesFlatCustom", True) 387 textColor=wx.Color(tred, tgreen, tblue))
388 else: self.mainmenu.SetMenuState("OpenRPGTabStylesFlatCustom", True)
426 self.log.log("Exit orpgFrame->OnMB_OpenRPGTabStylesFlatCustom(self)", ORPG_DEBUG) 389 self.log.log("Exit orpgFrame->OnMB_OpenRPGTabStylesFlatCustom(self)", ORPG_DEBUG)
427 390
428 #Window Menu 391 #Window Menu
429 def OnMB_WindowsMenu(self, event): 392 def OnMB_WindowsMenu(self, event):
430 self.log.log("Enter orpgFrame->OnMB_WindowsMenu(self, event)", ORPG_DEBUG) 393 self.log.log("Enter orpgFrame->OnMB_WindowsMenu(self, event)", ORPG_DEBUG)
431 menuid = event.GetId() 394 menuid = event.GetId()
432 name = self.mainwindows[menuid] 395 name = self.mainwindows[menuid]
433 if name == 'Alias Lib': 396 if name == 'Alias Lib':
434 if self.aliaslib.IsShown() == True: 397 if self.aliaslib.IsShown() == True: self.aliaslib.Hide()
435 self.aliaslib.Hide() 398 else: self.aliaslib.Show()
436 else:
437 self.aliaslib.Show()
438 else: 399 else:
439 if self._mgr.GetPane(name).IsShown() == True: 400 if self._mgr.GetPane(name).IsShown() == True: self._mgr.GetPane(name).Hide()
440 self._mgr.GetPane(name).Hide() 401 else: self._mgr.GetPane(name).Show()
441 else:
442 self._mgr.GetPane(name).Show()
443 self._mgr.Update() 402 self._mgr.Update()
444 self.log.log("Exit orpgFrame->OnMB_WindowsMenu(self, event)", ORPG_DEBUG) 403 self.log.log("Exit orpgFrame->OnMB_WindowsMenu(self, event)", ORPG_DEBUG)
445 404
446 #OpenRPG Menu 405 #OpenRPG Menu
447 def OnMB_OpenRPGSettings(self): 406 def OnMB_OpenRPGSettings(self):
455 self.OnCloseWindow(0) 414 self.OnCloseWindow(0)
456 415
457 #Game Server Menu 416 #Game Server Menu
458 def OnMB_GameServerBrowseServers(self): 417 def OnMB_GameServerBrowseServers(self):
459 self.log.log("Enter orpgFrame->OnMB_GameServerBrowseServers(self)", ORPG_DEBUG) 418 self.log.log("Enter orpgFrame->OnMB_GameServerBrowseServers(self)", ORPG_DEBUG)
460 if self._mgr.GetPane("Browse Server Window").IsShown() == True: 419 if self._mgr.GetPane("Browse Server Window").IsShown() == True: self._mgr.GetPane("Browse Server Window").Hide()
461 self._mgr.GetPane("Browse Server Window").Hide() 420 else: self._mgr.GetPane("Browse Server Window").Show()
462 else:
463 self._mgr.GetPane("Browse Server Window").Show()
464 self._mgr.Update() 421 self._mgr.Update()
465 self.log.log("Exit orpgFrame->OnMB_GameServerBrowseServers(self)", ORPG_DEBUG) 422 self.log.log("Exit orpgFrame->OnMB_GameServerBrowseServers(self)", ORPG_DEBUG)
466 423
467 def OnMB_GameServerServerHeartbeat(self): 424 def OnMB_GameServerServerHeartbeat(self):
468 self.log.log("Enter orpgFrame->OnMB_GameServerServerHeartbeat(self)", ORPG_DEBUG) 425 self.log.log("Enter orpgFrame->OnMB_GameServerServerHeartbeat(self)", ORPG_DEBUG)
469 if self.mainmenu.GetMenuState("GameServerServerHeartbeat"): 426 if self.mainmenu.GetMenuState("GameServerServerHeartbeat"): self.settings.set_setting('Heartbeat', '1')
470 self.settings.set_setting('Heartbeat', '1') 427 else: self.settings.set_setting('Heartbeat', '0')
471 else:
472 self.settings.set_setting('Heartbeat', '0')
473 self.log.log("Exit orpgFrame->OnMB_GameServerServerHeartbeat(self)", ORPG_DEBUG) 428 self.log.log("Exit orpgFrame->OnMB_GameServerServerHeartbeat(self)", ORPG_DEBUG)
474 429
475 def OnMB_GameServerStartServer(self): 430 def OnMB_GameServerStartServer(self):
476 self.log.log("Enter orpgFrame->OnMB_GameServerStartServer(self)", ORPG_DEBUG) 431 self.log.log("Enter orpgFrame->OnMB_GameServerStartServer(self)", ORPG_DEBUG)
477 start_dialog = wx.ProgressDialog( "Server Loading", "Server Loading, Please Wait...", 1, self ) 432 start_dialog = wx.ProgressDialog( "Server Loading", "Server Loading, Please Wait...", 1, self )
492 self.log.log("Exit orpgFrame->OnMB_GameServerStartServer(self)", ORPG_DEBUG) 447 self.log.log("Exit orpgFrame->OnMB_GameServerStartServer(self)", ORPG_DEBUG)
493 448
494 # Tools Menu 449 # Tools Menu
495 def OnMB_PluginControlPanel(self, evt): 450 def OnMB_PluginControlPanel(self, evt):
496 self.log.log("Enter orpgFrame->OnMB_ToolsPlugins(self)", ORPG_DEBUG) 451 self.log.log("Enter orpgFrame->OnMB_ToolsPlugins(self)", ORPG_DEBUG)
497 if self.pluginsFrame.IsShown() == True: 452 if self.pluginsFrame.IsShown() == True: self.pluginsFrame.Hide()
498 self.pluginsFrame.Hide() 453 else: self.pluginsFrame.Show()
499 else:
500 self.pluginsFrame.Show()
501 self.log.log("Exit orpgFrame->OnMB_ToolsPlugins(self)", ORPG_DEBUG) 454 self.log.log("Exit orpgFrame->OnMB_ToolsPlugins(self)", ORPG_DEBUG)
502 455
503 def OnMB_ToolsLoggingLevelDebug(self): 456 def OnMB_ToolsLoggingLevelDebug(self):
504 self.log.log("Enter orpgFrame->OnMB_ToolsLoggingLevelDebug(self)", ORPG_DEBUG) 457 self.log.log("Enter orpgFrame->OnMB_ToolsLoggingLevelDebug(self)", ORPG_DEBUG)
505 lvl = self.log.getLogLevel() 458 lvl = self.log.getLogLevel()
506 if self.mainmenu.GetMenuState("ToolsLoggingLevelDebug"): 459 if self.mainmenu.GetMenuState("ToolsLoggingLevelDebug"): lvl |= ORPG_DEBUG
507 lvl |= ORPG_DEBUG 460 else: lvl &= ~ORPG_DEBUG
508 else:
509 lvl &= ~ORPG_DEBUG
510 self.log.setLogLevel(lvl) 461 self.log.setLogLevel(lvl)
511 self.settings.set_setting('LoggingLevel', lvl) 462 self.settings.set_setting('LoggingLevel', lvl)
512 self.log.log("Exit orpgFrame->OnMB_ToolsLoggingLevelDebug(self)", ORPG_DEBUG) 463 self.log.log("Exit orpgFrame->OnMB_ToolsLoggingLevelDebug(self)", ORPG_DEBUG)
513 464
514 def OnMB_ToolsLoggingLevelNote(self): 465 def OnMB_ToolsLoggingLevelNote(self):
515 self.log.log("Enter orpgFrame->OnMB_ToolsLoggingLevelNote(self)", ORPG_DEBUG) 466 self.log.log("Enter orpgFrame->OnMB_ToolsLoggingLevelNote(self)", ORPG_DEBUG)
516 lvl = self.log.getLogLevel() 467 lvl = self.log.getLogLevel()
517 if self.mainmenu.GetMenuState("ToolsLoggingLevelNote"): 468 if self.mainmenu.GetMenuState("ToolsLoggingLevelNote"): lvl |= ORPG_DEBUG
518 lvl |= ORPG_DEBUG 469 else: lvl &= ~ORPG_DEBUG
519 else:
520 lvl &= ~ORPG_DEBUG
521 self.log.setLogLevel(lvl) 470 self.log.setLogLevel(lvl)
522 self.settings.set_setting('LoggingLevel', lvl) 471 self.settings.set_setting('LoggingLevel', lvl)
523 self.log.log("Exit orpgFrame->OnMB_ToolsLoggingLevelNote(self)", ORPG_DEBUG) 472 self.log.log("Exit orpgFrame->OnMB_ToolsLoggingLevelNote(self)", ORPG_DEBUG)
524 473
525 def OnMB_ToolsLoggingLevelInfo(self): 474 def OnMB_ToolsLoggingLevelInfo(self):
526 self.log.log("Enter orpgFrame->OnMB_ToolsLoggingLevelInfo(self)", ORPG_DEBUG) 475 self.log.log("Enter orpgFrame->OnMB_ToolsLoggingLevelInfo(self)", ORPG_DEBUG)
527 lvl = self.log.getLogLevel() 476 lvl = self.log.getLogLevel()
528 if self.mainmenu.GetMenuState("ToolsLoggingLevelInfo"): 477 if self.mainmenu.GetMenuState("ToolsLoggingLevelInfo"): lvl |= ORPG_INFO
529 lvl |= ORPG_INFO 478 else: lvl &= ~ORPG_INFO
530 else:
531 lvl &= ~ORPG_INFO
532 self.log.setLogLevel(lvl) 479 self.log.setLogLevel(lvl)
533 self.settings.set_setting('LoggingLevel', lvl) 480 self.settings.set_setting('LoggingLevel', lvl)
534 self.log.log("Exit orpgFrame->OnMB_ToolsLoggingLevelInfo(self)", ORPG_DEBUG) 481 self.log.log("Exit orpgFrame->OnMB_ToolsLoggingLevelInfo(self)", ORPG_DEBUG)
535 482
536 def OnMB_ToolsLoggingLevelGeneral(self): 483 def OnMB_ToolsLoggingLevelGeneral(self):
537 self.log.log("Enter orpgFrame->OnMB_ToolsLoggingLevelGeneral(self)", ORPG_DEBUG) 484 self.log.log("Enter orpgFrame->OnMB_ToolsLoggingLevelGeneral(self)", ORPG_DEBUG)
538 lvl = self.log.getLogLevel() 485 lvl = self.log.getLogLevel()
539 if self.mainmenu.GetMenuState("ToolsLoggingLevelGeneral"): 486 if self.mainmenu.GetMenuState("ToolsLoggingLevelGeneral"): lvl |= ORPG_GENERAL
540 lvl |= ORPG_GENERAL 487 else: lvl &= ~ORPG_GENERAL
541 else:
542 lvl &= ~ORPG_GENERAL
543 self.log.setLogLevel(lvl) 488 self.log.setLogLevel(lvl)
544 self.settings.set_setting('LoggingLevel', lvl) 489 self.settings.set_setting('LoggingLevel', lvl)
545 self.log.log("Exit orpgFrame->OnMB_ToolsLoggingLevelGeneral(self)", ORPG_DEBUG) 490 self.log.log("Exit orpgFrame->OnMB_ToolsLoggingLevelGeneral(self)", ORPG_DEBUG)
546 491
547 def OnMB_ToolsPasswordManager(self): 492 def OnMB_ToolsPasswordManager(self):
548 self.log.log("Enter orpgFrame->OnMB_ToolsPasswordManager(self)", ORPG_DEBUG) 493 self.log.log("Enter orpgFrame->OnMB_ToolsPasswordManager(self)", ORPG_DEBUG)
549 if self.mainmenu.GetMenuState("ToolsPasswordManager"): 494 if self.mainmenu.GetMenuState("ToolsPasswordManager"): self.password_manager.Enable()
550 self.password_manager.Enable() 495 else: self.password_manager.Disable()
551 else:
552 self.password_manager.Disable()
553 self.log.log("Exit orpgFrame->OnMB_ToolsPasswordManager(self)", ORPG_DEBUG) 496 self.log.log("Exit orpgFrame->OnMB_ToolsPasswordManager(self)", ORPG_DEBUG)
554 497
555 def OnMB_ToolsStatusBar(self): 498 def OnMB_ToolsStatusBar(self):
556 self.log.log("Enter orpgFrame->OnMB_ToolsStatusBar(self)", ORPG_DEBUG) 499 self.log.log("Enter orpgFrame->OnMB_ToolsStatusBar(self)", ORPG_DEBUG)
557 if self._mgr.GetPane("Status Window").IsShown() == True: 500 if self._mgr.GetPane("Status Window").IsShown() == True:
758 #Load the layout if one exists 701 #Load the layout if one exists
759 layout = xml_dom.getElementsByTagName("DockLayout") 702 layout = xml_dom.getElementsByTagName("DockLayout")
760 try: 703 try:
761 textnode = self.xml.safe_get_text_node(layout[0]) 704 textnode = self.xml.safe_get_text_node(layout[0])
762 self._mgr.LoadPerspective(textnode._get_nodeValue()) 705 self._mgr.LoadPerspective(textnode._get_nodeValue())
763 except: 706 except: pass
764 pass
765 xml_dom.unlink() 707 xml_dom.unlink()
766 self.log.log("Perspective Loaded", ORPG_DEBUG) 708 self.log.log("Perspective Loaded", ORPG_DEBUG)
767 self._mgr.GetPane("Browse Server Window").Hide() 709 self._mgr.GetPane("Browse Server Window").Hide()
768 self._mgr.Update() 710 self._mgr.Update()
769 self.Maximize(maximized) 711 self.Maximize(maximized)
785 return temp_wnd 727 return temp_wnd
786 728
787 def build_window(self, xml_dom, parent_wnd): 729 def build_window(self, xml_dom, parent_wnd):
788 name = xml_dom._get_nodeName() 730 name = xml_dom._get_nodeName()
789 self.log.log("Enter orpgFrame->build_window(" + name + ")", ORPG_DEBUG) 731 self.log.log("Enter orpgFrame->build_window(" + name + ")", ORPG_DEBUG)
790 if name == "DockLayout" or name == "dock": 732 if name == "DockLayout" or name == "dock": return
791 return
792 dir = xml_dom.getAttribute("direction") 733 dir = xml_dom.getAttribute("direction")
793 pos = xml_dom.getAttribute("pos") 734 pos = xml_dom.getAttribute("pos")
794 height = xml_dom.getAttribute("height") 735 height = xml_dom.getAttribute("height")
795 width = xml_dom.getAttribute("width") 736 width = xml_dom.getAttribute("width")
796 cap = xml_dom.getAttribute("caption") 737 cap = xml_dom.getAttribute("caption")
797 dockable = xml_dom.getAttribute("dockable") 738 dockable = xml_dom.getAttribute("dockable")
798 layer = xml_dom.getAttribute("layer") 739 layer = xml_dom.getAttribute("layer")
799 740
800 try: 741 try: layer = int(layer); dockable = int(dockable)
801 layer = int(layer) 742 except: layer = 0; dockable = 1
802 dockable = int(dockable) 743
803 except: 744 if name == "tab": temp_wnd = self.do_tab_window(xml_dom, parent_wnd)
804 layer = 0
805 dockable = 1
806
807 if name == "tab":
808 temp_wnd = self.do_tab_window(xml_dom, parent_wnd)
809 elif name == "map": 745 elif name == "map":
810 temp_wnd = orpg.mapper.map.map_wnd(parent_wnd, -1) 746 temp_wnd = orpg.mapper.map.map_wnd(parent_wnd, -1)
811 self.map = temp_wnd 747 self.map = temp_wnd
812 elif name == "tree": 748 elif name == "tree":
813 temp_wnd = orpg.gametree.gametree.game_tree(parent_wnd, -1) 749 temp_wnd = orpg.gametree.gametree.game_tree(parent_wnd, -1)
831 self.players.SetBackgroundColour(self.settings.get_setting('bgcolor')) 767 self.players.SetBackgroundColour(self.settings.get_setting('bgcolor'))
832 self.players.SetForegroundColour(self.settings.get_setting('textcolor')) 768 self.players.SetForegroundColour(self.settings.get_setting('textcolor'))
833 else: 769 else:
834 self.players.SetBackgroundColour('white') 770 self.players.SetBackgroundColour('white')
835 self.players.SetForegroundColour('black') 771 self.players.SetForegroundColour('black')
836 if parent_wnd != self: 772
837 #We dont need this if the window are beeing tabed 773 if parent_wnd != self: return temp_wnd
838 return temp_wnd
839 menuid = wx.NewId() 774 menuid = wx.NewId()
840 self.windowsmenu.Append(menuid, cap, kind=wx.ITEM_CHECK) 775 self.windowsmenu.Append(menuid, cap, kind=wx.ITEM_CHECK)
841 self.windowsmenu.Check(menuid, True) 776 self.windowsmenu.Check(menuid, True)
842 self.Bind(wx.EVT_MENU, self.OnMB_WindowsMenu, id=menuid) 777 self.Bind(wx.EVT_MENU, self.OnMB_WindowsMenu, id=menuid)
843 self.mainwindows[menuid] = cap 778 self.mainwindows[menuid] = cap
848 wndinfo.BestSize(wx.Size(int(width), int(height))) 783 wndinfo.BestSize(wx.Size(int(width), int(height)))
849 wndinfo.Layer(int(layer)) 784 wndinfo.Layer(int(layer))
850 wndinfo.Caption(cap) 785 wndinfo.Caption(cap)
851 786
852 # Lambda here should work! (future dev) 787 # Lambda here should work! (future dev)
853 if dir.lower() == 'top': 788 if dir.lower() == 'top': wndinfo.Top()
854 wndinfo.Top() 789 elif dir.lower() == 'bottom': wndinfo.Bottom()
855 elif dir.lower() == 'bottom': 790 elif dir.lower() == 'left': wndinfo.Left()
856 wndinfo.Bottom() 791 elif dir.lower() == 'right': wndinfo.Right()
857 elif dir.lower() == 'left': 792 elif dir.lower() == 'center': wndinfo.Center(); wndinfo.CaptionVisible(False)
858 wndinfo.Left()
859 elif dir.lower() == 'right':
860 wndinfo.Right()
861 elif dir.lower() == 'center':
862 wndinfo.Center()
863 wndinfo.CaptionVisible(False)
864 793
865 if dockable != 1: 794 if dockable != 1:
866 wndinfo.Dockable(False) 795 wndinfo.Dockable(False)
867 wndinfo.Floatable(False) 796 wndinfo.Floatable(False)
868 if pos != '' or pos != '0' or pos != None: 797 if pos != '' or pos != '0' or pos != None:
874 803
875 def onPaneClose(self, evt): 804 def onPaneClose(self, evt):
876 self.log.log("Enter orpgFrame->onPaneClose()", ORPG_DEBUG) 805 self.log.log("Enter orpgFrame->onPaneClose()", ORPG_DEBUG)
877 pane = evt.GetPane() 806 pane = evt.GetPane()
878 for wndid, wname in self.mainwindows.iteritems(): 807 for wndid, wname in self.mainwindows.iteritems():
879 if pane.name == wname: 808 if pane.name == wname: self.windowsmenu.Check(wndid, False); break
880 self.windowsmenu.Check(wndid, False)
881 break
882 evt.Skip() 809 evt.Skip()
883 self._mgr.Update() 810 self._mgr.Update()
884 self.log.log("Exit orpgFrame->onPaneClose()", ORPG_DEBUG) 811 self.log.log("Exit orpgFrame->onPaneClose()", ORPG_DEBUG)
885 812
886 def saveLayout(self): 813 def saveLayout(self):
890 txt = temp_file.read() 817 txt = temp_file.read()
891 xml_dom = self.xml.parseXml(txt)._get_documentElement() 818 xml_dom = self.xml.parseXml(txt)._get_documentElement()
892 temp_file.close() 819 temp_file.close()
893 (x_size,y_size) = self.GetClientSize() 820 (x_size,y_size) = self.GetClientSize()
894 (x_pos,y_pos) = self.GetPositionTuple() 821 (x_pos,y_pos) = self.GetPositionTuple()
895 if self.IsMaximized(): 822 if self.IsMaximized(): max = 1
896 max = 1 823 else: max = 0
897 else:
898 max = 0
899 xml_dom.setAttribute("height", str(y_size)) 824 xml_dom.setAttribute("height", str(y_size))
900 xml_dom.setAttribute("width", str(x_size)) 825 xml_dom.setAttribute("width", str(x_size))
901 xml_dom.setAttribute("posx", str(x_pos)) 826 xml_dom.setAttribute("posx", str(x_pos))
902 xml_dom.setAttribute("posy", str(y_pos)) 827 xml_dom.setAttribute("posy", str(y_pos))
903 xml_dom.setAttribute("maximized", str(max)) 828 xml_dom.setAttribute("maximized", str(max))
948 873
949 def on_status_event(self, evt): 874 def on_status_event(self, evt):
950 self.log.log("Enter orpgFrame->on_status_event(self, evt)", ORPG_DEBUG) 875 self.log.log("Enter orpgFrame->on_status_event(self, evt)", ORPG_DEBUG)
951 id = evt.get_id() 876 id = evt.get_id()
952 status = evt.get_data() 877 status = evt.get_data()
953 if id == orpg.networking.mplay_client.STATUS_SET_URL: 878 if id == orpg.networking.mplay_client.STATUS_SET_URL: self.status.set_url(status)
954 self.status.set_url(status)
955 self.log.log("Exit orpgFrame->on_status_event(self, evt)", ORPG_DEBUG) 879 self.log.log("Exit orpgFrame->on_status_event(self, evt)", ORPG_DEBUG)
956 880
957 def on_player_event(self, evt): 881 def on_player_event(self, evt):
958 self.log.log("Enter orpgFrame->on_player_event(self, evt)", ORPG_DEBUG) 882 self.log.log("Enter orpgFrame->on_player_event(self, evt)", ORPG_DEBUG)
959 id = evt.get_id() 883 id = evt.get_id()
974 def on_group_event(self, evt): 898 def on_group_event(self, evt):
975 self.log.log("Enter orpgFrame->on_group_event(self, evt)", ORPG_DEBUG) 899 self.log.log("Enter orpgFrame->on_group_event(self, evt)", ORPG_DEBUG)
976 id = evt.get_id() 900 id = evt.get_id()
977 data = evt.get_data() 901 data = evt.get_data()
978 902
979 if id == orpg.networking.mplay_client.GROUP_NEW: 903 if id == orpg.networking.mplay_client.GROUP_NEW: self.gs.add_room(data)
980 self.gs.add_room(data)
981 elif id == orpg.networking.mplay_client.GROUP_DEL: 904 elif id == orpg.networking.mplay_client.GROUP_DEL:
982 self.password_manager.RemoveGroupData(data) 905 self.password_manager.RemoveGroupData(data)
983 self.gs.del_room(data) 906 self.gs.del_room(data)
984 elif id == orpg.networking.mplay_client.GROUP_UPDATE: 907 elif id == orpg.networking.mplay_client.GROUP_UPDATE: self.gs.update_room(data)
985 self.gs.update_room(data)
986 self.log.log("Exit orpgFrame->on_group_event(self, evt)", ORPG_DEBUG) 908 self.log.log("Exit orpgFrame->on_group_event(self, evt)", ORPG_DEBUG)
987 909
988 def on_receive(self, data, player): 910 def on_receive(self, data, player):
989 self.log.log("Enter orpgFrame->on_receive(self, data, player)", ORPG_DEBUG) 911 self.log.log("Enter orpgFrame->on_receive(self, data, player)", ORPG_DEBUG)
990 912
991 # see if we are ignoring this user 913 # see if we are ignoring this user
992 (ignore_id,ignore_name) = self.session.get_ignore_list() 914 (ignore_id,ignore_name) = self.session.get_ignore_list()
993 for m in ignore_id: 915 for m in ignore_id:
994 if m == player[2]: 916 if m == player[2]: self.log.log("ignoring message from player:" + player[0], ORPG_INFO, True); return
995 # yes we are
996 self.log.log("ignoring message from player:" + player[0], ORPG_INFO, True)
997 return
998 917
999 # ok we are not ignoring this message 918 # ok we are not ignoring this message
1000 #recvSound = "RecvSound" # this will be the default sound. Whisper will change this below 919 #recvSound = "RecvSound" # this will be the default sound. Whisper will change this below
1001 if player: 920 if player: display_name = self.chat.chat_display_name(player)
1002 display_name = self.chat.chat_display_name(player) 921 else: display_name = "Server Administrator"
1003 else:
1004 display_name = "Server Administrator"
1005 922
1006 if data[:5] == "<tree": 923 if data[:5] == "<tree":
1007 self.tree.on_receive_data(data,player) 924 self.tree.on_receive_data(data,player)
1008 self.chat.InfoPost(display_name + " has sent you a tree node...") 925 self.chat.InfoPost(display_name + " has sent you a tree node...")
1009 #self.tree.OnNewData(data) 926 #self.tree.OnNewData(data)
1010 927
1011 elif data[:4] == "<map": 928 elif data[:4] == "<map": self.map.new_data(data)
1012 self.map.new_data(data)
1013 929
1014 elif data[:5] == "<chat": 930 elif data[:5] == "<chat":
1015 msg = orpg.chat.chat_msg.chat_msg(data) 931 msg = orpg.chat.chat_msg.chat_msg(data)
1016 self.chat.post_incoming_msg(msg,player) 932 self.chat.post_incoming_msg(msg,player)
1017 else: 933 else:
1045 data = data.replace("/w","") 961 data = data.replace("/w","")
1046 data = "<b>" + display_name + "</b> (whispering): " + data 962 data = "<b>" + display_name + "</b> (whispering): " + data
1047 963
1048 else: 964 else:
1049 # Normal text 965 # Normal text
1050 if player: 966 if player: data = "<b>" + display_name + "</b>: " + data
1051 data = "<b>" + display_name + "</b>: " + data 967 else: data = "<b><i><u>" + display_name + "</u>-></i></b> " + data
1052 else:
1053 data = "<b><i><u>" + display_name + "</u>-></i></b> " + data
1054 self.chat.Post(data) 968 self.chat.Post(data)
1055 self.log.log("Exit orpgFrame->on_receive(self, data, player)", ORPG_DEBUG) 969 self.log.log("Exit orpgFrame->on_receive(self, data, player)", ORPG_DEBUG)
1056 970
1057 def on_mplay_event(self, evt): 971 def on_mplay_event(self, evt):
1058 self.log.log("Enter orpgFrame->on_mplay_event(self, evt)", ORPG_DEBUG) 972 self.log.log("Enter orpgFrame->on_mplay_event(self, evt)", ORPG_DEBUG)
1074 ####Begin changes for Custom Exit Message by mDuo13###### 988 ####Begin changes for Custom Exit Message by mDuo13######
1075 elif id == orpg.networking.mplay_client.MPLAY_DISCONNECTING: 989 elif id == orpg.networking.mplay_client.MPLAY_DISCONNECTING:
1076 settings = open_rpg.get_component('settings') 990 settings = open_rpg.get_component('settings')
1077 custom_msg = settings.get_setting("dcmsg") 991 custom_msg = settings.get_setting("dcmsg")
1078 custom_msg=custom_msg[:80] 992 custom_msg=custom_msg[:80]
1079 if custom_msg[:3]=="/me": 993 if custom_msg[:3]=="/me": self.chat.send_chat_message(custom_msg[3:], 3)
1080 self.chat.send_chat_message(custom_msg[3:], 3) 994 else: self.chat.system_message(custom_msg)
1081 else:
1082 self.chat.system_message(custom_msg)
1083 #####End Changes for Custom Exit Message by mDuo13 995 #####End Changes for Custom Exit Message by mDuo13
1084 996
1085 elif id== orpg.networking.mplay_client.MPLAY_GROUP_CHANGE: 997 elif id== orpg.networking.mplay_client.MPLAY_GROUP_CHANGE:
1086 group = evt.get_data() 998 group = evt.get_data()
1087 self.chat.InfoPost("Moving to room '"+group[1]+"'..") 999 self.chat.InfoPost("Moving to room '"+group[1]+"'..")
1106 1018
1107 #following lines added by mDuo13 1019 #following lines added by mDuo13
1108 #########plugin_disabled()######### 1020 #########plugin_disabled()#########
1109 for plugin_fname in self.activeplugins.keys(): 1021 for plugin_fname in self.activeplugins.keys():
1110 plugin = self.activeplugins[plugin_fname] 1022 plugin = self.activeplugins[plugin_fname]
1111 try: 1023 try: plugin.plugin_disabled()
1112 plugin.plugin_disabled()
1113 except Exception, e: 1024 except Exception, e:
1114 if str(e) != "'module' object has no attribute 'plugin_disabled'": 1025 if str(e) != "'module' object has no attribute 'plugin_disabled'":
1115 #print e 1026 #print e
1116 traceback.print_exc() 1027 traceback.print_exc()
1117 #end mDuo13 added code 1028 #end mDuo13 added code
1118 self.saveLayout() 1029 self.saveLayout()
1119 try: 1030 try: self.settings.save()
1120 self.settings.save() 1031 except: self.log.log("[WARNING] Error saving 'settings' component", ORPG_GENERAL, True)
1121 except: 1032
1122 self.log.log("[WARNING] Error saving 'settings' component", ORPG_GENERAL, True) 1033 try: self.map.pre_exit_cleanup()
1123 1034 except: self.log.log("[WARNING] Map error pre_exit_cleanup()", ORPG_GENERAL, True)
1124 try:
1125 self.map.pre_exit_cleanup()
1126 except:
1127 self.log.log("[WARNING] Map error pre_exit_cleanup()", ORPG_GENERAL, True)
1128 1035
1129 try: 1036 try:
1130 save_tree = string.upper(self.settings.get_setting("SaveGameTreeOnExit")) 1037 save_tree = string.upper(self.settings.get_setting("SaveGameTreeOnExit"))
1131 if (save_tree != "0") and (save_tree != "False") and (save_tree != "NO"): 1038 if (save_tree != "0") and (save_tree != "False") and (save_tree != "NO"):
1132 self.tree.save_tree(self.settings.get_setting("gametree")) 1039 self.tree.save_tree(self.settings.get_setting("gametree"))
1133 except: 1040 except: self.log.log("[WARNING] Error saving gametree", ORPG_GENERAL, True)
1134 self.log.log("[WARNING] Error saving gametree", ORPG_GENERAL, True) 1041
1135 1042 if self.session.get_status() == orpg.networking.mplay_client.MPLAY_CONNECTED: self.kill_mplay_session()
1136 if self.session.get_status() == orpg.networking.mplay_client.MPLAY_CONNECTED:
1137 self.kill_mplay_session()
1138 1043
1139 try: 1044 try:
1140 #Kill all the damn timers 1045 #Kill all the damn timers
1141 self.sound_player.timer.Stop() 1046 self.sound_player.timer.Stop()
1142 del self.sound_player.timer 1047 del self.sound_player.timer
1143 except: 1048 except: self.log.log("sound didn't die properly.",ORPG_GENERAL, True)
1144 self.log.log("sound didn't die properly.",ORPG_GENERAL, True)
1145 1049
1146 try: 1050 try:
1147 self.poll_timer.Stop() 1051 self.poll_timer.Stop()
1148 self.ping_timer.Stop() 1052 self.ping_timer.Stop()
1149 self.chat.parent.chat_timer.Stop() 1053 self.chat.parent.chat_timer.Stop()
1150 self.map.canvas.zoom_display_timer.Stop() 1054 self.map.canvas.zoom_display_timer.Stop()
1151 self.map.canvas.image_timer.Stop() 1055 self.map.canvas.image_timer.Stop()
1152 self.status.timer.Stop() 1056 self.status.timer.Stop()
1153 del self.ping_timer; del self.poll_timer; del self.chat.parent.chat_timer 1057 del self.ping_timer; del self.poll_timer; del self.chat.parent.chat_timer
1154 del self.map.canvas.zoom_display_timer; del self.map.canvas.image_timer; del self.status.timer 1058 del self.map.canvas.zoom_display_timer; del self.map.canvas.image_timer; del self.status.timer
1155 except: 1059 except: self.log.log("some timer didn't die properly.",ORPG_GENERAL, True)
1156 self.log.log("some timer didn't die properly.",ORPG_GENERAL, True)
1157 self._mgr.UnInit() 1060 self._mgr.UnInit()
1158 mainapp = wx.GetApp() 1061 mainapp = wx.GetApp()
1159 mainapp.ExitMainLoop() 1062 mainapp.ExitMainLoop()
1160 self.Destroy() 1063 self.Destroy()
1161 1064
1171 self.server_pipe.close() 1074 self.server_pipe.close()
1172 self.std_out.close() 1075 self.std_out.close()
1173 self.server_thread.exit() 1076 self.server_thread.exit()
1174 dlg.Destroy() 1077 dlg.Destroy()
1175 self.log.log("Server killed:", ORPG_GENERAL, True) 1078 self.log.log("Server killed:", ORPG_GENERAL, True)
1176 except: 1079 except: pass
1177 pass
1178 self.log.log("Exit orpgFrame->closed_confirmed(self)", ORPG_DEBUG) 1080 self.log.log("Exit orpgFrame->closed_confirmed(self)", ORPG_DEBUG)
1179 1081
1180 1082
1181 ######################################## 1083 ########################################
1182 ## Application class 1084 ## Application class
1183 ######################################## 1085 ########################################
1184 class orpgSplashScreen(wx.SplashScreen): 1086 class orpgSplashScreen(wx.SplashScreen):
1185 def __init__(self, parent, bitmapfile, duration, callback): 1087 def __init__(self, parent, bitmapfile, duration, callback):
1186 wx.SplashScreen.__init__(self, wx.Bitmap(bitmapfile), wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT, duration, None, -1) 1088 wx.SplashScreen.__init__(self, wx.Bitmap(bitmapfile),
1089 wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT, duration, None, -1)
1187 self.callback = callback 1090 self.callback = callback
1188 self.closing = False 1091 self.closing = False
1189 self.Bind(wx.EVT_CLOSE, self.callback) 1092 self.Bind(wx.EVT_CLOSE, self.callback)
1190 1093
1191 class orpgApp(wx.App): 1094 class orpgApp(wx.App):
1212 wx.Yield() 1115 wx.Yield()
1213 return True 1116 return True
1214 1117
1215 def OnKeyPress(self, evt): 1118 def OnKeyPress(self, evt):
1216 #Event handler 1119 #Event handler
1217 if evt.AltDown() and evt.CmdDown() and evt.KeyCode == ord('I'): 1120 if evt.AltDown() and evt.CmdDown() and evt.KeyCode == ord('I'): self.ShowShell()
1218 self.ShowShell() 1121 else: evt.Skip()
1219 else:
1220 evt.Skip()
1221 1122
1222 def ShowShell(self): 1123 def ShowShell(self):
1223 #Show the PyCrust window. 1124 #Show the PyCrust window.
1224 if not self._crust: 1125 if not self._crust:
1225 self._crust = wx.py.crust.CrustFrame(self.GetTopWindow()) 1126 self._crust = wx.py.crust.CrustFrame(self.GetTopWindow())
1242 wx.CallAfter(self.splash.Close) 1143 wx.CallAfter(self.splash.Close)
1243 return True 1144 return True
1244 1145
1245 def OnExit_CleanUp(self): 1146 def OnExit_CleanUp(self):
1246 self.log.log("Preforming cleanup\n", ORPG_DEBUG) 1147 self.log.log("Preforming cleanup\n", ORPG_DEBUG)
1247 try: 1148 try: del os.environ["OPENRPG_BASE"]
1248 del os.environ["OPENRPG_BASE"] 1149 except: pass
1249 except: 1150 try: os.remove(os.environ["OPENRPG_BASE"] + os.sep + 'orpg' + os.sep + 'dirpath' + os.sep + 'approot.py')
1250 pass 1151 except: pass
1251 try: 1152 try: os.remove(os.environ["OPENRPG_BASE"] + os.sep + 'orpg' + os.sep + 'dirpath' + os.sep + 'approot.pyc')
1252 os.remove(os.environ["OPENRPG_BASE"] + os.sep + 'orpg' + os.sep + 'dirpath' + os.sep + 'approot.py') 1153 except: pass
1253 except:
1254 pass
1255 try:
1256 os.remove(os.environ["OPENRPG_BASE"] + os.sep + 'orpg' + os.sep + 'dirpath' + os.sep + 'approot.pyc')
1257 except:
1258 pass
1259 1154
1260 def OnExit(self): 1155 def OnExit(self):
1261 self.OnExit_CleanUp() 1156 self.OnExit_CleanUp()
1262 #Exit 1157 #Exit
1263 self.log.log("Main Application Exit\n\n", ORPG_DEBUG) 1158 self.log.log("Main Application Exit\n\n", ORPG_DEBUG)