@@ -92,6 +92,8 @@ bool AndroidUI::setup()
92
92
93
93
sprites.push_back (normal);
94
94
windowsMenu->addChild (button);
95
+
96
+ buttons.push_back (button);
95
97
}
96
98
97
99
updateTabs ();
@@ -148,26 +150,32 @@ bool AndroidUI::setup()
148
150
panel->addChild (input);
149
151
this ->inputField = input;
150
152
151
- std::stringstream ver;
152
- ver << " Using version " << Mod::get ()->getVersion ().getMajor () << " ." << Mod::get ()->getVersion ().getMinor () << " ." << Mod::get ()->getVersion ().getPatch ();
153
-
154
- auto versionText = CCLabelBMFont::create (ver.str ().c_str (), " chatFont.fnt" );
155
- versionText->setColor ({0 , 0 , 0 });
156
- versionText->setOpacity (100 );
157
- versionText->setAnchorPoint (ccp (0 .5f , 0 ));
158
- versionText->setScale (0 .45f );
159
- versionText->setPosition (ccp (64 , 13 + 8 ));
160
- // panel->addChild(versionText);
161
-
162
- auto devText = CCLabelBMFont::create (" Mod Developed By TheSillyDoggo" , " chatFont.fnt" );
163
- devText->setColor ({0 , 0 , 0 });
164
- devText->setOpacity (100 );
165
- devText->setAnchorPoint (ccp (0 .5f , 0 ));
166
- devText->setScale (0 .45f );
167
- devText->setPosition (ccp (64 , 13 ));
168
- // panel->addChild(devText);
153
+ versionParent = CCNode::create ();
154
+ versionParent->setAnchorPoint (ccp (0 .5f , 0 ));
155
+ versionParent->setContentWidth (150 );
156
+ versionParent->setPosition (windows->getPosition () + ccp (windows->getScaledContentWidth () / 2 , 5 ));
157
+ versionParent->setLayout (AxisLayout::create (Axis::Row)->setAutoScale (false )->setGap (6 ));
158
+ versionParent->getLayout ()->ignoreInvisibleChildren (true );
159
+
160
+ versionInfo = CCLabelBMFont::create (" L" , " chatFont.fnt" );
161
+ // versionInfo->setBlendFunc({ GL_ONE_MINUS_DST_COLOR, GL_ZERO });
162
+ versionInfo->setAlignment (CCTextAlignment::kCCTextAlignmentCenter );
163
+ versionInfo->setAnchorPoint (ccp (0 .5f , 0 ));
164
+ versionInfo->setScale (0 .55f );
165
+ versionInfo->setOpacity (125 );
166
+
167
+ checkingSprite = LoadingCircleSprite::create ();
168
+ checkingSprite->runAction (CCRepeatForever::create (CCRotateBy::create (1 , 360 )));
169
+ checkingSprite->setScale (versionInfo->getScaledContentHeight () / checkingSprite->getContentHeight ());
170
+
171
+ versionParent->addChild (versionInfo);
172
+ versionParent->addChild (checkingSprite);
173
+
174
+ panel->addChild (versionParent);
169
175
170
176
goToPage (selectedTab);
177
+ updateVersionLabel ();
178
+ updateSearchBox ();
171
179
172
180
// if (Client::GetModuleEnabled("npesta-width"))
173
181
// {
@@ -183,84 +191,54 @@ bool AndroidUI::setup()
183
191
return true ;
184
192
}
185
193
186
- CCNode* AndroidUI::getBGNode ()
194
+ void AndroidUI::updateVersionLabel ()
187
195
{
188
- int theme = Mod::get ()->getSavedValue <int >(" theme" , 5 );
196
+ auto ver = Mod::get ()->getVersion ();
197
+ versionInfo->setString (fmt::format (" Using Version {}.{}.{}" , ver.getMajor (), ver.getMinor (), ver.getPatch ()).c_str ());
189
198
190
- panel = CCScale9Sprite::create (fmt::format (" GJ_square0{}.png" , (theme < 0 ? 6 : theme)).c_str ());
191
- panel->setContentSize (ccp (475 , 280 ));
192
- panel->setID (" panel" );
199
+ checkingSprite->setVisible (!hasCheckedForUpdates);
193
200
194
- as<CCNode*>(panel->getChildren ()->objectAtIndex (0 ))->setZOrder (-2 );
195
-
196
- if (Loader::get ()->getLoadedMod (" thesillydoggo.gradientpages" ) && theme == -1 )
201
+ if (!hasCheckedForUpdates)
197
202
{
198
- auto gradient = CCLayerGradient::create (ccc4 (0 , 0 , 0 , 0 ), ccc4 (0 , 0 , 0 , 0 ));
199
- gradient->setContentSize (panel->getContentSize ());
200
- gradient->setZOrder (-1 );
201
- gradient->setID (" gradient" _spr);
202
-
203
- if (Loader::get ()->getLoadedMod (" thesillydoggo.gradientpages" )->getSettingValue <bool >(" use-custom-colours" ))
203
+ updateListener.bind ([this ](Mod::CheckUpdatesTask::Event* event)
204
204
{
205
- gradient->setStartColor (Loader::get ()->getLoadedMod (" thesillydoggo.gradientpages" )->getSettingValue <ccColor3B>(" primary-colour" ));
206
- gradient->setEndColor (Loader::get ()->getLoadedMod (" thesillydoggo.gradientpages" )->getSettingValue <ccColor3B>(" secondary-colour" ));
207
- }
208
- else
209
- {
210
- auto gm = GameManager::get ();
211
-
212
- gradient->setStartColor (gm->colorForIdx (gm->m_playerColor .value ()));
213
- gradient->setEndColor (gm->colorForIdx (gm->m_playerColor2 .value ()));
214
- }
215
-
216
- gradient->setStartOpacity (255 );
217
- gradient->setEndOpacity (255 );
218
-
219
- gradient->setPosition (CCDirector::get ()->getWinSize () / 2 );
220
- gradient->ignoreAnchorPointForPosition (false );
205
+ if (auto value = event->getValue ())
206
+ {
207
+ if (value->has_value ())
208
+ {
209
+ updateRequired = value->unwrap ().has_value ();
210
+ }
221
211
222
- if (Loader::get ()->getLoadedMod (" thesillydoggo.gradientpages" )->getSettingValue <bool >(" reverse-order" ))
223
- gradient->setScaleY (-1 );
212
+ hasCheckedForUpdates = true ;
213
+ updateVersionLabel ();
214
+ }
215
+ else if (event->isCancelled ())
216
+ {
217
+ hasCheckedForUpdates = false ;
218
+ updateVersionLabel ();
219
+ }
220
+ });
224
221
225
- auto outline = CCScale9Sprite::createWithSpriteFrameName ((std::string (" thesillydoggo.gradientpages/" ) + std::string (" square-outline.png" )).c_str ());
226
- outline->setPosition (panel->getContentSize () / 2 );
227
- outline->setContentSize (panel->getContentSize ());
228
- outline->setZOrder (1 );
229
- outline->setID (" outline" _spr);
230
-
231
- gradient->addChild (outline);
232
- panel->addChild (gradient);
222
+ updateListener.setFilter (Mod::get ()->checkUpdates ());
233
223
234
- gradient->setAnchorPoint (ccp (0 , 0 ));
235
- gradient->setPosition (ccp (0 , 0 ));
224
+ return ;
236
225
}
237
226
238
- if (theme == - 2 )
227
+ if (updateRequired )
239
228
{
240
- // panel->setColor(ccc3(0, 0, 0));
241
- // panel->setOpacity(175);
242
-
243
- auto out = CCScale9Sprite::create (" GJ_square07.png" );
244
- out->setContentSize (panel->getContentSize ());
245
- out->setAnchorPoint (ccp (0 , 0 ));
246
- out->setID (" panel-outline" );
247
- panel->addChild (out);
248
- }
229
+ versionInfo->setString (fmt::format (" {}\n Update Available!" , versionInfo->getString ()).c_str ());
249
230
250
- if (theme == -3 )
251
- {
252
- if (auto spr = CCSprite::create (Mod::get ()->getSavedValue <std::string>(" image-theme-path" ).c_str ()))
231
+ for (size_t i = 0 ; i < 17 ; i++)
253
232
{
254
- spr->setScaleX (panel->getContentWidth () / spr->getContentWidth ());
255
- spr->setScaleY (panel->getContentHeight () / spr->getContentHeight ());
256
- spr->setPosition (panel->getContentSize () / 2 );
257
- spr->setZOrder (-2 );
258
-
259
- panel->addChild (spr);
233
+ if (auto n = as<CCNodeRGBA*>(versionInfo->getChildren ()->objectAtIndex (versionInfo->getChildren ()->count () - i - 1 )))
234
+ {
235
+ n->setColor (ccc3 (87 , 87 , 255 ));
236
+ }
260
237
}
238
+
261
239
}
262
240
263
- return panel ;
241
+ versionParent-> updateLayout () ;
264
242
}
265
243
266
244
CCMenu* AndroidUI::getSearchPanel ()
@@ -510,4 +488,47 @@ void AndroidUI::onKeybinds(CCObject*)
510
488
AndroidUI::~AndroidUI ()
511
489
{
512
490
instance = nullptr ;
491
+ }
492
+
493
+ void AndroidUI::keyDown (cocos2d::enumKeyCodes key)
494
+ {
495
+ if (key == enumKeyCodes::KEY_One)
496
+ onPressTab (buttons[0 ]);
497
+
498
+ if (key == enumKeyCodes::KEY_Two)
499
+ onPressTab (buttons[1 ]);
500
+
501
+ if (key == enumKeyCodes::KEY_Three)
502
+ onPressTab (buttons[2 ]);
503
+
504
+ if (key == enumKeyCodes::KEY_Four)
505
+ onPressTab (buttons[3 ]);
506
+
507
+ if (key == enumKeyCodes::KEY_Five)
508
+ onPressTab (buttons[4 ]);
509
+
510
+ if (key == enumKeyCodes::KEY_Six)
511
+ onPressTab (buttons[5 ]);
512
+
513
+ if (key == enumKeyCodes::KEY_Seven)
514
+ onPressTab (buttons[6 ]);
515
+
516
+ if (key == enumKeyCodes::KEY_Eight)
517
+ onPressTab (buttons[7 ]);
518
+
519
+ // if (key == enumKeyCodes::KEY_Nine)
520
+ // onPressTab(buttons[8]);
521
+
522
+ // if (key == enumKeyCodes::KEY_Zero)
523
+ // onPressTab(buttons[9]);
524
+
525
+ Popup<>::keyDown (key);
526
+ }
527
+
528
+ void AndroidUI::updateSearchBox ()
529
+ {
530
+ auto en = Client::GetModuleEnabled (" ui-search-box" );
531
+
532
+ versionInfo->setVisible (!en);
533
+ inputField->setVisible (en);
513
534
}
0 commit comments