mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-07-12 13:35:35 -04:00
Move audio settings to init and set rather than update, improving performance
This commit is contained in:
@@ -5,36 +5,48 @@
|
|||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
|
||||||
namespace dusk::config {
|
namespace dusk::config {
|
||||||
inline void ImGuiCheckbox(const char* title, ConfigVar<bool>& var) {
|
inline bool ImGuiCheckbox(const char* title, ConfigVar<bool>& var) {
|
||||||
bool copy = var.getValue();
|
bool copy = var.getValue();
|
||||||
if (ImGui::Checkbox(title, ©)) {
|
if (ImGui::Checkbox(title, ©)) {
|
||||||
var.setValue(copy);
|
var.setValue(copy);
|
||||||
Save();
|
Save();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGuiSliderFloat(const char* label, ConfigVar<float>& var, float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0) {
|
static bool ImGuiSliderFloat(const char* label, ConfigVar<float>& var, float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0) {
|
||||||
float val = var;
|
float val = var;
|
||||||
if (ImGui::SliderFloat(label, &val, v_min, v_max, format, flags)) {
|
if (ImGui::SliderFloat(label, &val, v_min, v_max, format, flags)) {
|
||||||
var.setValue(val);
|
var.setValue(val);
|
||||||
Save();
|
Save();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGuiSliderInt(const char* label, ConfigVar<int>& var, int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0) {
|
static bool ImGuiSliderInt(const char* label, ConfigVar<int>& var, int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0) {
|
||||||
int val = var;
|
int val = var;
|
||||||
if (ImGui::SliderInt(label, &val, v_min, v_max, format, flags)) {
|
if (ImGui::SliderInt(label, &val, v_min, v_max, format, flags)) {
|
||||||
var.setValue(val);
|
var.setValue(val);
|
||||||
Save();
|
Save();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGuiMenuItem(const char* label, const char* shortcut, ConfigVar<bool>& p_selected, bool enabled = true) {
|
static bool ImGuiMenuItem(const char* label, const char* shortcut, ConfigVar<bool>& p_selected, bool enabled = true) {
|
||||||
bool copy = p_selected.getValue();
|
bool copy = p_selected.getValue();
|
||||||
if (ImGui::MenuItem(label, shortcut, ©, enabled)) {
|
if (ImGui::MenuItem(label, shortcut, ©, enabled)) {
|
||||||
p_selected.setValue(copy);
|
p_selected.setValue(copy);
|
||||||
Save();
|
Save();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -186,11 +186,12 @@ namespace dusk {
|
|||||||
} else {
|
} else {
|
||||||
VIUnlockAspectRatio();
|
VIUnlockAspectRatio();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dusk::audio::SetMasterVolume(dusk::getSettings().audio.masterVolume / 100.0f);
|
||||||
|
dusk::audio::SetEnableReverb(dusk::getSettings().audio.enableReverb);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGuiConsole::UpdateSettings() {
|
void ImGuiConsole::UpdateSettings() {
|
||||||
dusk::audio::SetMasterVolume(dusk::getSettings().audio.masterVolume / 100.0f);
|
|
||||||
dusk::audio::SetEnableReverb(dusk::getSettings().audio.enableReverb);
|
|
||||||
getTransientSettings().skipFrameRateLimit = getSettings().game.enableTurboKeybind && ImGui::IsKeyDown(ImGuiKey_Tab);
|
getTransientSettings().skipFrameRateLimit = getSettings().game.enableTurboKeybind && ImGui::IsKeyDown(ImGuiKey_Tab);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,8 +71,13 @@ namespace dusk {
|
|||||||
|
|
||||||
if (ImGui::BeginMenu("Audio")) {
|
if (ImGui::BeginMenu("Audio")) {
|
||||||
ImGui::Text("Master Volume");
|
ImGui::Text("Master Volume");
|
||||||
config::ImGuiSliderInt("##masterVolume", getSettings().audio.masterVolume, 0, 100);
|
if (config::ImGuiSliderInt("##masterVolume", getSettings().audio.masterVolume, 0, 100)) {
|
||||||
config::ImGuiCheckbox("Enable Reverb", getSettings().audio.enableReverb);
|
dusk::audio::SetMasterVolume(dusk::getSettings().audio.masterVolume / 100.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config::ImGuiCheckbox("Enable Reverb", getSettings().audio.enableReverb)) {
|
||||||
|
dusk::audio::SetEnableReverb(dusk::getSettings().audio.enableReverb);
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
// TODO: Implement additional settings
|
// TODO: Implement additional settings
|
||||||
ImGui::Text("Main Music Volume");
|
ImGui::Text("Main Music Volume");
|
||||||
|
|||||||
Reference in New Issue
Block a user