Mercurial > libervia-backend
comparison frontends/src/primitivus/card_game.py @ 1106:e2e1e27a3680
frontends: XMLUI refactoring + dialogs:
- there are now XMLUIPanel and XMLUIDialog both inheriting from XMLUIBase
- following dialogs are managed:
- MessageDialog
- NoteDialog
- ConfirmDialog
- FileDialog
- XMLUI creation is now made using xmlui.create(...) instead of instanciating directly XMLUI
- classes must be registed in frontends
- "parent" attribute renamed to "_xmlui_parent" to avoid name conflicts with frontends toolkits
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 13 Aug 2014 14:48:49 +0200 |
parents | b12706d164d7 |
children | c0f15e52695a |
comparison
equal
deleted
inserted
replaced
1105:018bdd687747 | 1106:e2e1e27a3680 |
---|---|
20 from sat.core.i18n import _ | 20 from sat.core.i18n import _ |
21 import urwid | 21 import urwid |
22 from urwid_satext import sat_widgets | 22 from urwid_satext import sat_widgets |
23 from sat_frontends.tools.games import TarotCard | 23 from sat_frontends.tools.games import TarotCard |
24 from sat_frontends.quick_frontend.quick_card_game import QuickCardGame | 24 from sat_frontends.quick_frontend.quick_card_game import QuickCardGame |
25 from sat_frontends.primitivus.xmlui import XMLUI | 25 from sat_frontends.primitivus import xmlui |
26 | 26 |
27 | 27 |
28 class CardDisplayer(urwid.Text): | 28 class CardDisplayer(urwid.Text): |
29 """Show a card""" | 29 """Show a card""" |
30 signals = ['click'] | 30 signals = ['click'] |
267 QuickCardGame.contratSelected(self, contrat) | 267 QuickCardGame.contratSelected(self, contrat) |
268 | 268 |
269 def chooseContrat(self, xml_data): | 269 def chooseContrat(self, xml_data): |
270 """Called when the player has to select his contrat | 270 """Called when the player has to select his contrat |
271 @param xml_data: SàT xml representation of the form""" | 271 @param xml_data: SàT xml representation of the form""" |
272 form = XMLUI(self.parent.host, xml_data, title=_('Please choose your contrat'), flags=['NO_CANCEL']) | 272 form = xmlui.create(self.parent.host, xml_data, title=_('Please choose your contrat'), flags=['NO_CANCEL']) |
273 form.show(valign='top') | 273 form.show(valign='top') |
274 | 274 |
275 def showCards(self, game_stage, cards, data): | 275 def showCards(self, game_stage, cards, data): |
276 """Display cards in the middle of the game (to show for e.g. chien ou poignée)""" | 276 """Display cards in the middle of the game (to show for e.g. chien ou poignée)""" |
277 QuickCardGame.showCards(self, game_stage, cards, data) | 277 QuickCardGame.showCards(self, game_stage, cards, data) |
286 @param xml_data: SàT xml representation of the form""" | 286 @param xml_data: SàT xml representation of the form""" |
287 if not winners and not loosers: | 287 if not winners and not loosers: |
288 title = _("Draw game") | 288 title = _("Draw game") |
289 else: | 289 else: |
290 title = _('You win \o/') if self.player_nick in winners else _('You loose :(') | 290 title = _('You win \o/') if self.player_nick in winners else _('You loose :(') |
291 form = XMLUI(self.parent.host, xml_data, title=title, flags=['NO_CANCEL']) | 291 form = xmlui.create(self.parent.host, xml_data, title=title, flags=['NO_CANCEL']) |
292 form.show() | 292 form.show() |
293 | 293 |
294 def invalidCards(self, phase, played_cards, invalid_cards): | 294 def invalidCards(self, phase, played_cards, invalid_cards): |
295 """Invalid cards have been played | 295 """Invalid cards have been played |
296 @param phase: phase of the game | 296 @param phase: phase of the game |