@@ -12,19 +12,23 @@ SearchPopup* SearchPopup::create(SearchCB callback) {
1212
1313bool SearchPopup::setup (SearchCB callback) {
1414 m_callback = callback;
15-
1615 this ->setTitle (" Search" );
16+ this ->setID (" SearchPopup" _spr);
17+ this ->m_bgSprite ->setID (" background" );
18+ this ->m_title ->setID (" title" );
19+ this ->m_buttonMenu ->setID (" button-menu" );
20+ this ->m_mainLayer ->setID (" main-layer" );
21+ this ->m_closeBtn ->setID (" close-button" );
1722
1823 m_input = TextInput::create (150 .f , " Query here" );
24+ m_input->setID (" search-input" );
1925 m_mainLayer->addChildAtPosition (m_input, Anchor::Center, {0 , 7 .5f });
2026
2127 auto btn = CCMenuItemSpriteExtra::create (
2228 ButtonSprite::create (" Search" ), this , menu_selector (SearchPopup::onSearch)
2329 );
24- auto menu = CCMenu::create ();
25- menu->addChild (btn);
26-
27- m_mainLayer->addChildAtPosition (menu, Anchor::Bottom, {0 , 25 });
30+ btn->setID (" search-button" );
31+ m_buttonMenu->addChildAtPosition (btn, Anchor::Center, {0 , 25 });
2832
2933 return true ;
3034}
@@ -47,25 +51,28 @@ SettingCell* SettingCell::create(std::string name, std::string gv, SettingCellTy
4751}
4852
4953bool SettingCell::init (std::string name, std::string gv, SettingCellType type) {
54+ setID (name);
5055 m_name = name;
5156 m_gameVariable = gv;
5257 m_type = type;
5358
5459 auto nameLabel = CCLabelBMFont::create (
5560 name.c_str (), " bigFont.fnt"
5661 );
62+ nameLabel->setID (" name-label" );
5763 // nameLabel->setScale(0.9f);
5864 nameLabel->limitLabelWidth (15 .f , 0 .9f , 0 .5f );
5965
6066 auto menu = CCMenu::create ();
67+ menu->setID (" button-menu" );
6168
6269 // needed so that the switch statement isn't fussy about variables
6370 CCSprite* spr;
6471 CCMenuItemSpriteExtra* btn;
6572 TextInput* input;
6673 CCLabelBMFont* text;
6774
68- auto fmodEngine = FMODAudioEngine::sharedEngine ();
75+ auto gameManager = GameManager::sharedState ();
6976
7077 switch (type) {
7178 case Default:
@@ -74,6 +81,7 @@ bool SettingCell::init(std::string name, std::string gv, SettingCellType type) {
7481 menu_selector (SettingCell::onCheckboxToggled),
7582 0 .75f
7683 );
84+ m_toggler->setID (" toggler" );
7785 m_toggler->toggle (
7886 GameManager::get ()->getGameVariable (gv.c_str ())
7987 );
@@ -83,6 +91,7 @@ bool SettingCell::init(std::string name, std::string gv, SettingCellType type) {
8391 btn = CCMenuItemSpriteExtra::create (
8492 spr, this , menu_selector (SettingCell::onInfo)
8593 );
94+ btn->setID (" info-button" );
8695 btn->setPositionX (-35 .f );
8796
8897 menu->addChild (btn);
@@ -94,33 +103,34 @@ bool SettingCell::init(std::string name, std::string gv, SettingCellType type) {
94103 btn = CCMenuItemSpriteExtra::create (
95104 spr, this , menu_selector (SettingCell::onFMODDebug)
96105 );
106+ btn->setID (" button" );
97107 btn->setPositionX (-10 .f );
98108 menu->addChild (btn);
99109 break ;
100110 case SongSelect:
101111 spr = CCSprite::createWithSpriteFrameName (" GJ_savedSongsBtn_001.png" );
102112 spr->setScale (0 .4f );
103- menu-> addChild ( CCMenuItemSpriteExtra::create (
113+ btn = CCMenuItemSpriteExtra::create (
104114 spr, this , menu_selector (SettingCell::onSongSelect)
105- ));
115+ );
116+ btn->setID (" button" );
117+ menu->addChild (btn);
106118 break ;
107119 case SongOffset:
108120 input = TextInput::create (100 .f , " Offset" );
109- input->getInputNode ()->setAllowedChars (" 0123456789" );
110- if (fmodEngine->m_musicOffset != 0 ) {
111- input->setString (std::to_string (fmodEngine->m_musicOffset ));
112- }
113- input->setCallback ([this , fmodEngine](std::string offset) {
114- fmodEngine->m_musicOffset = 0 ;
121+ input->setCommonFilter (CommonFilter::Uint);
122+ input->setMaxCharCount (4 );
123+ input->setID (" input" );
115124
116- std::stringstream ss;
117- ss << offset ;
118- int num = 0 ;
119- ss >> num;
120-
121- if (ss. good ()) {
122- fmodEngine-> m_musicOffset = std::stoi (offset );
125+ if (gameManager-> m_timeOffset != 0 ) {
126+ input-> setString ( fmt::format ( " {} " , gameManager-> m_timeOffset )) ;
127+ }
128+ input-> setCallback ([ this , gameManager](std::string offset) {
129+ auto res = geode::utils::numFromString< int >(offset);
130+ if (res. isErr ()) {
131+ log::info ( " {} " , res. unwrapErr () );
123132 }
133+ gameManager->m_timeOffset = geode::utils::numFromString<int >(offset).unwrapOrDefault ();
124134 });
125135 input->setPositionX (-25 .f );
126136 input->setScale (0 .75f );
@@ -132,6 +142,7 @@ bool SettingCell::init(std::string name, std::string gv, SettingCellType type) {
132142 name.c_str (),
133143 " goldFont.fnt"
134144 );
145+ text->setID (" label" );
135146 text->limitLabelWidth (300 .f , 0 .75f , 0.1 );
136147 this ->addChildAtPosition (text, Anchor::Center);
137148 break ;
@@ -285,8 +296,14 @@ CCMenuItemSpriteExtra* createCategoryBtn(std::string name, CCObject* target, Set
285296}
286297
287298bool SettingsLayer::setup () {
299+ this ->setID (" SettingsLayer" _spr);
300+ this ->m_bgSprite ->setID (" background" );
301+ this ->m_buttonMenu ->setID (" button-menu" );
302+ this ->m_mainLayer ->setID (" main-layer" );
303+ this ->m_closeBtn ->setID (" close-button" );
288304 m_noElasticity = true ;
289305 auto bg = CCScale9Sprite::create (" square02b_001.png" );
306+ bg->setID (" tab-background" );
290307 bg->setContentSize ({
291308 100 .f , 245 .f
292309 });
@@ -320,6 +337,7 @@ bool SettingsLayer::setup() {
320337 ->setAxisAlignment(AxisAlignment::Even)
321338 ->setAxisReverse(true )
322339 );
340+ menu->setID (" tab-menu" );
323341 menu->setContentSize (bg->getContentSize ());
324342 menu->setPosition (bg->getPosition ());
325343 menu->setAnchorPoint ({ 0 .f , 0 .f });
@@ -337,11 +355,13 @@ bool SettingsLayer::setup() {
337355 auto searchBtn = CCMenuItemSpriteExtra::create(
338356 searchBtnSpr, this , menu_selector(SettingsLayer::onSearchBtn)
339357 );
358+ searchBtn->setID (" search-button" );
340359
341360 auto searchBtnOffSpr = CCSprite::createWithSpriteFrameName(" gj_findBtnOff_001.png" );
342361 m_searchClearBtn = CCMenuItemSpriteExtra::create(
343362 searchBtnOffSpr, this , menu_selector(SettingsLayer::onClearSearch)
344363 );
364+ m_searchClearBtn->setID (" clear-search-button" );
345365
346366 m_searchClearBtn->setVisible (false );
347367
@@ -356,6 +376,7 @@ bool SettingsLayer::setup() {
356376 searchMenu->addChild (searchBtn);
357377 searchMenu->addChild (m_searchClearBtn);
358378 searchMenu->updateLayout ();
379+ searchMenu->setID (" search-menu" );
359380 m_mainLayer->addChildAtPosition (searchMenu, Anchor::TopRight, {15 , 0 });
360381
361382 return true ;
@@ -518,11 +539,13 @@ void SettingsLayer::switchPage(SettingPage page, bool isFirstRun, CCMenuItemSpri
518539 SETTING (" Hide Attempts in Practice" , " 0135" )
519540 break ;
520541 case Keybinds:
542+ #ifndef GEODE_IS_IOS
521543 // I need to manually create (but not show) the original
522544 // MoreOptionsLayer in order to do this so that I don't
523545 // accidently cause incompats with Custom Keybinds
524546 auto mol = MoreOptionsLayer::create ();
525547 mol->onKeybindings (btn);
548+ #endif
526549
527550 // auto dummyNode = CCNode::create();
528551 // auto text = CCLabelBMFont::create("There's nothing here!", "goldFont.fnt");
@@ -552,8 +575,12 @@ void SettingsLayer::switchPage(SettingPage page, bool isFirstRun, CCMenuItemSpri
552575
553576void SettingsLayer::refreshList () {
554577 ListView* listView = ListView::create (m_listItems, 30 .f , 365 .f , 245 .f );
578+ listView->setID (" list-view" );
579+ listView->m_tableView ->setID (" table-view" );
580+ listView->m_tableView ->m_contentLayer ->setID (" content-layer" );
555581
556582 m_border = Border::create (listView, {0 , 0 , 0 , 75 }, {365 .f , 245 .f });
583+ m_border->setID (" list-border" );
557584 if (CCScale9Sprite* borderSprite = typeinfo_cast<CCScale9Sprite*>(m_border->getChildByID (" geode.loader/border_sprite" ))) {
558585 float scaleFactor = 1 .5f ;
559586 borderSprite->setContentSize (CCSize{borderSprite->getContentSize ().width , borderSprite->getContentSize ().height + 1 } / scaleFactor);
0 commit comments