本文整理汇总了Python中lutris.game.Game.exit_main_loop方法的典型用法代码示例。如果您正苦于以下问题:Python Game.exit_main_loop方法的具体用法?Python Game.exit_main_loop怎么用?Python Game.exit_main_loop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lutris.game.Game
的用法示例。
在下文中一共展示了Game.exit_main_loop方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_command_line
# 需要导入模块: from lutris.game import Game [as 别名]
# 或者: from lutris.game.Game import exit_main_loop [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
示例2: do_command_line
# 需要导入模块: from lutris.game import Game [as 别名]
# 或者: from lutris.game.Game import exit_main_loop [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'):
games = []
for game in game_list:
games.append({
'id': game['id'],
'slug': game['slug'],
'name': game['name'],
'runner': game['runner'],
'directory': game['directory']
})
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
#.........这里部分代码省略.........