From e94a7fff50088068afa515caa826b1625d2b154d Mon Sep 17 00:00:00 2001 From: Alto1772 <56553686+Alto1772@users.noreply.github.com> Date: Wed, 26 Oct 2022 11:20:58 +0800 Subject: [PATCH] audio & rendering backend option greyed out if theres only one --- soh/soh/GameMenuBar.cpp | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/soh/soh/GameMenuBar.cpp b/soh/soh/GameMenuBar.cpp index 95f269860..c2a8a779e 100644 --- a/soh/soh/GameMenuBar.cpp +++ b/soh/soh/GameMenuBar.cpp @@ -553,17 +553,23 @@ namespace GameMenuBar { auto audioBackends = SohImGui::GetAvailableAudioBackends(); auto currentAudioBackend = SohImGui::GetCurrentAudioBackend(); + if (audioBackends.size() <= 1) { + ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); + ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * 0.5f); + } if (ImGui::BeginCombo("##AApi", currentAudioBackend.second)) { - if (audioBackends.size() > 1) { - for (uint8_t i = 0; i < audioBackends.size(); i++) { - if (ImGui::Selectable(audioBackends[i].second, audioBackends[i] == currentAudioBackend)) { - SohImGui::SetCurrentAudioBackend(i, audioBackends[i]); - } + for (uint8_t i = 0; i < audioBackends.size(); i++) { + if (ImGui::Selectable(audioBackends[i].second, audioBackends[i] == currentAudioBackend)) { + SohImGui::SetCurrentAudioBackend(i, audioBackends[i]); } } ImGui::EndCombo(); } + if (audioBackends.size() <= 1) { + ImGui::PopItemFlag(); + ImGui::PopStyleVar(1); + } ImGui::EndMenu(); } @@ -675,17 +681,23 @@ namespace GameMenuBar { auto renderingBackends = SohImGui::GetAvailableRenderingBackends(); auto currentRenderingBackend = SohImGui::GetCurrentRenderingBackend(); + if (renderingBackends.size() <= 1) { + ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); + ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * 0.5f); + } if (ImGui::BeginCombo("##RApi", currentRenderingBackend.second)) { - if (renderingBackends.size() > 1) { - for (uint8_t i = 0; i < renderingBackends.size(); i++) { - if (ImGui::Selectable(renderingBackends[i].second, renderingBackends[i] == currentRenderingBackend)) { - SohImGui::SetCurrentRenderingBackend(i, renderingBackends[i]); - } + for (uint8_t i = 0; i < renderingBackends.size(); i++) { + if (ImGui::Selectable(renderingBackends[i].second, renderingBackends[i] == currentRenderingBackend)) { + SohImGui::SetCurrentRenderingBackend(i, renderingBackends[i]); } } ImGui::EndCombo(); } + if (renderingBackends.size() <= 1) { + ImGui::PopItemFlag(); + ImGui::PopStyleVar(1); + } EXPERIMENTAL();