mirror of
https://github.com/lutris/lutris
synced 2024-10-14 11:42:36 +00:00
Fix assets path for RetroArch
This commit is contained in:
parent
f2eccb71f7
commit
56a4cc0440
|
@ -1,5 +1,7 @@
|
|||
import os
|
||||
from lutris.runners.runner import Runner
|
||||
from lutris.util.libretro import RetroConfig
|
||||
from lutris.util import system
|
||||
from lutris import settings
|
||||
|
||||
|
||||
|
@ -36,6 +38,10 @@ def get_default_config_path():
|
|||
return os.path.join(settings.RUNNER_DIR, 'retroarch/retroarch.cfg')
|
||||
|
||||
|
||||
def get_default_assets_directory():
|
||||
return os.path.join(settings.RUNNER_DIR, 'retroarch/assets')
|
||||
|
||||
|
||||
class libretro(Runner):
|
||||
human_name = "libretro"
|
||||
description = "Multi system emulator"
|
||||
|
@ -102,10 +108,25 @@ class libretro(Runner):
|
|||
super(libretro, self).install(version, downloader, callback)
|
||||
|
||||
def get_run_data(self):
|
||||
self.prelaunch()
|
||||
return {
|
||||
'command': [self.get_executable()] + self.get_runner_parameters()
|
||||
}
|
||||
|
||||
def get_config_file(self):
|
||||
return self.runner_config.get('config_file') or get_default_config_path()
|
||||
|
||||
def prelaunch(self):
|
||||
config_file = self.get_config_file()
|
||||
if os.path.exists(config_file):
|
||||
retro_config = RetroConfig(config_file)
|
||||
|
||||
# Change assets path to the Lutris provided one if necessary
|
||||
assets_directory = os.path.expanduser(retro_config['assets_directory'])
|
||||
if system.path_is_empty(assets_directory):
|
||||
retro_config['assets_directory'] = get_default_assets_directory()
|
||||
retro_config.save()
|
||||
|
||||
def get_runner_parameters(self):
|
||||
parameters = []
|
||||
# Fullscreen
|
||||
|
@ -113,9 +134,7 @@ class libretro(Runner):
|
|||
if fullscreen:
|
||||
parameters.append('--fullscreen')
|
||||
|
||||
config_file = self.runner_config.get('config_file') \
|
||||
or get_default_config_path()
|
||||
parameters.append('--config={}'.format(config_file))
|
||||
parameters.append('--config={}'.format(self.get_config_file()))
|
||||
return parameters
|
||||
|
||||
def play(self):
|
||||
|
|
|
@ -24,7 +24,7 @@ class RetroConfig:
|
|||
value = value.strip("\"")
|
||||
self.config.append((key, value))
|
||||
|
||||
def write(self):
|
||||
def save(self):
|
||||
with open(self.config_path, 'w') as config_file:
|
||||
for (key, value) in self.config:
|
||||
config_file.write("{} = \"{}\"\n".format(key, value))
|
||||
|
|
|
@ -281,5 +281,12 @@ def path_exists(path):
|
|||
return os.path.exists(path)
|
||||
|
||||
|
||||
def path_is_empty(path):
|
||||
"""Return True is the given path doen't exist or it is an empty directory"""
|
||||
if not path_exists(path):
|
||||
return True
|
||||
return len(os.listdir(path)) == 0
|
||||
|
||||
|
||||
def stacktrace():
|
||||
traceback.print_stack()
|
||||
|
|
Loading…
Reference in a new issue