Mercurial > libervia-web
diff browser_side/panels.py @ 275:a763b2ac5d41
bridge + browser_side: bridge signals for games and their callbacks:
- added radiocolPlayers and tarotGamePlayers to get the list of players
- added roomLeft to remove the muc from the host's room list
- display symbols to identify the players in a muc
- factorization of ChatPanel.startGame
author | souliane <souliane@mailoo.org> |
---|---|
date | Thu, 21 Nov 2013 16:13:14 +0100 |
parents | 11718798ab8a |
children | aebb96bfa8d1 |
line wrap: on
line diff
--- a/browser_side/panels.py Thu Nov 21 16:05:14 2013 +0100 +++ b/browser_side/panels.py Thu Nov 21 16:13:14 2013 +0100 @@ -52,6 +52,7 @@ from plugin_xep_0085 import ChatStateMachine from pyjamas import Window from __pyjamas__ import doc +from sat.tools.frontends.games import SYMBOLS class UniBoxPanel(HorizontalPanel): @@ -837,22 +838,23 @@ self.content.add(ChatText(timestamp, nick, mymess, msg, extra.get('xhtml'))) self.content_scroll.scrollToBottom() - def startGame(self, game_type, referee, players): + def startGame(self, game_type, referee, players, waiting=False): """Configure the chat window to start a game""" - if game_type == "Tarot": - if hasattr(self, "tarot_panel"): - return - self.tarot_panel = CardPanel(self, referee, players, self.nick) - self.vpanel.insert(self.tarot_panel, 0) - self.vpanel.setCellHeight(self.tarot_panel, self.tarot_panel.getHeight()) - elif game_type == "RadioCol": - # XXX: We can have double panel if we join quickly enough to have the group chat start signal - # on invitation + the one triggered on room join - if hasattr(self, "radiocol_panel"): - return - self.radiocol_panel = RadioColPanel(self, referee, self.nick) - self.vpanel.insert(self.radiocol_panel, 0) - self.vpanel.setCellHeight(self.radiocol_panel, self.radiocol_panel.getHeight()) + classes = {"Tarot": CardPanel, "RadioCol": RadioColPanel} + if game_type not in classes.keys(): + return # unknown game + attr = game_type.lower() + self.occupants_list.addSpecials(players, SYMBOLS[attr]) + if waiting or not self.nick in players: + return # waiting for player or not playing + attr = "%s_panel" % attr + if hasattr(self, attr): + return + print ("%s Game Started \o/" % game_type) + panel = classes[game_type](self, referee, self.nick, players) + setattr(self, attr, panel) + self.vpanel.insert(panel, 0) + self.vpanel.setCellHeight(panel, panel.getHeight()) def getGame(self, game_type): """Return class managing the game type"""