(Windows) Added the %COREPATH% variable logic.

This commit is contained in:
Leon Styhre 2020-12-20 14:30:31 +01:00
parent c4752e494e
commit b0b12591e0
4 changed files with 25 additions and 3 deletions

View file

@ -754,7 +754,7 @@ Note that compilation time is much longer than on Unix or macOS, and linking tim
If you are running Windows in a virtualized environment such as QEMU-KVM that does not support HW accelerated OpenGL, you can install the Mesa3D for Windows library, which can be downloaded at [https://fdossena.com/?p=mesa/index.frag](https://fdossena.com/?p=mesa/index.frag). If you are running Windows in a virtualized environment such as QEMU-KVM that does not support HW accelerated OpenGL, you can install the Mesa3D for Windows library, which can be downloaded at [https://fdossena.com/?p=mesa/index.frag](https://fdossena.com/?p=mesa/index.frag).
You simply extract the opengl32.dll file into the ES-DE directory and this will enable the llvmpipe renderer. The performance will be terrible of course, but everything should work and it should be good enough for test building on Windows without having to reboot your computer to a native Windows installation. You simply extract the opengl32.dll file into the ES-DE directory and this will enable the llvmpipe renderer. The performance will be terrible of course, but everything should work and it should be good enough for test building on Windows without having to reboot your computer to a native Windows installation. (Note that you may need to copy opengl32.dll to your RetroArch installation directory as well to get the emulators to work correctly.)
Obviously this library is only intended for development and will not be shipped with ES-DE. Obviously this library is only intended for development and will not be shipped with ES-DE.
@ -1071,7 +1071,7 @@ The following variables are expanded by ES for the `command` tag:
`%BASENAME%` - Replaced with the "base" name of the path to the selected ROM. For example, a path of `/foo/bar.rom`, this tag would be `bar`. This tag is useful for setting up AdvanceMAME. `%BASENAME%` - Replaced with the "base" name of the path to the selected ROM. For example, a path of `/foo/bar.rom`, this tag would be `bar`. This tag is useful for setting up AdvanceMAME.
`%COREPATH%` - The core file defined after this variable will be searched in each of the directories listed in the setting EmulatorCorePath (in es_settings.cfg). This is done until the first match occurs, or until the last directory is exhausted and no core file was found. This makes it possible to create a more general es_systems.cfg file but still support the variation between different operating systems and different types of emulator installations (e.g. installed via the OS repository, via Snap, compiled from source etc.). This is primarily intended for Unix as well as for RetroArch but it can also be used on macOS and Windows and for other emulators that utilizes discrete emulator cores. For macOS and Windows the EmulatorCorePath setting is blank by default, and for Unix it's set to the following value: `~/.config/retroarch/cores:~/snap/retroarch/current/.config/retroarch/cores:/usr/lib/x86_64-linux-gnu/libretro:/usr/lib64/libretro:/usr/lib/libretro:/usr/local/lib/libretro:/usr/pkg/lib/libretro`. Note that colons are used to separate the directories. This path setting can be changed from within the GUI, as described in the [User Guide](USERGUIDE.md#other-settings-1). Never use quotation marks around the directories for this setting. It's strongly adviced to not add spaces to directory names, but if still done, ES-DE will handle this automatically by adding the appropriate quotation marks to the launch command. `%COREPATH%` - The core file defined after this variable will be searched in each of the directories listed in the setting EmulatorCorePath (in es_settings.cfg). This is done until the first match occurs, or until the last directory is exhausted and no core file was found. This makes it possible to create a more general es_systems.cfg file but still support the variation between different operating systems and different types of emulator installations (e.g. installed via the OS repository, via Snap, compiled from source etc.). This is primarily intended for Unix as well as for RetroArch but it can also be used on macOS and Windows and for other emulators that utilizes discrete emulator cores. For macOS and Windows the EmulatorCorePath setting is blank by default, and for Unix it's set to the following value: `~/.config/retroarch/cores:~/snap/retroarch/current/.config/retroarch/cores:/usr/lib/x86_64-linux-gnu/libretro:/usr/lib64/libretro:/usr/lib/libretro:/usr/local/lib/libretro:/usr/pkg/lib/libretro`. Note that colons are used to separate the directories on Unix and macOS and semicolons are used on Windows. This path setting can be changed from within the GUI, as described in the [User Guide](USERGUIDE.md#other-settings-1). Never use quotation marks around the directories for this setting. It's strongly adviced to not add spaces to directory names, but if still done, ES-DE will handle this automatically by adding the appropriate quotation marks to the launch command.
`%ROM_RAW%` - Replaced with the unescaped, absolute path to the selected ROM. If your emulator is picky about paths, you might want to use this instead of %ROM%, but enclosed in quotes. `%ROM_RAW%` - Replaced with the unescaped, absolute path to the selected ROM. If your emulator is picky about paths, you might want to use this instead of %ROM%, but enclosed in quotes.

View file

@ -902,7 +902,7 @@ Here you can override the directory to your game media, i.e. the game images and
**Emulator core path** **Emulator core path**
This setting defines the path for which to search for emulator cores. This is used by the variable %COREPATH% which can be defined in the systems configuration file es_systems.cfg. By default this variable and corresponding setting is only used on Unix. For macOS and Windows it's not included in the es_systems.cfg template and the default core path value is therefore set to blank. If required for special setups it can be used for these operating systems, but the primary use is on Unix where the core path may vary depending on the operating system, how the emulator was packaged etc. For example the default RetroArch core directory is ~/.config/retroarch/cores but if installed as a Snap package or as part of the OS repository the cores could be stored elsewhere. The setting is primarily intended for RetroArch but it can be used for any emulator that utilizes discrete emulator cores. When attempting to launch a game, the core for the game system will be searched in each of the defined directories until the first match occurs. Multiple directories can be defined by separating them using colons. Please see [INSTALL.md](INSTALL.md#es_systemscfg) for more information about this. This setting defines the path for which to search for emulator cores. This is used by the variable %COREPATH% which can be defined in the systems configuration file es_systems.cfg. By default this variable and corresponding setting is only used on Unix. For macOS and Windows it's not included in the es_systems.cfg template and the default core path value is therefore set to blank. If required for special setups it can be used for these operating systems, but the primary use is on Unix where the core path may vary depending on the operating system, how the emulator was packaged etc. For example the default RetroArch core directory is ~/.config/retroarch/cores but if installed as a Snap package or as part of the OS repository the cores could be stored elsewhere. The setting is primarily intended for RetroArch but it can be used for any emulator that utilizes discrete emulator cores. When attempting to launch a game, the core for the game system will be searched in each of the defined directories until the first match occurs. Multiple directories can be defined by separating them using colons on Unix and macOS and semicolons on Windows. Please see [INSTALL.md](INSTALL.md#es_systemscfg) for more information about this.
**Per game launch command override** **Per game launch command override**

View file

@ -768,12 +768,22 @@ void FileData::launchGame(Window* window)
// If %COREPATH% is used in es_systems.cfg for this system, try to find the emulator // If %COREPATH% is used in es_systems.cfg for this system, try to find the emulator
// core using the core paths defined in the setting EmulatorCorePath. // core using the core paths defined in the setting EmulatorCorePath.
#if defined(_WIN64)
auto corePos = commandWide.find(L"%COREPATH%");
if (corePos != std::wstring::npos && emulatorCorePath.size() > 0) {
#else
auto corePos = command.find("%COREPATH%"); auto corePos = command.find("%COREPATH%");
if (corePos != std::string::npos && emulatorCorePath.size() > 0) { if (corePos != std::string::npos && emulatorCorePath.size() > 0) {
#endif
std::string coreName; std::string coreName;
bool foundCoreFile = false; bool foundCoreFile = false;
#if defined(_WIN64)
std::vector<std::string> corePaths =
Utils::String::delimitedStringToVector(emulatorCorePath, ";");
#else
std::vector<std::string> corePaths = std::vector<std::string> corePaths =
Utils::String::delimitedStringToVector(emulatorCorePath, ":"); Utils::String::delimitedStringToVector(emulatorCorePath, ":");
#endif
auto spacePos = command.find(" ", corePos); auto spacePos = command.find(" ", corePos);
if (spacePos != std::string::npos) { if (spacePos != std::string::npos) {
coreName = command.substr(corePos + 10, spacePos - corePos - 10); coreName = command.substr(corePos + 10, spacePos - corePos - 10);
@ -786,9 +796,17 @@ void FileData::launchGame(Window* window)
Utils::FileSystem::isSymlink(coreFile)) { Utils::FileSystem::isSymlink(coreFile)) {
foundCoreFile = true; foundCoreFile = true;
if (pathHasSpaces) if (pathHasSpaces)
#if defined(_WIN64)
commandWide.replace(corePos, spacePos - corePos, L"\"" +
Utils::String::stringToWideString(coreFile) + L"\"");
else
commandWide.replace(corePos, spacePos - corePos,
Utils::String::stringToWideString(coreFile));
#else
command.replace(corePos, spacePos - corePos, "\"" + coreFile + "\""); command.replace(corePos, spacePos - corePos, "\"" + coreFile + "\"");
else else
command.replace(corePos, spacePos - corePos, coreFile); command.replace(corePos, spacePos - corePos, coreFile);
#endif
break; break;
} }
} }

View file

@ -672,7 +672,11 @@ void GuiMenu::openOtherSettings()
bracketCorePath->setResize(Vector2f(0, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight())); bracketCorePath->setResize(Vector2f(0, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()));
rowCorePath.addElement(emulator_core_path, true); rowCorePath.addElement(emulator_core_path, true);
rowCorePath.addElement(bracketCorePath, false); rowCorePath.addElement(bracketCorePath, false);
#if defined(_WIN64)
std::string titleCorePath = "ENTER EMULATOR CORE PATH (USE SEMICOLON AS SEPARATOR)";
#else
std::string titleCorePath = "ENTER EMULATOR CORE PATH (USE COLON AS SEPARATOR)"; std::string titleCorePath = "ENTER EMULATOR CORE PATH (USE COLON AS SEPARATOR)";
#endif
std::string emulatorCorePathStaticText = "Default path:"; std::string emulatorCorePathStaticText = "Default path:";
std::string defaultEmulatorCorePath = Settings::getInstance()-> std::string defaultEmulatorCorePath = Settings::getInstance()->
getDefaultString("EmulatorCorePath"); getDefaultString("EmulatorCorePath");