add platform-specific settings + update changelog and bump version

This commit is contained in:
HJfod 2024-02-10 13:36:11 +02:00
parent bf43946daf
commit b241c1ccda
5 changed files with 39 additions and 21 deletions

View file

@ -1,5 +1,15 @@
# Geode Changelog # Geode Changelog
## v2.0.0-beta.17
* Add `$override` macro for syntactic sugar (e7a1913)
* Add support for platform-specific setting default values as well as platform-specific settings (9c8fcf1)
* Change `cc3bFromHexString` and `cc4bFromHexString` to be more strict with parsing by default (9c8fcf1)
* `JsonMaybeValue::is` is now a lot more reasonable (9c8fcf1)
* Make `LayoutOptions` also `CCObject` (3b7621c)
* Fix RobTop's socials in MenuLayer (cee8c74)
* Fix issues in CMake (d574248, 4ddd92d)
* Fix input nodes being clickable when invisible (bf32946)
## v2.0.0-beta.16 ## v2.0.0-beta.16
* Bump minimum CMake version to 3.25 * Bump minimum CMake version to 3.25
* Add support for platform-specific dependencies (30c7d3f) * Add support for platform-specific dependencies (30c7d3f)

View file

@ -1 +1 @@
2.0.0-beta.16 2.0.0-beta.17

View file

@ -817,7 +817,7 @@ namespace geode::cocos {
} }
/** /**
* Parse a ccColor3B from a hexadecimal string. The string may not contain * Parse a ccColor3B from a hexadecimal string. The string may contain
* a leading '#' * a leading '#'
* @param hexValue The string to parse into a color * @param hexValue The string to parse into a color
* @param permissive If true, strings like "f" are considered valid * @param permissive If true, strings like "f" are considered valid
@ -828,7 +828,7 @@ namespace geode::cocos {
*/ */
GEODE_DLL Result<cocos2d::ccColor3B> cc3bFromHexString(std::string const& hexValue, bool permissive = false); GEODE_DLL Result<cocos2d::ccColor3B> cc3bFromHexString(std::string const& hexValue, bool permissive = false);
/** /**
* Parse a ccColor4B from a hexadecimal string. The string may not contain * Parse a ccColor4B from a hexadecimal string. The string may contain
* a leading '#' * a leading '#'
* @param hexValue The string to parse into a color * @param hexValue The string to parse into a color
* @param requireAlpha Require the alpha component to be passed. If false, * @param requireAlpha Require the alpha component to be passed. If false,

View file

@ -172,6 +172,20 @@ Result<ModMetadata> ModMetadata::Impl::createFromSchemaV010(ModJson const& rawJs
} }
for (auto& [key, value] : root.has("settings").items()) { for (auto& [key, value] : root.has("settings").items()) {
// Skip settings not on this platform
if (value.template is<matjson::Object>()) {
auto obj = value.obj();
bool onThisPlatform = !obj.has("platforms");
for (auto& plat : obj.has("platforms").iterate()) {
if (PlatformID::from(plat.get<std::string>()) == GEODE_PLATFORM_TARGET) {
onThisPlatform = true;
}
}
if (!onThisPlatform) {
continue;
}
}
GEODE_UNWRAP_INTO(auto sett, Setting::parse(key, impl->m_id, value)); GEODE_UNWRAP_INTO(auto sett, Setting::parse(key, impl->m_id, value));
impl->m_settings.emplace_back(key, sett); impl->m_settings.emplace_back(key, sett);
} }

View file

@ -38,14 +38,7 @@ ccColor3B matjson::Serialize<ccColor3B>::from_json(matjson::Value const& json) {
} }
// hex string // hex string
else if (json.is_string()) { else if (json.is_string()) {
std::string str = json.as_string(); auto c = cc3bFromHexString(json.as_string());
if (str[0] == '#') {
str.erase(str.begin());
}
if (str.size() > 6) {
throw matjson::JsonException("Hex string for color too long");
}
auto c = cc3bFromHexString(str);
if (!c) { if (!c) {
throw matjson::JsonException("Invalid color hex string"); throw matjson::JsonException("Invalid color hex string");
} }
@ -94,14 +87,7 @@ ccColor4B matjson::Serialize<ccColor4B>::from_json(matjson::Value const& json) {
} }
// hex string // hex string
else if (json.is_string()) { else if (json.is_string()) {
std::string str = json.as_string(); auto c = cc4bFromHexString(json.as_string());
if (str[0] == '#') {
str.erase(str.begin());
}
if (str.size() > 8) {
throw matjson::JsonException("Hex string for color too long");
}
auto c = cc4bFromHexString(str);
if (!c) { if (!c) {
throw matjson::JsonException("Invalid color hex string: " + c.unwrapErr()); throw matjson::JsonException("Invalid color hex string: " + c.unwrapErr());
} }
@ -114,7 +100,11 @@ ccColor4B matjson::Serialize<ccColor4B>::from_json(matjson::Value const& json) {
return color; return color;
} }
Result<ccColor3B> geode::cocos::cc3bFromHexString(std::string const& hexValue, bool permissive) { Result<ccColor3B> geode::cocos::cc3bFromHexString(std::string const& rawHexValue, bool permissive) {
auto hexValue = rawHexValue;
if (hexValue[0] == '#') {
hexValue.erase(hexValue.begin());
}
if (permissive && hexValue.empty()) { if (permissive && hexValue.empty()) {
return Ok(ccc3(255, 255, 255)); return Ok(ccc3(255, 255, 255));
} }
@ -168,7 +158,11 @@ Result<ccColor3B> geode::cocos::cc3bFromHexString(std::string const& hexValue, b
} }
} }
Result<ccColor4B> geode::cocos::cc4bFromHexString(std::string const& hexValue, bool requireAlpha, bool permissive) { Result<ccColor4B> geode::cocos::cc4bFromHexString(std::string const& rawHexValue, bool requireAlpha, bool permissive) {
auto hexValue = rawHexValue;
if (hexValue[0] == '#') {
hexValue.erase(hexValue.begin());
}
if (permissive && hexValue.empty()) { if (permissive && hexValue.empty()) {
return Ok(ccc4(255, 255, 255, 255)); return Ok(ccc4(255, 255, 255, 255));
} }