From de9acbc8eb7eb351895d4f25c482b2409dd3e72a Mon Sep 17 00:00:00 2001 From: HJfod <60038575+HJfod@users.noreply.github.com> Date: Tue, 10 Sep 2024 17:14:37 +0300 Subject: [PATCH] add scrollbar + different errors for missing settings --- loader/src/loader/SettingNodeV3.cpp | 19 ++++++++++++------- loader/src/loader/SettingNodeV3.hpp | 6 ++++-- loader/src/loader/SettingV3.cpp | 2 +- loader/src/ui/mods/GeodeStyle.cpp | 1 + .../src/ui/mods/settings/ModSettingsPopup.cpp | 7 ++++++- 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/loader/src/loader/SettingNodeV3.cpp b/loader/src/loader/SettingNodeV3.cpp index 2e57c85f..36e4fbee 100644 --- a/loader/src/loader/SettingNodeV3.cpp +++ b/loader/src/loader/SettingNodeV3.cpp @@ -582,17 +582,22 @@ Color4BSettingNodeV3* Color4BSettingNodeV3::create(std::shared_ptrsetContentHeight(30); + m_mod = mod; + this->setContentHeight(30); + auto label = CCLabelBMFont::create( - fmt::format("Missing setting '{}'", key).c_str(), + (mod && mod->isEnabled() ? + fmt::format("Missing setting '{}'", key) : + fmt::format("Enable the Mod to Edit '{}'", key) + ).c_str(), "bigFont.fnt" ); - label->setColor("mod-list-errors-found-2"_cc3b); + label->setColor(mod && mod->isEnabled() ? "mod-list-errors-found-2"_cc3b : "mod-list-gray"_cc3b); label->limitLabelWidth(width - m_obContentSize.height, .3f, .1f); this->addChildAtPosition(label, Anchor::Left, ccp(m_obContentSize.height / 2, 0), ccp(0, .5f)); @@ -601,7 +606,7 @@ bool UnresolvedCustomSettingNodeV3::init(std::string_view key, float width) { void UnresolvedCustomSettingNodeV3::updateState(CCNode* invoker) { SettingNodeV3::updateState(invoker); - this->getBG()->setColor("mod-list-errors-found"_cc3b); + this->getBG()->setColor(m_mod && m_mod->isEnabled() ? "mod-list-errors-found-2"_cc3b : "mod-list-gray"_cc3b); this->getBG()->setOpacity(75); } @@ -615,9 +620,9 @@ bool UnresolvedCustomSettingNodeV3::hasNonDefaultValue() const { } void UnresolvedCustomSettingNodeV3::onResetToDefault() {} -UnresolvedCustomSettingNodeV3* UnresolvedCustomSettingNodeV3::create(std::string_view key, float width) { +UnresolvedCustomSettingNodeV3* UnresolvedCustomSettingNodeV3::create(std::string_view key, Mod* mod, float width) { auto ret = new UnresolvedCustomSettingNodeV3(); - if (ret && ret->init(key, width)) { + if (ret && ret->init(key, mod, width)) { ret->autorelease(); return ret; } diff --git a/loader/src/loader/SettingNodeV3.hpp b/loader/src/loader/SettingNodeV3.hpp index 89569931..cde5874f 100644 --- a/loader/src/loader/SettingNodeV3.hpp +++ b/loader/src/loader/SettingNodeV3.hpp @@ -292,14 +292,16 @@ public: class UnresolvedCustomSettingNodeV3 : public SettingNodeV3 { protected: - bool init(std::string_view key, float width); + Mod* m_mod; + + bool init(std::string_view key, Mod* mod, float width); void updateState(CCNode* invoker) override; void onCommit() override; public: - static UnresolvedCustomSettingNodeV3* create(std::string_view key, float width); + static UnresolvedCustomSettingNodeV3* create(std::string_view key, Mod* mod, float width); bool hasUncommittedChanges() const override; bool hasNonDefaultValue() const override; diff --git a/loader/src/loader/SettingV3.cpp b/loader/src/loader/SettingV3.cpp index 5418e844..4c8398f1 100644 --- a/loader/src/loader/SettingV3.cpp +++ b/loader/src/loader/SettingV3.cpp @@ -649,7 +649,7 @@ SettingNodeV3* LegacyCustomSettingV3::createNode(float width) { std::static_pointer_cast(shared_from_this()), width ); } - return UnresolvedCustomSettingNodeV3::create(this->getKey(), width); + return UnresolvedCustomSettingNodeV3::create(this->getKey(), this->getMod(), width); } bool LegacyCustomSettingV3::isDefaultValue() const { diff --git a/loader/src/ui/mods/GeodeStyle.cpp b/loader/src/ui/mods/GeodeStyle.cpp index 920244c9..3fcd4f96 100644 --- a/loader/src/ui/mods/GeodeStyle.cpp +++ b/loader/src/ui/mods/GeodeStyle.cpp @@ -18,6 +18,7 @@ $on_mod(Loaded) { ColorProvider::get()->define("mod-list-updates-available-bg-2"_spr, { 45, 110, 222, 255 }); ColorProvider::get()->define("mod-list-errors-found"_spr, { 235, 35, 112, 255 }); ColorProvider::get()->define("mod-list-errors-found-2"_spr, { 245, 27, 27, 255 }); + ColorProvider::get()->define("mod-list-gray"_spr, { 205, 205, 205, 255 }); ColorProvider::get()->define("mod-list-tab-deselected-bg"_spr, { 26, 24, 29, 255 }); ColorProvider::get()->define("mod-list-tab-selected-bg"_spr, { 168, 147, 185, 255 }); ColorProvider::get()->define("mod-list-tab-selected-bg-alt"_spr, { 147, 163, 185, 255 }); diff --git a/loader/src/ui/mods/settings/ModSettingsPopup.cpp b/loader/src/ui/mods/settings/ModSettingsPopup.cpp index 45d519a6..39664b2b 100644 --- a/loader/src/ui/mods/settings/ModSettingsPopup.cpp +++ b/loader/src/ui/mods/settings/ModSettingsPopup.cpp @@ -84,7 +84,7 @@ bool ModSettingsPopup::setup(Mod* mod) { node = sett->createNode(layerSize.width); } else { - node = UnresolvedCustomSettingNodeV3::create(key, layerSize.width); + node = UnresolvedCustomSettingNodeV3::create(key, mod, layerSize.width); } node->setDefaultBGColor(ccc4(0, 0, 0, bg ? 60 : 20)); @@ -112,6 +112,11 @@ bool ModSettingsPopup::setup(Mod* mod) { m_mainLayer->addChildAtPosition(createGeodeListBorders(layerSize), Anchor::Center); + auto scrollBar = Scrollbar::create(m_list); + m_mainLayer->addChildAtPosition( + scrollBar, Anchor::Center, ccp(layerBG->getContentWidth() / 2 + 10, 0) + ); + // buttons m_applyMenu = CCMenu::create();