Mercurial > traipse_dev
comparison orpg/networking/gsclient.py @ 71:449a8900f9ac ornery-dev
Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
author | sirebral |
---|---|
date | Thu, 20 Aug 2009 03:00:39 -0500 |
parents | c54768cffbd4 |
children | d1aff41c031b |
comparison
equal
deleted
inserted
replaced
70:52a5fa913008 | 71:449a8900f9ac |
---|---|
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 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 |
35 import orpg.tools.orpg_settings | 34 import orpg.tools.orpg_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 component |
38 import traceback | 38 import traceback |
39 | 39 |
40 gs_host = 1 | 40 gs_host = 1 |
97 | 97 |
98 class game_server_panel(wx.Panel): | 98 class game_server_panel(wx.Panel): |
99 def __init__(self,parent): | 99 def __init__(self,parent): |
100 wx.Panel.__init__(self, parent, -1) | 100 wx.Panel.__init__(self, parent, -1) |
101 self.parent = parent | 101 self.parent = parent |
102 self.log = component.get('log') | |
103 self.log.log("Enter game_server_panel", ORPG_DEBUG) | |
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') |
107 self.settings = component.get('settings') | 105 self.xml = component.get('xml') #Not used?? |
108 self.xml = component.get('xml') | |
109 self.serverNameSet = 0 | 106 self.serverNameSet = 0 |
110 self.last_motd = "" | 107 self.last_motd = "" |
111 self.buttons = {} | 108 self.buttons = {} |
112 self.texts = {} | 109 self.texts = {} |
113 self.svrList = [] | 110 self.svrList = [] |
114 self.build_ctrls() | 111 self.build_ctrls() |
115 self.refresh_server_list() | 112 self.refresh_server_list() |
116 self.refresh_room_list() | 113 self.refresh_room_list() |
117 self.log.log("Exit game_server_panel", ORPG_DEBUG) | |
118 | 114 |
119 #--------------------------------------------------------- | 115 #--------------------------------------------------------- |
120 # [START] Snowdog: Updated Game Server Window 12/02 | 116 # [START] Snowdog: Updated Game Server Window 12/02 |
121 #--------------------------------------------------------- | 117 #--------------------------------------------------------- |
122 def build_ctrls(self): | 118 def build_ctrls(self): |
123 self.log.log("Enter game_server_panel->build_ctrls(self)", ORPG_DEBUG) | |
124 | |
125 ## Section Sizers (with frame edges and text captions) | 119 ## Section Sizers (with frame edges and text captions) |
126 self.box_sizers = {} | 120 self.box_sizers = {} |
127 self.box_sizers["server"] = wx.StaticBox(self, -1, "Server") | 121 self.box_sizers["server"] = wx.StaticBox(self, -1, "Server") |
128 self.box_sizers["window"] = wx.StaticBox(self, -1, "Exit" ) | 122 self.box_sizers["window"] = wx.StaticBox(self, -1, "Exit" ) |
129 self.box_sizers["room"] = wx.StaticBox(self, -1, "Rooms") | 123 self.box_sizers["room"] = wx.StaticBox(self, -1, "Rooms") |
235 self.texts['address'].Bind(wx.EVT_SET_FOCUS, self.on_text) | 229 self.texts['address'].Bind(wx.EVT_SET_FOCUS, self.on_text) |
236 self.set_connected(self.session.is_connected()) | 230 self.set_connected(self.session.is_connected()) |
237 self.cur_room_index = -1 | 231 self.cur_room_index = -1 |
238 self.cur_server_index = -1 | 232 self.cur_server_index = -1 |
239 self.rmList = {} | 233 self.rmList = {} |
240 self.log.log("Exit game_server_panel->build_ctrls(self)", ORPG_DEBUG) | |
241 | 234 |
242 #--------------------------------------------------------- | 235 #--------------------------------------------------------- |
243 # [END] Snowdog: Updated Game Server Window 12/02 | 236 # [END] Snowdog: Updated Game Server Window 12/02 |
244 #--------------------------------------------------------- | 237 #--------------------------------------------------------- |
245 | 238 |
247 # on_server_dbclick() | 240 # on_server_dbclick() |
248 # support for double click selection of server. | 241 # support for double click selection of server. |
249 # 5/16/05 -- Snowdog | 242 # 5/16/05 -- Snowdog |
250 #----------------------------------------------------- | 243 #----------------------------------------------------- |
251 def on_server_dbclick(self, evt=None): | 244 def on_server_dbclick(self, evt=None): |
252 self.log.log("Enter game_server_panel->on_server_dbclick(self, evt)", ORPG_DEBUG) | |
253 | |
254 #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 |
255 try: | 246 try: |
256 self.on_select(evt) | 247 self.on_select(evt) |
257 except: | 248 except: |
258 pass | 249 pass |
263 return | 254 return |
264 else: | 255 else: |
265 #address differs, disconnect. | 256 #address differs, disconnect. |
266 self.frame.kill_mplay_session() | 257 self.frame.kill_mplay_session() |
267 self.do_connect(address) | 258 self.do_connect(address) |
268 self.log.log("Exit game_server_panel->on_server_dbclick(self, evt)", ORPG_DEBUG) | |
269 | 259 |
270 | 260 |
271 #----------------------------------------------------- | 261 #----------------------------------------------------- |
272 # on_room_dbclick() | 262 # on_room_dbclick() |
273 # support for double click selection of server. | 263 # support for double click selection of server. |
274 # 5/16/05 -- Snowdog | 264 # 5/16/05 -- Snowdog |
275 #----------------------------------------------------- | 265 #----------------------------------------------------- |
276 | 266 |
277 def on_room_dbclick(self, evt=None): | 267 def on_room_dbclick(self, evt=None): |
278 self.log.log("Enter game_server_panel->on_room_dbclick(self, evt)", ORPG_DEBUG) | |
279 | |
280 #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 |
281 try: | 269 try: |
282 self.on_select(evt) | 270 self.on_select(evt) |
283 except: | 271 except: |
284 pass | 272 pass |
300 if (group[2] == "True") or (group[2] == "1"): | 288 if (group[2] == "True") or (group[2] == "1"): |
301 pwd = self.password_manager.GetPassword("room", group_id) | 289 pwd = self.password_manager.GetPassword("room", group_id) |
302 else: | 290 else: |
303 pwd = "" | 291 pwd = "" |
304 self.session.send_join_group(group_id, pwd) | 292 self.session.send_join_group(group_id, pwd) |
305 self.log.log("Exit game_server_panel->on_room_dbclick(self, evt)", ORPG_DEBUG) | |
306 | 293 |
307 | 294 |
308 def on_select(self,evt): | 295 def on_select(self,evt): |
309 self.log.log("Enter game_server_panel->on_select(self,evt)", ORPG_DEBUG) | |
310 id = evt.GetId() | 296 id = evt.GetId() |
311 if id == LIST_ROOM: | 297 if id == LIST_ROOM: |
312 self.cur_room_index = evt.m_itemIndex | 298 self.cur_room_index = evt.m_itemIndex |
313 elif id==LIST_SERVER: | 299 elif id==LIST_SERVER: |
314 self.cur_server_index = evt.m_itemIndex | 300 self.cur_server_index = evt.m_itemIndex |
315 self.name = self.svrList[self.cur_server_index].name | 301 self.name = self.svrList[self.cur_server_index].name |
316 address = self.svrList[self.cur_server_index].addy | 302 address = self.svrList[self.cur_server_index].addy |
317 port = self.svrList[self.cur_server_index].port | 303 port = self.svrList[self.cur_server_index].port |
318 self.texts["address"].SetValue(address+":"+str(port)) | 304 self.texts["address"].SetValue(address+":"+str(port)) |
319 self.refresh_room_list() | 305 self.refresh_room_list() |
320 self.log.log("Exit game_server_panel->on_select(self,evt)", ORPG_DEBUG) | |
321 | 306 |
322 def on_text(self,evt): | 307 def on_text(self,evt): |
323 self.log.log("Enter game_server_panel->on_text(self,evt)", ORPG_DEBUG) | |
324 id = evt.GetId() | 308 id = evt.GetId() |
325 if (id == ADDRESS) and (self.cur_server_index >= 0): | 309 if (id == ADDRESS) and (self.cur_server_index >= 0): |
326 #print "ADDRESS id = ", id, "index = ", self.cur_server_index | 310 #print "ADDRESS id = ", id, "index = ", self.cur_server_index |
327 self.cur_server_index = -1 | 311 self.cur_server_index = -1 |
328 evt.Skip() | 312 evt.Skip() |
329 self.log.log("Exit game_server_panel->on_text(self,evt)", ORPG_DEBUG) | |
330 | 313 |
331 def add_room(self,data): | 314 def add_room(self,data): |
332 self.log.log("Enter game_server_panel->add_room(self,data)", ORPG_DEBUG) | |
333 i = self.room_list.GetItemCount() | 315 i = self.room_list.GetItemCount() |
334 if (data[2]=="1") or (data[2]=="True"): pwd="yes" | 316 if (data[2]=="1") or (data[2]=="True"): pwd="yes" |
335 else: pwd="no" | 317 else: pwd="no" |
336 self.room_list.InsertStringItem(i,data[1]) | 318 self.room_list.InsertStringItem(i,data[1]) |
337 self.room_list.SetStringItem(i,1,data[3]) | 319 self.room_list.SetStringItem(i,1,data[3]) |
338 self.room_list.SetStringItem(i,2,pwd) | 320 self.room_list.SetStringItem(i,2,pwd) |
339 self.room_list.SetItemData(i,int(data[0])) | 321 self.room_list.SetItemData(i,int(data[0])) |
340 self.refresh_room_list() | 322 self.refresh_room_list() |
341 self.log.log("Exit game_server_panel->add_room(self,data)", ORPG_DEBUG) | |
342 | 323 |
343 def del_room(self, data): | 324 def del_room(self, data): |
344 self.log.log("Enter game_server_panel->del_room(self, data)", ORPG_DEBUG) | |
345 i = self.room_list.FindItemData(-1, int(data[0])) | 325 i = self.room_list.FindItemData(-1, int(data[0])) |
346 self.room_list.DeleteItem(i) | 326 self.room_list.DeleteItem(i) |
347 self.refresh_room_list() | 327 self.refresh_room_list() |
348 self.log.log("Exit game_server_panel->del_room(self, data)", ORPG_DEBUG) | |
349 | 328 |
350 #--------------------------------------------------------- | 329 #--------------------------------------------------------- |
351 # [START] Snowdog Password/Room Name altering code 12/02 | 330 # [START] Snowdog Password/Room Name altering code 12/02 |
352 #--------------------------------------------------------- | 331 #--------------------------------------------------------- |
353 | 332 |
354 def update_room(self,data): | 333 def update_room(self,data): |
355 self.log.log("Enter game_server_panel->update_room(self,data)", ORPG_DEBUG) | |
356 | 334 |
357 #------------------------------------------------------- | 335 #------------------------------------------------------- |
358 # Udated 12/02 by Snowdog | 336 # Udated 12/02 by Snowdog |
359 # allows refresh of all room data not just player counts | 337 # allows refresh of all room data not just player counts |
360 #------------------------------------------------------- | 338 #------------------------------------------------------- |
363 else: pwd="no" | 341 else: pwd="no" |
364 self.room_list.SetStringItem(i,0,data[1]) | 342 self.room_list.SetStringItem(i,0,data[1]) |
365 self.room_list.SetStringItem(i,1,data[3]) | 343 self.room_list.SetStringItem(i,1,data[3]) |
366 self.room_list.SetStringItem(i,2,pwd) | 344 self.room_list.SetStringItem(i,2,pwd) |
367 self.refresh_room_list() | 345 self.refresh_room_list() |
368 self.log.log("Exit game_server_panel->update_room(self,data)", ORPG_DEBUG) | |
369 | 346 |
370 #--------------------------------------------------------- | 347 #--------------------------------------------------------- |
371 # [END] Snowdog Password/Room Name altering code 12/02 | 348 # [END] Snowdog Password/Room Name altering code 12/02 |
372 #--------------------------------------------------------- | 349 #--------------------------------------------------------- |
373 | 350 |
375 pass | 352 pass |
376 #self.texts["cur_room"].SetLabel(name) | 353 #self.texts["cur_room"].SetLabel(name) |
377 #self.sizers["room"].Layout() | 354 #self.sizers["room"].Layout() |
378 | 355 |
379 def set_lobbybutton(self,allow): | 356 def set_lobbybutton(self,allow): |
380 self.log.log("Enter game_server_panel->set_lobbybutton(self,allow)", ORPG_DEBUG) | |
381 self.buttons[GS_JOINLOBBY].Enable(allow) | 357 self.buttons[GS_JOINLOBBY].Enable(allow) |
382 self.log.log("Exit game_server_panel->set_lobbybutton(self,allow)", ORPG_DEBUG) | |
383 | 358 |
384 def set_connected(self,connected): | 359 def set_connected(self,connected): |
385 self.log.log("Enter game_server_panel->set_connected(self,connected)", ORPG_DEBUG) | |
386 self.buttons[GS_CONNECT].Enable(not connected) | 360 self.buttons[GS_CONNECT].Enable(not connected) |
387 self.buttons[GS_DISCONNECT].Enable(connected) | 361 self.buttons[GS_DISCONNECT].Enable(connected) |
388 self.buttons[GS_JOIN].Enable(connected) | 362 self.buttons[GS_JOIN].Enable(connected) |
389 self.buttons[GS_CREATE_ROOM].Enable(connected) | 363 self.buttons[GS_CREATE_ROOM].Enable(connected) |
390 if not connected: | 364 if not connected: |
395 self.frame.status.set_connect_status("Not Connected") | 369 self.frame.status.set_connect_status("Not Connected") |
396 else: | 370 else: |
397 #data = self.session.get_my_group() | 371 #data = self.session.get_my_group() |
398 self.frame.status.set_connect_status(self.name) | 372 self.frame.status.set_connect_status(self.name) |
399 self.set_cur_room_text("Lobby") | 373 self.set_cur_room_text("Lobby") |
400 self.log.log("Exit game_server_panel->set_connected(self,connected)", ORPG_DEBUG) | |
401 | 374 |
402 def on_button(self,evt): | 375 def on_button(self,evt): |
403 self.log.log("Enter game_server_panel->son_button(self,evt)", ORPG_DEBUG) | |
404 id = evt.GetId() | 376 id = evt.GetId() |
405 if id == GS_CONNECT: | 377 if id == GS_CONNECT: |
406 address = self.texts["address"].GetValue() | 378 address = self.texts["address"].GetValue() |
407 ### 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. |
408 try: | 380 try: |
409 dummy = self.name | 381 dummy = self.name |
410 except: | 382 except: |
411 self.name = `address` | 383 self.name = `address` |
412 self.do_connect(address) | 384 self.do_connect(address) |
413 elif id == GS_DISCONNECT: | 385 elif id == GS_DISCONNECT: self.frame.kill_mplay_session() |
414 self.frame.kill_mplay_session() | 386 elif id == GS_CREATE_ROOM: self.do_create_group() |
415 elif id == GS_CREATE_ROOM: | 387 elif id == GS_JOIN: self.do_join_group() |
416 self.do_create_group() | 388 elif id == GS_JOINLOBBY: self.do_join_lobby() |
417 elif id == GS_JOIN: | 389 elif id == GS_SERVER_REFRESH: self.refresh_server_list() |
418 self.do_join_group() | 390 elif id == GS_PWD: self.texts["room_pwd"].Enable(evt.Checked()) |
419 elif id == GS_JOINLOBBY: | |
420 self.do_join_lobby() | |
421 elif id == GS_SERVER_REFRESH: | |
422 self.refresh_server_list() | |
423 elif id == GS_PWD: | |
424 self.texts["room_pwd"].Enable(evt.Checked()) | |
425 elif id == OR_CLOSE: | 391 elif id == OR_CLOSE: |
426 dlg = wx.MessageDialog(self,"Quit OpenRPG?","OpenRPG",wx.YES_NO) | 392 dlg = wx.MessageDialog(self,"Quit OpenRPG?","OpenRPG",wx.YES_NO) |
427 if dlg.ShowModal() == wx.ID_YES: | 393 if dlg.ShowModal() == wx.ID_YES: |
428 dlg.Destroy() | 394 dlg.Destroy() |
429 self.frame.kill_mplay_session() | 395 self.frame.kill_mplay_session() |
430 self.frame.closed_confirmed() | 396 self.frame.closed_confirmed() |
431 elif id == GS_CLOSE: | 397 elif id == GS_CLOSE: |
432 self.parent.OnMB_GameServerBrowseServers() | 398 self.parent.OnMB_GameServerBrowseServers() |
433 self.log.log("Exit game_server_panel->son_button(self,evt)", ORPG_DEBUG) | |
434 | 399 |
435 def refresh_room_list(self): | 400 def refresh_room_list(self): |
436 self.log.log("Enter game_server_panel->refresh_room_list(self)", ORPG_DEBUG) | |
437 self.room_list.DeleteAllItems() | 401 self.room_list.DeleteAllItems() |
438 address = self.texts["address"].GetValue() | 402 address = self.texts["address"].GetValue() |
439 try: | 403 try: |
440 cadder = self.session.host_server | 404 cadder = self.session.host_server |
441 except: | 405 except: |
456 self.room_list.SetItemData(i, int(g[0])) | 420 self.room_list.SetItemData(i, int(g[0])) |
457 if self.room_list.GetItemCount() > 0: | 421 if self.room_list.GetItemCount() > 0: |
458 self.colorize_group_list(groups) | 422 self.colorize_group_list(groups) |
459 self.room_list.SortItems(roomCmp) | 423 self.room_list.SortItems(roomCmp) |
460 wx.CallAfter(self.autosizeRooms) | 424 wx.CallAfter(self.autosizeRooms) |
461 self.log.log("Exit game_server_panel->refresh_room_list(self)", ORPG_DEBUG) | |
462 | 425 |
463 def autosizeRooms(self): | 426 def autosizeRooms(self): |
464 self.log.log("Enter game_server_panel->autosizeRooms(self)", ORPG_DEBUG) | |
465 self.room_list.SetColumnWidth(0, wx.LIST_AUTOSIZE) | 427 self.room_list.SetColumnWidth(0, wx.LIST_AUTOSIZE) |
466 #self.room_list.SetColumnWidth(1, wx.LIST_AUTOSIZE) | |
467 #self.room_list.SetColumnWidth(2, wx.LIST_AUTOSIZE) | |
468 if self.room_list.GetColumnWidth(0) < 70: self.room_list.SetColumnWidth(0, 70) | 428 if self.room_list.GetColumnWidth(0) < 70: self.room_list.SetColumnWidth(0, 70) |
469 if self.room_list.GetColumnWidth(1) < 70: self.room_list.SetColumnWidth(1, 70) | 429 if self.room_list.GetColumnWidth(1) < 70: self.room_list.SetColumnWidth(1, 70) |
470 if self.room_list.GetColumnWidth(2) < 50: self.room_list.SetColumnWidth(2, 50) | 430 if self.room_list.GetColumnWidth(2) < 50: self.room_list.SetColumnWidth(2, 50) |
471 self.log.log("Exit game_server_panel->autosizeRooms(self)", ORPG_DEBUG) | |
472 | 431 |
473 def refresh_server_list(self): | 432 def refresh_server_list(self): |
474 self.log.log("Enter game_server_panel->refresh_server_list(self)", ORPG_DEBUG) | |
475 | |
476 try: | 433 try: |
477 self.svrList = [] | 434 self.svrList = [] |
478 self.server_list.DeleteAllItems() | 435 self.server_list.DeleteAllItems() |
479 xml_dom = meta_server_lib.get_server_list(["2"]); | 436 xml_dom = meta_server_lib.get_server_list(["2"]); |
480 node_list = xml_dom.getElementsByTagName('server') | 437 node_list = xml_dom.getElementsByTagName('server') |
481 hex = orpg.tools.rgbhex.RGBHex() | 438 hex = orpg.tools.rgbhex.RGBHex() |
482 color1 = self.settings.get_setting("RoomColor_Active") | 439 color1 = settings.get_setting("RoomColor_Active") |
483 color2 = self.settings.get_setting("RoomColor_Locked") | 440 color2 = settings.get_setting("RoomColor_Locked") |
484 color3 = self.settings.get_setting("RoomColor_Empty") | 441 color3 = settings.get_setting("RoomColor_Empty") |
485 color4 = self.settings.get_setting("RoomColor_Lobby") | 442 color4 = settings.get_setting("RoomColor_Lobby") |
486 | 443 |
487 if len(node_list): | 444 if len(node_list): |
488 length = len(node_list) | 445 length = len(node_list) |
489 part = 0 | 446 part = 0 |
490 partLength = 1.0/length | 447 partLength = 1.0/length |
491 for n in node_list: | 448 for n in node_list: |
492 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'): |
493 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'))) | |
494 address = n.getAttribute('address') + ':' + n.getAttribute('port') | 453 address = n.getAttribute('address') + ':' + n.getAttribute('port') |
495 self.rmList[address] = [] | 454 self.rmList[address] = [] |
496 rooms = n.getElementsByTagName('room') | 455 rooms = n.getElementsByTagName('room') |
497 | 456 |
498 for room in rooms: | 457 for room in rooms: |
551 except: | 510 except: |
552 pass | 511 pass |
553 except Exception, e: | 512 except Exception, e: |
554 print "Server List not available." | 513 print "Server List not available." |
555 traceback.print_exc() | 514 traceback.print_exc() |
556 self.log.log("Exit game_server_panel->refresh_server_list(self)", ORPG_DEBUG) | |
557 | 515 |
558 def failed_connection(self): | 516 def failed_connection(self): |
559 self.log.log("Enter game_server_panel->failed_connection(self)", ORPG_DEBUG) | |
560 if(self.cur_server_index >= 0): | 517 if(self.cur_server_index >= 0): |
561 id = self.servers[self.cur_server_index].getAttribute('id') | 518 id = self.servers[self.cur_server_index].getAttribute('id') |
562 meta = self.servers[self.cur_server_index].getAttribute('meta') | 519 meta = self.servers[self.cur_server_index].getAttribute('meta') |
563 address = self.servers[self.cur_server_index].getAttribute('address') | 520 address = self.servers[self.cur_server_index].getAttribute('address') |
564 port = self.servers[self.cur_server_index].getAttribute('port') | 521 port = self.servers[self.cur_server_index].getAttribute('port') |
565 # post_failed_connection will return a non-zero if the server | 522 # post_failed_connection will return a non-zero if the server |
566 # was removed. If it was, refresh the display | 523 # was removed. If it was, refresh the display |
567 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)): |
568 self.refresh_server_list() | 525 self.refresh_server_list() |
569 self.log.log("Exit game_server_panel->failed_connection(self)", ORPG_DEBUG) | |
570 | 526 |
571 def do_connect(self, address): | 527 def do_connect(self, address): |
572 self.log.log("Enter game_server_panel->do_connect(self, address)", ORPG_DEBUG) | |
573 chat = component.get('chat') | 528 chat = component.get('chat') |
574 chat.InfoPost("Locating server at " + address + "...") | 529 chat.InfoPost("Locating server at " + address + "...") |
575 if self.session.connect(address): | 530 if self.session.connect(address): |
576 self.frame.start_timer() | 531 self.frame.start_timer() |
577 else: | 532 else: |
578 chat.SystemPost("Failed to connect to game server...") | 533 chat.SystemPost("Failed to connect to game server...") |
579 self.failed_connection() | 534 self.failed_connection() |
580 self.log.log("Exit game_server_panel->do_connect(self, address)", ORPG_DEBUG) | |
581 | 535 |
582 def do_join_lobby(self): | 536 def do_join_lobby(self): |
583 self.log.log("Enter game_server_panel->do_join_lobby(self)", ORPG_DEBUG) | |
584 self.cur_room_index = 0 | 537 self.cur_room_index = 0 |
585 self.session.send_join_group("0","") | 538 self.session.send_join_group("0","") |
586 self.set_lobbybutton(0); | 539 self.set_lobbybutton(0); |
587 self.log.log("Exit game_server_panel->do_join_lobby(self)", ORPG_DEBUG) | |
588 | 540 |
589 def do_join_group(self): | 541 def do_join_group(self): |
590 self.log.log("Enter game_server_panel->do_join_group(self)", ORPG_DEBUG) | |
591 if self.cur_room_index >= 0: | 542 if self.cur_room_index >= 0: |
592 if self.cur_room_index != 0: | 543 if self.cur_room_index != 0: |
593 self.set_lobbybutton(1); | 544 self.set_lobbybutton(1); |
594 else: | 545 else: |
595 self.set_lobbybutton(0); | 546 self.set_lobbybutton(0); |
604 #dlg.Destroy() | 555 #dlg.Destroy() |
605 else: | 556 else: |
606 pwd = "" | 557 pwd = "" |
607 if pwd != None: #pwd==None means the user clicked "Cancel" | 558 if pwd != None: #pwd==None means the user clicked "Cancel" |
608 self.session.send_join_group(group_id,pwd) | 559 self.session.send_join_group(group_id,pwd) |
609 self.log.log("Exit game_server_panel->do_join_group(self)", ORPG_DEBUG) | |
610 | 560 |
611 def do_create_group(self): | 561 def do_create_group(self): |
612 self.log.log("Enter game_server_panel->do_create_group(self)", ORPG_DEBUG) | |
613 name = self.texts["room_name"].GetValue() | 562 name = self.texts["room_name"].GetValue() |
614 boot_pwd = self.texts["room_boot_pwd"].GetValue() | 563 boot_pwd = self.texts["room_boot_pwd"].GetValue() |
615 minversion = self.texts["room_min_version"].GetValue() | 564 minversion = self.texts["room_min_version"].GetValue() |
616 # | 565 # |
617 # 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. |
652 else: | 601 else: |
653 msg = "%s is creating room \'%s.\'" % (self.session.name, name) | 602 msg = "%s is creating room \'%s.\'" % (self.session.name, name) |
654 self.session.send( msg ) | 603 self.session.send( msg ) |
655 self.session.send_create_group(name,pwd,boot_pwd,minversion) | 604 self.session.send_create_group(name,pwd,boot_pwd,minversion) |
656 self.set_lobbybutton(1); #enable the Lobby quickbutton | 605 self.set_lobbybutton(1); #enable the Lobby quickbutton |
657 self.log.log("Exit game_server_panel->do_create_group(self)", ORPG_DEBUG) | |
658 | 606 |
659 | 607 |
660 #--------------------------------------------------------- | 608 #--------------------------------------------------------- |
661 # [START] Snowdog: Updated Game Server Window 12/02 | 609 # [START] Snowdog: Updated Game Server Window 12/02 |
662 #--------------------------------------------------------- | 610 #--------------------------------------------------------- |
674 # [END] Snowdog: Updated Game Server Window 12/02 | 622 # [END] Snowdog: Updated Game Server Window 12/02 |
675 #--------------------------------------------------------- | 623 #--------------------------------------------------------- |
676 | 624 |
677 | 625 |
678 def colorize_group_list(self, groups): | 626 def colorize_group_list(self, groups): |
679 self.log.log("Enter game_server_panel->colorize_group_list(self, groups)", ORPG_DEBUG) | |
680 | |
681 try: | 627 try: |
682 hex = orpg.tools.rgbhex.RGBHex() | 628 hex = orpg.tools.rgbhex.RGBHex() |
683 # activ = self.settings.get_setting("RoomColor_Active") | |
684 # lockt = self.settings.get_setting("RoomColor_Locked") | |
685 # empty = self.settings.get_setting("RoomColor_Empty") | |
686 # lobby = self.settings.get_setting("RoomColor_Lobby") | |
687 #renamed colors - TaS sirebral | |
688 | 629 |
689 for gr in groups: | 630 for gr in groups: |
690 item_list_location = self.room_list.FindItemData(-1,int(gr[0])) | 631 item_list_location = self.room_list.FindItemData(-1,int(gr[0])) |
691 if item_list_location != -1: | 632 if item_list_location != -1: |
692 item = self.room_list.GetItem(item_list_location) | 633 item = self.room_list.GetItem(item_list_location) |
693 if gr[0] == "0": | 634 if gr[0] == "0": |
694 # active_state = lobby | 635 |
695 r,g,b = hex.rgb_tuple(self.settings.get_setting("RoomColor_Lobby")) | 636 r,g,b = hex.rgb_tuple(settings.get_setting("RoomColor_Lobby")) |
696 elif gr[3] <> "0": | 637 elif gr[3] <> "0": |
697 # active_state = activ | 638 |
698 if gr[2] == "True" or gr[2] == "1": | 639 if gr[2] == "True" or gr[2] == "1": |
699 # active_state = lockt | 640 |
700 r,g,b = hex.rgb_tuple(self.settings.get_setting("RoomColor_Locked")) | 641 r,g,b = hex.rgb_tuple(settings.get_setting("RoomColor_Locked")) |
701 else: | 642 else: |
702 # active_state = activ | 643 |
703 r,g,b = hex.rgb_tuple(self.settings.get_setting("RoomColor_Active")) | 644 r,g,b = hex.rgb_tuple(settings.get_setting("RoomColor_Active")) |
704 else: | 645 else: |
705 # active_state = empty | 646 |
706 r,g,b = hex.rgb_tuple(self.settings.get_setting("RoomColor_Empty")) | 647 r,g,b = hex.rgb_tuple(settings.get_setting("RoomColor_Empty")) |
707 | 648 |
708 # r,g,b = hex.rgb_tuple(active_state) | 649 |
709 color = wx.Colour(red=r,green=g,blue=b) | 650 color = wx.Colour(red=r,green=g,blue=b) |
710 item.SetTextColour(color) | 651 item.SetTextColour(color) |
711 self.room_list.SetItem(item) | 652 self.room_list.SetItem(item) |
712 except: | 653 except: |
713 traceback.print_exc() | 654 traceback.print_exc() |
714 self.log.log("Exit game_server_panel->colorize_group_list(self, groups)", ORPG_DEBUG) |