本文整理汇总了Python中lutris.game.Game.set_platform_from_runner方法的典型用法代码示例。如果您正苦于以下问题:Python Game.set_platform_from_runner方法的具体用法?Python Game.set_platform_from_runner怎么用?Python Game.set_platform_from_runner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lutris.game.Game
的用法示例。
在下文中一共展示了Game.set_platform_from_runner方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_platforms
# 需要导入模块: from lutris.game import Game [as 别名]
# 或者: from lutris.game.Game import set_platform_from_runner [as 别名]
def update_platforms():
pga_games = pga.get_games(filter_installed=True)
for pga_game in pga_games:
if pga_game.get('platform') or not pga_game['runner']:
continue
game = Game(id=pga_game['id'])
game.set_platform_from_runner()
game.save()
示例2: platform
# 需要导入模块: from lutris.game import Game [as 别名]
# 或者: from lutris.game.Game import set_platform_from_runner [as 别名]
def platform(self):
"""Platform"""
_platform = self._pga_data["platform"]
if not _platform and self.installed:
game_inst = Game(self._pga_data["id"])
if game_inst.platform:
_platform = game_inst.platform
else:
logger.debug("Game %s has no platform", self)
game_inst.set_platform_from_runner()
_platform = game_inst.platform
return _platform
示例3: fill_missing_platforms
# 需要导入模块: from lutris.game import Game [as 别名]
# 或者: from lutris.game.Game import set_platform_from_runner [as 别名]
def fill_missing_platforms():
"""Sets the platform on games where it's missing.
This should never happen.
"""
pga_games = pga.get_games(filter_installed=True)
for pga_game in pga_games:
if pga_game.get("platform") or not pga_game["runner"]:
continue
game = Game(game_id=pga_game["id"])
logger.error("Providing missing platorm for game %s", game.slug)
game.set_platform_from_runner()
if game.platform:
game.save(metadata_only=True)
示例4: add_game
# 需要导入模块: from lutris.game import Game [as 别名]
# 或者: from lutris.game.Game import set_platform_from_runner [as 别名]
def add_game(self, game):
name = game['name'].replace('&', "&")
runner = None
platform = ''
runner_name = game['runner']
runner_human_name = ''
if runner_name:
game_inst = Game(game['id'])
if not game_inst.is_installed:
return
if runner_name in self.runner_names:
runner_human_name = self.runner_names[runner_name]
else:
try:
runner = runners.import_runner(runner_name)
except runners.InvalidRunner:
game['installed'] = False
else:
runner_human_name = runner.human_name
self.runner_names[runner_name] = runner_human_name
platform = game_inst.platform
if not platform:
game_inst.set_platform_from_runner()
platform = game_inst.platform
lastplayed = ''
if game['lastplayed']:
lastplayed = time.strftime("%c", time.localtime(game['lastplayed']))
pixbuf = get_pixbuf_for_game(game['slug'], self.icon_type,
game['installed'])
self.store.append((
game['id'],
game['slug'],
name,
pixbuf,
str(game['year'] or ''),
runner_name,
runner_human_name,
platform,
game['lastplayed'],
lastplayed,
game['installed']
))
示例5: GameDialogCommon
# 需要导入模块: from lutris.game import Game [as 别名]
# 或者: from lutris.game.Game import set_platform_from_runner [as 别名]
#.........这里部分代码省略.........
def _rebuild_tabs(self):
for i in range(self.notebook.get_n_pages(), 1, -1):
self.notebook.remove_page(i - 1)
self._build_game_tab()
self._build_runner_tab('game')
self._build_system_tab('game')
self.show_all()
def on_cancel_clicked(self, widget=None):
"""Dialog destroy callback."""
self.destroy()
def is_valid(self):
name = self.name_entry.get_text()
if not self.runner_name:
ErrorDialog("Runner not provided")
return False
if not name:
ErrorDialog("Please fill in the name")
return False
return True
def on_save(self, _button, callback=None):
"""Save game info and destroy widget. Return True if success."""
if not self.is_valid():
return False
name = self.name_entry.get_text()
if not self.slug:
self.slug = slugify(name)
if not self.game:
self.game = Game()
year = None
if self.year_entry.get_text():
year = int(self.year_entry.get_text())
if self.lutris_config.game_config_id == TEMP_CONFIG:
self.lutris_config.game_config_id = self.get_config_id()
runner_class = runners.import_runner(self.runner_name)
runner = runner_class(self.lutris_config)
self.game.name = name
self.game.slug = self.slug
self.game.year = year
self.game.runner_name = self.runner_name
self.game.config = self.lutris_config
self.game.directory = runner.game_path
self.game.is_installed = True
if self.runner_name in ('steam', 'winesteam'):
self.game.steamid = self.lutris_config.game_config['appid']
self.game.set_platform_from_runner()
self.game.save()
self.destroy()
self.saved = True
if callback:
callback()
def on_custom_image_select(self, widget, image_type):
dialog = Gtk.FileChooserDialog("Please choose a custom image", self,
Gtk.FileChooserAction.OPEN,
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
image_filter = Gtk.FileFilter()
image_filter.set_name("Images")
image_filter.add_pixbuf_formats()
dialog.add_filter(image_filter)
response = dialog.run()
if response == Gtk.ResponseType.OK:
image_path = dialog.get_filename()
if image_type == 'banner':
self.game.has_custom_banner = True
dest_path = datapath.get_banner_path(self.game.slug)
size = BANNER_SIZE
file_format = 'jpeg'
else:
self.game.has_custom_icon = True
dest_path = datapath.get_icon_path(self.game.slug)
size = ICON_SIZE
file_format = 'png'
pixbuf = get_pixbuf(image_path, None, size)
pixbuf.savev(dest_path, file_format, [], [])
self._set_image(image_type)
dialog.destroy()
def on_custom_image_reset_clicked(self, widget, image_type):
if image_type == 'banner':
self.game.has_custom_banner = False
dest_path = datapath.get_banner_path(self.game.slug)
elif image_type == 'icon':
self.game.has_custom_icon = False
dest_path = datapath.get_icon_path(self.game.slug)
else:
raise ValueError('Unsupported image type %s', image_type)
os.remove(dest_path)
self._set_image(image_type)
示例6: _write_config
# 需要导入模块: from lutris.game import Game [as 别名]
# 或者: from lutris.game.Game import set_platform_from_runner [as 别名]
def _write_config(self):
"""Write the game configuration in the DB and config file."""
if self.extends:
logger.info('This is an extension to %s, not creating a new game entry',
self.extends)
return
configpath = make_game_config_id(self.slug)
config_filename = os.path.join(settings.CONFIG_DIR, "games/%s.yml" % configpath)
if self.requires:
# Load the base game config
required_game = pga.get_game_by_field(self.requires, field='installer_slug')
base_config = LutrisConfig(
runner_slug=self.runner,
game_config_id=required_game['configpath']
)
config = base_config.game_level
else:
config = {
'game': {},
}
self.game_id = pga.add_or_update(
name=self.name,
runner=self.runner,
slug=self.game_slug,
directory=self.target_path,
installed=1,
installer_slug=self.slug,
parent_slug=self.requires,
year=self.year,
steamid=self.steamid,
configpath=configpath,
id=self.game_id
)
game = Game(self.game_id)
game.set_platform_from_runner()
game.save()
logger.debug("Saved game entry %s (%d)", self.game_slug, self.game_id)
# Config update
if 'system' in self.script:
config['system'] = self._substitute_config(self.script['system'])
if self.runner in self.script and self.script[self.runner]:
config[self.runner] = self._substitute_config(
self.script[self.runner]
)
# Game options such as exe or main_file can be added at the root of the
# script as a shortcut, this integrates them into the game config
# properly
launcher, launcher_value = self._get_game_launcher()
if type(launcher_value) == list:
game_files = []
for game_file in launcher_value:
if game_file in self.game_files:
game_files.append(self.game_files[game_file])
else:
game_files.append(game_file)
config['game'][launcher] = game_files
elif launcher_value:
if launcher_value in self.game_files:
launcher_value = (
self.game_files[launcher_value]
)
elif self.target_path and os.path.exists(
os.path.join(self.target_path, launcher_value)
):
launcher_value = os.path.join(self.target_path, launcher_value)
config['game'][launcher] = launcher_value
if 'game' in self.script:
config['game'].update(self.script['game'])
config['game'] = self._substitute_config(config['game'])
yaml_config = yaml.safe_dump(config, default_flow_style=False)
with open(config_filename, "w") as config_file:
config_file.write(yaml_config)