Mercurial > traipse_dev
comparison orpg/networking/mplay_server_gui.py @ 98:95b5281e8d34 alpha
Traipse Alpha 'OpenRPG' {090925-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:
00:
Update forwards to the 090909-02 Server code that now works.
New default Lobby Map, designed for Traipse. Feel free to change it.
Updates to Server GUI:
* Admin can Ban from Backend.
* Prework to modify Ban List in back end.
* Server GUI finds your Lobby Name
* New users default as Lurker unless a Role is set
New Addition to Chat Die Roll commands. Math Ordering. Ex. [(X+Y)dZ]. Currently does pairs only, no nesting either.
Cleaner TraipseSuiteAttention portability and clean up in Main (Beta!)
01:
Die Roll Commands addition removed in favor of Core code
{090925-00}:
Updates to Server GUI:
*Admin can Modify Ban List and Un Ban users.
New About Dialog. A more uniform About Dialog.
author | sirebral |
---|---|
date | Fri, 25 Sep 2009 06:16:37 -0500 |
parents | 65c1604e7949 |
children | 9314d63c0941 |
comparison
equal
deleted
inserted
replaced
97:bb22f0f1a7ec | 98:95b5281e8d34 |
---|---|
18 from orpg.tools.validate import validate | 18 from orpg.tools.validate import validate |
19 from orpg.orpg_wx import * | 19 from orpg.orpg_wx import * |
20 import webbrowser | 20 import webbrowser |
21 from threading import Thread | 21 from threading import Thread |
22 from meta_server_lib import post_server_data, remove_server | 22 from meta_server_lib import post_server_data, remove_server |
23 from mplay_server import mplay_server | 23 from mplay_server import mplay_server, server |
24 from xml.dom import minidom | 24 from xml.dom import minidom |
25 from orpg.orpgCore import component | |
25 | 26 |
26 # Constants ###################################### | 27 # Constants ###################################### |
27 SERVER_RUNNING = 1 | 28 SERVER_RUNNING = 1 |
28 SERVER_STOPPED = 0 | 29 SERVER_STOPPED = 0 |
29 MENU_START_SERVER = wx.NewId() | 30 MENU_START_SERVER = wx.NewId() |
40 | 41 |
41 # Add our menu id's for our right click popup | 42 # Add our menu id's for our right click popup |
42 MENU_PLAYER_BOOT = wx.NewId() | 43 MENU_PLAYER_BOOT = wx.NewId() |
43 ### Alpha ### | 44 ### Alpha ### |
44 MENU_ADMIN_BAN = wx.NewId() | 45 MENU_ADMIN_BAN = wx.NewId() |
46 MENU_BAN_LIST = wx.NewId() | |
47 MENU_ADMIN_UNBAN = wx.NewId() | |
45 ############# | 48 ############# |
46 MENU_PLAYER_CREATE_ROOM = wx.NewId() | 49 MENU_PLAYER_CREATE_ROOM = wx.NewId() |
47 MENU_PLAYER_SEND_MESSAGE = wx.NewId() | 50 MENU_PLAYER_SEND_MESSAGE = wx.NewId() |
48 MENU_PLAYER_SEND_ROOM_MESSAGE = wx.NewId() | 51 MENU_PLAYER_SEND_ROOM_MESSAGE = wx.NewId() |
49 MENU_PLAYER_SEND_SERVER_MESSAGE = wx.NewId() | 52 MENU_PLAYER_SEND_SERVER_MESSAGE = wx.NewId() |
96 validate.config_file("server_ini.xml", "default_server_ini.xml" ) | 99 validate.config_file("server_ini.xml", "default_server_ini.xml" ) |
97 configDom = minidom.parse(dir_struct["user"] + 'server_ini.xml') | 100 configDom = minidom.parse(dir_struct["user"] + 'server_ini.xml') |
98 port = configDom.childNodes[0].childNodes[1].getAttribute('port') | 101 port = configDom.childNodes[0].childNodes[1].getAttribute('port') |
99 OPENRPG_PORT = 6774 if port == '' else int(port) #Pretty ugly, but I couldn't find the tag any other way. | 102 OPENRPG_PORT = 6774 if port == '' else int(port) #Pretty ugly, but I couldn't find the tag any other way. |
100 self.owner = owner | 103 self.owner = owner |
101 | |
102 ### Early Alpha ### This is prep for the Modify Ban List Dialog, just working out the details. | |
103 validate.config_file("ban_list.xml", "default_ban_list.xml" ) | |
104 configDom = minidom.parse(dir_struct["user"] + 'ban_list.xml') | |
105 ban_dict = {} | |
106 for element in configDom.getElementsByTagName('banned'): | |
107 player = element.getAttribute('name').replace("&", "&").replace("<", "<").replace('"', """).replace(">", ">") | |
108 playerIP = element.getAttribute('ip') | |
109 ban_dict[player] = playerIP | |
110 print ban_dict | |
111 ################### | |
112 | 104 |
113 def load_xml(self, xml): | 105 def load_xml(self, xml): |
114 """ Load configuration from XML data. | 106 """ Load configuration from XML data. |
115 xml (xml) -- xml string to parse """ | 107 xml (xml) -- xml string to parse """ |
116 pass | 108 pass |
344 # Creat GUI | 336 # Creat GUI |
345 self.build_menu() | 337 self.build_menu() |
346 self.build_body() | 338 self.build_body() |
347 self.build_status() | 339 self.build_status() |
348 | 340 |
341 ### Alpha ### | |
342 # Ban List Dialog | |
343 self.BanListDialog = BanListDialog(self) | |
344 ############# | |
345 | |
349 # Server Callbacks | 346 # Server Callbacks |
350 cb = {} | 347 cb = {} |
351 cb["log"] = self.Log | 348 cb["log"] = self.Log |
352 cb["connect"] = self.OnConnect ##Fixed!! | 349 cb["connect"] = self.OnConnect ##Fixed!! |
353 cb["disconnect"] = self.OnDisconnect | 350 cb["disconnect"] = self.OnDisconnect |
392 self.Bind(wx.EVT_MENU, self.OnUnregister, id=MENU_UNREGISTER_SERVER) | 389 self.Bind(wx.EVT_MENU, self.OnUnregister, id=MENU_UNREGISTER_SERVER) |
393 self.mainMenu.Append( menu, '&Registration' ) | 390 self.mainMenu.Append( menu, '&Registration' ) |
394 | 391 |
395 # Server Configuration Menu | 392 # Server Configuration Menu |
396 menu = wx.Menu() | 393 menu = wx.Menu() |
394 menu.Append( MENU_BAN_LIST, 'Ban List', 'Modify Ban List.' ) | |
395 self.Bind(wx.EVT_MENU, self.ModifyBanList, id=MENU_BAN_LIST) | |
397 menu.Append( MENU_START_PING_PLAYERS, 'Start Ping', 'Ping players to validate remote connection.' ) | 396 menu.Append( MENU_START_PING_PLAYERS, 'Start Ping', 'Ping players to validate remote connection.' ) |
398 self.Bind(wx.EVT_MENU, self.PingPlayers, id=MENU_START_PING_PLAYERS) | 397 self.Bind(wx.EVT_MENU, self.PingPlayers, id=MENU_START_PING_PLAYERS) |
399 menu.Append( MENU_STOP_PING_PLAYERS, 'Stop Ping', 'Stop validating player connections.' ) | 398 menu.Append( MENU_STOP_PING_PLAYERS, 'Stop Ping', 'Stop validating player connections.' ) |
400 self.Bind(wx.EVT_MENU, self.StopPingPlayers, id=MENU_STOP_PING_PLAYERS) | 399 self.Bind(wx.EVT_MENU, self.StopPingPlayers, id=MENU_STOP_PING_PLAYERS) |
401 menu.Append( MENU_PING_INTERVAL, 'Ping Interval', 'Change the ping interval.' ) | 400 menu.Append( MENU_PING_INTERVAL, 'Ping Interval', 'Change the ping interval.' ) |
589 self.mainMenu.Enable( MENU_REGISTER_SERVER, True ) | 588 self.mainMenu.Enable( MENU_REGISTER_SERVER, True ) |
590 self.mainMenu.Enable( MENU_STOP_SERVER, True ) | 589 self.mainMenu.Enable( MENU_STOP_SERVER, True ) |
591 self.SetTitle(__appname__ + "- (running) - (unregistered)") | 590 self.SetTitle(__appname__ + "- (running) - (unregistered)") |
592 wx.EndBusyCursor() | 591 wx.EndBusyCursor() |
593 | 592 |
593 ### Alpha ### | |
594 def ModifyBanList(self, event): | |
595 if self.BanListDialog.IsShown() == True: self.BanListDialog.Hide() | |
596 else: self.BanListDialog.Show() | |
597 ############# | |
598 | |
594 def PingPlayers( self, event = None ): | 599 def PingPlayers( self, event = None ): |
595 "Ping all players that are connected at a periodic interval, detecting dropped connections." | 600 "Ping all players that are connected at a periodic interval, detecting dropped connections." |
596 wx.BeginBusyCursor() | 601 wx.BeginBusyCursor() |
597 wx.Yield() | 602 wx.Yield() |
598 wx.EndBusyCursor() | 603 wx.EndBusyCursor() |
604 "Configure the player ping interval. Note that all players are pinged on a single timer." | 609 "Configure the player ping interval. Note that all players are pinged on a single timer." |
605 | 610 |
606 def OnExit(self, event = None): | 611 def OnExit(self, event = None): |
607 """ Quit the program. """ | 612 """ Quit the program. """ |
608 self.OnStop() | 613 self.OnStop() |
614 self.BanListDialog.Destroy() ### Alpha ### | |
609 wx.CallAfter(self.Destroy) | 615 wx.CallAfter(self.Destroy) |
616 | |
617 ### Alpha ### | |
618 class BanListDialog(wx.Frame): | |
619 def __init__(self, parent): | |
620 super(BanListDialog, self).__init__(parent, -1, "Ban List") | |
621 icon = wx.Icon(dir_struct["icon"]+'noplayer.gif', wx.BITMAP_TYPE_GIF) | |
622 self.SetIcon( icon ) | |
623 self.BanList = wx.ListCtrl(self, wx.ID_ANY, style=wx.LC_SINGLE_SEL|wx.LC_REPORT|wx.LC_HRULES) | |
624 sizer = wx.BoxSizer(wx.VERTICAL) | |
625 sizer.Add(self.BanList, 1, wx.EXPAND) | |
626 self.BuildList() | |
627 self.SetSizer(sizer) | |
628 self.SetAutoLayout(True) | |
629 self.SetSize((300, 175)) | |
630 self.Bind(wx.EVT_CLOSE, self.Min) | |
631 self.Min(None) | |
632 | |
633 # Ban List Dialog Pop Up Menu, more can be added | |
634 self.menu = wx.Menu() | |
635 self.menu.SetTitle( "Modify Ban List" ) | |
636 self.menu.Append( MENU_ADMIN_UNBAN, "Un-Ban Player" ) | |
637 | |
638 # Even Association | |
639 self.BanList.Bind(wx.EVT_RIGHT_DOWN, self.BanPopupMenu) | |
640 self.Bind(wx.EVT_MENU, self.BanPopupMenuItem, id=MENU_ADMIN_UNBAN) | |
641 | |
642 # When we right click, cause our popup menu to appear | |
643 def BanPopupMenu( self, event ): | |
644 pos = wx.Point( event.GetX(), event.GetY() ) | |
645 (item, flag) = self.BanList.HitTest( pos ) | |
646 if item > -1: | |
647 self.selectedItem = item | |
648 self.PopupMenu( self.menu, pos ) | |
649 | |
650 def BanPopupMenuItem( self, event): | |
651 menuItem = event.GetId() | |
652 player = str(self.BanList.GetItemData(self.selectedItem)) | |
653 playerIP = str(self.BanList.GetItem((int(player)), 1).GetText()) | |
654 if menuItem == MENU_ADMIN_UNBAN: | |
655 server.admin_unban(playerIP) | |
656 self.BanList.DeleteItem(self.BanList.GetItemData(self.selectedItem)) | |
657 self.BanList.Refresh() | |
658 | |
659 def BuildList(self): | |
660 # Build Dialog Columns | |
661 self.BanList.ClearAll() | |
662 self.BanList.InsertColumn(0, "User Name") | |
663 self.BanList.InsertColumn(1, "IP") | |
664 | |
665 validate.config_file("ban_list.xml", "default_ban_list.xml" ) | |
666 configDom = minidom.parse(dir_struct["user"] + 'ban_list.xml') | |
667 ban_dict = {} | |
668 for element in configDom.getElementsByTagName('banned'): | |
669 player = element.getAttribute('name').replace("&", "&").replace("<", "<").replace('"', """).replace(">", ">") | |
670 playerIP = element.getAttribute('ip') | |
671 ban_dict[player] = playerIP | |
672 for key in ban_dict: | |
673 i = self.BanList.InsertImageStringItem( 0, key, 0 ) | |
674 self.BanList.SetStringItem(i, 1, ban_dict[key]) | |
675 self.BanList.RefreshItem(i) | |
676 self.AutoAdjust() | |
677 | |
678 def AutoAdjust(self): | |
679 self.BanList.SetColumnWidth(0, -1) | |
680 self.BanList.SetColumnWidth(1, -1) | |
681 self.BanList.Refresh() | |
682 | |
683 def Min(self, evt): | |
684 self.Hide() | |
685 ############### | |
610 | 686 |
611 class ServerGUIApp(wx.App): | 687 class ServerGUIApp(wx.App): |
612 def OnInit(self): | 688 def OnInit(self): |
613 # Make sure our image handlers are loaded before we try to display anything | 689 # Make sure our image handlers are loaded before we try to display anything |
614 wx.InitAllImageHandlers() | 690 wx.InitAllImageHandlers() |