mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 15:45:38 +00:00
Added %ESPATH% variable support and fixed some other minor issues with the launch command.
This commit is contained in:
parent
3cad68be13
commit
472a973f66
|
@ -512,7 +512,11 @@ Here's an overview of the file layout:
|
|||
configuration as the %EMUPATH% will expand to the path of the emulator binary, which will of course also include the spaces. -->
|
||||
<command>"C:\My Games\RetroArch\retroarch.exe" -L "%EMUPATH%\cores\snes9x_libretro.dll" %ROM%</command>
|
||||
|
||||
<!-- The platform(s) to use when scraping. You can see the full list of accepted platforms in src/PlatformIds.cpp.
|
||||
<!-- An example for use in a portable emulator installation, for instance on a USB memory stick. The %ESPATH% variable is
|
||||
expanded to the directory of the ES executable. -->
|
||||
<command>"%ESPATH%\..\RetroArch\retroarch.exe" -L "%ESPATH%\..\RetroArch\cores\snes9x_libretro.dll" %ROM%</command>
|
||||
|
||||
<!-- The platform(s) to use when scraping. You can see the full list of supported platforms in src/PlatformIds.cpp.
|
||||
It's case sensitive, but everything is lowercase. This tag is optional.
|
||||
You can use multiple platforms too, delimited with any of the whitespace characters (", \r\n\t"), e.g.: "megadrive, genesis" -->
|
||||
<platform>snes</platform>
|
||||
|
@ -533,6 +537,8 @@ The following variables are expanded by ES for the `command` tag:
|
|||
|
||||
`%EMUPATH%` - Replaced with the path to the emulator binary. This is expanded either using the PATH environmental variable of the operating system, or if an absolute emulator path is defined, this will be used instead. This variable is mostly useful to define the emulator core path for Windows, as this operating system does not have a standardized program installation directory structure.
|
||||
|
||||
`%ESPATH%` - Replaced with the path to the EmulationStation binary. Mostly useful for portable emulator installations, for example on a USB memory stick.
|
||||
|
||||
For the `path` tag, the following variable is expanded by ES:
|
||||
|
||||
`%ROMPATH%` - Replaced with the path defined for the setting ROMDirectory in `es_settings.cfg`.
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "Window.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <filesystem>
|
||||
|
||||
FileData::FileData(
|
||||
FileType type,
|
||||
|
@ -110,12 +109,9 @@ const std::string FileData::getROMDirectory()
|
|||
}
|
||||
else {
|
||||
romDirPath = romDirSetting;
|
||||
// Expand home path if ~ is used.
|
||||
romDirPath = Utils::FileSystem::expandHomePath(romDirPath);
|
||||
|
||||
// Expand home symbol if the path starts with ~
|
||||
if (romDirPath[0] == '~') {
|
||||
romDirPath.erase(0, 1);
|
||||
romDirPath.insert(0, Utils::FileSystem::getHomePath());
|
||||
}
|
||||
if (romDirPath.back() != '/')
|
||||
romDirPath = romDirPath + "/";
|
||||
}
|
||||
|
@ -446,7 +442,7 @@ void FileData::launchGame(Window* window)
|
|||
|
||||
std::string command = "";
|
||||
|
||||
// Check if there is a launch string override for the game
|
||||
// Check if there is a launch command override for the game
|
||||
// and the corresponding option to use it has been set.
|
||||
if (Settings::getInstance()->getBool("LaunchCommandOverride") &&
|
||||
!metadata.get("launchcommand").empty())
|
||||
|
@ -464,6 +460,10 @@ void FileData::launchGame(Window* window)
|
|||
command = Utils::String::replace(command, "%ROM%", rom);
|
||||
command = Utils::String::replace(command, "%BASENAME%", basename);
|
||||
command = Utils::String::replace(command, "%ROM_RAW%", rom_raw);
|
||||
command = Utils::String::replace(command, "%ESPATH%", emupath);
|
||||
|
||||
// Expand home path if ~ is used.
|
||||
command = Utils::FileSystem::expandHomePath(command);
|
||||
|
||||
#ifdef _WIN64
|
||||
std::wstring commandWide = Utils::String::stringToWideString(command);
|
||||
|
@ -517,7 +517,13 @@ void FileData::launchGame(Window* window)
|
|||
}
|
||||
}
|
||||
#else
|
||||
std::string exePath = Utils::FileSystem::getPathToBinary(emuExecutable);
|
||||
std::string exePath;
|
||||
if (Utils::FileSystem::isRegularFile(emuExecutable) ||
|
||||
Utils::FileSystem::isSymlink(emuExecutable))
|
||||
exePath = Utils::FileSystem::getParent(emuExecutable);
|
||||
else
|
||||
exePath = Utils::FileSystem::getPathToBinary(emuExecutable);
|
||||
|
||||
command = Utils::String::replace(command, "%EMUPATH%", exePath);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -307,13 +307,6 @@ bool SystemData::loadConfig()
|
|||
// Convert path to generic directory seperators.
|
||||
path = Utils::FileSystem::getGenericPath(path);
|
||||
|
||||
// Expand home symbol if the startpath contains ~
|
||||
if (path[0] == '~')
|
||||
{
|
||||
path.erase(0, 1);
|
||||
path.insert(0, Utils::FileSystem::getHomePath());
|
||||
}
|
||||
|
||||
// Create the system runtime environment data.
|
||||
SystemEnvironmentData* envData = new SystemEnvironmentData;
|
||||
envData->mStartPath = path;
|
||||
|
|
|
@ -75,7 +75,7 @@ GuiMetaDataEd::GuiMetaDataEd(
|
|||
if (iter->isStatistic)
|
||||
continue;
|
||||
|
||||
// Don't show the launch string override entry if this option has been disabled.
|
||||
// Don't show the launch command override entry if this option has been disabled.
|
||||
if (!Settings::getInstance()->getBool("LaunchCommandOverride") &&
|
||||
iter->type == MD_LAUNCHCOMMAND) {
|
||||
ed = std::make_shared<TextComponent>(window, "", Font::get(FONT_SIZE_SMALL,
|
||||
|
|
|
@ -438,6 +438,15 @@ namespace Utils
|
|||
return ".";
|
||||
}
|
||||
|
||||
std::string expandHomePath(const std::string& _path)
|
||||
{
|
||||
// Expand home path if ~ is used.
|
||||
std::string expandedPath = _path;
|
||||
|
||||
expandedPath = Utils::String::replace(_path, "~", Utils::FileSystem::getHomePath());
|
||||
return expandedPath;
|
||||
}
|
||||
|
||||
std::string resolveRelativePath(const std::string& _path,
|
||||
const std::string& _relativeTo, const bool _allowHome)
|
||||
{
|
||||
|
|
|
@ -39,6 +39,7 @@ namespace Utils
|
|||
std::string getFileName(const std::string& _path);
|
||||
std::string getStem(const std::string& _path);
|
||||
std::string getExtension(const std::string& _path);
|
||||
std::string expandHomePath(const std::string& _path);
|
||||
std::string resolveRelativePath(const std::string& _path,
|
||||
const std::string& _relativeTo, const bool _allowHome);
|
||||
std::string createRelativePath(const std::string& _path,
|
||||
|
|
Loading…
Reference in a new issue