44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
#include <AudioSettings.hpp>
|
|
|
|
AudioSettings::AudioSettings(nlohmann::json &settings) : settings(settings) {
|
|
lockChannels.setChecked(JSONGetField<bool>(settings, "audio", "lock"));
|
|
volumeL.setValue(JSONGetField<float>(settings, "audio", "volumeL") * 100);
|
|
volumeR.setValue(JSONGetField<float>(settings, "audio", "volumeR") * 100);
|
|
}
|
|
|
|
bool AudioSettings::render() {
|
|
if(lockChannels.render()) {
|
|
auto isChecked = lockChannels.isChecked();
|
|
JSONSetField(settings, "audio", "lock", isChecked);
|
|
if (isChecked) {
|
|
volumeR.setValue(volumeL.getValue());
|
|
}
|
|
|
|
modified = true;
|
|
}
|
|
|
|
ImGui::SameLine();
|
|
|
|
if(volumeL.render()) {
|
|
float valueL = volumeL.getValue();
|
|
JSONSetField(settings, "audio", "volumeL", float(valueL) / 100.f);
|
|
if (lockChannels.isChecked()) {
|
|
volumeR.setValue(valueL);
|
|
JSONSetField(settings, "audio", "volumeR", float(valueL) / 100.f);
|
|
}
|
|
|
|
modified = true;
|
|
}
|
|
|
|
ImGui::SameLine();
|
|
|
|
if(volumeR.render()) {
|
|
if (!lockChannels.isChecked()) {
|
|
JSONSetField(settings, "audio", "volumeR", float(volumeR.getValue()) / 100.f);
|
|
}
|
|
|
|
modified = true;
|
|
}
|
|
|
|
return modified;
|
|
} |