mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-22 23:48:08 -05:00
add PlatformID::toShortString and other things
This commit is contained in:
parent
e23b051a3d
commit
753fd4e152
3 changed files with 28 additions and 14 deletions
|
@ -158,6 +158,20 @@ namespace geode {
|
|||
return "Undefined";
|
||||
}
|
||||
|
||||
static constexpr char const* toShortString(Type lp, bool ignoreArch = false) {
|
||||
switch (lp) {
|
||||
case Unknown: return "unknown";
|
||||
case Windows: return "win";
|
||||
case MacOS: return "mac";
|
||||
case iOS: return "ios";
|
||||
case Android32: return ignoreArch ? "android" : "android32";
|
||||
case Android64: return ignoreArch ? "android" : "android64";
|
||||
case Linux: return "linux";
|
||||
default: break;
|
||||
}
|
||||
return "undefined";
|
||||
}
|
||||
|
||||
template <class T>
|
||||
requires requires(T t) {
|
||||
static_cast<Type>(t);
|
||||
|
|
|
@ -181,18 +181,7 @@ Result<ModMetadata> ModMetadata::Impl::create(ModJson const& json) {
|
|||
if (json["gd"].is_string()) {
|
||||
ver = json["gd"].as_string();
|
||||
} else if (json["gd"].is_object()) {
|
||||
std::string key;
|
||||
switch (GEODE_PLATFORM_TARGET) {
|
||||
case PlatformID::Android32:
|
||||
case PlatformID::Android64:
|
||||
key = "android"; break;
|
||||
case PlatformID::MacOS:
|
||||
key = "mac"; break;
|
||||
case PlatformID::Windows:
|
||||
key = "win"; break;
|
||||
case PlatformID::iOS:
|
||||
key = "ios"; break;
|
||||
}
|
||||
auto key = PlatformID::toShortString(GEODE_PLATFORM_TARGET, true);
|
||||
if (json["gd"].contains(key))
|
||||
ver = json["gd"][ver].as_string();
|
||||
} else {
|
||||
|
|
|
@ -6,14 +6,25 @@ using namespace geode::prelude;
|
|||
|
||||
PlatformID PlatformID::from(const char* str) {
|
||||
switch (hash(str)) {
|
||||
default:
|
||||
case hash("unknown"): return PlatformID::Unknown;
|
||||
case hash("win"):
|
||||
case hash("Windows"):
|
||||
case hash("windows"): return PlatformID::Windows;
|
||||
|
||||
case hash("mac"):
|
||||
case hash("MacOS"):
|
||||
case hash("macos"): return PlatformID::MacOS;
|
||||
|
||||
case hash("iOS"):
|
||||
case hash("ios"): return PlatformID::iOS;
|
||||
|
||||
case hash("Android32"):
|
||||
case hash("android32"): return PlatformID::Android32;
|
||||
case hash("Android64"):
|
||||
case hash("android64"): return PlatformID::Android64;
|
||||
|
||||
case hash("Linux"):
|
||||
case hash("linux"): return PlatformID::Linux;
|
||||
default: return PlatformID::Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue