Mercurial > libervia-web
comparison src/browser/sat_browser/game_tarot.py @ 676:849ffb24d5bf frontends_multi_profiles
browser side: menus refactorisation:
- use of the new quick_frontends.quick_menus module, resulting in a big code simplification in Libervia
- menu are added in there respective modules: main menus are done directely in libervia_main, while tarot and radiocol menus are done in game_tarot and game_radiocol
- launchAction has the same signature as in QuickApp
- base_menu: there are now 2 classes to launch an action: MenuCmd which manage quick_menus classes, and SimpleCmd to launch a generic callback
- base_menu: MenuNode has been removed as logic is now in quick_menus
- base_menu: GenericMenuBar.update method can be called to fully (re)build the menus
- base_widget: removed WidgetSubMenuBar which is no more useful (GenericMenuBar do the same thing)
- plugin_menu_context is used in LiberviaWidget and other classes with menus to indicate which menu types must be used
- otr menus hooks are temporarily removed, will be fixed soon
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 17 Mar 2015 20:42:02 +0100 |
parents | b39a9eddfe56 |
children | e876f493dccc |
comparison
equal
deleted
inserted
replaced
675:941e53b3af5c | 676:849ffb24d5bf |
---|---|
19 | 19 |
20 import pyjd # this is dummy in pyjs | 20 import pyjd # this is dummy in pyjs |
21 from sat.core.log import getLogger | 21 from sat.core.log import getLogger |
22 log = getLogger(__name__) | 22 log = getLogger(__name__) |
23 | 23 |
24 from sat.core.i18n import _ | 24 from sat.core.i18n import _, D_ |
25 from sat_frontends.tools.games import TarotCard | 25 from sat_frontends.tools.games import TarotCard |
26 from sat_frontends.tools import host_listener | |
26 | 27 |
27 from pyjamas.ui.AbsolutePanel import AbsolutePanel | 28 from pyjamas.ui.AbsolutePanel import AbsolutePanel |
28 from pyjamas.ui.DockPanel import DockPanel | 29 from pyjamas.ui.DockPanel import DockPanel |
29 from pyjamas.ui.SimplePanel import SimplePanel | 30 from pyjamas.ui.SimplePanel import SimplePanel |
30 from pyjamas.ui.Image import Image | 31 from pyjamas.ui.Image import Image |
32 from pyjamas.ui.ClickListener import ClickHandler | 33 from pyjamas.ui.ClickListener import ClickHandler |
33 from pyjamas.ui.MouseListener import MouseHandler | 34 from pyjamas.ui.MouseListener import MouseHandler |
34 from pyjamas.ui import HasAlignment | 35 from pyjamas.ui import HasAlignment |
35 from pyjamas import Window | 36 from pyjamas import Window |
36 from pyjamas import DOM | 37 from pyjamas import DOM |
38 from constants import Const as C | |
37 | 39 |
38 import dialog | 40 import dialog |
39 import xmlui | 41 import xmlui |
40 | 42 |
41 | 43 |
384 title = "You <b>loose</b> :(" | 386 title = "You <b>loose</b> :(" |
385 body = xmlui.create(self._parent.host, xml_data, title=title, flags=['NO_CANCEL']) | 387 body = xmlui.create(self._parent.host, xml_data, title=title, flags=['NO_CANCEL']) |
386 _dialog = dialog.GenericDialog(title, body, options=['NO_CLOSE']) | 388 _dialog = dialog.GenericDialog(title, body, options=['NO_CLOSE']) |
387 body.setCloseCb(_dialog.close) | 389 body.setCloseCb(_dialog.close) |
388 _dialog.show() | 390 _dialog.show() |
391 | |
392 | |
393 ## Menu | |
394 | |
395 def hostReady(host): | |
396 def onTarotGame(): | |
397 def onPlayersSelected(room_jid, other_players): | |
398 other_players = [unicode(contact) for contact in other_players] | |
399 room_jid_s = unicode(room_jid) if room_jid else '' | |
400 host.bridge.launchTarotGame(other_players, room_jid_s, profile=C.PROF_KEY_NONE) | |
401 dialog.RoomAndContactsChooser(host, onPlayersSelected, 3, title="Tarot", title_invite=_(u"Please select 3 other players"), visible=(False, True)) | |
402 | |
403 | |
404 def gotMenus(): | |
405 host.menus.addMenu(C.MENU_GLOBAL, (D_(u"Games"), D_(u"Tarot")), callback=onTarotGame) | |
406 host.addListener('gotMenus', gotMenus) | |
407 | |
408 host_listener.addListener(hostReady) |