Skip to content

Commit

Permalink
Move reading settings to readSettings() and change disable_ to enable_
Browse files Browse the repository at this point in the history
  • Loading branch information
srifqi committed May 31, 2023
1 parent 0ea127f commit 2887b23
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
6 changes: 3 additions & 3 deletions builtin/settingtypes.txt
Expand Up @@ -108,12 +108,12 @@ invert_mouse (Invert mouse) bool false
# Mouse sensitivity multiplier.
mouse_sensitivity (Mouse sensitivity) float 0.2 0.001 10.0

# Enable mouse wheel (scroll) for item selection in hotbar.
enable_hotbar_mouse_wheel (Hotbar: Enable mouse wheel for selection) bool true

# Invert mouse wheel (scroll) direction for item selection in hotbar.
invert_hotbar_mouse_wheel (Hotbar: Invert mouse wheel direction) bool false

# Disable mouse wheel (scroll) for item selection in hotbar.
disable_hotbar_mouse_wheel (Hotbar: Disable mouse wheel for selection) bool false

[*Touchscreen]

# The length in pixels it takes for touch screen interaction to start.
Expand Down
18 changes: 10 additions & 8 deletions src/client/game.cpp
Expand Up @@ -1003,9 +1003,10 @@ class Game {
f32 m_cache_cam_smoothing;
f32 m_cache_fog_start;

bool m_invert_mouse = false;
bool m_invert_hotbar_mouse_wheel = false;
bool m_disable_hotbar_mouse_wheel = false;
bool m_invert_mouse;
bool m_enable_hotbar_mouse_wheel;
bool m_invert_hotbar_mouse_wheel;

bool m_first_loop_after_window_activation = false;
bool m_camera_offset_changed = false;
bool m_game_focused;
Expand Down Expand Up @@ -1151,9 +1152,6 @@ bool Game::startup(bool *kill,

m_game_ui->initFlags();

m_invert_mouse = g_settings->getBool("invert_mouse");
m_invert_hotbar_mouse_wheel = g_settings->getBool("invert_hotbar_mouse_wheel");
m_disable_hotbar_mouse_wheel = g_settings->getBool("disable_hotbar_mouse_wheel");
m_first_loop_after_window_activation = true;

#ifdef HAVE_TOUCHSCREENGUI
Expand Down Expand Up @@ -2143,10 +2141,10 @@ void Game::processItemSelection(u16 *new_playeritem)
player->hud_hotbar_itemcount - 1);

s32 wheel = input->getMouseWheel();
if (!m_enable_hotbar_mouse_wheel)
wheel = 0;
if (m_invert_hotbar_mouse_wheel)
wheel *= -1;
if (m_disable_hotbar_mouse_wheel)
wheel = 0;

s32 dir = wheel;

Expand Down Expand Up @@ -4308,6 +4306,10 @@ void Game::readSettings()
m_cache_cam_smoothing = rangelim(m_cache_cam_smoothing, 0.01f, 1.0f);
m_cache_mouse_sensitivity = rangelim(m_cache_mouse_sensitivity, 0.001, 100.0);

m_invert_mouse = g_settings->getBool("invert_mouse");
m_enable_hotbar_mouse_wheel = g_settings->getBool("enable_hotbar_mouse_wheel");
m_invert_hotbar_mouse_wheel = g_settings->getBool("invert_hotbar_mouse_wheel");

m_does_lost_focus_pause_game = g_settings->getBool("pause_on_lost_focus");
}

Expand Down
2 changes: 1 addition & 1 deletion src/defaultsettings.cpp
Expand Up @@ -285,8 +285,8 @@ void set_default_settings()

// Input
settings->setDefault("invert_mouse", "false");
settings->setDefault("enable_hotbar_mouse_wheel", "true");
settings->setDefault("invert_hotbar_mouse_wheel", "false");
settings->setDefault("disable_hotbar_mouse_wheel", "false");
settings->setDefault("mouse_sensitivity", "0.2");
settings->setDefault("repeat_place_time", "0.25");
settings->setDefault("safe_dig_and_place", "false");
Expand Down

0 comments on commit 2887b23

Please sign in to comment.