1616
1717using 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+
1932void 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}
0 commit comments