summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorterkhen <terkhen@openttd.org>2010-07-14 15:08:31 +0000
committerterkhen <terkhen@openttd.org>2010-07-14 15:08:31 +0000
commitfa3d9d04d386daf3ee92c9ab0f2624fbdcd1abf4 (patch)
tree24cd72f3eae0edfc8d4a5ec691869b9582a36856
parent0753669fa75cc6cddabe617478ae8dc45321510c (diff)
downloadopenttd-fa3d9d04d386daf3ee92c9ab0f2624fbdcd1abf4.tar.xz
(svn r20144) -Feature: Allow to configure the delay of hover events, or to disable them completely.
-rw-r--r--src/lang/english.txt2
-rw-r--r--src/settings_gui.cpp1
-rw-r--r--src/settings_type.h1
-rw-r--r--src/table/settings.h1
-rw-r--r--src/window.cpp25
5 files changed, 18 insertions, 12 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 4999d00bb..713e9918c 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -1145,6 +1145,8 @@ STR_CONFIG_SETTING_AUTORENEW_VEHICLE :{LTBLUE}Autoren
STR_CONFIG_SETTING_AUTORENEW_MONTHS :{LTBLUE}Autorenew when vehicle is {ORANGE}{STRING1}{LTBLUE} months before/after max age
STR_CONFIG_SETTING_AUTORENEW_MONEY :{LTBLUE}Autorenew minimum needed money for renew: {ORANGE}{STRING1}
STR_CONFIG_SETTING_ERRMSG_DURATION :{LTBLUE}Duration of error message: {ORANGE}{STRING1}
+STR_CONFIG_SETTING_HOVER_DELAY :{LTBLUE}Delay of hover events: {ORANGE}{STRING1}
+STR_CONFIG_SETTING_HOVER_DELAY_DISABLED :{LTBLUE}Delay of hover events: {ORANGE}disabled
STR_CONFIG_SETTING_POPULATION_IN_LABEL :{LTBLUE}Show town population in the town name label: {ORANGE}{STRING1}
STR_CONFIG_SETTING_LAND_GENERATOR :{LTBLUE}Land generator: {ORANGE}{STRING1}
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index 69f13f484..abb0bf389 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -1291,6 +1291,7 @@ static SettingEntry _settings_ui[] = {
SettingEntry(&_settings_ui_interaction_page, STR_CONFIG_SETTING_INTERACTION),
SettingEntry("gui.show_finances"),
SettingEntry("gui.errmsg_duration"),
+ SettingEntry("gui.hover_delay"),
SettingEntry("gui.toolbar_pos"),
SettingEntry("gui.pause_on_newgame"),
SettingEntry("gui.advanced_vehicle_list"),
diff --git a/src/settings_type.h b/src/settings_type.h
index 59fb454e4..c2d999cad 100644
--- a/src/settings_type.h
+++ b/src/settings_type.h
@@ -53,6 +53,7 @@ struct GUISettings {
uint8 stop_location; ///< what is the default stop location of trains?
bool autoscroll; ///< scroll when moving mouse to the edge
byte errmsg_duration; ///< duration of error message
+ byte hover_delay; ///< time required to activate a hover event, in seconds
bool link_terraform_toolbar; ///< display terraform toolbar when displaying rail, road, water and airport toolbars
uint8 smallmap_land_colour; ///< colour used for land and heightmap at the smallmap
bool reverse_scroll; ///< right-Click-Scrolling scrolls in the opposite direction
diff --git a/src/table/settings.h b/src/table/settings.h
index a25664b9a..dbfc87ce0 100644
--- a/src/table/settings.h
+++ b/src/table/settings.h
@@ -558,6 +558,7 @@ const SettingDesc _settings[] = {
SDTC_BOOL(gui.left_mouse_btn_scrolling, S, 0, false, STR_CONFIG_SETTING_LEFT_MOUSE_BTN_SCROLLING, NULL),
SDTC_BOOL(gui.measure_tooltip, S, 0, true, STR_CONFIG_SETTING_MEASURE_TOOLTIP, NULL),
SDTC_VAR(gui.errmsg_duration, SLE_UINT8, S, 0, 5, 0, 20, 0, STR_CONFIG_SETTING_ERRMSG_DURATION, NULL),
+ SDTC_VAR(gui.hover_delay, SLE_UINT8, S, D0, 2, 1, 5, 0, STR_CONFIG_SETTING_HOVER_DELAY, NULL),
SDTC_VAR(gui.toolbar_pos, SLE_UINT8, S, MS, 1, 0, 2, 0, STR_CONFIG_SETTING_TOOLBAR_POS, v_PositionMainToolbar),
SDTC_VAR(gui.window_snap_radius, SLE_UINT8, S, D0, 10, 1, 32, 0, STR_CONFIG_SETTING_SNAP_RADIUS, NULL),
SDTC_VAR(gui.window_soft_limit, SLE_UINT8, S, D0, 20, 5, 255, 1, STR_CONFIG_SETTING_SOFT_LIMIT, NULL),
diff --git a/src/window.cpp b/src/window.cpp
index d8162d439..5658e6887 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -2043,7 +2043,6 @@ enum MouseClick {
MAX_OFFSET_DOUBLE_CLICK = 5, ///< How much the mouse is allowed to move to call it a double click
TIME_BETWEEN_DOUBLE_CLICK = 500, ///< Time between 2 left clicks before it becoming a double click, in ms
MAX_OFFSET_HOVER = 5, ///< Maximum mouse movement before stopping a hover event.
- TIME_HOVER = 1000, ///< Time required to activate a hover event, in ms.
};
extern EventState VpHandlePlaceSizingDrag();
@@ -2242,17 +2241,19 @@ void HandleMouseEvents()
static int hover_time = 0;
static Point hover_pos = {0, 0};
- if (click != MC_NONE || mousewheel != 0 || _left_button_down || _right_button_down ||
- hover_pos.x == 0 || abs(_cursor.pos.x - hover_pos.x) >= MAX_OFFSET_HOVER ||
- hover_pos.y == 0 || abs(_cursor.pos.y - hover_pos.y) >= MAX_OFFSET_HOVER) {
- hover_pos = _cursor.pos;
- hover_time = _realtime_tick;
- _mouse_hovering = false;
- } else {
- if (hover_time != 0 && _realtime_tick - hover_time > TIME_HOVER) {
- click = MC_HOVER;
- _input_events_this_tick++;
- _mouse_hovering = true;
+ if (_settings_client.gui.hover_delay > 0) {
+ if (click != MC_NONE || mousewheel != 0 || _left_button_down || _right_button_down ||
+ hover_pos.x == 0 || abs(_cursor.pos.x - hover_pos.x) >= MAX_OFFSET_HOVER ||
+ hover_pos.y == 0 || abs(_cursor.pos.y - hover_pos.y) >= MAX_OFFSET_HOVER) {
+ hover_pos = _cursor.pos;
+ hover_time = _realtime_tick;
+ _mouse_hovering = false;
+ } else {
+ if (hover_time != 0 && _realtime_tick - hover_time > _settings_client.gui.hover_delay * 1000) {
+ click = MC_HOVER;
+ _input_events_this_tick++;
+ _mouse_hovering = true;
+ }
}
}