quick_frontend: display MUC games symbols

This commit is contained in:
souliane 2015-03-20 16:29:03 +01:00
commit d24eb9976d
3 changed files with 15 additions and 3 deletions

View file

@ -48,7 +48,7 @@ class QuickChat(quick_widgets.QuickWidget):
self.type = type_
self.id = "" # FIXME: to be removed
self.nick = None
self.games = {}
self.games = {} # key=game name (unicode), value=instance of quick_games.RoomGame
def __str__(self):
return u"Chat Widget [target: {}, type: {}, profile: {}]".format(self.target, self.type, self.profile)

View file

@ -23,6 +23,7 @@ log = getLogger(__name__)
from sat.core.i18n import _
from sat_frontends.tools import jid
from sat_frontends.tools import games
from sat_frontends.quick_frontend.constants import Const as C
import quick_chat
@ -53,7 +54,18 @@ class RoomGame(object):
referee, players, args = args[0], args[1], args[2:]
chat_widget = host.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_=C.CHAT_GROUP, profile=profile)
# self.occupants_panel.updateSpecials(players, SYMBOLS[self._game_name.lower()]) # FIXME
# update symbols
if cls._game_name not in chat_widget.visible_states:
chat_widget.visible_states.append(cls._game_name)
symbols = games.SYMBOLS[cls._game_name]
index = 0
for occupant in chat_widget.occupants:
occupant_jid = jid.newResource(room_jid, occupant)
if occupant in players:
chat_widget.updateEntityState(occupant_jid, cls._game_name, symbols[index % len(symbols)])
else:
chat_widget.updateEntityState(occupant_jid, cls._game_name, None)
if suffix == "Players" or chat_widget.nick not in players:
return # waiting for other players to join, or not playing
if cls._game_name in chat_widget.games:

View file

@ -76,4 +76,4 @@ class TarotCard(object):
# These symbols are diplayed by Libervia next to the player's nicknames
SYMBOLS = {"radiocol": u"♬", "tarot": [u"♠", u"♣", u"♥", u"♦"]}
SYMBOLS = {"Radiocol": [u"♬"], "Tarot": [u"♠", u"♣", u"♥", u"♦"]}