From b3ce27efedb973368e753b2faceb53dd8c71c6fa Mon Sep 17 00:00:00 2001 From: Jordan Longstaff Date: Wed, 16 Oct 2024 18:32:56 -0400 Subject: [PATCH] Add separate speed option for slower text (#4424) --- soh/soh/Enhancements/presets.h | 8 ++++++++ soh/soh/SohMenuBar.cpp | 4 ++++ soh/src/code/z_message_PAL.c | 9 +++++---- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/soh/soh/Enhancements/presets.h b/soh/soh/Enhancements/presets.h index bdf26ac0f..d72e05dcb 100644 --- a/soh/soh/Enhancements/presets.h +++ b/soh/soh/Enhancements/presets.h @@ -302,6 +302,7 @@ const std::vector enhancementsCvars = { CVAR_ENHANCEMENT("TimeSavers.SkipGetItemAnimation"), CVAR_ENHANCEMENT("TimeSavers.SkipChildStealth"), CVAR_ENHANCEMENT("TimeSavers.SkipTowerEscape"), + CVAR_ENHANCEMENT("SlowTextSpeed"), }; const std::vector cheatCvars = { @@ -561,6 +562,8 @@ const std::vector vanillaPlusPresetEntries = { // Text Speed (1 to 5) PRESET_ENTRY_S32(CVAR_ENHANCEMENT("TextSpeed"), 5), + // Slow Text Speed (1 to 5) + PRESET_ENTRY_S32(CVAR_ENHANCEMENT("SlowTextSpeed"), 5), // Skip Text PRESET_ENTRY_S32(CVAR_ENHANCEMENT("SkipText"), 1), // King Zora Speed (1 to 5) @@ -634,6 +637,8 @@ const std::vector enhancedPresetEntries = { // Text Speed (1 to 5) PRESET_ENTRY_S32(CVAR_ENHANCEMENT("TextSpeed"), 5), + // Slow Text Speed (1 to 5) + PRESET_ENTRY_S32(CVAR_ENHANCEMENT("SlowTextSpeed"), 5), // Skip Text PRESET_ENTRY_S32(CVAR_ENHANCEMENT("SkipText"), 1), // King Zora Speed (1 to 5) @@ -768,6 +773,8 @@ const std::vector randomizerPresetEntries = { // Text Speed (1 to 5) PRESET_ENTRY_S32(CVAR_ENHANCEMENT("TextSpeed"), 5), + // Slow Text Speed (1 to 5) + PRESET_ENTRY_S32(CVAR_ENHANCEMENT("SlowTextSpeed"), 5), // Skip Text PRESET_ENTRY_S32(CVAR_ENHANCEMENT("SkipText"), 1), // King Zora Speed (1 to 5) @@ -922,6 +929,7 @@ const std::vector randomizerPresetEntries = { const std::vector spockRacePresetEntries = { PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("LogicRules"), 0), PRESET_ENTRY_S32(CVAR_ENHANCEMENT("TextSpeed"), 5), + PRESET_ENTRY_S32(CVAR_ENHANCEMENT("SlowTextSpeed"), 5), PRESET_ENTRY_FLOAT(CVAR_ENHANCEMENT("MweepSpeed"), 5.0f), PRESET_ENTRY_S32(CVAR_ENHANCEMENT("ClimbSpeed"), 4), PRESET_ENTRY_S32(CVAR_ENHANCEMENT("FasterBlockPush"), 5), diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp index 08b11328e..5d37644ee 100644 --- a/soh/soh/SohMenuBar.cpp +++ b/soh/soh/SohMenuBar.cpp @@ -666,6 +666,10 @@ void DrawEnhancementsMenu() { UIWidgets::PaddedEnhancementSliderInt("Text Speed: %dx", "##TEXTSPEED", CVAR_ENHANCEMENT("TextSpeed"), 1, 5, "", 1, true, false, true); UIWidgets::PaddedEnhancementCheckbox("Skip Text", CVAR_ENHANCEMENT("SkipText"), false, true); + UIWidgets::PaddedEnhancementSliderInt("Slow Text Speed: %dx", "##SLOWTEXTSPEED", CVAR_ENHANCEMENT("SlowTextSpeed"), 1, 5, "", 1, true, false, true); + if (ImGui::Button("Match Normal Text")) { + CVarSetInteger(CVAR_ENHANCEMENT("SlowTextSpeed"), CVarGetInteger(CVAR_ENHANCEMENT("TextSpeed"), 1)); + } UIWidgets::Tooltip("Holding down B skips text"); UIWidgets::PaddedEnhancementSliderFloat("King Zora Speed: %.2fx", "##MWEEPSPEED", CVAR_ENHANCEMENT("MweepSpeed"), 0.1f, 5.0f, "", 1.0f, false, false, true); UIWidgets::PaddedEnhancementSliderInt("Vine/Ladder Climb speed +%d", "##CLIMBSPEED", CVAR_ENHANCEMENT("ClimbSpeed"), 0, 12, "", 0, true, false, true); diff --git a/soh/src/code/z_message_PAL.c b/soh/src/code/z_message_PAL.c index 5ced23cb7..53b2bb943 100644 --- a/soh/src/code/z_message_PAL.c +++ b/soh/src/code/z_message_PAL.c @@ -835,7 +835,7 @@ void Message_DrawText(PlayState* play, Gfx** gfxP) { u16 i; u16 sfxHi; u16 charTexIdx; - int gTextSpeed; + int gTextSpeed, gSlowTextSpeed; Font* font = &play->msgCtx.font; Gfx* gfx = *gfxP; @@ -857,7 +857,8 @@ void Message_DrawText(PlayState* play, Gfx** gfxP) { charTexIdx = 0; gTextSpeed = CVarGetInteger(CVAR_ENHANCEMENT("TextSpeed"), 1); - + gSlowTextSpeed = CVarGetInteger(CVAR_ENHANCEMENT("SlowTextSpeed"), gTextSpeed); + for (i = 0; i < msgCtx->textDrawPos; i++) { character = msgCtx->msgBufDecoded[i]; @@ -1125,10 +1126,10 @@ void Message_DrawText(PlayState* play, Gfx** gfxP) { } else if (msgCtx->textDelayTimer == 0) { msgCtx->textDrawPos = i + 1; msgCtx->textDelayTimer = msgCtx->textDelay; - } else if (msgCtx->textDelayTimer <= gTextSpeed) { + } else if (msgCtx->textDelayTimer <= gSlowTextSpeed) { msgCtx->textDelayTimer = 0; } else { - msgCtx->textDelayTimer -= gTextSpeed; + msgCtx->textDelayTimer -= gSlowTextSpeed; } *gfxP = gfx; }