@@ -171,7 +171,16 @@ class $modify(MySimplePlayer, SimplePlayer) {
171171 void updatePlayerShaders (bool dual) {
172172 m_fields->m_isShaderSpr = true ;
173173 m_fields->m_shaderSprDual = dual;
174- ccColor3B outlineColor = Mod::get ()->getSavedValue <ccColor3B>(dual ? " p2-color" : " p1-color" );
174+
175+ std::string whichPlayer = dual ? " outline-color-p2" : " outline-color-p1" ;
176+
177+ ccColor3B outlineColor;
178+ if (Mod::get ()->getSavedValue <bool >(" override-color" )) {
179+ outlineColor = Mod::get ()->getSavedValue <ccColor3B>(dual ? " p2-color" : " p1-color" );
180+ }
181+ else {
182+ outlineColor = GameManager::get ()->colorForIdx (Mod::get ()->getSavedValue <int64_t >(whichPlayer));
183+ }
175184
176185 if (m_robotSprite && m_robotSprite->m_paSprite ) {
177186 for (CCSpritePart* part : CCArrayExt<CCSpritePart*>(m_robotSprite->m_paSprite ->m_spriteParts )) {
@@ -206,8 +215,15 @@ class $modify(MyPlayerObject, PlayerObject) {
206215
207216 if (!m_gameLayer || !(m_gameLayer->m_player1 == this || m_gameLayer->m_player2 == this )) return ;
208217
209- ccColor3B outlineColor = Mod::get ()->getSavedValue <ccColor3B>(
210- Loader::get ()->isModLoaded (" weebify.separate_dual_icons" ) && m_gameLayer->m_player2 == this ? " p2-color" : " p1-color" );
218+ ccColor3B outlineColor;
219+ if (Mod::get ()->getSavedValue <bool >(" override-color" )) {
220+ std::string whichPlayer = Loader::get ()->isModLoaded (" weebify.separate_dual_icons" ) && m_gameLayer->m_player2 == this ? " p2-color" : " p1-color" ;
221+ outlineColor = Mod::get ()->getSavedValue <ccColor3B>(whichPlayer);
222+ }
223+ else {
224+ std::string whichPlayer = Loader::get ()->isModLoaded (" weebify.separate_dual_icons" ) && m_gameLayer->m_player2 == this ? " outline-color-p2" : " outline-color-p1" ;
225+ outlineColor = GameManager::get ()->colorForIdx (Mod::get ()->getSavedValue <int64_t >(whichPlayer));
226+ }
211227
212228 updateSprite (m_iconSprite, outlineColor);
213229 updateSprite (m_vehicleSprite, outlineColor);
@@ -439,22 +455,27 @@ class $modify(MyGJGarageLayer, GJGarageLayer) {
439455class OutlineColorPickPopupDelegate : public ColorPickPopupDelegate {
440456
441457 Ref<CCArray> m_icons;
458+ Ref<CCMenuItemSpriteExtra> m_colorBtn;
442459 bool m_dual = false ;
443460 public:
444- void init (CCArray* icons, bool dual) {
461+ void init (CCArray* icons, CCMenuItemSpriteExtra* btn, bool dual) {
445462 m_icons = icons;
446463 m_dual = dual;
464+ m_colorBtn = btn;
447465 }
448466
449467 void updateColor (ccColor4B const & c) {
450468
451- for (CCNode* children : CCArrayExt<CCNode*>(m_icons)) {
452- if (SimplePlayer* player = typeinfo_cast<SimplePlayer*>(children)) {
453- static_cast <MySimplePlayer*>(player)->setOutlineColor (ccColor3B{c.r , c.g , c.b }, m_dual);
469+ if (Mod::get ()->getSavedValue <bool >(" override-color" )) {
470+ for (CCNode* children : CCArrayExt<CCNode*>(m_icons)) {
471+ if (SimplePlayer* player = typeinfo_cast<SimplePlayer*>(children)) {
472+ static_cast <MySimplePlayer*>(player)->setOutlineColor (ccColor3B{c.r , c.g , c.b }, m_dual);
473+ }
454474 }
475+ m_colorBtn->setColor (ccColor3B{c.r , c.g , c.b });
455476 }
456- Mod::get ()->setSavedValue <ccColor3B>(m_dual ? " p2-color" : " p1-color" , ccColor3B{c.r , c.g , c.b });
457477
478+ Mod::get ()->setSavedValue <ccColor3B>(m_dual ? " p2-color" : " p1-color" , ccColor3B{c.r , c.g , c.b });
458479 }
459480};
460481
@@ -468,14 +489,38 @@ class $modify(MyCharacterColorPage, CharacterColorPage) {
468489 struct Fields {
469490 CCMenuItemSpriteExtra* m_outlineColorBtn;
470491 OutlineColorPickPopupDelegate* m_outlineColorDelegate;
471-
492+ CCMenuItemToggler* m_outlineTab;
493+ CCMenuItemToggler* m_customColorToggle;
494+ CCSprite* m_outlineSelector;
495+ CCLabelBMFont* m_customColorLabel;
472496 ~Fields () {
473497 delete m_outlineColorDelegate;
474498 }
475499 };
476500
477- bool init () {
501+ void updateColor (ccColor3B const & c, bool dual) {
502+ for (CCNode* children : CCArrayExt<CCNode*>(m_playerObjects)) {
503+ if (SimplePlayer* player = typeinfo_cast<SimplePlayer*>(children)) {
504+ static_cast <MySimplePlayer*>(player)->setOutlineColor (c, dual);
505+ }
506+ }
507+ }
478508
509+ void moveToMenu (CCNode* menu, CCMenu* orig, std::string id) {
510+ if (CCMenuItemSpriteExtra* btn = typeinfo_cast<CCMenuItemSpriteExtra*>(orig->getChildByID (id.c_str ()))) {
511+ btn->removeFromParentAndCleanup (false );
512+ menu->addChild (btn);
513+ }
514+ }
515+
516+ void setOutlineSelectorPos (int color) {
517+ CCNode* btn = static_cast <CCNode*>(m_colorButtons->objectForKey (color))->getParent ();
518+ CCPoint worldSpace = btn->convertToWorldSpace ({0 , 0 });
519+ CCPoint nodeSpace = m_mainLayer->convertToNodeSpace (worldSpace);
520+ m_fields->m_outlineSelector ->setPosition (nodeSpace + btn->getScaledContentSize ()/2 );
521+ }
522+
523+ bool init () {
479524 if (!CharacterColorPage::init ()) return false ;
480525
481526 m_fields->m_outlineColorDelegate = new OutlineColorPickPopupDelegate ();
@@ -488,37 +533,181 @@ class $modify(MyCharacterColorPage, CharacterColorPage) {
488533 }
489534 }
490535
491- CCSprite* outlineColorSpr = CCSprite::createWithSpriteFrameName (" GJ_paintBtn_001.png" );
492- outlineColorSpr->setScale (0.5 );
536+ int outlineColor = Mod::get ()->getSavedValue <int64_t >(dual ? " outline-color-p2" : " outline-color-p1" , 15 );
537+
538+ m_fields->m_outlineSelector = CCSprite::createWithSpriteFrameName (" GJ_select_001.png" );
539+ m_fields->m_outlineSelector ->setColor ({50 , 50 , 50 });
540+ m_fields->m_outlineSelector ->setScale (0 .7f );
541+ m_fields->m_outlineSelector ->setZOrder (1 );
542+ m_fields->m_outlineSelector ->setID (" cursor-line" _spr);
543+
544+ m_mainLayer->addChild (m_fields->m_outlineSelector );
545+ setOutlineSelectorPos (outlineColor);
546+
547+ CCSprite* outlineColorSpr = CCSprite::createWithSpriteFrameName (" GJ_colorBtn_001.png" );
548+ outlineColorSpr->setScale (0 .65f );
549+
550+ CCMenu* colorTabsMenu = CCMenu::create ();
551+ colorTabsMenu->setID (" color-tabs-menu" _spr);
552+ colorTabsMenu->setAnchorPoint ({1 .f , 1 .f });
553+ if (CCNode* bg = m_mainLayer->getChildByID (" background" )) {
554+ colorTabsMenu->setPosition (m_mainLayer->getContentSize ()/2 );
555+ colorTabsMenu->setPositionX (colorTabsMenu->getPositionX () + 214 );
556+ colorTabsMenu->setPositionY (colorTabsMenu->getPositionY () + 142 );
557+ }
558+
559+ m_mainLayer->addChild (colorTabsMenu);
560+
561+ RowLayout* rowLayout = RowLayout::create ();
562+ rowLayout->setGap (0 );
563+ rowLayout->setAutoScale (false );
564+ rowLayout->setAxisAlignment (AxisAlignment::End);
565+
566+ colorTabsMenu->setLayout (rowLayout);
493567
494568 m_fields->m_outlineColorBtn = CCMenuItemSpriteExtra::create (outlineColorSpr, this , menu_selector (MyCharacterColorPage::onOutlineColor));
495569 m_fields->m_outlineColorBtn ->setVisible (false );
570+ m_fields->m_outlineColorBtn ->setID (" outline-color-button" _spr);
571+ m_fields->m_outlineColorBtn ->setColor (Mod::get ()->getSavedValue <ccColor3B>(dual ? " p2-color" : " p1-color" ));
572+
573+ m_fields->m_customColorToggle = CCMenuItemToggler::createWithStandardSprites (this , menu_selector (MyCharacterColorPage::onCustomColorToggle), 0 .6f );
574+ m_fields->m_customColorToggle ->setID (" custom-color-toggle" _spr);
575+ m_fields->m_customColorToggle ->setVisible (false );
576+ m_fields->m_customColorToggle ->setPosition (m_glowToggler->getPosition ());
577+ m_fields->m_customColorToggle ->toggle (Mod::get ()->getSavedValue <bool >(" override-color" ));
578+
496579 if (CCMenu* buttonsMenu = typeinfo_cast<CCMenu*>(m_mainLayer->getChildByID (" buttons-menu" ))) {
497580
498- m_fields->m_outlineColorBtn ->setPosition ({m_glowToggler->getPosition ().x + 74 , m_glowToggler->getPosition ().y });
581+ m_fields->m_outlineColorBtn ->setPosition ({m_glowToggler->getPosition ().x + 73 , m_glowToggler->getPosition ().y });
499582 buttonsMenu->addChild (m_fields->m_outlineColorBtn );
500583 if (CCMenuItemSpriteExtra* closeButton = typeinfo_cast<CCMenuItemSpriteExtra*>(buttonsMenu->getChildByID (" close-button" ))) {
501584 closeButton->m_pfnSelector = menu_selector (MyCharacterColorPage::onCloseH);
502585 }
586+
587+ moveToMenu (colorTabsMenu, buttonsMenu, " col1-button" );
588+ moveToMenu (colorTabsMenu, buttonsMenu, " col2-button" );
589+ moveToMenu (colorTabsMenu, buttonsMenu, " glow-button" );
590+
591+ buttonsMenu->addChild (m_fields->m_customColorToggle );
503592 }
593+
594+ ButtonSprite* greySpr = ButtonSprite::create (" Line" , 40 , false , " bigFont.fnt" , " GJ_button_04.png" , 20 , 0.4 );
595+ greySpr->setScale (0 .85f );
596+ ButtonSprite* greenSpr = ButtonSprite::create (" Line" , 40 , false , " bigFont.fnt" , " GJ_button_01.png" , 20 , 0.4 );
597+ greenSpr->setScale (0 .85f );
598+
599+ m_fields->m_outlineTab = CCMenuItemToggler::create (greySpr, greenSpr, this , menu_selector (MyCharacterColorPage::onMode));
600+ m_fields->m_outlineTab ->setContentSize (greySpr->getContentSize ());
601+ m_fields->m_outlineTab ->setTag (3 );
602+ m_fields->m_outlineTab ->setID (" outline-button" _spr);
603+ colorTabsMenu->addChild (m_fields->m_outlineTab );
604+
605+ colorTabsMenu->updateLayout ();
606+
607+ m_fields->m_customColorLabel = CCLabelBMFont::create (" Custom" , " bigFont.fnt" );
608+ m_fields->m_customColorLabel ->setAnchorPoint ({0 , 0 .5f });
609+ m_fields->m_customColorLabel ->setScale (0 .3f );
610+ m_fields->m_customColorLabel ->setPosition (m_glowLabel->getPosition ());
611+ m_fields->m_customColorLabel ->setVisible (false );
612+
613+ m_mainLayer->addChild (m_fields->m_customColorLabel );
504614
615+ m_fields->m_outlineTab ->toggle (false );
505616 return true ;
506617 }
507618
619+ void onCustomColorToggle (CCObject* sender) {
620+ bool toggled = !static_cast <CCMenuItemToggler*>(sender)->isToggled ();
621+
622+ Mod::get ()->setSavedValue <bool >(" override-color" , toggled);
623+ m_fields->m_outlineColorBtn ->setVisible (Mod::get ()->getSavedValue <bool >(" override-color" ));
624+
625+ auto sdi = Loader::get ()->getLoadedMod (" weebify.separate_dual_icons" );
626+ auto dual = sdi && sdi->getSavedValue <bool >(" 2pselected" );
627+
628+ if (!Mod::get ()->getSavedValue <bool >(" override-color" )) {
629+ updateColor (GameManager::get ()->colorForIdx (Mod::get ()->getSavedValue <int64_t >(dual ? " outline-color-p2" : " outline-color-p1" )), dual);
630+ }
631+ else {
632+ updateColor (Mod::get ()->getSavedValue <ccColor3B>(dual ? " p2-color" : " p1-color" ), dual);
633+ }
634+ }
635+
508636 void onOutlineColor (CCObject* sender) {
509637 auto sdi = Loader::get ()->getLoadedMod (" weebify.separate_dual_icons" );
510638 auto dual = sdi && sdi->getSavedValue <bool >(" 2pselected" );
511639 geode::ColorPickPopup* colorPopup = geode::ColorPickPopup::create (Mod::get ()->getSavedValue <ccColor3B>(dual ? " p2-color" : " p1-color" ));
512- m_fields->m_outlineColorDelegate ->init (m_playerObjects, dual);
640+ m_fields->m_outlineColorDelegate ->init (m_playerObjects, m_fields-> m_outlineColorBtn , dual);
513641 colorPopup->setDelegate (m_fields->m_outlineColorDelegate );
514642 colorPopup->show ();
515643 }
516644
645+ void showLocksForTab (int tab) {
646+
647+ switch (tab) {
648+ case 0 :
649+ for (auto obj : CCDictionaryExt<int , ColorChannelSprite*>(m_colorButtons)) {
650+ if (CCNode* child = obj.second ->getChildByTag (100 )) {
651+ child->setVisible (!GameManager::get ()->isColorUnlocked (obj.first , UnlockType::Col1));
652+ }
653+ }
654+ break ;
655+ case 1 :
656+ case 2 :
657+ for (auto obj : CCDictionaryExt<int , ColorChannelSprite*>(m_colorButtons)) {
658+ if (CCNode* child = obj.second ->getChildByTag (100 )) {
659+ child->setVisible (!GameManager::get ()->isColorUnlocked (obj.first , UnlockType::Col2));
660+ }
661+ }
662+ break ;
663+ case 3 :
664+ for (auto obj : CCDictionaryExt<int , ColorChannelSprite*>(m_colorButtons)) {
665+ if (CCNode* child = obj.second ->getChildByTag (100 )) {
666+ child->setVisible (false );
667+ }
668+ }
669+ break ;
670+ }
671+ }
672+
517673 void onMode (CCObject* sender) {
518674 CharacterColorPage::onMode (sender);
519- m_fields->m_outlineColorBtn ->setVisible (m_colorMode == 2 );
675+
676+ m_colorMode = sender->getTag ();
677+ m_fields->m_outlineColorBtn ->setVisible (m_colorMode == 3 && Mod::get ()->getSavedValue <bool >(" override-color" ));
678+ m_fields->m_customColorToggle ->setVisible (m_colorMode == 3 );
679+ m_fields->m_customColorLabel ->setVisible (m_colorMode == 3 );
680+
681+ showLocksForTab (m_colorMode);
682+
683+ if (m_colorMode != 3 ) {
684+ m_fields->m_outlineSelector ->setColor ({50 , 50 , 50 });
685+ m_fields->m_outlineTab ->toggle (false );
686+ m_fields->m_outlineTab ->setClickable (true );
687+ m_fields->m_outlineSelector ->setZOrder (1 );
688+ }
689+ else {
690+ m_fields->m_outlineSelector ->setColor ({255 , 255 , 255 });
691+ m_fields->m_outlineTab ->toggle (true );
692+ m_fields->m_outlineTab ->setClickable (false );
693+ m_fields->m_outlineSelector ->setZOrder (11 );
694+ }
520695 }
521696
697+ void onPlayerColor (cocos2d::CCObject* sender) {
698+ if (m_colorMode == 3 ) {
699+ auto sdi = Loader::get ()->getLoadedMod (" weebify.separate_dual_icons" );
700+ auto dual = sdi && sdi->getSavedValue <bool >(" 2pselected" );
701+ Mod::get ()->setSavedValue <int64_t >(dual ? " outline-color-p2" : " outline-color-p1" , sender->getTag ());
702+ setOutlineSelectorPos (sender->getTag ());
703+ if (!Mod::get ()->getSavedValue <bool >(" override-color" )) {
704+ updateColor (GameManager::get ()->colorForIdx (sender->getTag ()), dual);
705+ }
706+ }
707+ else {
708+ CharacterColorPage::onPlayerColor (sender);
709+ }
710+ }
522711
523712 void toggleShip (CCObject* sender) {
524713 CharacterColorPage::toggleShip (sender);
@@ -538,10 +727,20 @@ class $modify(MyCharacterColorPage, CharacterColorPage) {
538727 CCScene* scene = CCDirector::get ()->m_pRunningScene ;
539728 if (GJGarageLayer* garage = scene->getChildByType <GJGarageLayer>(0 )) {
540729 if (garage->m_playerObject ) {
541- static_cast <MySimplePlayer*>(garage->m_playerObject )->setOutlineColor (Mod::get ()->getSavedValue <ccColor3B>(" p1-color" ), false );
730+ if (Mod::get ()->getSavedValue <bool >(" override-color" )) {
731+ static_cast <MySimplePlayer*>(garage->m_playerObject )->setOutlineColor (Mod::get ()->getSavedValue <ccColor3B>(" p1-color" ), false );
732+ }
733+ else {
734+ static_cast <MySimplePlayer*>(garage->m_playerObject )->setOutlineColor (GameManager::get ()->colorForIdx (Mod::get ()->getSavedValue <int64_t >(" outline-color-p1" )), false );
735+ }
542736 }
543737 if (SimplePlayer* player2 = typeinfo_cast<SimplePlayer*>(garage->getChildByID (" player2-icon" ))) {
544- static_cast <MySimplePlayer*>(player2)->setOutlineColor (Mod::get ()->getSavedValue <ccColor3B>(" p2-color" ), true );
738+ if (Mod::get ()->getSavedValue <bool >(" override-color" )) {
739+ static_cast <MySimplePlayer*>(player2)->setOutlineColor (Mod::get ()->getSavedValue <ccColor3B>(" p2-color" ), true );
740+ }
741+ else {
742+ static_cast <MySimplePlayer*>(player2)->setOutlineColor (GameManager::get ()->colorForIdx (Mod::get ()->getSavedValue <int64_t >(" outline-color-p2" )), true );
743+ }
545744 }
546745 }
547746 }
@@ -566,7 +765,13 @@ class $modify(MyCommentCell, CommentCell) {
566765
567766 if (p0->m_accountID == GJAccountManager::get ()->m_accountID ){
568767 if (SimplePlayer* player = typeinfo_cast<SimplePlayer*>(getChildByIDRecursive (" player-icon" ))) {
569- static_cast <MySimplePlayer*>(player)->setOutlineColor (Mod::get ()->getSavedValue <ccColor3B>(" p1-color" ), false );
768+ if (Mod::get ()->getSavedValue <bool >(" override-color" )) {
769+ static_cast <MySimplePlayer*>(player)->setOutlineColor (Mod::get ()->getSavedValue <ccColor3B>(" p1-color" ), false );
770+ }
771+ else {
772+ static_cast <MySimplePlayer*>(player)->setOutlineColor (GameManager::get ()->colorForIdx (Mod::get ()->getSavedValue <int64_t >(" outline-color-p1" )), false );
773+ }
774+
570775 }
571776 }
572777 }
@@ -580,7 +785,12 @@ class $modify(MyGJScoreCell, GJScoreCell) {
580785
581786 if (p0->m_accountID == GJAccountManager::get ()->m_accountID ){
582787 if (SimplePlayer* player = typeinfo_cast<SimplePlayer*>(getChildByIDRecursive (" player-icon" ))) {
583- static_cast <MySimplePlayer*>(player)->setOutlineColor (Mod::get ()->getSavedValue <ccColor3B>(" p1-color" ), false );
788+ if (Mod::get ()->getSavedValue <bool >(" override-color" )) {
789+ static_cast <MySimplePlayer*>(player)->setOutlineColor (Mod::get ()->getSavedValue <ccColor3B>(" p1-color" ), false );
790+ }
791+ else {
792+ static_cast <MySimplePlayer*>(player)->setOutlineColor (GameManager::get ()->colorForIdx (Mod::get ()->getSavedValue <int64_t >(" outline-color-p1" )), false );
793+ }
584794 }
585795 }
586796 }
0 commit comments