mirror of
https://github.com/HarbourMasters/Starship.git
synced 2025-02-03 00:33:55 +03:00
Added volume into imgui
This commit is contained in:
parent
a66816a986
commit
d107567276
@ -118,8 +118,11 @@ void func_80011890(Note* note, NoteAttributes* noteAttr) {
|
||||
if (velocity > 1.0f) {
|
||||
velocity = 1.0f;
|
||||
}
|
||||
noteSub->panVolLeft = (s32) (velocity * panVolumeLeft * 4095.999f);
|
||||
noteSub->panVolRight = (s32) (velocity * pamVolumeRight * 4095.999f);
|
||||
|
||||
float master_vol = CVarGetFloat("gGameMasterVolume", 1.0f);
|
||||
noteSub->panVolLeft = (s32) (velocity * panVolumeLeft * 4095.999f) * master_vol;
|
||||
noteSub->panVolRight = (s32) (velocity * pamVolumeRight * 4095.999f) * master_vol;
|
||||
|
||||
noteSub->gain = noteAttr->gain;
|
||||
if (noteSub->reverb != reverb) {
|
||||
noteSub->reverb = reverb;
|
||||
|
@ -447,6 +447,9 @@ void Game_Update(void) {
|
||||
#ifdef MODS_BOOT_STATE
|
||||
gNextGameState = MODS_BOOT_STATE;
|
||||
#endif
|
||||
CVarSetFloat("gMainMusicVolume", gSaveFile.save.data.musicVolume / 100.0f);
|
||||
CVarSetFloat("gVoiceVolume", gSaveFile.save.data.voiceVolume / 100.0f);
|
||||
CVarSetFloat("gSFXMusicVolume", gSaveFile.save.data.sfxVolume / 100.0f);
|
||||
for (i = 0; i < 4; i++) {
|
||||
gBoostButton[i] = L_CBUTTONS;
|
||||
gBrakeButton[i] = D_CBUTTONS;
|
||||
|
@ -1437,14 +1437,17 @@ void Option_Sound_SetVolumeLevels(void) {
|
||||
switch (D_menu_801B9288 - 1) {
|
||||
case 0:
|
||||
gSaveFile.save.data.musicVolume = var_v1;
|
||||
CVarSetFloat("gMainMusicVolume", var_v1 / 100.0f);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
gSaveFile.save.data.voiceVolume = var_v1;
|
||||
CVarSetFloat("gVoiceVolume", var_v1 / 100.0f);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
gSaveFile.save.data.sfxVolume = var_v1;
|
||||
CVarSetFloat("gSFXMusicVolume", var_v1 / 100.0f);
|
||||
break;
|
||||
}
|
||||
Audio_SetVolume(D_menu_801B924C, var_v1);
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
extern "C" {
|
||||
#include "sys.h"
|
||||
#include <sf64audio_provisional.h>
|
||||
}
|
||||
|
||||
namespace GameUI {
|
||||
@ -88,56 +89,62 @@ 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));
|
||||
// }
|
||||
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,
|
||||
})) {
|
||||
float val = CVarGetFloat("gMainMusicVolume", 1.0f) * 100;
|
||||
gSaveFile.save.data.musicVolume = val;
|
||||
Audio_SetVolume(AUDIO_TYPE_MUSIC, val);
|
||||
}
|
||||
if (UIWidgets::CVarSliderFloat("Voice Volume", "gVoiceVolume", 0.0f, 1.0f, 1.0f, {
|
||||
.format = "%.0f%%",
|
||||
.isPercentage = true,
|
||||
})) {
|
||||
float val = CVarGetFloat("gVoiceVolume", 1.0f) * 100;
|
||||
gSaveFile.save.data.voiceVolume = val;
|
||||
Audio_SetVolume(AUDIO_TYPE_VOICE, val);
|
||||
}
|
||||
if (UIWidgets::CVarSliderFloat("Sound Effects Volume", "gSFXMusicVolume", 0.0f, 1.0f, 1.0f, {
|
||||
.format = "%.0f%%",
|
||||
.isPercentage = true,
|
||||
})) {
|
||||
float val = CVarGetFloat("gSFXMusicVolume", 1.0f) * 100;
|
||||
gSaveFile.save.data.sfxVolume = val;
|
||||
Audio_SetVolume(AUDIO_TYPE_SFX, val);
|
||||
}
|
||||
|
||||
// static std::unordered_map<Ship::AudioBackend, const char*> audioBackendNames = {
|
||||
// { Ship::AudioBackend::WASAPI, "Windows Audio Session API" },
|
||||
// { Ship::AudioBackend::SDL, "SDL" },
|
||||
// };
|
||||
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()->GetAudioBackend();
|
||||
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()->SetAudioBackend(backend);
|
||||
// }
|
||||
// }
|
||||
// ImGui::EndCombo();
|
||||
// }
|
||||
// if (Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1) {
|
||||
// UIWidgets::ReEnableComponent("");
|
||||
// }
|
||||
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();
|
||||
// }
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
UIWidgets::Spacer(0);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user