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
This commit is contained in:
parent
5ef7999fa7
commit
e597a804d9
1 changed files with 183 additions and 198 deletions
|
|
@ -25,7 +25,8 @@ from urwid_satext import sat_widgets
|
|||
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 @@ class Chat(PrimitivusWidget, QuickChat):
|
|||
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 @@ class Chat(PrimitivusWidget, QuickChat):
|
|||
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 @@ class Chat(PrimitivusWidget, QuickChat):
|
|||
|
||||
|
||||
quick_widgets.register(QuickChat, Chat)
|
||||
quick_widgets.register(quick_games.Tarot, game_tarot.TarotGame)
|
||||
|
|
|
|||
Loading…
Reference in a new issue