Skip to content

Commit 31b8414

Browse files
committed
1.1.4
1 parent b8586c0 commit 31b8414

File tree

8 files changed

+100
-85
lines changed

8 files changed

+100
-85
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ You can skip the text by pressing X or clicking/tapping on the screen!
66

77
Apply using the Geode mod loader!
88

9+
<img src="resources/screenshot.jpg" alt="[This should show a screenshot]">
10+
911
## Sources:
1012
- Fonts:
1113
- [Determination Extended](https://fontstruct.com/fontstructions/show/2460153/determination-40-7)

about.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44

55
You can <cj>advance</c> the text by pressing <cy>Z</c>, <cy>Enter</c> or by </cy>tapping</c>/</cy>clicking</c> on the screen!
66

7-
You can <cj>skip</c> the text by pressing <cy>X</c> or <cy>tapping</c>/<cy>clicking</c> while the text rolls out!
7+
You can <cj>skip</c> the text by pressing <cy>X</c>, <cy>Space</c> or by <cy>tapping</c>/<cy>clicking</c> while the text rolls out!
88

9-
If you want to suggest a feature, create an issue on github or ping me on discord (@timestepyt)
9+
![[This should be a screenshot]](timestepyt.deltarune_textboxes/screenshot.jpg&scale:0.5)
1010

11+
If you want to suggest a feature, create an issue on github or ping me on discord (@timestepyt)
1112

12-
## Special Thanks
13+
# Special Thanks
1314
<cr>prevter</c>: Answered my stupid questions, and helped a lot!
1415

1516
JohnnyEnglish1: Reported a bug where choices don't appear, which never happened to me.

changelog.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
### v1.1.4
22
- A little bit of cleanup
33
- Crashfix
4+
- Choices now show two lines of previous text instead of just one
45

5-
### v1.1.3
6-
- Finally fixed choices not showing up
7-
- Mod comments support
6+
### v1.1.3 (never released)
7+
- Finally fixed choices not showing up (thanks prevter for having this bug and helping me fix it)
8+
- Mod comments support (kinda)
89

910
### v1.1.2
1011
- Fix star not fully disappearing
1112
- Prevent the first line from being empty
1213
- Animated corner pixels :D
1314

14-
### v1.1.1
15+
### v1.1.1 (never released)
1516
- Crashfix
1617

17-
### v1.1.0
18+
### v1.1.0 (never released)
1819
- Fix text being cut off on wider screens while having restrict width on
1920
- Fix weirdness with Prism Menu
2021
- Fix weirdness with Death Tracker

mod.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"id": "timestepyt.deltarune_textboxes",
1010
"name": "Deltarune Textboxes",
11-
"version": "v1.1.3-beta",
11+
"version": "v1.1.4",
1212
"developer": "TimeStepYT",
1313
"description": "Makes FLAlertLayers look like textboxes from Deltarune",
1414
"repository": "https://github.com/Reinmmar/DeltaruneTextboxes",
@@ -68,6 +68,7 @@
6868
"resources/snd_txtspam.wav",
6969
"resources/snd_txtspam2.wav",
7070
"resources/snd_txtq.wav",
71+
"resources/screenshot.jpg",
7172
"resources/g.jpg"
7273
]
7374
},
@@ -128,7 +129,8 @@
128129
"Berdly",
129130
"Queen",
130131
"Spamton",
131-
"Spamton NEO"
132+
"Spamton NEO",
133+
"No Sound"
132134
]
133135
}
134136
}

resources/screenshot.jpg

207 KB
Loading

src/FLAlertLayer.cpp

Lines changed: 72 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,38 @@ float randomNumberInAGivenRangeThatGetsAddedOrRemovedFromADifferentNumber(float
77
return static_cast<float>(rand() % static_cast<int>(range * 100 + 1)) / 100.f - (range / 2.f);
88
}
99

10+
void DeltaruneAlertLayer::initMaps() {
11+
auto& nameToFile = m_fields->nameToFile;
12+
auto& nameToSound = m_fields->nameToSound;
13+
14+
nameToFile["Default"] = "SND_TXT1";
15+
nameToFile["Typewriter"] = "SND_TXT2";
16+
nameToFile["Toriel"] = "snd_txttor";
17+
nameToFile["Sans"] = "snd_txtsans";
18+
nameToFile["Papyrus"] = "snd_txtpap";
19+
nameToFile["Undyne"] = "snd_txtund";
20+
nameToFile["Alphys"] = "snd_txtal";
21+
nameToFile["Asgore"] = "snd_txtasg";
22+
nameToFile["Asriel"] = "snd_txtasr";
23+
nameToFile["Susie"] = "snd_txtsus";
24+
nameToFile["Ralsei"] = "snd_txtral";
25+
nameToFile["Lancer"] = "snd_txtlan";
26+
nameToFile["Noelle"] = "snd_txtnoe";
27+
nameToFile["Berdly"] = "snd_txtber";
28+
nameToFile["Spamton"] = "snd_txtspam";
29+
nameToFile["Spamton NEO"] = "snd_txtspam2";
30+
nameToFile["Jevil"] = "snd_txtjok";
31+
nameToFile["Queen"] = "snd_txtq";
32+
33+
nameToSound["The Mechanic"] = "Alphys";
34+
nameToSound["The Shopkeeper"] = "Spamton";
35+
nameToSound["Scratch"] = "Lancer";
36+
nameToSound["Potbor"] = "Spamton NEO";
37+
nameToSound["Diamond Shopkeeper"] = "Papyrus";
38+
nameToSound["The Keymaster"] = "Susie";
39+
40+
}
41+
1042
bool DeltaruneAlertLayer::init(FLAlertLayerProtocol* delegate, char const* title, gd::string desc, char const* btn1, char const* btn2, float width, bool scroll, float height, float textScale) {
1143
float& screenSize = m_fields->screenSize;
1244
if (screenSize >= 569 && !m_fields->dontRestrictWidth)
@@ -19,17 +51,20 @@ bool DeltaruneAlertLayer::init(FLAlertLayerProtocol* delegate, char const* title
1951

2052
NodeIDs::provideFor(this);
2153
setID("FLAlertLayer");
22-
if (Loader::get()->isModLoaded("firee.prism")) {
54+
if (Loader::get()->isModLoaded("firee.prism")) { // probably the easiest way to detect a Prism Menu alert :3
2355
if (desc == "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA") {
2456
m_fields->incompatible = true;
2557
return true;
2658
}
2759
}
2860

61+
2962
auto& textArea = m_fields->textArea;
3063
auto& bg = m_fields->bg;
3164
auto& titleNode = m_fields->title;
3265

66+
initMaps(); // for sounds
67+
3368
this->m_noElasticity = true;
3469

3570
m_fields->btn1 = m_button1 ? this->m_button1->getParent() : nullptr;
@@ -220,7 +255,7 @@ void DeltaruneAlertLayer::keyDown(enumKeyCodes key) {
220255
progressText();
221256
return;
222257
}
223-
else if (key == enumKeyCodes::KEY_X || key == enumKeyCodes::KEY_Shift || key == enumKeyCodes::CONTROLLER_B) {
258+
else if (key == enumKeyCodes::KEY_X || key == enumKeyCodes::KEY_Space || key == enumKeyCodes::CONTROLLER_B) {
224259
skipText();
225260
return;
226261
}
@@ -321,46 +356,37 @@ void DeltaruneAlertLayer::progressText() {
321356
}
322357
else if (btnSelected != 0) {
323358
done = true;
324-
if (btnSelected == 1)
325-
FLAlertLayer::onBtn1(btn1);
326-
else if (btnSelected == 2)
327-
FLAlertLayer::onBtn2(btn2);
359+
if (btnSelected == 1) FLAlertLayer::onBtn1(btn1);
360+
else if (btnSelected == 2) FLAlertLayer::onBtn2(btn2);
328361
return;
329362
}
330363
}
364+
// Don't progress if there's only a choice left!
331365
if (getLinesLeft() < 3 && m_button2)
332366
return;
333367

334-
// move EVERYTHING up
335-
368+
// Move EVERYTHING up
369+
336370
int offset;
337-
338371
m_mainLayer->getChildByID("star"_spr)->setVisible(false);
339-
340372
if (!noShadow) m_mainLayer->getChildByID("starShadow"_spr)->setVisible(false);
341-
342-
343373

344374
unschedule(schedule_selector(DeltaruneAlertLayer::rollText));
345375
m_fields->characterCount = 0;
346376
m_fields->rollingLine = 0;
347377

348-
349378
if (getLinesLeft() > 3)
350379
offset = 3;
351380
else if (getLinesLeft() == 3)
352-
offset = 2;
353-
381+
offset = 1;
354382

355383
auto fontNode = (CCNode*) textArea->getChildren()->objectAtIndex(0);
356-
357-
358384
while (true) {
359385
auto topLine = (CCLabelBMFont*) fontNode->getChildren()->objectAtIndex(linesProgressed + offset);
360386
if (!topLine) break;
361387
std::string topLineString = topLine->getString();
362388
std::string noSpaceTopLineString = "";
363-
std::for_each(topLineString.begin(), topLineString.end(), [&](char c) {
389+
std::for_each(topLineString.begin(), topLineString.end(), [&noSpaceTopLineString](char c) {
364390
if (c != ' ') noSpaceTopLineString += c;
365391
});
366392
if (noSpaceTopLineString != "") break;
@@ -369,20 +395,16 @@ void DeltaruneAlertLayer::progressText() {
369395
if (!noShadow) m_mainLayer->getChildByID("starShadow"_spr)->setVisible(true);
370396
}
371397

372-
373398
linesProgressed += offset;
374399
textArea->setPositionY(textArea->getPositionY() + m_fields->textSize * offset);
375-
if (gradientOverlay)
376-
gradientOverlay->setPositionY(textArea->getPositionY());
377-
if (shadow)
378-
shadow->setPositionY(textArea->getPositionY() - 1);
379-
400+
if (gradientOverlay) gradientOverlay->setPositionY(textArea->getPositionY());
401+
if (shadow) shadow->setPositionY(textArea->getPositionY() - 1);
380402

381403
showButtons();
382404
float pause = Mod::get()->getSettingValue<double>("textRollingPause");
383405
schedule(schedule_selector(DeltaruneAlertLayer::rollText), pause / 30);
384-
log::info("Finished");
385406
}
407+
386408
void DeltaruneAlertLayer::rollText(float dt) {
387409
int& waitQueue = m_fields->waitQueue;
388410
int& linesProgressed = m_fields->linesProgressed;
@@ -454,44 +476,30 @@ void DeltaruneAlertLayer::rollText(float dt) {
454476
characterCount = 0;
455477
rollingLine++;
456478
}
457-
if (playSound) {
458-
if (playedSound) {
459-
playedSound = false;
460-
return;
461-
}
462-
float pitch = 1;
463-
playedSound = true;
464-
std::string sound = "";
465-
if (sound == "Default") sound = "SND_TXT1";
466-
else if (sound == "Typewriter") sound = "SND_TXT2";
467-
else if (sound == "Toriel") sound = "snd_txttor";
468-
else if (sound == "Sans") sound = "snd_txtsans";
469-
else if (sound == "Papyrus") sound = "snd_txtpap";
470-
else if (sound == "Undyne") sound = "snd_txtund";
471-
else if (sound == "Alphys") sound = "snd_txtal";
472-
else if (sound == "Asgore") sound = "snd_txtasg";
473-
else if (sound == "Asriel") sound = "snd_txtasr";
474-
else if (sound == "Susie") sound = "snd_txtsus";
475-
else if (sound == "Ralsei") sound = "snd_txtral";
476-
else if (sound == "Lancer") sound = "snd_txtlan";
477-
else if (sound == "Noelle") sound = "snd_txtnoe";
478-
else if (sound == "Berdly") sound = "snd_txtber";
479-
else if (sound == "Spamton") sound = "snd_txtspam";
480-
else if (sound == "Spamton NEO") sound = "snd_txtspam2";
481-
else if (sound == "Jevil") sound = "snd_txtjok";
482-
else if (sound == "Queen") {
483-
sound = "snd_txtq";
484-
pitch = 1 + randomNumberInAGivenRangeThatGetsAddedOrRemovedFromADifferentNumber(0.2f);
485-
}
486-
std::string path = fmt::format("{}/{}.wav", Mod::get()->getResourcesDir().string(), sound);
487-
auto& system = m_fields->system;
488-
auto& fmodSound = m_fields->sound;
489-
auto& channel = m_fields->channel;
490-
491-
system->createSound(path.c_str(), FMOD_DEFAULT, nullptr, &fmodSound);
492-
system->playSound(fmodSound, nullptr, false, &channel);
493-
channel->setPitch(pitch);
494-
channel->setVolume(FMODAudioEngine::sharedEngine()->m_sfxVolume);
479+
480+
auto nameToFile = m_fields->nameToFile;
481+
std::string const textSound = m_fields->textSound;
482+
std::string const resFolder = Mod::get()->getResourcesDir().string();
483+
std::string path = fmt::format("{}/{}.wav", resFolder, nameToFile[textSound]);
484+
485+
if (nameToFile.find(textSound) == nameToFile.end()) return;
486+
487+
if (!playSound || playedSound) {
488+
playedSound = false;
489+
return;
495490
}
496-
else playedSound = false;
491+
float pitch = 1;
492+
playedSound = true;
493+
494+
auto& system = m_fields->system;
495+
auto& channel = m_fields->channel;
496+
auto& sound = m_fields->sound;
497+
498+
if (textSound == "Queen")
499+
pitch = 1 + randomNumberInAGivenRangeThatGetsAddedOrRemovedFromADifferentNumber(0.2f);
500+
501+
system->createSound(path.c_str(), FMOD_DEFAULT, nullptr, &sound);
502+
system->playSound(sound, nullptr, false, &channel);
503+
channel->setPitch(pitch);
504+
channel->setVolume(FMODAudioEngine::sharedEngine()->m_sfxVolume);
497505
}

src/FLAlertLayer.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ class $modify(DeltaruneAlertLayer, FLAlertLayer) {
3636
FMOD::System* system = FMODAudioEngine::sharedEngine()->m_system;
3737
FMOD::Channel* channel;
3838
FMOD::Sound* sound;
39+
std::unordered_map<std::string, std::string> nameToFile;
40+
std::unordered_map<std::string, std::string> nameToSound;
3941
};
4042
void animateBG(float);
4143
void changeBG();
@@ -45,6 +47,7 @@ class $modify(DeltaruneAlertLayer, FLAlertLayer) {
4547
void changeLook();
4648
void decideToBlockKeys();
4749
void show() override;
50+
void initMaps();
4851
bool init(FLAlertLayerProtocol*, char const*, gd::string, char const*, char const*, float, bool, float, float);
4952
void rollText(float);
5053
void showButtons();

src/changeDesign.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,10 @@ void DeltaruneAlertLayer::changeText() {
115115

116116
auto& sound = m_fields->textSound;
117117
auto& size = m_fields->textSize;
118+
auto& nameToSound = m_fields->nameToSound;
118119
bool& noShadow = m_fields->noShadow;
119120

121+
120122
noShadow = Mod::get()->getSettingValue<bool>("noShadow") || sound == "Sans" || sound == "Papyrus";
121123

122124
CCLabelBMFont* star = CCLabelBMFont::create("*", "Determination.fnt"_spr);
@@ -125,19 +127,14 @@ void DeltaruneAlertLayer::changeText() {
125127

126128
auto str = m_fields->text;
127129
auto screenSize = m_fields->screenSize;
128-
auto titleString = std::string_view(m_fields->title->getString());
129130
auto& bg = m_fields->bg;
131+
std::string titleString = m_fields->title->getString();
130132

131133
int xOffset = star->getContentWidth();
132134

133135
if (m_fields->dialog) {
136+
if (nameToSound.find(titleString.c_str()) != nameToSound.end()) sound = nameToSound[titleString];
134137
xOffset = m_fields->characterSprite->getContentWidth() + 27 + star->getContentWidth();
135-
if (titleString == "The Mechanic") sound = "Alphys";
136-
else if (titleString == "Scratch") sound = "Lancer";
137-
else if (titleString == "The Shopkeeper") sound = "Spamton";
138-
else if (titleString == "Potbor") sound = "Spamton NEO";
139-
else if (titleString == "Diamond Shopkeeper") sound = "Papyrus";
140-
else if (titleString == "The Keymaster") sound = "Susie";
141138
}
142139
star->setPositionX(bg->getPositionX() - screenSize / 2 + xOffset - star->getContentWidth() + 27);
143140
star->setPositionY(110);
@@ -168,7 +165,7 @@ void DeltaruneAlertLayer::changeText() {
168165
false
169166
);
170167

171-
newDesc->setContentWidth(screenSize);
168+
newDesc->setContentWidth(creatingWidth);
172169
newDesc->setAnchorPoint(CCPoint{ 0, 1 });
173170
newDesc->setPositionY(110);
174171
newDesc->setZOrder(textArea->getZOrder());
@@ -186,7 +183,7 @@ void DeltaruneAlertLayer::changeText() {
186183
size,
187184
false
188185
);
189-
newDescGrad->setContentWidth(screenSize);
186+
newDescGrad->setContentWidth(creatingWidth);
190187
newDescGrad->setAnchorPoint(CCPoint{ 0, 1 });
191188
newDescGrad->setPositionY(110);
192189
newDescGrad->setZOrder(textArea->getZOrder() + 1);
@@ -211,7 +208,7 @@ void DeltaruneAlertLayer::changeText() {
211208
size,
212209
false
213210
);
214-
newDescShad->setContentWidth(screenSize);
211+
newDescShad->setContentWidth(creatingWidth);
215212
newDescShad->setAnchorPoint(CCPoint{ 0, 1 });
216213
newDescShad->setPositionY(109);
217214
newDescShad->setPositionX(newDescShad->getPositionX() + 1);
@@ -228,7 +225,8 @@ void DeltaruneAlertLayer::changeText() {
228225
auto origLine = (CCLabelBMFont*) origLinesParent->getChildren()->objectAtIndex(i);
229226
auto origChar = (CCSprite*) origLine->getChildren()->objectAtIndex(j);
230227
auto color = origChar->getColor();
231-
if (color == ccColor3B{ 255,255,255 }) letter->setColor({ 15, 15, 127 });
228+
229+
if (color == ccColor3B{ 255,255,255 }) letter->setColor({ 15, 15, 127 });
232230
else if (color == ccColor3B{ 255, 0, 255 }) letter->setColor({ 76, 0, 76 });
233231
else if (color == ccColor3B{ 255, 90, 90 }) letter->setColor({ 76, 0, 0 });
234232
else if (color == ccColor3B{ 255, 165, 75 }) letter->setColor({ 76, 38, 18 });

0 commit comments

Comments
 (0)