From dba0ad2576aea3a31f8987f12205a49461f39aeb Mon Sep 17 00:00:00 2001 From: KiritoDv Date: Sat, 8 Mar 2025 18:36:42 -0600 Subject: [PATCH] Added install audio buttons --- src/port/Engine.cpp | 14 +++++++++++--- src/port/Engine.h | 2 +- src/port/ui/ImguiUI.cpp | 24 +++++++++++++++++++----- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/port/Engine.cpp b/src/port/Engine.cpp index 01d111fc..87cd9dd9 100644 --- a/src/port/Engine.cpp +++ b/src/port/Engine.cpp @@ -263,18 +263,26 @@ GameEngine::GameEngine() { context->GetResourceManager()->SetAltAssetsEnabled(prevAltAssets); } -bool GameEngine::GenAssetFile() { +bool GameEngine::GenAssetFile(bool exitOnFail) { auto extractor = new GameExtractor(); if (!extractor->SelectGameFromUI()) { ShowMessage("Error", "No ROM selected.\n\nExiting..."); - exit(1); + if (exitOnFail) { + exit(1); + } else { + return false; + } } auto game = extractor->ValidateChecksum(); if (!game.has_value()) { ShowMessage("Unsupported ROM", "The provided ROM is not supported.\n\nCheck the readme for a list of supported versions."); - exit(1); + if (exitOnFail) { + exit(1); + } else { + return false; + } } ShowMessage(("Found " + game.value()).c_str(), "The extraction process will now begin.\n\nThis may take a few minutes.", SDL_MESSAGEBOX_INFORMATION); diff --git a/src/port/Engine.h b/src/port/Engine.h index f0153fc1..26f9109f 100644 --- a/src/port/Engine.h +++ b/src/port/Engine.h @@ -30,7 +30,7 @@ class GameEngine { GameEngine(); void StartFrame() const; - static bool GenAssetFile(); + static bool GenAssetFile(bool exitOnFail = true); static void Create(); static void HandleAudioThread(); static void StartAudioFrame(); diff --git a/src/port/ui/ImguiUI.cpp b/src/port/ui/ImguiUI.cpp index e78c7255..addf058a 100644 --- a/src/port/ui/ImguiUI.cpp +++ b/src/port/ui/ImguiUI.cpp @@ -175,9 +175,12 @@ void DrawSettingsMenu(){ ImGui::EndMenu(); } - if(GameEngine::HasVersion(SF64_VER_EU)){ - UIWidgets::Spacer(0); - if (UIWidgets::BeginMenu("Language")) { + UIWidgets::Spacer(0); + + if (UIWidgets::BeginMenu("Language")) { + ImGui::Dummy(ImVec2(150, 0.0f)); + if(GameEngine::HasVersion(SF64_VER_EU)){ + UIWidgets::Spacer(0); if (UIWidgets::CVarCombobox("Voices", "gVoiceLanguage", voiceLangs, { .tooltip = "Changes the language of the voice acting in the game", @@ -185,9 +188,20 @@ void DrawSettingsMenu(){ })) { Audio_SetVoiceLanguage(CVarGetInteger("gVoiceLanguage", 0)); }; - ImGui::Dummy(ImVec2(ImGui::CalcTextSize(voiceLangs[0]).x + 55, 0.0f)); - ImGui::EndMenu(); + } else { + if(UIWidgets::Button("Install EU Audio")){ + if(!GameEngine::GenAssetFile()){ + GameEngine::ShowMessage("Success", "EU Audio Installed, restart the game to apply changes."); + } + } } + + if(!GameEngine::HasVersion(SF64_VER_JP) && UIWidgets::Button("Install JP Audio")) { + if(GameEngine::GenAssetFile()){ + GameEngine::ShowMessage("Success", "EU Audio Installed, restart the game to apply changes."); + } + } + ImGui::EndMenu(); } UIWidgets::Spacer(0);