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