@@ -52,12 +52,12 @@ bool DeltaruneAlertLayer::init(FLAlertLayerProtocol* delegate, char const* title
5252 NodeIDs::provideFor (this );
5353 setID (" FLAlertLayer" );
5454
55- std::string const descString = desc; // stupid android
55+ std::string_view descString = desc;
5656 bool const isEmpty = std::ranges::all_of (descString, [](unsigned char c) {
5757 return std::isspace (c);
5858 });
5959 bool const prismLoaded = Loader::get ()->isModLoaded (" firee.prism" );
60- std::string prismString = " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" ; // probably the easiest way to detect a Prism Menu alert :3
60+ std::string_view prismString{ " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" } ; // probably the easiest way to detect a Prism Menu alert :3
6161 if ((prismLoaded && desc == prismString) || isEmpty) {
6262 m_fields->incompatible = true ;
6363 return true ;
@@ -192,20 +192,17 @@ void DeltaruneAlertLayer::show() {
192192 changeLook ();
193193}
194194void DeltaruneAlertLayer::setHeartPosition (CCMenuItemSpriteExtra* button) {
195- auto & heart = m_fields->heart ;
196- CCNode* text = button->getChildByType <ButtonSprite>(0 )->getChildByType <CCLabelBMFont>(0 );
195+ auto & heart{ m_fields->heart } ;
196+ auto text{ button->getChildByType <ButtonSprite>(0 )->getChildByType <CCLabelBMFont>(0 ) } ;
197197
198198 if (!text) return ;
199-
199+
200200 heart->setPositionX (m_buttonMenu->getPositionX () + button->getPositionX () - text->getContentWidth () / 2 - heart->getContentWidth () / 2 - 5 );
201201}
202202
203203void DeltaruneAlertLayer::clickedOnButton (CCMenuItemSpriteExtra* btn, ButtonSprite* buttonSprite, int btnSelected) {
204- auto label = buttonSprite->getChildByType <CCLabelBMFont>(0 );
205- if (!label) {
206- // log::info("Where the fuck is the label?");
207- return ;
208- }
204+ auto label{ buttonSprite->getChildByType <CCLabelBMFont>(0 ) };
205+ if (!label) return ;
209206 if (btn->isSelected ()) {
210207 label->setColor (ccColor3B{ 255 , 255 , 0 });
211208 m_fields->btnSelected = btnSelected;
@@ -227,20 +224,9 @@ bool DeltaruneAlertLayer::ccTouchBegan(CCTouch* touch, CCEvent* event) {
227224 auto & btn2 = m_fields->btn2 ;
228225 int & btnSelected = m_fields->btnSelected ;
229226
230- if (!btn1) {
231- // log::info("No btn1");
232- return ret;
233- }
234- if (!btn2) {
235- // log::info("No btn2");
236- return ret;
237- }
238-
239- if (!btn1->isSelected () && !btn2->isSelected ()) {
240- // log::info("None of the buttons are clicked");
241- return ret;
242- }
243- // log::info("No problems in ccTouchBegan!");
227+ if (!btn1 || !btn2) return ret;
228+ if (!btn1->isSelected () && !btn2->isSelected ()) return ret;
229+
244230 clickedOnButton (btn1, m_button1, 1 );
245231 clickedOnButton (btn2, m_button2, 2 );
246232 return ret;
@@ -350,7 +336,7 @@ void DeltaruneAlertLayer::skipText() {
350336 if (!clippingNode) return ;
351337 CCArrayExt<TextArea*> textAreas = clippingNode->getChildren ();
352338 for (auto textArea : textAreas) {
353- CCArrayExt<CCLabelBMFont*> lines = static_cast <CCNode*>( textArea->getChildren ()-> objectAtIndex ( 0 ) )->getChildren ();
339+ CCArrayExt<CCLabelBMFont*> lines = textArea->getChildByType <MultilineBitmapFont>( 0 )->getChildren ();
354340
355341 for (int i = linesProgressed + m_fields->rollingLine ; i < lines.size () && i < linesProgressed + 3 ; i++) {
356342 auto line = lines[i];
@@ -374,28 +360,26 @@ void DeltaruneAlertLayer::skipText() {
374360}
375361
376362int DeltaruneAlertLayer::emptyLinesAmount (int offset) {
377- auto & textArea = m_fields->textArea ;
378- auto & linesProgressed = m_fields->linesProgressed ;
379- auto fontNode = (CCNode*) textArea->getChildren ()-> objectAtIndex (0 );
380- int lines = 0 ;
363+ auto & textArea{ m_fields->textArea } ;
364+ auto & linesProgressed{ m_fields->linesProgressed } ;
365+ auto fontNode{ textArea->getChildByType <MultilineBitmapFont> (0 ) } ;
366+ int lines{ 0 } ;
381367 while (true ) {
382368 if (linesProgressed + lines + offset >= fontNode->getChildrenCount ()) break ;
383369
384- auto topLineNode = fontNode->getChildren ()->objectAtIndex (linesProgressed + lines + offset);
385- auto topLine = static_cast <CCLabelBMFont*>(topLineNode);
386- if (!topLineNode) break ;
370+ auto topLine{ fontNode->getChildByType <CCLabelBMFont>(linesProgressed + lines + offset) };
387371 if (!topLine) break ;
388372
389- std::string topLineString = topLine->getString ();
373+ std::string_view topLineString = topLine->getString ();
390374 bool empty = std::ranges::all_of (topLineString, [](unsigned char c) {
391375 return std::isspace (c);
392376 });
393377 if (!empty) break ;
394378
395379 lines++;
396380
397- auto star = m_mainLayer->getChildByID (" star" _spr);
398- auto starShadow = m_mainLayer->getChildByID (" starShadow" _spr);
381+ auto star{ m_mainLayer->getChildByID (" star" _spr) } ;
382+ auto starShadow{ m_mainLayer->getChildByID (" starShadow" _spr) } ;
399383
400384 if (star) star->setVisible (true );
401385 if (starShadow) starShadow->setVisible (true );
@@ -408,21 +392,21 @@ void DeltaruneAlertLayer::progressText() {
408392 if (!m_buttonMenu) return ;
409393 if (!m_fields->textAreaClippingNode ) return ;
410394
411- auto & textArea = m_fields->textArea ;
412- auto & btn1 = m_fields->btn1 ;
413- auto & btn2 = m_fields->btn2 ;
414- auto & shadow = m_fields->shadow ;
415- auto & gradientOverlay = m_fields->gradientOverlay ;
416- int & btnSelected = m_fields->btnSelected ;
417- int & linesProgressed = m_fields->linesProgressed ;
418- bool & done = m_fields->done ;
419- bool & noShadow = m_fields->noShadow ;
395+ auto & textArea{ m_fields->textArea } ;
396+ auto & btn1{ m_fields->btn1 } ;
397+ auto & btn2{ m_fields->btn2 } ;
398+ auto & shadow{ m_fields->shadow } ;
399+ auto & gradientOverlay{ m_fields->gradientOverlay } ;
400+ int & btnSelected{ m_fields->btnSelected } ;
401+ int & linesProgressed{ m_fields->linesProgressed } ;
402+ bool & done{ m_fields->done } ;
403+ bool & noShadow{ m_fields->noShadow } ;
420404
421405 if (!textArea) return ;
422406
423407 if (getLinesLeft () - emptyLinesAmount (3 ) <= 3 ) {
424408 if (!m_button2) {
425- auto dialogLayer = m_fields->dialogLayer ;
409+ auto dialogLayer{ m_fields->dialogLayer } ;
426410 done = true ;
427411 if (m_fields->dialog && dialogLayer) {
428412 dialogLayer->keyBackClicked ();
@@ -485,7 +469,7 @@ void DeltaruneAlertLayer::progressText() {
485469 }
486470
487471
488- auto title = m_fields->titles [dialogCount];
472+ auto & title = m_fields->titles [dialogCount];
489473 auto & nameToSound = m_fields->nameToSound ;
490474 m_fields->title ->setString (title.c_str ());
491475 m_mainLayer->removeChildByID (" character-sprite" _spr);
@@ -541,12 +525,12 @@ void DeltaruneAlertLayer::rollText(float dt) {
541525 else rolledPage = false ;
542526
543527 for (auto textArea : textAreas) {
544- CCArrayExt<CCLabelBMFont*> lines = static_cast <CCNode*>( textArea->getChildren ()-> objectAtIndex ( 0 ) )->getChildren ();
528+ CCArrayExt<CCLabelBMFont*> lines = textArea->getChildByType <MultilineBitmapFont>( 0 )->getChildren ();
545529 int currentLine = linesProgressed + rollingLine;
546530 if (currentLine < lines.size () && currentLine < linesProgressed + 3 ) {
547- auto line = lines[currentLine];
548- CCArrayExt<CCNode*> letters = line->getChildren ();
549- auto letter = letters[characterCount];
531+ auto line{ lines[currentLine] } ;
532+ CCArrayExt<CCNode*> letters{ line->getChildren () } ;
533+ auto letter{ letters[characterCount] } ;
550534 if (letter->isVisible ()) {
551535 unschedule (schedule_selector (DeltaruneAlertLayer::rollText));
552536 doneRolling = true ;
0 commit comments