Default the game's path to the location of the entrypoint (Closes #2726)

This commit is contained in:
Mathieu Comandon 2020-06-26 16:26:02 -07:00 committed by Mathieu Comandon
parent a61628e7b1
commit 3517d86a83
9 changed files with 18 additions and 31 deletions

View file

@ -149,7 +149,7 @@ class Game(GObject.Object):
def get_browse_dir(self):
"""Return the path to open with the Browse Files action."""
return self.runner.browse_dir
return self.runner.game_path
def _get_runner(self):
"""Return the runner instance for this game's configuration"""

View file

@ -12,6 +12,7 @@ class frotz(Runner):
description = _("Z-code emulator for text adventure games such as Zork.")
platforms = [_("Z-Machine")]
runner_executable = "frotz/frotz"
entry_point_option = "story"
game_options = [
{

View file

@ -16,6 +16,8 @@ class hatari(Runner):
platforms = [_("Atari ST")]
runnable_alone = True
runner_executable = "hatari/bin/hatari"
entry_point_option = "disk-a"
game_options = [
{
"option":

View file

@ -14,6 +14,7 @@ class linux(Runner):
human_name = _("Linux")
description = _("Runs native games")
platforms = [_("Linux")]
entry_point_option = "exe"
game_options = [
{

View file

@ -18,6 +18,7 @@ class reicast(Runner):
description = _("Sega Dreamcast emulator")
platforms = [_("Sega Dreamcast")]
runner_executable = "reicast/reicast.elf"
entry_point_option = "iso"
joypads = None

View file

@ -39,6 +39,7 @@ class Runner(metaclass=RunnerMeta): # pylint: disable=too-many-public-methods
context_menu_entries = []
depends_on = None
runner_executable = None
entry_point_option = "main_file"
def __init__(self, config=None):
"""Initialize runner."""
@ -93,21 +94,18 @@ class Runner(metaclass=RunnerMeta): # pylint: disable=too-many-public-methods
"""Return the default path where games are installed."""
return self.system_config.get("game_path")
@property
def browse_dir(self):
"""Return the path to open with the Browse Files action."""
for key in self.game_config:
if key in ["exe", "main_file", "rom", "disk", "iso"]:
path = os.path.dirname(self.game_config.get(key) or "")
if not os.path.isabs(path):
path = os.path.join(self.game_path, path)
return path
return self.game_path
@property
def game_path(self):
"""Return the directory where the game is installed."""
return self.game_data.get("directory")
game_path = self.game_data.get("directory")
if game_path:
return game_path
# Default to the directory where the entry point is located.
return os.path.dirname(
os.path.expanduser(
self.game_config.get(self.entry_point_option)
)
)
@property
def working_dir(self):

View file

@ -162,15 +162,6 @@ class steam(Runner):
def appid(self):
return self.game_config.get("appid") or ""
@property
def browse_dir(self):
"""Return the path to open with the Browse Files action."""
if not self.is_installed():
installed = self.install_dialog()
if not installed:
return False
return self.game_path
def get_steam_config(self):
"""Return the "Steam" part of Steam's config.vdf as a dict."""
steam_data_dir = self.steam_data_dir

View file

@ -42,6 +42,8 @@ class wine(Runner):
human_name = _("Wine")
platforms = [_("Windows")]
multiple_versions = True
entry_point_option = "exe"
game_options = [
{
"option": "exe",

View file

@ -190,15 +190,6 @@ class winesteam(wine.wine):
_prefix = self.game_config.get("prefix") or self.get_or_create_default_prefix(arch=self.game_config.get("arch"))
return os.path.expanduser(_prefix)
@property
def browse_dir(self):
"""Return the path to open with the Browse Files action."""
if not self.is_installed():
installed = self.install_dialog()
if not installed:
return False
return self.game_path
@property
def game_path(self):
if not self.appid: