Mercurial > traipse_dev
comparison orpg/networking/mplay_server_gui.py @ 128:fba298d65cf8 alpha
Traipse Alpha 'OpenRPG' {091003-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 (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 | Tue, 03 Nov 2009 00:52:47 -0600 |
parents | 8827271fbe1b |
children | 8e07c1a2c69b |
comparison
equal
deleted
inserted
replaced
127:0f720618a8bd | 128:fba298d65cf8 |
---|---|
10 __doc__="""OpenRPG Server Graphical Interface""" | 10 __doc__="""OpenRPG Server Graphical Interface""" |
11 | 11 |
12 import os, sys, time, types | 12 import os, sys, time, types |
13 | 13 |
14 from orpg.dirpath import dir_struct | 14 from orpg.dirpath import dir_struct |
15 #import orpg.systempath looks old | |
16 from orpg.tools.validate import validate | 15 from orpg.tools.validate import validate |
17 from orpg.orpg_wx import * | 16 from orpg.orpg_wx import * |
17 from threading import Thread | |
18 | |
18 import webbrowser | 19 import webbrowser |
19 from threading import Thread | 20 |
20 from meta_server_lib import post_server_data, remove_server | 21 from meta_server_lib import post_server_data, remove_server |
21 from mplay_server import mplay_server, server | 22 from mplay_server import mplay_server, server |
23 | |
22 from xml.dom import minidom | 24 from xml.dom import minidom |
23 from orpg.orpgCore import component | 25 from orpg.orpgCore import component |
24 from orpg.tools.orpg_log import debug | 26 from orpg.tools.orpg_log import debug |
25 from orpg.tools.orpg_settings import settings | 27 from orpg.tools.orpg_settings import settings |
26 | 28 |
93 self.func = func | 95 self.func = func |
94 self.message = message | 96 self.message = message |
95 | 97 |
96 # ServerConfig Object ############################ | 98 # ServerConfig Object ############################ |
97 class ServerConfig: | 99 class ServerConfig: |
98 debug(log=False) | 100 #debug(log=False) |
99 """ This class contains configuration | 101 """ This class contains configuration |
100 setting used to control the server.""" | 102 setting used to control the server.""" |
101 | 103 |
102 def __init__(self, owner ): | 104 def __init__(self, owner ): |
103 """ Loads default configuration settings.""" | 105 """ Loads default configuration settings.""" |
104 validate.config_file("server_ini.xml", "default_server_ini.xml") | 106 validate.config_file("server_ini.xml", "default_server_ini.xml") |
105 config_xml = parse(dir_struct['user'] + 'server_ini.xml') | 107 config_xml = parse(dir_struct['user'] + 'server_ini.xml') |
106 debug(config_xml, log=False) | 108 #debug(config_xml, log=False) |
107 configDom = minidom.parse(dir_struct["user"] + 'server_ini.xml') | 109 configDom = minidom.parse(dir_struct["user"] + 'server_ini.xml') |
108 port = configDom.childNodes[0].childNodes[1].getAttribute('port') | 110 port = configDom.childNodes[0].childNodes[1].getAttribute('port') |
109 OPENRPG_PORT = 6774 if port == '' else int(port) #Pretty ugly, but I couldn't find the tag any other way. | 111 OPENRPG_PORT = 6774 if port == '' else int(port) #Pretty ugly, but I couldn't find the tag any other way. |
110 self.owner = owner | 112 self.owner = owner |
111 | 113 |
120 pass | 122 pass |
121 | 123 |
122 # Server Monitor ################################# | 124 # Server Monitor ################################# |
123 | 125 |
124 class ServerMonitor(Thread): | 126 class ServerMonitor(Thread): |
125 debug(log=False) | |
126 """ Monitor thread for GameServer. """ | 127 """ Monitor thread for GameServer. """ |
127 def __init__(self, cb, conf, name, pwd): | 128 def __init__(self, cb, conf, name, pwd): |
128 """ Setup the server. """ | 129 """ Setup the server. """ |
129 Thread.__init__(self) | 130 Thread.__init__(self) |
130 self.cb = cb | 131 self.cb = cb |
131 self.conf = conf | 132 self.conf = conf |
132 self.serverName = name | 133 self.serverName = name |
133 self.bootPwd = pwd | 134 self.bootPwd = pwd |
134 | 135 |
135 def log(self, mesg): | 136 def log(self, mesg): |
136 debug(log=False) | 137 #debug(log=False) |
137 if type(mesg) == types.TupleType: | 138 if type(mesg) == types.TupleType: |
138 func, msg = mesg | 139 func, msg = mesg |
139 event = MessageFunctionEvent( func, msg ) | 140 event = MessageFunctionEvent( func, msg ) |
140 else: event = MessageLogEvent( mesg ) | 141 else: event = MessageLogEvent( mesg ) |
141 wx.PostEvent( self.conf.owner, event ) | 142 wx.PostEvent( self.conf.owner, event ) |
142 del event | 143 del event |
143 | 144 |
144 def run(self): | 145 def run(self): |
145 debug(log=False) | 146 #debug(log=False) |
146 """ Start the server. """ | 147 """ Start the server. """ |
147 self.server = mplay_server(self.log, self.serverName ) | 148 self.server = mplay_server(self.log, self.serverName ) |
148 self.server.initServer(bootPassword=self.bootPwd, reg="No") | 149 self.server.initServer(bootPassword=self.bootPwd, reg="No") |
149 self.alive = 1 | 150 self.alive = 1 |
150 while self.alive: time.sleep(3) | 151 while self.alive: time.sleep(3) |
151 | 152 |
152 def stop(self): | 153 def stop(self): |
153 debug(log=False) | 154 #debug(log=False) |
154 """ Stop the server. """ | 155 """ Stop the server. """ |
155 self.server.kill_server() | 156 self.server.kill_server() |
156 self.alive = 0 | 157 self.alive = 0 |
157 | 158 |
158 # GUI Server ##################################### | 159 # GUI Server ##################################### |
159 # Parent = notebook | 160 # Parent = notebook |
160 # Main = GUI | 161 # Main = GUI |
162 class Groups(wx.ListCtrl): | |
163 def __init__(self, parent, main): | |
164 wx.ListCtrl.__init__(self, parent, -1, wx.DefaultPosition, | |
165 wx.DefaultSize, wx.LC_REPORT|wx.SUNKEN_BORDER|wx.EXPAND|wx.LC_HRULES) | |
166 self.main = main | |
167 | |
168 """Not completed. Creates room, delets rooms. Does not track players. Nor does gsclient, ftm.""" | |
169 | |
170 ### Alpha ### Get Lobby Name # Moving to etree. | |
171 validate.config_file("server_ini.xml", "default_server_ini.xml" ) | |
172 configDom = minidom.parse(dir_struct["user"] + 'server_ini.xml') | |
173 lobbyname = configDom.childNodes[0].getAttribute('lobbyname') | |
174 ############# | |
175 self.roomList = { 0 : lobbyname } | |
176 | |
177 self.InsertColumn(0, 'Group ID') | |
178 self.InsertColumn(1, 'Game') | |
179 self.InsertColumn(2, 'Players') | |
180 self.InsertColumn(3, 'Passworded') | |
181 self.AddGroup((self.roomList[0], '0', 'Need to Find', 'No')) | |
182 | |
183 def AddGroup(self, data): | |
184 (room, room_id, players, passworded) = data | |
185 i = self.InsertStringItem(0, str(room_id)) | |
186 self.SetStringItem(i, 1, room) | |
187 self.SetStringItem(i, 2, players) | |
188 self.SetStringItem(i, 3, str(passworded)) | |
189 | |
190 def DeleteGroup(self, data): | |
191 i = self.FindItem(-1, str(data)) | |
192 self.DeleteItem(i) | |
193 | |
194 def UpdateRoom(self, data): | |
195 (room, room_id, players) = data | |
196 i = self.FindItem( -1, str(room_id)) | |
197 self.SetStringItem( i, 1, room ) | |
198 if players: self.SetStringItem(i, 2, players) | |
199 ### Need to add room for Password Updates ### | |
200 | |
161 class Connections(wx.ListCtrl): | 201 class Connections(wx.ListCtrl): |
162 def __init__( self, parent, main ): | 202 def __init__( self, parent, main ): |
163 wx.ListCtrl.__init__( self, parent, -1, wx.DefaultPosition, | 203 wx.ListCtrl.__init__( self, parent, -1, wx.DefaultPosition, |
164 wx.DefaultSize, wx.LC_REPORT|wx.SUNKEN_BORDER|wx.EXPAND|wx.LC_HRULES ) | 204 wx.DefaultSize, wx.LC_REPORT|wx.SUNKEN_BORDER|wx.EXPAND|wx.LC_HRULES ) |
165 self.main = main | 205 self.main = main |
239 self.SetColumnWidth(6, -1) | 279 self.SetColumnWidth(6, -1) |
240 self.SetColumnWidth(7, -1) | 280 self.SetColumnWidth(7, -1) |
241 self.Refresh() | 281 self.Refresh() |
242 | 282 |
243 def colorize_player_list(self, player): | 283 def colorize_player_list(self, player): |
244 debug(player, log=False) | |
245 if player == 0: return | 284 if player == 0: return |
246 for m in player.keys(): | 285 for m in player.keys(): |
247 id = player['id'] | 286 id = player['id'] |
248 item_list_location = self.FindItemData(-1, int(id)) | 287 item_list_location = self.FindItemData(-1, int(id)) |
249 if item_list_location == -1: continue | 288 if item_list_location == -1: continue |
250 item = self.GetItem(item_list_location) | 289 item = self.GetItem(item_list_location) |
251 debug(item_list_location, log=False) | |
252 role = player['role'] | 290 role = player['role'] |
253 debug(role, log=False) | |
254 try: #Players that turn up Blue are not passing the correct arguments. | 291 try: #Players that turn up Blue are not passing the correct arguments. |
255 try: | 292 try: |
256 if player['group_id'] != "0": item.SetTextColour(settings.get_setting(role + "RoleColor")) | 293 if player['group_id'] != "0": item.SetTextColour(settings.get_setting(role + "RoleColor")) |
257 except KeyError: # Needed because group_id turns into group somewhere. | 294 except KeyError: # Needed because group_id turns into group somewhere. |
258 if player['group'] != "0": item.SetTextColour(settings.get_setting(role + "RoleColor")) | 295 if player['group'] != "0": item.SetTextColour(settings.get_setting(role + "RoleColor")) |
259 except: | 296 except: |
260 item.SetTextColour('BLUE') | 297 item.SetTextColour('BLUE') |
261 self.SetItem(item) | 298 self.SetItem(item) |
262 | 299 |
263 def update(self, player): | 300 def update(self, player): |
264 debug(player, log=False) | |
265 #try: int(player); i = self.FindItemData( -1, int(player) ) | 301 #try: int(player); i = self.FindItemData( -1, int(player) ) |
266 i = self.FindItemData( -1, int(player["id"]) ) | 302 i = self.FindItemData( -1, int(player["id"]) ) |
267 if i > -1: | 303 if i > -1: |
268 self.SetStringItem(i, 1, self.stripHtml(player["name"])) | 304 self.SetStringItem(i, 1, self.stripHtml(player["name"])) |
269 self.SetStringItem(i, 2, self.stripHtml(player["status"])) | 305 self.SetStringItem(i, 2, self.stripHtml(player["status"])) |
394 cb["data_recv"] = self.OnDataRecv | 430 cb["data_recv"] = self.OnDataRecv |
395 cb["data_sent"] = self.OnDataSent | 431 cb["data_sent"] = self.OnDataSent |
396 cb["create_group"] = self.OnCreateGroup | 432 cb["create_group"] = self.OnCreateGroup |
397 cb["delete_group"] = self.OnDeleteGroup | 433 cb["delete_group"] = self.OnDeleteGroup |
398 cb["join_group"] = self.OnJoinGroup | 434 cb["join_group"] = self.OnJoinGroup |
435 cb['update_group'] = self.OnUpdateGroup | |
399 cb["role"] = self.OnSetRole | 436 cb["role"] = self.OnSetRole |
400 self.callbacks = cb | 437 self.callbacks = cb |
401 | 438 |
402 # Misc. | 439 # Misc. |
403 self.conf = ServerConfig(self) | 440 self.conf = ServerConfig(self) |
456 | 493 |
457 def build_body(self): | 494 def build_body(self): |
458 """ Create the ViewNotebook and logger. """ | 495 """ Create the ViewNotebook and logger. """ |
459 splitter = wx.SplitterWindow(self, -1, style=wx.NO_3D | wx.SP_3D) | 496 splitter = wx.SplitterWindow(self, -1, style=wx.NO_3D | wx.SP_3D) |
460 nb = wx.Notebook( splitter, -1 ) | 497 nb = wx.Notebook( splitter, -1 ) |
461 self.conns = Connections( nb, self ) | 498 self.conns = Connections(nb, self) |
462 nb.AddPage( self.conns, "Players" ) | 499 self.groups = Groups(nb, self) |
500 nb.AddPage(self.conns, "Players") | |
501 nb.AddPage(self.groups, 'Rooms') | |
463 | 502 |
464 #Not sure why this is Remarked TaS - Sirebral | 503 #Not sure why this is Remarked TaS - Sirebral |
465 #nb.AddPage( self.conns, "Rooms" ) | 504 #nb.AddPage( self.conns, "Rooms" ) |
466 self.msgWindow = HTMLMessageWindow( nb ) | 505 self.msgWindow = HTMLMessageWindow( nb ) |
467 nb.AddPage( self.msgWindow, "Messages" ) | 506 nb.AddPage( self.msgWindow, "Messages" ) |
499 def OnLogMessage( self, event ): | 538 def OnLogMessage( self, event ): |
500 self.Log( event.message ) | 539 self.Log( event.message ) |
501 | 540 |
502 # Event handler for out logging event | 541 # Event handler for out logging event |
503 def OnFunctionMessage(self, event): | 542 def OnFunctionMessage(self, event): |
504 debug(log=False) | |
505 self.callbacks[event.func]( event.message ) | 543 self.callbacks[event.func]( event.message ) |
506 | 544 |
507 ### Server Callbacks ##################################### | 545 ### Server Callbacks ##################################### |
508 def Log(self, log): | 546 def Log(self, log): |
509 wx.LogMessage(str(log)) | 547 wx.LogMessage(str(log)) |
526 self.total_messages_received += 1 | 564 self.total_messages_received += 1 |
527 self.total_data_received += bytes | 565 self.total_data_received += bytes |
528 self.sb.SetStatusText("Recv: %s (%d)" % (format_bytes(self.total_data_received), self.total_messages_received), 2) | 566 self.sb.SetStatusText("Recv: %s (%d)" % (format_bytes(self.total_data_received), self.total_messages_received), 2) |
529 | 567 |
530 def OnCreateGroup( self, data ): | 568 def OnCreateGroup( self, data ): |
531 room_id = data[1] | 569 (room, room_id, player, pwd) = data |
532 name = data[0] | 570 self.groups.AddGroup(data) |
533 self.conns.roomList[room_id] = name | 571 self.conns.roomList[room_id] = name |
534 (room, room_id, player) = data | 572 data = (room, room_id, player) |
535 self.conns.updateRoom(data) | 573 self.conns.updateRoom(data) |
536 | 574 |
537 def OnDeleteGroup(self, data): | 575 def OnDeleteGroup(self, data): |
538 (room_id, player) = data | 576 (room_id, player) = data |
577 self.groups.DeleteGroup(room_id) | |
539 del self.conns.roomList[room_id] | 578 del self.conns.roomList[room_id] |
540 | 579 |
541 def OnJoinGroup(self, data): | 580 def OnJoinGroup(self, data): |
542 self.conns.updateRoom(data ) | 581 #debug(data) |
582 self.conns.updateRoom(data) | |
583 | |
584 def OnUpdateGroup(self, data): | |
585 (room, room_id, players) = data | |
586 self.groups.UpdateGroup(data) | |
543 | 587 |
544 def OnSetRole( self, data ): | 588 def OnSetRole( self, data ): |
545 (id, role) = data | 589 (id, role) = data |
546 self.conns.setPlayerRole( id, role ) | 590 self.conns.setPlayerRole(id, role) |
547 | 591 |
548 ### Misc. ################################################ | 592 ### Misc. ################################################ |
549 def OnStart(self, event = None): | 593 def OnStart(self, event = None): |
550 """ Start server. """ | 594 """ Start server. """ |
551 if self.STATUS == SERVER_STOPPED: | 595 if self.STATUS == SERVER_STOPPED: |
649 "Stop pinging connected players." | 693 "Stop pinging connected players." |
650 | 694 |
651 def ConfigPingInterval( self, event = None ): | 695 def ConfigPingInterval( self, event = None ): |
652 "Configure the player ping interval. Note that all players are pinged on a single timer." | 696 "Configure the player ping interval. Note that all players are pinged on a single timer." |
653 | 697 |
654 def OnExit(self, event = None): | 698 def OnExit(self, event): |
699 dlg = wx.MessageDialog(self, "Exit the Server?", "OpenRPG- Server", wx.YES_NO) | |
700 if dlg.ShowModal() == wx.ID_YES: | |
701 dlg.Destroy() | |
702 self.ExitConfirmed() | |
703 | |
704 def ExitConfirmed(self, event=None): | |
655 """ Quit the program. """ | 705 """ Quit the program. """ |
656 self.OnStop() | 706 self.OnStop() |
657 self.BanListDialog.Destroy() ### Alpha ### | 707 self.BanListDialog.Destroy() ### Alpha ### |
658 wx.CallAfter(self.Destroy) | 708 wx.CallAfter(self.Destroy) |
659 | 709 |