comparison orpg/player_list.py @ 66:c54768cffbd4 ornery-dev

Traipse Dev 'OpenRPG' {090818-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: *Unstable* This is the first wave of Code Refinement updates. Includes new material from Core Beta; new debugger material (partially implemented), beginnings of switch to etree, TerminalWriter, and a little more. open_rpg has been renamed to component; functioning now as component.get(), component.add(), component.delete(). This version has known bugs, specifically with the gametree and nodes. I think the XML files where not removed during testing of Core and switching back.
author sirebral
date Tue, 18 Aug 2009 06:33:37 -0500
parents f3d8101211c4
children 06f10429eedc
comparison
equal deleted inserted replaced
65:4840657c23c5 66:c54768cffbd4
28 # 28 #
29 29
30 __version__ = "$Id: player_list.py,v 1.29 2007/03/30 19:12:06 digitalxero Exp $" 30 __version__ = "$Id: player_list.py,v 1.29 2007/03/30 19:12:06 digitalxero Exp $"
31 31
32 from orpg.orpg_windows import * 32 from orpg.orpg_windows import *
33 import orpg.dirpath 33 from orpg.dirpath import dir_struct
34 34
35 # global definitions 35 # global definitions
36 global ROLE_GM; ROLE_GM = "GM" 36 global ROLE_GM; ROLE_GM = "GM"
37 global ROLE_PLAYER; ROLE_PLAYER = "PLAYER" 37 global ROLE_PLAYER; ROLE_PLAYER = "PLAYER"
38 global ROLE_LURKER; ROLE_LURKER = "LURKER" 38 global ROLE_LURKER; ROLE_LURKER = "LURKER"
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 )
82 wx.ListCtrl.__init__( self, parent, -1, wx.DefaultPosition, wx.DefaultSize, 81 wx.ListCtrl.__init__( self, parent, -1, wx.DefaultPosition, wx.DefaultSize,
83 wx.LC_REPORT|wx.SUNKEN_BORDER|wx.EXPAND|wx.LC_HRULES ) 82 wx.LC_REPORT|wx.SUNKEN_BORDER|wx.EXPAND|wx.LC_HRULES )
84 self.session = open_rpg.get_component("session") 83 self.session = component.get("session")
85 self.settings = open_rpg.get_component('settings') 84 self.settings = component.get('settings')
86 self.chat = open_rpg.get_component('chat') 85 self.chat = component.get('chat')
87 self.password_manager = open_rpg.get_component("password_manager") 86 self.password_manager = component.get("password_manager")
88 # Create in image list -- for whatever reason...guess it will be nice when we can tell which is a bot 87 # Create in image list -- for whatever reason...guess it will be nice when we can tell which is a bot
89 self.whisperCount = 0 88 self.whisperCount = 0
90 self._imageList = wx.ImageList( 16, 16, False ) 89 self._imageList = wx.ImageList( 16, 16, False )
91 img = wx.Image(orpg.dirpath.dir_struct["icon"]+"player.gif", wx.BITMAP_TYPE_GIF).ConvertToBitmap() 90 img = wx.Image(dir_struct["icon"]+"player.gif", wx.BITMAP_TYPE_GIF).ConvertToBitmap()
92 self._imageList.Add( img ) 91 self._imageList.Add( img )
93 img = wx.Image(orpg.dirpath.dir_struct["icon"]+"player-whisper.gif", wx.BITMAP_TYPE_GIF).ConvertToBitmap() 92 img = wx.Image(dir_struct["icon"]+"player-whisper.gif", wx.BITMAP_TYPE_GIF).ConvertToBitmap()
94 self._imageList.Add( img ) 93 self._imageList.Add( img )
95 self.SetImageList( self._imageList, wx.IMAGE_LIST_SMALL ) 94 self.SetImageList( self._imageList, wx.IMAGE_LIST_SMALL )
96 # Create our column headers 95 # Create our column headers
97 self.InsertColumn( 0, "ID" ) 96 self.InsertColumn( 0, "ID" )
98 self.InsertColumn( 1, "Player") 97 self.InsertColumn( 1, "Player")
199 if self.GetColumnWidth(2) < 75: self.SetColumnWidth(2, 75) 198 if self.GetColumnWidth(2) < 75: self.SetColumnWidth(2, 75)
200 self.Refresh() 199 self.Refresh()
201 200
202 def on_menu_password( self, evt ): 201 def on_menu_password( self, evt ):
203 id = evt.GetId() 202 id = evt.GetId()
204 self.session = open_rpg.get_component("session") 203 self.session = component.get("session")
205 self.password_manager = open_rpg.get_component("password_manager") 204 self.password_manager = component.get("password_manager")
206 self.chat = open_rpg.get_component("chat") 205 self.chat = component.get("chat")
207 boot_pwd = self.password_manager.GetPassword("admin",int(self.session.group_id)) 206 boot_pwd = self.password_manager.GetPassword("admin",int(self.session.group_id))
208 if boot_pwd != None: 207 if boot_pwd != None:
209 alter_pwd_dialog = wx.TextEntryDialog(self, 208 alter_pwd_dialog = wx.TextEntryDialog(self,
210 "Enter new room password: (blank for no password)","Alter Room Password") 209 "Enter new room password: (blank for no password)","Alter Room Password")
211 if alter_pwd_dialog.ShowModal() == wx.ID_OK: 210 if alter_pwd_dialog.ShowModal() == wx.ID_OK:
213 self.chat.InfoPost( "Requesting password change on server..." ) 212 self.chat.InfoPost( "Requesting password change on server..." )
214 self.session.set_room_pass(new_pass, boot_pwd) 213 self.session.set_room_pass(new_pass, boot_pwd)
215 214
216 def on_menu_room_rename( self, evt ): 215 def on_menu_room_rename( self, evt ):
217 id = evt.GetId() 216 id = evt.GetId()
218 self.session = open_rpg.get_component("session") 217 self.session = component.get("session")
219 self.password_manager = open_rpg.get_component("password_manager") 218 self.password_manager = component.get("password_manager")
220 self.chat = open_rpg.get_component("chat") 219 self.chat = component.get("chat")
221 boot_pwd = self.password_manager.GetPassword("admin",int(self.session.group_id)) 220 boot_pwd = self.password_manager.GetPassword("admin",int(self.session.group_id))
222 if boot_pwd != None: 221 if boot_pwd != None:
223 alter_name_dialog = wx.TextEntryDialog(self,"Enter new room name: ","Change Room Name") 222 alter_name_dialog = wx.TextEntryDialog(self,"Enter new room name: ","Change Room Name")
224 if alter_name_dialog.ShowModal() == wx.ID_OK: 223 if alter_name_dialog.ShowModal() == wx.ID_OK:
225 new_name = alter_name_dialog.GetValue() 224 new_name = alter_name_dialog.GetValue()
267 except: self.wgMenu.UpdateUI() 266 except: self.wgMenu.UpdateUI()
268 if self.wgMenu.GetMenuItemCount() == 2: WG_MENU_LIST.clear() 267 if self.wgMenu.GetMenuItemCount() == 2: WG_MENU_LIST.clear()
269 return 268 return
270 269
271 def on_menu_whispergroup( self, evt ): 270 def on_menu_whispergroup( self, evt ):
272 self.session = open_rpg.get_component("session") 271 self.session = component.get("session")
273 self.settings = open_rpg.get_component('settings') 272 self.settings = component.get('settings')
274 self.chat = open_rpg.get_component('chat') 273 self.chat = component.get('chat')
275 "Add/Remove players from Whisper Groups" 274 "Add/Remove players from Whisper Groups"
276 id = evt.GetId() 275 id = evt.GetId()
277 item = self.GetItem( self.selected_item ) 276 item = self.GetItem( self.selected_item )
278 #See if it is the main menu 277 #See if it is the main menu
279 if id == PLAYER_WG_CREATE: 278 if id == PLAYER_WG_CREATE:
296 #--------------------------------------------------------- 295 #---------------------------------------------------------
297 296
298 def on_menu_moderate( self, evt ): 297 def on_menu_moderate( self, evt ):
299 "Change the moderated status of a room or player." 298 "Change the moderated status of a room or player."
300 id = evt.GetId() 299 id = evt.GetId()
301 self.chat = open_rpg.get_component( "chat" ) 300 self.chat = component.get( "chat" )
302 self.session = open_rpg.get_component("session") 301 self.session = component.get("session")
303 playerID = self.GetItemData( self.selected_item ) 302 playerID = self.GetItemData( self.selected_item )
304 moderationString = None 303 moderationString = None
305 moderateRoomBase = "/moderate %s" 304 moderateRoomBase = "/moderate %s"
306 moderatePlayerBase = "/moderate %d=%s" 305 moderatePlayerBase = "/moderate %d=%s"
307 infoRoomBase = "Attempting to %s moderation in the current room..." 306 infoRoomBase = "Attempting to %s moderation in the current room..."
325 self.chat.chat_cmds.docmd( moderationString ) 324 self.chat.chat_cmds.docmd( moderationString )
326 # Now, provide local feedback as to what we requested 325 # Now, provide local feedback as to what we requested
327 self.chat.InfoPost( infoString ) 326 self.chat.InfoPost( infoString )
328 327
329 def on_menu_role_change( self, evt ): 328 def on_menu_role_change( self, evt ):
330 self.session = open_rpg.get_component("session") 329 self.session = component.get("session")
331 "Change the role of the selected id." 330 "Change the role of the selected id."
332 id = evt.GetId() 331 id = evt.GetId()
333 self.chat = open_rpg.get_component( "chat" ) 332 self.chat = component.get( "chat" )
334 playerID = self.GetItemData( self.selected_item ) 333 playerID = self.GetItemData( self.selected_item )
335 roleString = None 334 roleString = None
336 roleBase = "/role %d=%s" 335 roleBase = "/role %d=%s"
337 infoBase = "Attempting to assign the role of %s to (%d) %s..." 336 infoBase = "Attempting to assign the role of %s to (%d) %s..."
338 337
353 352
354 def on_d_lclick(self,evt): 353 def on_d_lclick(self,evt):
355 pos = wx.Point(evt.GetX(),evt.GetY()) 354 pos = wx.Point(evt.GetX(),evt.GetY())
356 (item, flag) = self.HitTest(pos) 355 (item, flag) = self.HitTest(pos)
357 id = self.GetItemText(item) 356 id = self.GetItemText(item)
358 self.chat = open_rpg.get_component("chat") 357 self.chat = component.get("chat")
359 self.chat.set_chat_text("/w " + id + "=") 358 self.chat.set_chat_text("/w " + id + "=")
360 359
361 def on_menu_item(self,evt): 360 def on_menu_item(self,evt):
362 id = evt.GetId() 361 id = evt.GetId()
363 self.session = open_rpg.get_component("session") 362 self.session = component.get("session")
364 self.password_manager = open_rpg.get_component("password_manager") 363 self.password_manager = component.get("password_manager")
365 364
366 if id == PLAYER_BOOT: 365 if id == PLAYER_BOOT:
367 id = str(self.GetItemData(self.selected_item)) 366 id = str(self.GetItemData(self.selected_item))
368 boot_pwd = self.password_manager.GetPassword("admin",int(self.session.group_id)) 367 boot_pwd = self.password_manager.GetPassword("admin",int(self.session.group_id))
369 if boot_pwd != None: self.session.boot_player(id,boot_pwd) 368 if boot_pwd != None: self.session.boot_player(id,boot_pwd)
370 elif id == PLAYER_WHISPER: 369 elif id == PLAYER_WHISPER:
371 id = self.GetItemText(self.selected_item) 370 id = self.GetItemText(self.selected_item)
372 self.chat = open_rpg.get_component("chat") 371 self.chat = component.get("chat")
373 self.chat.set_chat_text("/w " + id + "=") 372 self.chat.set_chat_text("/w " + id + "=")
374 elif id == PLAYER_IGNORE: 373 elif id == PLAYER_IGNORE:
375 id = str(self.GetItemData(self.selected_item)) 374 id = str(self.GetItemData(self.selected_item))
376 self.chat = open_rpg.get_component("chat") 375 self.chat = component.get("chat")
377 (result,id,name) = self.session.toggle_ignore(id) 376 (result,id,name) = self.session.toggle_ignore(id)
378 if result == 0: self.chat.Post(self.chat.colorize(self.chat.syscolor, 377 if result == 0: self.chat.Post(self.chat.colorize(self.chat.syscolor,
379 "Player " + name + " with ID:" + id +" no longer ignored")) 378 "Player " + name + " with ID:" + id +" no longer ignored"))
380 else: self.chat.Post(self.chat.colorize(self.chat.syscolor, 379 else: self.chat.Post(self.chat.colorize(self.chat.syscolor,
381 "Player " + name + " with ID:" + id +" now being ignored")) 380 "Player " + name + " with ID:" + id +" now being ignored"))
390 (item, flag) = self.HitTest(pos) 389 (item, flag) = self.HitTest(pos)
391 if item > -1: 390 if item > -1:
392 self.selected_item = item 391 self.selected_item = item
393 # This if-else block makes the menu item to boot players active or inactive, as appropriate 392 # This if-else block makes the menu item to boot players active or inactive, as appropriate
394 # This block is enabled for 1.7.8. Ver. 1.7.9 will boast Admin features. 393 # This block is enabled for 1.7.8. Ver. 1.7.9 will boast Admin features.
395 #if open_rpg.get_component("session").group_id == "0": 394 #if component.get("session").group_id == "0":
396 # self.menu.Enable(PLAYER_BOOT,0) 395 # self.menu.Enable(PLAYER_BOOT,0)
397 # self.menu.SetLabel(PLAYER_BOOT,"Can't boot from Lobby") 396 # self.menu.SetLabel(PLAYER_BOOT,"Can't boot from Lobby")
398 #else: 397 #else:
399 self.menu.Enable(PLAYER_BOOT,1) 398 self.menu.Enable(PLAYER_BOOT,1)
400 self.menu.SetLabel(PLAYER_BOOT,"Boot") 399 self.menu.SetLabel(PLAYER_BOOT,"Boot")
450 self.SetItemData(i,int(player[2])) 449 self.SetItemData(i,int(player[2]))
451 self.SetStringItem(i, 2,player[3]) 450 self.SetStringItem(i, 2,player[3])
452 self.colorize_player_list() 451 self.colorize_player_list()
453 self.Refresh() 452 self.Refresh()
454 # play sound 453 # play sound
455 setobj = open_rpg.get_component('settings') 454 setobj = component.get('settings')
456 sound_file = setobj.get_setting("AddSound") 455 sound_file = setobj.get_setting("AddSound")
457 if sound_file != '': 456 if sound_file != '':
458 sound_player = open_rpg.get_component('sound') 457 sound_player = component.get('sound')
459 sound_player.play(sound_file) 458 sound_player.play(sound_file)
460 self.AutoAdjust() 459 self.AutoAdjust()
461 460
462 def del_player(self,player): 461 def del_player(self,player):
463 i = self.FindItemData(-1,int(player[2])) 462 i = self.FindItemData(-1,int(player[2]))
471 #--------------------------------------------------------- 470 #---------------------------------------------------------
472 # [END] Digitalxero Multi Whisper Group 1/1/05 471 # [END] Digitalxero Multi Whisper Group 1/1/05
473 #--------------------------------------------------------- 472 #---------------------------------------------------------
474 473
475 # play sound 474 # play sound
476 setobj = open_rpg.get_component('settings') 475 setobj = component.get('settings')
477 sound_file = setobj.get_setting("DelSound") 476 sound_file = setobj.get_setting("DelSound")
478 if sound_file != '': 477 if sound_file != '':
479 sound_player = open_rpg.get_component('sound') 478 sound_player = component.get('sound')
480 sound_player.play(sound_file) 479 sound_player.play(sound_file)
481 ic = self.GetItemCount() 480 ic = self.GetItemCount()
482 self.whisperCount = 0 481 self.whisperCount = 0
483 index = 0 482 index = 0
484 while index < ic: 483 while index < ic:
502 item = self.GetItem(i) 501 item = self.GetItem(i)
503 self.colorize_player_list() 502 self.colorize_player_list()
504 self.AutoAdjust() 503 self.AutoAdjust()
505 504
506 def colorize_player_list(self): 505 def colorize_player_list(self):
507 session = open_rpg.get_component("session") 506 session = component.get("session")
508 settings = open_rpg.get_component('settings') 507 settings = component.get('settings')
509 mode = settings.get_setting("ColorizeRoles") 508 mode = settings.get_setting("ColorizeRoles")
510 if mode.lower() == "0": return 509 if mode.lower() == "0": return
511 players = session.players 510 players = session.players
512 for m in players.keys(): 511 for m in players.keys():
513 item_list_location = self.FindItemData(-1,int(m)) 512 item_list_location = self.FindItemData(-1,int(m))