annotate orpg/networking/mplay_server_gui.py @ 183:0d9b746b5751 beta

Traipse Beta 'OpenRPG' {100115-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) New Features: Added Bookmarks 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 New TrueDebug Class in orpg_log (See documentation for usage) Portable Mercurial Tip of the Day added, from Core and community New Reference Syntax added for custom PC sheets New Child Reference for gametree New Parent Reference for gametree New Gametree Recursion method, mapping, context sensitivity, and effeciency.. New Features node with bonus nodes and Node Referencing help added Dieroller structure from Core New DieRoller portability for odd Dice Added 7th Sea die roller; ie [7k3] = [7d10.takeHighest(3).open(10)] New 'Mythos' System die roller added Added new vs. die roller method for WoD; ie [3v3] = [3d10.vs(3)]. Included for Mythos roller also New Warhammer FRPG Die Roller (Special thanks to Puu-san for the support) New EZ_Tree Reference system. Push a button, Traipse the tree, get a reference (Beta!) Fixes: Fix to Text based Server Fix to Remote Admin Commands Fix to Pretty Print, from Core Fix to Splitter Nodes not being created Fix to massive amounts of images loading, from Core Fix to Map from gametree not showing to all clients Fix to gametree about menus Fix to Password Manager check on startup Fix to PC Sheets from tool nodes. They now use the tabber_panel Fix to Whiteboard ID to prevent random line or text deleting. Fixes to Server, Remote Server, and Server GUI Fix to Update Manager; cleaner clode for saved repositories Fixes made to Settings Panel and now reactive settings when Ok is pressed Fixes to Alternity roller's attack roll. Uses a simple Tuple instead of a Splice Fix to Use panel of Forms and Tabbers. Now longer enters design mode Fix made Image Fetching. New fetching image and new failed image Modified ID's to prevent non updated clients from ruining the fix. default_manifest.xml renamed to default_upmana.xml
author sirebral
date Fri, 15 Jan 2010 23:01:42 -0600
parents 6081bdc2b8d5
children dcae32e219f1
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
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
12 import os, sys, time, types
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
13
100
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
14 from orpg.dirpath import dir_struct
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
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
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
17 from threading import Thread
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
18
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
19 import webbrowser
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
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
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
22 from mplay_server import mplay_server, server
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
23
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 27
diff changeset
24 from xml.dom import minidom
100
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
25 from orpg.orpgCore import component
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
26 from orpg.tools.orpg_log import debug
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
27 from orpg.tools.orpg_settings import settings
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
28
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
29 from xml.etree.ElementTree import ElementTree, Element, iselement
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
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
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
35
100
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
36 ### Alpha ###
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
37 MENU_MODIFY_BANLIST = wx.NewId()
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
38 #############
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
39
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
40 MENU_PLAYER_CREATE_ROOM = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
41
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
42 # 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
43 # thread to another
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
44 wxEVT_LOG_MESSAGE = wx.NewEventType()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
45 wxEVT_FUNCTION_MESSAGE = wx.NewEventType()
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 # Our event connector -- wxEVT_LOG_MESSAGE
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
48 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
49
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
50 # Our event connector -- wxEVT_FUNCTION_MESSAGE
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
51 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
52
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
53 # Utils ##########################################
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
54 def format_bytes(b):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
55 f = ['b', 'Kb', 'Mb', 'Gb']
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
56 i = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
57 while i < 3:
100
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
58 if b < 1024: return str(b) + f[i]
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
59 else: b = b/1024
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
60 i += 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
61 return str(b) + f[3]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
62
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
63 # wxEVT_LOG_MESSAGE
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
64 # MessageLogEvent ###############################
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
65 class MessageLogEvent(wx.PyEvent):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
66 def __init__( self, message ):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
67 wx.PyEvent.__init__( self )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
68 self.SetEventType(wxEVT_LOG_MESSAGE)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
69 self.message = message
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 # wxEVT_TUPLE_MESSAGE
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
72 # MessageLogEvent ###############################
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
73 class MessageFunctionEvent(wx.PyEvent):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
74 def __init__( self, func, message ):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
75 wx.PyEvent.__init__( self )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
76 self.SetEventType(wxEVT_FUNCTION_MESSAGE)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
77 self.func = func
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
78 self.message = message
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
79
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
80 # ServerConfig Object ############################
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
81 class ServerConfig:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
82 """ This class contains configuration
100
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
83 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
84
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 27
diff changeset
85 def __init__(self, owner ):
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 27
diff changeset
86 """ Loads default configuration settings."""
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
87 validate.config_file("server_ini.xml", "default_server_ini.xml")
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
88 config_xml = parse(dir_struct['user'] + 'server_ini.xml').getroot()
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
89 port = config_xml.find('service').get('port')
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
90 OPENRPG_PORT = 6774 if port == '' else int(port)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
91 self.owner = owner
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
92
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
93 def load_xml(self, xml):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
94 """ Load configuration from XML data.
100
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
95 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
96 pass
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 def save_xml(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
99 """ Returns XML file representing
100
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
100 the active configuration. """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
101 pass
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
102
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
103 # Server Monitor #################################
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
104
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
105 class ServerMonitor(Thread):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
106 """ Monitor thread for GameServer. """
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
107 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
108 """ Setup the server. """
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
109 Thread.__init__(self)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
110 self.cb = cb
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
111 self.conf = conf
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
112 self.serverName = name
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
113 self.bootPwd = pwd
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
114
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
115 def log(self, mesg):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
116 if type(mesg) == types.TupleType:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
117 func, msg = mesg
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
118 event = MessageFunctionEvent( func, msg )
27
a571772a45c7 Minor house cleaning in the mplay_server_gui. Getting ready to push this
sirebral
parents: 9
diff changeset
119 else: event = MessageLogEvent( mesg )
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
120 wx.PostEvent( self.conf.owner, event )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
121 del event
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
122
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
123 def run(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
124 """ Start the server. """
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
125 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
126 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
127 self.alive = 1
27
a571772a45c7 Minor house cleaning in the mplay_server_gui. Getting ready to push this
sirebral
parents: 9
diff changeset
128 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
129
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
130 def stop(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
131 """ Stop the server. """
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
132 self.server.kill_server()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
133 self.alive = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
134
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
135 # GUI Server #####################################
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
136 # Parent = notebook
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
137 # Main = GUI
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
138 class Groups(wx.ListCtrl):
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
139 def __init__(self, parent, main):
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
140 wx.ListCtrl.__init__(self, parent, -1, wx.DefaultPosition,
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
141 wx.DefaultSize, wx.LC_REPORT|wx.SUNKEN_BORDER|wx.EXPAND|wx.LC_HRULES)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
142
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
143 """Not completed. Creates room, delets rooms. Does not track players. Nor does gsclient, ftm."""
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
144 validate.config_file("server_ini.xml", "default_server_ini.xml" )
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
145 config_xml = parse(dir_struct["user"] + 'server_ini.xml').getroot()
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
146 lobbyname = config_xml.get('lobbyname')
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
147
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
148 self.main = main
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
149 self.roomList = { 0 : lobbyname }
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
150 self.InsertColumn(0, 'Group ID')
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
151 self.InsertColumn(1, 'Game')
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
152 self.InsertColumn(2, 'Players')
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
153 self.InsertColumn(3, 'Passworded')
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
154 self.AddGroup((self.roomList[0], '0', '0', 'No'))
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
155
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
156 def AddGroup(self, data):
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
157 (room, room_id, players, passworded) = data
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
158 i = self.InsertStringItem(0, str(room_id))
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
159 self.SetStringItem(i, 1, room)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
160 self.SetStringItem(i, 2, players)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
161 self.SetStringItem(i, 3, str(passworded))
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
162
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
163 def DeleteGroup(self, data):
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
164 i = self.FindItem(-1, str(data))
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
165 self.DeleteItem(i)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
166
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
167 def UpdateGroup(self, data):
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
168 (room, room_id, players) = data
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
169 i = self.FindItem( -1, str(room_id))
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
170 self.SetStringItem( i, 1, room )
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
171 if players: self.SetStringItem(i, 2, str(players))
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
172 ### Need to add room for Password Updates ###
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
173
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
174 class Connections(wx.ListCtrl):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
175 def __init__( self, parent, main ):
100
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
176 wx.ListCtrl.__init__( self, parent, -1, wx.DefaultPosition,
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
177 wx.DefaultSize, wx.LC_REPORT|wx.SUNKEN_BORDER|wx.EXPAND|wx.LC_HRULES )
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
178
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
179 validate.config_file("server_ini.xml", "default_server_ini.xml" )
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
180 config_xml = parse(dir_struct["user"] + 'server_ini.xml').getroot()
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
181 lobbyname = config_xml.get('lobbyname')
100
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
182
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
183 self.main = main
100
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
184 self.roomList = { 0 : lobbyname }
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
185 self._imageList = wx.ImageList( 16, 16, False )
100
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
186 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
187 self._imageList.Add( img )
100
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
188 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
189 self._imageList.Add( img )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
190 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
191
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
192 # Set The columns
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
193 self.InsertColumn(0, "ID")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
194 self.InsertColumn(1, "Player")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
195 self.InsertColumn(2, "Status")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
196 self.InsertColumn(3, "Room")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
197 self.InsertColumn(4, "Version")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
198 self.InsertColumn(5, "Role")
9
c97c641a76fd Small changes made to the mplay_server_gui.py that prevented a server
sirebral
parents: 0
diff changeset
199 self.InsertColumn(6, "IP")
c97c641a76fd Small changes made to the mplay_server_gui.py that prevented a server
sirebral
parents: 0
diff changeset
200 self.InsertColumn(7, "Ping")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
201
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
202 # Set the column widths
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
203 self.AutoAjust()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
204
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
205 # 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
206 self.menu = wx.Menu()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
207 self.menu.SetTitle( "Player Menu" )
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
208 self.menu.Append( 1, "Boot Player" )
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
209 self.menu.Append( 2, 'Ban Player' )
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
210 self.menu.Append( 3, "Player Version" )
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
211 self.menu.AppendSeparator()
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
212 self.menu.Append( 4, "Send Player Message" )
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
213 self.menu.Append( 5, "Send Room Message" )
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
214 self.menu.Append( 6, "Broadcast Server Message" )
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
215
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
216 # Associate our events
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
217 self.Bind(wx.EVT_RIGHT_DOWN, self.OnPopupMenu)
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
218 self.Bind(wx.EVT_MENU, self.OnPopupMenuItem, id=1)
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
219 self.Bind(wx.EVT_MENU, self.OnPopupMenuItem, id=2)
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
220 self.Bind(wx.EVT_MENU, self.OnPopupMenuItem, id=4)
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
221 self.Bind(wx.EVT_MENU, self.OnPopupMenuItem, id=5)
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
222 self.Bind(wx.EVT_MENU, self.OnPopupMenuItem, id=6)
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
223 self.Bind(wx.EVT_MENU, self.OnPopupMenuItem, id=3)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
224
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
225 def add(self, player):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
226 i = self.InsertImageStringItem( 0, player["id"], 0 )
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
227 self.SetStringItem(i, 1, self.stripHtml(player["name"]))
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
228 self.SetStringItem(i, 2, "NEW")
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
229 self.SetStringItem(i, 3, self.roomList[0])
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
230 self.SetStringItem(i, 4, self.stripHtml(player["version"]))
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
231 self.SetStringItem(i, 5, 'Lurker' if player["role"] == None else self.stripHtml(player["role"]))
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
232 self.SetStringItem(i, 6, self.stripHtml(player["ip"]))
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
233 self.SetStringItem(i, 7, "PING")
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
234 self.SetItemData(i, int(player["id"]))
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
235 self.colorize_player_list(player)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
236 self.AutoAjust()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
237
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
238 def remove(self, id):
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
239 i = self.FindItemData( -1, int(id))
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
240 self.DeleteItem(i)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
241 self.AutoAjust()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
242
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
243 def AutoAjust(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
244 self.SetColumnWidth(0, -1)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
245 self.SetColumnWidth(1, -1)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
246 self.SetColumnWidth(2, -1)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
247 self.SetColumnWidth(3, -1)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
248 self.SetColumnWidth(4, -1)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
249 self.SetColumnWidth(5, -1)
27
a571772a45c7 Minor house cleaning in the mplay_server_gui. Getting ready to push this
sirebral
parents: 9
diff changeset
250 self.SetColumnWidth(6, -1)
a571772a45c7 Minor house cleaning in the mplay_server_gui. Getting ready to push this
sirebral
parents: 9
diff changeset
251 self.SetColumnWidth(7, -1)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
252 self.Refresh()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
253
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
254 def colorize_player_list(self, player):
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
255 if player == 0: return
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
256 for m in player.keys():
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
257 id = player['id']
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
258 item_list_location = self.FindItemData(-1, int(id))
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
259 if item_list_location == -1: continue
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
260 item = self.GetItem(item_list_location)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
261 role = player['role']
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
262 try: #Players that turn up Blue are not passing the correct arguments.
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
263 try:
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
264 if player['group_id'] != "0": item.SetTextColour(settings.get_setting(role + "RoleColor"))
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
265 except KeyError: # Needed because group_id turns into group somewhere.
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
266 if player['group'] != "0": item.SetTextColour(settings.get_setting(role + "RoleColor"))
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
267 except: item.SetTextColour('BLUE')
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
268 self.SetItem(item)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
269
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
270 def update(self, player):
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
271 #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
272 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
273 if i > -1:
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 27
diff changeset
274 self.SetStringItem(i, 1, self.stripHtml(player["name"]))
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 27
diff changeset
275 self.SetStringItem(i, 2, self.stripHtml(player["status"]))
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
276 self.SetStringItem(i, 5, 'Lurker' if player["role"] == None else self.stripHtml(player["role"]))
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
277 self.colorize_player_list(player)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
278 self.AutoAjust()
27
a571772a45c7 Minor house cleaning in the mplay_server_gui. Getting ready to push this
sirebral
parents: 9
diff changeset
279 else: self.add(player)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
280
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
281 def updateRoom( self, data ):
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 27
diff changeset
282 (room, room_id, player) = data
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 27
diff changeset
283 i = self.FindItemData( -1, int(player) )
100
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
284 if player > 0: self.SetStringItem( i, 3, room )
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 27
diff changeset
285 self.AutoAjust()
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
286 #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
287
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
288 def setPlayerRole( self, id, role ):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
289 i = self.FindItemData( -1, int(id) )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
290 self.SetStringItem( i, 5, role )
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
291 self.AutoAjust()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
292
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
293 def stripHtml( self, name ):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
294 ret_string = ""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
295 x = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
296 in_tag = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
297 for x in range( len(name) ):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
298 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
299 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
300 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
301 else: pass
a571772a45c7 Minor house cleaning in the mplay_server_gui. Getting ready to push this
sirebral
parents: 9
diff changeset
302 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
303 return ret_string
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
304
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
305 # 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
306 def OnPopupMenu( self, event ):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
307 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
308 (item, flag) = self.HitTest( pos )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
309 if item > -1:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
310 self.selectedItem = item
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
311 self.PopupMenu( self.menu, pos )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
312
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
313 # 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
314 def OnPopupMenuItem( self, event ):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
315 # 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
316 if self.main.STATUS == SERVER_RUNNING:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
317 menuItem = event.GetId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
318 playerID = str( self.GetItemData( self.selectedItem ) )
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 27
diff changeset
319 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
320 idList = self.main.server.server.groups
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 27
diff changeset
321 for r in self.roomList:
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 27
diff changeset
322 if room == self.roomList[r]: groupID = r
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 27
diff changeset
323 else: groupID = 0
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
324 if menuItem == 1:
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
325 self.main.server.server.admin_kick( playerID )
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
326 elif menuItem == 2:
100
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
327 message = 'Banishment'
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
328 BanMsg = wx.TextEntryDialog( self, "Enter A Message To Send:",
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
329 "Ban Message", message, wx.OK|wx.CANCEL|wx.CENTRE )
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
330 if BanMsg.ShowModal() == wx.ID_OK: message = BanMsg.GetValue()
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
331 else: message = ''
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
332 Silent = wx.MessageDialog(None, 'Silent Ban?', 'Question',
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
333 wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
334 if Silent.ShowModal() == wx.ID_YES: silent = 1
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
335 else: silent = 0
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
336 self.main.server.server.admin_ban(playerID, message, silent)
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
337 self.remove( playerID )
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
338 elif menuItem == 4:
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
339 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
340 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
341 #Leave this in for now.
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
342 elif menuItem == 5:
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 27
diff changeset
343 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
344 if len(msg): self.main.server.server.send_to_group('0', str(groupID), msg )
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
345 elif menuItem == 6:
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
346 msg = self.GetMessageInput( "Broadcast Server Message" )
100
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
347 if len(msg): self.main.server.server.broadcast( msg )
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
348 elif menuItem == 3:
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
349 version_string = self.main.server.server.obtain_by_id(playerID, 'client_string')
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
350 if version_string: wx.MessageBox("Running client version " + version_string,"Version")
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
351 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
352
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
353 def GetMessageInput( self, title ):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
354 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
355 msg = wx.TextEntryDialog(self, prompt, title)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
356 msg.ShowModal()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
357 msg.Destroy()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
358 return msg.GetValue()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
359
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
360 class ServerGUI(wx.Frame):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
361 STATUS = SERVER_STOPPED
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
362 def __init__(self, parent, id, title):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
363 wx.Frame.__init__(self, parent, id, title, size = (760, 560) )
100
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
364 if wx.Platform == '__WXMSW__': icon = wx.Icon( dir_struct["icon"]+'WAmisc9.ico', wx.BITMAP_TYPE_ICO )
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
365 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
366 self.SetIcon(icon)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
367 self.serverName = "Server Name"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
368 self.bootPwd = ""
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
369 self.do_log = True
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
370
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
371 # 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
372 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
373 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
374 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
375
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
376 # Creat GUI
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
377 self.build_menu()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
378 self.build_body()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
379 self.build_status()
100
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
380 self.BanListDialog = BanListDialog(self)
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
381
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
382 # Server Callbacks
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
383 cb = {}
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
384 cb["log"] = self.Log
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
385 cb["connect"] = self.OnConnect
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
386 cb["disconnect"] = self.OnDisconnect
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
387 cb["update"] = self.OnUpdatePlayer
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
388 cb["data_recv"] = self.OnDataRecv
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
389 cb["data_sent"] = self.OnDataSent
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
390 cb["create_group"] = self.OnCreateGroup
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
391 cb["delete_group"] = self.OnDeleteGroup
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
392 cb["join_group"] = self.OnJoinGroup
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
393 cb['update_group'] = self.OnUpdateGroup
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
394 cb["role"] = self.OnSetRole
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
395 self.callbacks = cb
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
396
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
397 # Misc.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
398 self.conf = ServerConfig(self)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
399 self.total_messages_received = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
400 self.total_data_received = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
401 self.total_messages_sent = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
402 self.total_data_sent = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
403
100
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
404 """ Build GUI """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
405 def build_menu(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
406 """ Build the GUI menu. """
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
407 self.mainMenu = wx.MenuBar()
100
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
408
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
409 # File Menu
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
410 menu = wx.Menu()
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
411 menu.Append( 1, 'Start', 'Start server.')
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
412 menu.Append( 2, 'Stop', 'Shutdown server.')
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
413 menu.AppendSeparator()
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
414 menu.Append( 3, 'E&xit', 'Exit application.')
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
415 self.Bind(wx.EVT_MENU, self.OnStart, id=1)
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
416 self.Bind(wx.EVT_MENU, self.OnStop, id=2)
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
417 self.Bind(wx.EVT_MENU, self.OnExit, id=3)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
418 self.mainMenu.Append(menu, '&Server')
100
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
419
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
420 # Registration Menu
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
421 menu = wx.Menu()
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
422 menu.Append( 4, 'Register', 'Register with OpenRPG server directory.')
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
423 menu.Append( 5, 'Unregister', 'Unregister from OpenRPG server directory.')
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
424 self.Bind(wx.EVT_MENU, self.OnRegister, id=4)
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
425 self.Bind(wx.EVT_MENU, self.OnUnregister, id=5)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
426 self.mainMenu.Append( menu, '&Registration' )
100
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
427
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
428 # Server Configuration Menu
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
429 menu = wx.Menu()
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
430 menu.Append( 6, 'Ban List', 'Modify Ban List.')
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
431 menu.Append(11, 'Zombies', 'Set auto-kick time for zombie clients')
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
432 menu.Append(14, 'Send Size', 'Adjust the send size limit')
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
433 menu.AppendSeparator()
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
434 menu.Append( 7, 'Start Ping', 'Ping players to validate remote connection.' )
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
435 menu.Append( 8, 'Stop Ping', 'Stop validating player connections.' )
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
436 menu.Append( 9, 'Ping Interval', 'Change the ping interval.' )
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
437 menu.AppendSeparator()
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
438 menu.AppendCheckItem( 10, 'Server Logging', 'Turn on or off the Server GUI Log').Check(self.do_log)
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
439 menu.AppendCheckItem(12, 'Room Passwords', 'Allow or Deny Room Passwords').Check(False)
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
440 menu.AppendCheckItem(13, 'Remote Admin', 'Allow or Deny Remote Admin').Check(False)
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
441 menu.AppendCheckItem(15, 'Remote Kill', 'Allow or Deny Remote Admin Server Kill').Check(False)
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
442 self.Bind(wx.EVT_MENU, self.ModifyBanList, id=6)
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
443 self.Bind(wx.EVT_MENU, self.PingPlayers, id=7)
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
444 self.Bind(wx.EVT_MENU, self.StopPingPlayers, id=8)
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
445 self.Bind(wx.EVT_MENU, self.ConfigPingInterval, id=9)
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
446 self.Bind(wx.EVT_MENU, self.LogToggle, id=10)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
447 self.mainMenu.Append( menu, '&Configuration' )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
448 self.SetMenuBar( self.mainMenu )
100
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
449
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
450 self.mainMenu.Enable( 2, False )
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
451 self.mainMenu.Enable( 4, False )
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
452 self.mainMenu.Enable( 5, False )
100
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
453
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
454 # Disable the ping menu items
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
455 self.mainMenu.Enable( 7, False )
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
456 self.mainMenu.Enable( 8, False )
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
457 self.mainMenu.Enable( 9, False )
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
458
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
459 # Disable placeholders
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
460 self.mainMenu.Enable( 11, False )
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
461 self.mainMenu.Enable( 14, False )
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
462 self.mainMenu.Enable( 12, False )
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
463 self.mainMenu.Enable( 13, False )
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
464 self.mainMenu.Enable( 15, False )
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
465 def build_body(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
466 """ Create the ViewNotebook and logger. """
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
467 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
468 nb = wx.Notebook( splitter, -1 )
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
469 self.conns = Connections(nb, self)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
470 self.groups = Groups(nb, self)
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
471 self.msgWindow = HTMLMessageWindow( nb )
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
472 nb.AddPage(self.conns, "Players")
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
473 nb.AddPage(self.groups, 'Rooms')
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
474 nb.AddPage( self.msgWindow, "Messages" )
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
475
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
476 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
477 wx.Log.SetActiveTarget( wx.LogTextCtrl(log) )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
478 splitter.SplitHorizontally(nb, log, 400)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
479 splitter.SetMinimumPaneSize(40)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
480 self.nb = nb
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
481 self.log = log
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
482
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
483 def build_status(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
484 """ Create status bar and set defaults. """
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
485 sb = wx.StatusBar(self, -1)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
486 sb.SetFieldsCount(5)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
487 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
488 sb.SetStatusText("Sent: 0", 1)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
489 sb.SetStatusText("Recv: 0", 2)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
490 sb.SetStatusText("Stopped", 3)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
491 sb.SetStatusText("Unregistered", 4)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
492 self.SetStatusBar(sb)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
493 self.sb = sb
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
494
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
495 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
496 """ Display an error.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
497 mesg (str) -- error message to display
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
498 title (str) -- title of window
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
499 """
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
500 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
501 dlg.ShowModal()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
502 dlg.Destroy()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
503
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
504
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
505 # Event handler for out logging event
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
506 def LogToggle(self, event):
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
507 self.do_log = event.IsChecked()
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
508
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
509 def OnLogMessage( self, event ):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
510 self.Log( event.message )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
511
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
512 # Event handler for out logging event
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
513 def OnFunctionMessage(self, event):
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
514 self.callbacks[event.func]( event.message )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
515
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
516 ### Server Callbacks #####################################
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
517 def Log(self, log):
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
518 if self.do_log: wx.LogMessage(str(log))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
519
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 27
diff changeset
520 def OnConnect(self, player):
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
521 self.conns.add(player)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
522
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
523 def OnDisconnect(self, id):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
524 self.conns.remove(id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
525
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
526 def OnUpdatePlayer(self, data):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
527 self.conns.update(data)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
528
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
529 def OnDataSent(self, bytes):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
530 self.total_messages_sent += 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
531 self.total_data_sent += bytes
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
532 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
533
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
534 def OnDataRecv(self, bytes):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
535 self.total_messages_received += 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
536 self.total_data_received += bytes
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
537 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
538
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
539 def OnCreateGroup( self, data ):
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
540 (room, room_id, player, pwd) = data
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
541 self.groups.AddGroup(data)
140
e842a5f1b775 Traipse Beta 'OpenRPG' {091123-00}
sirebral
parents: 135
diff changeset
542 self.conns.roomList[room_id] = room
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
543 data = (room, room_id, player)
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 27
diff changeset
544 self.conns.updateRoom(data)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
545
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
546 def OnDeleteGroup(self, data):
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 27
diff changeset
547 (room_id, player) = data
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
548 self.groups.DeleteGroup(room_id)
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 27
diff changeset
549 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
550
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
551 def OnJoinGroup(self, data):
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
552 self.conns.updateRoom(data)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
553
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
554 def OnUpdateGroup(self, data):
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
555 (room, room_id, players) = data
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
556 self.groups.UpdateGroup(data)
0
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 OnSetRole( self, data ):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
559 (id, role) = data
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
560 self.conns.setPlayerRole(id, role)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
561
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
562 ### Misc. ################################################
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
563 def OnStart(self, event = None):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
564 """ Start server. """
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
565 if self.STATUS == SERVER_STOPPED:
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 27
diff changeset
566 # see if we already have name specified
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 27
diff changeset
567 try:
92
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 71
diff changeset
568 validate.config_file( "server_ini.xml", "default_server_ini.xml" )
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
569 configDoc = parse(dir_struct["user"] + 'server_ini.xml').getroot()
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
570 if configDoc.get("name"): self.serverName = configDoc.get("name")
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 27
diff changeset
571 except: pass
100
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
572 if self.serverName == '':
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
573 self.serverName = 'Server Name'
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
574 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
575 "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
576 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
577 # see if we already have password specified
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 27
diff changeset
578 try:
92
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 71
diff changeset
579 validate.config_file( "server_ini.xml", "default_server_ini.xml" )
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
580 configDoc = parse(dir_struct["user"] + 'server_ini.xml').getroot()
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
581 if configDoc.get("admin"): self.bootPwd = configDoc.get("admin")
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
582 elif configDoc.get("boot"): self.bootPwd = configDoc.get("boot")
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 27
diff changeset
583 except: pass
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 27
diff changeset
584 if self.bootPwd == '':
100
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
585 serverPasswordEntry = wx.TextEntryDialog(self,
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
586 "Please Enter The Server Admin Password:", "Server's Password",
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
587 self.bootPwd, wx.OK|wx.CANCEL|wx.CENTRE)
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 27
diff changeset
588 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
589 if len(self.serverName):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
590 wx.BeginBusyCursor()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
591 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
592 self.server.start()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
593 self.STATUS = SERVER_RUNNING
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
594 self.sb.SetStatusText("Running", 3)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
595 self.SetTitle(__appname__ + "- (running) - (unregistered)")
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
596 self.mainMenu.Enable( 1, False )
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
597 self.mainMenu.Enable( 2, True )
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
598 self.mainMenu.Enable( 4, True )
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
599 wx.EndBusyCursor()
27
a571772a45c7 Minor house cleaning in the mplay_server_gui. Getting ready to push this
sirebral
parents: 9
diff changeset
600 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
601
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
602 def OnStop(self, event = None):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
603 """ Stop server. """
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
604 if self.STATUS == SERVER_RUNNING:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
605 self.OnUnregister()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
606 self.server.stop()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
607 self.STATUS = SERVER_STOPPED
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
608 self.sb.SetStatusText("Stopped", 3)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
609 self.SetTitle(__appname__ + "- (stopped) - (unregistered)")
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
610 self.mainMenu.Enable( 1, True )
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
611 self.mainMenu.Enable( 2, False )
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
612 self.mainMenu.Enable( 4, False )
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
613 self.mainMenu.Enable( 5, False )
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
614 self.conns.DeleteAllItems()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
615
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
616 def OnRegister(self, event = None):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
617 """ 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
618 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
619 registered with configured metas
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
620 """
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
621 if len( self.serverName ):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
622 wx.BeginBusyCursor()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
623 self.server.server.register(self.serverName)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
624 self.sb.SetStatusText( ("%s" % (self.serverName)), 4 )
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
625 self.mainMenu.Enable( 4, False )
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
626 self.mainMenu.Enable( 5, True )
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
627 #self.mainMenu.Enable( 2, False )
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
628 self.SetTitle(__appname__ + "- (running) - (registered)")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
629 wx.EndBusyCursor()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
630
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
631 def OnUnregister(self, event = None):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
632 """ 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
633 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
634 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
635 from all metas
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
636 """
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
637 wx.BeginBusyCursor()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
638 self.server.server.unregister()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
639 self.sb.SetStatusText( "Unregistered", 4 )
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
640 self.mainMenu.Enable( 5, False )
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
641 self.mainMenu.Enable( 4, True )
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
642 #self.mainMenu.Enable( 2, True )
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
643 self.SetTitle(__appname__ + "- (running) - (unregistered)")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
644 wx.EndBusyCursor()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
645
100
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
646 def ModifyBanList(self, event):
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
647 if self.BanListDialog.IsShown() == True: self.BanListDialog.Hide()
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
648 else: self.BanListDialog.Show()
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
649
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
650 def PingPlayers( self, event = None ):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
651 "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
652 wx.BeginBusyCursor()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
653 wx.Yield()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
654 wx.EndBusyCursor()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
655
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
656 def StopPingPlayers( self, event = None ):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
657 "Stop pinging connected players."
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
658
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
659 def ConfigPingInterval( self, event = None ):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
660 "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
661
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
662 def OnExit(self, event):
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
663 dlg = wx.MessageDialog(self, "Exit the Server?", "OpenRPG- Server", wx.YES_NO)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
664 if dlg.ShowModal() == wx.ID_YES:
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
665 dlg.Destroy()
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
666 self.ExitConfirmed()
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
667
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 100
diff changeset
668 def ExitConfirmed(self, event=None):
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
669 """ Quit the program. """
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
670 self.OnStop()
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
671 self.BanListDialog.Destroy()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
672 wx.CallAfter(self.Destroy)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
673
100
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
674 class BanListDialog(wx.Frame):
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
675 def __init__(self, parent):
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
676 super(BanListDialog, self).__init__(parent, -1, "Ban List")
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
677 icon = wx.Icon(dir_struct["icon"]+'noplayer.gif', wx.BITMAP_TYPE_GIF)
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
678 self.SetIcon( icon )
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
679 self.BanList = wx.ListCtrl(self, wx.ID_ANY, style=wx.LC_SINGLE_SEL|wx.LC_REPORT|wx.LC_HRULES)
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
680 sizer = wx.BoxSizer(wx.VERTICAL)
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
681 sizer.Add(self.BanList, 1, wx.EXPAND)
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
682 self.BuildList()
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
683 self.SetSizer(sizer)
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
684 self.SetAutoLayout(True)
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
685 self.SetSize((300, 175))
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
686 self.Bind(wx.EVT_CLOSE, self.Min)
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
687 self.Min(None)
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
688
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
689 # Ban List Dialog Pop Up Menu, more can be added
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
690 self.menu = wx.Menu()
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
691 self.menu.SetTitle( "Modify Ban List" )
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
692 self.menu.Append( 1, "Un-Ban Player" )
100
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
693
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
694 # Even Association
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
695 self.BanList.Bind(wx.EVT_RIGHT_DOWN, self.BanPopupMenu)
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
696 self.Bind(wx.EVT_MENU, self.BanPopupMenuItem, id=1)
100
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
697
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
698 # When we right click, cause our popup menu to appear
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
699 def BanPopupMenu( self, event ):
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
700 pos = wx.Point( event.GetX(), event.GetY() )
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
701 (item, flag) = self.BanList.HitTest( pos )
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
702 if item > -1:
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
703 self.selectedItem = item
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
704 self.PopupMenu( self.menu, pos )
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
705
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
706 def BanPopupMenuItem( self, event):
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
707 menuItem = event.GetId()
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
708 player = str(self.BanList.GetItemData(self.selectedItem))
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
709 playerIP = str(self.BanList.GetItem((int(player)), 1).GetText())
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
710 if menuItem == 1:
100
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
711 server.admin_unban(playerIP)
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
712 self.BanList.DeleteItem(self.BanList.GetItemData(self.selectedItem))
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
713 self.BanList.Refresh()
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
714
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
715 def BuildList(self):
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
716 # Build Dialog Columns
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
717 self.BanList.ClearAll()
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
718 self.BanList.InsertColumn(0, "User Name")
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
719 self.BanList.InsertColumn(1, "IP")
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
720
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
721 validate.config_file("ban_list.xml", "default_ban_list.xml" )
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
722 configDom = parse(dir_struct["user"] + 'ban_list.xml').getroot()
100
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
723 ban_dict = {}
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
724 for element in configDom.findall('banned'):
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
725 player = element.get('name').replace("&", "&amp;").replace("<", "&lt;").replace('"', "&quot;").replace(">", "&gt;")
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
726 playerIP = element.get('ip')
100
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
727 ban_dict[player] = playerIP
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
728 for key in ban_dict:
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
729 i = self.BanList.InsertImageStringItem( 0, key, 0 )
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
730 self.BanList.SetStringItem(i, 1, ban_dict[key])
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
731 self.BanList.RefreshItem(i)
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
732 self.AutoAdjust()
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
733
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
734 def AutoAdjust(self):
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
735 self.BanList.SetColumnWidth(0, -1)
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
736 self.BanList.SetColumnWidth(1, -1)
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
737 self.BanList.Refresh()
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
738
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
739 def Min(self, evt):
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
740 self.BuildList()
100
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
741 self.Hide()
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
742 ###############
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
743
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
744 class ServerGUIApp(wx.App):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
745 def OnInit(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
746 # 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
747 wx.InitAllImageHandlers()
100
7ed4979cc1cf Traipse Beta 'OpenRPG' {090925-00}
sirebral
parents: 92
diff changeset
748 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
749 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
750 2000,
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
751 None)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
752 self.splash.Show(True)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
753 wx.Yield()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
754 wx.CallAfter(self.AfterSplash)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
755 return True
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
756
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
757 def AfterSplash(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
758 self.splash.Close(True)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
759 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
760 frame.Show(True)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
761 frame.Raise()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
762 self.SetTopWindow(frame)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
763
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
764 class HTMLMessageWindow(wx.html.HtmlWindow):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
765 "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
766 # Init using the derived from class
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
767 def __init__( self, parent ):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
768 wx.html.HtmlWindow.__init__( self, parent )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
769 def OnLinkClicked( self, ref ):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
770 "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
771 href = ref.GetHref()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
772 webbrowser.open( href )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
773
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
774 if __name__ == '__main__':
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
775 app = ServerGUIApp(0)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
776 app.MainLoop()