Mercurial > traipse_dev
comparison orpg/player_list.py @ 19:78407d627cba traipse_dev
Beginning of Code Clean-up. Some code untested, may break!
author | sirebral |
---|---|
date | Sat, 25 Jul 2009 17:24:40 -0500 |
parents | d5e81dac98ff |
children | 69149263026d |
comparison
equal
deleted
inserted
replaced
18:67b900deb35c | 19:78407d627cba |
---|---|
76 # [END] Snowdog Password/Room Name altering code 12/02 | 76 # [END] Snowdog Password/Room Name altering code 12/02 |
77 #--------------------------------------------------------- | 77 #--------------------------------------------------------- |
78 | 78 |
79 class player_list(wx.ListCtrl): | 79 class player_list(wx.ListCtrl): |
80 def __init__( self, parent): | 80 def __init__( self, parent): |
81 ## wx.ListCtrl.__init__( self, parent, -1, wx.DefaultPosition, wx.DefaultSize, wx.LC_REPORT|wx.SUNKEN_BORDER|wx.EXPAND ) | 81 ##wx.ListCtrl.__init__( self, parent, -1, wx.DefaultPosition, wx.DefaultSize, wx.LC_REPORT|wx.SUNKEN_BORDER|wx.EXPAND ) |
82 wx.ListCtrl.__init__( self, parent, -1, wx.DefaultPosition, wx.DefaultSize, wx.LC_REPORT|wx.SUNKEN_BORDER|wx.EXPAND|wx.LC_HRULES ) | 82 wx.ListCtrl.__init__( self, parent, -1, wx.DefaultPosition, wx.DefaultSize, |
83 wx.LC_REPORT|wx.SUNKEN_BORDER|wx.EXPAND|wx.LC_HRULES ) | |
83 self.session = open_rpg.get_component("session") | 84 self.session = open_rpg.get_component("session") |
84 self.settings = open_rpg.get_component('settings') | 85 self.settings = open_rpg.get_component('settings') |
85 self.chat = open_rpg.get_component('chat') | 86 self.chat = open_rpg.get_component('chat') |
86 self.password_manager = open_rpg.get_component("password_manager") | 87 self.password_manager = open_rpg.get_component("password_manager") |
87 # Create in image list -- for whatever reason...guess it will be nice when we can tell which is a bot | 88 # Create in image list -- for whatever reason...guess it will be nice when we can tell which is a bot |
196 self.session = open_rpg.get_component("session") | 197 self.session = open_rpg.get_component("session") |
197 self.password_manager = open_rpg.get_component("password_manager") | 198 self.password_manager = open_rpg.get_component("password_manager") |
198 self.chat = open_rpg.get_component("chat") | 199 self.chat = open_rpg.get_component("chat") |
199 boot_pwd = self.password_manager.GetPassword("admin",int(self.session.group_id)) | 200 boot_pwd = self.password_manager.GetPassword("admin",int(self.session.group_id)) |
200 if boot_pwd != None: | 201 if boot_pwd != None: |
201 alter_pwd_dialog = wx.TextEntryDialog(self,"Enter new room password: (blank for no password)","Alter Room Password") | 202 alter_pwd_dialog = wx.TextEntryDialog(self, |
203 "Enter new room password: (blank for no password)","Alter Room Password") | |
202 if alter_pwd_dialog.ShowModal() == wx.ID_OK: | 204 if alter_pwd_dialog.ShowModal() == wx.ID_OK: |
203 new_pass = alter_pwd_dialog.GetValue() | 205 new_pass = alter_pwd_dialog.GetValue() |
204 self.chat.InfoPost( "Requesting password change on server..." ) | 206 self.chat.InfoPost( "Requesting password change on server..." ) |
205 self.session.set_room_pass(new_pass, boot_pwd) | 207 self.session.set_room_pass(new_pass, boot_pwd) |
206 | 208 |
255 try: | 257 try: |
256 self.wgMenu.Remove(WG_MENU_LIST[mid]["menuid"]) | 258 self.wgMenu.Remove(WG_MENU_LIST[mid]["menuid"]) |
257 WG_MENU_LIST[mid]["menu"].Destroy() | 259 WG_MENU_LIST[mid]["menu"].Destroy() |
258 except: | 260 except: |
259 self.wgMenu.UpdateUI() | 261 self.wgMenu.UpdateUI() |
260 if self.wgMenu.GetMenuItemCount() == 2: | 262 if self.wgMenu.GetMenuItemCount() == 2: WG_MENU_LIST.clear() |
261 WG_MENU_LIST.clear() | |
262 return | 263 return |
263 | 264 |
264 def on_menu_whispergroup( self, evt ): | 265 def on_menu_whispergroup( self, evt ): |
265 self.session = open_rpg.get_component("session") | 266 self.session = open_rpg.get_component("session") |
266 self.settings = open_rpg.get_component('settings') | 267 self.settings = open_rpg.get_component('settings') |
273 create_new_group_dialog = wx.TextEntryDialog(self,"Enter Group Name","Create New Whisper Group") | 274 create_new_group_dialog = wx.TextEntryDialog(self,"Enter Group Name","Create New Whisper Group") |
274 if create_new_group_dialog.ShowModal() == wx.ID_OK: | 275 if create_new_group_dialog.ShowModal() == wx.ID_OK: |
275 group_name = create_new_group_dialog.GetValue() | 276 group_name = create_new_group_dialog.GetValue() |
276 WG_LIST[group_name] = {} | 277 WG_LIST[group_name] = {} |
277 return | 278 return |
278 elif id == PLAYER_WG_CLEAR_ALL: | 279 elif id == PLAYER_WG_CLEAR_ALL: WG_LIST.clear(); return |
279 WG_LIST.clear() | |
280 return | |
281 #Check Sub Menus | 280 #Check Sub Menus |
282 for mid in WG_MENU_LIST: | 281 for mid in WG_MENU_LIST: |
283 if id == WG_MENU_LIST[mid]["add"]: | 282 if id == WG_MENU_LIST[mid]["add"]: WG_LIST[mid][int(item.GetText())] = int(item.GetText()); return |
284 WG_LIST[mid][int(item.GetText())] = int(item.GetText()) | 283 elif id == WG_MENU_LIST[mid]["remove"]: del WG_LIST[mid][int(item.GetText())]; return |
285 return | 284 elif id == WG_MENU_LIST[mid]["clear"]: WG_LIST[mid].clear(); return |
286 elif id == WG_MENU_LIST[mid]["remove"]: | 285 elif id == WG_MENU_LIST[mid]["whisper"]: self.chat.set_chat_text("/gw " + mid + "="); return |
287 del WG_LIST[mid][int(item.GetText())] | |
288 return | |
289 elif id == WG_MENU_LIST[mid]["clear"]: | |
290 WG_LIST[mid].clear() | |
291 return | |
292 elif id == WG_MENU_LIST[mid]["whisper"]: | |
293 self.chat.set_chat_text("/gw " + mid + "=") | |
294 return | |
295 return | 286 return |
296 | 287 |
297 #--------------------------------------------------------- | 288 #--------------------------------------------------------- |
298 # [END] Digitalxero Multi Whisper Group 1/1/05 | 289 # [END] Digitalxero Multi Whisper Group 1/1/05 |
299 #--------------------------------------------------------- | 290 #--------------------------------------------------------- |
376 self.chat.set_chat_text("/w " + id + "=") | 367 self.chat.set_chat_text("/w " + id + "=") |
377 elif id == PLAYER_IGNORE: | 368 elif id == PLAYER_IGNORE: |
378 id = str(self.GetItemData(self.selected_item)) | 369 id = str(self.GetItemData(self.selected_item)) |
379 self.chat = open_rpg.get_component("chat") | 370 self.chat = open_rpg.get_component("chat") |
380 (result,id,name) = self.session.toggle_ignore(id) | 371 (result,id,name) = self.session.toggle_ignore(id) |
381 if result == 0: | 372 if result == 0: self.chat.Post(self.chat.colorize(self.chat.syscolor, |
382 self.chat.Post(self.chat.colorize(self.chat.syscolor, "Player " + name + " with ID:" + id +" no longer ignored")) | 373 "Player " + name + " with ID:" + id +" no longer ignored")) |
383 else: | 374 else: self.chat.Post(self.chat.colorize(self.chat.syscolor, |
384 self.chat.Post(self.chat.colorize(self.chat.syscolor, "Player " + name + " with ID:" + id +" now being ignored")) | 375 "Player " + name + " with ID:" + id +" now being ignored")) |
385 elif id == PLAYER_SHOW_VERSION: | 376 elif id == PLAYER_SHOW_VERSION: |
386 id = str(self.GetItemData(self.selected_item)) | 377 id = str(self.GetItemData(self.selected_item)) |
387 version_string = self.session.players[id][6] | 378 version_string = self.session.players[id][6] |
388 if version_string: | 379 if version_string: wx.MessageBox("Running client version " + version_string,"Version") |
389 wx.MessageBox("Running client version " + version_string,"Version") | 380 else: wx.MessageBox("No client version available for this player","Version") |
390 else: | |
391 wx.MessageBox("No client version available for this player","Version") | |
392 | 381 |
393 def on_menu(self, evt): | 382 def on_menu(self, evt): |
394 pos = wx.Point(evt.GetX(),evt.GetY()) | 383 pos = wx.Point(evt.GetX(),evt.GetY()) |
395 (item, flag) = self.HitTest(pos) | 384 (item, flag) = self.HitTest(pos) |
396 if item > -1: | 385 if item > -1: |
406 #--------------------------------------------------------- | 395 #--------------------------------------------------------- |
407 # [START] Digitalxero Multi Whisper Group 1/1/05 | 396 # [START] Digitalxero Multi Whisper Group 1/1/05 |
408 #--------------------------------------------------------- | 397 #--------------------------------------------------------- |
409 self.menu.Enable(PLAYER_WG_MENU, True) | 398 self.menu.Enable(PLAYER_WG_MENU, True) |
410 item = self.GetItem( self.selected_item ) | 399 item = self.GetItem( self.selected_item ) |
411 if len(WG_MENU_LIST) > len(WG_LIST): | 400 if len(WG_MENU_LIST) > len(WG_LIST): self.clean_sub_menus() |
412 self.clean_sub_menus() | 401 if len(WG_LIST) == 0: self.wgMenu.Enable(PLAYER_WG_CLEAR_ALL, False) |
413 if len(WG_LIST) == 0: | 402 else: self.wgMenu.Enable(PLAYER_WG_CLEAR_ALL, True) |
414 self.wgMenu.Enable(PLAYER_WG_CLEAR_ALL, False) | |
415 else: | |
416 self.wgMenu.Enable(PLAYER_WG_CLEAR_ALL, True) | |
417 for gid in WG_LIST: | 403 for gid in WG_LIST: |
418 if not WG_MENU_LIST.has_key(gid): | 404 if not WG_MENU_LIST.has_key(gid): |
419 WG_MENU_LIST[gid] = {} | 405 WG_MENU_LIST[gid] = {} |
420 WG_MENU_LIST[gid]["menuid"] = wx.NewId() | 406 WG_MENU_LIST[gid]["menuid"] = wx.NewId() |
421 WG_MENU_LIST[gid]["whisper"] = wx.NewId() | 407 WG_MENU_LIST[gid]["whisper"] = wx.NewId() |
540 # [END] Digitalxero Multi Whisper Group 1/1/05 | 526 # [END] Digitalxero Multi Whisper Group 1/1/05 |
541 #--------------------------------------------------------- | 527 #--------------------------------------------------------- |
542 self.DeleteAllItems() | 528 self.DeleteAllItems() |
543 | 529 |
544 def strip_html(self,player): | 530 def strip_html(self,player): |
545 ret_string = "" | 531 ret_string = ""; x = 0; in_tag = 0 |
546 x = 0 | |
547 in_tag = 0 | |
548 for x in range(len(player[0])) : | 532 for x in range(len(player[0])) : |
549 if player[0][x] == "<" or player[0][x] == ">" or in_tag == 1 : | 533 if player[0][x] == "<" or player[0][x] == ">" or in_tag == 1 : |
550 if player[0][x] == "<" : | 534 if player[0][x] == "<": in_tag = 1 |
551 in_tag = 1 | 535 elif player[0][x] == ">": in_tag = 0 |
552 elif player[0][x] == ">" : | 536 else: pass |
553 in_tag = 0 | 537 else: ret_string = ret_string + player[0][x] |
554 else : | |
555 pass | |
556 else : | |
557 ret_string = ret_string + player[0][x] | |
558 return ret_string | 538 return ret_string |
559 | 539 |
560 def size_cols(self): | 540 def size_cols(self): |
561 ## # moved skip here to see if it breaks | 541 ##moved skip here to see if it breaks |
562 ## w,h = self.GetClientSizeTuple() | 542 ## w,h = self.GetClientSizeTuple() |
563 ## w /= 8 | 543 ## w /= 8 |
564 ## self.SetColumnWidth( 0, w*2 ) | 544 ## self.SetColumnWidth( 0, w*2 ) |
565 ## self.SetColumnWidth( 1, w*2 ) | 545 ## self.SetColumnWidth( 1, w*2 ) |
566 ## self.SetColumnWidth( 2, w*3 ) | 546 ## self.SetColumnWidth( 2, w*3 ) |
567 pass | 547 pass |