本文整理汇总了Python中fife.extensions.pychan.widgets.Icon.isVisible方法的典型用法代码示例。如果您正苦于以下问题:Python Icon.isVisible方法的具体用法?Python Icon.isVisible怎么用?Python Icon.isVisible使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fife.extensions.pychan.widgets.Icon
的用法示例。
在下文中一共展示了Icon.isVisible方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from fife.extensions.pychan.widgets import Icon [as 别名]
# 或者: from fife.extensions.pychan.widgets.Icon import isVisible [as 别名]
class Background:
"""
Display a centered background image on top of a black screen.
"""
def __init__(self):
available_images = glob.glob('content/gui/images/background/mainmenu/bg_*.png')
self.bg_images = deque(available_images)
latest_bg = horizons.globals.fife.get_uh_setting("LatestBackground")
try:
# If we know the current background from an earlier session,
# show all other available ones before picking that one again.
self.bg_images.remove(latest_bg)
self.bg_images.append(latest_bg)
except ValueError:
pass
(res_width, res_height) = horizons.globals.fife.get_fife_setting('ScreenResolution').split('x')
self._black_box = Container()
self._black_box.size = int(res_width), int(res_height)
self._black_box.base_color = (0, 0, 0, 255)
self._image = Icon(position_technique='center:center')
self.rotate_image()
def rotate_image(self):
"""Select next background image to use in the game menu.
Triggered by the "Change background" main menu button.
"""
self.bg_images.rotate(1)
self._image.image = self.bg_images[0]
# Save current background choice to settings.
# This keeps the background image consistent between sessions.
horizons.globals.fife.set_uh_setting("LatestBackground", self.bg_images[0])
horizons.globals.fife.save_settings()
def show(self):
self._black_box.show()
self._image.show()
def hide(self):
self._image.hide()
self._black_box.hide()
@property
def visible(self):
return self._image.isVisible()
示例2: Gui
# 需要导入模块: from fife.extensions.pychan.widgets import Icon [as 别名]
# 或者: from fife.extensions.pychan.widgets.Icon import isVisible [as 别名]
class Gui(object):
"""This class handles all the out of game menu, like the main and pause menu, etc.
"""
log = logging.getLogger("gui")
def __init__(self):
self.mainlistener = MainListener(self)
self.windows = WindowManager()
# temporary aliases for compatibility with rest of the code
self.show_popup = self.windows.show_popup
self.show_error_popup = self.windows.show_error_popup
self._background = Icon(image=self._get_random_background(),
position_technique='center:center')
self._background.show()
self.subscribe()
self.singleplayermenu = SingleplayerMenu(self.windows)
self.multiplayermenu = MultiplayerMenu(self, self.windows)
self.help_dialog = HelpDialog(self.windows)
self.loadingscreen = LoadingScreen()
self.settings_dialog = SettingsDialog(self.windows)
self.mainmenu = MainMenu(self, self.windows)
self.fps_display = FPSDisplay()
def subscribe(self):
"""Subscribe to the necessary messages."""
GuiAction.subscribe(self._on_gui_action)
def unsubscribe(self):
GuiAction.unsubscribe(self._on_gui_action)
def show_main(self):
"""Shows the main menu """
if not self._background.isVisible():
self._background.show()
self.windows.show(self.mainmenu)
def show_select_savegame(self, mode):
window = SelectSavegameDialog(mode, self.windows)
return self.windows.show(window)
def load_game(self):
saved_game = self.show_select_savegame(mode='load')
if saved_game is None:
return False # user aborted dialog
options = StartGameOptions(saved_game)
horizons.main.start_singleplayer(options)
return True
def on_help(self):
self.windows.toggle(self.help_dialog)
def show_credits(self):
"""Shows the credits dialog. """
window = CreditsPickbeltWidget(self.windows)
self.windows.show(window)
def on_escape(self):
self.windows.on_escape()
def close_all(self):
self.windows.close_all()
self._background.hide()
def show_loading_screen(self):
if not self._background.isVisible():
self._background.show()
self.windows.show(self.loadingscreen)
def randomize_background(self):
"""Randomly select a background image to use. This function is triggered by
change background button from main menu."""
self._background.image = self._get_random_background()
def _get_random_background(self):
"""Randomly select a background image to use through out the game menu."""
available_images = glob.glob('content/gui/images/background/mainmenu/bg_*.png')
#get latest background
latest_background = horizons.globals.fife.get_uh_setting("LatestBackground")
#if there is a latest background then remove it from available list
if latest_background is not None:
available_images.remove(latest_background)
background_choice = random.choice(available_images)
#save current background choice
horizons.globals.fife.set_uh_setting("LatestBackground", background_choice)
horizons.globals.fife.save_settings()
return background_choice
def _on_gui_action(self, msg):
AmbientSoundComponent.play_special('click')
def show_editor_start_menu(self):
editor_start_menu = EditorStartMenu(self.windows)
self.windows.show(editor_start_menu)
示例3: Gui
# 需要导入模块: from fife.extensions.pychan.widgets import Icon [as 别名]
# 或者: from fife.extensions.pychan.widgets.Icon import isVisible [as 别名]
class Gui(object):
"""This class handles all the out of game menu, like the main and pause menu, etc.
"""
log = logging.getLogger("gui")
def __init__(self):
self.mainlistener = MainListener(self)
self.windows = WindowManager()
# temporary aliases for compatibility with rest of the code
self.show_popup = self.windows.show_popup
self.show_error_popup = self.windows.show_error_popup
# Main menu background image setup.
available_images = glob.glob('content/gui/images/background/mainmenu/bg_*.png')
self.bg_images = deque(available_images)
latest_bg = horizons.globals.fife.get_uh_setting("LatestBackground")
try:
# If we know the current background from an earlier session,
# show all other available ones before picking that one again.
self.bg_images.remove(latest_bg)
self.bg_images.append(latest_bg)
except ValueError:
pass
self._background = Icon(position_technique='center:center')
self.rotate_background()
self._background.show()
self.singleplayermenu = SingleplayerMenu(self.windows)
self.multiplayermenu = MultiplayerMenu(self, self.windows)
self.help_dialog = HelpDialog(self.windows)
self.loadingscreen = LoadingScreen()
self.settings_dialog = SettingsDialog(self.windows)
self.mainmenu = MainMenu(self, self.windows)
self.fps_display = FPSDisplay()
def show_main(self):
"""Shows the main menu """
GuiAction.subscribe(self._on_gui_action)
if not self._background.isVisible():
self._background.show()
self.windows.show(self.mainmenu)
def show_select_savegame(self, mode):
window = SelectSavegameDialog(mode, self.windows)
return self.windows.show(window)
def load_game(self):
saved_game = self.show_select_savegame(mode='load')
if saved_game is None:
return False # user aborted dialog
options = StartGameOptions(saved_game)
horizons.main.start_singleplayer(options)
return True
def on_help(self):
self.windows.toggle(self.help_dialog)
def show_credits(self):
"""Shows the credits dialog. """
window = CreditsPickbeltWidget(self.windows)
self.windows.show(window)
def on_escape(self):
self.windows.on_escape()
def on_return(self):
self.windows.on_return()
def close_all(self):
GuiAction.discard(self._on_gui_action)
self.windows.close_all()
self._background.hide()
def show_loading_screen(self):
if not self._background.isVisible():
self._background.show()
self.windows.show(self.loadingscreen)
def rotate_background(self):
"""Select next background image to use in the game menu.
Triggered by the "Change background" main menu button.
"""
# Note: bg_images is a deque.
self.bg_images.rotate()
self._background.image = self.bg_images[0]
# Save current background choice to settings.
# This keeps the background image consistent between sessions.
horizons.globals.fife.set_uh_setting("LatestBackground", self.bg_images[0])
horizons.globals.fife.save_settings()
def _on_gui_action(self, msg):
AmbientSoundComponent.play_special('click')
def show_editor_start_menu(self):
#.........这里部分代码省略.........