From 720b60bcdab4c75f1aaf564fc409bc265071ecdd Mon Sep 17 00:00:00 2001 From: Lucas Dominique Date: Fri, 22 May 2026 16:59:04 +0200 Subject: [PATCH 1/2] Added sound menu + cleanup --- include/client/App.hpp | 2 + include/client/AudioManager.hpp | 2 +- include/client/menus/SettingsMenu.hpp | 3 + include/client/menus/SoundsMenu.hpp | 42 ++++++++ src/client/App.cpp | 48 +++++++++ src/client/AudioManager.cpp | 4 - src/client/menus/SettingsMenu.cpp | 11 +++ src/client/menus/SoundsMenu.cpp | 135 ++++++++++++++++++++++++++ 8 files changed, 242 insertions(+), 5 deletions(-) create mode 100644 include/client/menus/SoundsMenu.hpp create mode 100644 src/client/menus/SoundsMenu.cpp diff --git a/include/client/App.hpp b/include/client/App.hpp index d24bff87..fe085406 100644 --- a/include/client/App.hpp +++ b/include/client/App.hpp @@ -75,6 +75,7 @@ #include "PauseMenu.hpp" #include "AudioManager.hpp" #include "ControlsMenu.hpp" +#include "SoundsMenu.hpp" std::atomic& interrupted(); @@ -183,6 +184,7 @@ class App { std::shared_ptr graphicsMenu; std::shared_ptr pauseMenu; std::shared_ptr controlsMenu; + std::shared_ptr soundsMenu; GLuint menuDirtTex = 0; std::unique_ptr playerListHUD; diff --git a/include/client/AudioManager.hpp b/include/client/AudioManager.hpp index 61262b53..4430e75d 100644 --- a/include/client/AudioManager.hpp +++ b/include/client/AudioManager.hpp @@ -154,7 +154,7 @@ class AudioManager { // ---- volumes (cached so sliders survive restart of music tracks) ------ float masterVolume = 1.0f; - float musicVolume = 0.0f; + float musicVolume = 0.8f; float sfxVolume = 1.0f; // Per-SoundId multiplier; filled with 1.0 in init(). diff --git a/include/client/menus/SettingsMenu.hpp b/include/client/menus/SettingsMenu.hpp index 9d868109..4a3dca0e 100644 --- a/include/client/menus/SettingsMenu.hpp +++ b/include/client/menus/SettingsMenu.hpp @@ -19,6 +19,7 @@ class SettingsMenu : public Menu { } void setChangeControlsCallback(std::function cb) { changeControls = std::move(cb); } void setGraphicsCallback(std::function cb) { onGraphics = std::move(cb); } + void setSoundsCallback(std::function cb) { onSounds = std::move(cb); } void handleMouseClick(double mouseX, double mouseY, int button, int action) override; void handleMouseMove(double mouseX, double mouseY) override; @@ -43,11 +44,13 @@ class SettingsMenu : public Menu { std::function onDone; std::function changeControls; std::function onGraphics; + std::function onSounds; GLuint dirtTexture = 0; Button doneButton; Button changeControlsButton; Button graphicsButton; + Button soundsButton; Button nameBox; // box }; diff --git a/include/client/menus/SoundsMenu.hpp b/include/client/menus/SoundsMenu.hpp new file mode 100644 index 00000000..eb5a9bcd --- /dev/null +++ b/include/client/menus/SoundsMenu.hpp @@ -0,0 +1,42 @@ +#ifndef SOUNDSMENU_HPP +#define SOUNDSMENU_HPP + +#include "Menu.hpp" +#include +#include + +class SoundsMenu : public Menu { +public: + SoundsMenu(float width, float height, GLuint dirtTex); + + void setDoneCallback(std::function cb) { onDone = std::move(cb); } + + void handleMouseClick(double mouseX, double mouseY, int button, int action) override; + void handleMouseMove(double mouseX, double mouseY) override; + + void addFloatSlider(const std::string& label, float min, float max, + std::function get, + std::function set, + int precision = 0); + + void addIntSlider(const std::string& label, int min, int max, + std::function get, + std::function set); + + // Lay out widgets after all add* calls. The caller adds widgets up front, then + // calls this once + void commit() { build(); } + +private: + void onRender() override; + void build() override; + + std::vector sliders; + + Button doneButton; + GLuint dirtTexture = 0; + + std::function onDone; +}; + +#endif diff --git a/src/client/App.cpp b/src/client/App.cpp index 90f316a8..3ad1657d 100644 --- a/src/client/App.cpp +++ b/src/client/App.cpp @@ -100,6 +100,7 @@ void App::init(const std::string& serverIp) { if (app->graphicsMenu) app->graphicsMenu->resize(width, height); if (app->pauseMenu) app->pauseMenu->resize(width, height); if (app->controlsMenu) app->controlsMenu->resize(width, height); + if (app->soundsMenu) app->soundsMenu->resize(width, height); }); glfwMakeContextCurrent(window); @@ -438,6 +439,7 @@ void App::init(const std::string& serverIp) { graphicsMenu = std::make_shared(screenWidth, screenHeight, menuDirtTex); pauseMenu = std::make_shared(screenWidth, screenHeight); controlsMenu = std::make_shared(screenWidth, screenHeight, menuDirtTex); + soundsMenu = std::make_shared(screenWidth, screenHeight, menuDirtTex); graphicsMenu->addToggle("V-Sync", [this]() { return vsync; }, @@ -467,6 +469,39 @@ void App::init(const std::string& serverIp) { graphicsMenu->commit(); controlsArray = controlsMenu->getControlsArray(); + + soundsMenu->addIntSlider("Master Volume", 0, 100, + [this]() { + if (audio) + return static_cast(audio->getMasterVolume() * 100); + return 100; + }, + [this](int v) { + if (audio) + audio->setMasterVolume(static_cast(v) / 100); + }); + soundsMenu->addIntSlider("Music Volume", 0, 100, + [this]() { + if (audio) + return static_cast(audio->getMusicVolume() * 100); + return 100; + }, + [this](int v) { + if (audio) + audio->setMusicVolume(static_cast(v) / 100); + }); + soundsMenu->addIntSlider("Effects Volume", 0, 100, + [this]() { + if (audio) + return static_cast(audio->getSfxVolume() * 100); + return 100; + }, + [this](int v) { + if (audio) + audio->setSfxVolume(static_cast(v) / 100); + }); + soundsMenu->commit(); + mainMenu->setButtonCallback([this](int btn) { switch (btn) { case 0: break; // Singleplayer - disabled @@ -518,6 +553,14 @@ void App::init(const std::string& serverIp) { menuManager = settingsMenu; }); + settingsMenu->setSoundsCallback([this]() { + menuManager = soundsMenu; + }); + + soundsMenu->setDoneCallback([this]() { + menuManager = settingsMenu; + }); + pauseMenu->setContinueCallback([this]() { menuManager.reset(); if (!uiInteractive) @@ -3107,6 +3150,7 @@ void App::cleanup() { settingsMenu.reset(); graphicsMenu.reset(); controlsMenu.reset(); + soundsMenu.reset(); pauseMenu.reset(); autoExposure.reset(); sceneFBO.reset(); @@ -3182,6 +3226,10 @@ bool App::popSubMenuOnEscape() { menuManager = settingsMenu; return true; } + if (mgr == soundsMenu) { + menuManager = settingsMenu; + return true; + } if (mgr == controlsMenu) { // Don't pop while a key rebind is pending — the rebinder consumes ESC. if (!controlsMenu->getChangeRequested()) diff --git a/src/client/AudioManager.cpp b/src/client/AudioManager.cpp index f6af6964..69b11e54 100644 --- a/src/client/AudioManager.cpp +++ b/src/client/AudioManager.cpp @@ -166,7 +166,6 @@ void AudioManager::loadAllAssets() { "assets/sounds/footsteps/grass/grass5.wav", "assets/sounds/footsteps/grass/grass6.wav", }); - loadSfx(SoundId::Footstep_Water, {"assets/sounds/footsteps/water/splash1.wav"}); // Block break / place — keyed by material group. loadSfx(SoundId::Break_Stone, { @@ -199,7 +198,6 @@ void AudioManager::loadAllAssets() { "assets/sounds/blocks/gravel/gravel3.wav", "assets/sounds/blocks/gravel/gravel4.wav", }); - loadSfx(SoundId::Break_Leaves, {"assets/sounds/blocks/break/leaves.wav"}); loadSfx(SoundId::Break_Snow, { "assets/sounds/blocks/snow/snow1.wav", "assets/sounds/blocks/snow/snow2.wav", @@ -285,7 +283,6 @@ void AudioManager::loadAllAssets() { "assets/sounds/mobs/creeper/explode3.wav", "assets/sounds/mobs/creeper/explode4.wav"}); - loadSfx(SoundId::Player_Jump, {"assets/sounds/player/jump.wav"}); loadSfx(SoundId::Player_Splash, { "assets/sounds/liquids/splash.wav", "assets/sounds/liquids/splash2.wav", @@ -327,7 +324,6 @@ void AudioManager::loadAllAssets() { "assets/sounds/player/damage/hit3.wav"}); // Generic Minecraft-style "block pop" used for pickup up items loadSfx(SoundId::Block_Pop, {"assets/sounds/player/pop.wav"}); - loadSfx(SoundId::UI_Click, {"assets/sounds/ui/button_click.wav"}); // Per-biome ambient music. Streamed (no full decode in RAM). loadMusic(BiomeType::PLAINS, "assets/sounds/music/plains.ogg"); diff --git a/src/client/menus/SettingsMenu.cpp b/src/client/menus/SettingsMenu.cpp index 80c1cdb4..5080f4f1 100644 --- a/src/client/menus/SettingsMenu.cpp +++ b/src/client/menus/SettingsMenu.cpp @@ -13,6 +13,7 @@ SettingsMenu::SettingsMenu(float width, float height, GLuint dirtTex) doneButton.label = "Done"; changeControlsButton.label = "Controls"; graphicsButton.label = "Graphics"; + soundsButton.label = "Sounds"; resize(width, height); username = "nameless"; loadUsername(); @@ -57,6 +58,11 @@ void SettingsMenu::build() graphicsButton.x = centerX - btnW / 2.0f; graphicsButton.y = changeControlsButton.y - btnH - 20.0f * menuScale; + soundsButton.w = btnW; + soundsButton.h = btnH; + soundsButton.x = centerX - btnW / 2.0f; + soundsButton.y = graphicsButton.y - btnH - 20.0f * menuScale; + doneButton.w = btnW; doneButton.h = btnH; doneButton.x = centerX - btnW / 2.0f; @@ -97,6 +103,9 @@ void SettingsMenu::onRender() drawButton(graphicsButton.x, graphicsButton.y, graphicsButton.w, graphicsButton.h, graphicsButton.label, graphicsButton.hovered); + drawButton(soundsButton.x, soundsButton.y, soundsButton.w, soundsButton.h, + soundsButton.label, soundsButton.hovered); + textRenderer.setScale(savedScale); } @@ -108,6 +117,7 @@ void SettingsMenu::handleMouseMove(double mouseX, double mouseY) updateHover(doneButton, glX, glY); updateHover(changeControlsButton, glX, glY); updateHover(graphicsButton, glX, glY); + updateHover(soundsButton, glX, glY); } void SettingsMenu::handleMouseClick(double mouseX, double mouseY, int button, int action) @@ -121,6 +131,7 @@ void SettingsMenu::handleMouseClick(double mouseX, double mouseY, int button, in if (isInside(doneButton, glX, glY) && onDone) onDone(); if (isInside(changeControlsButton, glX, glY) && changeControls) changeControls(); if (isInside(graphicsButton, glX, glY) && onGraphics) onGraphics(); + if (isInside(soundsButton, glX, glY) && onSounds) onSounds(); } void SettingsMenu::saveUsername(const char* filename) diff --git a/src/client/menus/SoundsMenu.cpp b/src/client/menus/SoundsMenu.cpp new file mode 100644 index 00000000..7808a223 --- /dev/null +++ b/src/client/menus/SoundsMenu.cpp @@ -0,0 +1,135 @@ +#include "SoundsMenu.hpp" +#include + +static constexpr float DESIGN_W = 960.0f; +static constexpr float DESIGN_H = 540.0f; + +static constexpr float ROW_W = 280.0f; +static constexpr float ROW_H = 30.0f; +static constexpr float ROW_GAP = 10.0f; + +static constexpr float DONE_W = 200.0f; +static constexpr float DONE_H = 40.0f; + +SoundsMenu::SoundsMenu(float width, float height, GLuint dirtTex) + : Menu(DESIGN_W, DESIGN_H), dirtTexture(dirtTex) +{ + doneButton.label = "Done"; + resize(width, height); +} + +void SoundsMenu::addFloatSlider(const std::string& label, float min, float max, + std::function get, + std::function set, + int precision) +{ + Slider s; + s.label = label; + s.minVal = min; + s.maxVal = max; + s.isInt = false; + s.precision = precision; + s.getF = std::move(get); + s.setF = std::move(set); + sliders.push_back(std::move(s)); +} + +void SoundsMenu::addIntSlider(const std::string& label, int min, int max, + std::function get, + std::function set) +{ + Slider s; + s.label = label; + s.minVal = static_cast(min); + s.maxVal = static_cast(max); + s.isInt = true; + s.getI = std::move(get); + s.setI = std::move(set); + sliders.push_back(std::move(s)); +} + +void SoundsMenu::build() +{ + float centerX = fullscreenWidth / 2.0f; + float rowW = ROW_W * menuScale; + float rowH = ROW_H * menuScale; + float rowGap = ROW_GAP * menuScale; + + float topY = fullscreenHeight - 130.0f * menuScale; + float y = topY - rowH; + + for (auto& s : sliders) + { + s.track.x = centerX - rowW / 2.0f; + s.track.y = y; + s.track.w = rowW; + s.track.h = rowH; + y -= rowH + rowGap; + } + + doneButton.w = DONE_W * menuScale; + doneButton.h = DONE_H * menuScale; + doneButton.x = centerX - doneButton.w / 2.0f; + doneButton.y = 60.0f * menuScale; +} + +void SoundsMenu::handleMouseClick(double mouseX, double mouseY, int button, int action) +{ + if (button != GLFW_MOUSE_BUTTON_LEFT) return; + + float glY = fullscreenHeight - static_cast(mouseY); + float glX = static_cast(mouseX); + + if (action == GLFW_RELEASE) { + for (auto& s : sliders) s.dragging = false; + return; + } + + if (action != GLFW_PRESS) return; + + for (auto& s : sliders) + if (clickSlider(s, glX, glY)) return; + + if (isInside(doneButton, glX, glY)) + { + if (onDone) onDone(); + } +} + +void SoundsMenu::handleMouseMove(double mouseX, double mouseY) +{ + float glY = fullscreenHeight - static_cast(mouseY); + float glX = static_cast(mouseX); + + for (auto& s : sliders) + { + updateHover(s.track, glX, glY); + dragSlider(s, glX); + } + + updateHover(doneButton, glX, glY); +} + +void SoundsMenu::onRender() +{ + drawTiledBackground(dirtTexture); + + float savedScale = textRenderer.getScale(); + + titleRenderer.setScale(0.4f * menuScale); + titleRenderer.setProjection(fullscreenWidth, fullscreenHeight); + + std::string title = "Sounds"; + float titleWidth = titleRenderer.getPixelSizeOfString(title); + float titleX = (fullscreenWidth - titleWidth) / 2.0f; + float titleY = fullscreenHeight - 80.0f * menuScale; + titleRenderer.renderText(title, titleX, titleY, glm::vec3(1.0f)); + + for (auto& s : sliders) + drawSlider(s); + + drawButton(doneButton.x, doneButton.y, doneButton.w, doneButton.h, + doneButton.label, doneButton.hovered); + + textRenderer.setScale(savedScale); +} From 8668c420ed1cb10201eda9c794f0fb112c74fd79 Mon Sep 17 00:00:00 2001 From: Lucas Dominique Date: Fri, 22 May 2026 17:31:57 +0200 Subject: [PATCH 2/2] Refactoring --- include/client/App.hpp | 2 +- include/client/menus/GraphicsMenu.hpp | 10 ----- include/client/menus/Menu.hpp | 11 +++++ include/client/menus/SoundsMenu.hpp | 11 ----- src/client/App.cpp | 65 +++++++++++++-------------- src/client/AudioManager.cpp | 4 ++ src/client/menus/GraphicsMenu.cpp | 30 ------------- src/client/menus/Menu.cpp | 30 +++++++++++++ src/client/menus/SoundsMenu.cpp | 30 ------------- 9 files changed, 78 insertions(+), 115 deletions(-) diff --git a/include/client/App.hpp b/include/client/App.hpp index fe085406..14c84dff 100644 --- a/include/client/App.hpp +++ b/include/client/App.hpp @@ -184,7 +184,7 @@ class App { std::shared_ptr graphicsMenu; std::shared_ptr pauseMenu; std::shared_ptr controlsMenu; - std::shared_ptr soundsMenu; + std::shared_ptr soundsMenu; GLuint menuDirtTex = 0; std::unique_ptr playerListHUD; diff --git a/include/client/menus/GraphicsMenu.hpp b/include/client/menus/GraphicsMenu.hpp index 365bfc85..b0e3a17f 100644 --- a/include/client/menus/GraphicsMenu.hpp +++ b/include/client/menus/GraphicsMenu.hpp @@ -18,15 +18,6 @@ class GraphicsMenu : public Menu { std::function get, std::function set); - void addFloatSlider(const std::string& label, float min, float max, - std::function get, - std::function set, - int precision = 0); - - void addIntSlider(const std::string& label, int min, int max, - std::function get, - std::function set); - // Lay out widgets after all add* calls. The caller adds widgets up front, then // calls this once void commit() { build(); } @@ -36,7 +27,6 @@ class GraphicsMenu : public Menu { void build() override; std::vector toggles; - std::vector sliders; Button doneButton; GLuint dirtTexture = 0; diff --git a/include/client/menus/Menu.hpp b/include/client/menus/Menu.hpp index 1faa4da2..40bae806 100644 --- a/include/client/menus/Menu.hpp +++ b/include/client/menus/Menu.hpp @@ -83,12 +83,23 @@ class Menu { bool clickSlider(Slider& s, float glX, float glY); void dragSlider(Slider& s, float glX); + std::vector sliders; + private: static void applySliderAtX(Slider& s, float glX); public: static GLuint loadTexture2D(const char* path, bool pixelated = true, int* outWidth = nullptr, int* outHeight = nullptr); + void addFloatSlider(const std::string& label, float min, float max, + std::function get, + std::function set, + int precision = 0); + + void addIntSlider(const std::string& label, int min, int max, + std::function get, + std::function set); + protected: virtual void onRender() = 0; diff --git a/include/client/menus/SoundsMenu.hpp b/include/client/menus/SoundsMenu.hpp index eb5a9bcd..d160f3e5 100644 --- a/include/client/menus/SoundsMenu.hpp +++ b/include/client/menus/SoundsMenu.hpp @@ -14,15 +14,6 @@ class SoundsMenu : public Menu { void handleMouseClick(double mouseX, double mouseY, int button, int action) override; void handleMouseMove(double mouseX, double mouseY) override; - void addFloatSlider(const std::string& label, float min, float max, - std::function get, - std::function set, - int precision = 0); - - void addIntSlider(const std::string& label, int min, int max, - std::function get, - std::function set); - // Lay out widgets after all add* calls. The caller adds widgets up front, then // calls this once void commit() { build(); } @@ -31,8 +22,6 @@ class SoundsMenu : public Menu { void onRender() override; void build() override; - std::vector sliders; - Button doneButton; GLuint dirtTexture = 0; diff --git a/src/client/App.cpp b/src/client/App.cpp index 3ad1657d..fe527b76 100644 --- a/src/client/App.cpp +++ b/src/client/App.cpp @@ -439,7 +439,7 @@ void App::init(const std::string& serverIp) { graphicsMenu = std::make_shared(screenWidth, screenHeight, menuDirtTex); pauseMenu = std::make_shared(screenWidth, screenHeight); controlsMenu = std::make_shared(screenWidth, screenHeight, menuDirtTex); - soundsMenu = std::make_shared(screenWidth, screenHeight, menuDirtTex); + soundsMenu = std::make_shared(screenWidth, screenHeight, menuDirtTex); graphicsMenu->addToggle("V-Sync", [this]() { return vsync; }, @@ -469,38 +469,37 @@ void App::init(const std::string& serverIp) { graphicsMenu->commit(); controlsArray = controlsMenu->getControlsArray(); - - soundsMenu->addIntSlider("Master Volume", 0, 100, - [this]() { - if (audio) - return static_cast(audio->getMasterVolume() * 100); - return 100; - }, - [this](int v) { - if (audio) - audio->setMasterVolume(static_cast(v) / 100); - }); - soundsMenu->addIntSlider("Music Volume", 0, 100, - [this]() { - if (audio) - return static_cast(audio->getMusicVolume() * 100); - return 100; - }, - [this](int v) { - if (audio) - audio->setMusicVolume(static_cast(v) / 100); - }); - soundsMenu->addIntSlider("Effects Volume", 0, 100, - [this]() { - if (audio) - return static_cast(audio->getSfxVolume() * 100); - return 100; - }, - [this](int v) { - if (audio) - audio->setSfxVolume(static_cast(v) / 100); - }); - soundsMenu->commit(); + soundsMenu->addIntSlider("Master Volume", 0, 100, + [this]() { + if (audio) + return static_cast(audio->getMasterVolume() * 100); + return 100; + }, + [this](int v) { + if (audio) + audio->setMasterVolume(static_cast(v) / 100); + }); + soundsMenu->addIntSlider("Music Volume", 0, 100, + [this]() { + if (audio) + return static_cast(audio->getMusicVolume() * 100); + return 100; + }, + [this](int v) { + if (audio) + audio->setMusicVolume(static_cast(v) / 100); + }); + soundsMenu->addIntSlider("Effects Volume", 0, 100, + [this]() { + if (audio) + return static_cast(audio->getSfxVolume() * 100); + return 100; + }, + [this](int v) { + if (audio) + audio->setSfxVolume(static_cast(v) / 100); + }); + soundsMenu->commit(); mainMenu->setButtonCallback([this](int btn) { switch (btn) { diff --git a/src/client/AudioManager.cpp b/src/client/AudioManager.cpp index 69b11e54..33692d3e 100644 --- a/src/client/AudioManager.cpp +++ b/src/client/AudioManager.cpp @@ -166,6 +166,10 @@ void AudioManager::loadAllAssets() { "assets/sounds/footsteps/grass/grass5.wav", "assets/sounds/footsteps/grass/grass6.wav", }); + loadSfx(SoundId::Footstep_Water, { + "assets/sounds/liquids/splash.wav", + "assets/sounds/liquids/splash2.wav", + }); // Block break / place — keyed by material group. loadSfx(SoundId::Break_Stone, { diff --git a/src/client/menus/GraphicsMenu.cpp b/src/client/menus/GraphicsMenu.cpp index a115e279..aa63e96a 100644 --- a/src/client/menus/GraphicsMenu.cpp +++ b/src/client/menus/GraphicsMenu.cpp @@ -29,36 +29,6 @@ void GraphicsMenu::addToggle(const std::string& label, toggles.push_back(std::move(t)); } -void GraphicsMenu::addFloatSlider(const std::string& label, float min, float max, - std::function get, - std::function set, - int precision) -{ - Slider s; - s.label = label; - s.minVal = min; - s.maxVal = max; - s.isInt = false; - s.precision = precision; - s.getF = std::move(get); - s.setF = std::move(set); - sliders.push_back(std::move(s)); -} - -void GraphicsMenu::addIntSlider(const std::string& label, int min, int max, - std::function get, - std::function set) -{ - Slider s; - s.label = label; - s.minVal = static_cast(min); - s.maxVal = static_cast(max); - s.isInt = true; - s.getI = std::move(get); - s.setI = std::move(set); - sliders.push_back(std::move(s)); -} - void GraphicsMenu::build() { float centerX = fullscreenWidth / 2.0f; diff --git a/src/client/menus/Menu.cpp b/src/client/menus/Menu.cpp index 0fce0ddb..a143de47 100644 --- a/src/client/menus/Menu.cpp +++ b/src/client/menus/Menu.cpp @@ -287,6 +287,36 @@ void Menu::dragSlider(Slider& s, float glX) applySliderAtX(s, glX); } +void Menu::addFloatSlider(const std::string& label, float min, float max, + std::function get, + std::function set, + int precision) +{ + Slider s; + s.label = label; + s.minVal = min; + s.maxVal = max; + s.isInt = false; + s.precision = precision; + s.getF = std::move(get); + s.setF = std::move(set); + sliders.push_back(std::move(s)); +} + +void Menu::addIntSlider(const std::string& label, int min, int max, + std::function get, + std::function set) +{ + Slider s; + s.label = label; + s.minVal = static_cast(min); + s.maxVal = static_cast(max); + s.isInt = true; + s.getI = std::move(get); + s.setI = std::move(set); + sliders.push_back(std::move(s)); +} + void Menu::drawSlider(const Slider& s) { float border = 2.0f * menuScale; diff --git a/src/client/menus/SoundsMenu.cpp b/src/client/menus/SoundsMenu.cpp index 7808a223..e2c52aab 100644 --- a/src/client/menus/SoundsMenu.cpp +++ b/src/client/menus/SoundsMenu.cpp @@ -18,36 +18,6 @@ SoundsMenu::SoundsMenu(float width, float height, GLuint dirtTex) resize(width, height); } -void SoundsMenu::addFloatSlider(const std::string& label, float min, float max, - std::function get, - std::function set, - int precision) -{ - Slider s; - s.label = label; - s.minVal = min; - s.maxVal = max; - s.isInt = false; - s.precision = precision; - s.getF = std::move(get); - s.setF = std::move(set); - sliders.push_back(std::move(s)); -} - -void SoundsMenu::addIntSlider(const std::string& label, int min, int max, - std::function get, - std::function set) -{ - Slider s; - s.label = label; - s.minVal = static_cast(min); - s.maxVal = static_cast(max); - s.isInt = true; - s.getI = std::move(get); - s.setI = std::move(set); - sliders.push_back(std::move(s)); -} - void SoundsMenu::build() { float centerX = fullscreenWidth / 2.0f;