本文整理汇总了Python中lutris.game.Game.quit_game方法的典型用法代码示例。如果您正苦于以下问题:Python Game.quit_game方法的具体用法?Python Game.quit_game怎么用?Python Game.quit_game使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lutris.game.Game
的用法示例。
在下文中一共展示了Game.quit_game方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LutrisWindow
# 需要导入模块: from lutris.game import Game [as 别名]
# 或者: from lutris.game.Game import quit_game [as 别名]
#.........这里部分代码省略.........
def on_game_clicked(self, *args):
"""Launch a game."""
# Wait two seconds to avoid running a game twice
if time.time() - self.game_launch_time < 2:
return
self.game_launch_time = time.time()
game_slug = self.view.selected_game
if game_slug:
self.running_game = Game(game_slug)
if self.running_game.is_installed:
self.stop_button.set_sensitive(True)
self.running_game.play()
else:
InstallerDialog(game_slug, self)
def set_status(self, text):
self.status_label.set_text(text)
def sync_library(self):
def set_library_synced(result, error):
self.set_status("Library synced")
self.switch_splash_screen()
self.set_status("Syncing library")
async_call(
api.sync,
lambda r, e: async_call(self.sync_icons, set_library_synced),
caller=self
)
def reset(self, *args):
"""Reset the desktop to it's initial state."""
if self.running_game:
self.running_game.quit_game()
self.status_label.set_text("Stopped %s" % self.running_game.name)
self.running_game = None
self.stop_button.set_sensitive(False)
def game_selection_changed(self, _widget):
# Emulate double click to workaround GTK bug #484640
# https://bugzilla.gnome.org/show_bug.cgi?id=484640
if type(self.view) is GameGridView:
is_double_click = time.time() - self.game_selection_time < 0.4
is_same_game = self.view.selected_game == self.last_selected_game
if is_double_click and is_same_game:
self.on_game_clicked()
self.game_selection_time = time.time()
self.last_selected_game = self.view.selected_game
sensitive = True if self.view.selected_game else False
self.play_button.set_sensitive(sensitive)
self.delete_button.set_sensitive(sensitive)
def add_game_to_view(self, slug):
if not slug:
raise ValueError("Missing game slug")
game = Game(slug)
def do_add_game():
self.view.add_game(game)
self.switch_splash_screen()
GLib.idle_add(do_add_game)
def add_game(self, _widget, _data=None):
"""Add a new game."""
add_game_dialog = AddGameDialog(self)
示例2: LutrisWindow
# 需要导入模块: from lutris.game import Game [as 别名]
# 或者: from lutris.game.Game import quit_game [as 别名]
#.........这里部分代码省略.........
def on_image_downloaded(self, game_slug):
self.view.update_image(game_slug)
def on_search_entry_changed(self, widget):
self.view.emit('filter-updated', widget.get_text())
def on_game_clicked(self, *args):
"""Launch a game"""
game_slug = self.view.selected_game
if game_slug:
self.running_game = Game(game_slug)
if self.running_game.is_installed:
self.running_game.play()
else:
InstallerDialog(game_slug, self)
def set_status(self, text):
self.status_label.set_text(text)
def sync_library(self):
def set_library_synced(result, error):
self.set_status("Library synced")
self.set_status("Syncing library")
async_call(api.sync,
async_call(
self.sync_icons,
set_library_synced,
),
caller=self)
def reset(self, *args):
"""Reset the desktop to it's initial state"""
if self.running_game:
self.running_game.quit_game()
self.status_label.set_text("Stopped %s" % self.running_game.name)
self.running_game = None
def game_selection_changed(self, _widget):
sensitive = True if self.view.selected_game else False
self.play_button.set_sensitive(sensitive)
self.delete_button.set_sensitive(sensitive)
def add_game_to_view(self, slug):
game = Game(slug)
GLib.idle_add(lambda: self.view.add_game(game))
def add_game(self, _widget, _data=None):
""" Add a new game """
add_game_dialog = AddGameDialog(self)
if add_game_dialog.runner_name:
self.add_game_to_view(add_game_dialog.slug)
def add_manually(self, *args):
game = Game(self.view.selected_game)
add_game_dialog = AddGameDialog(self, game)
if add_game_dialog.runner_name:
self.view.update_image(game.slug, is_installed=True)
def edit_game_configuration(self, _button):
"""Edit game preferences"""
game = Game(self.view.selected_game)
if game.is_installed:
EditGameConfigDialog(self, self.view.selected_game)
def on_viewmenu_toggled(self, menuitem):
view_type = 'icon' if menuitem.get_active() else 'list'
示例3: LutrisWindow
# 需要导入模块: from lutris.game import Game [as 别名]
# 或者: from lutris.game.Game import quit_game [as 别名]
#.........这里部分代码省略.........
def on_connect(self, *args):
"""Callback when a user connects to his account"""
login_dialog = dialogs.ClientLoginDialog()
login_dialog.connect('connected', self.on_connect_success)
def on_connect_success(self, dialog, token):
logger.info("Successfully connected to Lutris.net")
self.status_label.set_text("Connected")
self.sync_db()
def on_destroy(self, *args):
"""Signal for window close"""
view_type = 'icon' if 'IconView' in str(type(self.view)) else 'list'
settings.write_setting('view_type', view_type)
width, height = self.window_size
settings.write_setting('width', width)
settings.write_setting('height', height)
Gtk.main_quit(*args)
def on_runners_activate(self, _widget, _data=None):
"""Callback when manage runners is activated"""
RunnersDialog()
def on_preferences_activate(self, _widget, _data=None):
"""Callback when preferences is activated"""
SystemConfigDialog()
def on_pga_menuitem_activate(self, _widget, _data=None):
dialogs.PgaSourceDialog()
def on_image_downloaded(self, game_slug):
self.view.update_image(game_slug)
def import_scummvm(self, _widget, _data=None):
"""Callback for importing scummvm games"""
from lutris.runners.scummvm import import_games
new_games = import_games()
if not new_games:
dialogs.NoticeDialog("No ScummVM games found")
else:
for new_game in new_games:
self.view.add_game(new_game)
def on_search_entry_changed(self, widget):
self.view.emit('filter-updated', widget.get_text())
def on_game_clicked(self, *args):
"""Launch a game"""
game_slug = self.view.selected_game[0]
if game_slug:
self.running_game = Game(game_slug)
if self.running_game.is_installed:
self.running_game.play()
else:
InstallerDialog(game_slug, self)
def reset(self, *args):
"""Reset the desktop to it's initial state"""
if self.running_game:
self.running_game.quit_game()
self.status_label.set_text("Stopped %s" % self.running_game.name)
self.running_game = None
def game_selection_changed(self, _widget):
sensitive = True if self.view.selected_game else False
self.play_button.set_sensitive(sensitive)
self.delete_button.set_sensitive(sensitive)
def add_game(self, _widget, _data=None):
""" Manually add a game """
add_game_dialog = AddGameDialog(self)
if hasattr(add_game_dialog, "game_info"):
game_info = add_game_dialog.game_info
game = Game(game_info['slug'])
self.view.game_store.add_game(game)
def edit_game_configuration(self, _button):
"""Edit game preferences"""
EditGameConfigDialog(self, self.view.selected_game)
def on_iconview_toggled(self, menuitem):
"""Switches between icon view and list view"""
self.view.destroy()
self.view = switch_to_view('icon' if menuitem.get_active() else 'list')
self.view.contextual_menu = self.menu
self.connect_signals()
self.games_scrollwindow.add_with_viewport(self.view)
def create_menu_shortcut(self, *args):
"""Adds the game to the system's Games menu"""
game_slug = slugify(self.view.selected_game)
create_launcher(game_slug, menu=True)
dialogs.NoticeDialog(
"Shortcut added to the Games category of the global menu.")
def create_desktop_shortcut(self, *args):
"""Adds the game to the system's Games menu"""
game_slug = slugify(self.view.selected_game)
create_launcher(game_slug, desktop=True)
dialogs.NoticeDialog('Shortcut created on your desktop.')