99
1010int currentMenuIndexGD = 0 ;
1111
12+ matjson::Array currentThemeApplied;
13+
1214int calcLimit (int n) {
1315 return static_cast <int >(std::floor (std::log10 (n)) + 1 );
1416}
@@ -107,7 +109,6 @@ float calculateScale(const std::string& input, int charsBeforeShrink, float minS
107109}
108110
109111bool PrismUIButton::init (HackItem* hack) {
110- auto currentLanguage = Lang::getLanguage ();
111112 menu = CCMenu::create ();
112113 const auto & obj = hack->data ;
113114 std::string name = hack->name ;
@@ -386,17 +387,19 @@ void PrismUIButton::onDropdownBtn(CCObject* sender) {
386387 if (hack->name == " Menu Style" ) {
387388 auto obj = static_cast <PrismUI*>(CCScene::get ()->getChildByID (" prism-menu" ));
388389 obj->onClose (sender);
390+ } else if (hack->name == " Theme" ) {
391+ currentThemeApplied = matjson::Array {};
389392 }
390393}
391394
392- void PrismUI::CreateHackItem (HackItem* hack, bool isSettings ) {
395+ void PrismUI::CreateHackItem (HackItem* hack) {
393396 const auto & obj = hack->data ;
394397 std::string name = hack->name ;
395398 std::string desc = hack->desc ;
396399 auto opcodes = obj.get <matjson::Array>(" opcodes" );
397400 if (!((Hacks::isHackEnabled (" Enable Patching" ) && obj.contains (" winOnly" )) || !obj.contains (" winOnly" ) || name == " Enable Patching" )) return ;
398- auto btn = PrismUIButton::create (hack);
399- float indexY = (isSettings) ? ((currentI - 1 )* 28 ) + 100 : ( currentI * 28 ) + 100 ;
401+ auto btn = PrismUIButton::create (hack, m_currentLang. get () );
402+ float indexY = (currentI * 28 ) + 100 ;
400403 // TODO: create custom sprite so people dont complain
401404 auto infoSpr = CCSprite::createWithSpriteFrameName (" GJ_infoIcon_001.png" );
402405 // infoSpr->setScale(.5F);
@@ -562,8 +565,7 @@ void PrismUI::RegenCategory() {
562565 break ;
563566 case 5 : { // Settings
564567 jsonArray = matjson::parse (Hacks::getSettings ()).as_array ();
565- auto currentLanguage = Lang::getLanguage ();
566- auto createdByLabel = CCLabelBMFont::create (currentLanguage->name (" Prism Menu by Firee" ).c_str (), " PrismMenu.fnt" _spr);
568+ auto createdByLabel = CCLabelBMFont::create (m_currentLang->name (" Prism Menu by Firee" ).c_str (), " PrismMenu.fnt" _spr);
567569 auto versionLabel = CCLabelBMFont::create (" Unknown." , " PrismMenu.fnt" _spr);
568570 createdByLabel->limitLabelWidth (150 , 1 .0F , .2F );
569571 createdByLabel->setPosition ({63 , 470 });
@@ -602,7 +604,7 @@ void PrismUI::RegenCategory() {
602604 std::string name = obj.get <std::string>(" name" );
603605 HackItem* hack = Hacks::getHack (name);
604606 if (hack != nullptr ) {
605- CreateHackItem (hack, currentMenuIndexGD == 5 );
607+ CreateHackItem (hack);
606608 }
607609 }
608610}
@@ -701,7 +703,8 @@ void PrismUIButton::onInfoBtn(CCObject* ret) {
701703 ->setAxisAlignment (AxisAlignment::Center)
702704 ->setAxisReverse (true )
703705 );
704- newLines->setPosition ({282 , (cocos2d::CCDirector::sharedDirector ()->getWinSize ().height / 2 ) + 10 }); // 160 - 220
706+ auto winSize = cocos2d::CCDirector::sharedDirector ()->getWinSize ();
707+ newLines->setPosition ({(winSize.width / 2 ), (winSize.height / 2 ) + 10 }); // 160 - 220
705708 newLines->setZOrder (lines->getZOrder ());
706709 lines->removeFromParentAndCleanup (true );
707710 flAlert->m_mainLayer ->addChild (newLines);
@@ -712,12 +715,16 @@ void PrismUIButton::onInfoBtn(CCObject* ret) {
712715}
713716
714717matjson::Object PrismUI::GetTheme () {
715- return Themes::getCurrentTheme ();
718+ if (currentThemeApplied.empty ()) {
719+ log::debug (" Getting current theme..." );
720+ currentThemeApplied.push_back (Themes::getCurrentTheme ());
721+ }
722+ return currentThemeApplied[0 ].as_object ();
716723}
717724
718725bool PrismUI::init (float _w, float _h) {
719726 auto winSize = cocos2d::CCDirector::sharedDirector ()->getWinSize ();
720- auto currentLanguage = Lang::getLanguage ();
727+ m_currentLang = Lang::getLanguage ();
721728
722729 float menuScale = Hacks::getHack (" Menu Scale" )->value .floatValue ;
723730 this ->m_pLrSize = cocos2d::CCSize { _w, _h };
@@ -774,12 +781,12 @@ bool PrismUI::init(float _w, float _h) {
774781
775782 bg->addChild (sideBar);
776783 bg->addChild (buttonBG);
777- CreateButton (currentLanguage ->name (" § Global" ).c_str (), 0 );
778- CreateButton (currentLanguage ->name (" ¬ Player" ).c_str (), 1 );
779- CreateButton (currentLanguage ->name (" ª Bypass" ).c_str (), 2 );
780- CreateButton (currentLanguage ->name (" « Creator" ).c_str (), 3 );
781- CreateButton (currentLanguage ->name (" ··· Misc" ).c_str (), 4 );
782- CreateButton (currentLanguage ->name (" ¶ Settings" ).c_str (), 5 );
784+ CreateButton (m_currentLang ->name (" § Global" ).c_str (), 0 );
785+ CreateButton (m_currentLang ->name (" ¬ Player" ).c_str (), 1 );
786+ CreateButton (m_currentLang ->name (" ª Bypass" ).c_str (), 2 );
787+ CreateButton (m_currentLang ->name (" « Creator" ).c_str (), 3 );
788+ CreateButton (m_currentLang ->name (" ··· Misc" ).c_str (), 4 );
789+ CreateButton (m_currentLang ->name (" ¶ Settings" ).c_str (), 5 );
783790 Themes::RGBAToCC (GetTheme ()[" BG" ], bg);
784791 Themes::RGBAToCC (GetTheme ()[" BG" ], bgBehind);
785792 bgBehind->setColor ({255 , 255 , 255 });
@@ -838,9 +845,10 @@ PrismUI* PrismUI::create() {
838845 return nullptr ;
839846};
840847
841- PrismUIButton* PrismUIButton::create (HackItem* hack) {
848+ PrismUIButton* PrismUIButton::create (HackItem* hack, Lang* lang ) {
842849 auto pRet = new PrismUIButton ();
843850 if (pRet) {
851+ pRet->currentLanguage = lang;
844852 if (pRet->init (hack)) {
845853 pRet->autorelease ();
846854 return pRet;
0 commit comments