comparison orpg/networking/mplay_server_gui.py @ 212:13054be69834 beta

Traipse Beta 'OpenRPG' {100428-00} Traipse is a distribution of OpenRPG that is designed to be easy to setup and go. Traipse also makes it easy for developers to work on code without fear of sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the code. 'Ornery-Orc's main goal is to offer more advanced features and enhance the productivity of the user. Update Summary (Patch-2) New Features: New Namespace method with two new syntaxes New Namespace Internal is context sensitive, always! New Namespace External is 'as narrow as you make it' New Namespace FutureCheck helps ensure you don't receive an incorrect node New PluginDB access for URL2Link plugin New to Forms, they now show their content in Design Mode New to Update Manager, checks Repo for updates on software start Fixes: Fix to Server GUI startup errors Fix to Server GUI Rooms tab updating Fix to Chat and Settings if non existant die roller is picked Fix to Dieroller and .open() used with .vs(). Successes are correctly calculated Fix to Alias Lib's Export to Tree, Open, Save features Fix to alias node, now works properly Fix to Splitter node, minor GUI cleanup Fix to Backgrounds not loading through remote loader Fix to Node name errors Fix to rolling dice in chat Whispers Fix to Splitters Sizing issues Fix to URL2Link plugin, modified regex compilation should remove memory leak Fix to mapy.py, a roll back due to zoomed grid issues Fix to whiteboard_handler, Circles work by you clicking the center of the circle Fix to Servers parse_incoming_dom which was outdated and did not respect XML Fix to a broken link in the server welcome message Fix to InterParse and logger requiring traceback Fix to Update Manager Status Bar Fix to failed image and erroneous pop up
author sirebral
date Wed, 28 Apr 2010 08:08:09 -0500
parents 477b646a39f4
children bb7b9648792c
comparison
equal deleted inserted replaced
194:44ef45e77880 212:13054be69834
149 149
150 def AddGroup(self, data): 150 def AddGroup(self, data):
151 (room, room_id, players, passworded) = data 151 (room, room_id, players, passworded) = data
152 i = self.InsertStringItem(0, str(room_id)) 152 i = self.InsertStringItem(0, str(room_id))
153 self.SetStringItem(i, 1, room) 153 self.SetStringItem(i, 1, room)
154 self.SetStringItem(i, 2, players) 154 self.SetStringItem(i, 2, str(players))
155 self.SetStringItem(i, 3, str(passworded)) 155 self.SetStringItem(i, 3, passworded)
156 156
157 def DeleteGroup(self, data): 157 def DeleteGroup(self, data):
158 i = self.FindItem(-1, str(data)) 158 i = self.FindItem(-1, str(data))
159 self.DeleteItem(i) 159 self.DeleteItem(i)
160 160
161 def UpdateGroup(self, data): 161 def UpdateGroup(self, data):
162 (room, room_id, players) = data 162 (room, room_id, players) = data
163 i = self.FindItem( -1, str(room_id)) 163 i = self.FindItem( -1, str(room_id))
164 self.SetStringItem( i, 1, room ) 164 self.SetStringItem( i, 1, room )
165 if players: self.SetStringItem(i, 2, str(players)) 165 self.SetStringItem(i, 2, str(players))
166 ### Need to add room for Password Updates ### 166 ### Need to add room for Password Updates ###
167 167
168 class Connections(wx.ListCtrl): 168 class Connections(wx.ListCtrl):
169 def __init__( self, parent, main ): 169 def __init__( self, parent, main ):
170 wx.ListCtrl.__init__( self, parent, -1, wx.DefaultPosition, 170 wx.ListCtrl.__init__( self, parent, -1, wx.DefaultPosition,
352 352
353 class ServerGUI(wx.Frame): 353 class ServerGUI(wx.Frame):
354 STATUS = SERVER_STOPPED 354 STATUS = SERVER_STOPPED
355 def __init__(self, parent, id, title): 355 def __init__(self, parent, id, title):
356 wx.Frame.__init__(self, parent, id, title, size = (760, 560) ) 356 wx.Frame.__init__(self, parent, id, title, size = (760, 560) )
357 if wx.Platform == '__WXMSW__': icon = wx.Icon( dir_struct["icon"]+'WAmisc9.ico', wx.BITMAP_TYPE_ICO ) 357 if wx.Platform == '__WXMSW__': icon = wx.Icon(dir_struct["icon"]+'WAmisc9.ico', wx.BITMAP_TYPE_ICO)
358 else: icon = wx.Icon( dir_struct["icon"]+'connect.gif', wx.BITMAP_TYPE_GIF ) 358 else: icon = wx.Icon(dir_struct["icon"]+'connect.gif', wx.BITMAP_TYPE_GIF)
359 self.SetIcon(icon) 359 self.SetIcon(icon)
360 self.serverName = "Server Name" 360 self.serverName = "Server Name"
361 self.bootPwd = "" 361 self.bootPwd = ""
362 self.do_log = True 362 self.do_log = True
363 363
399 """ Build the GUI menu. """ 399 """ Build the GUI menu. """
400 self.mainMenu = wx.MenuBar() 400 self.mainMenu = wx.MenuBar()
401 401
402 # File Menu 402 # File Menu
403 menu = wx.Menu() 403 menu = wx.Menu()
404 menu.Append( 1, 'Start', 'Start server.') 404 menu.Append(1, 'Start', 'Start server.')
405 menu.Append( 2, 'Stop', 'Shutdown server.') 405 menu.Append(2, 'Stop', 'Shutdown server.')
406 menu.AppendSeparator() 406 menu.AppendSeparator()
407 menu.Append( 3, 'E&xit', 'Exit application.') 407 menu.Append(3, 'E&xit', 'Exit application.')
408 self.Bind(wx.EVT_MENU, self.OnStart, id=1) 408 self.Bind(wx.EVT_MENU, self.OnStart, id=1)
409 self.Bind(wx.EVT_MENU, self.OnStop, id=2) 409 self.Bind(wx.EVT_MENU, self.OnStop, id=2)
410 self.Bind(wx.EVT_MENU, self.OnExit, id=3) 410 self.Bind(wx.EVT_MENU, self.OnExit, id=3)
411 self.mainMenu.Append(menu, '&Server') 411 self.mainMenu.Append(menu, '&Server')
412 412
413 # Registration Menu 413 # Registration Menu
414 menu = wx.Menu() 414 menu = wx.Menu()
415 menu.Append( 4, 'Register', 'Register with OpenRPG server directory.') 415 menu.Append(4, 'Register', 'Register with OpenRPG server directory.')
416 menu.Append( 5, 'Unregister', 'Unregister from OpenRPG server directory.') 416 menu.Append(5, 'Unregister', 'Unregister from OpenRPG server directory.')
417 self.Bind(wx.EVT_MENU, self.OnRegister, id=4) 417 self.Bind(wx.EVT_MENU, self.OnRegister, id=4)
418 self.Bind(wx.EVT_MENU, self.OnUnregister, id=5) 418 self.Bind(wx.EVT_MENU, self.OnUnregister, id=5)
419 self.mainMenu.Append( menu, '&Registration' ) 419 self.mainMenu.Append( menu, '&Registration' )
420 420
421 # Server Configuration Menu 421 # Server Configuration Menu
422 menu = wx.Menu() 422 menu = wx.Menu()
423 menu.Append( 6, 'Ban List', 'Modify Ban List.') 423 menu.Append(6, 'Ban List', 'Modify Ban List.')
424 menu.Append(11, 'Zombies', 'Set auto-kick time for zombie clients') 424 menu.Append(11, 'Zombies', 'Set auto-kick time for zombie clients')
425 menu.Append(14, 'Send Size', 'Adjust the send size limit') 425 menu.Append(14, 'Send Size', 'Adjust the send size limit')
426 menu.AppendSeparator() 426 menu.AppendSeparator()
427 menu.Append( 7, 'Start Ping', 'Ping players to validate remote connection.' ) 427 menu.Append(7, 'Start Ping', 'Ping players to validate remote connection.' )
428 menu.Append( 8, 'Stop Ping', 'Stop validating player connections.' ) 428 menu.Append(8, 'Stop Ping', 'Stop validating player connections.' )
429 menu.Append( 9, 'Ping Interval', 'Change the ping interval.' ) 429 menu.Append(9, 'Ping Interval', 'Change the ping interval.' )
430 menu.AppendSeparator() 430 menu.AppendSeparator()
431 menu.AppendCheckItem( 10, 'Server Logging', 'Turn on or off the Server GUI Log').Check(self.do_log) 431 menu.AppendCheckItem(10, 'Server Logging',
432 'Turn on or off the Server GUI Log').Check(self.do_log)
432 menu.AppendCheckItem(12, 'Room Passwords', 'Allow or Deny Room Passwords').Check(False) 433 menu.AppendCheckItem(12, 'Room Passwords', 'Allow or Deny Room Passwords').Check(False)
433 menu.AppendCheckItem(13, 'Remote Admin', 'Allow or Deny Remote Admin').Check(False) 434 menu.AppendCheckItem(13, 'Remote Admin', 'Allow or Deny Remote Admin').Check(False)
434 menu.AppendCheckItem(15, 'Remote Kill', 'Allow or Deny Remote Admin Server Kill').Check(False) 435 menu.AppendCheckItem(15, 'Remote Kill', 'Allow or Deny Remote Admin Server Kill').Check(False)
435 self.Bind(wx.EVT_MENU, self.ModifyBanList, id=6) 436 self.Bind(wx.EVT_MENU, self.ModifyBanList, id=6)
436 self.Bind(wx.EVT_MENU, self.PingPlayers, id=7) 437 self.Bind(wx.EVT_MENU, self.PingPlayers, id=7)
437 self.Bind(wx.EVT_MENU, self.StopPingPlayers, id=8) 438 self.Bind(wx.EVT_MENU, self.StopPingPlayers, id=8)
438 self.Bind(wx.EVT_MENU, self.ConfigPingInterval, id=9) 439 self.Bind(wx.EVT_MENU, self.ConfigPingInterval, id=9)
439 self.Bind(wx.EVT_MENU, self.LogToggle, id=10) 440 self.Bind(wx.EVT_MENU, self.LogToggle, id=10)
440 self.mainMenu.Append( menu, '&Configuration' ) 441 self.mainMenu.Append( menu, '&Configuration')
441 self.SetMenuBar( self.mainMenu ) 442 self.SetMenuBar(self.mainMenu)
442 443
443 self.mainMenu.Enable( 2, False ) 444 self.mainMenu.Enable(2, False)
444 self.mainMenu.Enable( 4, False ) 445 self.mainMenu.Enable(4, False)
445 self.mainMenu.Enable( 5, False ) 446 self.mainMenu.Enable(5, False)
446 447
447 # Disable the ping menu items 448 # Disable the ping menu items
448 self.mainMenu.Enable( 7, False ) 449 self.mainMenu.Enable(7, False)
449 self.mainMenu.Enable( 8, False ) 450 self.mainMenu.Enable(8, False)
450 self.mainMenu.Enable( 9, False ) 451 self.mainMenu.Enable(9, False)
451 452
452 # Disable placeholders 453 # Disable placeholders
453 self.mainMenu.Enable( 11, False ) 454 self.mainMenu.Enable(11, False)
454 self.mainMenu.Enable( 14, False ) 455 self.mainMenu.Enable(14, False)
455 self.mainMenu.Enable( 12, False ) 456 self.mainMenu.Enable(12, False)
456 self.mainMenu.Enable( 13, False ) 457 self.mainMenu.Enable(13, False)
457 self.mainMenu.Enable( 15, False ) 458 self.mainMenu.Enable(15, False)
459
458 def build_body(self): 460 def build_body(self):
459 """ Create the ViewNotebook and logger. """ 461 """ Create the ViewNotebook and logger. """
460 splitter = wx.SplitterWindow(self, -1, style=wx.NO_3D | wx.SP_3D) 462 splitter = wx.SplitterWindow(self, -1, style=wx.NO_3D | wx.SP_3D)
461 nb = wx.Notebook( splitter, -1 ) 463 nb = wx.Notebook(splitter, -1)
462 self.conns = Connections(nb, self) 464 self.conns = Connections(nb, self)
463 self.groups = Groups(nb, self) 465 self.groups = Groups(nb, self)
464 self.msgWindow = HTMLMessageWindow( nb ) 466 self.msgWindow = HTMLMessageWindow(nb)
465 nb.AddPage(self.conns, "Players") 467 nb.AddPage(self.conns, "Players")
466 nb.AddPage(self.groups, 'Rooms') 468 nb.AddPage(self.groups, 'Rooms')
467 nb.AddPage( self.msgWindow, "Messages" ) 469 nb.AddPage(self.msgWindow, "Messages")
468 470
469 log = wx.TextCtrl(splitter, -1, style=wx.TE_MULTILINE | wx.TE_READONLY | wx.HSCROLL) 471 log = wx.TextCtrl(splitter, -1, style=wx.TE_MULTILINE | wx.TE_READONLY | wx.HSCROLL)
470 wx.Log.SetActiveTarget( wx.LogTextCtrl(log) ) 472 wx.Log.SetActiveTarget(wx.LogTextCtrl(log))
471 splitter.SplitHorizontally(nb, log, 400) 473 splitter.SplitHorizontally(nb, log, 400)
472 splitter.SetMinimumPaneSize(40) 474 splitter.SetMinimumPaneSize(40)
473 self.nb = nb 475 self.nb = nb
474 self.log = log 476 self.log = log
475 477
520 self.conns.update(data) 522 self.conns.update(data)
521 523
522 def OnDataSent(self, bytes): 524 def OnDataSent(self, bytes):
523 self.total_messages_sent += 1 525 self.total_messages_sent += 1
524 self.total_data_sent += bytes 526 self.total_data_sent += bytes
525 self.sb.SetStatusText("Sent: %s (%d)" % (format_bytes(self.total_data_sent), self.total_messages_sent), 1) 527 self.sb.SetStatusText("Sent: %s (%d)" % (format_bytes(self.total_data_sent),
528 self.total_messages_sent), 1)
526 529
527 def OnDataRecv(self, bytes): 530 def OnDataRecv(self, bytes):
528 self.total_messages_received += 1 531 self.total_messages_received += 1
529 self.total_data_received += bytes 532 self.total_data_received += bytes
530 self.sb.SetStatusText("Recv: %s (%d)" % (format_bytes(self.total_data_received), self.total_messages_received), 2) 533 self.sb.SetStatusText("Recv: %s (%d)" % (format_bytes(self.total_data_received),
534 self.total_messages_received), 2)
531 535
532 def OnCreateGroup( self, data ): 536 def OnCreateGroup( self, data ):
533 (room, room_id, player, pwd) = data 537 (room, room_id, player, pwd) = data
534 self.groups.AddGroup(data) 538 self.groups.AddGroup(data)
535 self.conns.roomList[room_id] = room 539 self.conns.roomList[room_id] = room
543 547
544 def OnJoinGroup(self, data): 548 def OnJoinGroup(self, data):
545 self.conns.updateRoom(data) 549 self.conns.updateRoom(data)
546 550
547 def OnUpdateGroup(self, data): 551 def OnUpdateGroup(self, data):
548 (room, room_id, players) = data 552 (room, room_id, players) = data; print 'update group', data
549 self.groups.UpdateGroup(data) 553 self.groups.UpdateGroup(data)
550 554
551 def OnSetRole( self, data ): 555 def OnSetRole( self, data ):
552 (id, role) = data 556 (id, role) = data
553 self.conns.setPlayerRole(id, role) 557 self.conns.setPlayerRole(id, role)
567 if configDoc.get("admin"): self.bootPwd = configDoc.get("admin") 571 if configDoc.get("admin"): self.bootPwd = configDoc.get("admin")
568 elif configDoc.get("boot"): self.bootPwd = configDoc.get("boot") 572 elif configDoc.get("boot"): self.bootPwd = configDoc.get("boot")
569 except: pass 573 except: pass
570 if self.serverName == '': 574 if self.serverName == '':
571 self.serverName = 'Server Name' 575 self.serverName = 'Server Name'
572 serverNameEntry = wx.TextEntryDialog(self, "Please Enter The Server Name You Wish To Use:", 576 serverNameEntry = wx.TextEntryDialog(self,
573 "Server's Name", self.serverName, wx.OK|wx.CANCEL|wx.CENTRE ) 577 "Please Enter The Server Name You Wish To Use:",
578 "Server's Name",
579 self.serverName, wx.OK|wx.CANCEL|wx.CENTRE)
574 if serverNameEntry.ShowModal() == wx.ID_OK: self.serverName = serverNameEntry.GetValue() 580 if serverNameEntry.ShowModal() == wx.ID_OK: self.serverName = serverNameEntry.GetValue()
575 if self.bootPwd == '': 581 if self.bootPwd == '':
576 serverPasswordEntry = wx.TextEntryDialog(self, 582 serverPasswordEntry = wx.TextEntryDialog(self,
577 "Please Enter The Server Admin Password:", "Server's Password", 583 "Please Enter The Server Admin Password:",
578 self.bootPwd, wx.OK|wx.CANCEL|wx.CENTRE) 584 "Server's Password",
585 self.bootPwd, wx.OK|wx.CANCEL|wx.CENTRE)
579 if serverPasswordEntry.ShowModal() == wx.ID_OK: self.bootPwd = serverPasswordEntry.GetValue() 586 if serverPasswordEntry.ShowModal() == wx.ID_OK: self.bootPwd = serverPasswordEntry.GetValue()
580 if len(self.serverName): 587 if len(self.serverName):
581 wx.BeginBusyCursor() 588 wx.BeginBusyCursor()
582 self.server = ServerMonitor(self.callbacks, self.conf, self.serverName, self.bootPwd) 589 self.server = ServerMonitor(self.callbacks, self.conf, self.serverName, self.bootPwd)
583 self.server.start() 590 self.server.start()
584 self.STATUS = SERVER_RUNNING 591 self.STATUS = SERVER_RUNNING
585 self.sb.SetStatusText("Running", 3) 592 self.sb.SetStatusText("Running", 3)
586 self.SetTitle(__appname__ + "- (running) - (unregistered)") 593 self.SetTitle(__appname__ + "- (running) - (unregistered)")
587 self.mainMenu.Enable( 1, False ) 594 self.mainMenu.Enable(1, False)
588 self.mainMenu.Enable( 2, True ) 595 self.mainMenu.Enable(2, True)
589 self.mainMenu.Enable( 4, True ) 596 self.mainMenu.Enable(4, True)
590 wx.EndBusyCursor() 597 wx.EndBusyCursor()
591 else: self.show_error("Server is already running.", "Error Starting Server") 598 else: self.show_error("Server is already running.", "Error Starting Server")
592 599
593 def OnStop(self, event = None): 600 def OnStop(self, event = None):
594 """ Stop server. """ 601 """ Stop server. """
596 self.OnUnregister() 603 self.OnUnregister()
597 self.server.stop() 604 self.server.stop()
598 self.STATUS = SERVER_STOPPED 605 self.STATUS = SERVER_STOPPED
599 self.sb.SetStatusText("Stopped", 3) 606 self.sb.SetStatusText("Stopped", 3)
600 self.SetTitle(__appname__ + "- (stopped) - (unregistered)") 607 self.SetTitle(__appname__ + "- (stopped) - (unregistered)")
601 self.mainMenu.Enable( 1, True ) 608 self.mainMenu.Enable(1, True)
602 self.mainMenu.Enable( 2, False ) 609 self.mainMenu.Enable(2, False)
603 self.mainMenu.Enable( 4, False ) 610 self.mainMenu.Enable(4, False)
604 self.mainMenu.Enable( 5, False ) 611 self.mainMenu.Enable(5, False)
605 self.conns.DeleteAllItems() 612 self.conns.DeleteAllItems()
606 613
607 def OnRegister(self, event = None): 614 def OnRegister(self, event = None):
608 """ Call into mplay_server's register() function. 615 """ Call into mplay_server's register() function.
609 This will begin registerThread(s) to keep server 616 This will begin registerThread(s) to keep server
611 """ 618 """
612 if len( self.serverName ): 619 if len( self.serverName ):
613 wx.BeginBusyCursor() 620 wx.BeginBusyCursor()
614 self.server.server.register(self.serverName) 621 self.server.server.register(self.serverName)
615 self.sb.SetStatusText( ("%s" % (self.serverName)), 4 ) 622 self.sb.SetStatusText( ("%s" % (self.serverName)), 4 )
616 self.mainMenu.Enable( 4, False ) 623 self.mainMenu.Enable(4, False)
617 self.mainMenu.Enable( 5, True ) 624 self.mainMenu.Enable(5, True)
618 #self.mainMenu.Enable( 2, False ) 625 #self.mainMenu.Enable( 2, False )
619 self.SetTitle(__appname__ + "- (running) - (registered)") 626 self.SetTitle(__appname__ + "- (running) - (registered)")
620 wx.EndBusyCursor() 627 wx.EndBusyCursor()
621 628
622 def OnUnregister(self, event = None): 629 def OnUnregister(self, event = None):
625 and result in the server being de-listed 632 and result in the server being de-listed
626 from all metas 633 from all metas
627 """ 634 """
628 wx.BeginBusyCursor() 635 wx.BeginBusyCursor()
629 self.server.server.unregister() 636 self.server.server.unregister()
630 self.sb.SetStatusText( "Unregistered", 4 ) 637 self.sb.SetStatusText("Unregistered", 4)
631 self.mainMenu.Enable( 5, False ) 638 self.mainMenu.Enable(5, False)
632 self.mainMenu.Enable( 4, True ) 639 self.mainMenu.Enable(4, True)
633 #self.mainMenu.Enable( 2, True ) 640 #self.mainMenu.Enable( 2, True )
634 self.SetTitle(__appname__ + "- (running) - (unregistered)") 641 self.SetTitle(__appname__ + "- (running) - (unregistered)")
635 wx.EndBusyCursor() 642 wx.EndBusyCursor()
636 643
637 def ModifyBanList(self, event): 644 def ModifyBanList(self, event):