Mercurial > traipse_dev
comparison orpg/networking/gsclient.py @ 135:dcf4fbe09b70 beta
Traipse Beta 'OpenRPG' {091010-00}
Traipse is a distribution of OpenRPG that is designed to be easy to setup and go. Traipse also makes it easy for developers to work on
code without fear of sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the code. 'Ornery-Orc's main goal is to
offer more advanced features and enhance the productivity of the user.
Update Summary (Beta)
Added Bookmarks
Fix to Remote Admin Commands
Minor fix to text based Server
Fix to Pretty Print, from Core
Fix to Splitter Nodes not being created
Fix to massive amounts of images loading, from Core
Added 'boot' command to remote admin
Added confirmation window for sent nodes
Minor changes to allow for portability to an OpenSUSE linux OS
Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG
Zoom Mouse plugin added
Images added to Plugin UI
Switching to Element Tree
Map efficiency, from FlexiRPG
Added Status Bar to Update Manager
default_manifest.xml renamed to default_upmana.xml
Cleaner clode for saved repositories
New TrueDebug Class in orpg_log (See documentation for usage)
Mercurial's hgweb folder is ported to upmana
**Pretty important update that can help remove thousands of dead children from your gametree.
**Children, <forms />, <group_atts />, <horizontal />, <cols />, <rows />, <height />, etc... are all tags now. Check your gametree and
look for dead children!!
**New Gamtree Recusion method, mapping, and context sensitivity. !!Alpha - Watch out for infinite loops!!
author | sirebral |
---|---|
date | Tue, 10 Nov 2009 14:11:28 -0600 |
parents | 7ed4979cc1cf |
children | e842a5f1b775 |
comparison
equal
deleted
inserted
replaced
101:394ebb3b6a0f | 135:dcf4fbe09b70 |
---|---|
24 # $Id: gsclient.py,v 1.53 2007/10/25 21:49:34 digitalxero Exp $ | 24 # $Id: gsclient.py,v 1.53 2007/10/25 21:49:34 digitalxero Exp $ |
25 # | 25 # |
26 # Description: The file contains code for the game server browser | 26 # Description: The file contains code for the game server browser |
27 # | 27 # |
28 | 28 |
29 from __future__ import with_statement | |
29 __version__ = "$Id: gsclient.py,v 1.53 2007/10/25 21:49:34 digitalxero Exp $" | 30 __version__ = "$Id: gsclient.py,v 1.53 2007/10/25 21:49:34 digitalxero Exp $" |
31 | |
32 import meta_server_lib | |
33 #import orpg.tools.orpg_settings | |
34 import orpg.tools.rgbhex | |
35 import traceback | |
30 | 36 |
31 from orpg.dirpath import dir_struct | 37 from orpg.dirpath import dir_struct |
32 from orpg.orpg_windows import * | 38 from orpg.orpg_windows import * |
33 import meta_server_lib | 39 from orpg.tools.validate import validate |
34 import orpg.tools.orpg_settings | 40 from orpg.orpgCore import component |
35 from orpg.tools.orpg_settings import settings | 41 from orpg.tools.orpg_settings import settings |
36 import orpg.tools.rgbhex | 42 from orpg.tools.orpg_log import debug |
37 from orpg.orpgCore import component | 43 |
38 import traceback | 44 from xml.etree.ElementTree import ElementTree, Element |
45 from xml.etree.ElementTree import fromstring, tostring | |
39 | 46 |
40 gs_host = 1 | 47 gs_host = 1 |
41 gs_join = 2 | 48 gs_join = 2 |
42 # constants | 49 # constants |
43 | |
44 LIST_SERVER = wx.NewId() | |
45 LIST_ROOM = wx.NewId() | |
46 ADDRESS = wx.NewId() | |
47 GS_CONNECT = wx.NewId() | |
48 GS_DISCONNECT = wx.NewId() | |
49 GS_SERVER_REFRESH = wx.NewId() | |
50 GS_JOIN = wx.NewId() | |
51 GS_JOINLOBBY = wx.NewId() | |
52 GS_CREATE_ROOM = wx.NewId() | |
53 GS_PWD = wx.NewId() | |
54 GS_CLOSE = wx.NewId() | |
55 OR_CLOSE = wx.NewId() | |
56 | 50 |
57 class server_instance: | 51 class server_instance: |
58 def __init__(self, id, name="[Unknown]", users="0", address="127.0.0.1", port="9557"): | 52 def __init__(self, id, name="[Unknown]", users="0", address="127.0.0.1", port="9557"): |
59 self.id = id | 53 self.id = id |
60 self.name = name | 54 self.name = name |
62 self.addy = address | 56 self.addy = address |
63 self.port = port | 57 self.port = port |
64 | 58 |
65 def server_instance_compare(x,y): | 59 def server_instance_compare(x,y): |
66 """compares server insances for list sort""" | 60 """compares server insances for list sort""" |
61 ### Alpha ### makes changes from core. | |
67 DEV_SERVER = "OpenRPG DEV" | 62 DEV_SERVER = "OpenRPG DEV" |
68 xuser = 0 | 63 xname = x.name |
69 yuser = 0 | 64 xuser = int(x.user) |
70 try: xuser = int(x.user) | 65 yname = y.name |
71 except: pass | 66 yuser = int(y.user) |
72 try: yuser = int(y.user) | 67 |
73 except: pass | 68 who_name = cmp(yname, xname) |
69 who_user = cmp(yuser, xuser) | |
70 | |
74 if x.name.startswith(DEV_SERVER): | 71 if x.name.startswith(DEV_SERVER): |
75 if y.name.startswith(DEV_SERVER): | 72 if y.name.startswith(DEV_SERVER): |
76 if x.name > y.name: return 1 | 73 if not who_name: return who_user |
77 elif x.name == y.name: | 74 else: return who_name |
78 if xuser < yuser: return 1 | |
79 elif xuser > yuser: return -1 | |
80 else: return 0 | |
81 else: return -1 | |
82 else: return -1 | 75 else: return -1 |
76 | |
83 elif y.name.startswith(DEV_SERVER): return 1 | 77 elif y.name.startswith(DEV_SERVER): return 1 |
84 elif xuser < yuser: return 1 | 78 elif not who_user: return who_name |
85 elif xuser == yuser: | 79 else: return who_user |
86 if x.name > y.name: return 1 | |
87 elif x.name == y.name: return 0 | |
88 else: return -1 | |
89 else: return -1 | |
90 | 80 |
91 def roomCmp(room1, room2): | 81 def roomCmp(room1, room2): |
92 if int(room1) > int(room2): | 82 if int(room1) > int(room2): return 1 |
93 return 1 | 83 elif int(room1) < int(room2): return -1 |
94 elif int(room1) < int(room2): | |
95 return -1 | |
96 return 0 | 84 return 0 |
97 | 85 |
98 class game_server_panel(wx.Panel): | 86 class game_server_panel(wx.Panel): |
99 def __init__(self,parent): | 87 def __init__(self,parent): |
100 wx.Panel.__init__(self, parent, -1) | 88 wx.Panel.__init__(self, parent, -1) |
101 self.parent = parent | 89 self.parent = parent |
102 self.password_manager = component.get('password_manager') # passtool --SD 8/03 | 90 self.password_manager = component.get('password_manager') |
103 self.frame = component.get('frame') | 91 self.frame = component.get('frame') |
104 self.session = component.get('session') | 92 self.session = component.get('session') |
105 self.xml = component.get('xml') #Not used?? | |
106 self.serverNameSet = 0 | 93 self.serverNameSet = 0 |
107 self.last_motd = "" | 94 self.last_motd = "" |
108 self.buttons = {} | 95 self.buttons = {} |
109 self.texts = {} | 96 self.texts = {} |
110 self.svrList = [] | 97 self.svrList = [] |
111 self.build_ctrls() | 98 self.build_ctrls() |
99 self.bookmarks() | |
112 self.refresh_server_list() | 100 self.refresh_server_list() |
113 self.refresh_room_list() | 101 self.refresh_room_list() |
114 | 102 self.build_bookmark_menu() |
115 #--------------------------------------------------------- | 103 |
116 # [START] Snowdog: Updated Game Server Window 12/02 | |
117 #--------------------------------------------------------- | |
118 def build_ctrls(self): | 104 def build_ctrls(self): |
119 ## Section Sizers (with frame edges and text captions) | 105 ## Section Sizers (with frame edges and text captions) |
120 self.box_sizers = {} | 106 self.box_sizers = {} |
121 self.box_sizers["server"] = wx.StaticBox(self, -1, "Server") | 107 self.box_sizers["server"] = wx.StaticBox(self, -1, "Server") |
122 self.box_sizers["window"] = wx.StaticBox(self, -1, "Exit" ) | 108 self.box_sizers["window"] = wx.StaticBox(self, -1, "Exit" ) |
131 self.sizers["close"] = wx.StaticBoxSizer(self.box_sizers["window"], wx.HORIZONTAL) | 117 self.sizers["close"] = wx.StaticBoxSizer(self.box_sizers["window"], wx.HORIZONTAL) |
132 self.sizers["c_room"] = wx.StaticBoxSizer(self.box_sizers["c_room"], wx.VERTICAL) | 118 self.sizers["c_room"] = wx.StaticBoxSizer(self.box_sizers["c_room"], wx.VERTICAL) |
133 | 119 |
134 #Build Server Sizer | 120 #Build Server Sizer |
135 adder = wx.StaticText(self, -1, "Address:") | 121 adder = wx.StaticText(self, -1, "Address:") |
136 self.texts["address"] = wx.TextCtrl(self, ADDRESS) | 122 self.texts["address"] = wx.TextCtrl(self, wx.ID_ANY) |
137 servers = wx.StaticText(self, -1, "Servers:") | 123 servers = wx.StaticText(self, -1, "Servers:") |
138 self.server_list = wx.ListCtrl(self, LIST_SERVER, style=wx.LC_REPORT | wx.SUNKEN_BORDER ) | 124 self.server_list = wx.ListCtrl(self, wx.ID_ANY, style=wx.LC_REPORT | wx.SUNKEN_BORDER ) |
139 self.server_list.InsertColumn(0, "Players", wx.LIST_FORMAT_LEFT, 0) | 125 self.server_list.InsertColumn(0, '', wx.LIST_FORMAT_LEFT, 0) |
140 self.server_list.InsertColumn(1, "Name", wx.LIST_FORMAT_LEFT, 0) | 126 self.server_list.InsertColumn(1, "Players", wx.LIST_FORMAT_LEFT, 0) |
141 self.buttons[GS_CONNECT] = wx.Button(self, GS_CONNECT, "Connect") | 127 self.server_list.InsertColumn(2, "Name", wx.LIST_FORMAT_LEFT, 0) |
142 self.buttons[GS_SERVER_REFRESH] = wx.Button(self, GS_SERVER_REFRESH, "Refresh") | 128 self.buttons['gs_connect'] = wx.Button(self, wx.ID_ANY, "Connect") |
143 self.buttons[GS_DISCONNECT] = wx.Button(self, GS_DISCONNECT, "Disconnect") | 129 self.buttons['gs_refresh'] = wx.Button(self, wx.ID_ANY, "Refresh") |
130 self.buttons['gs_disconnect'] = wx.Button(self, wx.ID_ANY, "Disconnect") | |
144 self.sizers["svrbtns"] = wx.BoxSizer(wx.HORIZONTAL) | 131 self.sizers["svrbtns"] = wx.BoxSizer(wx.HORIZONTAL) |
145 self.sizers["svrbtns"].Add(self.buttons[GS_CONNECT], 0, wx.EXPAND) | 132 self.sizers["svrbtns"].Add(self.buttons['gs_connect'], 0, wx.EXPAND) |
146 self.sizers["svrbtns"].Add(self.buttons[GS_SERVER_REFRESH], 0, wx.EXPAND) | 133 self.sizers["svrbtns"].Add(self.buttons['gs_refresh'], 0, wx.EXPAND) |
147 self.sizers["svrbtns"].Add(self.buttons[GS_DISCONNECT], 0, wx.EXPAND) | 134 self.sizers["svrbtns"].Add(self.buttons['gs_disconnect'], 0, wx.EXPAND) |
148 self.sizers["server"].Add(adder, 0, wx.EXPAND) | 135 self.sizers["server"].Add(adder, 0, wx.EXPAND) |
149 self.sizers["server"].Add(self.texts["address"], 0, wx.EXPAND) | 136 self.sizers["server"].Add(self.texts["address"], 0, wx.EXPAND) |
150 self.sizers["server"].Add(servers, 0, wx.EXPAND) | 137 self.sizers["server"].Add(servers, 0, wx.EXPAND) |
151 self.sizers["server"].Add(self.server_list, 1, wx.EXPAND) | 138 self.sizers["server"].Add(self.server_list, 1, wx.EXPAND) |
152 self.sizers["server"].Add(self.sizers["svrbtns"], 0, wx.EXPAND) | 139 self.sizers["server"].Add(self.sizers["svrbtns"], 0, wx.EXPAND) |
153 | 140 |
154 #Build Rooms Sizer | 141 #Build Rooms Sizer |
155 self.room_list = wx.ListCtrl(self, LIST_ROOM, style=wx.LC_REPORT | wx.SUNKEN_BORDER) | 142 self.room_list = wx.ListCtrl(self, wx.ID_ANY, style=wx.LC_REPORT | wx.SUNKEN_BORDER) |
156 self.room_list.InsertColumn(0,"Game", wx.LIST_FORMAT_LEFT,-1) | 143 self.room_list.InsertColumn(0,"Game", wx.LIST_FORMAT_LEFT,-1) |
157 self.room_list.InsertColumn(1,"Players", wx.LIST_FORMAT_LEFT,-1) | 144 self.room_list.InsertColumn(1,"Players", wx.LIST_FORMAT_LEFT,-1) |
158 self.room_list.InsertColumn(2,"PW", wx.LIST_FORMAT_LEFT,-1) | 145 self.room_list.InsertColumn(2,"PW", wx.LIST_FORMAT_LEFT,-1) |
159 self.buttons[GS_JOIN] = wx.Button(self, GS_JOIN, "Join Room") | 146 self.buttons['gs_join_room'] = wx.Button(self, wx.ID_ANY, "Join Room") |
160 self.buttons[GS_JOINLOBBY] = wx.Button(self, GS_JOINLOBBY, "Lobby") | 147 self.buttons['gs_join_lobby'] = wx.Button(self, wx.ID_ANY, "Lobby") |
161 self.sizers["roombtns"] = wx.BoxSizer(wx.HORIZONTAL) | 148 self.sizers["roombtns"] = wx.BoxSizer(wx.HORIZONTAL) |
162 self.sizers["roombtns"].Add(self.buttons[GS_JOIN], 0, wx.EXPAND) | 149 self.sizers["roombtns"].Add(self.buttons['gs_join_room'], 0, wx.EXPAND) |
163 self.sizers["roombtns"].Add(self.buttons[GS_JOINLOBBY], 0, wx.EXPAND) | 150 self.sizers["roombtns"].Add(self.buttons['gs_join_lobby'], 0, wx.EXPAND) |
164 self.sizers["rooms"].Add(self.room_list, 1, wx.EXPAND) | 151 self.sizers["rooms"].Add(self.room_list, 1, wx.EXPAND) |
165 self.sizers["rooms"].Add(self.sizers["roombtns"], 0, wx.EXPAND) | 152 self.sizers["rooms"].Add(self.sizers["roombtns"], 0, wx.EXPAND) |
166 | 153 |
167 #Build Close Sizer | 154 #Build Close Sizer |
168 self.buttons[OR_CLOSE] = wx.Button(self, OR_CLOSE,"Exit OpenRPG") | 155 self.buttons['close_orpg'] = wx.Button(self, wx.ID_ANY,"Exit OpenRPG") |
169 self.buttons[GS_CLOSE] = wx.Button(self, GS_CLOSE,"Close Window") | 156 self.buttons['gs_close'] = wx.Button(self, wx.ID_ANY,"Close Window") |
170 self.sizers["close"].Add(self.buttons[OR_CLOSE], 1, wx.ALIGN_CENTER_VERTICAL) | 157 self.sizers["close"].Add(self.buttons['close_orpg'], 1, wx.ALIGN_CENTER_VERTICAL) |
171 self.sizers["close"].Add(self.buttons[GS_CLOSE], 1, wx.ALIGN_CENTER_VERTICAL) | 158 self.sizers["close"].Add(self.buttons['gs_close'], 1, wx.ALIGN_CENTER_VERTICAL) |
172 | 159 |
173 #Build Create Room Sizer | 160 #Build Create Room Sizer |
174 rname = wx.StaticText(self,-1, "Room Name:") | 161 rname = wx.StaticText(self,-1, "Room Name:") |
175 self.texts["room_name"] = wx.TextCtrl(self, -1) | 162 self.texts["room_name"] = wx.TextCtrl(self, -1) |
176 rpass = wx.StaticText(self,-1, "Password:") | 163 rpass = wx.StaticText(self,-1, "Password:") |
177 self.buttons[GS_PWD] = wx.CheckBox(self, GS_PWD, "") | 164 self.buttons['gs_pwd'] = wx.CheckBox(self, wx.ID_ANY, "") |
178 self.texts["room_pwd"] = wx.TextCtrl(self, -1) | 165 self.texts["room_pwd"] = wx.TextCtrl(self, -1) |
179 self.texts["room_pwd"].Enable(0) | 166 self.texts["room_pwd"].Enable(0) |
180 pwsizer = wx.BoxSizer(wx.HORIZONTAL) | 167 pwsizer = wx.BoxSizer(wx.HORIZONTAL) |
181 pwsizer.Add(self.buttons[GS_PWD],0,0) | 168 pwsizer.Add(self.buttons['gs_pwd'],0,0) |
182 pwsizer.Add(self.texts["room_pwd"], 1, wx.EXPAND) | 169 pwsizer.Add(self.texts["room_pwd"], 1, wx.EXPAND) |
183 apass = wx.StaticText(self,-1, "Admin Password:") | 170 apass = wx.StaticText(self,-1, "Admin Password:") |
184 self.texts["room_boot_pwd"] = wx.TextCtrl(self, -1) | 171 self.texts["room_boot_pwd"] = wx.TextCtrl(self, -1) |
185 minver = wx.StaticText(self,-1, "Minimum Version:") | 172 minver = wx.StaticText(self,-1, "Minimum Version:") |
186 self.texts["room_min_version"] = wx.TextCtrl(self, -1) | 173 self.texts["room_min_version"] = wx.TextCtrl(self, -1) |
192 self.sizers["c_room_layout"].Add(apass, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.ALL) | 179 self.sizers["c_room_layout"].Add(apass, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.ALL) |
193 self.sizers["c_room_layout"].Add(self.texts["room_boot_pwd"], 0, wx.EXPAND) | 180 self.sizers["c_room_layout"].Add(self.texts["room_boot_pwd"], 0, wx.EXPAND) |
194 self.sizers["c_room_layout"].Add(minver, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.ALL) | 181 self.sizers["c_room_layout"].Add(minver, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.ALL) |
195 self.sizers["c_room_layout"].Add(self.texts["room_min_version"], 0, wx.EXPAND) | 182 self.sizers["c_room_layout"].Add(self.texts["room_min_version"], 0, wx.EXPAND) |
196 self.sizers["c_room_layout"].AddGrowableCol(1) | 183 self.sizers["c_room_layout"].AddGrowableCol(1) |
197 self.buttons[GS_CREATE_ROOM] = wx.Button(self, GS_CREATE_ROOM, "Create Room") | 184 self.buttons['gs_create_room'] = wx.Button(self, wx.ID_ANY, "Create Room") |
198 self.sizers["c_room"].Add(self.sizers["c_room_layout"], 1, wx.EXPAND) | 185 self.sizers["c_room"].Add(self.sizers["c_room_layout"], 1, wx.EXPAND) |
199 self.sizers["c_room"].Add(self.buttons[GS_CREATE_ROOM], 0, wx.EXPAND) | 186 self.sizers["c_room"].Add(self.buttons['gs_create_room'], 0, wx.EXPAND) |
200 | 187 |
201 #Build Main Sizer | 188 #Build Main Sizer |
202 self.sizers["main"].Add(self.sizers["server"], (0,0), span=(2,1), flag=wx.EXPAND) | 189 self.sizers["main"].Add(self.sizers["server"], (0,0), span=(2,1), flag=wx.EXPAND) |
203 self.sizers["main"].Add(self.sizers["rooms"], (0,1), flag=wx.EXPAND) | 190 self.sizers["main"].Add(self.sizers["rooms"], (0,1), flag=wx.EXPAND) |
204 self.sizers["main"].Add(self.sizers["close"], (2,0), flag=wx.EXPAND) | 191 self.sizers["main"].Add(self.sizers["close"], (2,0), flag=wx.EXPAND) |
209 self.SetSizer(self.sizers["main"]) | 196 self.SetSizer(self.sizers["main"]) |
210 self.SetAutoLayout(True) | 197 self.SetAutoLayout(True) |
211 self.Fit() | 198 self.Fit() |
212 | 199 |
213 ## Event Handlers | 200 ## Event Handlers |
214 self.Bind(wx.EVT_BUTTON, self.on_button, id=GS_CONNECT) | 201 self.Bind(wx.EVT_BUTTON, self.gs_connect, self.buttons['gs_connect']) |
215 self.Bind(wx.EVT_BUTTON, self.on_button, id=GS_DISCONNECT) | 202 self.Bind(wx.EVT_BUTTON, self.gs_disconnect, self.buttons['gs_disconnect']) |
216 self.Bind(wx.EVT_BUTTON, self.on_button, id=GS_CREATE_ROOM) | 203 self.Bind(wx.EVT_BUTTON, self.gs_create_room, self.buttons['gs_create_room']) |
217 self.Bind(wx.EVT_BUTTON, self.on_button, id=GS_JOIN) | 204 self.Bind(wx.EVT_BUTTON, self.gs_join, self.buttons['gs_join_room']) |
218 self.Bind(wx.EVT_BUTTON, self.on_button, id=GS_JOINLOBBY) | 205 self.Bind(wx.EVT_BUTTON, self.gs_join_lobby, self.buttons['gs_join_lobby']) |
219 self.Bind(wx.EVT_BUTTON, self.on_button, id=GS_SERVER_REFRESH) | 206 self.Bind(wx.EVT_BUTTON, self.gs_server_refresh, self.buttons['gs_refresh']) |
220 self.Bind(wx.EVT_BUTTON, self.on_button, id=GS_CLOSE) | 207 self.Bind(wx.EVT_BUTTON, self.gs_close, self.buttons['gs_close']) |
221 self.Bind(wx.EVT_BUTTON, self.on_button, id=OR_CLOSE) | 208 self.Bind(wx.EVT_BUTTON, self.close_orpg, self.buttons['close_orpg']) |
222 self.Bind(wx.EVT_CHECKBOX, self.on_button, id=GS_PWD) | 209 self.Bind(wx.EVT_CHECKBOX, self.gs_pwd, self.buttons['gs_pwd']) |
223 | 210 |
224 # Added double click handlers 5/05 -- Snowdog | 211 # Added double click handlers 5/05 -- Snowdog |
225 self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.on_server_dbclick, id=LIST_SERVER) | 212 self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.on_server_dbclick, self.server_list) |
226 self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.on_room_dbclick, id=LIST_ROOM) | 213 self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.on_room_dbclick, self.room_list) |
227 self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.on_select, id=LIST_ROOM) | 214 self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.on_room_select, self.room_list) |
228 self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.on_select, id=LIST_SERVER) | 215 self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.on_server_select, self.server_list) |
229 self.texts['address'].Bind(wx.EVT_SET_FOCUS, self.on_text) | 216 self.texts['address'].Bind(wx.EVT_SET_FOCUS, self.on_text) |
230 self.set_connected(self.session.is_connected()) | 217 self.set_connected(self.session.is_connected()) |
231 self.cur_room_index = -1 | 218 self.cur_room_index = -1 |
232 self.cur_server_index = -1 | 219 self.cur_server_index = -1 |
233 self.rmList = {} | 220 self.rmList = {} |
234 | 221 |
235 #--------------------------------------------------------- | 222 # Create Book Mark Image List |
236 # [END] Snowdog: Updated Game Server Window 12/02 | 223 self.server_list.Bind(wx.EVT_LEFT_DOWN, self.on_hit) |
237 #--------------------------------------------------------- | 224 self._imageList = wx.ImageList( 16, 16, False ) |
238 | 225 img = wx.Image(dir_struct["icon"]+"add.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap() |
239 #----------------------------------------------------- | 226 self._imageList.Add( img ) |
240 # on_server_dbclick() | 227 img = wx.Image(dir_struct["icon"]+"star.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap() |
241 # support for double click selection of server. | 228 self._imageList.Add( img ) |
242 # 5/16/05 -- Snowdog | 229 self.server_list.SetImageList( self._imageList, wx.IMAGE_LIST_SMALL ) |
243 #----------------------------------------------------- | 230 |
231 def bookmarks(self): | |
232 validate.config_file('server_bookmarks.xml', | |
233 'default_server_bookmarks.xml') | |
234 self.bookmarks = ElementTree() | |
235 self.bookmarks.parse(dir_struct['user'] + 'server_bookmarks.xml') | |
236 | |
237 def build_bookmark_menu(self): | |
238 gsm = self.frame.mainmenu.GetMenu( | |
239 self.frame.mainmenu.FindMenu('Game Server')) | |
240 self.bookmarks_menu = wx.Menu() | |
241 x = 0 | |
242 for server in self.bookmarks.findall('server'): | |
243 for svr in self.svrList: | |
244 address = svr.addy | |
245 if server.get('address') == address: self.server_list.SetItemImage(x, 1) | |
246 x += 1 | |
247 item = wx.MenuItem(self.bookmarks_menu, wx.ID_ANY, | |
248 server.get('name'), server.get('name')) | |
249 open_rpg.get_component('frame').Bind(wx.EVT_MENU, | |
250 self.on_bookmarks_menu, item) | |
251 self.bookmarks_menu.AppendItem(item) | |
252 gsm.AppendSubMenu(self.bookmarks_menu, "Bookmarks") | |
253 | |
254 def on_bookmarks_menu(self, evt): | |
255 id = evt.GetId() | |
256 menu = self.bookmarks_menu.FindItemById(id) | |
257 for server in self.bookmarks.findall('server'): | |
258 if server.get('name') == menu.GetLabel(): | |
259 address = server.get('address') | |
260 self.cur_server_index = 999 | |
261 self.name = server.get('name') | |
262 if self.session.is_connected(): | |
263 if self.session.host_server == address : return | |
264 else: self.frame.kill_mplay_session() | |
265 self.do_connect(address) | |
266 break | |
267 | |
268 def bookmark(self, item, flag): | |
269 name = self.svrList[item].name | |
270 address = self.svrList[item].addy | |
271 port = self.svrList[item].port | |
272 self.server_list.SetItemImage(item, 1) | |
273 | |
274 for server in self.bookmarks.findall('server'): | |
275 if server.get('name') == name: | |
276 self.bookmarks_menu.Remove( | |
277 self.bookmarks_menu.FindItem(server.get('name'))) | |
278 self.bookmarks.getroot().remove(server) | |
279 self.server_list.SetItemImage(item, 0) | |
280 break | |
281 else: | |
282 server = Element('server') | |
283 server.set('name', name) | |
284 server.set('address', address + ':' + port) | |
285 self.bookmarks.getroot().append(server) | |
286 item = wx.MenuItem(self.bookmarks_menu, wx.ID_ANY, name, name) | |
287 open_rpg.get_component('frame').Bind(wx.EVT_MENU, | |
288 self.on_bookmarks_menu, item) | |
289 self.bookmarks_menu.AppendItem(item) | |
290 self.save_bookmarks() | |
291 | |
292 def save_bookmarks(self): | |
293 with open(dir_struct['user'] + 'server_bookmarks.xml', 'w') as f: | |
294 self.bookmarks.write(f) | |
295 | |
244 def on_server_dbclick(self, evt=None): | 296 def on_server_dbclick(self, evt=None): |
245 #make sure address is updated just in case list select wasn't done | 297 #make sure address is updated just in case list select wasn't done |
246 try: | 298 try: self.on_select(evt) |
247 self.on_select(evt) | 299 except: pass |
248 except: | |
249 pass | |
250 address = self.texts["address"].GetValue() | 300 address = self.texts["address"].GetValue() |
251 if self.session.is_connected(): | 301 if self.session.is_connected(): |
252 if self.session.host_server == address : | 302 if self.session.host_server == address : |
253 #currently connected to address. Do nothing. | 303 #currently connected to address. Do nothing. |
254 return | 304 return |
255 else: | 305 else: |
256 #address differs, disconnect. | 306 #address differs, disconnect. |
257 self.frame.kill_mplay_session() | 307 self.frame.kill_mplay_session() |
258 self.do_connect(address) | 308 self.do_connect(address) |
259 | 309 |
260 | |
261 #----------------------------------------------------- | |
262 # on_room_dbclick() | |
263 # support for double click selection of server. | |
264 # 5/16/05 -- Snowdog | |
265 #----------------------------------------------------- | |
266 | |
267 def on_room_dbclick(self, evt=None): | 310 def on_room_dbclick(self, evt=None): |
268 #make sure address is updated just in case list select wasn't done | 311 #make sure address is updated just in case list select wasn't done |
269 try: | 312 try: self.on_select(evt) |
270 self.on_select(evt) | 313 except: pass |
271 except: | |
272 pass | |
273 group_id = str(self.room_list.GetItemData(self.cur_room_index)) | 314 group_id = str(self.room_list.GetItemData(self.cur_room_index)) |
274 | 315 |
275 if self.NoGroups: | 316 if self.NoGroups: |
276 self.NoGroups = False | 317 self.NoGroups = False |
277 self.session.group_id = group_id | 318 self.session.group_id = group_id |
278 self.on_server_dbclick() | 319 self.on_server_dbclick() |
279 return | 320 return |
280 | 321 |
281 if self.cur_room_index >= 0: | 322 if self.cur_room_index >= 0: |
282 if self.cur_room_index != 0: | 323 if self.cur_room_index != 0: self.set_lobbybutton(1); |
283 self.set_lobbybutton(1); | 324 else: self.set_lobbybutton(0); |
284 else: | |
285 self.set_lobbybutton(0); | |
286 group = self.session.get_group_info(group_id) | 325 group = self.session.get_group_info(group_id) |
287 pwd = "" | 326 pwd = "" |
288 if (group[2] == "True") or (group[2] == "1"): | 327 if (group[2] == "True") or (group[2] == "1"): |
289 pwd = self.password_manager.GetPassword("room", group_id) | 328 pwd = self.password_manager.GetPassword("room", group_id) |
290 else: | 329 else: pwd = "" |
291 pwd = "" | |
292 self.session.send_join_group(group_id, pwd) | 330 self.session.send_join_group(group_id, pwd) |
293 | 331 |
294 | 332 def on_room_select(self,evt): |
295 def on_select(self,evt): | 333 self.cur_room_index = evt.m_itemIndex |
334 | |
335 def on_hit(self, evt): | |
336 pos = wx.Point( evt.GetX(), evt.GetY() ) | |
337 (item, flag) = self.server_list.HitTest( pos ) | |
338 ## Item == list[server], flag == (32 = 0 colum, 128 = else) ## | |
339 if flag == 32: self.bookmark(item, flag) | |
340 evt.Skip() | |
341 | |
342 def on_server_select(self,evt): | |
343 self.cur_server_index = evt.m_itemIndex | |
344 self.name = self.svrList[self.cur_server_index].name | |
345 address = self.svrList[self.cur_server_index].addy | |
346 port = self.svrList[self.cur_server_index].port | |
347 self.texts["address"].SetValue(address + ":" + str(port)) | |
348 self.refresh_room_list() | |
349 | |
350 def on_text(self, evt): | |
296 id = evt.GetId() | 351 id = evt.GetId() |
297 if id == LIST_ROOM: | 352 if (id == self.texts["address"].GetValue()) and (self.cur_server_index >= 0): |
298 self.cur_room_index = evt.m_itemIndex | |
299 elif id==LIST_SERVER: | |
300 self.cur_server_index = evt.m_itemIndex | |
301 self.name = self.svrList[self.cur_server_index].name | |
302 address = self.svrList[self.cur_server_index].addy | |
303 port = self.svrList[self.cur_server_index].port | |
304 self.texts["address"].SetValue(address+":"+str(port)) | |
305 self.refresh_room_list() | |
306 | |
307 def on_text(self,evt): | |
308 id = evt.GetId() | |
309 if (id == ADDRESS) and (self.cur_server_index >= 0): | |
310 #print "ADDRESS id = ", id, "index = ", self.cur_server_index | 353 #print "ADDRESS id = ", id, "index = ", self.cur_server_index |
311 self.cur_server_index = -1 | 354 self.cur_server_index = -1 |
312 evt.Skip() | 355 evt.Skip() |
313 | 356 |
314 def add_room(self,data): | 357 def add_room(self, data): |
358 #debug() | |
315 i = self.room_list.GetItemCount() | 359 i = self.room_list.GetItemCount() |
316 if (data[2]=="1") or (data[2]=="True"): pwd="yes" | 360 if (data[2]=="1") or (data[2]=="True"): pwd="yes" |
317 else: pwd="no" | 361 else: pwd="no" |
318 self.room_list.InsertStringItem(i,data[1]) | 362 self.room_list.InsertStringItem(i,data[1]) |
319 self.room_list.SetStringItem(i,1,data[3]) | 363 self.room_list.SetStringItem(i,1,data[3]) |
320 self.room_list.SetStringItem(i,2,pwd) | 364 self.room_list.SetStringItem(i,2,pwd) |
321 self.room_list.SetItemData(i,int(data[0])) | 365 self.room_list.SetItemData(i,int(data[0])) |
322 self.refresh_room_list() | 366 self.refresh_room_list() |
323 | 367 |
324 def del_room(self, data): | 368 def del_room(self, data): |
369 #debug(data) | |
325 i = self.room_list.FindItemData(-1, int(data[0])) | 370 i = self.room_list.FindItemData(-1, int(data[0])) |
326 self.room_list.DeleteItem(i) | 371 self.room_list.DeleteItem(i) |
327 self.refresh_room_list() | 372 self.refresh_room_list() |
328 | 373 |
329 #--------------------------------------------------------- | 374 def update_room(self, data): |
330 # [START] Snowdog Password/Room Name altering code 12/02 | |
331 #--------------------------------------------------------- | |
332 | |
333 def update_room(self,data): | |
334 | |
335 #------------------------------------------------------- | |
336 # Udated 12/02 by Snowdog | |
337 # allows refresh of all room data not just player counts | |
338 #------------------------------------------------------- | |
339 i = self.room_list.FindItemData(-1,int(data[0])) | 375 i = self.room_list.FindItemData(-1,int(data[0])) |
340 if data[2]=="1" : pwd="yes" | 376 if data[2]=="1" : pwd="yes" |
341 else: pwd="no" | 377 else: pwd="no" |
342 self.room_list.SetStringItem(i,0,data[1]) | 378 self.room_list.SetStringItem(i,0,data[1]) |
343 self.room_list.SetStringItem(i,1,data[3]) | 379 self.room_list.SetStringItem(i,1,data[3]) |
344 self.room_list.SetStringItem(i,2,pwd) | 380 self.room_list.SetStringItem(i,2,pwd) |
345 self.refresh_room_list() | 381 self.refresh_room_list() |
346 | 382 |
347 #--------------------------------------------------------- | 383 def set_cur_room_text(self, name): |
348 # [END] Snowdog Password/Room Name altering code 12/02 | |
349 #--------------------------------------------------------- | |
350 | |
351 def set_cur_room_text(self,name): | |
352 pass | 384 pass |
353 #self.texts["cur_room"].SetLabel(name) | 385 #self.texts["cur_room"].SetLabel(name) |
354 #self.sizers["room"].Layout() | 386 #self.sizers["room"].Layout() |
355 | 387 |
356 def set_lobbybutton(self,allow): | 388 def set_lobbybutton(self, allow): |
357 self.buttons[GS_JOINLOBBY].Enable(allow) | 389 self.buttons['gs_join_lobby'].Enable(allow) |
358 | 390 |
359 def set_connected(self,connected): | 391 def set_connected(self, connected): |
360 self.buttons[GS_CONNECT].Enable(not connected) | 392 self.buttons['gs_connect'].Enable(not connected) |
361 self.buttons[GS_DISCONNECT].Enable(connected) | 393 self.buttons['gs_disconnect'].Enable(connected) |
362 self.buttons[GS_JOIN].Enable(connected) | 394 self.buttons['gs_join_room'].Enable(connected) |
363 self.buttons[GS_CREATE_ROOM].Enable(connected) | 395 self.buttons['gs_create_room'].Enable(connected) |
364 if not connected: | 396 if not connected: |
365 self.buttons[GS_JOINLOBBY].Enable(connected) | 397 self.buttons['gs_join_lobby'].Enable(connected) |
366 self.room_list.DeleteAllItems() | 398 self.room_list.DeleteAllItems() |
367 self.set_cur_room_text("Not Connected!") | 399 self.set_cur_room_text("Not Connected!") |
368 self.cur_room_index = -1 | 400 self.cur_room_index = -1 |
369 self.frame.status.set_connect_status("Not Connected") | 401 self.frame.status.set_connect_status("Not Connected") |
370 else: | 402 else: |
371 #data = self.session.get_my_group() | 403 #data = self.session.get_my_group() |
372 self.frame.status.set_connect_status(self.name) | 404 self.frame.status.set_connect_status(self.name) |
373 self.set_cur_room_text("Lobby") | 405 self.set_cur_room_text("Lobby") |
374 | 406 |
375 def on_button(self,evt): | 407 def gs_connect(self, evt): |
376 id = evt.GetId() | 408 address = self.texts['address'].GetValue() |
377 if id == GS_CONNECT: | 409 try: dummy = self.name |
378 address = self.texts["address"].GetValue() | 410 except: self.name = `address` |
379 ### check to see if this is a manual entry vs. list entry. | 411 self.do_connect(address) |
380 try: | 412 |
381 dummy = self.name | 413 def gs_disconnect(self, evt): |
382 except: | 414 self.frame.kill_mplay_session() |
383 self.name = `address` | 415 |
384 self.do_connect(address) | 416 def gs_create_room(self, evt): |
385 elif id == GS_DISCONNECT: self.frame.kill_mplay_session() | 417 self.do_create_group() |
386 elif id == GS_CREATE_ROOM: self.do_create_group() | 418 |
387 elif id == GS_JOIN: self.do_join_group() | 419 def gs_join(self, evt): |
388 elif id == GS_JOINLOBBY: self.do_join_lobby() | 420 self.do_join_group() |
389 elif id == GS_SERVER_REFRESH: self.refresh_server_list() | 421 |
390 elif id == GS_PWD: self.texts["room_pwd"].Enable(evt.Checked()) | 422 def gs_join_lobby(self, evt): |
391 elif id == OR_CLOSE: | 423 self.do_join_lobby() |
392 dlg = wx.MessageDialog(self,"Quit OpenRPG?","OpenRPG",wx.YES_NO) | 424 |
393 if dlg.ShowModal() == wx.ID_YES: | 425 def gs_server_refresh(self, evt): |
394 dlg.Destroy() | 426 self.refresh_server_list() |
395 self.frame.kill_mplay_session() | 427 |
396 self.frame.closed_confirmed() | 428 def gs_pwd(self, evt): |
397 elif id == GS_CLOSE: | 429 self.texts['room_pwd'].Enable(evt.Checked()) |
398 self.parent.OnMB_GameServerBrowseServers() | 430 |
399 | 431 def close_orpg(self, evt): |
432 dlg = wx.MessageDialog(self, 'Quit OpenRPG?', "OpenRPG", wx.YES_NO) | |
433 if dlg.ShowModal() == wx.ID_YES: | |
434 dlg.Destroy() | |
435 self.frame.kill_mplay_session() | |
436 self.frame.closed_confirmed() | |
437 | |
438 def gs_close(self, evt): | |
439 self.parent.OnMB_GameServerBrowseServers() | |
440 | |
400 def refresh_room_list(self): | 441 def refresh_room_list(self): |
401 self.room_list.DeleteAllItems() | 442 self.room_list.DeleteAllItems() |
402 address = self.texts["address"].GetValue() | 443 address = self.texts["address"].GetValue() |
403 try: | 444 try: cadder = self.session.host_server |
404 cadder = self.session.host_server | 445 except: cadder = '' |
405 except: | |
406 cadder = '' | |
407 if self.rmList.has_key(address) and len(self.rmList[address]) > 0 and cadder != address: | 446 if self.rmList.has_key(address) and len(self.rmList[address]) > 0 and cadder != address: |
408 groups = self.rmList[address] | 447 groups = self.rmList[address] |
409 self.NoGroups = True | 448 self.NoGroups = True |
410 else: | 449 else: |
411 self.NoGroups = False | 450 self.NoGroups = False |
431 | 470 |
432 def refresh_server_list(self): | 471 def refresh_server_list(self): |
433 try: | 472 try: |
434 self.svrList = [] | 473 self.svrList = [] |
435 self.server_list.DeleteAllItems() | 474 self.server_list.DeleteAllItems() |
436 xml_dom = meta_server_lib.get_server_list(["2"]); | 475 etreeEl = meta_server_lib.get_server_list(["2"]); |
437 node_list = xml_dom.getElementsByTagName('server') | 476 node_list = etreeEl.findall('server') |
438 hex = orpg.tools.rgbhex.RGBHex() | 477 hex = orpg.tools.rgbhex.RGBHex() |
439 color1 = settings.get_setting("RoomColor_Active") | 478 color1 = settings.get("RoomColor_Active") |
440 color2 = settings.get_setting("RoomColor_Locked") | 479 color2 = settings.get("RoomColor_Locked") |
441 color3 = settings.get_setting("RoomColor_Empty") | 480 color3 = settings.get("RoomColor_Empty") |
442 color4 = settings.get_setting("RoomColor_Lobby") | 481 color4 = settings.get("RoomColor_Lobby") |
443 | 482 |
444 if len(node_list): | 483 if len(node_list): |
445 length = len(node_list) | 484 length = len(node_list) |
446 part = 0 | 485 part = 0 |
447 partLength = 1.0/length | 486 partLength = 1.0/length |
448 for n in node_list: | 487 for n in node_list: |
449 if n.hasAttribute('id') and n.hasAttribute('name') and n.hasAttribute('num_users') and n.hasAttribute('address') and n.hasAttribute('port'): | 488 #if n.get('id') and n.get('name') and n.get('num_users') and n.get('address') and n.get('port'): |
450 self.svrList.append(server_instance(n.getAttribute('id'), n.getAttribute('name'), | 489 self.svrList.append(server_instance(n.get('id'), n.get('name'), |
451 n.getAttribute('num_users'), n.getAttribute('address'), | 490 n.get('num_users'), n.get('address'), |
452 n.getAttribute('port'))) | 491 n.get('port'))) |
453 address = n.getAttribute('address') + ':' + n.getAttribute('port') | 492 address = n.get('address') + ':' + n.get('port') |
454 self.rmList[address] = [] | 493 self.rmList[address] = [] |
455 rooms = n.getElementsByTagName('room') | 494 rooms = n.findall('room') |
456 | 495 |
457 for room in rooms: | 496 for room in rooms: |
458 pwd = room.getAttribute("pwd") | 497 self.rmList[address].append((room.get("id"), room.get("name"), |
459 id = room.getAttribute("id") | 498 room.get("pwd"), room.get("num_users"))) |
460 name = room.getAttribute("name") | |
461 nump = room.getAttribute("num_users") | |
462 self.rmList[address].append((id, name, pwd, nump)) | |
463 self.svrList.sort(server_instance_compare) | 499 self.svrList.sort(server_instance_compare) |
464 | 500 |
465 for n in self.svrList: | 501 for n in self.svrList: |
466 i = self.server_list.GetItemCount() | 502 i = self.server_list.GetItemCount() |
467 name = n.name | 503 name = n.name |
468 players = n.user | 504 players = n.user |
469 self.server_list.InsertStringItem(i,players) | 505 self.server_list.InsertImageStringItem(i, '', 0) |
470 self.server_list.SetStringItem(i,1,name) | 506 for server in self.bookmarks.findall('server'): |
507 if server.get('name') == name: self.server_list.SetItemImage(i, 1) | |
508 self.server_list.SetStringItem(i,1,players) | |
509 self.server_list.SetStringItem(i,2,name) | |
471 r,g,b = hex.rgb_tuple(color1) | 510 r,g,b = hex.rgb_tuple(color1) |
472 svrcolor = wx.Colour(red=r,green=g,blue=b) | 511 svrcolor = wx.Colour(red=r,green=g,blue=b) |
473 | 512 |
474 if players == "0": | 513 if players == "0": |
475 r,g,b = hex.rgb_tuple(color3) | 514 r,g,b = hex.rgb_tuple(color3) |
486 self.servers = node_list | 525 self.servers = node_list |
487 | 526 |
488 # No server is currently selected!!! Versus the broken and random 0! | 527 # No server is currently selected!!! Versus the broken and random 0! |
489 self.cur_server_index = -1 | 528 self.cur_server_index = -1 |
490 self.server_list.SetColumnWidth(0, wx.LIST_AUTOSIZE) | 529 self.server_list.SetColumnWidth(0, wx.LIST_AUTOSIZE) |
491 if self.server_list.GetColumnWidth(0) < 70: self.server_list.SetColumnWidth(0, 70) | |
492 self.server_list.SetColumnWidth(1, wx.LIST_AUTOSIZE) | 530 self.server_list.SetColumnWidth(1, wx.LIST_AUTOSIZE) |
531 if self.server_list.GetColumnWidth(1) < 70: self.server_list.SetColumnWidth(1, 70) | |
532 self.server_list.SetColumnWidth(2, wx.LIST_AUTOSIZE) | |
493 | 533 |
494 if self.serverNameSet == 0: | 534 if self.serverNameSet == 0: |
495 # Pointless to constantly set the address field to random | |
496 # server. This way, at least, if someone has their own local | |
497 # server it can now easily be connected with. Nor do we want | |
498 # to reset this every time as it would wipe any previously | |
499 # entered data or even the previously selected server data! | |
500 # Localhost should probably be used but some systems are ultra/lame | |
501 # broken about localhost use. | |
502 self.texts["address"].SetValue("127.0.0.1:6774") | 535 self.texts["address"].SetValue("127.0.0.1:6774") |
503 self.serverNameSet = 1 | 536 self.serverNameSet = 1 |
504 else: | 537 else: pass |
505 pass | |
506 | |
507 # Allow xml_dom to be collected | 538 # Allow xml_dom to be collected |
508 try: | |
509 xml_dom.unlink() | |
510 except: | |
511 pass | |
512 except Exception, e: | 539 except Exception, e: |
513 print "Server List not available." | 540 print "Server List not available." |
514 traceback.print_exc() | 541 traceback.print_exc() |
515 | 542 |
543 | |
516 def failed_connection(self): | 544 def failed_connection(self): |
517 if(self.cur_server_index >= 0): | 545 if(self.cur_server_index >= 0): |
518 id = self.servers[self.cur_server_index].getAttribute('id') | 546 server_index = self.servers[self.cur_server_index] |
519 meta = self.servers[self.cur_server_index].getAttribute('meta') | |
520 address = self.servers[self.cur_server_index].getAttribute('address') | |
521 port = self.servers[self.cur_server_index].getAttribute('port') | |
522 # post_failed_connection will return a non-zero if the server | 547 # post_failed_connection will return a non-zero if the server |
523 # was removed. If it was, refresh the display | 548 # was removed. If it was, refresh the display |
524 if(meta_server_lib.post_failed_connection(id,meta=meta,address=address,port=port)): | 549 if(meta_server_lib.post_failed_connection(server_index.get('id'), |
550 meta=server_index.get('meta'), address=server_index.get('address'), | |
551 port=server_index.get('port'))): | |
525 self.refresh_server_list() | 552 self.refresh_server_list() |
526 | 553 |
527 def do_connect(self, address): | 554 def do_connect(self, address): |
528 chat = component.get('chat') | 555 chat = component.get('chat') |
529 chat.InfoPost("Locating server at " + address + "...") | 556 chat.InfoPost("Locating server at " + address + "...") |
530 if self.session.connect(address): | 557 if self.session.connect(address): self.frame.start_timer() |
531 self.frame.start_timer() | |
532 else: | 558 else: |
533 chat.SystemPost("Failed to connect to game server...") | 559 chat.SystemPost("Failed to connect to game server...") |
534 self.failed_connection() | 560 self.failed_connection() |
535 | 561 |
536 def do_join_lobby(self): | 562 def do_join_lobby(self): |
537 self.cur_room_index = 0 | 563 self.cur_room_index = 0 |
538 self.session.send_join_group("0","") | 564 self.session.send_join_group("0", "") |
539 self.set_lobbybutton(0); | 565 self.set_lobbybutton(0); |
540 | 566 |
541 def do_join_group(self): | 567 def do_join_group(self): |
542 if self.cur_room_index >= 0: | 568 if self.cur_room_index >= 0: |
543 if self.cur_room_index != 0: | 569 if self.cur_room_index != 0: self.set_lobbybutton(1); |
544 self.set_lobbybutton(1); | 570 else: self.set_lobbybutton(0); |
545 else: | |
546 self.set_lobbybutton(0); | |
547 group_id = str(self.room_list.GetItemData(self.cur_room_index)) | 571 group_id = str(self.room_list.GetItemData(self.cur_room_index)) |
548 group = self.session.get_group_info(group_id) | 572 group = self.session.get_group_info(group_id) |
549 pwd = "" | 573 pwd = "" |
550 if (group[2] == "True") or (group[2] == "1"): | 574 if (group[2] == "True") or (group[2] == "1"): |
551 pwd = self.password_manager.GetPassword("room", group_id) | 575 pwd = self.password_manager.GetPassword("room", group_id) |
552 #dlg = wx.TextEntryDialog(self,"Password?","Join Private Room") | 576 #dlg = wx.TextEntryDialog(self,"Password?","Join Private Room") |
553 #if dlg.ShowModal() == wx.ID_OK: | 577 #if dlg.ShowModal() == wx.ID_OK: |
554 # pwd = dlg.GetValue() | 578 # pwd = dlg.GetValue() |
555 #dlg.Destroy() | 579 #dlg.Destroy() |
556 else: | 580 else: pwd = "" |
557 pwd = "" | 581 if pwd != None: #pwd == None means the user clicked "Cancel" |
558 if pwd != None: #pwd==None means the user clicked "Cancel" | 582 self.session.send_join_group(group_id, pwd) |
559 self.session.send_join_group(group_id,pwd) | |
560 | 583 |
561 def do_create_group(self): | 584 def do_create_group(self): |
562 name = self.texts["room_name"].GetValue() | 585 name = self.texts["room_name"].GetValue() |
563 boot_pwd = self.texts["room_boot_pwd"].GetValue() | 586 boot_pwd = self.texts["room_boot_pwd"].GetValue() |
564 minversion = self.texts["room_min_version"].GetValue() | 587 minversion = self.texts["room_min_version"].GetValue() |
590 if loc > -1: | 613 if loc > -1: |
591 b = name[:loc] | 614 b = name[:loc] |
592 e = name[loc+1:] | 615 e = name[loc+1:] |
593 name = b + "'" + e | 616 name = b + "'" + e |
594 oldloc = loc+1 | 617 oldloc = loc+1 |
595 if self.buttons[GS_PWD].GetValue(): | 618 if self.buttons['gs_pwd'].GetValue(): pwd = self.texts["room_pwd"].GetValue() |
596 pwd = self.texts["room_pwd"].GetValue() | 619 else: pwd = "" |
597 else: | 620 if name == "": wx.MessageBox("Invalid Name","Error"); |
598 pwd = "" | |
599 if name == "": | |
600 wx.MessageBox("Invalid Name","Error"); | |
601 else: | 621 else: |
602 msg = "%s is creating room \'%s.\'" % (self.session.name, name) | 622 msg = "%s is creating room \'%s.\'" % (self.session.name, name) |
603 self.session.send( msg ) | 623 self.session.send(msg) |
604 self.session.send_create_group(name,pwd,boot_pwd,minversion) | 624 self.session.send_create_group(name, pwd, boot_pwd, minversion) |
605 self.set_lobbybutton(1); #enable the Lobby quickbutton | 625 self.set_lobbybutton(1); #enable the Lobby quickbutton |
606 | |
607 | 626 |
608 #--------------------------------------------------------- | 627 #--------------------------------------------------------- |
609 # [START] Snowdog: Updated Game Server Window 12/02 | 628 # [START] Snowdog: Updated Game Server Window 12/02 |
610 #--------------------------------------------------------- | 629 #--------------------------------------------------------- |
611 | 630 |
612 def on_size(self,evt): | 631 def on_size(self, evt): |
613 # set column widths for room list | 632 # set column widths for room list |
614 | |
615 | |
616 # set column widths for server list | 633 # set column widths for server list |
617 pass | 634 pass |
618 | |
619 | |
620 | 635 |
621 #--------------------------------------------------------- | 636 #--------------------------------------------------------- |
622 # [END] Snowdog: Updated Game Server Window 12/02 | 637 # [END] Snowdog: Updated Game Server Window 12/02 |
623 #--------------------------------------------------------- | 638 #--------------------------------------------------------- |
624 | 639 |
625 | |
626 def colorize_group_list(self, groups): | 640 def colorize_group_list(self, groups): |
627 try: | 641 try: |
628 hex = orpg.tools.rgbhex.RGBHex() | 642 hex = orpg.tools.rgbhex.RGBHex() |
629 | |
630 for gr in groups: | 643 for gr in groups: |
631 item_list_location = self.room_list.FindItemData(-1,int(gr[0])) | 644 item_list_location = self.room_list.FindItemData(-1,int(gr[0])) |
632 if item_list_location != -1: | 645 if item_list_location != -1: |
633 item = self.room_list.GetItem(item_list_location) | 646 item = self.room_list.GetItem(item_list_location) |
634 if gr[0] == "0": | 647 if gr[0] == "0": r,g,b = hex.rgb_tuple(settings.get("RoomColor_Lobby")) |
635 | |
636 r,g,b = hex.rgb_tuple(settings.get_setting("RoomColor_Lobby")) | |
637 elif gr[3] <> "0": | 648 elif gr[3] <> "0": |
638 | |
639 if gr[2] == "True" or gr[2] == "1": | 649 if gr[2] == "True" or gr[2] == "1": |
640 | 650 r,g,b = hex.rgb_tuple(settings.get("RoomColor_Locked")) |
641 r,g,b = hex.rgb_tuple(settings.get_setting("RoomColor_Locked")) | 651 else: r,g,b = hex.rgb_tuple(settings.get("RoomColor_Active")) |
642 else: | 652 else: r,g,b = hex.rgb_tuple(settings.get("RoomColor_Empty")) |
643 | |
644 r,g,b = hex.rgb_tuple(settings.get_setting("RoomColor_Active")) | |
645 else: | |
646 | |
647 r,g,b = hex.rgb_tuple(settings.get_setting("RoomColor_Empty")) | |
648 | |
649 | |
650 color = wx.Colour(red=r,green=g,blue=b) | 653 color = wx.Colour(red=r,green=g,blue=b) |
651 item.SetTextColour(color) | 654 item.SetTextColour(color) |
652 self.room_list.SetItem(item) | 655 self.room_list.SetItem(item) |
653 except: | 656 except: traceback.print_exc() |
654 traceback.print_exc() |