Mercurial > traipse
diff orpg/player_list.py @ 13:211ac836b6a0 grumpy-goblin
{090731-00} Fixes problem with Name & Settings window, cleans code.
author | sirebral |
---|---|
date | Fri, 31 Jul 2009 15:22:11 -0500 |
parents | d5e81dac98ff |
children | 265b987cce4f |
line wrap: on
line diff
--- a/orpg/player_list.py Fri Jul 24 10:03:22 2009 -0500 +++ b/orpg/player_list.py Fri Jul 31 15:22:11 2009 -0500 @@ -78,8 +78,9 @@ class player_list(wx.ListCtrl): def __init__( self, parent): -## wx.ListCtrl.__init__( self, parent, -1, wx.DefaultPosition, wx.DefaultSize, wx.LC_REPORT|wx.SUNKEN_BORDER|wx.EXPAND ) - wx.ListCtrl.__init__( self, parent, -1, wx.DefaultPosition, wx.DefaultSize, wx.LC_REPORT|wx.SUNKEN_BORDER|wx.EXPAND|wx.LC_HRULES ) + ##wx.ListCtrl.__init__( self, parent, -1, wx.DefaultPosition, wx.DefaultSize, wx.LC_REPORT|wx.SUNKEN_BORDER|wx.EXPAND ) + wx.ListCtrl.__init__( self, parent, -1, wx.DefaultPosition, wx.DefaultSize, + wx.LC_REPORT|wx.SUNKEN_BORDER|wx.EXPAND|wx.LC_HRULES ) self.session = open_rpg.get_component("session") self.settings = open_rpg.get_component('settings') self.chat = open_rpg.get_component('chat') @@ -198,7 +199,8 @@ self.chat = open_rpg.get_component("chat") boot_pwd = self.password_manager.GetPassword("admin",int(self.session.group_id)) if boot_pwd != None: - alter_pwd_dialog = wx.TextEntryDialog(self,"Enter new room password: (blank for no password)","Alter Room Password") + alter_pwd_dialog = wx.TextEntryDialog(self, + "Enter new room password: (blank for no password)","Alter Room Password") if alter_pwd_dialog.ShowModal() == wx.ID_OK: new_pass = alter_pwd_dialog.GetValue() self.chat.InfoPost( "Requesting password change on server..." ) @@ -255,10 +257,8 @@ try: self.wgMenu.Remove(WG_MENU_LIST[mid]["menuid"]) WG_MENU_LIST[mid]["menu"].Destroy() - except: - self.wgMenu.UpdateUI() - if self.wgMenu.GetMenuItemCount() == 2: - WG_MENU_LIST.clear() + except: self.wgMenu.UpdateUI() + if self.wgMenu.GetMenuItemCount() == 2: WG_MENU_LIST.clear() return def on_menu_whispergroup( self, evt ): @@ -275,23 +275,13 @@ group_name = create_new_group_dialog.GetValue() WG_LIST[group_name] = {} return - elif id == PLAYER_WG_CLEAR_ALL: - WG_LIST.clear() - return + elif id == PLAYER_WG_CLEAR_ALL: WG_LIST.clear(); return #Check Sub Menus for mid in WG_MENU_LIST: - if id == WG_MENU_LIST[mid]["add"]: - WG_LIST[mid][int(item.GetText())] = int(item.GetText()) - return - elif id == WG_MENU_LIST[mid]["remove"]: - del WG_LIST[mid][int(item.GetText())] - return - elif id == WG_MENU_LIST[mid]["clear"]: - WG_LIST[mid].clear() - return - elif id == WG_MENU_LIST[mid]["whisper"]: - self.chat.set_chat_text("/gw " + mid + "=") - return + if id == WG_MENU_LIST[mid]["add"]: WG_LIST[mid][int(item.GetText())] = int(item.GetText()); return + elif id == WG_MENU_LIST[mid]["remove"]: del WG_LIST[mid][int(item.GetText())]; return + elif id == WG_MENU_LIST[mid]["clear"]: WG_LIST[mid].clear(); return + elif id == WG_MENU_LIST[mid]["whisper"]: self.chat.set_chat_text("/gw " + mid + "="); return return #--------------------------------------------------------- @@ -368,8 +358,7 @@ if id == PLAYER_BOOT: id = str(self.GetItemData(self.selected_item)) boot_pwd = self.password_manager.GetPassword("admin",int(self.session.group_id)) - if boot_pwd != None: - self.session.boot_player(id,boot_pwd) + if boot_pwd != None: self.session.boot_player(id,boot_pwd) elif id == PLAYER_WHISPER: id = self.GetItemText(self.selected_item) self.chat = open_rpg.get_component("chat") @@ -378,17 +367,15 @@ id = str(self.GetItemData(self.selected_item)) self.chat = open_rpg.get_component("chat") (result,id,name) = self.session.toggle_ignore(id) - if result == 0: - self.chat.Post(self.chat.colorize(self.chat.syscolor, "Player " + name + " with ID:" + id +" no longer ignored")) - else: - self.chat.Post(self.chat.colorize(self.chat.syscolor, "Player " + name + " with ID:" + id +" now being ignored")) + if result == 0: self.chat.Post(self.chat.colorize(self.chat.syscolor, + "Player " + name + " with ID:" + id +" no longer ignored")) + else: self.chat.Post(self.chat.colorize(self.chat.syscolor, + "Player " + name + " with ID:" + id +" now being ignored")) elif id == PLAYER_SHOW_VERSION: id = str(self.GetItemData(self.selected_item)) version_string = self.session.players[id][6] - if version_string: - wx.MessageBox("Running client version " + version_string,"Version") - else: - wx.MessageBox("No client version available for this player","Version") + if version_string: wx.MessageBox("Running client version " + version_string,"Version") + else: wx.MessageBox("No client version available for this player","Version") def on_menu(self, evt): pos = wx.Point(evt.GetX(),evt.GetY()) @@ -396,7 +383,7 @@ if item > -1: self.selected_item = item # This if-else block makes the menu item to boot players active or inactive, as appropriate - # This block is enabled for 1.7.8. Ver. 1.7.9 will boast Admin features. + # This block is enabled for 1.7.8. Ver. 1.7.9 will boast Admin features. #if open_rpg.get_component("session").group_id == "0": # self.menu.Enable(PLAYER_BOOT,0) # self.menu.SetLabel(PLAYER_BOOT,"Can't boot from Lobby") @@ -408,12 +395,9 @@ #--------------------------------------------------------- self.menu.Enable(PLAYER_WG_MENU, True) item = self.GetItem( self.selected_item ) - if len(WG_MENU_LIST) > len(WG_LIST): - self.clean_sub_menus() - if len(WG_LIST) == 0: - self.wgMenu.Enable(PLAYER_WG_CLEAR_ALL, False) - else: - self.wgMenu.Enable(PLAYER_WG_CLEAR_ALL, True) + if len(WG_MENU_LIST) > len(WG_LIST): self.clean_sub_menus() + if len(WG_LIST) == 0: self.wgMenu.Enable(PLAYER_WG_CLEAR_ALL, False) + else: self.wgMenu.Enable(PLAYER_WG_CLEAR_ALL, True) for gid in WG_LIST: if not WG_MENU_LIST.has_key(gid): WG_MENU_LIST[gid] = {} @@ -474,8 +458,7 @@ # [START] Digitalxero Multi Whisper Group 1/1/05 #--------------------------------------------------------- for gid in WG_LIST: - if WG_LIST[gid].has_key(int(player[2])): - del WG_LIST[gid][int(player[2])] + if WG_LIST[gid].has_key(int(player[2])): del WG_LIST[gid][int(player[2])] #--------------------------------------------------------- # [END] Digitalxero Multi Whisper Group 1/1/05 #--------------------------------------------------------- @@ -491,8 +474,7 @@ index = 0 while index < ic: item = self.GetItem( index ) - if item.GetImage(): - self.whisperCount += 1 + if item.GetImage(): self.whisperCount += 1 index += 1 self.colorize_player_list() self.Refresh() @@ -516,8 +498,7 @@ session = open_rpg.get_component("session") settings = open_rpg.get_component('settings') mode = settings.get_setting("ColorizeRoles") - if mode.lower() == "0": - return + if mode.lower() == "0": return players = session.players for m in players.keys(): item_list_location = self.FindItemData(-1,int(m)) @@ -526,8 +507,7 @@ item = self.GetItem(item_list_location) role = player_info[7] color = wx.GREEN - if self.session.group_id != "0": - item.SetTextColour(settings.get_setting(role + "RoleColor")) + if self.session.group_id != "0": item.SetTextColour(settings.get_setting(role + "RoleColor")) self.SetItem(item) def reset(self): @@ -542,26 +522,20 @@ self.DeleteAllItems() def strip_html(self,player): - ret_string = "" - x = 0 - in_tag = 0 + ret_string = ""; x = 0; in_tag = 0 for x in range(len(player[0])) : if player[0][x] == "<" or player[0][x] == ">" or in_tag == 1 : - if player[0][x] == "<" : - in_tag = 1 - elif player[0][x] == ">" : - in_tag = 0 - else : - pass - else : - ret_string = ret_string + player[0][x] + if player[0][x] == "<": in_tag = 1 + elif player[0][x] == ">": in_tag = 0 + else: pass + else: ret_string = ret_string + player[0][x] return ret_string def size_cols(self): -## # moved skip here to see if it breaks -## w,h = self.GetClientSizeTuple() -## w /= 8 -## self.SetColumnWidth( 0, w*2 ) -## self.SetColumnWidth( 1, w*2 ) -## self.SetColumnWidth( 2, w*3 ) + ##moved skip here to see if it breaks + ## w,h = self.GetClientSizeTuple() + ## w /= 8 + ## self.SetColumnWidth( 0, w*2 ) + ## self.SetColumnWidth( 1, w*2 ) + ## self.SetColumnWidth( 2, w*3 ) pass