@@ -18,6 +18,8 @@ void CustomAlert::showPopup(std::string id)
1818 bool hasButton = data.contains (" button1" ) || data.contains (" button" );
1919 matjson::Value button1 = hasButton ? (data.contains (" button1" ) ? data[" button1" ] : data[" button" ]) : nullptr ;
2020
21+ bool instant = getBool (data, " instant" );
22+
2123 if (data.contains (" sound" )) playCustomSound (data[" sound" ]);
2224
2325 if (alertType == " item" || alertType == " icon" || alertType == " unlock" ) {
@@ -27,7 +29,6 @@ void CustomAlert::showPopup(std::string id)
2729 icon.id ,
2830 static_cast <UnlockType>(icon.type )
2931 );
30- popup->setID (" custom_iconpopup" _spr);
3132
3233 CCLayer* iconLayer = popup->m_mainLayer ;
3334
@@ -61,6 +62,8 @@ void CustomAlert::showPopup(std::string id)
6162
6263 customizeIcon (iconLayer->getChildByType <GJItemIcon>(0 )->m_player , data);
6364
65+ popup->m_noElasticity = instant;
66+ popup->setID (" custom_iconpopup" _spr);
6467 popup->show ();
6568 }
6669
@@ -75,7 +78,6 @@ void CustomAlert::showPopup(std::string id)
7578 );
7679
7780 PurchaseItemPopup* popup = PurchaseItemPopup::create (item);
78- popup->setID (" custom_shoppopup" _spr);
7981
8082 CCLayer* purchaseLayer = popup->m_mainLayer ;
8183
@@ -105,6 +107,8 @@ void CustomAlert::showPopup(std::string id)
105107
106108 customizeIcon (purchaseLayer->getChildByType <GJItemIcon>(0 )->m_player , data);
107109
110+ popup->m_noElasticity = instant;
111+ popup->setID (" custom_shoppopup" _spr);
108112 popup->show ();
109113 }
110114
@@ -123,6 +127,7 @@ void CustomAlert::showPopup(std::string id)
123127
124128 setBorder (popup->m_mainLayer , data);
125129
130+ popup->m_noElasticity = instant;
126131 popup->setID (" custom_modpopup" _spr);
127132 popup->show ();
128133
@@ -135,28 +140,29 @@ void CustomAlert::showPopup(std::string id)
135140
136141
137142 else if (alertType == " comment" ) {
138- ShareCommentLayer* comment = ShareCommentLayer::create (
143+ ShareCommentLayer* popup = ShareCommentLayer::create (
139144 title,
140145 getInt (data, " charLimit" , 100 ),
141146 static_cast <CommentType>(getKey (data, " commentType" , COMMENT_TYPES, 0 )), 1 ,
142147 hasContent ? getText (content, " " ) : " "
143148 );
144- comment->setID (" custom_commentpopup" _spr);
145149
146- comment ->m_percent = getInt (data, " percent" , 0 );
150+ popup ->m_percent = getInt (data, " percent" , 0 );
147151
148- comment->show ();
152+ popup->m_noElasticity = instant;
153+ popup->setID (" custom_commentpopup" _spr);
154+ popup->show ();
149155
150- setBorder (comment ->m_mainLayer , data);
156+ setBorder (popup ->m_mainLayer , data);
151157
152158 if (data.contains (" title" )) {
153- customizeText (comment ->m_mainLayer ->getChildByType <CCLabelBMFont>(0 ), data[" title" ]);
159+ customizeText (popup ->m_mainLayer ->getChildByType <CCLabelBMFont>(0 ), data[" title" ]);
154160 }
155161
156- if (hasButton) customizeButton (comment ->m_buttonMenu ->getChildByType <CCMenuItemSpriteExtra>(-1 ), comment , button1, " " );
157- if (data.contains (" button2" )) customizeButton (comment ->m_buttonMenu ->getChildByType <CCMenuItemSpriteExtra>(-2 ), comment , data[" button2" ], " " );
162+ if (hasButton) customizeButton (popup ->m_buttonMenu ->getChildByType <CCMenuItemSpriteExtra>(-1 ), popup , button1, " " );
163+ if (data.contains (" button2" )) customizeButton (popup ->m_buttonMenu ->getChildByType <CCMenuItemSpriteExtra>(-2 ), popup , data[" button2" ], " " );
158164
159- setupCustomButtons (comment , data);
165+ setupCustomButtons (popup , data);
160166 }
161167
162168
@@ -173,6 +179,8 @@ void CustomAlert::showPopup(std::string id)
173179 data.contains (" button2" ) ? getText (data[" button2" ], " Cancel" ).c_str () : nullptr ,
174180 width
175181 );
182+
183+ popup->m_noElasticity = instant;
176184 popup->setID (" custom_alertpopup" _spr);
177185 popup->show ();
178186
@@ -258,7 +266,6 @@ void customizeButton(CCMenuItemSpriteExtra* buttonBase, CCObject* parent, matjso
258266 CCLabelBMFont* label = button->getChildByType <CCLabelBMFont>(0 );
259267 if (!label) return ;
260268
261- CCScale9Sprite* slice = button->getChildByType <CCScale9Sprite>(0 );
262269
263270 if (fallback == " " ) fallback = label->m_sInitialStringUTF8 ;
264271 std::string str = getText (data, fallback);
@@ -268,6 +275,7 @@ void customizeButton(CCMenuItemSpriteExtra* buttonBase, CCObject* parent, matjso
268275
269276 // ====== //
270277
278+ CCScale9Sprite* slice = button->getChildByType <CCScale9Sprite>(0 );
271279 if (slice && data.contains (" texture" )) {
272280 auto customTexture = getCustomTexture (getStr (data, " texture" ).c_str (), " GJ_button_06.png" , true );
273281 set9SpriteFrame (slice, customTexture); // button->updateBGImage() is very prone to crashes
@@ -295,6 +303,7 @@ void customizeButton(CCMenuItemSpriteExtra* buttonBase, CCObject* parent, matjso
295303 float w = getNum (data, " width" , std::clamp (label->getContentWidth () + 14 .0f , size.width , 150 .0f ));
296304 float h = getNum (data, " height" , size.height );
297305
306+ slice = button->getChildByType <CCScale9Sprite>(0 ); // need to get this again for some reason
298307 if (slice && (w != size.width || h != size.height )) {
299308 buttonBase->setContentSize ({w, h});
300309 label->setPositionX (w / 2 .0f );
0 commit comments