comparison orpg/player_list.py @ 0:4385a7d0efd1 grumpy-goblin

Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
author sirebral
date Tue, 14 Jul 2009 16:41:58 -0500
parents
children d5e81dac98ff
comparison
equal deleted inserted replaced
-1:000000000000 0:4385a7d0efd1
1 #!/usr/bin/env python
2 # Copyright (C) 2000-2001 The OpenRPG Project
3 #
4 # openrpg-dev@lists.sourceforge.net
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 # --
20 #
21 # File: player_list.py
22 # Author: Chris Davis
23 # Maintainer:
24 # Version:
25 # $Id: player_list.py,v 1.29 2007/03/30 19:12:06 digitalxero Exp $
26 #
27 # Description: This is the main entry point of the oprg application
28 #
29
30 __version__ = "$Id: player_list.py,v 1.29 2007/03/30 19:12:06 digitalxero Exp $"
31
32 from orpg.orpg_windows import *
33 import orpg.dirpath
34
35 # global definitions
36 global ROLE_GM; ROLE_GM = "GM"
37 global ROLE_PLAYER; ROLE_PLAYER = "PLAYER"
38 global ROLE_LURKER; ROLE_LURKER = "LURKER"
39
40 #########################
41 #player frame window
42 #########################
43 PLAYER_BOOT = wx.NewId()
44 PLAYER_WHISPER = wx.NewId()
45 PLAYER_IGNORE = wx.NewId()
46 PLAYER_ROLE_MENU = wx.NewId()
47 PLAYER_ROLE_LURKER = wx.NewId()
48 PLAYER_ROLE_PLAYER = wx.NewId()
49 PLAYER_ROLE_GM = wx.NewId()
50 PLAYER_MODERATE_MENU = wx.NewId()
51 PLAYER_MODERATE_ROOM_ON = wx.NewId()
52 PLAYER_MODERATE_ROOM_OFF = wx.NewId()
53 PLAYER_MODERATE_GIVE_VOICE = wx.NewId()
54 PLAYER_MODERATE_TAKE_VOICE = wx.NewId()
55 PLAYER_SHOW_VERSION = wx.NewId()
56 WG_LIST = {}
57
58 #---------------------------------------------------------
59 # [START] Digitalxero Multi Whisper Group 1/1/05
60 #---------------------------------------------------------
61 PLAYER_WG_MENU = wx.NewId()
62 PLAYER_WG_CREATE = wx.NewId()
63 PLAYER_WG_CLEAR_ALL = wx.NewId()
64 WG_MENU_LIST = {}
65 #---------------------------------------------------------
66 # [END] Digitalxero Multi Whisper Group 1/1/05
67 #---------------------------------------------------------
68
69 #---------------------------------------------------------
70 # [START] Snowdog Password/Room Name altering code 12/02
71 #---------------------------------------------------------
72 PLAYER_COMMAND_MENU = wx.NewId()
73 PLAYER_COMMAND_PASSWORD_ALTER = wx.NewId()
74 PLAYER_COMMAND_ROOM_RENAME = wx.NewId()
75 #---------------------------------------------------------
76 # [END] Snowdog Password/Room Name altering code 12/02
77 #---------------------------------------------------------
78
79 class player_list(wx.ListCtrl):
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, wx.LC_REPORT|wx.SUNKEN_BORDER|wx.EXPAND|wx.LC_HRULES )
83 self.session = open_rpg.get_component("session")
84 self.settings = open_rpg.get_component('settings')
85 self.chat = open_rpg.get_component('chat')
86 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 self.whisperCount = 0
89 self._imageList = wx.ImageList( 16, 16, False )
90 img = wx.Image(orpg.dirpath.dir_struct["icon"]+"player.gif", wx.BITMAP_TYPE_GIF).ConvertToBitmap()
91 self._imageList.Add( img )
92 img = wx.Image(orpg.dirpath.dir_struct["icon"]+"player-whisper.gif", wx.BITMAP_TYPE_GIF).ConvertToBitmap()
93 self._imageList.Add( img )
94 self.SetImageList( self._imageList, wx.IMAGE_LIST_SMALL )
95 # Create our column headers
96 self.InsertColumn( 0, "ID" )
97 self.InsertColumn( 1, "Player" )
98 self.InsertColumn( 2, "Status" )
99 #---------------------------------------------------------
100 # [START] Digitalxero Multi Whisper Group 1/1/05
101 #---------------------------------------------------------
102 ##Main Menu
103 self.wgMenu = wx.Menu()
104 #Add the Base Menu items, so they are always at the bottom
105 self.wgMenu.Append(PLAYER_WG_CREATE, "Create")
106 self.wgMenu.Append(PLAYER_WG_CLEAR_ALL, "Delete All Groups")
107 #---------------------------------------------------------
108 # [END] Digitalxero Multi Whisper Group 1/1/05
109 #---------------------------------------------------------
110 # Create the role menu
111 self.roleMenu = wx.Menu()
112 self.roleMenu.SetTitle( "Assign Role" )
113 self.roleMenu.Append( PLAYER_ROLE_LURKER, "Lurker" )
114 self.roleMenu.Append( PLAYER_ROLE_PLAYER, "Player" )
115 self.roleMenu.Append( PLAYER_ROLE_GM, "GM" )
116 # Create the moderation menu
117 self.moderateMenu = wx.Menu()
118 self.moderateMenu.SetTitle( "Moderate" )
119 self.moderateMenu.Append( PLAYER_MODERATE_ROOM_ON, "Room Moderation ON" )
120 self.moderateMenu.Append( PLAYER_MODERATE_ROOM_OFF, "Room Moderation OFF" )
121 self.moderateMenu.AppendSeparator()
122 self.moderateMenu.Append( PLAYER_MODERATE_GIVE_VOICE, "Give Voice" )
123 self.moderateMenu.Append( PLAYER_MODERATE_TAKE_VOICE, "Take Voice" )
124 #---------------------------------------------------------
125 # [START] Snowdog Password/Room Name altering code 12/02
126 #---------------------------------------------------------
127 # Create the room control menu
128 self.commandMenu = wx.Menu()
129 self.commandMenu.SetTitle( "Room Controls" )
130 self.commandMenu.Append( PLAYER_COMMAND_PASSWORD_ALTER, "Password" )
131 self.commandMenu.Append( PLAYER_COMMAND_ROOM_RENAME, "Room Name" )
132 self.commandMenu.AppendSeparator()
133 #---------------------------------------------------------
134 # [END] Snowdog Password/Room Name altering code 12/02
135 #---------------------------------------------------------
136 # Create the pop up menu
137 self.menu = wx.Menu()
138 self.menu.SetTitle( "Player Menu" )
139 self.menu.Append( PLAYER_BOOT, "Boot" )
140 self.menu.AppendSeparator()
141 self.menu.Append( PLAYER_IGNORE, "Toggle &Ignore" )
142 self.menu.AppendSeparator()
143 self.menu.Append( PLAYER_WHISPER, "Whisper" )
144 #---------------------------------------------------------
145 # [START] Digitalxero Multi Whisper Group 1/1/05
146 #---------------------------------------------------------
147 self.menu.AppendMenu(PLAYER_WG_MENU, "Whisper Groups", self.wgMenu)
148 #---------------------------------------------------------
149 # [END] Digitalxero Multi Whisper Group 1/1/05
150 #---------------------------------------------------------
151 self.menu.AppendSeparator()
152 self.menu.AppendMenu( PLAYER_MODERATE_MENU, "Moderate", self.moderateMenu )
153 self.menu.AppendMenu( PLAYER_COMMAND_MENU, "Room Control", self.commandMenu )
154 self.menu.AppendSeparator()
155 self.menu.AppendMenu( PLAYER_ROLE_MENU, "Assign Role", self.roleMenu )
156 self.menu.AppendSeparator()
157 self.menu.Append( PLAYER_SHOW_VERSION, "Version" )
158 # Event processing for our menu
159 self.Bind(wx.EVT_MENU, self.on_menu_item, id=PLAYER_BOOT)
160 self.Bind(wx.EVT_MENU, self.on_menu_item, id=PLAYER_IGNORE)
161 self.Bind(wx.EVT_MENU, self.on_menu_item, id=PLAYER_WHISPER)
162 self.Bind(wx.EVT_MENU, self.on_menu_moderate, id=PLAYER_MODERATE_ROOM_ON)
163 self.Bind(wx.EVT_MENU, self.on_menu_moderate, id=PLAYER_MODERATE_ROOM_OFF)
164 self.Bind(wx.EVT_MENU, self.on_menu_moderate, id=PLAYER_MODERATE_GIVE_VOICE)
165 self.Bind(wx.EVT_MENU, self.on_menu_moderate, id=PLAYER_MODERATE_TAKE_VOICE)
166 self.Bind(wx.EVT_MENU, self.on_menu_role_change, id=PLAYER_ROLE_LURKER)
167 self.Bind(wx.EVT_MENU, self.on_menu_role_change, id=PLAYER_ROLE_PLAYER)
168 self.Bind(wx.EVT_MENU, self.on_menu_role_change, id=PLAYER_ROLE_GM)
169 self.Bind(wx.EVT_MENU, self.on_menu_item, id=PLAYER_SHOW_VERSION)
170 #---------------------------------------------------------
171 # [START] Digitalxero Multi Whisper Group 1/1/05
172 #---------------------------------------------------------
173 self.Bind(wx.EVT_MENU, self.on_menu_whispergroup, id=PLAYER_WG_CREATE)
174 self.Bind(wx.EVT_MENU, self.on_menu_whispergroup, id=PLAYER_WG_CLEAR_ALL)
175 #---------------------------------------------------------
176 # [END] Digitalxero Multi Whisper Group 1/1/05
177 #---------------------------------------------------------
178 #---------------------------------------------------------
179 # [START] Snowdog Password/Room Name altering code 12/02
180 #---------------------------------------------------------
181 self.Bind(wx.EVT_MENU, self.on_menu_password, id=PLAYER_COMMAND_PASSWORD_ALTER)
182 self.Bind(wx.EVT_MENU, self.on_menu_room_rename, id=PLAYER_COMMAND_ROOM_RENAME)
183 #---------------------------------------------------------
184 # [END] Snowdog Password/Room Name altering code 12/02
185 #---------------------------------------------------------
186 self.Bind(wx.EVT_LEFT_DCLICK, self.on_d_lclick)
187 self.Bind(wx.EVT_RIGHT_DOWN, self.on_menu)
188 self.sized = 1
189 #---------------------------------------------------------
190 # [START] Snowdog Password/Room Name altering code 12/02
191 #
192 # Revised 8/03 to add support for password manager
193 #---------------------------------------------------------
194 def on_menu_password( self, evt ):
195 id = evt.GetId()
196 self.session = open_rpg.get_component("session")
197 self.password_manager = open_rpg.get_component("password_manager")
198 self.chat = open_rpg.get_component("chat")
199 boot_pwd = self.password_manager.GetPassword("admin",int(self.session.group_id))
200 if boot_pwd != None:
201 alter_pwd_dialog = wx.TextEntryDialog(self,"Enter new room password: (blank for no password)","Alter Room Password")
202 if alter_pwd_dialog.ShowModal() == wx.ID_OK:
203 new_pass = alter_pwd_dialog.GetValue()
204 self.chat.InfoPost( "Requesting password change on server..." )
205 self.session.set_room_pass(new_pass, boot_pwd)
206
207 def on_menu_room_rename( self, evt ):
208 id = evt.GetId()
209 self.session = open_rpg.get_component("session")
210 self.password_manager = open_rpg.get_component("password_manager")
211 self.chat = open_rpg.get_component("chat")
212 boot_pwd = self.password_manager.GetPassword("admin",int(self.session.group_id))
213 if boot_pwd != None:
214 alter_name_dialog = wx.TextEntryDialog(self,"Enter new room name: ","Change Room Name")
215 if alter_name_dialog.ShowModal() == wx.ID_OK:
216 new_name = alter_name_dialog.GetValue()
217 self.chat.InfoPost( "Requesting room name change on server..." )
218 loc = new_name.find("&")
219 oldloc=0
220 while loc > -1:
221 loc = new_name.find("&",oldloc)
222 if loc > -1:
223 b = new_name[:loc]
224 e = new_name[loc+1:]
225 new_name = b + "&" + e
226 oldloc = loc +1
227 loc = new_name.find("'")
228 oldloc=0
229 while loc > -1:
230 loc = new_name.find("'",oldloc)
231 if loc > -1:
232 b = new_name[:loc]
233 e = new_name[loc+1:]
234 new_name = b + "'" + e
235 oldloc = loc +1
236 loc = new_name.find('"')
237 oldloc=0
238 while loc > -1:
239 loc = new_name.find('"',oldloc)
240 if loc > -1:
241 b = new_name[:loc]
242 e = new_name[loc+1:]
243 new_name = b + "&quote" + e
244 oldloc = loc +1
245 self.session.set_room_name(new_name, boot_pwd)
246 #---------------------------------------------------------
247 # [END] Snowdog Password/Room Name altering code 12/02
248 #---------------------------------------------------------
249
250 #---------------------------------------------------------
251 # [START] Digitalxero Multi Whisper Group 1/1/05
252 #---------------------------------------------------------
253 def clean_sub_menus(self):
254 for mid in WG_MENU_LIST:
255 try:
256 self.wgMenu.Remove(WG_MENU_LIST[mid]["menuid"])
257 WG_MENU_LIST[mid]["menu"].Destroy()
258 except:
259 self.wgMenu.UpdateUI()
260 if self.wgMenu.GetMenuItemCount() == 2:
261 WG_MENU_LIST.clear()
262 return
263
264 def on_menu_whispergroup( self, evt ):
265 self.session = open_rpg.get_component("session")
266 self.settings = open_rpg.get_component('settings')
267 self.chat = open_rpg.get_component('chat')
268 "Add/Remove players from Whisper Groups"
269 id = evt.GetId()
270 item = self.GetItem( self.selected_item )
271 #See if it is the main menu
272 if id == PLAYER_WG_CREATE:
273 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 group_name = create_new_group_dialog.GetValue()
276 WG_LIST[group_name] = {}
277 return
278 elif id == PLAYER_WG_CLEAR_ALL:
279 WG_LIST.clear()
280 return
281 #Check Sub Menus
282 for mid in WG_MENU_LIST:
283 if id == WG_MENU_LIST[mid]["add"]:
284 WG_LIST[mid][int(item.GetText())] = int(item.GetText())
285 return
286 elif id == WG_MENU_LIST[mid]["remove"]:
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
296
297 #---------------------------------------------------------
298 # [END] Digitalxero Multi Whisper Group 1/1/05
299 #---------------------------------------------------------
300
301 def on_menu_moderate( self, evt ):
302 "Change the moderated status of a room or player."
303 id = evt.GetId()
304 self.chat = open_rpg.get_component( "chat" )
305 self.session = open_rpg.get_component("session")
306 playerID = self.GetItemData( self.selected_item )
307 moderationString = None
308 moderateRoomBase = "/moderate %s"
309 moderatePlayerBase = "/moderate %d=%s"
310 infoRoomBase = "Attempting to %s moderation in the current room..."
311 infoPlayerBase = "Attempting to %s voice to %s (%d)..."
312
313 if id == PLAYER_MODERATE_ROOM_ON:
314 moderationString = (moderateRoomBase % "on")
315 infoString = (infoRoomBase % "ENABLE")
316 if id == PLAYER_MODERATE_ROOM_OFF:
317 moderationString = (moderateRoomBase % "off")
318 infoString = (infoRoomBase % "DISABLE")
319 elif id == PLAYER_MODERATE_GIVE_VOICE:
320 moderationString = (moderatePlayerBase % (playerID, "on"))
321 infoString = (infoPlayerBase % ("GIVE", self.session.get_player_by_player_id( str(playerID) )[0], playerID))
322 elif id == PLAYER_MODERATE_TAKE_VOICE:
323 moderationString = (moderatePlayerBase % (playerID, "off"))
324 infoString = (infoPlayerBase % ("TAKE", self.session.get_player_by_player_id( str(playerID) )[0], playerID))
325
326 # Now, send it to the server
327 if moderationString:
328 self.chat.chat_cmds.docmd( moderationString )
329 # Now, provide local feedback as to what we requested
330 self.chat.InfoPost( infoString )
331
332 def on_menu_role_change( self, evt ):
333 self.session = open_rpg.get_component("session")
334 "Change the role of the selected id."
335 id = evt.GetId()
336 self.chat = open_rpg.get_component( "chat" )
337 playerID = self.GetItemData( self.selected_item )
338 roleString = None
339 roleBase = "/role %d=%s"
340 infoBase = "Attempting to assign the role of %s to (%d) %s..."
341 # Do type specific processing
342 recycle_bin = {PLAYER_ROLE_LURKER: ROLE_LURKER, PLAYER_ROLE_PLAYER: ROLE_PLAYER, PLAYER_ROLE_GM: ROLE_GM}
343 if recycle_bin.has_key(id):
344 roleName = recycle_bin[id]
345 roleString = (roleBase % ( playerID, roleName ))
346 recycle_bin = {}
347
348 # Now, send it to the server
349 if roleString:
350 self.chat.chat_cmds.docmd( roleString )
351 # Now, provide local feedback as to what we requested
352 displayName = self.session.get_player_by_player_id( str(playerID) )[0]
353 infoString = (infoBase % ( roleName, playerID, displayName ))
354 self.chat.InfoPost( infoString )
355
356 def on_d_lclick(self,evt):
357 pos = wx.Point(evt.GetX(),evt.GetY())
358 (item, flag) = self.HitTest(pos)
359 id = self.GetItemText(item)
360 self.chat = open_rpg.get_component("chat")
361 self.chat.set_chat_text("/w " + id + "=")
362
363 def on_menu_item(self,evt):
364 id = evt.GetId()
365 self.session = open_rpg.get_component("session")
366 self.password_manager = open_rpg.get_component("password_manager")
367
368 if id == PLAYER_BOOT:
369 id = str(self.GetItemData(self.selected_item))
370 boot_pwd = self.password_manager.GetPassword("admin",int(self.session.group_id))
371 if boot_pwd != None:
372 self.session.boot_player(id,boot_pwd)
373 elif id == PLAYER_WHISPER:
374 id = self.GetItemText(self.selected_item)
375 self.chat = open_rpg.get_component("chat")
376 self.chat.set_chat_text("/w " + id + "=")
377 elif id == PLAYER_IGNORE:
378 id = str(self.GetItemData(self.selected_item))
379 self.chat = open_rpg.get_component("chat")
380 (result,id,name) = self.session.toggle_ignore(id)
381 if result == 0:
382 self.chat.Post(self.chat.colorize(self.chat.syscolor, "Player " + name + " with ID:" + id +" no longer ignored"))
383 else:
384 self.chat.Post(self.chat.colorize(self.chat.syscolor, "Player " + name + " with ID:" + id +" now being ignored"))
385 elif id == PLAYER_SHOW_VERSION:
386 id = str(self.GetItemData(self.selected_item))
387 version_string = self.session.players[id][6]
388 if version_string:
389 wx.MessageBox("Running client version " + version_string,"Version")
390 else:
391 wx.MessageBox("No client version available for this player","Version")
392
393 def on_menu(self, evt):
394 pos = wx.Point(evt.GetX(),evt.GetY())
395 (item, flag) = self.HitTest(pos)
396 if item > -1:
397 self.selected_item = item
398 # This if-else block makes the menu item to boot players active or inactive, as appropriate
399 # This block is enabled for 1.7.8. Ver. 1.7.9 will boast Admin features.
400 #if open_rpg.get_component("session").group_id == "0":
401 # self.menu.Enable(PLAYER_BOOT,0)
402 # self.menu.SetLabel(PLAYER_BOOT,"Can't boot from Lobby")
403 #else:
404 self.menu.Enable(PLAYER_BOOT,1)
405 self.menu.SetLabel(PLAYER_BOOT,"Boot")
406 #---------------------------------------------------------
407 # [START] Digitalxero Multi Whisper Group 1/1/05
408 #---------------------------------------------------------
409 self.menu.Enable(PLAYER_WG_MENU, True)
410 item = self.GetItem( self.selected_item )
411 if len(WG_MENU_LIST) > len(WG_LIST):
412 self.clean_sub_menus()
413 if len(WG_LIST) == 0:
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:
418 if not WG_MENU_LIST.has_key(gid):
419 WG_MENU_LIST[gid] = {}
420 WG_MENU_LIST[gid]["menuid"] = wx.NewId()
421 WG_MENU_LIST[gid]["whisper"] = wx.NewId()
422 WG_MENU_LIST[gid]["add"] = wx.NewId()
423 WG_MENU_LIST[gid]["remove"] = wx.NewId()
424 WG_MENU_LIST[gid]["clear"] = wx.NewId()
425 WG_MENU_LIST[gid]["menu"] = wx.Menu()
426 WG_MENU_LIST[gid]["menu"].SetTitle(gid)
427 WG_MENU_LIST[gid]["menu"].Append(WG_MENU_LIST[gid]["whisper"], "Whisper")
428 WG_MENU_LIST[gid]["menu"].Append(WG_MENU_LIST[gid]["add"], "Add")
429 WG_MENU_LIST[gid]["menu"].Append(WG_MENU_LIST[gid]["remove"], "Remove")
430 WG_MENU_LIST[gid]["menu"].Append(WG_MENU_LIST[gid]["clear"], "Clear")
431 self.wgMenu.PrependMenu(WG_MENU_LIST[gid]["menuid"], gid, WG_MENU_LIST[gid]["menu"])
432 if WG_LIST[gid].has_key(int(item.GetText())):
433 WG_MENU_LIST[gid]["menu"].Enable(WG_MENU_LIST[gid]["remove"], True)
434 WG_MENU_LIST[gid]["menu"].Enable(WG_MENU_LIST[gid]["add"], False)
435 else:
436 WG_MENU_LIST[gid]["menu"].Enable(WG_MENU_LIST[gid]["remove"], False)
437 WG_MENU_LIST[gid]["menu"].Enable(WG_MENU_LIST[gid]["add"], True)
438 if len(WG_LIST[gid]) == 0:
439 WG_MENU_LIST[gid]["menu"].Enable(WG_MENU_LIST[gid]["whisper"], False)
440 WG_MENU_LIST[gid]["menu"].Enable(WG_MENU_LIST[gid]["clear"], False)
441 else:
442 WG_MENU_LIST[gid]["menu"].Enable(WG_MENU_LIST[gid]["whisper"], True)
443 WG_MENU_LIST[gid]["menu"].Enable(WG_MENU_LIST[gid]["clear"], True)
444
445 #Event Stuff
446 self.Bind(wx.EVT_MENU, self.on_menu_whispergroup, id=WG_MENU_LIST[gid]["whisper"] )
447 self.Bind(wx.EVT_MENU, self.on_menu_whispergroup, id=WG_MENU_LIST[gid]["add"] )
448 self.Bind(wx.EVT_MENU, self.on_menu_whispergroup, id=WG_MENU_LIST[gid]["remove"] )
449 self.Bind(wx.EVT_MENU, self.on_menu_whispergroup, id=WG_MENU_LIST[gid]["clear"] )
450 #---------------------------------------------------------
451 # [END] Digitalxero Multi Whisper Group 1/1/05
452 #---------------------------------------------------------
453 self.PopupMenu(self.menu,pos)
454
455 def add_player(self,player):
456 i = self.InsertImageStringItem(0,player[2],0)
457 self.SetStringItem(i,1,self.strip_html(player))
458 self.SetItemData(i,int(player[2]))
459 self.SetStringItem(i, 2,player[3])
460 self.colorize_player_list()
461 self.Refresh()
462 # play sound
463 setobj = open_rpg.get_component('settings')
464 sound_file = setobj.get_setting("AddSound")
465 if sound_file != '':
466 sound_player = open_rpg.get_component('sound')
467 sound_player.play(sound_file)
468
469 def del_player(self,player):
470 i = self.FindItemData(-1,int(player[2]))
471 self.DeleteItem(i)
472
473 #---------------------------------------------------------
474 # [START] Digitalxero Multi Whisper Group 1/1/05
475 #---------------------------------------------------------
476 for gid in WG_LIST:
477 if WG_LIST[gid].has_key(int(player[2])):
478 del WG_LIST[gid][int(player[2])]
479 #---------------------------------------------------------
480 # [END] Digitalxero Multi Whisper Group 1/1/05
481 #---------------------------------------------------------
482
483 # play sound
484 setobj = open_rpg.get_component('settings')
485 sound_file = setobj.get_setting("DelSound")
486 if sound_file != '':
487 sound_player = open_rpg.get_component('sound')
488 sound_player.play(sound_file)
489 ic = self.GetItemCount()
490 self.whisperCount = 0
491 index = 0
492 while index < ic:
493 item = self.GetItem( index )
494 if item.GetImage():
495 self.whisperCount += 1
496 index += 1
497 self.colorize_player_list()
498 self.Refresh()
499
500 # This method updates the player info
501 #
502 # self: reference to this PlayerList
503 # player: reference to a player structure(list)
504 #
505 # Returns: None
506 #
507 def update_player(self,player):
508 i = self.FindItemData(-1,int(player[2])) # finds the right list box index
509 self.SetStringItem(i,1,self.strip_html(player))
510 self.SetStringItem(i,2,player[3])
511 item = self.GetItem(i)
512 self.colorize_player_list()
513 self.Refresh()
514
515 def colorize_player_list(self):
516 session = open_rpg.get_component("session")
517 settings = open_rpg.get_component('settings')
518 mode = settings.get_setting("ColorizeRoles")
519 if mode.lower() == "off":
520 return
521 gmColor = settings.get_setting("GMRoleColor")
522 plColor = settings.get_setting("PlayerRoleColor")
523 lkColor = settings.get_setting("LurkerRoleColor")
524 players = session.players
525 for m in players.keys():
526 item_list_location = self.FindItemData(-1,int(m))
527 if item_list_location == -1: continue
528 player_info = session.get_player_by_player_id(m)
529 item = self.GetItem(item_list_location)
530 role = player_info[7].lower()
531 color = wx.GREEN
532 if self.session.group_id != "0":
533 recycle_bin = {'lurker': lkColor, 'player': plColor, 'gm': gmColor }
534 item.SetTextColour(recycle_bin[role])
535 recycle_bin = {}
536 self.SetItem(item)
537
538 def reset(self):
539 self.whisperCount = 0
540 #---------------------------------------------------------
541 # [START] Digitalxero Multi Whisper Group 1/1/05
542 #---------------------------------------------------------
543 WG_LIST.clear()
544 #---------------------------------------------------------
545 # [END] Digitalxero Multi Whisper Group 1/1/05
546 #---------------------------------------------------------
547 self.DeleteAllItems()
548
549 def strip_html(self,player):
550 ret_string = ""
551 x = 0
552 in_tag = 0
553 for x in range(len(player[0])) :
554 if player[0][x] == "<" or player[0][x] == ">" or in_tag == 1 :
555 if player[0][x] == "<" :
556 in_tag = 1
557 elif player[0][x] == ">" :
558 in_tag = 0
559 else :
560 pass
561 else :
562 ret_string = ret_string + player[0][x]
563 return ret_string
564
565 def size_cols(self):
566 ## # moved skip here to see if it breaks
567 ## w,h = self.GetClientSizeTuple()
568 ## w /= 8
569 ## self.SetColumnWidth( 0, w*2 )
570 ## self.SetColumnWidth( 1, w*2 )
571 ## self.SetColumnWidth( 2, w*3 )
572 pass