本文整理汇总了Python中lutris.game.Game.play方法的典型用法代码示例。如果您正苦于以下问题:Python Game.play方法的具体用法?Python Game.play怎么用?Python Game.play使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lutris.game.Game
的用法示例。
在下文中一共展示了Game.play方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: launch_game
# 需要导入模块: from lutris.game import Game [as 别名]
# 或者: from lutris.game.Game import play [as 别名]
def launch_game(self, widget, _data=None):
"""Launch a game after it's been installed."""
widget.set_sensitive(False)
self.close(widget)
if self.parent:
self.parent.on_game_run(game_id=self.interpreter.game_id)
else:
game = Game(self.interpreter.game_id)
game.play()
示例2: launch_game
# 需要导入模块: from lutris.game import Game [as 别名]
# 或者: from lutris.game.Game import play [as 别名]
def launch_game(self, widget, _data=None):
"""Launch a game after it's been installed"""
widget.set_sensitive(False)
game = Game(self.interpreter.game_slug)
game.play()
self.close(widget)
示例3: LutrisWindow
# 需要导入模块: from lutris.game import Game [as 别名]
# 或者: from lutris.game.Game import play [as 别名]
class LutrisWindow(object):
"""Handler class for main window signals."""
def __init__(self):
ui_filename = os.path.join(datapath.get(), "ui", "LutrisWindow.ui")
if not os.path.exists(ui_filename):
raise IOError("File %s not found" % ui_filename)
self.running_game = None
self.threads_stoppers = []
# Emulate double click to workaround GTK bug #484640
# https://bugzilla.gnome.org/show_bug.cgi?id=484640
self.game_selection_time = 0
self.game_launch_time = 0
self.last_selected_game = None
self.builder = Gtk.Builder()
self.builder.add_from_file(ui_filename)
# Load settings
width = int(settings.read_setting("width") or 800)
height = int(settings.read_setting("height") or 600)
self.window_size = (width, height)
view_type = self.get_view_type()
self.icon_type = self.get_icon_type(view_type)
filter_installed_setting = settings.read_setting("filter_installed") or "false"
filter_installed = filter_installed_setting == "true"
show_installed_games_menuitem = self.builder.get_object("filter_installed")
show_installed_games_menuitem.set_active(filter_installed)
# Load view
logger.debug("Loading view")
self.game_store = GameStore([], self.icon_type, filter_installed)
self.view = load_view(view_type, self.game_store)
logger.debug("Connecting signals")
self.main_box = self.builder.get_object("main_box")
self.splash_box = self.builder.get_object("splash_box")
# View menu
self.grid_view_menuitem = self.builder.get_object("gridview_menuitem")
self.grid_view_menuitem.set_active(view_type == "grid")
self.list_view_menuitem = self.builder.get_object("listview_menuitem")
self.list_view_menuitem.set_active(view_type == "list")
# View buttons
self.grid_view_btn = self.builder.get_object("switch_grid_view_btn")
self.grid_view_btn.set_active(view_type == "grid")
self.list_view_btn = self.builder.get_object("switch_list_view_btn")
self.list_view_btn.set_active(view_type == "list")
# Icon type menu
self.banner_small_menuitem = self.builder.get_object("banner_small_menuitem")
self.banner_small_menuitem.set_active(self.icon_type == "banner_small")
self.banner_menuitem = self.builder.get_object("banner_menuitem")
self.banner_menuitem.set_active(self.icon_type == "banner")
self.icon_menuitem = self.builder.get_object("icon_menuitem")
self.icon_menuitem.set_active(self.icon_type == "icon")
self.search_entry = self.builder.get_object("search_entry")
self.search_entry.connect("icon-press", self.on_clear_search)
# Scroll window
self.games_scrollwindow = self.builder.get_object("games_scrollwindow")
self.games_scrollwindow.add(self.view)
# Status bar
self.status_label = self.builder.get_object("status_label")
self.joystick_icons = []
# Buttons
self.stop_button = self.builder.get_object("stop_button")
self.stop_button.set_sensitive(False)
self.delete_button = self.builder.get_object("delete_button")
self.delete_button.set_sensitive(False)
self.play_button = self.builder.get_object("play_button")
self.play_button.set_sensitive(False)
# Contextual menu
main_entries = [
("play", "Play", self.on_game_run),
("install", "Install", self.on_install_clicked),
("add", "Add manually", self.add_manually),
("configure", "Configure", self.edit_game_configuration),
("browse", "Browse files", self.on_browse_files),
("desktop-shortcut", "Create desktop shortcut", self.create_desktop_shortcut),
("rm-desktop-shortcut", "Delete desktop shortcut", self.remove_desktop_shortcut),
("menu-shortcut", "Create application menu shortcut", self.create_menu_shortcut),
("rm-menu-shortcut", "Delete application menu shortcut", self.remove_menu_shortcut),
("remove", "Remove", self.on_remove_game),
]
self.menu = ContextualMenu(main_entries)
self.view.contextual_menu = self.menu
# Sidebar
sidebar_paned = self.builder.get_object("sidebar_paned")
sidebar_paned.set_position(150)
self.sidebar_treeview = SidebarTreeView()
self.sidebar_treeview.connect("cursor-changed", self.on_sidebar_changed)
self.sidebar_viewport = self.builder.get_object("sidebar_viewport")
self.sidebar_viewport.add(self.sidebar_treeview)
# Window initialization
#.........这里部分代码省略.........
示例4: do_command_line
# 需要导入模块: from lutris.game import Game [as 别名]
# 或者: from lutris.game.Game import play [as 别名]
def do_command_line(self, command_line):
options = command_line.get_options_dict()
if options.contains('debug'):
logger.setLevel(logging.DEBUG)
if options.contains('list-games'):
game_list = pga.get_games()
if options.contains('installed'):
game_list = [game for game in game_list if game['installed']]
if options.contains('json'):
self.print_game_json(command_line, game_list)
else:
self.print_game_list(command_line, game_list)
return 0
elif options.contains('list-steam-games'):
self.print_steam_list(command_line)
return 0
elif options.contains('list-steam-folders'):
self.print_steam_folders(command_line)
return 0
elif options.contains('exec'):
command = options.lookup_value('exec').get_string()
self.execute_command(command)
return 0
game_slug = ''
revision = None
uri = options.lookup_value(GLib.OPTION_REMAINING)
if uri:
uri = uri.get_strv()
if uri and len(uri):
uri = uri[0] # TODO: Support multiple
installer_info = parse_installer_url(uri)
if installer_info is False:
self._print(command_line, '%s is not a valid URI' % uri)
return 1
game_slug = installer_info['game_slug']
revision = installer_info['revision']
if game_slug or options.contains('install'):
installer_file = None
if options.contains('install'):
installer_file = options.lookup_value('install').get_string()
if not os.path.isfile(installer_file):
self._print(command_line, "No such file: %s" % installer_file)
return 1
db_game = None
if game_slug:
db_game = (pga.get_game_by_field(game_slug, 'id') or
pga.get_game_by_field(game_slug, 'slug') or
pga.get_game_by_field(game_slug, 'installer_slug'))
force_install = options.contains('reinstall') or bool(installer_info.get('revision'))
if db_game and db_game['installed'] and not force_install:
self._print(command_line, "Launching %s" % db_game['name'])
if self.window:
self.run_game(db_game['id'])
else:
lutris_game = Game(db_game['id'])
# FIXME: This is awful
lutris_game.exit_main_loop = True
lutris_game.play()
try:
GLib.MainLoop().run()
except KeyboardInterrupt:
lutris_game.stop()
else:
self._print(command_line, "Installing %s" % game_slug or installer_file)
if self.window:
self.window.on_install_clicked(game_slug=game_slug,
installer_file=installer_file,
revision=revision)
else:
runtime_updater = RuntimeUpdater()
runtime_updater.update()
# FIXME: This should be a Gtk.Dialog child of LutrisWindow
dialog = InstallerDialog(game_slug=game_slug,
installer_file=installer_file,
revision=revision)
self.add_window(dialog)
return 0
self.activate()
return 0
示例5: do_command_line
# 需要导入模块: from lutris.game import Game [as 别名]
# 或者: from lutris.game.Game import play [as 别名]
#.........这里部分代码省略.........
self._print(command_line, json.dumps(games, indent=2))
else:
for game in game_list:
self._print(
command_line,
"{:4} | {:<40} | {:<40} | {:<15} | {:<64}".format(
game['id'],
game['name'][:40],
game['slug'][:40],
game['runner'] or '-',
game['directory'] or '-'
)
)
return 0
if options.contains('list-steam-games'):
steamapps_paths = get_steamapps_paths()
for platform in ('linux', 'windows'):
for path in steamapps_paths[platform]:
appmanifest_files = get_appmanifests(path)
for appmanifest_file in appmanifest_files:
appmanifest = AppManifest(os.path.join(path, appmanifest_file))
self._print(
command_line,
" {:8} | {:<60} | {:10} | {}".format(
appmanifest.steamid,
appmanifest.name or '-',
platform,
", ".join(appmanifest.states)
)
)
return 0
if options.contains('list-steam-folders'):
steamapps_paths = get_steamapps_paths()
for platform in ('linux', 'windows'):
for path in steamapps_paths[platform]:
self._print(command_line, path)
return 0
check_config(force_wipe=False)
migrate()
game = None
game_slug = ''
uri = options.lookup_value(GLib.OPTION_REMAINING)
if uri:
uri = uri.get_strv()
if uri and len(uri):
uri = uri[0] # TODO: Support multiple
if not uri.startswith('lutris:'):
self._print(command_line, '%s is not a valid URI' % uri)
return 1
game_slug = uri[7:]
if game_slug or options.contains('install'):
if options.contains('install'):
installer_file = options.lookup_value('install').get_string()
installer = installer_file
else:
installer_file = None
installer = game_slug
if not game_slug and not os.path.isfile(installer_file):
self._print(command_line, "No such file: %s" % installer_file)
return 1
db_game = None
if game_slug:
db_game = (pga.get_game_by_field(game_slug, 'id')
or pga.get_game_by_field(game_slug, 'slug')
or pga.get_game_by_field(game_slug, 'installer_slug'))
if db_game and db_game['installed'] and not options.contains('reinstall'):
self._print(command_line, "Launching %s" % db_game['name'])
if self.window:
self.run_game(db_game['id'])
else:
lutris_game = Game(db_game['id'])
# FIXME: This is awful
lutris_game.exit_main_loop = True
lutris_game.play()
try:
GLib.MainLoop().run()
except KeyboardInterrupt:
lutris_game.stop()
return 0
else:
self._print(command_line, "Installing %s" % installer)
if self.window:
self.install_game(installer)
else:
runtime_updater = RuntimeUpdater()
runtime_updater.update()
# FIXME: This should be a Gtk.Dialog child of LutrisWindow
dialog = InstallerDialog(installer)
self.add_window(dialog)
return 0
self.activate()
return 0
示例6: LutrisWindow
# 需要导入模块: from lutris.game import Game [as 别名]
# 或者: from lutris.game.Game import play [as 别名]
class LutrisWindow(Gtk.Application):
"""Handler class for main window signals."""
def __init__(self, service=None):
Gtk.Application.__init__(
self, application_id="net.lutris.main",
flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE
)
ui_filename = os.path.join(
datapath.get(), 'ui', 'lutris-window.ui'
)
if not os.path.exists(ui_filename):
raise IOError('File %s not found' % ui_filename)
self.service = service
self.runtime_updater = RuntimeUpdater()
self.running_game = None
self.threads_stoppers = []
# Emulate double click to workaround GTK bug #484640
# https://bugzilla.gnome.org/show_bug.cgi?id=484640
self.game_selection_time = 0
self.game_launch_time = 0
self.last_selected_game = None
self.selected_runner = None
self.builder = Gtk.Builder()
self.builder.add_from_file(ui_filename)
# Load settings
width = int(settings.read_setting('width') or 800)
height = int(settings.read_setting('height') or 600)
self.window_size = (width, height)
window = self.builder.get_object('window')
window.resize(width, height)
view_type = self.get_view_type()
self.load_icon_type_from_settings(view_type)
self.filter_installed = \
settings.read_setting('filter_installed') == 'true'
self.sidebar_visible = \
settings.read_setting('sidebar_visible') in ['true', None]
# Set theme to dark if set in the settings
dark_theme_menuitem = self.builder.get_object('dark_theme_menuitem')
use_dark_theme = settings.read_setting('dark_theme') == 'true'
dark_theme_menuitem.set_active(use_dark_theme)
self.set_dark_theme(use_dark_theme)
self.game_list = pga.get_games()
# Load view
self.game_store = GameStore([], self.icon_type, self.filter_installed)
self.view = self.get_view(view_type)
self.main_box = self.builder.get_object('main_box')
self.splash_box = self.builder.get_object('splash_box')
self.connect_link = self.builder.get_object('connect_link')
# View menu
installed_games_only_menuitem =\
self.builder.get_object('filter_installed')
installed_games_only_menuitem.set_active(self.filter_installed)
self.grid_view_menuitem = self.builder.get_object("gridview_menuitem")
self.grid_view_menuitem.set_active(view_type == 'grid')
self.list_view_menuitem = self.builder.get_object("listview_menuitem")
self.list_view_menuitem.set_active(view_type == 'list')
sidebar_menuitem = self.builder.get_object('sidebar_menuitem')
sidebar_menuitem.set_active(self.sidebar_visible)
# View buttons
self.grid_view_btn = self.builder.get_object('switch_grid_view_btn')
self.grid_view_btn.set_active(view_type == 'grid')
self.list_view_btn = self.builder.get_object('switch_list_view_btn')
self.list_view_btn.set_active(view_type == 'list')
# Icon type menu
self.banner_small_menuitem = \
self.builder.get_object('banner_small_menuitem')
self.banner_small_menuitem.set_active(self.icon_type == 'banner_small')
self.banner_menuitem = self.builder.get_object('banner_menuitem')
self.banner_menuitem.set_active(self.icon_type == 'banner')
self.icon_menuitem = self.builder.get_object('icon_menuitem')
self.icon_menuitem.set_active(self.icon_type == 'icon')
self.search_entry = self.builder.get_object('search_entry')
self.search_entry.connect('icon-press', self.on_clear_search)
# Scroll window
self.games_scrollwindow = self.builder.get_object('games_scrollwindow')
self.games_scrollwindow.add(self.view)
# Buttons
self.stop_button = self.builder.get_object('stop_button')
self.stop_button.set_sensitive(False)
self.delete_button = self.builder.get_object('delete_button')
self.delete_button.set_sensitive(False)
self.play_button = self.builder.get_object('play_button')
self.play_button.set_sensitive(False)
# Contextual menu
main_entries = [
('play', "Play", self.on_game_run),
('install', "Install", self.on_install_clicked),
#.........这里部分代码省略.........
示例7: LutrisWindow
# 需要导入模块: from lutris.game import Game [as 别名]
# 或者: from lutris.game.Game import play [as 别名]
class LutrisWindow(object):
"""Handler class for main window signals"""
def __init__(self):
ui_filename = os.path.join(
datapath.get(), 'ui', 'LutrisWindow.ui'
)
if not os.path.exists(ui_filename):
raise IOError('File %s not found' % ui_filename)
self.builder = Gtk.Builder()
self.builder.add_from_file(ui_filename)
# load config
width = int(settings.read_setting('width') or 800)
height = int(settings.read_setting('height') or 600)
self.window_size = (width, height)
view_type = settings.read_setting('view_type') or 'icon'
filter_installed_setting = settings.read_setting(
'filter_installed'
) or 'false'
self.filter_installed = filter_installed_setting == 'true'
show_installed_games_menuitem = self.builder.get_object(
'filter_installed'
)
show_installed_games_menuitem.set_active(self.filter_installed)
logger.debug("Getting game list")
game_list = get_game_list(self.filter_installed)
logger.debug("Switching view")
self.view = switch_to_view(view_type, game_list)
logger.debug("Connecting signals")
self.icon_view_menuitem = self.builder.get_object("iconview_menuitem")
self.icon_view_menuitem.set_active(view_type == 'icon')
self.list_view_menuitem = self.builder.get_object("listview_menuitem")
self.list_view_menuitem.set_active(view_type == 'list')
self.icon_view_btn = self.builder.get_object('switch_grid_view_btn')
self.icon_view_btn.set_active(view_type == 'icon')
self.list_view_btn = self.builder.get_object('switch_list_view_btn')
self.list_view_btn.set_active(view_type == 'list')
# Scroll window
self.games_scrollwindow = self.builder.get_object('games_scrollwindow')
self.games_scrollwindow.add(self.view)
#Status bar
self.status_label = self.builder.get_object('status_label')
self.joystick_icons = []
# Buttons
self.stop_button = self.builder.get_object('stop_button')
self.stop_button.set_sensitive(False)
self.delete_button = self.builder.get_object('delete_button')
self.delete_button.set_sensitive(False)
self.play_button = self.builder.get_object('play_button')
self.play_button.set_sensitive(False)
#Contextual menu
menu_callbacks = [
('play', self.on_game_clicked),
('install', self.on_game_clicked),
('add', self.add_manually),
('configure', self.edit_game_configuration),
('desktop-shortcut', self.create_desktop_shortcut),
('menu-shortcut', self.create_menu_shortcut),
('uninstall', self.on_remove_game),
]
self.menu = ContextualMenu(menu_callbacks)
self.view.contextual_menu = self.menu
#Timer
self.timer_id = GLib.timeout_add(2000, self.refresh_status)
self.window = self.builder.get_object("window")
self.window.resize_to_geometry(width, height)
self.window.show_all()
self.builder.connect_signals(self)
self.connect_signals()
if api.read_api_key():
self.status_label.set_text("Connected to lutris.net")
self.sync_library()
else:
async_call(self.sync_icons, None)
@property
def current_view_type(self):
return 'icon' \
if self.view.__class__.__name__ == "GameIconView" \
else 'list'
def sync_icons(self):
game_list = pga.get_games()
resources.fetch_banners([game_info['slug'] for game_info in game_list],
callback=self.on_image_downloaded)
def connect_signals(self):
"""Connects signals from the view with the main window.
This must be called each time the view is rebuilt.
"""
self.view.connect('game-installed', self.on_game_installed)
self.view.connect("game-activated", self.on_game_clicked)
self.view.connect("game-selected", self.game_selection_changed)
#.........这里部分代码省略.........
示例8: LutrisWindow
# 需要导入模块: from lutris.game import Game [as 别名]
# 或者: from lutris.game.Game import play [as 别名]
class LutrisWindow(Gtk.ApplicationWindow):
"""Handler class for main window signals."""
__gtype_name__ = 'LutrisWindow'
main_box = GtkTemplate.Child()
splash_box = GtkTemplate.Child()
connect_link = GtkTemplate.Child()
games_scrollwindow = GtkTemplate.Child()
sidebar_paned = GtkTemplate.Child()
sidebar_viewport = GtkTemplate.Child()
statusbar = GtkTemplate.Child()
connection_label = GtkTemplate.Child()
status_box = GtkTemplate.Child()
def __init__(self, application, **kwargs):
self.runtime_updater = RuntimeUpdater()
self.running_game = None
self.threads_stoppers = []
# Emulate double click to workaround GTK bug #484640
# https://bugzilla.gnome.org/show_bug.cgi?id=484640
self.game_selection_time = 0
self.game_launch_time = 0
self.last_selected_game = None
self.selected_runner = None
self.selected_platform = None
# Load settings
width = int(settings.read_setting('width') or 800)
height = int(settings.read_setting('height') or 600)
self.window_size = (width, height)
self.maximized = settings.read_setting('maximized') == 'True'
view_type = self.get_view_type()
self.load_icon_type_from_settings(view_type)
self.filter_installed = \
settings.read_setting('filter_installed') == 'true'
self.sidebar_visible = \
settings.read_setting('sidebar_visible') in ['true', None]
self.use_dark_theme = settings.read_setting('dark_theme') == 'true'
# Sync local lutris library with current Steam games and desktop games
# before setting up game list and view
steam.sync_with_lutris()
desktopapps.sync_with_lutris()
# Window initialization
self.game_list = pga.get_games()
self.game_store = GameStore([], self.icon_type, self.filter_installed)
self.view = self.get_view(view_type)
super().__init__(default_width=width,
default_height=height,
icon_name='lutris',
application=application,
**kwargs)
if self.maximized:
self.maximize()
self.init_template()
self._init_actions()
# Set theme to dark if set in the settings
self.set_dark_theme(self.use_dark_theme)
# Load view
self.games_scrollwindow.add(self.view)
self.connect_signals()
self.view.show()
# Contextual menu
main_entries = [
('play', "Play", self.on_game_run),
('install', "Install", self.on_install_clicked),
('add', "Add manually", self.on_add_manually),
('configure', "Configure", self.on_edit_game_configuration),
('browse', "Browse files", self.on_browse_files),
('desktop-shortcut', "Create desktop shortcut",
self.create_desktop_shortcut),
('rm-desktop-shortcut', "Delete desktop shortcut",
self.remove_desktop_shortcut),
('menu-shortcut', "Create application menu shortcut",
self.create_menu_shortcut),
('rm-menu-shortcut', "Delete application menu shortcut",
self.remove_menu_shortcut),
('install_more', "Install (add) another version", self.on_install_clicked),
('remove', "Remove", self.on_remove_game),
('view', "View on Lutris.net", self.on_view_game),
]
self.menu = ContextualMenu(main_entries)
self.view.contextual_menu = self.menu
# Sidebar
self.sidebar_treeview = SidebarTreeView()
self.sidebar_treeview.connect('cursor-changed', self.on_sidebar_changed)
self.sidebar_viewport.add(self.sidebar_treeview)
self.sidebar_treeview.show()
self.game_store.fill_store(self.game_list)
self.switch_splash_screen()
#.........这里部分代码省略.........
示例9: LutrisWindow
# 需要导入模块: from lutris.game import Game [as 别名]
# 或者: from lutris.game.Game import play [as 别名]
class LutrisWindow(object):
"""Handler class for main window signals."""
def __init__(self):
ui_filename = os.path.join(
datapath.get(), 'ui', 'LutrisWindow.ui'
)
if not os.path.exists(ui_filename):
raise IOError('File %s not found' % ui_filename)
# Currently running game
self.running_game = None
# Emulate double click to workaround GTK bug #484640
# https://bugzilla.gnome.org/show_bug.cgi?id=484640
self.game_selection_time = 0
self.game_launch_time = 0
self.last_selected_game = None
self.builder = Gtk.Builder()
self.builder.add_from_file(ui_filename)
# load config
width = int(settings.read_setting('width') or 800)
height = int(settings.read_setting('height') or 600)
self.window_size = (width, height)
view_type = self.get_view_type()
self.icon_type = self.get_icon_type(view_type)
filter_installed_setting = settings.read_setting(
'filter_installed'
) or 'false'
self.filter_installed = filter_installed_setting == 'true'
show_installed_games_menuitem = self.builder.get_object(
'filter_installed'
)
show_installed_games_menuitem.set_active(self.filter_installed)
logger.debug("Getting game list")
game_list = get_game_list(self.filter_installed)
logger.debug("Switching view")
self.view = load_view(view_type, game_list,
icon_type=self.icon_type)
logger.debug("Connecting signals")
self.main_box = self.builder.get_object('main_box')
self.splash_box = self.builder.get_object('splash_box')
# View menu
self.grid_view_menuitem = self.builder.get_object("gridview_menuitem")
self.grid_view_menuitem.set_active(view_type == 'grid')
self.list_view_menuitem = self.builder.get_object("listview_menuitem")
self.list_view_menuitem.set_active(view_type == 'list')
# View buttons
self.grid_view_btn = self.builder.get_object('switch_grid_view_btn')
self.grid_view_btn.set_active(view_type == 'grid')
self.list_view_btn = self.builder.get_object('switch_list_view_btn')
self.list_view_btn.set_active(view_type == 'list')
# Icon type menu
self.banner_small_menuitem = \
self.builder.get_object('banner_small_menuitem')
self.banner_small_menuitem.set_active(self.icon_type == 'banner_small')
self.banner_menuitem = self.builder.get_object('banner_menuitem')
self.banner_menuitem.set_active(self.icon_type == 'banner')
self.icon_menuitem = self.builder.get_object('icon_menuitem')
self.icon_menuitem.set_active(self.icon_type == 'grid')
self.search_entry = self.builder.get_object('search_entry')
# Scroll window
self.games_scrollwindow = self.builder.get_object('games_scrollwindow')
self.games_scrollwindow.add(self.view)
# Status bar
self.status_label = self.builder.get_object('status_label')
self.joystick_icons = []
# Buttons
self.stop_button = self.builder.get_object('stop_button')
self.stop_button.set_sensitive(False)
self.delete_button = self.builder.get_object('delete_button')
self.delete_button.set_sensitive(False)
self.play_button = self.builder.get_object('play_button')
self.play_button.set_sensitive(False)
# Contextual menu
menu_callbacks = [
('play', self.on_game_clicked),
('install', self.on_game_clicked),
('add', self.add_manually),
('configure', self.edit_game_configuration),
('browse', self.on_browse_files),
('desktop-shortcut', self.create_desktop_shortcut),
('menu-shortcut', self.create_menu_shortcut),
('remove', self.on_remove_game),
]
self.menu = ContextualMenu(menu_callbacks)
self.view.contextual_menu = self.menu
# Timer
self.timer_id = GLib.timeout_add(2000, self.refresh_status)
# Window initialization
self.window = self.builder.get_object("window")
self.window.resize_to_geometry(width, height)
self.window.show_all()
#.........这里部分代码省略.........
示例10: LutrisWindow
# 需要导入模块: from lutris.game import Game [as 别名]
# 或者: from lutris.game.Game import play [as 别名]
class LutrisWindow(object):
"""Handler class for main window signals."""
def __init__(self, service=None):
ui_filename = os.path.join(
datapath.get(), 'ui', 'LutrisWindow.ui'
)
if not os.path.exists(ui_filename):
raise IOError('File %s not found' % ui_filename)
self.service = service
self.running_game = None
self.threads_stoppers = []
# Emulate double click to workaround GTK bug #484640
# https://bugzilla.gnome.org/show_bug.cgi?id=484640
self.game_selection_time = 0
self.game_launch_time = 0
self.last_selected_game = None
self.builder = Gtk.Builder()
self.builder.add_from_file(ui_filename)
# Load settings
width = int(settings.read_setting('width') or 800)
height = int(settings.read_setting('height') or 600)
self.window_size = (width, height)
view_type = self.get_view_type()
self.icon_type = self.get_icon_type(view_type)
filter_installed = \
settings.read_setting('filter_installed') == 'true'
self.sidebar_visible = \
settings.read_setting('sidebar_visible') in ['true', None]
# Load view
logger.debug("Loading view")
self.game_store = GameStore([], self.icon_type, filter_installed)
self.view = load_view(view_type, self.game_store)
logger.debug("Connecting signals")
self.main_box = self.builder.get_object('main_box')
self.splash_box = self.builder.get_object('splash_box')
# View menu
installed_games_only_menuitem =\
self.builder.get_object('filter_installed')
installed_games_only_menuitem.set_active(filter_installed)
self.grid_view_menuitem = self.builder.get_object("gridview_menuitem")
self.grid_view_menuitem.set_active(view_type == 'grid')
self.list_view_menuitem = self.builder.get_object("listview_menuitem")
self.list_view_menuitem.set_active(view_type == 'list')
sidebar_menuitem = self.builder.get_object('sidebar_menuitem')
sidebar_menuitem.set_active(self.sidebar_visible)
# View buttons
self.grid_view_btn = self.builder.get_object('switch_grid_view_btn')
self.grid_view_btn.set_active(view_type == 'grid')
self.list_view_btn = self.builder.get_object('switch_list_view_btn')
self.list_view_btn.set_active(view_type == 'list')
# Icon type menu
self.banner_small_menuitem = \
self.builder.get_object('banner_small_menuitem')
self.banner_small_menuitem.set_active(self.icon_type == 'banner_small')
self.banner_menuitem = self.builder.get_object('banner_menuitem')
self.banner_menuitem.set_active(self.icon_type == 'banner')
self.icon_menuitem = self.builder.get_object('icon_menuitem')
self.icon_menuitem.set_active(self.icon_type == 'icon')
self.search_entry = self.builder.get_object('search_entry')
self.search_entry.connect('icon-press', self.on_clear_search)
# Scroll window
self.games_scrollwindow = self.builder.get_object('games_scrollwindow')
self.games_scrollwindow.add(self.view)
# Status bar
self.status_label = self.builder.get_object('status_label')
self.joystick_icons = []
# Buttons
self.stop_button = self.builder.get_object('stop_button')
self.stop_button.set_sensitive(False)
self.delete_button = self.builder.get_object('delete_button')
self.delete_button.set_sensitive(False)
self.play_button = self.builder.get_object('play_button')
self.play_button.set_sensitive(False)
# Contextual menu
main_entries = [
('play', "Play", self.on_game_run),
('install', "Install", self.on_install_clicked),
('add', "Add manually", self.add_manually),
('configure', "Configure", self.edit_game_configuration),
('browse', "Browse files", self.on_browse_files),
('desktop-shortcut', "Create desktop shortcut", self.create_desktop_shortcut),
('rm-desktop-shortcut', "Delete desktop shortcut", self.remove_desktop_shortcut),
('menu-shortcut', "Create application menu shortcut", self.create_menu_shortcut),
('rm-menu-shortcut', "Delete application menu shortcut", self.remove_menu_shortcut),
('install_more', "Install (add) another version", self.on_install_clicked),
('remove', "Remove", self.on_remove_game),
]
self.menu = ContextualMenu(main_entries)
self.view.contextual_menu = self.menu
#.........这里部分代码省略.........
示例11: LutrisWindow
# 需要导入模块: from lutris.game import Game [as 别名]
# 或者: from lutris.game.Game import play [as 别名]
class LutrisWindow(object):
"""Handler class for main window signals"""
def __init__(self):
ui_filename = os.path.join(
settings.get_data_path(), 'ui', 'LutrisWindow.ui'
)
if not os.path.exists(ui_filename):
raise IOError('File %s not found' % ui_filename)
self.builder = Gtk.Builder()
self.builder.add_from_file(ui_filename)
# load config
width = int(settings.read_setting('width') or 800)
height = int(settings.read_setting('height') or 600)
self.window_size = (width, height)
view_type = settings.read_setting('view_type') or 'icon'
self.view = switch_to_view(view_type)
view_menuitem = self.builder.get_object("iconview_menuitem")
view_menuitem.set_active(view_type == 'icon')
view_menuitem = self.builder.get_object("listview_menuitem")
view_menuitem.set_active(view_type == 'list')
switch_grid_view_btn = self.builder.get_object('switch_grid_view_btn')
switch_grid_view_btn.set_active(view_type == 'icon')
switch_list_view_btn = self.builder.get_object('switch_list_view_btn')
switch_list_view_btn.set_active(view_type == 'list')
# Scroll window
self.games_scrollwindow = self.builder.get_object('games_scrollwindow')
self.games_scrollwindow.add(self.view)
#Status bar
self.status_label = self.builder.get_object('status_label')
self.joystick_icons = []
# Buttons
self.stop_button = self.builder.get_object('stop_button')
self.stop_button.set_sensitive(False)
self.delete_button = self.builder.get_object('delete_button')
self.delete_button.set_sensitive(False)
self.play_button = self.builder.get_object('play_button')
self.play_button.set_sensitive(False)
#Contextual menu
menu_actions = [
('Play', self.on_game_clicked),
('Configure', self.edit_game_configuration),
('Create desktop shortcut', self.create_desktop_shortcut),
('Create global menu shortcut', self.create_menu_shortcut)
]
self.menu = Gtk.Menu()
for action in menu_actions:
subitem = Gtk.ImageMenuItem(action[0])
subitem.connect('activate', action[1])
self.menu.append(subitem)
self.menu.show_all()
self.view.contextual_menu = self.menu
#Timer
self.timer_id = GLib.timeout_add(2000, self.refresh_status)
self.window = self.builder.get_object("window")
self.window.resize_to_geometry(width, height)
self.window.show_all()
self.builder.connect_signals(self)
self.connect_signals()
async_call(self.sync_db, None)
def sync_db(self, *args):
api.sync()
game_list = pga.get_games()
resources.fetch_banners([game_info['slug'] for game_info in game_list],
callback=self.on_image_downloaded)
def connect_signals(self):
"""Connects signals from the view with the main window.
This must be called each time the view is rebuilt.
"""
self.view.connect("game-activated", self.on_game_clicked)
self.view.connect("game-selected", self.game_selection_changed)
self.window.connect("configure-event", self.get_size)
def get_size(self, widget, _):
self.window_size = widget.get_size()
def refresh_status(self):
"""Refresh status bar"""
if hasattr(self, "running_game"):
if hasattr(self.running_game.game_thread, "pid"):
pid = self.running_game.game_thread.pid
name = self.running_game.name
if pid == 99999:
self.status_label.set_text("Preparing to launch %s" % name)
elif pid is None:
self.status_label.set_text("Game has quit")
else:
self.status_label.set_text("Playing %s (pid: %r)"
% (name, pid))
for index in range(4):
#.........这里部分代码省略.........