forked from OpenEnroth/OpenEnroth
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7731d38
commit abe4267
Showing
49 changed files
with
426 additions
and
209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
#include <string> | ||
|
||
class Platform; | ||
class Environment; | ||
|
||
constexpr char mm6PathOverrideKey[] = "OPENENROTH_MM6_PATH"; | ||
constexpr char mm7PathOverrideKey[] = "OPENENROTH_MM7_PATH"; | ||
constexpr char mm8PathOverrideKey[] = "OPENENROTH_MM8_PATH"; | ||
|
||
std::string resolveMm6Path(Platform *platform); | ||
std::string resolveMm7Path(Platform *platform); | ||
std::string resolveMm8Path(Platform *platform); | ||
std::string resolveMm6Path(Environment *environment); | ||
std::string resolveMm7Path(Environment *environment); | ||
std::string resolveMm8Path(Environment *environment); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include "AndroidEnvironment.h" | ||
|
||
#include <SDL.h> | ||
|
||
std::string AndroidEnvironment::queryRegistry(const std::string &path) const { | ||
return {} | ||
} | ||
|
||
std::string AndroidEnvironment::path(EnvironmentPath path) const { | ||
const char *result = nullptr; | ||
if (path == PATH_ANDROID_STORAGE_INTERNAL) { | ||
result = SDL_AndroidGetInternalStoragePath(); | ||
} else if (path == PATH_ANDROID_STORAGE_EXTERNAL) { | ||
result = SDL_AndroidGetExternalStoragePath(); | ||
} | ||
|
||
// TODO(captainurist): No PATH_HOME on Android? Verify & write a comment here. | ||
|
||
if (result) | ||
return result; | ||
return {}; | ||
} | ||
|
||
std::string AndroidEnvironment::getenv(const std::string &key) const { | ||
const char *result = SDL_getenv(key.c_str()); | ||
if (result) | ||
return result; | ||
return {}; | ||
} | ||
|
||
std::unique_ptr<Environment> Environment::createStandardEnvironment() { | ||
return std::make_unique<AndroidEnvironment>(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#pragma once | ||
|
||
#include "Library/Environment/Interface/Environment.h" | ||
|
||
class AndroidEnvironment : public Environment { | ||
public: | ||
virtual std::string queryRegistry(const std::string &path) const override; | ||
virtual std::string path(EnvironmentPath path) const override; | ||
virtual std::string getenv(const std::string &key) const override; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
cmake_minimum_required(VERSION 3.24 FATAL_ERROR) | ||
|
||
set(LIBRARY_ENVIRONMENT_ANDROID_SOURCES | ||
AndroidEnvironment.cpp) | ||
|
||
set(LIBRARY_ENVIRONMENT_ANDROID_HEADERS | ||
AndroidEnvironment.h) | ||
|
||
if(BUILD_PLATFORM STREQUAL "android") | ||
add_library(library_environment_android STATIC ${LIBRARY_ENVIRONMENT_ANDROID_SOURCES} ${LIBRARY_ENVIRONMENT_ANDROID_HEADERS}) | ||
target_check_style(library_environment_android) | ||
target_link_libraries(library_environment_android PUBLIC library_environment_interface PRIVATE SDL2::SDL2OE) | ||
|
||
add_library(library_environment_implementation INTERFACE) | ||
target_link_libraries(library_environment_implementation INTERFACE library_environment_android) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
cmake_minimum_required(VERSION 3.24 FATAL_ERROR) | ||
|
||
add_subdirectory(Android) | ||
add_subdirectory(Interface) | ||
add_subdirectory(Posix) | ||
add_subdirectory(Win) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
cmake_minimum_required(VERSION 3.24 FATAL_ERROR) | ||
|
||
set(LIBRARY_ENVIRONMENT_INTERFACE_SOURCES) | ||
|
||
set(LIBRARY_ENVIRONMENT_INTERFACE_HEADERS | ||
Environment.h | ||
EnvironmentEnums.h) | ||
|
||
add_library(library_environment_interface INTERFACE ${LIBRARY_ENVIRONMENT_INTERFACE_SOURCES} ${LIBRARY_ENVIRONMENT_INTERFACE_HEADERS}) | ||
target_check_style(library_environment_interface) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
#include <memory> | ||
|
||
#include "EnvironmentEnums.h" | ||
|
||
class Environment { | ||
public: | ||
virtual ~Environment() = default; | ||
|
||
/** | ||
* @return Newly created standard `Environment` instance. | ||
*/ | ||
static std::unique_ptr<Environment> createStandardEnvironment(); | ||
|
||
/** | ||
* Windows-only function for querying the registry. Always returns an empty string on non-Windows systems. | ||
* | ||
* @param path Registry path to query. | ||
* @return Value at the given path, or an empty string in case of an error. | ||
*/ | ||
virtual std::string queryRegistry(const std::string &path) const = 0; | ||
|
||
/** | ||
* Accessor for various system paths. | ||
* | ||
* @param path Path to get. | ||
*/ | ||
virtual std::string path(EnvironmentPath path) const = 0; | ||
|
||
/** | ||
* Same as `std::getenv`, but takes & returns UTF8-encoded keys and values on all platforms. | ||
* | ||
* Returns an empty string for non-existent environment variables, and thus doesn't distinguish between empty and | ||
* non-existent values (and you shouldn't, either). | ||
* | ||
* @param key UTF8-encoded name of the environment variable to query. | ||
* @return UTF8-encoded value of the environment variable. | ||
*/ | ||
virtual std::string getenv(const std::string &key) const = 0; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#pragma once | ||
|
||
enum class EnvironmentPath { | ||
PATH_HOME, | ||
PATH_ANDROID_STORAGE_INTERNAL, | ||
PATH_ANDROID_STORAGE_EXTERNAL | ||
}; | ||
using enum EnvironmentPath; |
Oops, something went wrong.