(svn r20144) -Feature: Allow to configure the delay of hover events, or to disable them completely.

This commit is contained in:
terkhen 2010-07-14 15:08:31 +00:00
parent 39e5c7e526
commit 6154b346e3
5 changed files with 18 additions and 12 deletions

View File

@ -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}

View File

@ -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"),

View File

@ -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

View File

@ -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),

View File

@ -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;
}
}
}