From ddc64fb14caded7e49c0886cfa58b1ca82900262 Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Wed, 3 Jan 2024 20:08:57 +1100 Subject: Fix up and add options menu slider --- source/frontend/StarOptionsMenu.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'source/frontend/StarOptionsMenu.cpp') diff --git a/source/frontend/StarOptionsMenu.cpp b/source/frontend/StarOptionsMenu.cpp index caa1b21..0ea1fa1 100644 --- a/source/frontend/StarOptionsMenu.cpp +++ b/source/frontend/StarOptionsMenu.cpp @@ -20,6 +20,9 @@ OptionsMenu::OptionsMenu(PaneManager* manager) GuiReader reader; + reader.registerCallback("instrumentSlider", [=](Widget*) { + updateInstrumentVol(); + }); reader.registerCallback("sfxSlider", [=](Widget*) { updateSFXVol(); }); @@ -67,6 +70,7 @@ OptionsMenu::OptionsMenu(PaneManager* manager) reader.construct(config.get("paneLayout"), this); + m_instrumentSlider = fetchChild("instrumentSlider"); m_sfxSlider = fetchChild("sfxSlider"); m_musicSlider = fetchChild("musicSlider"); m_tutorialMessagesButton = fetchChild("tutorialMessagesCheckbox"); @@ -74,10 +78,12 @@ OptionsMenu::OptionsMenu(PaneManager* manager) m_clientP2PJoinableButton = fetchChild("clientP2PJoinableCheckbox"); m_allowAssetsMismatchButton = fetchChild("allowAssetsMismatchCheckbox"); + m_instrumentLabel = fetchChild("instrumentValueLabel"); m_sfxLabel = fetchChild("sfxValueLabel"); m_musicLabel = fetchChild("musicValueLabel"); m_p2pJoinableLabel = fetchChild("clientP2PJoinableLabel"); + m_instrumentSlider->setRange(m_sfxRange, assets->json("/interface/optionsmenu/optionsmenu.config:sfxDelta").toInt()); m_sfxSlider->setRange(m_sfxRange, assets->json("/interface/optionsmenu/optionsmenu.config:sfxDelta").toInt()); m_musicSlider->setRange(m_musicRange, assets->json("/interface/optionsmenu/optionsmenu.config:musicDelta").toInt()); @@ -103,6 +109,7 @@ void OptionsMenu::toggleFullscreen() { } StringList const OptionsMenu::ConfigKeys = { + "instrumentVol", "sfxVol", "musicVol", "tutorialMessages", @@ -120,6 +127,12 @@ void OptionsMenu::initConfig() { } } +void OptionsMenu::updateInstrumentVol() { + m_localChanges.set("instrumentVol", m_instrumentSlider->val()); + Root::singleton().configuration()->set("instrumentVol", m_instrumentSlider->val()); + m_instrumentLabel->setText(toString(m_instrumentSlider->val())); +} + void OptionsMenu::updateSFXVol() { m_localChanges.set("sfxVol", m_sfxSlider->val()); Root::singleton().configuration()->set("sfxVol", m_sfxSlider->val()); @@ -154,6 +167,9 @@ void OptionsMenu::updateAllowAssetsMismatch() { } void OptionsMenu::syncGuiToConf() { + m_instrumentSlider->setVal(m_localChanges.get("instrumentVol").toInt(), false); + m_instrumentLabel->setText(toString(m_instrumentSlider->val())); + m_sfxSlider->setVal(m_localChanges.get("sfxVol").toInt(), false); m_sfxLabel->setText(toString(m_sfxSlider->val())); -- cgit v1.2.3