Codechange: Creating enum for 'scrollwheel_scrolling' setting

This commit is contained in:
Steve Goldman 2024-06-18 14:47:44 -05:00 committed by rubidium42
parent e8be933ee6
commit c53ed9fad6
6 changed files with 15 additions and 8 deletions

View File

@ -434,7 +434,7 @@ struct MainWindow : Window
void OnMouseWheel(int wheel) override void OnMouseWheel(int wheel) override
{ {
if (_settings_client.gui.scrollwheel_scrolling != 2) { if (_settings_client.gui.scrollwheel_scrolling != SWS_OFF) {
ZoomInOrOutToCursorWindow(wheel < 0, this); ZoomInOrOutToCursorWindow(wheel < 0, this);
} }
} }

View File

@ -126,6 +126,13 @@ enum ViewportScrollMode {
VSM_END, ///< Number of scroll mode settings. VSM_END, ///< Number of scroll mode settings.
}; };
/** Settings related to scroll wheel behavior. */
enum ScrollWheelScrollingSetting {
SWS_ZOOM_MAP = 0, ///< Scroll wheel zooms the map.
SWS_SCROLL_MAP = 1, ///< Scroll wheel scrolls the map.
SWS_OFF = 2 ///< Scroll wheel has no effect.
};
/** Settings related to the GUI and other stuff that is not saved in the savegame. */ /** Settings related to the GUI and other stuff that is not saved in the savegame. */
struct GUISettings { struct GUISettings {
bool sg_full_load_any; ///< new full load calculation, any cargo must be full read from pre v93 savegames bool sg_full_load_any; ///< new full load calculation, any cargo must be full read from pre v93 savegames

View File

@ -1790,7 +1790,7 @@ public:
void OnMouseWheel(int wheel) override void OnMouseWheel(int wheel) override
{ {
if (_settings_client.gui.scrollwheel_scrolling != 2) { if (_settings_client.gui.scrollwheel_scrolling != SWS_OFF) {
const NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_SM_MAP); const NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_SM_MAP);
int cursor_x = _cursor.pos.x - this->left - wid->pos_x; int cursor_x = _cursor.pos.x - this->left - wid->pos_x;
int cursor_y = _cursor.pos.y - this->top - wid->pos_y; int cursor_y = _cursor.pos.y - this->top - wid->pos_y;

View File

@ -387,9 +387,9 @@ cat = SC_BASIC
var = gui.scrollwheel_scrolling var = gui.scrollwheel_scrolling
type = SLE_UINT8 type = SLE_UINT8
flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC | SF_GUI_DROPDOWN flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC | SF_GUI_DROPDOWN
def = 0 def = SWS_ZOOM_MAP
min = 0 min = SWS_ZOOM_MAP
max = 2 max = SWS_OFF
str = STR_CONFIG_SETTING_SCROLLWHEEL_SCROLLING str = STR_CONFIG_SETTING_SCROLLWHEEL_SCROLLING
strhelp = STR_CONFIG_SETTING_SCROLLWHEEL_SCROLLING_HELPTEXT strhelp = STR_CONFIG_SETTING_SCROLLWHEEL_SCROLLING_HELPTEXT
strval = STR_CONFIG_SETTING_SCROLLWHEEL_ZOOM strval = STR_CONFIG_SETTING_SCROLLWHEEL_ZOOM

View File

@ -124,7 +124,7 @@ public:
void OnMouseWheel(int wheel) override void OnMouseWheel(int wheel) override
{ {
if (_settings_client.gui.scrollwheel_scrolling != 2) { if (_settings_client.gui.scrollwheel_scrolling != SWS_OFF) {
ZoomInOrOutToCursorWindow(wheel < 0, this); ZoomInOrOutToCursorWindow(wheel < 0, this);
} }
} }

View File

@ -2352,7 +2352,7 @@ static EventState HandleActiveWidget()
*/ */
static EventState HandleViewportScroll() static EventState HandleViewportScroll()
{ {
bool scrollwheel_scrolling = _settings_client.gui.scrollwheel_scrolling == 1 && (_cursor.v_wheel != 0 || _cursor.h_wheel != 0); bool scrollwheel_scrolling = _settings_client.gui.scrollwheel_scrolling == SWS_SCROLL_MAP && (_cursor.v_wheel != 0 || _cursor.h_wheel != 0);
if (!_scrolling_viewport) return ES_NOT_HANDLED; if (!_scrolling_viewport) return ES_NOT_HANDLED;
@ -2776,7 +2776,7 @@ static void MouseLoop(MouseClick click, int mousewheel)
HandleMouseOver(); HandleMouseOver();
bool scrollwheel_scrolling = _settings_client.gui.scrollwheel_scrolling == 1 && (_cursor.v_wheel != 0 || _cursor.h_wheel != 0); bool scrollwheel_scrolling = _settings_client.gui.scrollwheel_scrolling == SWS_SCROLL_MAP && (_cursor.v_wheel != 0 || _cursor.h_wheel != 0);
if (click == MC_NONE && mousewheel == 0 && !scrollwheel_scrolling) return; if (click == MC_NONE && mousewheel == 0 && !scrollwheel_scrolling) return;
int x = _cursor.pos.x; int x = _cursor.pos.x;