Mercurial > libervia-backend
diff frontends/src/primitivus/chat.py @ 1360:8ea8fa13c351 frontends_multi_profiles
frontends (quick_frontend, primitivus): fixes room games:
- add quick_frontend.quick_games for registering the signals and registering the UI classes
- rename the signals handlers to fit the convention (e.g.: tarotGameScoreHandler)
- rename card_game to game_tarot, quick_card_game to quick_game_tarot, CardGame to TarotGame
author | souliane <souliane@mailoo.org> |
---|---|
date | Wed, 11 Mar 2015 12:43:48 +0100 |
parents | faa1129559b8 |
children | d3e9848b9574 |
line wrap: on
line diff
--- a/frontends/src/primitivus/chat.py Wed Mar 11 12:36:22 2015 +0100 +++ b/frontends/src/primitivus/chat.py Wed Mar 11 12:43:48 2015 +0100 @@ -25,7 +25,8 @@ from urwid_satext.files_management import FileDialog from sat_frontends.quick_frontend import quick_widgets from sat_frontends.quick_frontend.quick_chat import QuickChat -from sat_frontends.primitivus.card_game import CardGame +from sat_frontends.quick_frontend import quick_games +from sat_frontends.primitivus import game_tarot from sat_frontends.primitivus.constants import Const as C from sat_frontends.primitivus.keys import action_key_map as a_key from sat_frontends.primitivus.widget import PrimitivusWidget @@ -197,13 +198,21 @@ self.chat_colums.contents.remove((widget, options)) break - def _appendGamePanel(self, widget): + def addGamePanel(self, widget): + """Insert a game panel to this Chat dialog. + + @param widget (Widget): the game panel + """ assert (len(self.pile.contents) == 1) - self.pile.contents.insert(0,(widget,('weight', 1))) - self.pile.contents.insert(1,(urwid.Filler(urwid.Divider('-'),('fixed', 1)))) + self.pile.contents.insert(0, (widget, ('weight', 1))) + self.pile.contents.insert(1, (urwid.Filler(urwid.Divider('-'), ('fixed', 1)))) self.host.redraw() - def _removeGamePanel(self): + def removeGamePanel(self, widget): + """Remove the game panel from this Chat dialog. + + @param widget (Widget): the game panel + """ assert (len(self.pile.contents) == 3) del self.pile.contents[0] self.host.redraw() @@ -333,18 +342,6 @@ elif self.getUserNick().lower() in msg.lower(): self.host.x_notify.sendNotification(_("Primitivus: %(user)s mentioned you in room '%(room)s'") % {'user': from_jid, 'room': self.target}) - def startGame(self, game_type, referee, players): - """Configure the chat window to start a game""" - if game_type=="Tarot": - self.tarot_wid = CardGame(self, referee, players, self.nick) - self._appendGamePanel(self.tarot_wid) - - def getGame(self, game_type): - """Return class managing the game type""" - #TODO: check that the game is launched, and manage errors - if game_type=="Tarot": - return self.tarot_wid - #MENU EVENTS# def onTarotRequest(self, menu): # TODO: move this to plugin_misc_tarot with dynamic menu @@ -379,3 +376,4 @@ quick_widgets.register(QuickChat, Chat) +quick_widgets.register(quick_games.Tarot, game_tarot.TarotGame)