From 8320cf60574b3e2d5a2f28d8cc751fa6b6853260 Mon Sep 17 00:00:00 2001 From: altalk23 <45172705+altalk23@users.noreply.github.com> Date: Mon, 4 Nov 2024 21:27:14 +0300 Subject: [PATCH] Alias V3 settings to default --- loader/include/Geode/Loader.hpp | 2 +- loader/include/Geode/loader/Event.hpp | 6 +-- loader/include/Geode/loader/Mod.hpp | 12 ++--- loader/include/Geode/loader/ModMetadata.hpp | 2 +- .../Geode/loader/ModSettingsManager.hpp | 8 +--- loader/include/Geode/loader/Setting.hpp | 48 +++++++++++++++++++ loader/include/Geode/loader/SettingV3.hpp | 34 ++++++------- loader/include/Geode/loader/Types.hpp | 3 -- loader/include/Geode/platform/platform.hpp | 26 ++++++---- loader/include/Geode/ui/SceneManager.hpp | 10 ++-- loader/src/hooks/persist.cpp | 13 +++-- loader/src/loader/Mod.cpp | 2 +- loader/src/loader/ModImpl.cpp | 8 ++-- loader/src/loader/ModMetadataImpl.cpp | 2 +- loader/src/loader/ModMetadataImpl.hpp | 2 +- loader/src/loader/ModSettingsManager.cpp | 37 ++++++-------- loader/src/loader/SettingNode.hpp | 16 +++++++ loader/src/loader/SettingNodeV3.hpp | 2 +- loader/src/loader/SettingV3.cpp | 14 ++---- loader/src/ui/mods/ModsLayer.cpp | 2 +- loader/src/ui/mods/ModsLayer.hpp | 4 +- loader/src/ui/mods/list/ModItem.cpp | 2 +- loader/src/ui/mods/list/ModItem.hpp | 2 +- loader/src/ui/mods/popups/ModPopup.cpp | 2 +- loader/src/ui/mods/popups/ModPopup.hpp | 2 +- .../src/ui/mods/settings/ModSettingsPopup.cpp | 19 ++++---- .../src/ui/mods/settings/ModSettingsPopup.hpp | 8 ++-- loader/src/utils/PlatformID.cpp | 5 -- 28 files changed, 167 insertions(+), 126 deletions(-) create mode 100644 loader/include/Geode/loader/Setting.hpp create mode 100644 loader/src/loader/SettingNode.hpp diff --git a/loader/include/Geode/Loader.hpp b/loader/include/Geode/Loader.hpp index 3de671be..a1bb4c37 100644 --- a/loader/include/Geode/Loader.hpp +++ b/loader/include/Geode/Loader.hpp @@ -5,7 +5,7 @@ #include "loader/Log.hpp" #include "loader/Mod.hpp" #include "loader/ModEvent.hpp" -#include "loader/SettingV3.hpp" +#include "loader/Setting.hpp" #include "loader/Dirs.hpp" #include diff --git a/loader/include/Geode/loader/Event.hpp b/loader/include/Geode/loader/Event.hpp index d7420a03..8f88cb54 100644 --- a/loader/include/Geode/loader/Event.hpp +++ b/loader/include/Geode/loader/Event.hpp @@ -51,6 +51,7 @@ namespace geode { private: static DefaultEventListenerPool* create(); + DefaultEventListenerPool(); public: bool add(EventListenerProtocol* listener) override; @@ -63,10 +64,7 @@ namespace geode { friend class DispatchEvent; template - friend class DispatchFilter; - - // todo: make this private in Geode 4.0.0 - DefaultEventListenerPool(); + friend class DispatchFilter; }; class GEODE_DLL EventListenerProtocol { diff --git a/loader/include/Geode/loader/Mod.hpp b/loader/include/Geode/loader/Mod.hpp index 99cb2b9d..5639e628 100644 --- a/loader/include/Geode/loader/Mod.hpp +++ b/loader/include/Geode/loader/Mod.hpp @@ -9,7 +9,7 @@ #include "Loader.hpp" // very nice circular dependency fix #include "Hook.hpp" #include "ModMetadata.hpp" -#include "SettingV3.hpp" +#include "Setting.hpp" #include "Types.hpp" #include "Loader.hpp" @@ -22,9 +22,7 @@ #include #include -namespace geode { - class SettingV3; - +namespace geode { template struct HandleToSaved : public T { Mod* m_mod; @@ -182,7 +180,7 @@ namespace geode { * `Mod::registerCustomSettingType` * @param key The key of the setting as defined in `mod.json` */ - std::shared_ptr getSettingV3(std::string_view const key) const; + std::shared_ptr getSetting(std::string_view const key) const; /** * Register a custom setting type. See @@ -245,7 +243,7 @@ namespace geode { template T getSettingValue(std::string_view const key) const { using S = typename SettingTypeForValueType::SettingType; - if (auto sett = cast::typeinfo_pointer_cast(this->getSettingV3(key))) { + if (auto sett = cast::typeinfo_pointer_cast(this->getSetting(key))) { return sett->getValue(); } return T(); @@ -254,7 +252,7 @@ namespace geode { template T setSettingValue(std::string_view const key, T const& value) { using S = typename SettingTypeForValueType::SettingType; - if (auto sett = cast::typeinfo_pointer_cast(this->getSettingV3(key))) { + if (auto sett = cast::typeinfo_pointer_cast(this->getSetting(key))) { auto old = sett->getValue(); sett->setValue(value); return old; diff --git a/loader/include/Geode/loader/ModMetadata.hpp b/loader/include/Geode/loader/ModMetadata.hpp index 0316c6c1..9c0c553f 100644 --- a/loader/include/Geode/loader/ModMetadata.hpp +++ b/loader/include/Geode/loader/ModMetadata.hpp @@ -171,7 +171,7 @@ namespace geode { * Mod settings * @note Not a map because insertion order must be preserved */ - [[nodiscard]] std::vector> getSettingsV3() const; + [[nodiscard]] std::vector> getSettings() const; /** * Get the tags for this mod */ diff --git a/loader/include/Geode/loader/ModSettingsManager.hpp b/loader/include/Geode/loader/ModSettingsManager.hpp index 6baa355d..6f5db523 100644 --- a/loader/include/Geode/loader/ModSettingsManager.hpp +++ b/loader/include/Geode/loader/ModSettingsManager.hpp @@ -1,7 +1,7 @@ #pragma once #include -#include "SettingV3.hpp" +#include "Setting.hpp" namespace geode { class Mod; @@ -57,12 +57,8 @@ namespace geode { matjson::Value& getSaveData(); Result<> registerCustomSettingType(std::string_view type, SettingGenerator generator); - // todo in v4: remove this - Result<> registerLegacyCustomSetting(std::string_view key, std::unique_ptr&& ptr); - std::shared_ptr get(std::string_view key); - std::shared_ptr getLegacy(std::string_view key); - std::optional getLegacyDefinition(std::string_view key); + std::shared_ptr get(std::string_view key); /** * Returns true if any setting with the `"restart-required"` attribute diff --git a/loader/include/Geode/loader/Setting.hpp b/loader/include/Geode/loader/Setting.hpp new file mode 100644 index 00000000..3ae2ef7b --- /dev/null +++ b/loader/include/Geode/loader/Setting.hpp @@ -0,0 +1,48 @@ +#pragma once +#include "SettingV3.hpp" + +namespace geode { + using Setting = SettingV3; + using SettingGenerator = SettingGeneratorV3; + + template + using SettingBaseValue = SettingBaseValueV3; + + using TitleSetting = TitleSettingV3; + using BoolSetting = BoolSettingV3; + using IntSetting = IntSettingV3; + using FloatSetting = FloatSettingV3; + using StringSetting = StringSettingV3; + using FileSetting = FileSettingV3; + using Color3BSetting = Color3BSettingV3; + using Color4BSetting = Color4BSettingV3; + + using SettingNode = SettingNodeV3; + template + using SettingValueNode = SettingValueNodeV3; + + using SettingChangedEvent = SettingChangedEventV3; + using SettingChangedFilter = SettingChangedFilterV3; + using SettingNodeSizeChangeEvent = SettingNodeSizeChangeEventV3; + using SettingNodeValueChangeEvent = SettingNodeValueChangeEventV3; + + template + using SettingTypeForValueType = SettingTypeForValueTypeV3; + + template + EventListener* listenForSettingChanges(std::string_view settingKey, Lambda&& callback, Mod* mod = getMod()) { + return listenForSettingChangesV3(settingKey, std::forward(callback), mod); + } + + template + EventListener* listenForSettingChanges(std::string_view settingKey, Lambda&& callback, Mod* mod = getMod()) { + return listenForSettingChangesV3(settingKey, std::forward(callback), mod); + } + + inline EventListener* listenForAllSettingChanges( + std::function)> const& callback, + Mod* mod = getMod() + ) { + return listenForAllSettingChangesV3(callback, mod); + } +} \ No newline at end of file diff --git a/loader/include/Geode/loader/SettingV3.hpp b/loader/include/Geode/loader/SettingV3.hpp index bea8bda8..bf6e528f 100644 --- a/loader/include/Geode/loader/SettingV3.hpp +++ b/loader/include/Geode/loader/SettingV3.hpp @@ -14,8 +14,6 @@ class ModSettingsPopup; namespace geode { class ModSettingsManager; class SettingNodeV3; - // todo in v4: remove this - class SettingValue; class GEODE_DLL SettingV3 : public std::enable_shared_from_this { private: @@ -122,8 +120,6 @@ namespace geode { */ void markChanged(); - friend class ::geode::SettingValue; - public: SettingV3(); virtual ~SettingV3(); @@ -182,7 +178,7 @@ namespace geode { virtual void reset() = 0; }; - using SettingGenerator = std::function>( + using SettingGeneratorV3 = std::function>( std::string const& key, std::string const& modID, matjson::Value const& json @@ -697,45 +693,45 @@ namespace geode { }; template - struct SettingTypeForValueType { + struct SettingTypeForValueTypeV3 { static_assert( !std::is_same_v, - "specialize the SettingTypeForValueType class to use Mod::getSettingValue for custom settings" + "specialize the SettingTypeForValueTypeV3 class to use Mod::getSettingValue for custom settings" ); }; template <> - struct SettingTypeForValueType { + struct SettingTypeForValueTypeV3 { using SettingType = BoolSettingV3; }; template <> - struct SettingTypeForValueType { + struct SettingTypeForValueTypeV3 { using SettingType = IntSettingV3; }; template <> - struct SettingTypeForValueType { + struct SettingTypeForValueTypeV3 { using SettingType = FloatSettingV3; }; template <> - struct SettingTypeForValueType { + struct SettingTypeForValueTypeV3 { using SettingType = StringSettingV3; }; template <> - struct SettingTypeForValueType { + struct SettingTypeForValueTypeV3 { using SettingType = FileSettingV3; }; template <> - struct SettingTypeForValueType { + struct SettingTypeForValueTypeV3 { using SettingType = Color3BSettingV3; }; template <> - struct SettingTypeForValueType { + struct SettingTypeForValueTypeV3 { using SettingType = Color4BSettingV3; }; template - EventListener* listenForSettingChanges(std::string_view settingKey, auto&& callback, Mod* mod = getMod()) { - using Ty = typename SettingTypeForValueType::SettingType; + EventListener* listenForSettingChangesV3(std::string_view settingKey, auto&& callback, Mod* mod = getMod()) { + using Ty = typename SettingTypeForValueTypeV3::SettingType; return new EventListener( [callback = std::move(callback)](std::shared_ptr setting) { if (auto ty = geode::cast::typeinfo_pointer_cast(setting)) { @@ -745,11 +741,11 @@ namespace geode { SettingChangedFilterV3(mod, std::string(settingKey)) ); } - EventListener* listenForSettingChanges(std::string_view settingKey, auto&& callback, Mod* mod = getMod()) { + EventListener* listenForSettingChangesV3(std::string_view settingKey, auto&& callback, Mod* mod = getMod()) { using T = std::remove_cvref_t>; - return listenForSettingChanges(settingKey, std::move(callback), mod); + return listenForSettingChangesV3(settingKey, std::move(callback), mod); } - GEODE_DLL EventListener* listenForAllSettingChanges( + GEODE_DLL EventListener* listenForAllSettingChangesV3( std::function)> const& callback, Mod* mod = getMod() ); diff --git a/loader/include/Geode/loader/Types.hpp b/loader/include/Geode/loader/Types.hpp index ba869cf5..e5243a47 100644 --- a/loader/include/Geode/loader/Types.hpp +++ b/loader/include/Geode/loader/Types.hpp @@ -89,14 +89,11 @@ namespace geode { constexpr std::string_view GEODE_MOD_EXTENSION = ".geode"; class Mod; - class Setting; class Loader; class Hook; class VersionInfo; class Unknown; - using unknownmemfn_t = void (Unknown::*)(); - using unknownfn_t = void (*)(); namespace modifier { template diff --git a/loader/include/Geode/platform/platform.hpp b/loader/include/Geode/platform/platform.hpp index c8d52484..2ef19b36 100644 --- a/loader/include/Geode/platform/platform.hpp +++ b/loader/include/Geode/platform/platform.hpp @@ -116,14 +116,22 @@ namespace geode { public: // todo in v4: make these flags and add archless Mac and Android as well as Desktop and Mobile and remove Linux enum { - Unknown = -1, - Windows = 0, - MacIntel = 1, - MacArm = 2, - iOS = 3, - Android32 = 4, - Android64 = 5, - Linux = 6, + Unknown = 0b000000, + Windows = 0b000001, + Android32 = 0b000010, + Android64 = 0b000100, + MacIntel = 0b001000, + MacArm = 0b010000, + iOS = 0b100000, + Android = Android32 | Android64, + Mac = MacIntel | MacArm, + Apple = Mac | iOS, + X64 = MacIntel | Windows, + X86 = Unknown, + ArmV7 = Android32, + ArmV8 = Android64 | MacArm | iOS, + Desktop = Windows | Mac, + Mobile = Android | iOS, }; using Type = decltype(Unknown); @@ -190,7 +198,6 @@ namespace geode { case iOS: return "iOS"; case Android32: return "Android32"; case Android64: return "Android64"; - case Linux: return "Linux"; default: break; } return "Undefined"; @@ -206,7 +213,6 @@ namespace geode { case iOS: return "ios"; case Android32: return ignoreArch ? "android" : "android32"; case Android64: return ignoreArch ? "android" : "android64"; - case Linux: return "linux"; default: break; } return "undefined"; diff --git a/loader/include/Geode/ui/SceneManager.hpp b/loader/include/Geode/ui/SceneManager.hpp index 961003e1..2c57c564 100644 --- a/loader/include/Geode/ui/SceneManager.hpp +++ b/loader/include/Geode/ui/SceneManager.hpp @@ -8,6 +8,8 @@ #include namespace geode { + struct SceneSwitch; + class GEODE_DLL SceneManager final { protected: std::vector> m_persistedNodes; @@ -15,6 +17,10 @@ namespace geode { virtual ~SceneManager(); + void willSwitchToScene(cocos2d::CCScene* scene); + + friend struct SceneSwitch; + public: static SceneManager* get(); @@ -34,9 +40,5 @@ namespace geode { * Gets a span of the persisted nodes. To add new nodes to the list, use keepAcrossScenes. */ std::span const> getPersistedNodes(); - - // This method should only be called by geode itself - // TODO(v4): hide this - void willSwitchToScene(cocos2d::CCScene* scene); }; } diff --git a/loader/src/hooks/persist.cpp b/loader/src/hooks/persist.cpp index 44a18d14..0c0ea468 100644 --- a/loader/src/hooks/persist.cpp +++ b/loader/src/hooks/persist.cpp @@ -2,10 +2,15 @@ using namespace geode::prelude; +#ifdef GEODE_IS_WINDOWS +#include +#else +#include +#endif + +namespace geode { #ifdef GEODE_IS_WINDOWS - -#include struct SceneSwitch : Modify { GEODE_FORWARD_COMPAT_DISABLE_HOOKS("persist disabled") void willSwitchToScene(CCScene* scene) { @@ -15,8 +20,6 @@ struct SceneSwitch : Modify { }; #else - -#include struct SceneSwitch : Modify { GEODE_FORWARD_COMPAT_DISABLE_HOOKS("persist disabled") void willSwitchToScene(CCScene* scene) { @@ -26,3 +29,5 @@ struct SceneSwitch : Modify { }; #endif + +} \ No newline at end of file diff --git a/loader/src/loader/Mod.cpp b/loader/src/loader/Mod.cpp index c377f9c6..0bddeacc 100644 --- a/loader/src/loader/Mod.cpp +++ b/loader/src/loader/Mod.cpp @@ -152,7 +152,7 @@ bool Mod::hasSetting(std::string_view const key) const { return m_impl->hasSetting(key); } -std::shared_ptr Mod::getSettingV3(std::string_view const key) const { +std::shared_ptr Mod::getSetting(std::string_view const key) const { return m_impl->m_settings->get(std::string(key)); } diff --git a/loader/src/loader/ModImpl.cpp b/loader/src/loader/ModImpl.cpp index 0334e06d..963925f4 100644 --- a/loader/src/loader/ModImpl.cpp +++ b/loader/src/loader/ModImpl.cpp @@ -229,19 +229,19 @@ Result<> Mod::Impl::saveData() { } bool Mod::Impl::hasSettings() const { - return m_metadata.getSettingsV3().size(); + return m_metadata.getSettings().size(); } std::vector Mod::Impl::getSettingKeys() const { std::vector keys; - for (auto& [key, _] : m_metadata.getSettingsV3()) { + for (auto& [key, _] : m_metadata.getSettings()) { keys.push_back(key); } return keys; } bool Mod::Impl::hasSetting(std::string_view const key) const { - for (auto& setting : m_metadata.getSettingsV3()) { + for (auto& setting : m_metadata.getSettings()) { if (setting.first == key) { return true; } @@ -681,8 +681,6 @@ ModJson Mod::Impl::getRuntimeInfo() const { for (auto patch : m_patches) { obj["patches"].as_array().push_back(ModJson(patch->getRuntimeInfo())); } - // TODO: so which one is it - // obj["enabled"] = m_enabled; obj["loaded"] = m_enabled; obj["temp-dir"] = this->getTempDir(); obj["save-dir"] = this->getSaveDir(); diff --git a/loader/src/loader/ModMetadataImpl.cpp b/loader/src/loader/ModMetadataImpl.cpp index 54162a44..0924187a 100644 --- a/loader/src/loader/ModMetadataImpl.cpp +++ b/loader/src/loader/ModMetadataImpl.cpp @@ -519,7 +519,7 @@ std::vector ModMetadata::getIncompatibilities() co std::vector ModMetadata::getSpritesheets() const { return m_impl->m_spritesheets; } -std::vector> ModMetadata::getSettingsV3() const { +std::vector> ModMetadata::getSettings() const { return m_impl->m_settings; } std::unordered_set ModMetadata::getTags() const { diff --git a/loader/src/loader/ModMetadataImpl.hpp b/loader/src/loader/ModMetadataImpl.hpp index fbf97448..f14ab996 100644 --- a/loader/src/loader/ModMetadataImpl.hpp +++ b/loader/src/loader/ModMetadataImpl.hpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include using namespace geode::prelude; diff --git a/loader/src/loader/ModSettingsManager.cpp b/loader/src/loader/ModSettingsManager.cpp index 23615909..c908bb27 100644 --- a/loader/src/loader/ModSettingsManager.cpp +++ b/loader/src/loader/ModSettingsManager.cpp @@ -13,17 +13,17 @@ private: std::unordered_map m_types; SharedSettingTypesPool() : m_types({ - { "title", &TitleSettingV3::parse }, - { "bool", &BoolSettingV3::parse }, - { "int", &IntSettingV3::parse }, - { "float", &FloatSettingV3::parse }, - { "string", &StringSettingV3::parse }, - { "file", &FileSettingV3::parse }, - { "folder", &FileSettingV3::parse }, - { "path", &FileSettingV3::parse }, - { "rgb", &Color3BSettingV3::parse }, - { "color", &Color3BSettingV3::parse }, - { "rgba", &Color4BSettingV3::parse }, + { "title", &TitleSetting::parse }, + { "bool", &BoolSetting::parse }, + { "int", &IntSetting::parse }, + { "float", &FloatSetting::parse }, + { "string", &StringSetting::parse }, + { "file", &FileSetting::parse }, + { "folder", &FileSetting::parse }, + { "path", &FileSetting::parse }, + { "rgb", &Color3BSetting::parse }, + { "color", &Color3BSetting::parse }, + { "rgba", &Color4BSetting::parse }, }) {} public: @@ -78,9 +78,7 @@ public: struct SettingInfo final { std::string type; matjson::Value json; - std::shared_ptr v3 = nullptr; - // todo: remove in v4 - std::shared_ptr legacy = nullptr; + std::shared_ptr v3 = nullptr; }; std::string modID; std::unordered_map settings; @@ -159,7 +157,7 @@ ModSettingsManager::ModSettingsManager(ModMetadata const& metadata) : m_impl(std::make_unique()) { m_impl->modID = metadata.getID(); - for (auto const& [key, json] : metadata.getSettingsV3()) { + for (auto const& [key, json] : metadata.getSettings()) { auto setting = Impl::SettingInfo(); setting.json = json; auto root = checkJson(json, "setting"); @@ -195,13 +193,6 @@ Result<> ModSettingsManager::registerCustomSettingType(std::string_view type, Se m_impl->createSettings(); return Ok(); } -Result<> ModSettingsManager::registerLegacyCustomSetting(std::string_view key, std::unique_ptr&& ptr) { - auto id = std::string(key); - if (!m_impl->settings.count(id)) { - return Err("No such setting '{}' in mod {}", id, m_impl->modID); - } - return Ok(); -} Result<> ModSettingsManager::load(matjson::Value const& json) { if (json.is_object()) { @@ -225,7 +216,7 @@ matjson::Value& ModSettingsManager::getSaveData() { return m_impl->savedata; } -std::shared_ptr ModSettingsManager::get(std::string_view key) { +std::shared_ptr ModSettingsManager::get(std::string_view key) { auto id = std::string(key); return m_impl->settings.count(id) ? m_impl->settings.at(id).v3 : nullptr; } diff --git a/loader/src/loader/SettingNode.hpp b/loader/src/loader/SettingNode.hpp new file mode 100644 index 00000000..1e4d1e5e --- /dev/null +++ b/loader/src/loader/SettingNode.hpp @@ -0,0 +1,16 @@ +#pragma once +#include "SettingNodeV3.hpp" + +using namespace geode::prelude; + +using TitleSettingNode = TitleSettingNodeV3; +using BoolSettingNode = BoolSettingNodeV3; +template +using NumberSettingNode = NumberSettingNodeV3; +using IntSettingNode = IntSettingNodeV3; +using FloatSettingNode = FloatSettingNodeV3; +using StringSettingNode = StringSettingNodeV3; +using FileSettingNode = FileSettingNodeV3; +using Color3BSettingNode = Color3BSettingNodeV3; +using Color4BSettingNode = Color4BSettingNodeV3; +using UnresolvedCustomSettingNode = UnresolvedCustomSettingNodeV3; \ No newline at end of file diff --git a/loader/src/loader/SettingNodeV3.hpp b/loader/src/loader/SettingNodeV3.hpp index be462eb5..794379b7 100644 --- a/loader/src/loader/SettingNodeV3.hpp +++ b/loader/src/loader/SettingNodeV3.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include #include diff --git a/loader/src/loader/SettingV3.cpp b/loader/src/loader/SettingV3.cpp index e7b3292a..7f0d91b3 100644 --- a/loader/src/loader/SettingV3.cpp +++ b/loader/src/loader/SettingV3.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -45,7 +45,7 @@ namespace enable_if_parsing { if (!mod->hasSetting(settingID)) { return Err("Mod '{}' does not have setting '{}'", mod->getName(), settingID); } - if (!typeinfo_pointer_cast(mod->getSettingV3(settingID))) { + if (!typeinfo_pointer_cast(mod->getSetting(settingID))) { return Err("Setting '{}' in mod '{}' is not a boolean setting", settingID, mod->getName()); } } @@ -59,7 +59,7 @@ namespace enable_if_parsing { // This is an if-check just in case, even though check() should already // make sure that getSettingV3 is guaranteed to return true auto name = settingID; - if (auto sett = mod->getSettingV3(settingID)) { + if (auto sett = mod->getSetting(settingID)) { name = sett->getDisplayName(); } if (modID == defaultModID) { @@ -446,7 +446,7 @@ SettingChangedFilterV3::SettingChangedFilterV3(Mod* mod, std::optional* geode::listenForAllSettingChanges( +EventListener* geode::listenForAllSettingChangesV3( std::function)> const& callback, Mod* mod ) { @@ -572,12 +572,6 @@ void SettingV3::markChanged() { manager->markRestartRequired(); } SettingChangedEventV3(shared_from_this()).post(); - if (manager) { - // TODO: v4 - // Use ModSettingsManager rather than convertToLegacyValue since it - // caches the result and we want to have that for performance - // SettingChangedEvent(this->getMod(), manager->getLegacy(this->getKey()).get()).post(); - } } class TitleSettingV3::Impl final { public: diff --git a/loader/src/ui/mods/ModsLayer.cpp b/loader/src/ui/mods/ModsLayer.cpp index 27fc2866..64985430 100644 --- a/loader/src/ui/mods/ModsLayer.cpp +++ b/loader/src/ui/mods/ModsLayer.cpp @@ -90,7 +90,7 @@ bool ModsStatusNode::init() { m_downloadListener.bind([this](auto) { this->updateState(); }); - m_settingNodeListener.bind([this](SettingNodeValueChangeEventV3* ev) { + m_settingNodeListener.bind([this](SettingNodeValueChangeEvent* ev) { this->updateState(); return ListenerResult::Propagate; }); diff --git a/loader/src/ui/mods/ModsLayer.hpp b/loader/src/ui/mods/ModsLayer.hpp index 35e36b97..ed585239 100644 --- a/loader/src/ui/mods/ModsLayer.hpp +++ b/loader/src/ui/mods/ModsLayer.hpp @@ -12,7 +12,7 @@ #include "sources/ModListSource.hpp" #include "UpdateModListState.hpp" #include -#include +#include using namespace geode::prelude; @@ -40,7 +40,7 @@ protected: EventListener m_updateStateListener; EventListener m_downloadListener; DownloadState m_lastState = DownloadState::None; - EventListener> m_settingNodeListener; + EventListener> m_settingNodeListener; bool init(); void updateState(); diff --git a/loader/src/ui/mods/list/ModItem.cpp b/loader/src/ui/mods/list/ModItem.cpp index 570c89d7..abe3c536 100644 --- a/loader/src/ui/mods/list/ModItem.cpp +++ b/loader/src/ui/mods/list/ModItem.cpp @@ -303,7 +303,7 @@ bool ModItem::init(ModSource&& source) { m_downloadListener.bind([this](auto) { this->updateState(); }); m_downloadListener.setFilter(server::ModDownloadFilter(m_source.getID())); - m_settingNodeListener.bind([this](SettingNodeValueChangeEventV3*) { + m_settingNodeListener.bind([this](SettingNodeValueChangeEvent*) { this->updateState(); return ListenerResult::Propagate; }); diff --git a/loader/src/ui/mods/list/ModItem.hpp b/loader/src/ui/mods/list/ModItem.hpp index f5f9fc90..c6a3fa75 100644 --- a/loader/src/ui/mods/list/ModItem.hpp +++ b/loader/src/ui/mods/list/ModItem.hpp @@ -35,7 +35,7 @@ protected: EventListener>> m_checkUpdateListener; EventListener m_downloadListener; std::optional m_availableUpdate; - EventListener> m_settingNodeListener; + EventListener> m_settingNodeListener; /** * @warning Make sure `getMetadata` and `createModLogo` are callable diff --git a/loader/src/ui/mods/popups/ModPopup.cpp b/loader/src/ui/mods/popups/ModPopup.cpp index 07762c6f..1d8b6f8a 100644 --- a/loader/src/ui/mods/popups/ModPopup.cpp +++ b/loader/src/ui/mods/popups/ModPopup.cpp @@ -618,7 +618,7 @@ bool ModPopup::setup(ModSource&& src) { m_downloadListener.bind([this](auto) { this->updateState(); }); m_downloadListener.setFilter(m_source.getID()); - m_settingNodeListener.bind([this](SettingNodeValueChangeEventV3*) { + m_settingNodeListener.bind([this](SettingNodeValueChangeEvent*) { this->updateState(); return ListenerResult::Propagate; }); diff --git a/loader/src/ui/mods/popups/ModPopup.hpp b/loader/src/ui/mods/popups/ModPopup.hpp index c5689af3..bb660302 100644 --- a/loader/src/ui/mods/popups/ModPopup.hpp +++ b/loader/src/ui/mods/popups/ModPopup.hpp @@ -42,7 +42,7 @@ protected: EventListener>> m_checkUpdateListener; EventListener m_updateStateListener; EventListener m_downloadListener; - EventListener> m_settingNodeListener; + EventListener> m_settingNodeListener; bool setup(ModSource&& src) override; void updateState(); diff --git a/loader/src/ui/mods/settings/ModSettingsPopup.cpp b/loader/src/ui/mods/settings/ModSettingsPopup.cpp index a68e9aa2..22a0dacf 100644 --- a/loader/src/ui/mods/settings/ModSettingsPopup.cpp +++ b/loader/src/ui/mods/settings/ModSettingsPopup.cpp @@ -6,12 +6,13 @@ #include #include #include -#include +#include +#include // needed for weightedFuzzyMatch #include -static bool matchSearch(SettingNodeV3* node, std::string const& query) { - if (typeinfo_cast(node)) { +static bool matchSearch(SettingNode* node, std::string const& query) { + if (typeinfo_cast(node)) { return true; } bool addToList = false; @@ -73,12 +74,12 @@ bool ModSettingsPopup::setup(Mod* mod) { m_list->setTouchEnabled(true); for (auto& key : mod->getSettingKeys()) { - SettingNodeV3* node; - if (auto sett = mod->getSettingV3(key)) { + SettingNode* node; + if (auto sett = mod->getSetting(key)) { node = sett->createNode(layerSize.width); } else { - node = UnresolvedCustomSettingNodeV3::create(key, mod, layerSize.width); + node = UnresolvedCustomSettingNode::create(key, mod, layerSize.width); } m_settings.push_back(node); @@ -249,7 +250,7 @@ void ModSettingsPopup::onClearSearch(CCObject*) { m_list->moveToTop(); } -void ModSettingsPopup::updateState(SettingNodeV3* invoker) { +void ModSettingsPopup::updateState(SettingNode* invoker) { auto search = m_searchInput->getString(); auto hasSearch = !search.empty(); @@ -261,10 +262,10 @@ void ModSettingsPopup::updateState(SettingNodeV3* invoker) { // Update search visibility + all settings with "enable-if" schemes + // checkerboard BG - TitleSettingNodeV3* lastTitle = nullptr; + TitleSettingNode* lastTitle = nullptr; bool bg = false; for (auto& sett : m_settings) { - if (auto asTitle = typeinfo_cast(sett.data())) { + if (auto asTitle = typeinfo_cast(sett.data())) { lastTitle = asTitle; } sett->removeFromParent(); diff --git a/loader/src/ui/mods/settings/ModSettingsPopup.hpp b/loader/src/ui/mods/settings/ModSettingsPopup.hpp index c569d53f..506d157d 100644 --- a/loader/src/ui/mods/settings/ModSettingsPopup.hpp +++ b/loader/src/ui/mods/settings/ModSettingsPopup.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include #include @@ -14,17 +14,17 @@ class ModSettingsPopup : public GeodePopup { protected: Mod* m_mod; ScrollLayer* m_list; - std::vector> m_settings; + std::vector> m_settings; CCMenu* m_applyMenu; CCMenuItemSpriteExtra* m_applyBtn; CCMenuItemSpriteExtra* m_restartBtn; ButtonSprite* m_applyBtnSpr; TextInput* m_searchInput; CCMenuItemSpriteExtra* m_searchClearBtn; - EventListener> m_changeListener; + EventListener> m_changeListener; bool setup(Mod* mod) override; - void updateState(SettingNodeV3* invoker = nullptr); + void updateState(SettingNode* invoker = nullptr); bool hasUncommitted() const; void onClose(CCObject*) override; void onApply(CCObject*); diff --git a/loader/src/utils/PlatformID.cpp b/loader/src/utils/PlatformID.cpp index 49038918..a3fb35a7 100644 --- a/loader/src/utils/PlatformID.cpp +++ b/loader/src/utils/PlatformID.cpp @@ -33,8 +33,6 @@ PlatformID PlatformID::from(const char* str) { case hash("Android64"): case hash("android64"): return PlatformID::Android64; - case hash("Linux"): - case hash("linux"): return PlatformID::Linux; default: return PlatformID::Unknown; } } @@ -64,9 +62,6 @@ std::vector PlatformID::getCovered(std::string_view str) { case hash("android"): return { PlatformID::Android32, PlatformID::Android64 }; case hash("android32"): return { PlatformID::Android32 }; case hash("android64"): return { PlatformID::Android64 }; - - // todo in v4: no linux - case hash("linux"): return { PlatformID::Linux }; default: return {}; }