summaryrefslogtreecommitdiffstats
path: root/game/client
diff options
context:
space:
mode:
authoruntodesu <kirill@untode.su>2025-05-27 16:35:41 +0500
committeruntodesu <kirill@untode.su>2025-05-27 16:35:41 +0500
commitadbbe24b0941c369d52461418cef206fc895168e (patch)
tree349141c1e81f1d1113d8bbd96525ff2cf37d691b /game/client
parent29da2327c990ef0ad4347b0067f4556030bbb3dc (diff)
downloadvoxelius-adbbe24b0941c369d52461418cef206fc895168e.tar.bz2
voxelius-adbbe24b0941c369d52461418cef206fc895168e.zip
GUI updates
- Update ImGui to latest release (v1.91.9b) - Fixup splash using a deprecated ImGui function - Hide some settings tabs when not available - Fix sound config values getting trashed whenever sound system cannot be initialized
Diffstat (limited to 'game/client')
-rw-r--r--game/client/game.cc2
-rw-r--r--game/client/settings.cc48
-rw-r--r--game/client/sound.cc5
-rw-r--r--game/client/sound.hh1
-rw-r--r--game/client/splash.cc2
5 files changed, 34 insertions, 24 deletions
diff --git a/game/client/game.cc b/game/client/game.cc
index c1d3fa8..d6d1886 100644
--- a/game/client/game.cc
+++ b/game/client/game.cc
@@ -342,6 +342,8 @@ void client_game::init(void)
globals::gui_scale = 0U;
globals::gui_screen = GUI_MAIN_MENU;
+ sound::init_config();
+
if(globals::sound_ctx) {
sound::init();
}
diff --git a/game/client/settings.cc b/game/client/settings.cc
index d239532..12ce96c 100644
--- a/game/client/settings.cc
+++ b/game/client/settings.cc
@@ -18,20 +18,20 @@ constexpr static ImGuiWindowFlags WINDOW_FLAGS = ImGuiWindowFlags_NoBackground |
constexpr static unsigned int NUM_LOCATIONS = static_cast<unsigned int>(settings_location::COUNT);
enum class setting_type : unsigned int {
- CHECKBOX = 0x0000U, // ConfigBoolean
- INPUT_INT = 0x0001U, // ConfigNumber<int>
- INPUT_FLOAT = 0x0002U, // ConfigNumber<float>
- INPUT_UINT = 0x0003U, // ConfigNumber<unsigned int>
- INPUT_STRING = 0x0004U, // ConfigString
- SLIDER_INT = 0x0005U, // ConfigNumber<int>
- SLIDER_FLOAT = 0x0006U, // ConfigNumber<float>
- SLIDER_UINT = 0x0007U, // ConfigNumber<unsigned int>
- STEPPER_INT = 0x0008U, // ConfigNumber<int>
- STEPPER_UINT = 0x0009U, // ConfigNumber<unsigned int>
- KEYBIND = 0x000AU, // ConfigKeyBind
- GAMEPAD_AXIS = 0x000BU, // ConfigGamepadAxis
- GAMEPAD_BUTTON = 0x000CU, // ConfigGamepadButton
- LANGUAGE_SELECT = 0x000DU, // ConfigString internally
+ CHECKBOX = 0x0000U, ///< ConfigBoolean
+ INPUT_INT = 0x0001U, ///< ConfigNumber<int>
+ INPUT_FLOAT = 0x0002U, ///< ConfigNumber<float>
+ INPUT_UINT = 0x0003U, ///< ConfigNumber<unsigned int>
+ INPUT_STRING = 0x0004U, ///< ConfigString
+ SLIDER_INT = 0x0005U, ///< ConfigNumber<int>
+ SLIDER_FLOAT = 0x0006U, ///< ConfigNumber<float>
+ SLIDER_UINT = 0x0007U, ///< ConfigNumber<unsigned int>
+ STEPPER_INT = 0x0008U, ///< ConfigNumber<int>
+ STEPPER_UINT = 0x0009U, ///< ConfigNumber<unsigned int>
+ KEYBIND = 0x000AU, ///< ConfigKeyBind
+ GAMEPAD_AXIS = 0x000BU, ///< ConfigGamepadAxis
+ GAMEPAD_BUTTON = 0x000CU, ///< ConfigGamepadButton
+ LANGUAGE_SELECT = 0x000DU, ///< ConfigString internally
};
class SettingValue {
@@ -709,10 +709,12 @@ static void layout_input(void)
ImGui::EndTabItem();
}
- if(ImGui::BeginTabItem(str_input_gamepad.c_str())) {
- globals::gui_keybind_ptr = nullptr;
- layout_input_gamepad();
- ImGui::EndTabItem();
+ if(gamepad::available) {
+ if(ImGui::BeginTabItem(str_input_gamepad.c_str())) {
+ globals::gui_keybind_ptr = nullptr;
+ layout_input_gamepad();
+ ImGui::EndTabItem();
+ }
}
if(ImGui::BeginTabItem(str_input_mouse.c_str())) {
@@ -812,10 +814,12 @@ void settings::layout(void)
ImGui::EndTabItem();
}
- if(ImGui::BeginTabItem(str_tab_sound.c_str())) {
- globals::gui_keybind_ptr = nullptr;
- layout_sound();
- ImGui::EndTabItem();
+ if(globals::sound_ctx && globals::sound_dev) {
+ if(ImGui::BeginTabItem(str_tab_sound.c_str())) {
+ globals::gui_keybind_ptr = nullptr;
+ layout_sound();
+ ImGui::EndTabItem();
+ }
}
ImGui::EndTabBar();
diff --git a/game/client/sound.cc b/game/client/sound.cc
index fc48002..2512a04 100644
--- a/game/client/sound.cc
+++ b/game/client/sound.cc
@@ -30,7 +30,7 @@ static resource_ptr<SoundEffect> sfx_generic;
static resource_ptr<SoundEffect> sfx_player;
static resource_ptr<SoundEffect> sfx_ui;
-void sound::init(void)
+void sound::init_config(void)
{
globals::client_config.add_value("sound.volume_master", sound::volume_master);
globals::client_config.add_value("sound.volume_effects", sound::volume_effects);
@@ -42,7 +42,10 @@ void sound::init(void)
settings::add_slider(0, sound::volume_effects, settings_location::SOUND_LEVELS, "sound.volume_effects", false, "%.0f%%");
settings::add_slider(1, sound::volume_music, settings_location::SOUND_LEVELS, "sound.volume_music", false, "%.0f%%");
settings::add_slider(2, sound::volume_ui, settings_location::SOUND_LEVELS, "sound.volume_ui", false, "%.0f%%");
+}
+void sound::init(void)
+{
alGenSources(1, &generic_source);
alSourcei(generic_source, AL_SOURCE_RELATIVE, AL_TRUE);
alSource3f(generic_source, AL_POSITION, 0.0f, 0.0f, 0.0f);
diff --git a/game/client/sound.hh b/game/client/sound.hh
index 680c296..05ea39f 100644
--- a/game/client/sound.hh
+++ b/game/client/sound.hh
@@ -17,6 +17,7 @@ extern ConfigFloat volume_ui;
namespace sound
{
+void init_config(void);
void init(void);
void init_late(void);
void deinit(void);
diff --git a/game/client/splash.cc b/game/client/splash.cc
index 8bcf7e6..1de1e93 100644
--- a/game/client/splash.cc
+++ b/game/client/splash.cc
@@ -153,7 +153,7 @@ void client_splash::render(void)
const ImVec4 tint = ImVec4(1.0f, 1.0f, 1.0f, texture_alpha);
ImGui::SetCursorPos(image_pos);
- ImGui::Image(texture->handle, image_size, uv_a, uv_b, tint);
+ ImGui::ImageWithBg(texture->handle, image_size, uv_a, uv_b, ImVec4(0.0f, 0.0f, 0.0f, 0.0f), tint);
}
ImGui::End();