From 29c50ff5a1a2cfe1a7769ed1b4746bb58e96ebd7 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sun, 12 Jul 2020 12:47:39 +0200 Subject: [PATCH] Reintroduced the ES executable directory on Unix as a path to look for resources and themes. --- INSTALL.md | 35 ++++++++++++++++++----- es-core/src/ThemeData.cpp | 15 +++++----- es-core/src/resources/ResourceManager.cpp | 28 ++++++++++++------ 3 files changed, 56 insertions(+), 22 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index f78e01c9f..be9ae12a0 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -4,8 +4,7 @@ EmulationStation Desktop Edition - Installation and configuration **Note:** This is a quite technical document intended for those that are interested in compiling EmulationStation from source code, or would like to customize the configuration. If you just want to start using the software, check out the [User Guide](USERGUIDE.md) instead. -Development Environment -======================= +### Development Environment EmulationStation-DE is developed and compiled using both Clang/LLVM and GCC on Unix, and GCC (MinGW) on Windows. I'm intending to get Clang/LLVM working on Windows as well. @@ -137,19 +136,23 @@ Assuming the default installation prefix `/usr/local` has been used, this is the /usr/local/share/emulationstation/themes ``` -**Note:** The resources directory is critical, without it the application won't start. - -ES will look in the following locations for the resources: +ES will look in the following locations for the resources, in the listed order: * `[HOME]/.emulationstation/resources/` * `[INSTALL PREFIX]/share/emulationstation/resources/` +* `[ES EXECUTABLE DIRECTORY]/resources/` -And it will look in the following locations for the themes: +**Note:** The resources directory is critical, without it the application won't start. + +And it will look in the following locations for the themes, also in the listed order: * `[HOME]/.emulationstation/themes/` * `[INSTALL PREFIX]/share/emulationstation/themes/` +* `[ES EXECUTABLE DIRECTORY]/themes/` -The home directory will always take precedence, so any resources or themes located there will override the ones in the installation path. +The theme is not mandatory to start the application, but ES will be basically useless without it. + +So the home directory will always take precedence, and any resources or themes located there will override the ones in the installation path or the path of the ES executable. **Creating .deb and .rpm packages:** @@ -380,6 +383,24 @@ CPack: Create package CPack: - package: C:/Programming/emulationstation-de/emulationstation-de-1.0.0-win64.exe generated. ``` +The default installation directory suggested by the installer is `C:\Program Files\EmulationStation`. However this can of course be changed by the user. + +ES will look in the following locations for the resources, in the listed order: + +* `[HOME]\.emulationstation\resources\` +* `[ES EXECUTABLE DIRECTORY]\resources\` + +**Note:** The resources directory is critical, without it the application won't start. + +And it will look in the following locations for the themes, also in the listed order: + +* `[HOME]\.emulationstation\themes\` +* `[ES EXECUTABLE DIRECTORY]\themes\` + +The theme is not mandatory to start the application, but ES will be basically useless without it. + +So the home directory will always take precedence, and any resources or themes located there will override the ones in the path of the ES executable. + **Setting up a portable installation:** It's possible to easily create a portable installation of ES for Windows, for example on a USB memory stick. diff --git a/es-core/src/ThemeData.cpp b/es-core/src/ThemeData.cpp index 3bde83b0b..9b7714967 100644 --- a/es-core/src/ThemeData.cpp +++ b/es-core/src/ThemeData.cpp @@ -602,15 +602,16 @@ std::map ThemeData::getThemeSets() { std::map sets; - // Check for themes under the data installation directory for Unix or under the - // executable directory for Windows, as well as under the user home directory regardless - // of operating system. + // Check for themes first under the home directory, then under the data installation + // directory (Unix only) and last under the ES executable directory. + #ifdef __unix__ + static const size_t pathCount = 3; + #else static const size_t pathCount = 2; - std::string paths[pathCount] = - { - #ifdef _WIN64 + #endif + std::string paths[pathCount] = { Utils::FileSystem::getExePath() + "/themes", - #else + #ifdef __unix__ Utils::FileSystem::getProgramDataPath() + "/themes", #endif Utils::FileSystem::getHomePath() + "/.emulationstation/themes" diff --git a/es-core/src/resources/ResourceManager.cpp b/es-core/src/resources/ResourceManager.cpp index 7c0f23e47..a91eedd55 100644 --- a/es-core/src/resources/ResourceManager.cpp +++ b/es-core/src/resources/ResourceManager.cpp @@ -36,32 +36,44 @@ std::string ResourceManager::getResourcePath(const std::string& path) const { // Check if this is a resource file. if ((path[0] == ':') && (path[1] == '/')) { - std::string testHome; - std::string testDataPath; // Check under the home directory. + std::string testHome; + testHome = Utils::FileSystem::getHomePath() + "/.emulationstation/resources/" + &path[2]; if (Utils::FileSystem::exists(testHome)) return testHome; - // Check for the resource under the data installation directory for Unix or under - // the executable directory for Windows. - #ifdef _WIN64 - testDataPath = Utils::FileSystem::getExePath() + "/resources/" + &path[2]; - #else + // Check under the data installation directory (Unix only). + #ifdef __unix__ + std::string testDataPath; + testDataPath = Utils::FileSystem::getProgramDataPath() + "/resources/" + &path[2]; - #endif if (Utils::FileSystem::exists(testDataPath)) { return testDataPath; } + #endif + + // Check under the ES executable directory. + std::string testExePath; + + testExePath = Utils::FileSystem::getExePath() + "/resources/" + &path[2]; + + if (Utils::FileSystem::exists(testExePath)) { + return testExePath; + } + // For missing resources, log an error and terminate the application. This should // indicate that we have a broken EmulationStation installation. else { LOG(LogError) << "Error - Program resource missing: " << path; LOG(LogError) << "Tried to find the resource in the following locations:"; LOG(LogError) << testHome; + #ifdef __unix__ LOG(LogError) << testDataPath; + #endif + LOG(LogError) << testExePath; LOG(LogError) << "Has EmulationStation been properly installed?"; Scripting::fireEvent("quit"); emergencyShutdown();