mirror of
https://github.com/HarbourMasters/SpaghettiKart
synced 2026-06-24 17:53:29 -04:00
Implemented audio sliders
This commit is contained in:
+55
-55
@@ -18,6 +18,7 @@
|
||||
extern "C" {
|
||||
extern s32 gGamestateNext;
|
||||
extern s32 gMenuSelection;
|
||||
#include "audio/external.h"
|
||||
#include "defines.h"
|
||||
}
|
||||
|
||||
@@ -125,61 +126,60 @@ static const char* filters[3] = {
|
||||
|
||||
void DrawSettingsMenu() {
|
||||
if (UIWidgets::BeginMenu("Settings")) {
|
||||
// if (UIWidgets::BeginMenu("Audio")) {
|
||||
// UIWidgets::CVarSliderFloat("Master Volume", "gGameMasterVolume", 0.0f, 1.0f, 1.0f, {
|
||||
// .format = "%.0f%%",
|
||||
// .isPercentage = true,
|
||||
// });
|
||||
// if (UIWidgets::CVarSliderFloat("Main Music Volume", "gMainMusicVolume", 0.0f, 1.0f, 1.0f,
|
||||
// {
|
||||
// .format = "%.0f%%",
|
||||
// .isPercentage = true,
|
||||
// })) {
|
||||
// audio_set_player_volume(SEQ_PLAYER_LEVEL, CVarGetFloat("gMainMusicVolume", 1.0f));
|
||||
// }
|
||||
// if (UIWidgets::CVarSliderFloat("Sound Effects Volume", "gSFXMusicVolume",
|
||||
// 0.0f, 1.0f, 1.0f, {
|
||||
// .format = "%.0f%%",
|
||||
// .isPercentage = true,
|
||||
// })) {
|
||||
// audio_set_player_volume(SEQ_PLAYER_SFX, CVarGetFloat("gSFXMusicVolume", 1.0f));
|
||||
// }
|
||||
// if (UIWidgets::CVarSliderFloat("Environment Volume", "gEnvironmentVolume",
|
||||
// 0.0f, 1.0f, 1.0f, {
|
||||
// .format = "%.0f%%",
|
||||
// .isPercentage = true,
|
||||
// })) {
|
||||
// audio_set_player_volume(SEQ_PLAYER_ENV, CVarGetFloat("gEnvironmentVolume", 1.0f));
|
||||
// }
|
||||
//
|
||||
// static std::unordered_map<Ship::AudioBackend, const char*> audioBackendNames = {
|
||||
// { Ship::AudioBackend::WASAPI, "Windows Audio Session API" },
|
||||
// { Ship::AudioBackend::PULSE, "PulseAudio" },
|
||||
// { Ship::AudioBackend::SDL, "SDL" },
|
||||
// };
|
||||
//
|
||||
// ImGui::Text("Audio API (Needs reload)");
|
||||
// auto currentAudioBackend = Ship::Context::GetInstance()->GetAudio()->GetAudioBackend();
|
||||
//
|
||||
// if (Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1) {
|
||||
// UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f);
|
||||
// }
|
||||
// if (ImGui::BeginCombo("##AApi", audioBackendNames[currentAudioBackend])) {
|
||||
// for (uint8_t i = 0; i <
|
||||
// Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size(); i++) {
|
||||
// auto backend = Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->data()[i];
|
||||
// if (ImGui::Selectable(audioBackendNames[backend], backend == currentAudioBackend)) {
|
||||
// Ship::Context::GetInstance()->GetAudio()->SetAudioBackend(backend);
|
||||
// }
|
||||
// }
|
||||
// ImGui::EndCombo();
|
||||
// }
|
||||
// if (Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1) {
|
||||
// UIWidgets::ReEnableComponent("");
|
||||
// }
|
||||
//
|
||||
// ImGui::EndMenu();
|
||||
// }
|
||||
if (UIWidgets::BeginMenu("Audio")) {
|
||||
UIWidgets::CVarSliderFloat("Master Volume", "gGameMasterVolume", 0.0f, 1.0f, 1.0f, {
|
||||
.format = "%.0f%%",
|
||||
.isPercentage = true,
|
||||
});
|
||||
if (UIWidgets::CVarSliderFloat("Main Music Volume", "gMainMusicVolume", 0.0f, 1.0f, 1.0f,
|
||||
{
|
||||
.format = "%.0f%%",
|
||||
.isPercentage = true,
|
||||
})) {
|
||||
audio_set_player_volume(SEQ_PLAYER_LEVEL, CVarGetFloat("gMainMusicVolume", 1.0f));
|
||||
}
|
||||
if (UIWidgets::CVarSliderFloat("Sound Effects Volume", "gSFXMusicVolume",
|
||||
0.0f, 1.0f, 1.0f, {
|
||||
.format = "%.0f%%",
|
||||
.isPercentage = true,
|
||||
})) {
|
||||
audio_set_player_volume(SEQ_PLAYER_SFX, CVarGetFloat("gSFXMusicVolume", 1.0f));
|
||||
}
|
||||
if (UIWidgets::CVarSliderFloat("Environment Volume", "gEnvironmentVolume",
|
||||
0.0f, 1.0f, 1.0f, {
|
||||
.format = "%.0f%%",
|
||||
.isPercentage = true,
|
||||
})) {
|
||||
audio_set_player_volume(SEQ_PLAYER_ENV, CVarGetFloat("gEnvironmentVolume", 1.0f));
|
||||
}
|
||||
|
||||
static std::unordered_map<Ship::AudioBackend, const char*> audioBackendNames = {
|
||||
{ Ship::AudioBackend::WASAPI, "Windows Audio Session API" },
|
||||
{ Ship::AudioBackend::SDL, "SDL" },
|
||||
};
|
||||
|
||||
ImGui::Text("Audio API (Needs reload)");
|
||||
auto currentAudioBackend = Ship::Context::GetInstance()->GetAudio()->GetCurrentAudioBackend();
|
||||
|
||||
if (Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1) {
|
||||
UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f);
|
||||
}
|
||||
if (ImGui::BeginCombo("##AApi", audioBackendNames[currentAudioBackend])) {
|
||||
for (uint8_t i = 0; i <
|
||||
Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size(); i++) {
|
||||
auto backend = Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->data()[i];
|
||||
if (ImGui::Selectable(audioBackendNames[backend], backend == currentAudioBackend)) {
|
||||
Ship::Context::GetInstance()->GetAudio()->SetCurrentAudioBackend(backend);
|
||||
}
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
if (Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1) {
|
||||
UIWidgets::ReEnableComponent("");
|
||||
}
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
UIWidgets::Spacer(0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user