Skip to content

Commit f2f3030

Browse files
committed
this too
1 parent 8d596f9 commit f2f3030

File tree

3 files changed

+49
-69
lines changed

3 files changed

+49
-69
lines changed

mod.json

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,20 @@
1414
"links": {
1515
"source": "https://github.com/TimeStepYT/DeltaruneTextboxes"
1616
},
17-
"tags": [
18-
"customization"
19-
],
20-
"dependencies": {
21-
"geode.node-ids": ">=1.19.0",
22-
"geode.custom-keybinds": {
17+
"tags": ["customization"],
18+
"dependencies": [
19+
{
20+
"id": "geode.node-ids",
21+
"version": ">=1.19.0",
22+
"importance": "required"
23+
},
24+
{
25+
"id": "geode.custom-keybinds",
2326
"importance": "required",
2427
"version": ">=v1.7.1",
25-
"platforms": [
26-
"win",
27-
"macos",
28-
"android64"
29-
]
28+
"platforms": ["win", "macos", "android64"]
3029
}
31-
},
30+
],
3231
"resources": {
3332
"sprites": [
3433
"resources/undertaleSquare.png",
@@ -100,10 +99,7 @@
10099
"type": "bool",
101100
"default": false,
102101
"description": "Disables <cy>clicking</c> to progress textboxes",
103-
"platforms": [
104-
"win",
105-
"mac"
106-
]
102+
"platforms": ["win", "mac"]
107103
},
108104
"coloredPortraits": {
109105
"name": "Colored Portraits",
@@ -175,4 +171,4 @@
175171
]
176172
}
177173
}
178-
}
174+
}

src/DialogLayer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ bool DeltaruneDialogLayer::init(DialogObject* dialogObject, CCArray* objectsOrig
1616
title = character.c_str();
1717
}
1818
else {
19-
character = static_cast<DialogObject*>(objects->objectAtIndex(0))->m_character;
19+
character = static_cast<DialogObject*>(objects->firstObject())->m_character;
2020
title = character.c_str();
2121
for (size_t i = 0; i < objects->count(); i++) {
2222
if (text.length() == 0) {
@@ -40,7 +40,7 @@ bool DeltaruneDialogLayer::init(DialogObject* dialogObject, CCArray* objectsOrig
4040
alert->m_fields->characterSprite = sprite;
4141
}
4242
else {
43-
auto firstObj = static_cast<DialogObject*>(objects->objectAtIndex(0));
43+
auto firstObj = static_cast<DialogObject*>(objects->firstObject());
4444
std::string textureName = fmt::format("dialogIcon_{:03}.png", firstObj->m_characterFrame);
4545

4646
if (Mod::get()->getSettingValue<bool>("coloredPortraits"))

src/FLAlertLayer.cpp

Lines changed: 34 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}
194194
void 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

203203
void 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

376362
int 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

Comments
 (0)