From a335aba98729b1933c439f6d5d4939df4fb12708 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Thu, 19 Jan 2023 03:50:50 -0500 Subject: [PATCH] Adds option for showing sequence names on the overlay (#2237) * Adds option for showing sequence names on the overlay Allows sequences to appear on the overlay in the bottom right corner for a few seconds whenever a new one is loaded into the primary sequence player. This means it does not apply to fanfares or enemy bgm. Fanfares I chose not to display because it would cause a lot of text to display back to back in some areas, and enemy bgm would have some technical challenges with this due to the way it loads. Mainly because the Lost Woods music would load in Goron City the same way (as well as the opposite). * Fixes crash when a sequence without a name is attempted to be displayed. * Removes accidentally committed CMakeSettings.json * Updates CVar_GetS32 to CVarGetInteger --- soh/soh/Enhancements/sfx-editor/SfxEditor.cpp | 13 +++++++++++++ soh/soh/Enhancements/sfx-editor/SfxEditor.h | 1 + soh/src/code/audio_load.c | 6 ++++++ 3 files changed, 20 insertions(+) diff --git a/soh/soh/Enhancements/sfx-editor/SfxEditor.cpp b/soh/soh/Enhancements/sfx-editor/SfxEditor.cpp index f336189d0..19a862584 100644 --- a/soh/soh/Enhancements/sfx-editor/SfxEditor.cpp +++ b/soh/soh/Enhancements/sfx-editor/SfxEditor.cpp @@ -384,6 +384,14 @@ extern "C" u16 SfxEditor_GetReverseReplacementSeq(u16 seqId) { return static_cast(seqId); } +extern "C" const char* SfxEditor_GetSequenceName(u16 seqId) { + if (sfxEditorSequenceMap.contains(seqId)) { + const char *name = std::get<0>(sfxEditorSequenceMap.at(seqId)).c_str(); + return name; + } + return NULL; +} + void DrawSfxEditor(bool& open) { if (!open) { CVarSetInteger("gSfxEditor", 0); @@ -435,6 +443,11 @@ void DrawSfxEditor(bool& open) { UIWidgets::InsertHelpHoverText( "Disables the music change when getting close to enemies. Useful for hearing " "your custom music for each scene more often."); + UIWidgets::EnhancementCheckbox("Display Sequence Name on Overlay", "gSeqNameOverlay"); + UIWidgets::InsertHelpHoverText( + "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)." + ); 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/Enhancements/sfx-editor/SfxEditor.h b/soh/soh/Enhancements/sfx-editor/SfxEditor.h index 526cd41f9..5b1cd39fd 100644 --- a/soh/soh/Enhancements/sfx-editor/SfxEditor.h +++ b/soh/soh/Enhancements/sfx-editor/SfxEditor.h @@ -3,6 +3,7 @@ void InitSfxEditor(); #ifndef __cplusplus +const char* SfxEditor_GetSequenceName(u16 seqId); void SfxEditor_AddSequence(char *otrPath, uint16_t seqNum); #endif diff --git a/soh/src/code/audio_load.c b/soh/src/code/audio_load.c index 7883aa405..03542f84f 100644 --- a/soh/src/code/audio_load.c +++ b/soh/src/code/audio_load.c @@ -612,6 +612,12 @@ s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIdx, s32 seqId, s32 arg2) { seqPlayer->playerIdx = playerIdx; AudioSeq_SkipForwardSequence(seqPlayer); //! @bug missing return (but the return value is not used so it's not UB) + if (CVarGetInteger("gSeqNameOverlay", 0) && playerIdx == SEQ_PLAYER_BGM_MAIN) { + const char* sequenceName = SfxEditor_GetSequenceName(seqId); + if (sequenceName != NULL) { + Overlay_DisplayText(5.0f, sequenceName); + } + } } u8* AudioLoad_SyncLoadSeq(s32 seqId) {