Mercurial > traipse_dev
annotate orpg/networking/mplay_server_gui.py @ 135:dcf4fbe09b70 beta
Traipse Beta 'OpenRPG' {091010-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 (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
**Pretty important update that can help remove thousands of dead children from your gametree.
**Children, <forms />, <group_atts />, <horizontal />, <cols />, <rows />, <height />, etc... are all tags now. Check your gametree and
look for dead children!!
**New Gamtree Recusion method, mapping, and context sensitivity. !!Alpha - Watch out for infinite loops!!
author | sirebral |
---|---|
date | Tue, 10 Nov 2009 14:11:28 -0600 |
parents | 7ed4979cc1cf |
children | e842a5f1b775 |
rev | line source |
---|---|
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
1 #!/usr/bin/env python |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
2 # |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
3 # OpenRPG Server Graphical Interface |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
4 # GNU General Public License |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
5 # |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
6 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
7 __appname__=' OpenRPG GUI Server v0.7 ' |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
8 __version__='$Revision: 1.26 $'[11:-2] |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
9 __cvsinfo__='$Id: mplay_server_gui.py,v 1.26 2007/11/06 00:32:39 digitalxero Exp $'[5:-2] |
56
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
10 __doc__="""OpenRPG Server Graphical Interface""" |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
11 |
135 | 12 import os, sys, time, types |
13 | |
100 | 14 from orpg.dirpath import dir_struct |
15 from orpg.tools.validate import validate | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
16 from orpg.orpg_wx import * |
135 | 17 from threading import Thread |
18 | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
19 import webbrowser |
135 | 20 |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
21 from meta_server_lib import post_server_data, remove_server |
100 | 22 from mplay_server import mplay_server, server |
135 | 23 |
56
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
24 from xml.dom import minidom |
100 | 25 from orpg.orpgCore import component |
135 | 26 from orpg.tools.orpg_log import debug |
27 from orpg.tools.orpg_settings import settings | |
28 | |
29 from xml.etree.ElementTree import ElementTree, Element, iselement | |
30 from xml.etree.ElementTree import fromstring, tostring, parse | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
31 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
32 # Constants ###################################### |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
33 SERVER_RUNNING = 1 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
34 SERVER_STOPPED = 0 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
35 MENU_START_SERVER = wx.NewId() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
36 MENU_STOP_SERVER = wx.NewId() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
37 MENU_EXIT = wx.NewId() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
38 MENU_REGISTER_SERVER = wx.NewId() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
39 MENU_UNREGISTER_SERVER = wx.NewId() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
40 MENU_START_PING_PLAYERS = wx.NewId() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
41 MENU_STOP_PING_PLAYERS = wx.NewId() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
42 MENU_PING_INTERVAL = wx.NewId() |
100 | 43 ### Alpha ### |
44 MENU_MODIFY_BANLIST = wx.NewId() | |
45 ############# | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
46 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
47 # Add our menu id's for our right click popup |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
48 MENU_PLAYER_BOOT = wx.NewId() |
100 | 49 ### Alpha ### |
50 MENU_ADMIN_BAN = wx.NewId() | |
51 MENU_BAN_LIST = wx.NewId() | |
52 MENU_ADMIN_UNBAN = wx.NewId() | |
135 | 53 PLAYER_SHOW_VERSION = wx.NewId() |
100 | 54 ############# |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
55 MENU_PLAYER_CREATE_ROOM = wx.NewId() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
56 MENU_PLAYER_SEND_MESSAGE = wx.NewId() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
57 MENU_PLAYER_SEND_ROOM_MESSAGE = wx.NewId() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
58 MENU_PLAYER_SEND_SERVER_MESSAGE = wx.NewId() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
59 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
60 # Our new event type that gets posted from one |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
61 # thread to another |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
62 wxEVT_LOG_MESSAGE = wx.NewEventType() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
63 wxEVT_FUNCTION_MESSAGE = wx.NewEventType() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
64 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
65 # Our event connector -- wxEVT_LOG_MESSAGE |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
66 EVT_LOG_MESSAGE = wx.PyEventBinder(wxEVT_LOG_MESSAGE, 1) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
67 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
68 # Our event connector -- wxEVT_FUNCTION_MESSAGE |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
69 EVT_FUNCTION_MESSAGE = wx.PyEventBinder(wxEVT_FUNCTION_MESSAGE, 1) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
70 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
71 # Utils ########################################## |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
72 def format_bytes(b): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
73 f = ['b', 'Kb', 'Mb', 'Gb'] |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
74 i = 0 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
75 while i < 3: |
100 | 76 if b < 1024: return str(b) + f[i] |
77 else: b = b/1024 | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
78 i += 1 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
79 return str(b) + f[3] |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
80 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
81 # wxEVT_LOG_MESSAGE |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
82 # MessageLogEvent ############################### |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
83 class MessageLogEvent(wx.PyEvent): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
84 def __init__( self, message ): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
85 wx.PyEvent.__init__( self ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
86 self.SetEventType(wxEVT_LOG_MESSAGE) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
87 self.message = message |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
88 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
89 # wxEVT_TUPLE_MESSAGE |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
90 # MessageLogEvent ############################### |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
91 class MessageFunctionEvent(wx.PyEvent): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
92 def __init__( self, func, message ): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
93 wx.PyEvent.__init__( self ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
94 self.SetEventType(wxEVT_FUNCTION_MESSAGE) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
95 self.func = func |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
96 self.message = message |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
97 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
98 # ServerConfig Object ############################ |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
99 class ServerConfig: |
135 | 100 #debug(log=False) |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
101 """ This class contains configuration |
100 | 102 setting used to control the server.""" |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
103 |
56
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
104 def __init__(self, owner ): |
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
105 """ Loads default configuration settings.""" |
135 | 106 validate.config_file("server_ini.xml", "default_server_ini.xml") |
107 config_xml = parse(dir_struct['user'] + 'server_ini.xml') | |
108 #debug(config_xml, log=False) | |
100 | 109 configDom = minidom.parse(dir_struct["user"] + 'server_ini.xml') |
56
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
110 port = configDom.childNodes[0].childNodes[1].getAttribute('port') |
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
111 OPENRPG_PORT = 6774 if port == '' else int(port) #Pretty ugly, but I couldn't find the tag any other way. |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
112 self.owner = owner |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
113 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
114 def load_xml(self, xml): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
115 """ Load configuration from XML data. |
100 | 116 xml (xml) -- xml string to parse """ |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
117 pass |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
118 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
119 def save_xml(self): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
120 """ Returns XML file representing |
100 | 121 the active configuration. """ |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
122 pass |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
123 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
124 # Server Monitor ################################# |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
125 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
126 class ServerMonitor(Thread): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
127 """ Monitor thread for GameServer. """ |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
128 def __init__(self, cb, conf, name, pwd): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
129 """ Setup the server. """ |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
130 Thread.__init__(self) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
131 self.cb = cb |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
132 self.conf = conf |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
133 self.serverName = name |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
134 self.bootPwd = pwd |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
135 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
136 def log(self, mesg): |
135 | 137 #debug(log=False) |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
138 if type(mesg) == types.TupleType: |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
139 func, msg = mesg |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
140 event = MessageFunctionEvent( func, msg ) |
27
a571772a45c7
Minor house cleaning in the mplay_server_gui. Getting ready to push this
sirebral
parents:
9
diff
changeset
|
141 else: event = MessageLogEvent( mesg ) |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
142 wx.PostEvent( self.conf.owner, event ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
143 del event |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
144 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
145 def run(self): |
135 | 146 #debug(log=False) |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
147 """ Start the server. """ |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
148 self.server = mplay_server(self.log, self.serverName ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
149 self.server.initServer(bootPassword=self.bootPwd, reg="No") |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
150 self.alive = 1 |
27
a571772a45c7
Minor house cleaning in the mplay_server_gui. Getting ready to push this
sirebral
parents:
9
diff
changeset
|
151 while self.alive: time.sleep(3) |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
152 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
153 def stop(self): |
135 | 154 #debug(log=False) |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
155 """ Stop the server. """ |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
156 self.server.kill_server() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
157 self.alive = 0 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
158 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
159 # GUI Server ##################################### |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
160 # Parent = notebook |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
161 # Main = GUI |
135 | 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 | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
201 class Connections(wx.ListCtrl): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
202 def __init__( self, parent, main ): |
100 | 203 wx.ListCtrl.__init__( self, parent, -1, wx.DefaultPosition, |
204 wx.DefaultSize, wx.LC_REPORT|wx.SUNKEN_BORDER|wx.EXPAND|wx.LC_HRULES ) | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
205 self.main = main |
100 | 206 |
207 ### Alpha ### Get Lobby Name | |
208 validate.config_file("server_ini.xml", "default_server_ini.xml" ) | |
209 configDom = minidom.parse(dir_struct["user"] + 'server_ini.xml') | |
210 lobbyname = configDom.childNodes[0].getAttribute('lobbyname') | |
211 ############# | |
212 | |
213 self.roomList = { 0 : lobbyname } | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
214 self._imageList = wx.ImageList( 16, 16, False ) |
100 | 215 img = wx.Image(dir_struct["icon"]+"player.gif", wx.BITMAP_TYPE_GIF).ConvertToBitmap() |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
216 self._imageList.Add( img ) |
100 | 217 img = wx.Image(dir_struct["icon"]+"player-whisper.gif", wx.BITMAP_TYPE_GIF).ConvertToBitmap() |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
218 self._imageList.Add( img ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
219 self.SetImageList( self._imageList, wx.IMAGE_LIST_SMALL ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
220 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
221 # Set The columns |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
222 self.InsertColumn(0, "ID") |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
223 self.InsertColumn(1, "Player") |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
224 self.InsertColumn(2, "Status") |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
225 self.InsertColumn(3, "Room") |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
226 self.InsertColumn(4, "Version") |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
227 self.InsertColumn(5, "Role") |
9
c97c641a76fd
Small changes made to the mplay_server_gui.py that prevented a server
sirebral
parents:
0
diff
changeset
|
228 self.InsertColumn(6, "IP") |
c97c641a76fd
Small changes made to the mplay_server_gui.py that prevented a server
sirebral
parents:
0
diff
changeset
|
229 self.InsertColumn(7, "Ping") |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
230 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
231 # Set the column widths |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
232 self.AutoAjust() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
233 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
234 # Build our pop up menu to do cool things with the players in the list |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
235 self.menu = wx.Menu() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
236 self.menu.SetTitle( "Player Menu" ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
237 self.menu.Append( MENU_PLAYER_BOOT, "Boot Player" ) |
100 | 238 self.menu.Append( MENU_ADMIN_BAN, 'Ban Player' ) |
135 | 239 self.menu.Append( PLAYER_SHOW_VERSION, "Player Version" ) |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
240 self.menu.AppendSeparator() |
56
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
241 self.menu.Append( MENU_PLAYER_SEND_MESSAGE, "Send Player Message" ) |
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
242 self.menu.Append( MENU_PLAYER_SEND_ROOM_MESSAGE, "Send Room Message" ) |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
243 self.menu.Append( MENU_PLAYER_SEND_SERVER_MESSAGE, "Broadcast Server Message" ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
244 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
245 # Associate our events |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
246 self.Bind(wx.EVT_RIGHT_DOWN, self.OnPopupMenu) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
247 self.Bind(wx.EVT_MENU, self.OnPopupMenuItem, id=MENU_PLAYER_BOOT) |
100 | 248 self.Bind(wx.EVT_MENU, self.OnPopupMenuItem, id=MENU_ADMIN_BAN) |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
249 self.Bind(wx.EVT_MENU, self.OnPopupMenuItem, id=MENU_PLAYER_SEND_MESSAGE) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
250 self.Bind(wx.EVT_MENU, self.OnPopupMenuItem, id=MENU_PLAYER_SEND_ROOM_MESSAGE) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
251 self.Bind(wx.EVT_MENU, self.OnPopupMenuItem, id=MENU_PLAYER_SEND_SERVER_MESSAGE) |
135 | 252 self.Bind(wx.EVT_MENU, self.OnPopupMenuItem, id=PLAYER_SHOW_VERSION) |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
253 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
254 def add(self, player): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
255 i = self.InsertImageStringItem( 0, player["id"], 0 ) |
135 | 256 self.SetStringItem(i, 1, self.stripHtml(player["name"])) |
257 self.SetStringItem(i, 2, "NEW") | |
258 self.SetStringItem(i, 3, self.roomList[0]) | |
259 self.SetStringItem(i, 4, self.stripHtml(player["version"])) | |
260 self.SetStringItem(i, 5, 'Lurker' if player["role"] == None else self.stripHtml(player["role"])) | |
261 self.SetStringItem(i, 6, self.stripHtml(player["ip"])) | |
262 self.SetStringItem(i, 7, "PING") | |
263 self.SetItemData(i, int(player["id"])) | |
264 self.colorize_player_list(player) | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
265 self.AutoAjust() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
266 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
267 def remove(self, id): |
135 | 268 i = self.FindItemData( -1, int(id)) |
269 self.DeleteItem(i) | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
270 self.AutoAjust() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
271 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
272 def AutoAjust(self): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
273 self.SetColumnWidth(0, -1) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
274 self.SetColumnWidth(1, -1) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
275 self.SetColumnWidth(2, -1) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
276 self.SetColumnWidth(3, -1) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
277 self.SetColumnWidth(4, -1) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
278 self.SetColumnWidth(5, -1) |
27
a571772a45c7
Minor house cleaning in the mplay_server_gui. Getting ready to push this
sirebral
parents:
9
diff
changeset
|
279 self.SetColumnWidth(6, -1) |
a571772a45c7
Minor house cleaning in the mplay_server_gui. Getting ready to push this
sirebral
parents:
9
diff
changeset
|
280 self.SetColumnWidth(7, -1) |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
281 self.Refresh() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
282 |
135 | 283 def colorize_player_list(self, player): |
284 if player == 0: return | |
285 for m in player.keys(): | |
286 id = player['id'] | |
287 item_list_location = self.FindItemData(-1, int(id)) | |
288 if item_list_location == -1: continue | |
289 item = self.GetItem(item_list_location) | |
290 role = player['role'] | |
291 try: #Players that turn up Blue are not passing the correct arguments. | |
292 try: | |
293 if player['group_id'] != "0": item.SetTextColour(settings.get_setting(role + "RoleColor")) | |
294 except KeyError: # Needed because group_id turns into group somewhere. | |
295 if player['group'] != "0": item.SetTextColour(settings.get_setting(role + "RoleColor")) | |
296 except: | |
297 item.SetTextColour('BLUE') | |
298 self.SetItem(item) | |
299 | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
300 def update(self, player): |
135 | 301 #try: int(player); i = self.FindItemData( -1, int(player) ) |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
302 i = self.FindItemData( -1, int(player["id"]) ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
303 if i > -1: |
56
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
304 self.SetStringItem(i, 1, self.stripHtml(player["name"])) |
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
305 self.SetStringItem(i, 2, self.stripHtml(player["status"])) |
135 | 306 self.SetStringItem(i, 5, 'Lurker' if player["role"] == None else self.stripHtml(player["role"])) |
307 self.colorize_player_list(player) | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
308 self.AutoAjust() |
27
a571772a45c7
Minor house cleaning in the mplay_server_gui. Getting ready to push this
sirebral
parents:
9
diff
changeset
|
309 else: self.add(player) |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
310 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
311 def updateRoom( self, data ): |
56
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
312 (room, room_id, player) = data |
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
313 i = self.FindItemData( -1, int(player) ) |
100 | 314 if player > 0: self.SetStringItem( i, 3, room ) |
56
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
315 self.AutoAjust() |
135 | 316 #self.update(player) # player object doesn't send role object. |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
317 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
318 def setPlayerRole( self, id, role ): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
319 i = self.FindItemData( -1, int(id) ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
320 self.SetStringItem( i, 5, role ) |
135 | 321 self.AutoAjust() |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
322 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
323 def stripHtml( self, name ): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
324 ret_string = "" |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
325 x = 0 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
326 in_tag = 0 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
327 for x in range( len(name) ): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
328 if name[x] == "<" or name[x] == ">" or in_tag == 1 : |
27
a571772a45c7
Minor house cleaning in the mplay_server_gui. Getting ready to push this
sirebral
parents:
9
diff
changeset
|
329 if name[x] == "<": in_tag = 1 |
a571772a45c7
Minor house cleaning in the mplay_server_gui. Getting ready to push this
sirebral
parents:
9
diff
changeset
|
330 elif name[x] == ">": in_tag = 0 |
a571772a45c7
Minor house cleaning in the mplay_server_gui. Getting ready to push this
sirebral
parents:
9
diff
changeset
|
331 else: pass |
a571772a45c7
Minor house cleaning in the mplay_server_gui. Getting ready to push this
sirebral
parents:
9
diff
changeset
|
332 else: ret_string = ret_string + name[x] |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
333 return ret_string |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
334 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
335 # When we right click, cause our popup menu to appear |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
336 def OnPopupMenu( self, event ): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
337 pos = wx.Point( event.GetX(), event.GetY() ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
338 (item, flag) = self.HitTest( pos ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
339 if item > -1: |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
340 self.selectedItem = item |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
341 self.PopupMenu( self.menu, pos ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
342 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
343 # Process the events associated with our popup menu |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
344 def OnPopupMenuItem( self, event ): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
345 # if we are not running, the player list is empty anyways |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
346 if self.main.STATUS == SERVER_RUNNING: |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
347 menuItem = event.GetId() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
348 playerID = str( self.GetItemData( self.selectedItem ) ) |
56
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
349 room = str(self.GetItem((int(playerID)-1), 3).GetText()) |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
350 idList = self.main.server.server.groups |
56
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
351 for r in self.roomList: |
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
352 if room == self.roomList[r]: groupID = r |
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
353 else: groupID = 0 |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
354 if menuItem == MENU_PLAYER_BOOT: |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
355 print "booting player: ", playerID |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
356 self.main.server.server.del_player( playerID, groupID ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
357 self.main.server.server.check_group( playerID, groupID ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
358 self.remove( playerID ) |
100 | 359 ### Alpha ### |
360 elif menuItem == MENU_ADMIN_BAN: | |
361 message = 'Banishment' | |
362 BanMsg = wx.TextEntryDialog( self, "Enter A Message To Send:", | |
363 "Ban Message", message, wx.OK|wx.CANCEL|wx.CENTRE ) | |
364 if BanMsg.ShowModal() == wx.ID_OK: message = BanMsg.GetValue() | |
365 else: message = '' | |
366 Silent = wx.MessageDialog(None, 'Silent Ban?', 'Question', | |
367 wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION) | |
368 if Silent.ShowModal() == wx.ID_YES: silent = 1 | |
369 else: silent = 0 | |
370 self.main.server.server.admin_ban(playerID, message, silent) | |
371 self.remove( playerID ) | |
372 ############### | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
373 elif menuItem == MENU_PLAYER_SEND_MESSAGE: |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
374 print "send a message..." |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
375 msg = self.GetMessageInput( "Send a message to player" ) |
27
a571772a45c7
Minor house cleaning in the mplay_server_gui. Getting ready to push this
sirebral
parents:
9
diff
changeset
|
376 if len(msg): self.main.server.server.send( msg, playerID, str(groupID) ) |
a571772a45c7
Minor house cleaning in the mplay_server_gui. Getting ready to push this
sirebral
parents:
9
diff
changeset
|
377 #Leave this in for now. |
56
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
378 elif menuItem == MENU_PLAYER_SEND_ROOM_MESSAGE: |
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
379 print "Send message to room..." |
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
380 msg = self.GetMessageInput( "Send message to room of this player") |
58
27e58b0483e7
Fixed major bug that caused an error to spit out in Windows platforms.
sirebral
parents:
57
diff
changeset
|
381 if len(msg): self.main.server.server.send_to_group('0', str(groupID), msg ) |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
382 elif menuItem == MENU_PLAYER_SEND_SERVER_MESSAGE: |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
383 print "broadcast a message..." |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
384 msg = self.GetMessageInput( "Broadcast Server Message" ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
385 # If we got a message back, send it |
100 | 386 if len(msg): self.main.server.server.broadcast( msg ) |
135 | 387 elif menuItem == PLAYER_SHOW_VERSION: |
388 version_string = self.main.server.server.obtain_by_id(playerID, 'client_string') | |
389 if version_string: wx.MessageBox("Running client version " + version_string,"Version") | |
390 else: wx.MessageBox("No client version available for this player", "Version") | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
391 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
392 def GetMessageInput( self, title ): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
393 prompt = "Please enter the message you wish to send:" |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
394 msg = wx.TextEntryDialog(self, prompt, title) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
395 msg.ShowModal() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
396 msg.Destroy() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
397 return msg.GetValue() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
398 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
399 class ServerGUI(wx.Frame): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
400 STATUS = SERVER_STOPPED |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
401 def __init__(self, parent, id, title): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
402 wx.Frame.__init__(self, parent, id, title, size = (760, 560) ) |
100 | 403 if wx.Platform == '__WXMSW__': icon = wx.Icon( dir_struct["icon"]+'WAmisc9.ico', wx.BITMAP_TYPE_ICO ) |
404 else: icon = wx.Icon( dir_struct["icon"]+'connect.gif', wx.BITMAP_TYPE_GIF ) | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
405 self.SetIcon(icon) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
406 self.serverName = "Server Name" |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
407 self.bootPwd = "" |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
408 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
409 # Register our events to process -- notice the custom event handler |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
410 self.Bind(wx.EVT_CLOSE, self.OnExit) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
411 self.Bind(EVT_LOG_MESSAGE, self.OnLogMessage) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
412 self.Bind(EVT_FUNCTION_MESSAGE, self.OnFunctionMessage) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
413 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
414 # Creat GUI |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
415 self.build_menu() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
416 self.build_body() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
417 self.build_status() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
418 |
100 | 419 ### Alpha ### |
420 # Ban List Dialog | |
421 self.BanListDialog = BanListDialog(self) | |
422 ############# | |
423 | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
424 # Server Callbacks |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
425 cb = {} |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
426 cb["log"] = self.Log |
56
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
427 cb["connect"] = self.OnConnect ##Fixed!! |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
428 cb["disconnect"] = self.OnDisconnect |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
429 cb["update"] = self.OnUpdatePlayer |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
430 cb["data_recv"] = self.OnDataRecv |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
431 cb["data_sent"] = self.OnDataSent |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
432 cb["create_group"] = self.OnCreateGroup |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
433 cb["delete_group"] = self.OnDeleteGroup |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
434 cb["join_group"] = self.OnJoinGroup |
135 | 435 cb['update_group'] = self.OnUpdateGroup |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
436 cb["role"] = self.OnSetRole |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
437 self.callbacks = cb |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
438 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
439 # Misc. |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
440 self.conf = ServerConfig(self) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
441 self.total_messages_received = 0 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
442 self.total_data_received = 0 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
443 self.total_messages_sent = 0 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
444 self.total_data_sent = 0 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
445 |
100 | 446 """ Build GUI """ |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
447 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
448 def build_menu(self): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
449 """ Build the GUI menu. """ |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
450 self.mainMenu = wx.MenuBar() |
100 | 451 |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
452 # File Menu |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
453 menu = wx.Menu() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
454 menu.Append( MENU_START_SERVER, 'Start', 'Start server.') |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
455 self.Bind(wx.EVT_MENU, self.OnStart, id=MENU_START_SERVER) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
456 menu.Append( MENU_STOP_SERVER, 'Stop', 'Shutdown server.') |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
457 self.Bind(wx.EVT_MENU, self.OnStop, id=MENU_STOP_SERVER) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
458 menu.AppendSeparator() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
459 menu.Append( MENU_EXIT, 'E&xit', 'Exit application.') |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
460 self.Bind(wx.EVT_MENU, self.OnExit, id=MENU_EXIT) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
461 self.mainMenu.Append(menu, '&Server') |
100 | 462 |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
463 # Registration Menu |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
464 menu = wx.Menu() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
465 menu.Append( MENU_REGISTER_SERVER, 'Register', 'Register with OpenRPG server directory.') |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
466 self.Bind(wx.EVT_MENU, self.OnRegister, id=MENU_REGISTER_SERVER) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
467 menu.Append( MENU_UNREGISTER_SERVER, 'Unregister', 'Unregister from OpenRPG server directory.') |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
468 self.Bind(wx.EVT_MENU, self.OnUnregister, id=MENU_UNREGISTER_SERVER) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
469 self.mainMenu.Append( menu, '&Registration' ) |
100 | 470 |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
471 # Server Configuration Menu |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
472 menu = wx.Menu() |
100 | 473 menu.Append( MENU_BAN_LIST, 'Ban List', 'Modify Ban List.' ) |
474 self.Bind(wx.EVT_MENU, self.ModifyBanList, id=MENU_BAN_LIST) | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
475 menu.Append( MENU_START_PING_PLAYERS, 'Start Ping', 'Ping players to validate remote connection.' ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
476 self.Bind(wx.EVT_MENU, self.PingPlayers, id=MENU_START_PING_PLAYERS) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
477 menu.Append( MENU_STOP_PING_PLAYERS, 'Stop Ping', 'Stop validating player connections.' ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
478 self.Bind(wx.EVT_MENU, self.StopPingPlayers, id=MENU_STOP_PING_PLAYERS) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
479 menu.Append( MENU_PING_INTERVAL, 'Ping Interval', 'Change the ping interval.' ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
480 self.Bind(wx.EVT_MENU, self.ConfigPingInterval, id=MENU_PING_INTERVAL) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
481 self.mainMenu.Append( menu, '&Configuration' ) |
100 | 482 |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
483 self.SetMenuBar( self.mainMenu ) |
100 | 484 |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
485 self.mainMenu.Enable( MENU_STOP_SERVER, False ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
486 self.mainMenu.Enable( MENU_REGISTER_SERVER, False ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
487 self.mainMenu.Enable( MENU_UNREGISTER_SERVER, False ) |
100 | 488 |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
489 # Disable the ping menu items |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
490 self.mainMenu.Enable( MENU_START_PING_PLAYERS, False ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
491 self.mainMenu.Enable( MENU_STOP_PING_PLAYERS, False ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
492 self.mainMenu.Enable( MENU_PING_INTERVAL, False ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
493 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
494 def build_body(self): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
495 """ Create the ViewNotebook and logger. """ |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
496 splitter = wx.SplitterWindow(self, -1, style=wx.NO_3D | wx.SP_3D) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
497 nb = wx.Notebook( splitter, -1 ) |
135 | 498 self.conns = Connections(nb, self) |
499 self.groups = Groups(nb, self) | |
500 nb.AddPage(self.conns, "Players") | |
501 nb.AddPage(self.groups, 'Rooms') | |
27
a571772a45c7
Minor house cleaning in the mplay_server_gui. Getting ready to push this
sirebral
parents:
9
diff
changeset
|
502 |
a571772a45c7
Minor house cleaning in the mplay_server_gui. Getting ready to push this
sirebral
parents:
9
diff
changeset
|
503 #Not sure why this is Remarked TaS - Sirebral |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
504 #nb.AddPage( self.conns, "Rooms" ) |
135 | 505 self.msgWindow = HTMLMessageWindow( nb ) |
506 nb.AddPage( self.msgWindow, "Messages" ) | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
507 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
508 log = wx.TextCtrl(splitter, -1, style=wx.TE_MULTILINE | wx.TE_READONLY | wx.HSCROLL) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
509 wx.Log.SetActiveTarget( wx.LogTextCtrl(log) ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
510 splitter.SplitHorizontally(nb, log, 400) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
511 splitter.SetMinimumPaneSize(40) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
512 self.nb = nb |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
513 self.log = log |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
514 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
515 def build_status(self): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
516 """ Create status bar and set defaults. """ |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
517 sb = wx.StatusBar(self, -1) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
518 sb.SetFieldsCount(5) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
519 sb.SetStatusWidths([-1, 115, 115, 65, 200]) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
520 sb.SetStatusText("Sent: 0", 1) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
521 sb.SetStatusText("Recv: 0", 2) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
522 sb.SetStatusText("Stopped", 3) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
523 sb.SetStatusText("Unregistered", 4) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
524 self.SetStatusBar(sb) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
525 self.sb = sb |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
526 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
527 def show_error(self, mesg, title = "Error"): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
528 """ Display an error. |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
529 mesg (str) -- error message to display |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
530 title (str) -- title of window |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
531 """ |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
532 dlg = wx.MessageDialog(self, mesg, title, wx.OK | wx.ICON_EXCLAMATION) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
533 dlg.ShowModal() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
534 dlg.Destroy() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
535 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
536 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
537 # Event handler for out logging event |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
538 def OnLogMessage( self, event ): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
539 self.Log( event.message ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
540 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
541 # Event handler for out logging event |
135 | 542 def OnFunctionMessage(self, event): |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
543 self.callbacks[event.func]( event.message ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
544 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
545 ### Server Callbacks ##################################### |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
546 def Log(self, log): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
547 wx.LogMessage(str(log)) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
548 |
56
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
549 def OnConnect(self, player): |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
550 self.conns.add(player) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
551 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
552 def OnDisconnect(self, id): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
553 self.conns.remove(id) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
554 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
555 def OnUpdatePlayer(self, data): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
556 self.conns.update(data) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
557 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
558 def OnDataSent(self, bytes): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
559 self.total_messages_sent += 1 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
560 self.total_data_sent += bytes |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
561 self.sb.SetStatusText("Sent: %s (%d)" % (format_bytes(self.total_data_sent), self.total_messages_sent), 1) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
562 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
563 def OnDataRecv(self, bytes): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
564 self.total_messages_received += 1 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
565 self.total_data_received += bytes |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
566 self.sb.SetStatusText("Recv: %s (%d)" % (format_bytes(self.total_data_received), self.total_messages_received), 2) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
567 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
568 def OnCreateGroup( self, data ): |
135 | 569 (room, room_id, player, pwd) = data |
570 self.groups.AddGroup(data) | |
56
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
571 self.conns.roomList[room_id] = name |
135 | 572 data = (room, room_id, player) |
56
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
573 self.conns.updateRoom(data) |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
574 |
135 | 575 def OnDeleteGroup(self, data): |
56
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
576 (room_id, player) = data |
135 | 577 self.groups.DeleteGroup(room_id) |
56
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
578 del self.conns.roomList[room_id] |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
579 |
135 | 580 def OnJoinGroup(self, 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) | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
587 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
588 def OnSetRole( self, data ): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
589 (id, role) = data |
135 | 590 self.conns.setPlayerRole(id, role) |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
591 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
592 ### Misc. ################################################ |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
593 def OnStart(self, event = None): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
594 """ Start server. """ |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
595 if self.STATUS == SERVER_STOPPED: |
56
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
596 # see if we already have name specified |
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
597 try: |
92 | 598 validate.config_file( "server_ini.xml", "default_server_ini.xml" ) |
100 | 599 configDom = minidom.parse(dir_struct["user"] + 'server_ini.xml') |
56
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
600 configDom.normalize() |
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
601 configDoc = configDom.documentElement |
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
602 if configDoc.hasAttribute("name"): self.serverName = configDoc.getAttribute("name") |
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
603 except: pass |
100 | 604 if self.serverName == '': |
605 self.serverName = 'Server Name' | |
135 | 606 serverNameEntry = wx.TextEntryDialog(self, "Please Enter The Server Name You Wish To Use:", |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
607 "Server's Name", self.serverName, wx.OK|wx.CANCEL|wx.CENTRE ) |
56
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
608 if serverNameEntry.ShowModal() == wx.ID_OK: self.serverName = serverNameEntry.GetValue() |
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
609 # see if we already have password specified |
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
610 try: |
92 | 611 validate.config_file( "server_ini.xml", "default_server_ini.xml" ) |
100 | 612 configDom = minidom.parse(dir_struct["user"] + 'server_ini.xml') |
56
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
613 configDom.normalize() |
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
614 configDoc = configDom.documentElement |
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
615 if configDoc.hasAttribute("admin"): self.bootPwd = configDoc.getAttribute("admin") |
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
616 elif configDoc.hasAttribute("boot"): self.bootPwd = configDoc.getAttribute("boot") |
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
617 except: pass |
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
618 if self.bootPwd == '': |
100 | 619 serverPasswordEntry = wx.TextEntryDialog(self, |
620 "Please Enter The Server Admin Password:", "Server's Password", | |
621 self.bootPwd, wx.OK|wx.CANCEL|wx.CENTRE) | |
56
c7f04d3c76f5
Major update to Server GUI. Basically makes it functional.
sirebral
parents:
27
diff
changeset
|
622 if serverPasswordEntry.ShowModal() == wx.ID_OK: self.bootPwd = serverPasswordEntry.GetValue() |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
623 if len(self.serverName): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
624 wx.BeginBusyCursor() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
625 self.server = ServerMonitor(self.callbacks, self.conf, self.serverName, self.bootPwd) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
626 self.server.start() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
627 self.STATUS = SERVER_RUNNING |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
628 self.sb.SetStatusText("Running", 3) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
629 self.SetTitle(__appname__ + "- (running) - (unregistered)") |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
630 self.mainMenu.Enable( MENU_START_SERVER, False ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
631 self.mainMenu.Enable( MENU_STOP_SERVER, True ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
632 self.mainMenu.Enable( MENU_REGISTER_SERVER, True ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
633 wx.EndBusyCursor() |
27
a571772a45c7
Minor house cleaning in the mplay_server_gui. Getting ready to push this
sirebral
parents:
9
diff
changeset
|
634 else: self.show_error("Server is already running.", "Error Starting Server") |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
635 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
636 def OnStop(self, event = None): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
637 """ Stop server. """ |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
638 if self.STATUS == SERVER_RUNNING: |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
639 self.OnUnregister() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
640 self.server.stop() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
641 self.STATUS = SERVER_STOPPED |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
642 self.sb.SetStatusText("Stopped", 3) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
643 self.SetTitle(__appname__ + "- (stopped) - (unregistered)") |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
644 self.mainMenu.Enable( MENU_STOP_SERVER, False ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
645 self.mainMenu.Enable( MENU_START_SERVER, True ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
646 self.mainMenu.Enable( MENU_REGISTER_SERVER, False ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
647 self.mainMenu.Enable( MENU_UNREGISTER_SERVER, False ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
648 self.conns.DeleteAllItems() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
649 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
650 def OnRegister(self, event = None): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
651 """ Call into mplay_server's register() function. |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
652 This will begin registerThread(s) to keep server |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
653 registered with configured metas |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
654 """ |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
655 if len( self.serverName ): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
656 wx.BeginBusyCursor() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
657 self.server.server.register(self.serverName) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
658 self.sb.SetStatusText( ("%s" % (self.serverName)), 4 ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
659 self.mainMenu.Enable( MENU_REGISTER_SERVER, False ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
660 self.mainMenu.Enable( MENU_UNREGISTER_SERVER, True ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
661 self.mainMenu.Enable( MENU_STOP_SERVER, False ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
662 self.SetTitle(__appname__ + "- (running) - (registered)") |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
663 wx.EndBusyCursor() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
664 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
665 def OnUnregister(self, event = None): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
666 """ Call into mplay_server's unregister() function. |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
667 This will kill any registerThreads currently running |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
668 and result in the server being de-listed |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
669 from all metas |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
670 """ |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
671 wx.BeginBusyCursor() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
672 self.server.server.unregister() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
673 self.sb.SetStatusText( "Unregistered", 4 ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
674 self.mainMenu.Enable( MENU_UNREGISTER_SERVER, False ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
675 self.mainMenu.Enable( MENU_REGISTER_SERVER, True ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
676 self.mainMenu.Enable( MENU_STOP_SERVER, True ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
677 self.SetTitle(__appname__ + "- (running) - (unregistered)") |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
678 wx.EndBusyCursor() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
679 |
100 | 680 ### Alpha ### |
681 def ModifyBanList(self, event): | |
682 if self.BanListDialog.IsShown() == True: self.BanListDialog.Hide() | |
683 else: self.BanListDialog.Show() | |
684 ############# | |
685 | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
686 def PingPlayers( self, event = None ): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
687 "Ping all players that are connected at a periodic interval, detecting dropped connections." |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
688 wx.BeginBusyCursor() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
689 wx.Yield() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
690 wx.EndBusyCursor() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
691 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
692 def StopPingPlayers( self, event = None ): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
693 "Stop pinging connected players." |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
694 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
695 def ConfigPingInterval( self, event = None ): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
696 "Configure the player ping interval. Note that all players are pinged on a single timer." |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
697 |
135 | 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): | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
705 """ Quit the program. """ |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
706 self.OnStop() |
100 | 707 self.BanListDialog.Destroy() ### Alpha ### |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
708 wx.CallAfter(self.Destroy) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
709 |
100 | 710 ### Alpha ### |
711 class BanListDialog(wx.Frame): | |
712 def __init__(self, parent): | |
713 super(BanListDialog, self).__init__(parent, -1, "Ban List") | |
714 icon = wx.Icon(dir_struct["icon"]+'noplayer.gif', wx.BITMAP_TYPE_GIF) | |
715 self.SetIcon( icon ) | |
716 self.BanList = wx.ListCtrl(self, wx.ID_ANY, style=wx.LC_SINGLE_SEL|wx.LC_REPORT|wx.LC_HRULES) | |
717 sizer = wx.BoxSizer(wx.VERTICAL) | |
718 sizer.Add(self.BanList, 1, wx.EXPAND) | |
719 self.BuildList() | |
720 self.SetSizer(sizer) | |
721 self.SetAutoLayout(True) | |
722 self.SetSize((300, 175)) | |
723 self.Bind(wx.EVT_CLOSE, self.Min) | |
724 self.Min(None) | |
725 | |
726 # Ban List Dialog Pop Up Menu, more can be added | |
727 self.menu = wx.Menu() | |
728 self.menu.SetTitle( "Modify Ban List" ) | |
729 self.menu.Append( MENU_ADMIN_UNBAN, "Un-Ban Player" ) | |
730 | |
731 # Even Association | |
732 self.BanList.Bind(wx.EVT_RIGHT_DOWN, self.BanPopupMenu) | |
733 self.Bind(wx.EVT_MENU, self.BanPopupMenuItem, id=MENU_ADMIN_UNBAN) | |
734 | |
735 # When we right click, cause our popup menu to appear | |
736 def BanPopupMenu( self, event ): | |
737 pos = wx.Point( event.GetX(), event.GetY() ) | |
738 (item, flag) = self.BanList.HitTest( pos ) | |
739 if item > -1: | |
740 self.selectedItem = item | |
741 self.PopupMenu( self.menu, pos ) | |
742 | |
743 def BanPopupMenuItem( self, event): | |
744 menuItem = event.GetId() | |
745 player = str(self.BanList.GetItemData(self.selectedItem)) | |
746 playerIP = str(self.BanList.GetItem((int(player)), 1).GetText()) | |
747 if menuItem == MENU_ADMIN_UNBAN: | |
748 server.admin_unban(playerIP) | |
749 self.BanList.DeleteItem(self.BanList.GetItemData(self.selectedItem)) | |
750 self.BanList.Refresh() | |
751 | |
752 def BuildList(self): | |
753 # Build Dialog Columns | |
754 self.BanList.ClearAll() | |
755 self.BanList.InsertColumn(0, "User Name") | |
756 self.BanList.InsertColumn(1, "IP") | |
757 | |
758 validate.config_file("ban_list.xml", "default_ban_list.xml" ) | |
759 configDom = minidom.parse(dir_struct["user"] + 'ban_list.xml') | |
760 ban_dict = {} | |
761 for element in configDom.getElementsByTagName('banned'): | |
762 player = element.getAttribute('name').replace("&", "&").replace("<", "<").replace('"', """).replace(">", ">") | |
763 playerIP = element.getAttribute('ip') | |
764 ban_dict[player] = playerIP | |
765 for key in ban_dict: | |
766 i = self.BanList.InsertImageStringItem( 0, key, 0 ) | |
767 self.BanList.SetStringItem(i, 1, ban_dict[key]) | |
768 self.BanList.RefreshItem(i) | |
769 self.AutoAdjust() | |
770 | |
771 def AutoAdjust(self): | |
772 self.BanList.SetColumnWidth(0, -1) | |
773 self.BanList.SetColumnWidth(1, -1) | |
774 self.BanList.Refresh() | |
775 | |
776 def Min(self, evt): | |
777 self.Hide() | |
778 ############### | |
779 | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
780 class ServerGUIApp(wx.App): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
781 def OnInit(self): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
782 # Make sure our image handlers are loaded before we try to display anything |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
783 wx.InitAllImageHandlers() |
100 | 784 self.splash = wx.SplashScreen(wx.Bitmap(dir_struct["icon"]+'splash.gif'), |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
785 wx.SPLASH_CENTRE_ON_SCREEN|wx.SPLASH_TIMEOUT, |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
786 2000, |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
787 None) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
788 self.splash.Show(True) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
789 wx.Yield() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
790 wx.CallAfter(self.AfterSplash) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
791 return True |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
792 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
793 def AfterSplash(self): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
794 self.splash.Close(True) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
795 frame = ServerGUI(None, -1, __appname__ + "- (stopped) - (unregistered)") |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
796 frame.Show(True) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
797 frame.Raise() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
798 self.SetTopWindow(frame) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
799 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
800 class HTMLMessageWindow(wx.html.HtmlWindow): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
801 "Widget used to present user to admin messages, in HTML format, to the server administrator" |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
802 # Init using the derived from class |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
803 def __init__( self, parent ): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
804 wx.html.HtmlWindow.__init__( self, parent ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
805 def OnLinkClicked( self, ref ): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
806 "Open an external browser to resolve our About box links!!!" |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
807 href = ref.GetHref() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
808 webbrowser.open( href ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
809 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
810 if __name__ == '__main__': |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
811 app = ServerGUIApp(0) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
812 app.MainLoop() |