Skip to content

Commit 0f8ace7

Browse files
committed
update
1 parent ce00b61 commit 0f8ace7

File tree

2 files changed

+35
-5
lines changed

2 files changed

+35
-5
lines changed

src/layers/GYModSettingsPopup.cpp

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,19 @@
1616

1717
using namespace geode::prelude;
1818

19+
void GYModSettingsPopup::onApply(CCObject* sender) {
20+
bool someChangesMade = false;
21+
for (auto& sett : m_settings) {
22+
if (sett->hasUncommittedChanges()) {
23+
sett->commit();
24+
someChangesMade = true;
25+
}
26+
}
27+
if (!someChangesMade) {
28+
FLAlertLayer::create("Info", "No changes have been made.", "OK")->show();
29+
}
30+
}
31+
1932
void GYModSettingsPopup::screenshotPopup(CCObject* sender) {
2033
log::debug("Screenshot popup for setting {}", sender->getTag());
2134
GYScreenshotPopup::create(sender->getTag())->show();
@@ -28,8 +41,8 @@ bool GYModSettingsPopup::setup(std::string const& modName, std::string const& mo
2841

2942
auto layerSize = CCSize(winSize.width * 0.75f, winSize.height * 0.75f);
3043

31-
auto scroll = ScrollLayer::create(layerSize * 0.9f - ccp(layerSize.width * 0.05f, layerSize.height * 0.2f));
32-
scroll->setPosition({ ((winSize.width - layerSize.width) / 2) + layerSize.width * 0.05f, ((winSize.height - layerSize.height) / 2) + layerSize.height * 0.05f });
44+
auto scroll = ScrollLayer::create(layerSize * 0.9f - ccp(layerSize.width * 0.05f, layerSize.height * 0.35f));
45+
scroll->setPosition({ layerSize.width * 0.05f, layerSize.height * 0.175f });
3346
scroll->setTouchEnabled(true);
3447

3548
for (auto& key : Mod::get()->getSettingKeys()) {
@@ -46,7 +59,9 @@ bool GYModSettingsPopup::setup(std::string const& modName, std::string const& mo
4659
std::string modifiedKey = key;
4760
std::replace(modifiedKey.begin(), modifiedKey.end(), '/', '-');
4861
log::debug("Modified key: {}", modifiedKey);
49-
node->setTag(tags.getTagFromString(modifiedKey));
62+
int Tag = tags.getTagFromString(modifiedKey);
63+
node->setTag(Tag);
64+
btn->setTag(Tag);
5065

5166
btn->setTarget(node, menu_selector(GYModSettingsPopup::screenshotPopup));
5267
}
@@ -55,6 +70,7 @@ bool GYModSettingsPopup::setup(std::string const& modName, std::string const& mo
5570
// node = UnresolvedCustomSettingNode::create(key, Mod::get(), layerSize.width);
5671
// }
5772

73+
m_settings.push_back(node);
5874
scroll->m_contentLayer->addChild(node);
5975
}
6076
}
@@ -68,7 +84,20 @@ bool GYModSettingsPopup::setup(std::string const& modName, std::string const& mo
6884
);
6985
scroll->moveToTop();
7086

71-
this->addChild(scroll);
87+
auto menu = CCMenu::create();
88+
menu->setPosition({ 0.f, 0.f });
89+
90+
auto applyBtn = CCMenuItemSpriteExtra::create(
91+
ButtonSprite::create("Apply"),
92+
this,
93+
menu_selector(GYModSettingsPopup::onApply)
94+
);
95+
applyBtn->setPosition({ layerSize.width * 0.5f, layerSize.height * 0.1f });
96+
97+
menu->addChild(applyBtn);
98+
99+
this->m_mainLayer->addChild(menu);
100+
this->m_mainLayer->addChild(scroll);
72101

73102
return true;
74103
}

src/layers/GYModSettingsPopup.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ using namespace geode::prelude;
66

77
class GYModSettingsPopup : public geode::Popup<std::string const&, std::string const&, std::string const&> {
88
protected:
9+
void onApply(CCObject* sender);
910
void screenshotPopup(CCObject* sender);
1011
bool setup(std::string const& modName, std::string const& modAuthor, std::string const& modID) override;
11-
12+
std::vector<Ref<SettingNode>> m_settings;
1213
public:
1314
static GYModSettingsPopup* create(std::string const& modName, std::string const& modAuthor, std::string const& modID);
1415
};

0 commit comments

Comments
 (0)