Merge remote-tracking branch 'upstream/1.11' into 1.11
This commit is contained in:
@@ -2165,8 +2165,8 @@ void ResizeWindow(Window *w, int delta_x, int delta_y, bool clamp_to_screen)
|
||||
* the resolution clamp it in such a manner that it stays within the bounds. */
|
||||
int new_right = w->left + w->width + delta_x;
|
||||
int new_bottom = w->top + w->height + delta_y;
|
||||
if (new_right >= (int)_cur_resolution.width) delta_x -= Ceil(new_right - _cur_resolution.width, std::max(1U, w->nested_root->resize_x));
|
||||
if (new_bottom >= (int)_cur_resolution.height) delta_y -= Ceil(new_bottom - _cur_resolution.height, std::max(1U, w->nested_root->resize_y));
|
||||
if (new_right >= (int)_screen.width) delta_x -= Ceil(new_right - _screen.width, std::max(1U, w->nested_root->resize_x));
|
||||
if (new_bottom >= (int)_screen.height) delta_y -= Ceil(new_bottom - _screen.height, std::max(1U, w->nested_root->resize_y));
|
||||
}
|
||||
|
||||
w->SetDirty();
|
||||
@@ -2833,11 +2833,12 @@ enum MouseClick {
|
||||
MC_HOVER,
|
||||
|
||||
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.
|
||||
};
|
||||
extern EventState VpHandlePlaceSizingDrag();
|
||||
|
||||
const std::chrono::milliseconds TIME_BETWEEN_DOUBLE_CLICK(500); ///< Time between 2 left clicks before it becoming a double click.
|
||||
|
||||
static void ScrollMainViewport(int x, int y)
|
||||
{
|
||||
if (_game_mode != GM_MENU) {
|
||||
@@ -2999,19 +3000,27 @@ void HandleMouseEvents()
|
||||
* But there is no company related window open anyway, so _current_company is not used. */
|
||||
assert(HasModalProgress() || IsLocalCompany());
|
||||
|
||||
static int double_click_time = 0;
|
||||
/* Handle sprite picker before any GUI interaction */
|
||||
if (_newgrf_debug_sprite_picker.mode == SPM_REDRAW && _input_events_this_tick == 0) {
|
||||
/* We are done with the last draw-frame, so we know what sprites we
|
||||
* clicked on. Reset the picker mode and invalidate the window. */
|
||||
_newgrf_debug_sprite_picker.mode = SPM_NONE;
|
||||
InvalidateWindowData(WC_SPRITE_ALIGNER, 0, 1);
|
||||
}
|
||||
|
||||
static std::chrono::steady_clock::time_point double_click_time = {};
|
||||
static Point double_click_pos = {0, 0};
|
||||
|
||||
/* Mouse event? */
|
||||
MouseClick click = MC_NONE;
|
||||
if (_left_button_down && !_left_button_clicked) {
|
||||
click = MC_LEFT;
|
||||
if (double_click_time != 0 && _realtime_tick - double_click_time < TIME_BETWEEN_DOUBLE_CLICK &&
|
||||
if (std::chrono::steady_clock::now() <= double_click_time + TIME_BETWEEN_DOUBLE_CLICK &&
|
||||
double_click_pos.x != 0 && abs(_cursor.pos.x - double_click_pos.x) < MAX_OFFSET_DOUBLE_CLICK &&
|
||||
double_click_pos.y != 0 && abs(_cursor.pos.y - double_click_pos.y) < MAX_OFFSET_DOUBLE_CLICK) {
|
||||
click = MC_DOUBLE_LEFT;
|
||||
}
|
||||
double_click_time = _realtime_tick;
|
||||
double_click_time = std::chrono::steady_clock::now();
|
||||
double_click_pos = _cursor.pos;
|
||||
_left_button_clicked = true;
|
||||
_input_events_this_tick++;
|
||||
@@ -3028,7 +3037,7 @@ void HandleMouseEvents()
|
||||
_input_events_this_tick++;
|
||||
}
|
||||
|
||||
static uint32 hover_time = 0;
|
||||
static std::chrono::steady_clock::time_point hover_time = {};
|
||||
static Point hover_pos = {0, 0};
|
||||
|
||||
if (_settings_client.gui.hover_delay_ms > 0) {
|
||||
@@ -3036,10 +3045,10 @@ void HandleMouseEvents()
|
||||
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;
|
||||
hover_time = std::chrono::steady_clock::now();
|
||||
_mouse_hovering = false;
|
||||
} else {
|
||||
if (hover_time != 0 && _realtime_tick > hover_time + _settings_client.gui.hover_delay_ms) {
|
||||
if (std::chrono::steady_clock::now() > hover_time + std::chrono::milliseconds(_settings_client.gui.hover_delay_ms)) {
|
||||
click = MC_HOVER;
|
||||
_input_events_this_tick++;
|
||||
_mouse_hovering = true;
|
||||
@@ -3047,18 +3056,10 @@ void HandleMouseEvents()
|
||||
}
|
||||
}
|
||||
|
||||
/* Handle sprite picker before any GUI interaction */
|
||||
if (_newgrf_debug_sprite_picker.mode == SPM_REDRAW && _newgrf_debug_sprite_picker.click_time != _realtime_tick) {
|
||||
/* Next realtime tick? Then redraw has finished */
|
||||
_newgrf_debug_sprite_picker.mode = SPM_NONE;
|
||||
InvalidateWindowData(WC_SPRITE_ALIGNER, 0, 1);
|
||||
}
|
||||
|
||||
if (click == MC_LEFT && _newgrf_debug_sprite_picker.mode == SPM_WAIT_CLICK) {
|
||||
/* Mark whole screen dirty, and wait for the next realtime tick, when drawing is finished. */
|
||||
Blitter *blitter = BlitterFactory::GetCurrentBlitter();
|
||||
_newgrf_debug_sprite_picker.clicked_pixel = blitter->MoveTo(_screen.dst_ptr, _cursor.pos.x, _cursor.pos.y);
|
||||
_newgrf_debug_sprite_picker.click_time = _realtime_tick;
|
||||
_newgrf_debug_sprite_picker.sprites.clear();
|
||||
_newgrf_debug_sprite_picker.mode = SPM_REDRAW;
|
||||
MarkWholeScreenDirty();
|
||||
@@ -3146,12 +3147,13 @@ void CallWindowRealtimeTickEvent(uint delta_ms)
|
||||
*/
|
||||
void UpdateWindows()
|
||||
{
|
||||
static uint32 last_realtime_tick = _realtime_tick;
|
||||
uint delta_ms = _realtime_tick - last_realtime_tick;
|
||||
last_realtime_tick = _realtime_tick;
|
||||
static std::chrono::steady_clock::time_point last_time = std::chrono::steady_clock::now();
|
||||
uint delta_ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - last_time).count();
|
||||
|
||||
if (delta_ms == 0) return;
|
||||
|
||||
last_time = std::chrono::steady_clock::now();
|
||||
|
||||
PerformanceMeasurer framerate(PFE_DRAWING);
|
||||
PerformanceAccumulator::Reset(PFE_DRAWWORLD);
|
||||
|
||||
@@ -3476,7 +3478,7 @@ void ReInitAllWindows()
|
||||
NetworkReInitChatBoxSize();
|
||||
|
||||
/* Make sure essential parts of all windows are visible */
|
||||
RelocateAllWindows(_cur_resolution.width, _cur_resolution.height);
|
||||
RelocateAllWindows(_screen.width, _screen.height);
|
||||
MarkWholeScreenDirty();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user