本文整理汇总了Python中horizons.gui.util.LazyWidgetsDict.reload方法的典型用法代码示例。如果您正苦于以下问题:Python LazyWidgetsDict.reload方法的具体用法?Python LazyWidgetsDict.reload怎么用?Python LazyWidgetsDict.reload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类horizons.gui.util.LazyWidgetsDict
的用法示例。
在下文中一共展示了LazyWidgetsDict.reload方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Gui
# 需要导入模块: from horizons.gui.util import LazyWidgetsDict [as 别名]
# 或者: from horizons.gui.util.LazyWidgetsDict import reload [as 别名]
#.........这里部分代码省略.........
def load_game(self):
saved_game = self.show_select_savegame(mode="load")
if saved_game is None:
return False # user aborted dialog
self.show_loading_screen()
options = StartGameOptions(saved_game)
horizons.main.start_singleplayer(options)
return True
def toggle_pause(self):
"""Shows in-game pause menu if the game is currently not paused.
Else unpauses and hides the menu. Multiple layers of the 'paused' concept exist;
if two widgets are opened which would both pause the game, we do not want to
unpause after only one of them is closed. Uses PauseCommand and UnPauseCommand.
"""
# TODO: logically, this now belongs to the ingame_gui (it used to be different)
# this manifests itself by the need for the __pause_displayed hack below
# in the long run, this should be moved, therefore eliminating the hack, and
# ensuring correct setup/teardown.
if self.__pause_displayed:
self.__pause_displayed = False
self.hide()
self.current = None
UnPauseCommand(suggestion=True).execute(self.session)
self.on_escape = self.toggle_pause
else:
self.__pause_displayed = True
# reload the menu because caching creates spacing problems
# see http://trac.unknown-horizons.org/t/ticket/1047
in_editor_mode = self.session.in_editor_mode()
menu_name = "editor_pause_menu" if in_editor_mode else "ingamemenu"
self.widgets.reload(menu_name)
def do_load():
did_load = self.load_game()
if did_load:
self.__pause_displayed = False
def do_load_map():
self.show_editor_start_menu(False)
def do_quit():
did_quit = self.quit_session()
if did_quit:
self.__pause_displayed = False
events = { # needed twice, save only once here
"e_load": do_load_map if in_editor_mode else do_load,
"e_save": self.session.ingame_gui.show_save_map_dialog if in_editor_mode else self.save_game,
"e_sett": self.show_settings,
"e_help": self.on_help,
"e_start": self.toggle_pause,
"e_quit": do_quit,
}
self._switch_current_widget(
menu_name,
center=True,
show=False,
event_map={
# icons
"loadgameButton": events["e_load"],
"savegameButton": events["e_save"],
"settingsLink": events["e_sett"],
"helpLink": events["e_help"],
示例2: Gui
# 需要导入模块: from horizons.gui.util import LazyWidgetsDict [as 别名]
# 或者: from horizons.gui.util.LazyWidgetsDict import reload [as 别名]
class Gui(SingleplayerMenu, MultiplayerMenu):
"""This class handles all the out of game menu, like the main and pause menu, etc.
"""
log = logging.getLogger("gui")
# styles to apply to a widget
styles = {
'mainmenu': 'menu',
'requirerestart': 'book',
'ingamemenu': 'headline',
'help': 'book',
'singleplayermenu': 'book',
'sp_random': 'book',
'sp_scenario': 'book',
'sp_campaign': 'book',
'sp_free_maps': 'book',
'multiplayermenu' : 'book',
'multiplayer_creategame' : 'book',
'multiplayer_gamelobby' : 'book',
'playerdataselection' : 'book',
'aidataselection' : 'book',
'select_savegame': 'book',
'ingame_pause': 'book',
'game_settings' : 'book',
# 'credits': 'book',
}
def __init__(self):
self.mainlistener = MainListener(self)
self.current = None # currently active window
self.widgets = LazyWidgetsDict(self.styles) # access widgets with their filenames without '.xml'
build_help_strings(self.widgets['help'])
self.session = None
self.current_dialog = None
self.dialog_executed = False
self.__pause_displayed = False
self._background_image = self._get_random_background()
GuiAction.subscribe( self._on_gui_action )
# basic menu widgets
def show_main(self):
"""Shows the main menu """
self._switch_current_widget('mainmenu', center=True, show=True, event_map={
'startSingle' : self.show_single, # first is the icon in menu
'start' : self.show_single, # second is the lable in menu
'startMulti' : self.show_multi,
'start_multi' : self.show_multi,
'settingsLink' : self.show_settings,
'settings' : self.show_settings,
'helpLink' : self.on_help,
'help' : self.on_help,
'closeButton' : self.show_quit,
'quit' : self.show_quit,
'dead_link' : self.on_chime, # call for help; SoC information
'chimebell' : self.on_chime,
'creditsLink' : self.show_credits,
'credits' : self.show_credits,
'loadgameButton' : horizons.main.load_game,
'loadgame' : horizons.main.load_game,
'changeBackground' : self.get_random_background_by_button
})
self.on_escape = self.show_quit
def toggle_pause(self):
"""
Show Pause menu
"""
# TODO: logically, this now belongs to the ingame_gui (it used to be different)
# this manifests itself by the need for the __pause_displayed hack below
# in the long run, this should be moved, therefore eliminating the hack, and
# ensuring correct setup/teardown.
if self.__pause_displayed:
self.__pause_displayed = False
self.hide()
self.current = None
UnPauseCommand(suggestion=True).execute(self.session)
self.on_escape = self.toggle_pause
else:
self.__pause_displayed = True
# reload the menu because caching creates spacing problems
# see http://trac.unknown-horizons.org/t/ticket/1047
self.widgets.reload('ingamemenu')
def do_load():
did_load = horizons.main.load_game()
if did_load:
self.__pause_displayed = False
def do_quit():
did_quit = self.quit_session()
if did_quit:
self.__pause_displayed = False
events = { # needed twice, save only once here
'e_load' : do_load,
'e_save' : self.save_game,
'e_sett' : self.show_settings,
#.........这里部分代码省略.........
示例3: Gui
# 需要导入模块: from horizons.gui.util import LazyWidgetsDict [as 别名]
# 或者: from horizons.gui.util.LazyWidgetsDict import reload [as 别名]
#.........这里部分代码省略.........
self.on_escape = self.show_quit
def load_game(self):
saved_game = self.show_select_savegame(mode='load')
if saved_game is None:
return False # user aborted dialog
self.show_loading_screen()
options = StartGameOptions(saved_game)
horizons.main.start_singleplayer(options)
return True
def toggle_pause(self):
"""Shows in-game pause menu if the game is currently not paused.
Else unpauses and hides the menu. Multiple layers of the 'paused' concept exist;
if two widgets are opened which would both pause the game, we do not want to
unpause after only one of them is closed. Uses PauseCommand and UnPauseCommand.
"""
# TODO: logically, this now belongs to the ingame_gui (it used to be different)
# this manifests itself by the need for the __pause_displayed hack below
# in the long run, this should be moved, therefore eliminating the hack, and
# ensuring correct setup/teardown.
if self.__pause_displayed:
self.__pause_displayed = False
self.hide()
self.current = None
UnPauseCommand(suggestion=True).execute(self.session)
self.on_escape = self.toggle_pause
else:
self.__pause_displayed = True
# reload the menu because caching creates spacing problems
# see http://trac.unknown-horizons.org/t/ticket/1047
self.widgets.reload('ingamemenu')
def do_load():
did_load = self.load_game()
if did_load:
self.__pause_displayed = False
def do_quit():
did_quit = self.quit_session()
if did_quit:
self.__pause_displayed = False
events = { # needed twice, save only once here
'e_load' : do_load,
'e_save' : self.save_game,
'e_sett' : self.show_settings,
'e_help' : self.on_help,
'e_start': self.toggle_pause,
'e_quit' : do_quit,
}
self._switch_current_widget('ingamemenu', center=True, show=False, event_map={
# icons
'loadgameButton' : events['e_load'],
'savegameButton' : events['e_save'],
'settingsLink' : events['e_sett'],
'helpLink' : events['e_help'],
'startGame' : events['e_start'],
'closeButton' : events['e_quit'],
# labels
'loadgame' : events['e_load'],
'savegame' : events['e_save'],
'settings' : events['e_sett'],
'help' : events['e_help'],
'start' : events['e_start'],
'quit' : events['e_quit'],
})