comparison orpg/player_list.py @ 25:69149263026d traipse_dev

This patch fixes the problem that occurs when users attempt to change their name with the settings menu. It also cleans a big chunk of settings menu code out. This remains in Dev for testing.
author sirebral
date Thu, 30 Jul 2009 00:32:05 -0500
parents 78407d627cba
children 65c5cb9be59c
comparison
equal deleted inserted replaced
24:c88a794d9a22 25:69149263026d
255 def clean_sub_menus(self): 255 def clean_sub_menus(self):
256 for mid in WG_MENU_LIST: 256 for mid in WG_MENU_LIST:
257 try: 257 try:
258 self.wgMenu.Remove(WG_MENU_LIST[mid]["menuid"]) 258 self.wgMenu.Remove(WG_MENU_LIST[mid]["menuid"])
259 WG_MENU_LIST[mid]["menu"].Destroy() 259 WG_MENU_LIST[mid]["menu"].Destroy()
260 except: 260 except: self.wgMenu.UpdateUI()
261 self.wgMenu.UpdateUI()
262 if self.wgMenu.GetMenuItemCount() == 2: WG_MENU_LIST.clear() 261 if self.wgMenu.GetMenuItemCount() == 2: WG_MENU_LIST.clear()
263 return 262 return
264 263
265 def on_menu_whispergroup( self, evt ): 264 def on_menu_whispergroup( self, evt ):
266 self.session = open_rpg.get_component("session") 265 self.session = open_rpg.get_component("session")
357 self.password_manager = open_rpg.get_component("password_manager") 356 self.password_manager = open_rpg.get_component("password_manager")
358 357
359 if id == PLAYER_BOOT: 358 if id == PLAYER_BOOT:
360 id = str(self.GetItemData(self.selected_item)) 359 id = str(self.GetItemData(self.selected_item))
361 boot_pwd = self.password_manager.GetPassword("admin",int(self.session.group_id)) 360 boot_pwd = self.password_manager.GetPassword("admin",int(self.session.group_id))
362 if boot_pwd != None: 361 if boot_pwd != None: self.session.boot_player(id,boot_pwd)
363 self.session.boot_player(id,boot_pwd)
364 elif id == PLAYER_WHISPER: 362 elif id == PLAYER_WHISPER:
365 id = self.GetItemText(self.selected_item) 363 id = self.GetItemText(self.selected_item)
366 self.chat = open_rpg.get_component("chat") 364 self.chat = open_rpg.get_component("chat")
367 self.chat.set_chat_text("/w " + id + "=") 365 self.chat.set_chat_text("/w " + id + "=")
368 elif id == PLAYER_IGNORE: 366 elif id == PLAYER_IGNORE:
383 pos = wx.Point(evt.GetX(),evt.GetY()) 381 pos = wx.Point(evt.GetX(),evt.GetY())
384 (item, flag) = self.HitTest(pos) 382 (item, flag) = self.HitTest(pos)
385 if item > -1: 383 if item > -1:
386 self.selected_item = item 384 self.selected_item = item
387 # This if-else block makes the menu item to boot players active or inactive, as appropriate 385 # This if-else block makes the menu item to boot players active or inactive, as appropriate
388 # This block is enabled for 1.7.8. Ver. 1.7.9 will boast Admin features. 386 # This block is enabled for 1.7.8. Ver. 1.7.9 will boast Admin features.
389 #if open_rpg.get_component("session").group_id == "0": 387 #if open_rpg.get_component("session").group_id == "0":
390 # self.menu.Enable(PLAYER_BOOT,0) 388 # self.menu.Enable(PLAYER_BOOT,0)
391 # self.menu.SetLabel(PLAYER_BOOT,"Can't boot from Lobby") 389 # self.menu.SetLabel(PLAYER_BOOT,"Can't boot from Lobby")
392 #else: 390 #else:
393 self.menu.Enable(PLAYER_BOOT,1) 391 self.menu.Enable(PLAYER_BOOT,1)
458 456
459 #--------------------------------------------------------- 457 #---------------------------------------------------------
460 # [START] Digitalxero Multi Whisper Group 1/1/05 458 # [START] Digitalxero Multi Whisper Group 1/1/05
461 #--------------------------------------------------------- 459 #---------------------------------------------------------
462 for gid in WG_LIST: 460 for gid in WG_LIST:
463 if WG_LIST[gid].has_key(int(player[2])): 461 if WG_LIST[gid].has_key(int(player[2])): del WG_LIST[gid][int(player[2])]
464 del WG_LIST[gid][int(player[2])]
465 #--------------------------------------------------------- 462 #---------------------------------------------------------
466 # [END] Digitalxero Multi Whisper Group 1/1/05 463 # [END] Digitalxero Multi Whisper Group 1/1/05
467 #--------------------------------------------------------- 464 #---------------------------------------------------------
468 465
469 # play sound 466 # play sound
475 ic = self.GetItemCount() 472 ic = self.GetItemCount()
476 self.whisperCount = 0 473 self.whisperCount = 0
477 index = 0 474 index = 0
478 while index < ic: 475 while index < ic:
479 item = self.GetItem( index ) 476 item = self.GetItem( index )
480 if item.GetImage(): 477 if item.GetImage(): self.whisperCount += 1
481 self.whisperCount += 1
482 index += 1 478 index += 1
483 self.colorize_player_list() 479 self.colorize_player_list()
484 self.Refresh() 480 self.Refresh()
485 481
486 # This method updates the player info 482 # This method updates the player info
490 # 486 #
491 # Returns: None 487 # Returns: None
492 # 488 #
493 def update_player(self,player): 489 def update_player(self,player):
494 i = self.FindItemData(-1,int(player[2])) # finds the right list box index 490 i = self.FindItemData(-1,int(player[2])) # finds the right list box index
495 self.SetStringItem(i,1,self.strip_html(player)) 491 self.SetStringItem(i,1,player[0])
496 self.SetStringItem(i,2,player[3]) 492 self.SetStringItem(i,2,player[3])
497 item = self.GetItem(i) 493 item = self.GetItem(i)
498 self.colorize_player_list() 494 self.colorize_player_list()
499 self.Refresh() 495 self.Refresh()
500 496
501 def colorize_player_list(self): 497 def colorize_player_list(self):
502 session = open_rpg.get_component("session") 498 session = open_rpg.get_component("session")
503 settings = open_rpg.get_component('settings') 499 settings = open_rpg.get_component('settings')
504 mode = settings.get_setting("ColorizeRoles") 500 mode = settings.get_setting("ColorizeRoles")
505 if mode.lower() == "0": 501 if mode.lower() == "0": return
506 return
507 players = session.players 502 players = session.players
508 for m in players.keys(): 503 for m in players.keys():
509 item_list_location = self.FindItemData(-1,int(m)) 504 item_list_location = self.FindItemData(-1,int(m))
510 if item_list_location == -1: continue 505 if item_list_location == -1: continue
511 player_info = session.get_player_by_player_id(m) 506 player_info = session.get_player_by_player_id(m)
512 item = self.GetItem(item_list_location) 507 item = self.GetItem(item_list_location)
513 role = player_info[7] 508 role = player_info[7]
514 color = wx.GREEN 509 color = wx.GREEN
515 if self.session.group_id != "0": 510 if self.session.group_id != "0": item.SetTextColour(settings.get_setting(role + "RoleColor"))
516 item.SetTextColour(settings.get_setting(role + "RoleColor"))
517 self.SetItem(item) 511 self.SetItem(item)
518 512
519 def reset(self): 513 def reset(self):
520 self.whisperCount = 0 514 self.whisperCount = 0
521 #--------------------------------------------------------- 515 #---------------------------------------------------------