From 1b9962dfc2b65134bf46cbe027cfc4a106ee898a Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Fri, 20 Jan 2023 21:48:17 -0500 Subject: [PATCH] Enhancement: Adds Slider for Duration of Sequence Names on the Overlay (#2375) * New function: overlay text duration in seconds. `Overlay_DisplayText` took a float as an argument, with no clear indication of what that float represented. That float also evaluates to different durations given different frame rates. However, since we know what the frame rate should be at any given time (since it's stored in a CVar) we can calculate what this duration should be based on the number of seconds we want the overlay to be displayed. That's what `Overlay_DisplayText_Seconds` does. * Adds Slider for Overlay Sequence Name Durations --- soh/soh/Enhancements/sfx-editor/SfxEditor.cpp | 4 ++++ soh/soh/OTRGlobals.cpp | 5 +++++ soh/soh/OTRGlobals.h | 1 + soh/src/code/audio_load.c | 2 +- 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/soh/soh/Enhancements/sfx-editor/SfxEditor.cpp b/soh/soh/Enhancements/sfx-editor/SfxEditor.cpp index 19a862584..80b9c9baa 100644 --- a/soh/soh/Enhancements/sfx-editor/SfxEditor.cpp +++ b/soh/soh/Enhancements/sfx-editor/SfxEditor.cpp @@ -448,6 +448,10 @@ void DrawSfxEditor(bool& open) { "Displays the name of the current sequence in the corner of the screen whenever a new sequence " "is loaded to the main sequence player (does not apply to fanfares or enemy BGM)." ); + ImGui::SameLine(); + UIWidgets::EnhancementSliderInt("Overlay Duration: %d seconds", "##SeqNameOverlayDuration", + "gSeqNameOverlayDuration", 1, 10, "", 5, true); + ImGui::NewLine(); UIWidgets::PaddedSeparator(); UIWidgets::PaddedText("The following options are experimental and may cause music\nto sound odd or have other undesireable effects."); UIWidgets::EnhancementCheckbox("Lower Octaves of Unplayable High Notes", "gExperimentalOctaveDrop"); diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 435cdc6c1..6c7bb459f 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -1598,6 +1598,11 @@ extern "C" void Overlay_DisplayText(float duration, const char* text) { SohImGui::GetGameOverlay()->TextDrawNotification(duration, true, text); } +extern "C" void Overlay_DisplayText_Seconds(int seconds, const char* text) { + float duration = seconds * CVarGetInteger("gInterpolationFPS", 20) * 0.05; + SohImGui::GetGameOverlay()->TextDrawNotification(duration, true, text); +} + extern "C" void Entrance_ClearEntranceTrackingData(void) { ClearEntranceTrackingData(); } diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index 6b93bd2c7..6b393f177 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -130,6 +130,7 @@ GetItemEntry Randomizer_GetItemFromKnownCheckWithoutObtainabilityCheck(Randomize ItemObtainability Randomizer_GetItemObtainabilityFromRandomizerCheck(RandomizerCheck randomizerCheck); int CustomMessage_RetrieveIfExists(PlayState* play); void Overlay_DisplayText(float duration, const char* text); +void Overlay_DisplayText_Seconds(int seconds, const char* text); GetItemEntry ItemTable_Retrieve(int16_t getItemID); GetItemEntry ItemTable_RetrieveEntry(s16 modIndex, s16 getItemID); void Entrance_ClearEntranceTrackingData(void); diff --git a/soh/src/code/audio_load.c b/soh/src/code/audio_load.c index 03542f84f..4b4b027f3 100644 --- a/soh/src/code/audio_load.c +++ b/soh/src/code/audio_load.c @@ -615,7 +615,7 @@ s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIdx, s32 seqId, s32 arg2) { if (CVarGetInteger("gSeqNameOverlay", 0) && playerIdx == SEQ_PLAYER_BGM_MAIN) { const char* sequenceName = SfxEditor_GetSequenceName(seqId); if (sequenceName != NULL) { - Overlay_DisplayText(5.0f, sequenceName); + Overlay_DisplayText_Seconds(CVarGetInteger("gSeqNameOverlayDuration", 5), sequenceName); } } }