mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-14 19:15:05 -05:00
add scrollbar + different errors for missing settings
This commit is contained in:
parent
324cc768fe
commit
de9acbc8eb
5 changed files with 24 additions and 11 deletions
|
@ -582,17 +582,22 @@ Color4BSettingNodeV3* Color4BSettingNodeV3::create(std::shared_ptr<Color4BSettin
|
|||
|
||||
// UnresolvedCustomSettingNodeV3
|
||||
|
||||
bool UnresolvedCustomSettingNodeV3::init(std::string_view key, float width) {
|
||||
bool UnresolvedCustomSettingNodeV3::init(std::string_view key, Mod* mod, float width) {
|
||||
if (!SettingNodeV3::init(nullptr, width))
|
||||
return false;
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -649,7 +649,7 @@ SettingNodeV3* LegacyCustomSettingV3::createNode(float width) {
|
|||
std::static_pointer_cast<LegacyCustomSettingV3>(shared_from_this()), width
|
||||
);
|
||||
}
|
||||
return UnresolvedCustomSettingNodeV3::create(this->getKey(), width);
|
||||
return UnresolvedCustomSettingNodeV3::create(this->getKey(), this->getMod(), width);
|
||||
}
|
||||
|
||||
bool LegacyCustomSettingV3::isDefaultValue() const {
|
||||
|
|
|
@ -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 });
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue