Mercurial > traipse_dev
comparison orpg/networking/gsclient.py @ 96:65c1604e7949 alpha
Traipse Alpha 'OpenRPG' {090924-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:
00:
Update forwards to the 090909-02 Server code that now works.
New default Lobby Map, designed for Traipse. Feel free to change it.
Updates to Server GUI:
* Admin can Ban from Backend.
* Prework to modify Ban List in back end.
* Server GUI finds your Lobby Name
* New users default as Lurker unless a Role is set
New Addition to Chat Die Roll commands. Math Ordering. Ex. [(X+Y)dZ]. Currently does pairs only, no nesting either.
Cleaner TraipseSuiteAttention portability and clean up in Main (Beta!)
author | sirebral |
---|---|
date | Thu, 24 Sep 2009 02:05:08 -0500 |
parents | d1aff41c031b |
children | 905fa5b06d53 dcf4fbe09b70 |
comparison
equal
deleted
inserted
replaced
95:af6bf998f425 | 96:65c1604e7949 |
---|---|
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 __version__ = "$Id: gsclient.py,v 1.53 2007/10/25 21:49:34 digitalxero Exp $" | 29 __version__ = "$Id: gsclient.py,v 1.53 2007/10/25 21:49:34 digitalxero Exp $" |
30 | 30 |
31 import orpg.dirpath | 31 from orpg.dirpath import dir_struct |
32 from orpg.orpg_windows import * | 32 from orpg.orpg_windows import * |
33 from orpg.orpg_xml import * | |
34 import meta_server_lib | 33 import meta_server_lib |
34 import orpg.tools.orpg_settings | |
35 from orpg.tools.orpg_settings import settings | 35 from orpg.tools.orpg_settings import settings |
36 import orpg.tools.rgbhex | 36 import orpg.tools.rgbhex |
37 from orpg.orpgCore import open_rpg, component | 37 from orpg.orpgCore import component |
38 import traceback | 38 import traceback |
39 from orpg.tools.orpg_log import logger | |
40 | 39 |
41 gs_host = 1 | 40 gs_host = 1 |
42 gs_join = 2 | 41 gs_join = 2 |
43 # constants | 42 # constants |
44 | 43 |
98 | 97 |
99 class game_server_panel(wx.Panel): | 98 class game_server_panel(wx.Panel): |
100 def __init__(self,parent): | 99 def __init__(self,parent): |
101 wx.Panel.__init__(self, parent, -1) | 100 wx.Panel.__init__(self, parent, -1) |
102 self.parent = parent | 101 self.parent = parent |
103 logger.debug("Enter game_server_panel", False) | |
104 self.password_manager = component.get('password_manager') # passtool --SD 8/03 | 102 self.password_manager = component.get('password_manager') # passtool --SD 8/03 |
105 self.frame = component.get('frame') | 103 self.frame = component.get('frame') |
106 self.session = component.get('session') | 104 self.session = component.get('session') |
105 self.xml = component.get('xml') #Not used?? | |
107 self.serverNameSet = 0 | 106 self.serverNameSet = 0 |
108 self.last_motd = "" | 107 self.last_motd = "" |
109 self.buttons = {} | 108 self.buttons = {} |
110 self.texts = {} | 109 self.texts = {} |
111 self.svrList = [] | 110 self.svrList = [] |
112 self.build_ctrls() | 111 self.build_ctrls() |
113 self.refresh_server_list() | 112 self.refresh_server_list() |
114 self.refresh_room_list() | 113 self.refresh_room_list() |
115 logger.debug("Exit game_server_panel", False) | |
116 | 114 |
117 #--------------------------------------------------------- | 115 #--------------------------------------------------------- |
118 # [START] Snowdog: Updated Game Server Window 12/02 | 116 # [START] Snowdog: Updated Game Server Window 12/02 |
119 #--------------------------------------------------------- | 117 #--------------------------------------------------------- |
120 def build_ctrls(self): | 118 def build_ctrls(self): |
121 logger.debug("Enter game_server_panel->build_ctrls(self)", False) | |
122 | |
123 ## Section Sizers (with frame edges and text captions) | 119 ## Section Sizers (with frame edges and text captions) |
124 self.box_sizers = {} | 120 self.box_sizers = {} |
125 self.box_sizers["server"] = wx.StaticBox(self, -1, "Server") | 121 self.box_sizers["server"] = wx.StaticBox(self, -1, "Server") |
126 self.box_sizers["window"] = wx.StaticBox(self, -1, "Exit" ) | 122 self.box_sizers["window"] = wx.StaticBox(self, -1, "Exit" ) |
127 self.box_sizers["room"] = wx.StaticBox(self, -1, "Rooms") | 123 self.box_sizers["room"] = wx.StaticBox(self, -1, "Rooms") |
155 self.sizers["server"].Add(self.server_list, 1, wx.EXPAND) | 151 self.sizers["server"].Add(self.server_list, 1, wx.EXPAND) |
156 self.sizers["server"].Add(self.sizers["svrbtns"], 0, wx.EXPAND) | 152 self.sizers["server"].Add(self.sizers["svrbtns"], 0, wx.EXPAND) |
157 | 153 |
158 #Build Rooms Sizer | 154 #Build Rooms Sizer |
159 self.room_list = wx.ListCtrl(self, LIST_ROOM, style=wx.LC_REPORT | wx.SUNKEN_BORDER) | 155 self.room_list = wx.ListCtrl(self, LIST_ROOM, style=wx.LC_REPORT | wx.SUNKEN_BORDER) |
160 self.room_list.InsertColumn(0,"Game", wx.LIST_FORMAT_LEFT,0) | 156 self.room_list.InsertColumn(0,"Game", wx.LIST_FORMAT_LEFT,-1) |
161 self.room_list.InsertColumn(1,"Players", wx.LIST_FORMAT_LEFT,0) | 157 self.room_list.InsertColumn(1,"Players", wx.LIST_FORMAT_LEFT,-1) |
162 self.room_list.InsertColumn(2,"PW", wx.LIST_FORMAT_LEFT,0) | 158 self.room_list.InsertColumn(2,"PW", wx.LIST_FORMAT_LEFT,-1) |
163 self.buttons[GS_JOIN] = wx.Button(self, GS_JOIN, "Join Room") | 159 self.buttons[GS_JOIN] = wx.Button(self, GS_JOIN, "Join Room") |
164 self.buttons[GS_JOINLOBBY] = wx.Button(self, GS_JOINLOBBY, "Lobby") | 160 self.buttons[GS_JOINLOBBY] = wx.Button(self, GS_JOINLOBBY, "Lobby") |
165 self.sizers["roombtns"] = wx.BoxSizer(wx.HORIZONTAL) | 161 self.sizers["roombtns"] = wx.BoxSizer(wx.HORIZONTAL) |
166 self.sizers["roombtns"].Add(self.buttons[GS_JOIN], 0, wx.EXPAND) | 162 self.sizers["roombtns"].Add(self.buttons[GS_JOIN], 0, wx.EXPAND) |
167 self.sizers["roombtns"].Add(self.buttons[GS_JOINLOBBY], 0, wx.EXPAND) | 163 self.sizers["roombtns"].Add(self.buttons[GS_JOINLOBBY], 0, wx.EXPAND) |
233 self.texts['address'].Bind(wx.EVT_SET_FOCUS, self.on_text) | 229 self.texts['address'].Bind(wx.EVT_SET_FOCUS, self.on_text) |
234 self.set_connected(self.session.is_connected()) | 230 self.set_connected(self.session.is_connected()) |
235 self.cur_room_index = -1 | 231 self.cur_room_index = -1 |
236 self.cur_server_index = -1 | 232 self.cur_server_index = -1 |
237 self.rmList = {} | 233 self.rmList = {} |
238 logger.debug("Exit game_server_panel->build_ctrls(self)", False) | |
239 | 234 |
240 #--------------------------------------------------------- | 235 #--------------------------------------------------------- |
241 # [END] Snowdog: Updated Game Server Window 12/02 | 236 # [END] Snowdog: Updated Game Server Window 12/02 |
242 #--------------------------------------------------------- | 237 #--------------------------------------------------------- |
243 | |
244 | 238 |
245 #----------------------------------------------------- | 239 #----------------------------------------------------- |
246 # on_server_dbclick() | 240 # on_server_dbclick() |
247 # support for double click selection of server. | 241 # support for double click selection of server. |
248 # 5/16/05 -- Snowdog | 242 # 5/16/05 -- Snowdog |
249 #----------------------------------------------------- | 243 #----------------------------------------------------- |
250 def on_server_dbclick(self, evt=None): | 244 def on_server_dbclick(self, evt=None): |
251 logger.debug("Enter game_server_panel->on_server_dbclick(self, evt)", False) | |
252 | |
253 #make sure address is updated just in case list select wasn't done | 245 #make sure address is updated just in case list select wasn't done |
254 try: | 246 try: |
255 self.on_select(evt) | 247 self.on_select(evt) |
256 except: | 248 except: |
257 pass | 249 pass |
262 return | 254 return |
263 else: | 255 else: |
264 #address differs, disconnect. | 256 #address differs, disconnect. |
265 self.frame.kill_mplay_session() | 257 self.frame.kill_mplay_session() |
266 self.do_connect(address) | 258 self.do_connect(address) |
267 logger.debug("Exit game_server_panel->on_server_dbclick(self, evt)", False) | |
268 | 259 |
269 | 260 |
270 #----------------------------------------------------- | 261 #----------------------------------------------------- |
271 # on_room_dbclick() | 262 # on_room_dbclick() |
272 # support for double click selection of server. | 263 # support for double click selection of server. |
273 # 5/16/05 -- Snowdog | 264 # 5/16/05 -- Snowdog |
274 #----------------------------------------------------- | 265 #----------------------------------------------------- |
275 | 266 |
276 def on_room_dbclick(self, evt=None): | 267 def on_room_dbclick(self, evt=None): |
277 logger.debug("Enter game_server_panel->on_room_dbclick(self, evt)", False) | |
278 | |
279 #make sure address is updated just in case list select wasn't done | 268 #make sure address is updated just in case list select wasn't done |
280 try: | 269 try: |
281 self.on_select(evt) | 270 self.on_select(evt) |
282 except: | 271 except: |
283 pass | 272 pass |
299 if (group[2] == "True") or (group[2] == "1"): | 288 if (group[2] == "True") or (group[2] == "1"): |
300 pwd = self.password_manager.GetPassword("room", group_id) | 289 pwd = self.password_manager.GetPassword("room", group_id) |
301 else: | 290 else: |
302 pwd = "" | 291 pwd = "" |
303 self.session.send_join_group(group_id, pwd) | 292 self.session.send_join_group(group_id, pwd) |
304 logger.debug("Exit game_server_panel->on_room_dbclick(self, evt)", False) | |
305 | 293 |
306 | 294 |
307 def on_select(self,evt): | 295 def on_select(self,evt): |
308 logger.debug("Enter game_server_panel->on_select(self,evt)", False) | |
309 id = evt.GetId() | 296 id = evt.GetId() |
310 if id == LIST_ROOM: | 297 if id == LIST_ROOM: |
311 self.cur_room_index = evt.m_itemIndex | 298 self.cur_room_index = evt.m_itemIndex |
312 elif id==LIST_SERVER: | 299 elif id==LIST_SERVER: |
313 self.cur_server_index = evt.m_itemIndex | 300 self.cur_server_index = evt.m_itemIndex |
314 self.name = self.svrList[self.cur_server_index].name | 301 self.name = self.svrList[self.cur_server_index].name |
315 address = self.svrList[self.cur_server_index].addy | 302 address = self.svrList[self.cur_server_index].addy |
316 port = self.svrList[self.cur_server_index].port | 303 port = self.svrList[self.cur_server_index].port |
317 self.texts["address"].SetValue(address+":"+str(port)) | 304 self.texts["address"].SetValue(address+":"+str(port)) |
318 self.refresh_room_list() | 305 self.refresh_room_list() |
319 logger.debug("Exit game_server_panel->on_select(self,evt)", False) | |
320 | 306 |
321 def on_text(self,evt): | 307 def on_text(self,evt): |
322 logger.debug("Enter game_server_panel->on_text(self,evt)", False) | |
323 id = evt.GetId() | 308 id = evt.GetId() |
324 if (id == ADDRESS) and (self.cur_server_index >= 0): | 309 if (id == ADDRESS) and (self.cur_server_index >= 0): |
325 #print "ADDRESS id = ", id, "index = ", self.cur_server_index | 310 #print "ADDRESS id = ", id, "index = ", self.cur_server_index |
326 self.cur_server_index = -1 | 311 self.cur_server_index = -1 |
327 evt.Skip() | 312 evt.Skip() |
328 logger.debug("Exit game_server_panel->on_text(self,evt)", False) | |
329 | 313 |
330 def add_room(self,data): | 314 def add_room(self,data): |
331 logger.debug("Enter game_server_panel->add_room(self,data)", False) | |
332 i = self.room_list.GetItemCount() | 315 i = self.room_list.GetItemCount() |
333 if (data[2]=="1") or (data[2]=="True"): pwd="yes" | 316 if (data[2]=="1") or (data[2]=="True"): pwd="yes" |
334 else: pwd="no" | 317 else: pwd="no" |
335 self.room_list.InsertStringItem(i,data[1]) | 318 self.room_list.InsertStringItem(i,data[1]) |
336 self.room_list.SetStringItem(i,1,data[3]) | 319 self.room_list.SetStringItem(i,1,data[3]) |
337 self.room_list.SetStringItem(i,2,pwd) | 320 self.room_list.SetStringItem(i,2,pwd) |
338 self.room_list.SetItemData(i,int(data[0])) | 321 self.room_list.SetItemData(i,int(data[0])) |
339 self.refresh_room_list() | 322 self.refresh_room_list() |
340 logger.debug("Exit game_server_panel->add_room(self,data)", False) | |
341 | 323 |
342 def del_room(self, data): | 324 def del_room(self, data): |
343 logger.debug("Enter game_server_panel->del_room(self, data)", False) | |
344 i = self.room_list.FindItemData(-1, int(data[0])) | 325 i = self.room_list.FindItemData(-1, int(data[0])) |
345 self.room_list.DeleteItem(i) | 326 self.room_list.DeleteItem(i) |
346 self.refresh_room_list() | 327 self.refresh_room_list() |
347 logger.debug("Exit game_server_panel->del_room(self, data)", False) | |
348 | 328 |
349 #--------------------------------------------------------- | 329 #--------------------------------------------------------- |
350 # [START] Snowdog Password/Room Name altering code 12/02 | 330 # [START] Snowdog Password/Room Name altering code 12/02 |
351 #--------------------------------------------------------- | 331 #--------------------------------------------------------- |
352 | 332 |
353 def update_room(self,data): | 333 def update_room(self,data): |
354 logger.debug("Enter game_server_panel->update_room(self,data)", False) | |
355 | 334 |
356 #------------------------------------------------------- | 335 #------------------------------------------------------- |
357 # Udated 12/02 by Snowdog | 336 # Udated 12/02 by Snowdog |
358 # allows refresh of all room data not just player counts | 337 # allows refresh of all room data not just player counts |
359 #------------------------------------------------------- | 338 #------------------------------------------------------- |
362 else: pwd="no" | 341 else: pwd="no" |
363 self.room_list.SetStringItem(i,0,data[1]) | 342 self.room_list.SetStringItem(i,0,data[1]) |
364 self.room_list.SetStringItem(i,1,data[3]) | 343 self.room_list.SetStringItem(i,1,data[3]) |
365 self.room_list.SetStringItem(i,2,pwd) | 344 self.room_list.SetStringItem(i,2,pwd) |
366 self.refresh_room_list() | 345 self.refresh_room_list() |
367 logger.debug("Exit game_server_panel->update_room(self,data)", False) | |
368 | 346 |
369 #--------------------------------------------------------- | 347 #--------------------------------------------------------- |
370 # [END] Snowdog Password/Room Name altering code 12/02 | 348 # [END] Snowdog Password/Room Name altering code 12/02 |
371 #--------------------------------------------------------- | 349 #--------------------------------------------------------- |
372 | 350 |
374 pass | 352 pass |
375 #self.texts["cur_room"].SetLabel(name) | 353 #self.texts["cur_room"].SetLabel(name) |
376 #self.sizers["room"].Layout() | 354 #self.sizers["room"].Layout() |
377 | 355 |
378 def set_lobbybutton(self,allow): | 356 def set_lobbybutton(self,allow): |
379 logger.debug("Enter game_server_panel->set_lobbybutton(self,allow)", False) | |
380 self.buttons[GS_JOINLOBBY].Enable(allow) | 357 self.buttons[GS_JOINLOBBY].Enable(allow) |
381 logger.debug("Exit game_server_panel->set_lobbybutton(self,allow)", False) | |
382 | 358 |
383 def set_connected(self,connected): | 359 def set_connected(self,connected): |
384 logger.debug("Enter game_server_panel->set_connected(self,connected)", False) | |
385 self.buttons[GS_CONNECT].Enable(not connected) | 360 self.buttons[GS_CONNECT].Enable(not connected) |
386 self.buttons[GS_DISCONNECT].Enable(connected) | 361 self.buttons[GS_DISCONNECT].Enable(connected) |
387 self.buttons[GS_JOIN].Enable(connected) | 362 self.buttons[GS_JOIN].Enable(connected) |
388 self.buttons[GS_CREATE_ROOM].Enable(connected) | 363 self.buttons[GS_CREATE_ROOM].Enable(connected) |
389 if not connected: | 364 if not connected: |
394 self.frame.status.set_connect_status("Not Connected") | 369 self.frame.status.set_connect_status("Not Connected") |
395 else: | 370 else: |
396 #data = self.session.get_my_group() | 371 #data = self.session.get_my_group() |
397 self.frame.status.set_connect_status(self.name) | 372 self.frame.status.set_connect_status(self.name) |
398 self.set_cur_room_text("Lobby") | 373 self.set_cur_room_text("Lobby") |
399 logger.debug("Exit game_server_panel->set_connected(self,connected)", False) | |
400 | 374 |
401 def on_button(self,evt): | 375 def on_button(self,evt): |
402 logger.debug("Enter game_server_panel->son_button(self,evt)", False) | |
403 id = evt.GetId() | 376 id = evt.GetId() |
404 if id == GS_CONNECT: | 377 if id == GS_CONNECT: |
405 address = self.texts["address"].GetValue() | 378 address = self.texts["address"].GetValue() |
406 ### check to see if this is a manual entry vs. list entry. | 379 ### check to see if this is a manual entry vs. list entry. |
407 try: | 380 try: |
408 dummy = self.name | 381 dummy = self.name |
409 except: | 382 except: |
410 self.name = `address` | 383 self.name = `address` |
411 self.do_connect(address) | 384 self.do_connect(address) |
412 elif id == GS_DISCONNECT: | 385 elif id == GS_DISCONNECT: self.frame.kill_mplay_session() |
413 self.frame.kill_mplay_session() | 386 elif id == GS_CREATE_ROOM: self.do_create_group() |
414 elif id == GS_CREATE_ROOM: | 387 elif id == GS_JOIN: self.do_join_group() |
415 self.do_create_group() | 388 elif id == GS_JOINLOBBY: self.do_join_lobby() |
416 elif id == GS_JOIN: | 389 elif id == GS_SERVER_REFRESH: self.refresh_server_list() |
417 self.do_join_group() | 390 elif id == GS_PWD: self.texts["room_pwd"].Enable(evt.Checked()) |
418 elif id == GS_JOINLOBBY: | |
419 self.do_join_lobby() | |
420 elif id == GS_SERVER_REFRESH: | |
421 self.refresh_server_list() | |
422 elif id == GS_PWD: | |
423 self.texts["room_pwd"].Enable(evt.Checked()) | |
424 elif id == OR_CLOSE: | 391 elif id == OR_CLOSE: |
425 dlg = wx.MessageDialog(self,"Quit OpenRPG?","OpenRPG",wx.YES_NO) | 392 dlg = wx.MessageDialog(self,"Quit OpenRPG?","OpenRPG",wx.YES_NO) |
426 if dlg.ShowModal() == wx.ID_YES: | 393 if dlg.ShowModal() == wx.ID_YES: |
427 dlg.Destroy() | 394 dlg.Destroy() |
428 self.frame.kill_mplay_session() | 395 self.frame.kill_mplay_session() |
429 self.frame.closed_confirmed() | 396 self.frame.closed_confirmed() |
430 elif id == GS_CLOSE: | 397 elif id == GS_CLOSE: |
431 self.parent.OnMB_GameServerBrowseServers() | 398 self.parent.OnMB_GameServerBrowseServers() |
432 logger.debug("Exit game_server_panel->son_button(self,evt)", False) | |
433 | 399 |
434 def refresh_room_list(self): | 400 def refresh_room_list(self): |
435 logger.debug("Enter game_server_panel->refresh_room_list(self)", False) | |
436 self.room_list.DeleteAllItems() | 401 self.room_list.DeleteAllItems() |
437 address = self.texts["address"].GetValue() | 402 address = self.texts["address"].GetValue() |
438 try: | 403 try: |
439 cadder = self.session.host_server | 404 cadder = self.session.host_server |
440 except: | 405 except: |
455 self.room_list.SetItemData(i, int(g[0])) | 420 self.room_list.SetItemData(i, int(g[0])) |
456 if self.room_list.GetItemCount() > 0: | 421 if self.room_list.GetItemCount() > 0: |
457 self.colorize_group_list(groups) | 422 self.colorize_group_list(groups) |
458 self.room_list.SortItems(roomCmp) | 423 self.room_list.SortItems(roomCmp) |
459 wx.CallAfter(self.autosizeRooms) | 424 wx.CallAfter(self.autosizeRooms) |
460 logger.debug("Exit game_server_panel->refresh_room_list(self)", False) | |
461 | 425 |
462 def autosizeRooms(self): | 426 def autosizeRooms(self): |
463 logger.debug("Enter game_server_panel->autosizeRooms(self)", False) | |
464 self.room_list.SetColumnWidth(0, wx.LIST_AUTOSIZE) | 427 self.room_list.SetColumnWidth(0, wx.LIST_AUTOSIZE) |
465 self.room_list.SetColumnWidth(1, wx.LIST_AUTOSIZE) | 428 if self.room_list.GetColumnWidth(0) < 70: self.room_list.SetColumnWidth(0, 70) |
466 self.room_list.SetColumnWidth(2, wx.LIST_AUTOSIZE) | 429 if self.room_list.GetColumnWidth(1) < 70: self.room_list.SetColumnWidth(1, 70) |
467 logger.debug("Exit game_server_panel->autosizeRooms(self)", False) | 430 if self.room_list.GetColumnWidth(2) < 50: self.room_list.SetColumnWidth(2, 50) |
468 | 431 |
469 def refresh_server_list(self): | 432 def refresh_server_list(self): |
470 logger.debug("Enter game_server_panel->refresh_server_list(self)", False) | |
471 | |
472 try: | 433 try: |
473 self.svrList = [] | 434 self.svrList = [] |
474 self.server_list.DeleteAllItems() | 435 self.server_list.DeleteAllItems() |
475 xml_dom = meta_server_lib.get_server_list(["2"]); | 436 xml_dom = meta_server_lib.get_server_list(["2"]); |
476 node_list = xml_dom.getElementsByTagName('server') | 437 node_list = xml_dom.getElementsByTagName('server') |
484 length = len(node_list) | 445 length = len(node_list) |
485 part = 0 | 446 part = 0 |
486 partLength = 1.0/length | 447 partLength = 1.0/length |
487 for n in node_list: | 448 for n in node_list: |
488 if n.hasAttribute('id') and n.hasAttribute('name') and n.hasAttribute('num_users') and n.hasAttribute('address') and n.hasAttribute('port'): | 449 if n.hasAttribute('id') and n.hasAttribute('name') and n.hasAttribute('num_users') and n.hasAttribute('address') and n.hasAttribute('port'): |
489 self.svrList.append( server_instance(n.getAttribute('id'),n.getAttribute('name'), n.getAttribute('num_users'), n.getAttribute('address'),n.getAttribute('port'))) | 450 self.svrList.append(server_instance(n.getAttribute('id'), n.getAttribute('name'), |
451 n.getAttribute('num_users'), n.getAttribute('address'), | |
452 n.getAttribute('port'))) | |
490 address = n.getAttribute('address') + ':' + n.getAttribute('port') | 453 address = n.getAttribute('address') + ':' + n.getAttribute('port') |
491 self.rmList[address] = [] | 454 self.rmList[address] = [] |
492 rooms = n.getElementsByTagName('room') | 455 rooms = n.getElementsByTagName('room') |
493 | 456 |
494 for room in rooms: | 457 for room in rooms: |
523 self.servers = node_list | 486 self.servers = node_list |
524 | 487 |
525 # No server is currently selected!!! Versus the broken and random 0! | 488 # No server is currently selected!!! Versus the broken and random 0! |
526 self.cur_server_index = -1 | 489 self.cur_server_index = -1 |
527 self.server_list.SetColumnWidth(0, wx.LIST_AUTOSIZE) | 490 self.server_list.SetColumnWidth(0, wx.LIST_AUTOSIZE) |
491 if self.server_list.GetColumnWidth(0) < 70: self.server_list.SetColumnWidth(0, 70) | |
528 self.server_list.SetColumnWidth(1, wx.LIST_AUTOSIZE) | 492 self.server_list.SetColumnWidth(1, wx.LIST_AUTOSIZE) |
529 | 493 |
530 if self.serverNameSet == 0: | 494 if self.serverNameSet == 0: |
531 # Pointless to constantly set the address field to random | 495 # Pointless to constantly set the address field to random |
532 # server. This way, at least, if someone has their own local | 496 # server. This way, at least, if someone has their own local |
546 except: | 510 except: |
547 pass | 511 pass |
548 except Exception, e: | 512 except Exception, e: |
549 print "Server List not available." | 513 print "Server List not available." |
550 traceback.print_exc() | 514 traceback.print_exc() |
551 logger.debug("Exit game_server_panel->refresh_server_list(self)", False) | |
552 | 515 |
553 def failed_connection(self): | 516 def failed_connection(self): |
554 logger.debug("Enter game_server_panel->failed_connection(self)", False) | |
555 if(self.cur_server_index >= 0): | 517 if(self.cur_server_index >= 0): |
556 id = self.servers[self.cur_server_index].getAttribute('id') | 518 id = self.servers[self.cur_server_index].getAttribute('id') |
557 meta = self.servers[self.cur_server_index].getAttribute('meta') | 519 meta = self.servers[self.cur_server_index].getAttribute('meta') |
558 address = self.servers[self.cur_server_index].getAttribute('address') | 520 address = self.servers[self.cur_server_index].getAttribute('address') |
559 port = self.servers[self.cur_server_index].getAttribute('port') | 521 port = self.servers[self.cur_server_index].getAttribute('port') |
560 # post_failed_connection will return a non-zero if the server | 522 # post_failed_connection will return a non-zero if the server |
561 # was removed. If it was, refresh the display | 523 # was removed. If it was, refresh the display |
562 if(meta_server_lib.post_failed_connection(id,meta=meta,address=address,port=port)): | 524 if(meta_server_lib.post_failed_connection(id,meta=meta,address=address,port=port)): |
563 self.refresh_server_list() | 525 self.refresh_server_list() |
564 logger.debug("Exit game_server_panel->failed_connection(self)", False) | |
565 | 526 |
566 def do_connect(self, address): | 527 def do_connect(self, address): |
567 logger.debug("Enter game_server_panel->do_connect(self, address)", False) | |
568 chat = component.get('chat') | 528 chat = component.get('chat') |
569 chat.InfoPost("Locating server at " + address + "...") | 529 chat.InfoPost("Locating server at " + address + "...") |
570 if self.session.connect(address): | 530 if self.session.connect(address): |
571 self.frame.start_timer() | 531 self.frame.start_timer() |
572 else: | 532 else: |
573 chat.SystemPost("Failed to connect to game server...") | 533 chat.SystemPost("Failed to connect to game server...") |
574 self.failed_connection() | 534 self.failed_connection() |
575 logger.debug("Exit game_server_panel->do_connect(self, address)", False) | |
576 | 535 |
577 def do_join_lobby(self): | 536 def do_join_lobby(self): |
578 logger.debug("Enter game_server_panel->do_join_lobby(self)", False) | |
579 self.cur_room_index = 0 | 537 self.cur_room_index = 0 |
580 self.session.send_join_group("0","") | 538 self.session.send_join_group("0","") |
581 self.set_lobbybutton(0); | 539 self.set_lobbybutton(0); |
582 logger.debug("Exit game_server_panel->do_join_lobby(self)", False) | |
583 | 540 |
584 def do_join_group(self): | 541 def do_join_group(self): |
585 logger.debug("Enter game_server_panel->do_join_group(self)", False) | |
586 if self.cur_room_index >= 0: | 542 if self.cur_room_index >= 0: |
587 if self.cur_room_index != 0: | 543 if self.cur_room_index != 0: |
588 self.set_lobbybutton(1); | 544 self.set_lobbybutton(1); |
589 else: | 545 else: |
590 self.set_lobbybutton(0); | 546 self.set_lobbybutton(0); |
599 #dlg.Destroy() | 555 #dlg.Destroy() |
600 else: | 556 else: |
601 pwd = "" | 557 pwd = "" |
602 if pwd != None: #pwd==None means the user clicked "Cancel" | 558 if pwd != None: #pwd==None means the user clicked "Cancel" |
603 self.session.send_join_group(group_id,pwd) | 559 self.session.send_join_group(group_id,pwd) |
604 logger.debug("Exit game_server_panel->do_join_group(self)", False) | |
605 | 560 |
606 def do_create_group(self): | 561 def do_create_group(self): |
607 logger.debug("Enter game_server_panel->do_create_group(self)", False) | |
608 name = self.texts["room_name"].GetValue() | 562 name = self.texts["room_name"].GetValue() |
609 boot_pwd = self.texts["room_boot_pwd"].GetValue() | 563 boot_pwd = self.texts["room_boot_pwd"].GetValue() |
610 minversion = self.texts["room_min_version"].GetValue() | 564 minversion = self.texts["room_min_version"].GetValue() |
611 # | 565 # |
612 # Check for & in name. We want to allow this becaus of its common use in D&D. | 566 # Check for & in name. We want to allow this becaus of its common use in D&D. |
647 else: | 601 else: |
648 msg = "%s is creating room \'%s.\'" % (self.session.name, name) | 602 msg = "%s is creating room \'%s.\'" % (self.session.name, name) |
649 self.session.send( msg ) | 603 self.session.send( msg ) |
650 self.session.send_create_group(name,pwd,boot_pwd,minversion) | 604 self.session.send_create_group(name,pwd,boot_pwd,minversion) |
651 self.set_lobbybutton(1); #enable the Lobby quickbutton | 605 self.set_lobbybutton(1); #enable the Lobby quickbutton |
652 logger.debug("Exit game_server_panel->do_create_group(self)", False) | |
653 | 606 |
654 | 607 |
655 #--------------------------------------------------------- | 608 #--------------------------------------------------------- |
656 # [START] Snowdog: Updated Game Server Window 12/02 | 609 # [START] Snowdog: Updated Game Server Window 12/02 |
657 #--------------------------------------------------------- | 610 #--------------------------------------------------------- |
669 # [END] Snowdog: Updated Game Server Window 12/02 | 622 # [END] Snowdog: Updated Game Server Window 12/02 |
670 #--------------------------------------------------------- | 623 #--------------------------------------------------------- |
671 | 624 |
672 | 625 |
673 def colorize_group_list(self, groups): | 626 def colorize_group_list(self, groups): |
674 logger.debug("Enter game_server_panel->colorize_group_list(self, groups)", False) | |
675 | |
676 try: | 627 try: |
677 hex = orpg.tools.rgbhex.RGBHex() | 628 hex = orpg.tools.rgbhex.RGBHex() |
678 # activ = settings.get_setting("RoomColor_Active") | |
679 # lockt = settings.get_setting("RoomColor_Locked") | |
680 # empty = settings.get_setting("RoomColor_Empty") | |
681 # lobby = settings.get_setting("RoomColor_Lobby") | |
682 #renamed colors - TaS sirebral | |
683 | 629 |
684 for gr in groups: | 630 for gr in groups: |
685 item_list_location = self.room_list.FindItemData(-1,int(gr[0])) | 631 item_list_location = self.room_list.FindItemData(-1,int(gr[0])) |
686 if item_list_location != -1: | 632 if item_list_location != -1: |
687 item = self.room_list.GetItem(item_list_location) | 633 item = self.room_list.GetItem(item_list_location) |
688 if gr[0] == "0": | 634 if gr[0] == "0": |
689 # active_state = lobby | 635 |
690 r,g,b = hex.rgb_tuple(settings.get_setting("RoomColor_Lobby")) | 636 r,g,b = hex.rgb_tuple(settings.get_setting("RoomColor_Lobby")) |
691 elif gr[3] <> "0": | 637 elif gr[3] <> "0": |
692 # active_state = activ | 638 |
693 if gr[2] == "True" or gr[2] == "1": | 639 if gr[2] == "True" or gr[2] == "1": |
694 # active_state = lockt | 640 |
695 r,g,b = hex.rgb_tuple(settings.get_setting("RoomColor_Locked")) | 641 r,g,b = hex.rgb_tuple(settings.get_setting("RoomColor_Locked")) |
696 else: | 642 else: |
697 # active_state = activ | 643 |
698 r,g,b = hex.rgb_tuple(settings.get_setting("RoomColor_Active")) | 644 r,g,b = hex.rgb_tuple(settings.get_setting("RoomColor_Active")) |
699 else: | 645 else: |
700 # active_state = empty | 646 |
701 r,g,b = hex.rgb_tuple(settings.get_setting("RoomColor_Empty")) | 647 r,g,b = hex.rgb_tuple(settings.get_setting("RoomColor_Empty")) |
702 | 648 |
703 # r,g,b = hex.rgb_tuple(active_state) | 649 |
704 color = wx.Colour(red=r,green=g,blue=b) | 650 color = wx.Colour(red=r,green=g,blue=b) |
705 item.SetTextColour(color) | 651 item.SetTextColour(color) |
706 self.room_list.SetItem(item) | 652 self.room_list.SetItem(item) |
707 except: | 653 except: |
708 traceback.print_exc() | 654 traceback.print_exc() |
709 logger.debug("Exit game_server_panel->colorize_group_list(self, groups)", False) |