@@ -26,10 +26,19 @@ class GradientPages
26
26
27
27
static CCNode* createGradientWithSize (CCPoint size, GJUserScore* score = nullptr )
28
28
{
29
+ auto node = CCNode::create ();
30
+ node->setID (" gradient-container" _spr);
31
+ node->setPosition (CCDirector::get ()->getWinSize () / 2 );
32
+ node->setAnchorPoint (ccp (0 .5f , 0 .5f ));
33
+ node->setContentSize (size);
34
+ node->setZOrder (-69 );
35
+
29
36
auto gradient = CCLayerGradient::create ();
30
37
gradient->setContentSize (size);
31
- gradient->setZOrder (-69 );
38
+ gradient->setPosition (ccp (0 , 0 ));
39
+ gradient->setAnchorPoint (ccp (0 , 0 ));
32
40
gradient->setID (" gradient" _spr);
41
+ gradient->ignoreAnchorPointForPosition (false );
33
42
34
43
if (Mod::get ()->getSettingValue <bool >(" use-custom-colours" ))
35
44
{
@@ -42,9 +51,6 @@ class GradientPages
42
51
gradient->setEndColor (GameManager::get ()->colorForIdx (GameManager::get ()->m_playerColor2 .value ()));
43
52
}
44
53
45
- gradient->setPosition (CCDirector::get ()->getWinSize () / 2 );
46
- gradient->ignoreAnchorPointForPosition (false );
47
-
48
54
if (score)
49
55
{
50
56
gradient->setStartColor (GameManager::sharedState ()->colorForIdx (score->m_color1 ));
@@ -54,22 +60,34 @@ class GradientPages
54
60
if (Mod::get ()->getSettingValue <bool >(" reverse-order" ))
55
61
gradient->setScaleY (-1 );
56
62
57
- auto darken = CCScale9Sprite::createWithSpriteFrameName (" square-fill.png" _spr);
63
+ auto darken = CCScale9Sprite::createWithSpriteFrameName (Mod::get ()-> getSettingValue < bool >( " rounded-corners " ) ? " square-fill-rounded.png " _spr : " square-fill.png" _spr);
58
64
darken->setID (" darken" _spr);
59
65
darken->setContentSize (size - ccp (15 , 15 ));
60
66
darken->setZOrder (0 );
61
67
darken->setPosition (size / 2 );
62
68
63
- auto outline = CCScale9Sprite::createWithSpriteFrameName (" square-outline.png" _spr);
69
+ auto outline = Mod::get ()-> getSettingValue < bool >( " rounded-corners " ) ? CCScale9Sprite::create ( " GJ_square07.png " ) : CCScale9Sprite::createWithSpriteFrameName (" square-outline.png" _spr);
64
70
outline->setPosition (size / 2 );
65
71
outline->setContentSize (size);
66
72
outline->setZOrder (1 );
67
73
outline->setID (" outline" _spr);
68
-
69
- gradient->addChild (darken);
70
- gradient->addChild (outline);
71
74
72
- return gradient;
75
+ auto gg = CCScale9Sprite::create (Mod::get ()->getSettingValue <bool >(" rounded-corners" ) ? " GJ_square01.png" : " GJ_gradientBG.png" );
76
+ gg->setContentSize (size - ccp (3 , 3 ));
77
+ gg->setPosition (ccp (1 .5f , 1 .5f ));
78
+ gg->setAnchorPoint (ccp (0 , 0 ));
79
+
80
+ CCClippingNode* clippingNode = CCClippingNode::create ();
81
+ clippingNode->setAlphaThreshold (0 .05f );
82
+ clippingNode->setPosition (CCPointZero);
83
+ clippingNode->setStencil (gg);
84
+ clippingNode->addChild (gradient);
85
+
86
+ node->addChild (clippingNode);
87
+ node->addChild (darken);
88
+ node->addChild (outline);
89
+
90
+ return node;
73
91
}
74
92
75
93
static ccColor3B lerpColor (const ccColor3B& startColor, const ccColor3B& endColor, float t) {
@@ -159,8 +177,6 @@ class $modify(ProfilePageExt, ProfilePage) {
159
177
160
178
if (res)
161
179
{
162
- GradientPages::macNode = nullptr ;
163
-
164
180
if (!Mod::get ()->getSettingValue <bool >(" apply-profiles" ) || Loader::get ()->getLoadedMod (" bitz.customprofiles" ))
165
181
return res;
166
182
@@ -196,45 +212,60 @@ class $modify(ProfilePageExt, ProfilePage) {
196
212
as<ProfilePageExt*>(res)->updateCommentList ();
197
213
198
214
auto l = res->m_mainLayer ;
215
+ auto size = ccp (440 , 290 );
216
+
217
+ auto node = CCNode::create ();
218
+ node->setID (" gradient-container" _spr);
219
+ node->setPosition (CCDirector::get ()->getWinSize () / 2 );
220
+ node->setAnchorPoint (ccp (0 .5f , 0 .5f ));
221
+ node->setContentSize (ccp (440 , 290 ));
222
+ node->setZOrder (-1 );
199
223
200
224
auto gradient = CCLayerGradient::create ();
201
225
202
226
gradient->setStartColor ({255 , 0 , 0 });
203
227
gradient->setEndColor ({0 , 255 , 0 });
204
- gradient->setZOrder (-1 );
205
228
gradient->setID (" gradient" _spr);
206
229
gradient->setOpacity (0 );
207
-
208
- gradient->setPosition (CCDirector::get ()->getWinSize () / 2 );
209
- gradient->setContentSize (ccp (440 , 290 ));
230
+ gradient->setPosition (size / 2 );
231
+ gradient->setContentSize (size);
210
232
gradient->ignoreAnchorPointForPosition (false );
211
233
212
234
if (Mod::get ()->getSettingValue <bool >(" reverse-order" ))
213
235
gradient->setScaleY (-1 );
214
236
215
- auto darken = CCScale9Sprite::createWithSpriteFrameName (" square-fill.png" _spr);
237
+ auto darken = CCScale9Sprite::createWithSpriteFrameName (Mod::get ()-> getSettingValue < bool >( " rounded-corners " ) ? " square-fill-rounded.png " _spr : " square-fill.png" _spr);
216
238
darken->setID (" darken" _spr);
217
239
darken->setContentSize (gradient->getContentSize () - ccp (15 , 15 ));
218
240
darken->setZOrder (0 );
219
241
darken->setPosition (gradient->getContentSize () / 2 );
220
242
darken->setAnchorPoint (gradient->getAnchorPoint ());
221
243
darken->setOpacity (0 );
222
244
223
- auto bg = CCScale9Sprite::createWithSpriteFrameName (" square-outline.png" _spr);
245
+ auto bg = Mod::get ()-> getSettingValue < bool >( " rounded-corners " ) ? CCScale9Sprite::create ( " GJ_square07.png " ) : CCScale9Sprite::createWithSpriteFrameName (" square-outline.png" _spr);
224
246
bg->setPosition (gradient->getContentSize () / 2 );
225
247
bg->setContentSize (ccp (440 , 290 ));
226
248
bg->setZOrder (1 );
227
249
bg->setID (" bg" _spr);
228
250
229
- gradient->addChild (bg, 42069 );
230
- gradient->addChild (darken);
231
- l->addChild (gradient);
251
+ auto gg = CCScale9Sprite::create (Mod::get ()->getSettingValue <bool >(" rounded-corners" ) ? " GJ_square01.png" : " GJ_gradientBG.png" );
252
+ gg->setContentSize (ccp (440 , 290 ) - ccp (3 , 3 ));
253
+ gg->setPosition (ccp (1 .5f , 1 .5f ));
254
+ gg->setAnchorPoint (ccp (0 , 0 ));
255
+
256
+ CCClippingNode* clippingNode = CCClippingNode::create ();
257
+ clippingNode->setAlphaThreshold (0 .05f );
258
+ clippingNode->setPosition (CCPointZero);
259
+ clippingNode->setStencil (gg);
260
+ clippingNode->addChild (gradient);
261
+
262
+ node->addChild (clippingNode);
263
+ node->addChild (darken);
264
+ node->addChild (bg, 42069 );
265
+
266
+ l->addChild (node);
232
267
233
- if (GradientPages::score == nullptr )
234
- {
235
- log::info (" hasn't loaded profile info yet :(" );
236
- }
237
- else
268
+ if (GradientPages::score)
238
269
{
239
270
gradient->setStartColor (GameManager::get ()->colorForIdx (GradientPages::score->m_color1 ));
240
271
gradient->setEndColor (GameManager::get ()->colorForIdx (GradientPages::score->m_color2 ));
@@ -261,25 +292,31 @@ class $modify(ProfilePageExt, ProfilePage) {
261
292
262
293
if (l)
263
294
{
264
- auto g = as<CCLayerGradient*>(l->getChildByID (" gradient" _spr));
265
-
266
- if (g)
295
+ if (auto container = l->getChildByID (" gradient-container" _spr))
267
296
{
268
- auto d = as<CCScale9Sprite*>(g->getChildByID (" darken" _spr));
269
-
270
- g->setStartColor (GameManager::get ()->colorForIdx (score->m_color1 ));
271
- g->setEndColor (GameManager::get ()->colorForIdx (score->m_color2 ));
272
-
273
- if (g->getOpacity () == 0 )
297
+ if (auto gCont = getChildOfType<CCClippingNode>(container, 0 ))
274
298
{
275
- g->runAction (CCFadeTo::create (0 .25f , 255 ));
276
- }
299
+ auto g = as<CCLayerGradient*>(gCont ->getChildByID (" gradient" _spr));
277
300
278
- if (d)
279
- {
280
- if (d->getOpacity () == 0 )
301
+ if (g)
281
302
{
282
- d->runAction (CCFadeTo::create (0 .25f , 255 ));
303
+ auto d = as<CCScale9Sprite*>(container->getChildByID (" darken" _spr));
304
+
305
+ g->setStartColor (GameManager::get ()->colorForIdx (score->m_color1 ));
306
+ g->setEndColor (GameManager::get ()->colorForIdx (score->m_color2 ));
307
+
308
+ if (g->getOpacity () == 0 )
309
+ {
310
+ g->runAction (CCFadeTo::create (0 .25f , 255 ));
311
+ }
312
+
313
+ if (d)
314
+ {
315
+ if (d->getOpacity () == 0 )
316
+ {
317
+ d->runAction (CCFadeTo::create (0 .25f , 255 ));
318
+ }
319
+ }
283
320
}
284
321
}
285
322
}
0 commit comments