Mercurial > traipse_dev
comparison orpg/networking/mplay_server_gui.py @ 124:8827271fbe1b alpha
Traipse Alpha 'OpenRPG' {091001-01}
Traipse is a distribution of OpenRPG that is designed to be easy to setup and go.
Traipse also makes it easy for developers to work on code without fear of
sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the
code. 'Ornery-Orc's main goal is to offer more advanced features and enhance the
productivity of the user.
Update Summary (Cleaning up for Beta)
Added Bookmarks
Fix to Remote Admin Commands
Minor fix to text based Server
Fix to Pretty Print, from Core
Fix to Splitter Nodes not being created
Fix to massive amounts of images loading, from Core
Added 'boot' command to remote admin
Added confirmation window for sent nodes
Minor changes to allow for portability to an OpenSUSE linux OS
Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG
Zoom Mouse plugin added
Images added to Plugin UI
Switching to Element Tree
Map efficiency, from FlexiRPG
Added Status Bar to Update Manager
default_manifest.xml renamed to default_upmana.xml
Cleaner clode for saved repositories
New TrueDebug Class in orpg_log (See documentation for usage)
Mercurial's hgweb folder is ported to upmana
Happy Halloween!
author | sirebral |
---|---|
date | Sun, 01 Nov 2009 11:36:14 -0600 |
parents | 36919b8a3ef9 |
children | fba298d65cf8 |
comparison
equal
deleted
inserted
replaced
123:174658f839c0 | 124:8827271fbe1b |
---|---|
20 from meta_server_lib import post_server_data, remove_server | 20 from meta_server_lib import post_server_data, remove_server |
21 from mplay_server import mplay_server, server | 21 from mplay_server import mplay_server, server |
22 from xml.dom import minidom | 22 from xml.dom import minidom |
23 from orpg.orpgCore import component | 23 from orpg.orpgCore import component |
24 from orpg.tools.orpg_log import debug | 24 from orpg.tools.orpg_log import debug |
25 from orpg.tools.orpg_settings import settings | |
25 | 26 |
26 from xml.etree.ElementTree import ElementTree, Element, iselement | 27 from xml.etree.ElementTree import ElementTree, Element, iselement |
27 from xml.etree.ElementTree import fromstring, tostring, parse | 28 from xml.etree.ElementTree import fromstring, tostring, parse |
28 | 29 |
29 # Constants ###################################### | 30 # Constants ###################################### |
45 MENU_PLAYER_BOOT = wx.NewId() | 46 MENU_PLAYER_BOOT = wx.NewId() |
46 ### Alpha ### | 47 ### Alpha ### |
47 MENU_ADMIN_BAN = wx.NewId() | 48 MENU_ADMIN_BAN = wx.NewId() |
48 MENU_BAN_LIST = wx.NewId() | 49 MENU_BAN_LIST = wx.NewId() |
49 MENU_ADMIN_UNBAN = wx.NewId() | 50 MENU_ADMIN_UNBAN = wx.NewId() |
51 PLAYER_SHOW_VERSION = wx.NewId() | |
50 ############# | 52 ############# |
51 MENU_PLAYER_CREATE_ROOM = wx.NewId() | 53 MENU_PLAYER_CREATE_ROOM = wx.NewId() |
52 MENU_PLAYER_SEND_MESSAGE = wx.NewId() | 54 MENU_PLAYER_SEND_MESSAGE = wx.NewId() |
53 MENU_PLAYER_SEND_ROOM_MESSAGE = wx.NewId() | 55 MENU_PLAYER_SEND_ROOM_MESSAGE = wx.NewId() |
54 MENU_PLAYER_SEND_SERVER_MESSAGE = wx.NewId() | 56 MENU_PLAYER_SEND_SERVER_MESSAGE = wx.NewId() |
91 self.func = func | 93 self.func = func |
92 self.message = message | 94 self.message = message |
93 | 95 |
94 # ServerConfig Object ############################ | 96 # ServerConfig Object ############################ |
95 class ServerConfig: | 97 class ServerConfig: |
96 debug() | 98 debug(log=False) |
97 """ This class contains configuration | 99 """ This class contains configuration |
98 setting used to control the server.""" | 100 setting used to control the server.""" |
99 | 101 |
100 def __init__(self, owner ): | 102 def __init__(self, owner ): |
101 """ Loads default configuration settings.""" | 103 """ Loads default configuration settings.""" |
102 validate.config_file("server_ini.xml", "default_server_ini.xml" ) | 104 validate.config_file("server_ini.xml", "default_server_ini.xml") |
105 config_xml = parse(dir_struct['user'] + 'server_ini.xml') | |
106 debug(config_xml, log=False) | |
103 configDom = minidom.parse(dir_struct["user"] + 'server_ini.xml') | 107 configDom = minidom.parse(dir_struct["user"] + 'server_ini.xml') |
104 port = configDom.childNodes[0].childNodes[1].getAttribute('port') | 108 port = configDom.childNodes[0].childNodes[1].getAttribute('port') |
105 OPENRPG_PORT = 6774 if port == '' else int(port) #Pretty ugly, but I couldn't find the tag any other way. | 109 OPENRPG_PORT = 6774 if port == '' else int(port) #Pretty ugly, but I couldn't find the tag any other way. |
106 self.owner = owner | 110 self.owner = owner |
107 | 111 |
116 pass | 120 pass |
117 | 121 |
118 # Server Monitor ################################# | 122 # Server Monitor ################################# |
119 | 123 |
120 class ServerMonitor(Thread): | 124 class ServerMonitor(Thread): |
121 debug() | 125 debug(log=False) |
122 """ Monitor thread for GameServer. """ | 126 """ Monitor thread for GameServer. """ |
123 def __init__(self, cb, conf, name, pwd): | 127 def __init__(self, cb, conf, name, pwd): |
124 """ Setup the server. """ | 128 """ Setup the server. """ |
125 Thread.__init__(self) | 129 Thread.__init__(self) |
126 self.cb = cb | 130 self.cb = cb |
127 self.conf = conf | 131 self.conf = conf |
128 self.serverName = name | 132 self.serverName = name |
129 self.bootPwd = pwd | 133 self.bootPwd = pwd |
130 | 134 |
131 def log(self, mesg): | 135 def log(self, mesg): |
132 debug() | 136 debug(log=False) |
133 if type(mesg) == types.TupleType: | 137 if type(mesg) == types.TupleType: |
134 func, msg = mesg | 138 func, msg = mesg |
135 event = MessageFunctionEvent( func, msg ) | 139 event = MessageFunctionEvent( func, msg ) |
136 else: event = MessageLogEvent( mesg ) | 140 else: event = MessageLogEvent( mesg ) |
137 wx.PostEvent( self.conf.owner, event ) | 141 wx.PostEvent( self.conf.owner, event ) |
138 del event | 142 del event |
139 | 143 |
140 def run(self): | 144 def run(self): |
141 debug() | 145 debug(log=False) |
142 """ Start the server. """ | 146 """ Start the server. """ |
143 self.server = mplay_server(self.log, self.serverName ) | 147 self.server = mplay_server(self.log, self.serverName ) |
144 self.server.initServer(bootPassword=self.bootPwd, reg="No") | 148 self.server.initServer(bootPassword=self.bootPwd, reg="No") |
145 self.alive = 1 | 149 self.alive = 1 |
146 while self.alive: time.sleep(3) | 150 while self.alive: time.sleep(3) |
147 | 151 |
148 def stop(self): | 152 def stop(self): |
149 debug() | 153 debug(log=False) |
150 """ Stop the server. """ | 154 """ Stop the server. """ |
151 self.server.kill_server() | 155 self.server.kill_server() |
152 self.alive = 0 | 156 self.alive = 0 |
153 | 157 |
154 # GUI Server ##################################### | 158 # GUI Server ##################################### |
190 # Build our pop up menu to do cool things with the players in the list | 194 # Build our pop up menu to do cool things with the players in the list |
191 self.menu = wx.Menu() | 195 self.menu = wx.Menu() |
192 self.menu.SetTitle( "Player Menu" ) | 196 self.menu.SetTitle( "Player Menu" ) |
193 self.menu.Append( MENU_PLAYER_BOOT, "Boot Player" ) | 197 self.menu.Append( MENU_PLAYER_BOOT, "Boot Player" ) |
194 self.menu.Append( MENU_ADMIN_BAN, 'Ban Player' ) | 198 self.menu.Append( MENU_ADMIN_BAN, 'Ban Player' ) |
199 self.menu.Append( PLAYER_SHOW_VERSION, "Player Version" ) | |
195 self.menu.AppendSeparator() | 200 self.menu.AppendSeparator() |
196 self.menu.Append( MENU_PLAYER_SEND_MESSAGE, "Send Player Message" ) | 201 self.menu.Append( MENU_PLAYER_SEND_MESSAGE, "Send Player Message" ) |
197 self.menu.Append( MENU_PLAYER_SEND_ROOM_MESSAGE, "Send Room Message" ) | 202 self.menu.Append( MENU_PLAYER_SEND_ROOM_MESSAGE, "Send Room Message" ) |
198 self.menu.Append( MENU_PLAYER_SEND_SERVER_MESSAGE, "Broadcast Server Message" ) | 203 self.menu.Append( MENU_PLAYER_SEND_SERVER_MESSAGE, "Broadcast Server Message" ) |
199 | 204 |
202 self.Bind(wx.EVT_MENU, self.OnPopupMenuItem, id=MENU_PLAYER_BOOT) | 207 self.Bind(wx.EVT_MENU, self.OnPopupMenuItem, id=MENU_PLAYER_BOOT) |
203 self.Bind(wx.EVT_MENU, self.OnPopupMenuItem, id=MENU_ADMIN_BAN) | 208 self.Bind(wx.EVT_MENU, self.OnPopupMenuItem, id=MENU_ADMIN_BAN) |
204 self.Bind(wx.EVT_MENU, self.OnPopupMenuItem, id=MENU_PLAYER_SEND_MESSAGE) | 209 self.Bind(wx.EVT_MENU, self.OnPopupMenuItem, id=MENU_PLAYER_SEND_MESSAGE) |
205 self.Bind(wx.EVT_MENU, self.OnPopupMenuItem, id=MENU_PLAYER_SEND_ROOM_MESSAGE) | 210 self.Bind(wx.EVT_MENU, self.OnPopupMenuItem, id=MENU_PLAYER_SEND_ROOM_MESSAGE) |
206 self.Bind(wx.EVT_MENU, self.OnPopupMenuItem, id=MENU_PLAYER_SEND_SERVER_MESSAGE) | 211 self.Bind(wx.EVT_MENU, self.OnPopupMenuItem, id=MENU_PLAYER_SEND_SERVER_MESSAGE) |
212 self.Bind(wx.EVT_MENU, self.OnPopupMenuItem, id=PLAYER_SHOW_VERSION) | |
207 | 213 |
208 def add(self, player): | 214 def add(self, player): |
209 i = self.InsertImageStringItem( 0, player["id"], 0 ) | 215 i = self.InsertImageStringItem( 0, player["id"], 0 ) |
210 self.SetStringItem(i, 1, self.stripHtml(player["name"])) | 216 self.SetStringItem(i, 1, self.stripHtml(player["name"])) |
211 self.SetStringItem(i, 2, "NEW") | 217 self.SetStringItem(i, 2, "NEW") |
212 self.SetStringItem(i, 3, self.roomList[0]) | 218 self.SetStringItem(i, 3, self.roomList[0]) |
213 self.SetStringItem(i, 4, self.stripHtml(player["version"])) | 219 self.SetStringItem(i, 4, self.stripHtml(player["version"])) |
214 print self.stripHtml(player["role"]) | 220 self.SetStringItem(i, 5, 'Lurker' if player["role"] == None else self.stripHtml(player["role"])) |
215 self.SetStringItem(i, 5, 'Lurker' if self.stripHtml(player["role"]) == '' else self.stripHtml(player["role"])) | |
216 self.SetStringItem(i, 6, self.stripHtml(player["ip"])) | 221 self.SetStringItem(i, 6, self.stripHtml(player["ip"])) |
217 self.SetStringItem(i, 7, "PING") | 222 self.SetStringItem(i, 7, "PING") |
218 self.SetItemData(i, int(player["id"])) | 223 self.SetItemData(i, int(player["id"])) |
224 self.colorize_player_list(player) | |
219 self.AutoAjust() | 225 self.AutoAjust() |
220 | 226 |
221 def remove(self, id): | 227 def remove(self, id): |
222 i = self.FindItemData( -1, int(id)) | 228 i = self.FindItemData( -1, int(id)) |
223 self.DeleteItem(i) | 229 self.DeleteItem(i) |
232 self.SetColumnWidth(5, -1) | 238 self.SetColumnWidth(5, -1) |
233 self.SetColumnWidth(6, -1) | 239 self.SetColumnWidth(6, -1) |
234 self.SetColumnWidth(7, -1) | 240 self.SetColumnWidth(7, -1) |
235 self.Refresh() | 241 self.Refresh() |
236 | 242 |
243 def colorize_player_list(self, player): | |
244 debug(player, log=False) | |
245 if player == 0: return | |
246 for m in player.keys(): | |
247 id = player['id'] | |
248 item_list_location = self.FindItemData(-1, int(id)) | |
249 if item_list_location == -1: continue | |
250 item = self.GetItem(item_list_location) | |
251 debug(item_list_location, log=False) | |
252 role = player['role'] | |
253 debug(role, log=False) | |
254 try: #Players that turn up Blue are not passing the correct arguments. | |
255 try: | |
256 if player['group_id'] != "0": item.SetTextColour(settings.get_setting(role + "RoleColor")) | |
257 except KeyError: # Needed because group_id turns into group somewhere. | |
258 if player['group'] != "0": item.SetTextColour(settings.get_setting(role + "RoleColor")) | |
259 except: | |
260 item.SetTextColour('BLUE') | |
261 self.SetItem(item) | |
262 | |
237 def update(self, player): | 263 def update(self, player): |
264 debug(player, log=False) | |
265 #try: int(player); i = self.FindItemData( -1, int(player) ) | |
238 i = self.FindItemData( -1, int(player["id"]) ) | 266 i = self.FindItemData( -1, int(player["id"]) ) |
239 if i > -1: | 267 if i > -1: |
240 self.SetStringItem(i, 1, self.stripHtml(player["name"])) | 268 self.SetStringItem(i, 1, self.stripHtml(player["name"])) |
241 self.SetStringItem(i, 2, self.stripHtml(player["status"])) | 269 self.SetStringItem(i, 2, self.stripHtml(player["status"])) |
242 print self.stripHtml(player["role"]) | 270 self.SetStringItem(i, 5, 'Lurker' if player["role"] == None else self.stripHtml(player["role"])) |
243 self.SetStringItem(i, 5, 'Lurker' if self.stripHtml(player["role"]) == '' else self.stripHtml(player["role"])) | 271 self.colorize_player_list(player) |
244 self.AutoAjust() | 272 self.AutoAjust() |
245 else: self.add(player) | 273 else: self.add(player) |
246 | 274 |
247 def updateRoom( self, data ): | 275 def updateRoom( self, data ): |
248 (room, room_id, player) = data | 276 (room, room_id, player) = data |
249 i = self.FindItemData( -1, int(player) ) | 277 i = self.FindItemData( -1, int(player) ) |
250 if player > 0: self.SetStringItem( i, 3, room ) | 278 if player > 0: self.SetStringItem( i, 3, room ) |
251 self.AutoAjust() | 279 self.AutoAjust() |
280 #self.update(player) # player object doesn't send role object. | |
252 | 281 |
253 def setPlayerRole( self, id, role ): | 282 def setPlayerRole( self, id, role ): |
254 i = self.FindItemData( -1, int(id) ) | 283 i = self.FindItemData( -1, int(id) ) |
255 self.SetStringItem( i, 5, role ) | 284 self.SetStringItem( i, 5, role ) |
256 self.AutoAjust | 285 self.AutoAjust() |
257 | 286 |
258 def stripHtml( self, name ): | 287 def stripHtml( self, name ): |
259 ret_string = "" | 288 ret_string = "" |
260 x = 0 | 289 x = 0 |
261 in_tag = 0 | 290 in_tag = 0 |
317 elif menuItem == MENU_PLAYER_SEND_SERVER_MESSAGE: | 346 elif menuItem == MENU_PLAYER_SEND_SERVER_MESSAGE: |
318 print "broadcast a message..." | 347 print "broadcast a message..." |
319 msg = self.GetMessageInput( "Broadcast Server Message" ) | 348 msg = self.GetMessageInput( "Broadcast Server Message" ) |
320 # If we got a message back, send it | 349 # If we got a message back, send it |
321 if len(msg): self.main.server.server.broadcast( msg ) | 350 if len(msg): self.main.server.server.broadcast( msg ) |
351 elif menuItem == PLAYER_SHOW_VERSION: | |
352 version_string = self.main.server.server.obtain_by_id(playerID, 'client_string') | |
353 if version_string: wx.MessageBox("Running client version " + version_string,"Version") | |
354 else: wx.MessageBox("No client version available for this player", "Version") | |
322 | 355 |
323 def GetMessageInput( self, title ): | 356 def GetMessageInput( self, title ): |
324 prompt = "Please enter the message you wish to send:" | 357 prompt = "Please enter the message you wish to send:" |
325 msg = wx.TextEntryDialog(self, prompt, title) | 358 msg = wx.TextEntryDialog(self, prompt, title) |
326 msg.ShowModal() | 359 msg.ShowModal() |
428 self.conns = Connections( nb, self ) | 461 self.conns = Connections( nb, self ) |
429 nb.AddPage( self.conns, "Players" ) | 462 nb.AddPage( self.conns, "Players" ) |
430 | 463 |
431 #Not sure why this is Remarked TaS - Sirebral | 464 #Not sure why this is Remarked TaS - Sirebral |
432 #nb.AddPage( self.conns, "Rooms" ) | 465 #nb.AddPage( self.conns, "Rooms" ) |
433 #self.msgWindow = HTMLMessageWindow( nb ) | 466 self.msgWindow = HTMLMessageWindow( nb ) |
434 #nb.AddPage( self.msgWindow, "Messages" ) | 467 nb.AddPage( self.msgWindow, "Messages" ) |
435 | 468 |
436 log = wx.TextCtrl(splitter, -1, style=wx.TE_MULTILINE | wx.TE_READONLY | wx.HSCROLL) | 469 log = wx.TextCtrl(splitter, -1, style=wx.TE_MULTILINE | wx.TE_READONLY | wx.HSCROLL) |
437 wx.Log.SetActiveTarget( wx.LogTextCtrl(log) ) | 470 wx.Log.SetActiveTarget( wx.LogTextCtrl(log) ) |
438 splitter.SplitHorizontally(nb, log, 400) | 471 splitter.SplitHorizontally(nb, log, 400) |
439 splitter.SetMinimumPaneSize(40) | 472 splitter.SetMinimumPaneSize(40) |
466 def OnLogMessage( self, event ): | 499 def OnLogMessage( self, event ): |
467 self.Log( event.message ) | 500 self.Log( event.message ) |
468 | 501 |
469 # Event handler for out logging event | 502 # Event handler for out logging event |
470 def OnFunctionMessage(self, event): | 503 def OnFunctionMessage(self, event): |
471 debug() | 504 debug(log=False) |
472 self.callbacks[event.func]( event.message ) | 505 self.callbacks[event.func]( event.message ) |
473 | 506 |
474 ### Server Callbacks ##################################### | 507 ### Server Callbacks ##################################### |
475 def Log(self, log): | 508 def Log(self, log): |
476 wx.LogMessage(str(log)) | 509 wx.LogMessage(str(log)) |