changeset 1379:da2ea16fabc6

quick_frontend: display MUC games symbols
author souliane <souliane@mailoo.org>
date Fri, 20 Mar 2015 16:29:03 +0100
parents 3dae6964c071
children 8aa32bcc3a9c
files frontends/src/quick_frontend/quick_chat.py frontends/src/quick_frontend/quick_games.py frontends/src/tools/games.py
diffstat 3 files changed, 15 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/frontends/src/quick_frontend/quick_chat.py	Fri Mar 20 16:28:19 2015 +0100
+++ b/frontends/src/quick_frontend/quick_chat.py	Fri Mar 20 16:29:03 2015 +0100
@@ -48,7 +48,7 @@
         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)
--- a/frontends/src/quick_frontend/quick_games.py	Fri Mar 20 16:28:19 2015 +0100
+++ b/frontends/src/quick_frontend/quick_games.py	Fri Mar 20 16:29:03 2015 +0100
@@ -23,6 +23,7 @@
 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 @@
         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:
--- a/frontends/src/tools/games.py	Fri Mar 20 16:28:19 2015 +0100
+++ b/frontends/src/tools/games.py	Fri Mar 20 16:29:03 2015 +0100
@@ -76,4 +76,4 @@
 
 
 # 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"♦"]}