Skip to content

Commit 6a736f7

Browse files
committed
tweaked text sound rates
1 parent 90f6512 commit 6a736f7

File tree

5 files changed

+48
-18
lines changed

5 files changed

+48
-18
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ else()
88
endif()
99
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
1010

11-
project(DeltaruneTextboxes VERSION 1.5.0)
11+
project(DeltaruneTextboxes VERSION 1.5.2)
1212

1313
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "iOS" OR IOS OR (ANDROID AND ANDROID_ABI STREQUAL "armeabi-v7a"))
1414
add_compile_definitions(DISABLE_KEYBOARD)

changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
### v1.5.2
2+
- Tweaked the rate of the text sounds for some characters
3+
14
### v1.5.1
25
- Updated to newer Geode version so that iOS 26 works that came out right after I submitted v1.5.0, just my luck!
36

mod.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"geode": "4.6.0",
2+
"geode": "4.6.1",
33
"gd": {
44
"win": "2.2074",
55
"android": "2.2074",
@@ -8,7 +8,7 @@
88
},
99
"id": "timestepyt.deltarune_textboxes",
1010
"name": "Deltarune Textboxes",
11-
"version": "v1.5.1",
11+
"version": "v1.5.2",
1212
"developer": "TimeStepYT",
1313
"description": "Makes Popups look like Deltarune",
1414
"links": {

src/FLAlertLayer.cpp

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ float randomNumberInAGivenRangeThatGetsAddedOrRemovedFromADifferentNumber(float
2424
void DeltaruneAlertLayer::initMaps() {
2525
auto& nameToFile = m_fields->nameToFile;
2626
auto& nameToSound = m_fields->nameToSound;
27+
auto& nameToSoundRate = m_fields->nameToSoundRate;
2728

2829
nameToFile["Default"] = "SND_TXT1";
2930
nameToFile["Typewriter"] = "SND_TXT2";
@@ -57,6 +58,24 @@ void DeltaruneAlertLayer::initMaps() {
5758
nameToSound["Globed"] = "Tenna";
5859
nameToSound["Globed Error"] = "Tenna";
5960
nameToSound["Globed notice"] = "Tenna"; // I thought it was funny
61+
62+
nameToSoundRate["Tenna"] = 3;
63+
nameToSoundRate["Jackenstein"] = 3;
64+
nameToSoundRate["Gerson"] = 3;
65+
nameToSoundRate["Queen"] = 3;
66+
}
67+
68+
void DeltaruneAlertLayer::initSoundRate() {
69+
auto& soundRate = m_fields->soundRate;
70+
auto& soundTimer = m_fields->soundTimer;
71+
auto& textSound = m_fields->textSound;
72+
auto& nameToSoundRate = m_fields->nameToSoundRate;
73+
74+
if (nameToSoundRate.find(textSound) == nameToSoundRate.end())
75+
return;
76+
77+
soundRate = nameToSoundRate[textSound];
78+
soundTimer = soundRate;
6079
}
6180

6281
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) {
@@ -88,6 +107,7 @@ bool DeltaruneAlertLayer::init(FLAlertLayerProtocol* delegate, char const* title
88107
auto& titleNode = m_fields->title;
89108

90109
initMaps(); // for sounds
110+
initSoundRate();
91111

92112
this->m_noElasticity = true;
93113

@@ -520,25 +540,28 @@ void DeltaruneAlertLayer::rollText(float dt) {
520540
int& linesProgressed = m_fields->linesProgressed;
521541
int& characterCount = m_fields->characterCount;
522542
int& rollingLine = m_fields->rollingLine;
523-
bool& playedSound = m_fields->playedSound;
524543
bool& doneRolling = m_fields->doneRolling;
525544
bool& rolledPage = m_fields->rolledPage;
526545
float& lostTime = m_fields->lostTime;
527546
double const pause = Mod::get()->getSettingValue<double>("textRollingPause") / 30;
547+
auto& soundTimer = m_fields->soundTimer;
548+
auto& soundRate = m_fields->soundRate;
528549

529550
if (dt - pause > pause)
530551
lostTime += dt - pause;
531552

532553
bool playSound = true;
533554
char character;
534555

556+
soundTimer++;
557+
535558
for (bool firstRun{true}; lostTime >= pause || firstRun; firstRun = false) {
536559
bool newLine = false;
537560

538561
if (waitQueue != 0) {
539562
waitQueue--;
540-
playedSound = false;
541563
playSound = false;
564+
542565
if (lostTime >= pause && !firstRun) {
543566
lostTime -= pause;
544567
}
@@ -570,7 +593,7 @@ void DeltaruneAlertLayer::rollText(float dt) {
570593
character = line->getString()[characterCount];
571594
switch (character) {
572595
case ' ':
573-
waitQueue = 1;
596+
waitQueue = 0;
574597
playSound = false;
575598
break;
576599
case '.':
@@ -611,8 +634,7 @@ void DeltaruneAlertLayer::rollText(float dt) {
611634
}
612635
}
613636

614-
if (!playSound || playedSound) {
615-
playedSound = false;
637+
if (!playSound || soundTimer < soundRate) {
616638
return;
617639
}
618640

@@ -622,16 +644,18 @@ void DeltaruneAlertLayer::rollText(float dt) {
622644
void DeltaruneAlertLayer::playSound(char character) {
623645
auto& nameToFile = m_fields->nameToFile;
624646
auto& textSound = m_fields->textSound;
625-
auto& playedSound = m_fields->playedSound;
626-
auto& prevSoundNum = m_fields->prevSoundNum;
647+
auto& soundRate = m_fields->soundRate;
648+
auto& soundTimer = m_fields->soundTimer;
649+
auto& prevSoundNum = m_fields->prevSoundNum;
627650
auto const resFolder = Mod::get()->getResourcesDir();
628651

629652
if (nameToFile.find(textSound) == nameToFile.end()) return;
630653

631654
handleAprilFools();
632655

633656
float pitch = 1.f;
634-
playedSound = true;
657+
658+
soundTimer = 0;
635659

636660
auto& system = m_fields->system;
637661
auto& channel = m_fields->channel;
@@ -649,12 +673,12 @@ void DeltaruneAlertLayer::playSound(char character) {
649673
soundNumber = 5;
650674
else {
651675
soundNumber = mt() % numSounds + 1;
652-
while (prevSoundNum == soundNumber) {
653-
soundNumber = mt() % numSounds + 1;
654-
}
676+
while (prevSoundNum == soundNumber) {
677+
soundNumber = mt() % numSounds + 1;
678+
}
655679
}
656680

657-
prevSoundNum = soundNumber;
681+
prevSoundNum = soundNumber;
658682

659683
file = fmt::format("snd_txtten{}", soundNumber);
660684
}

src/FLAlertLayer.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ class $modify(DeltaruneAlertLayer, FLAlertLayer) {
1111
bool noShadow = false;
1212
bool doneRolling = false;
1313
bool rolledPage = false;
14-
bool playedSound = false;
1514
bool done = false;
1615
bool dontRestrictWidth = Mod::get()->getSettingValue<bool>("dontRestrictWidth");
1716
bool disableClickToProgress = Mod::get()->getSettingValue<bool>("disableClickToProgress");
@@ -26,6 +25,8 @@ class $modify(DeltaruneAlertLayer, FLAlertLayer) {
2625
int btnSelected = 0;
2726
int dialogCount = 0;
2827
int prevSoundNum = 200;
28+
int soundRate = 2;
29+
int soundTimer = 0;
2930
CCMenuItemSpriteExtra* btn1;
3031
CCMenuItemSpriteExtra* btn2;
3132
CCNode* textAreaClippingNode;
@@ -38,14 +39,15 @@ class $modify(DeltaruneAlertLayer, FLAlertLayer) {
3839
ImageNode* imageNode;
3940
DialogLayer* dialogLayer;
4041
FMOD::System* system = FMODAudioEngine::sharedEngine()->m_system;
41-
FMOD::Channel* channel;
42-
FMOD::Sound* sound;
42+
FMOD::Channel* channel = nullptr;
43+
FMOD::Sound* sound = nullptr;
4344
std::vector<std::string> characterSpriteNames;
4445
std::vector<std::string> titles;
4546
std::string text = "";
4647
std::string textSound = Mod::get()->getSettingValue<std::string>("textSound");
4748
std::unordered_map<std::string, std::string> nameToFile;
4849
std::unordered_map<std::string, std::string_view> nameToSound;
50+
std::unordered_map<std::string, int> nameToSoundRate;
4951
};
5052
void animateBG(float);
5153
void changeBG();
@@ -58,6 +60,7 @@ class $modify(DeltaruneAlertLayer, FLAlertLayer) {
5860
void changeLook();
5961
void decideToBlockKeys();
6062
void show() override;
63+
void initSoundRate();
6164
void initMaps();
6265
bool init(FLAlertLayerProtocol*, char const*, gd::string, char const*, char const*, float, bool, float, float);
6366
void rollText(float);

0 commit comments

Comments
 (0)