@@ -15,7 +15,8 @@ using namespace geode::prelude;
1515using namespace horrible ;
1616
1717// add yo mods here :D
18- std::vector<std::tuple<std::string, std::string, std::string, SillyTier, bool >> HorribleMenuPopup::getAllOptions () {
18+ std::vector<std::tuple<std::string, std::string, std::string, SillyTier, bool >> HorribleMenuPopup::getAllOptions ()
19+ {
1920 // for simple minded: [modID, modName, modDescription, sillyTier, restartRequired]
2021 return {
2122 {" oxygen" ,
@@ -138,81 +139,107 @@ std::vector<std::tuple<std::string, std::string, std::string, SillyTier, bool>>
138139 " Your icon will start to randomly blink.\n <cy>Credit: DragonixGD</c>" ,
139140 SillyTier::Low,
140141 false },
141- {" dementia" ,
142- " Dementia" ,
143- " Chance of your player randomly teleports back. This is more like player lagging to be honest!\n <cy>Credit: imdissapearinghelp</c>" ,
144- SillyTier::Medium,
145- false },
146- {" meme_death" ,
147- " Meme Death Sounds" ,
148- " Plays a meme sound effect on certain percentage where you died at.\n <cy>Credit: imdissapearinghelp</c>" ,
149- SillyTier::Low,
150- false },
151- };
142+ {" dementia" ,
143+ " Dementia" ,
144+ " Chance of your player randomly teleports back. This is more like player lagging to be honest!\n <cy>Credit: imdissapearinghelp</c>" ,
145+ SillyTier::Medium,
146+ false },
147+ {" meme_death" ,
148+ " Meme Death Sounds" ,
149+ " Plays a meme sound effect on certain percentage where you died at.\n <cy>Credit: imdissapearinghelp</c>" ,
150+ SillyTier::Low,
151+ false },
152+ };
152153};
153154
154155// silly tier filter
155156static SillyTier s_selectedTier = SillyTier::None;
156157
157- void filterOptionsByTier (ScrollLayer* optionsScrollLayer, const std::vector<std::tuple<std::string, std::string, std::string, SillyTier, bool >>& allOptions, SillyTier tier) {
158+ void filterOptionsByTier (ScrollLayer *optionsScrollLayer, const std::vector<std::tuple<std::string, std::string, std::string, SillyTier, bool >> &allOptions, SillyTier tier)
159+ {
158160 optionsScrollLayer->m_contentLayer ->removeAllChildren ();
159- for (const auto & option : allOptions) {
160- const auto & [id, name, desc, silly, restart] = option;
161- if (tier == SillyTier::None || silly == tier) {
162- if (auto modOption = ModOption::create ({ optionsScrollLayer->m_contentLayer ->getScaledContentWidth (), 32 .f }, id, name, desc, silly, restart))
161+ for (const auto &option : allOptions)
162+ {
163+ const auto &[id, name, desc, silly, restart] = option;
164+ if (tier == SillyTier::None || silly == tier)
165+ {
166+ if (auto modOption = ModOption::create ({optionsScrollLayer->m_contentLayer ->getScaledContentWidth (), 32 .f }, id, name, desc, silly, restart))
163167 optionsScrollLayer->m_contentLayer ->addChild (modOption);
164168 }
165169 }
166170 optionsScrollLayer->m_contentLayer ->updateLayout ();
167171 optionsScrollLayer->scrollToTop ();
168172}
169173
170- bool HorribleMenuPopup::setup () {
174+ bool HorribleMenuPopup::setup ()
175+ {
171176 setID (" options" _spr);
172177 setTitle (" Horrible Options" );
173178
174179 auto mainLayerSize = m_mainLayer->getContentSize ();
175180
176181 // Add a background sprite to the popup
177182 auto optionScrollBg = CCScale9Sprite::create (" square02_001.png" );
178- optionScrollBg->setAnchorPoint ({ 0.5 , 0.5 });
179- optionScrollBg->setPosition ({ mainLayerSize.width / 2 .f - 80 .f , mainLayerSize.height / 2 .f - 10 .f });
180- optionScrollBg->setContentSize ({ mainLayerSize.width / 1 .5f - 25 .f , mainLayerSize.height - 45 .f });
183+ optionScrollBg->setAnchorPoint ({0.5 , 0.5 });
184+ optionScrollBg->setPosition ({mainLayerSize.width / 2 .f - 80 .f , mainLayerSize.height / 2 .f - 10 .f });
185+ optionScrollBg->setContentSize ({mainLayerSize.width / 1 .5f - 25 .f , mainLayerSize.height - 45 .f });
181186 optionScrollBg->setOpacity (50 );
182187 m_mainLayer->addChild (optionScrollBg);
183188
189+ // add a list button background
190+ auto listBtnBg = CCScale9Sprite::create (" square02_001.png" );
191+ listBtnBg->setAnchorPoint ({0.5 , 0.5 });
192+ listBtnBg->setPosition ({mainLayerSize.width - (mainLayerSize.width / 2 .f - 25 .f ) + 115 .f , mainLayerSize.height / 2 .f - 10 .f });
193+ listBtnBg->setContentSize ({mainLayerSize.width / 3 .f , mainLayerSize.height - 45 .f });
194+ listBtnBg->setOpacity (50 );
195+ m_mainLayer->addChild (listBtnBg);
196+
184197 // filter buttons :o
185198 auto filterMenu = CCMenu::create ();
186- filterMenu->setPosition ({ mainLayerSize.width - 85 .f , mainLayerSize.height / 2 .f + 80 .f });
199+ filterMenu->setPosition ({mainLayerSize.width - 85 .f , mainLayerSize.height / 2 .f + 80 .f });
187200
188- struct FilterBtnInfo {
201+ struct FilterBtnInfo
202+ {
189203 SillyTier tier;
190- const char * label;
204+ const char * label;
191205 ccColor3B color;
192206 };
193207
194208 std::vector<FilterBtnInfo> btns = {
195209 {SillyTier::Low, " Low" , {100 , 255 , 100 }},
196210 {SillyTier::Medium, " Medium" , {255 , 255 , 100 }},
197- {SillyTier::High, " High" , {255 , 100 , 100 }} };
211+ {SillyTier::High, " High" , {255 , 100 , 100 }}};
198212
199213 float btnY = 0 .f ;
200- for (const auto & btn : btns) {
201- // Create a ButtonSprite using caption + font overload, then tint its internal label
202- auto bs = ButtonSprite::create (btn.label , 0 , false , " bigFont.fnt" , " GJ_button_01.png" , 0 , 1 .f );
203- if (bs && bs->m_label ) {
204- bs->m_label ->setColor (btn.color );
205- bs->setScale (1 .f );
206- };
214+ for (const auto &btn : btns)
215+ {
216+ auto normalBS = ButtonSprite::create (btn.label , 0 , false , " bigFont.fnt" , " GJ_button_01.png" , 0 , 0 .8f );
217+ auto selectedBS = ButtonSprite::create (btn.label , 0 , false , " bigFont.fnt" , " GJ_button_02.png" , 0 , 0 .8f );
218+ if (normalBS && normalBS->m_label )
219+ {
220+ normalBS->m_label ->setColor (btn.color );
221+ normalBS->setScale (.8f );
222+ }
223+ if (selectedBS && selectedBS->m_label )
224+ {
225+ selectedBS->m_label ->setColor (btn.color );
226+ selectedBS->setScale (.8f );
227+ }
207228
208- auto btnItem = CCMenuItemSpriteExtra::create (bs, this , menu_selector (HorribleMenuPopup::filterTierCallback));
209- btnItem->setTag (static_cast <int >(btn.tier ));
210- btnItem->setPosition ({ 0 .f , btnY });
229+ auto normalItem = CCMenuItemSpriteExtra::create (normalBS, nullptr , nullptr );
230+ auto selectedItem = CCMenuItemSpriteExtra::create (selectedBS, nullptr , nullptr );
211231
212- filterMenu->addChild (btnItem);
232+ auto itemsArray = CCArray::create ();
233+ itemsArray->addObject (normalItem);
234+ itemsArray->addObject (selectedItem);
213235
214- btnY -= 40 .f ;
215- };
236+ auto toggleItem = CCMenuItemToggle::createWithTarget (this , menu_selector (HorribleMenuPopup::filterTierCallback), itemsArray);
237+ toggleItem->setTag (static_cast <int >(btn.tier ));
238+ toggleItem->setPosition ({0 .f , btnY});
239+ toggleItem->setSelectedIndex (s_selectedTier == btn.tier ? 1 : 0 );
240+ filterMenu->addChild (toggleItem);
241+ btnY -= 50 .f ;
242+ }
216243
217244 m_mainLayer->addChild (filterMenu);
218245
@@ -223,9 +250,9 @@ bool HorribleMenuPopup::setup() {
223250 columnLayout->setAutoGrowAxis (0 .f );
224251
225252 // scroll layer
226- auto optionsScrollLayer = ScrollLayer::create ({ optionScrollBg->getContentSize ().width - 10 .f , optionScrollBg->getContentSize ().height - 10 .f });
253+ auto optionsScrollLayer = ScrollLayer::create ({optionScrollBg->getContentSize ().width - 10 .f , optionScrollBg->getContentSize ().height - 10 .f });
227254 optionsScrollLayer->setID (" scrollLayer" );
228- optionsScrollLayer->setAnchorPoint ({ 0.5 , 0.5 });
255+ optionsScrollLayer->setAnchorPoint ({0.5 , 0.5 });
229256 optionsScrollLayer->ignoreAnchorPointForPosition (false );
230257 optionsScrollLayer->setPosition (optionScrollBg->getPosition ());
231258 optionsScrollLayer->m_contentLayer ->setLayout (columnLayout);
@@ -249,54 +276,89 @@ bool HorribleMenuPopup::setup() {
249276 modSettingsBtnSprite,
250277 this ,
251278 menu_selector (HorribleMenuPopup::openModSettings));
252- modSettingsMenu->setPosition ({ 0 .f , 0 .f });
279+ modSettingsMenu->setPosition ({0 .f , 0 .f });
253280 modSettingsMenu->addChild (modSettingsBtn);
254281 m_mainLayer->addChild (modSettingsMenu);
255282
256- auto safeModeLabel = CCLabelBMFont::create (" !! Safe Mode INACTIVE !! " , " chatFont .fnt" );
257- safeModeLabel->setColor ({ 255 , 0 , 0 });
258- safeModeLabel->setAnchorPoint ({ 0 .5f , 0 .0f });
259- safeModeLabel->setPosition ({ m_mainLayer-> getContentSize () .width / 2 .f , 5 . f });
260- safeModeLabel->setScale (0 .5f );
283+ auto safeModeLabel = CCLabelBMFont::create (" Safe Mode: INACTIVE" , " bigFont .fnt" );
284+ safeModeLabel->setColor ({255 , 0 , 0 });
285+ safeModeLabel->setAnchorPoint ({0 .5f , 0 .0f });
286+ safeModeLabel->setPosition ({mainLayerSize. width - (mainLayerSize .width / 2 .f - 25 . f ) + 115 . f , 20 . f });
287+ safeModeLabel->setScale (0 .325f );
261288
262289 // Set safemode label if active
263- if (horribleMod->getSettingValue <bool >(" safe-mode" )) {
264- safeModeLabel->setCString (" !! Safe Mode ACTIVE !!" );
265- safeModeLabel->setColor ({ 255 , 255 , 0 });
266- } else {
290+ if (horribleMod->getSettingValue <bool >(" safe-mode" ))
291+ {
292+ safeModeLabel->setCString (" Safe Mode: ACTIVE" );
293+ safeModeLabel->setColor ({0 , 255 , 0 });
294+ }
295+ else
296+ {
267297 log::warn (" Safe mode is inactive" );
268298 };
269299
270300 m_mainLayer->addChild (safeModeLabel, 100 );
271301 return true ;
272302}
273303
274- void HorribleMenuPopup::filterTierCallback (CCObject* sender) {
275- auto node = static_cast <CCNode*>(sender);
276- SillyTier tier = static_cast <SillyTier>(node->getTag ());
304+ void HorribleMenuPopup::filterTierCallback (CCObject *sender)
305+ {
306+ auto toggleItem = typeinfo_cast<CCMenuItemToggle *>(sender);
307+ if (!toggleItem)
308+ return ;
309+ SillyTier tier = static_cast <SillyTier>(toggleItem->getTag ());
277310
278311 // Toggle: clicking same button disables filter
279- if (s_selectedTier == tier) {
312+ if (s_selectedTier == tier)
313+ {
280314 s_selectedTier = SillyTier::None;
281- } else {
315+ }
316+ else
317+ {
282318 s_selectedTier = tier;
283- };
319+ }
284320
285321 // Find scroll layer and options
286- auto optionsScrollLayer = static_cast <ScrollLayer*>(m_mainLayer->getChildByID (" scrollLayer" ));
322+ auto optionsScrollLayer = static_cast <ScrollLayer *>(m_mainLayer->getChildByID (" scrollLayer" ));
287323 auto modOptions = getAllOptions ();
288324
289325 filterOptionsByTier (optionsScrollLayer, modOptions, s_selectedTier);
326+
327+ // Update toggle states for all filter buttons
328+ CCMenu *filterMenu = nullptr ;
329+ for (unsigned int i = 0 ; i < m_mainLayer->getChildrenCount (); ++i)
330+ {
331+ auto child = m_mainLayer->getChildren ()->objectAtIndex (i);
332+ filterMenu = typeinfo_cast<CCMenu *>(child);
333+ if (filterMenu)
334+ break ;
335+ }
336+ if (filterMenu)
337+ {
338+ for (unsigned int i = 0 ; i < filterMenu->getChildrenCount (); ++i)
339+ {
340+ auto btnObj = filterMenu->getChildren ()->objectAtIndex (i);
341+ auto toggle = typeinfo_cast<CCMenuItemToggle *>(btnObj);
342+ if (toggle)
343+ {
344+ SillyTier btnTier = static_cast <SillyTier>(toggle->getTag ());
345+ toggle->setSelectedIndex (s_selectedTier == btnTier ? 1 : 0 );
346+ }
347+ }
348+ }
290349};
291350
292- void HorribleMenuPopup::openModSettings (CCObject* sender) {
351+ void HorribleMenuPopup::openModSettings (CCObject *sender)
352+ {
293353 openSettingsPopup (horribleMod);
294354};
295355
296- HorribleMenuPopup* HorribleMenuPopup::create () {
356+ HorribleMenuPopup *HorribleMenuPopup::create ()
357+ {
297358 auto ret = new HorribleMenuPopup ();
298359
299- if (ret && ret->initAnchored (450 .f , 280 .f )) {
360+ if (ret && ret->initAnchored (450 .f , 280 .f ))
361+ {
300362 ret->autorelease ();
301363 return ret;
302364 };
0 commit comments