Merge branch 'master' into jgrpp
# Conflicts: # cmake/CompileFlags.cmake # src/aircraft_cmd.cpp # src/blitter/32bpp_anim.cpp # src/cargopacket.cpp # src/cheat_gui.cpp # src/company_cmd.cpp # src/company_gui.cpp # src/core/pool_func.hpp # src/date.cpp # src/economy.cpp # src/error_gui.cpp # src/ground_vehicle.cpp # src/ground_vehicle.hpp # src/group_gui.cpp # src/industry_cmd.cpp # src/lang/dutch.txt # src/lang/french.txt # src/lang/german.txt # src/linkgraph/linkgraph_gui.cpp # src/linkgraph/mcf.cpp # src/network/network_content.cpp # src/network/network_server.cpp # src/network/network_udp.cpp # src/newgrf_engine.cpp # src/newgrf_station.cpp # src/order_cmd.cpp # src/order_gui.cpp # src/pathfinder/follow_track.hpp # src/pathfinder/yapf/yapf_common.hpp # src/saveload/saveload.cpp # src/settings_gui.cpp # src/station_cmd.cpp # src/station_kdtree.h # src/string_func.h # src/table/settings.ini # src/tgp.cpp # src/timetable_cmd.cpp # src/timetable_gui.cpp # src/toolbar_gui.cpp # src/town_cmd.cpp # src/train_cmd.cpp # src/train_gui.cpp # src/tree_gui.cpp # src/tunnelbridge_cmd.cpp # src/vehicle.cpp # src/vehicle_gui.cpp # src/video/sdl2_v.cpp # src/video/sdl_v.cpp # src/video/win32_v.cpp # src/viewport.cpp # src/viewport_sprite_sorter_sse4.cpp # src/window.cpp
This commit is contained in:
@@ -739,8 +739,8 @@ static void DispatchLeftClickEvent(Window *w, int x, int y, int click_count)
|
||||
w->window_desc->pref_width = w->width;
|
||||
w->window_desc->pref_height = w->height;
|
||||
} else {
|
||||
int16 def_width = max<int16>(min(w->window_desc->GetDefaultWidth(), _screen.width), w->nested_root->smallest_x);
|
||||
int16 def_height = max<int16>(min(w->window_desc->GetDefaultHeight(), _screen.height - 50), w->nested_root->smallest_y);
|
||||
int16 def_width = std::max<int16>(std::min<int16>(w->window_desc->GetDefaultWidth(), _screen.width), w->nested_root->smallest_x);
|
||||
int16 def_height = std::max<int16>(std::min<int16>(w->window_desc->GetDefaultHeight(), _screen.height - 50), w->nested_root->smallest_y);
|
||||
|
||||
int dx = (w->resize.step_width == 0) ? 0 : def_width - w->width;
|
||||
int dy = (w->resize.step_height == 0) ? 0 : def_height - w->height;
|
||||
@@ -972,7 +972,7 @@ void DrawOverlappedWindowForAll(int left, int top, int right, int bottom)
|
||||
left < w->left + w->width &&
|
||||
top < w->top + w->height) {
|
||||
/* Window w intersects with the rectangle => needs repaint */
|
||||
DrawOverlappedWindow(w, max(left, w->left), max(top, w->top), min(right, w->left + w->width), min(bottom, w->top + w->height), DOWF_NONE);
|
||||
DrawOverlappedWindow(w, std::max(left, w->left), std::max(top, w->top), std::min(right, w->left + w->width), std::min(bottom, w->top + w->height), DOWF_NONE);
|
||||
}
|
||||
}
|
||||
_cur_dpi = old_dpi;
|
||||
@@ -1030,8 +1030,8 @@ void Window::ReInit(int rx, int ry)
|
||||
this->resize.step_height = this->nested_root->resize_y;
|
||||
|
||||
/* Resize as close to the original size + requested resize as possible. */
|
||||
window_width = max(window_width + rx, this->width);
|
||||
window_height = max(window_height + ry, this->height);
|
||||
window_width = std::max(window_width + rx, this->width);
|
||||
window_height = std::max(window_height + ry, this->height);
|
||||
int dx = (this->resize.step_width == 0) ? 0 : window_width - this->width;
|
||||
int dy = (this->resize.step_height == 0) ? 0 : window_height - this->height;
|
||||
/* dx and dy has to go by step.. calculate it.
|
||||
@@ -1548,8 +1548,8 @@ void Window::InitializePositionSize(int x, int y, int sm_width, int sm_height)
|
||||
*/
|
||||
void Window::FindWindowPlacementAndResize(int def_width, int def_height)
|
||||
{
|
||||
def_width = max(def_width, this->width); // Don't allow default size to be smaller than smallest size
|
||||
def_height = max(def_height, this->height);
|
||||
def_width = std::max(def_width, this->width); // Don't allow default size to be smaller than smallest size
|
||||
def_height = std::max(def_height, this->height);
|
||||
/* Try to make windows smaller when our window is too small.
|
||||
* w->(width|height) is normally the same as min_(width|height),
|
||||
* but this way the GUIs can be made a little more dynamic;
|
||||
@@ -1563,8 +1563,8 @@ void Window::FindWindowPlacementAndResize(int def_width, int def_height)
|
||||
wt = FindWindowById(WC_MAIN_TOOLBAR, 0);
|
||||
if (wt != nullptr) free_height -= wt->height;
|
||||
|
||||
int enlarge_x = max(min(def_width - this->width, _screen.width - this->width), 0);
|
||||
int enlarge_y = max(min(def_height - this->height, free_height - this->height), 0);
|
||||
int enlarge_x = std::max(std::min(def_width - this->width, _screen.width - this->width), 0);
|
||||
int enlarge_y = std::max(std::min(def_height - this->height, free_height - this->height), 0);
|
||||
|
||||
/* X and Y has to go by step.. calculate it.
|
||||
* The cast to int is necessary else x/y are implicitly casted to
|
||||
@@ -1585,8 +1585,8 @@ void Window::FindWindowPlacementAndResize(int def_width, int def_height)
|
||||
if (nx + this->width > _screen.width) nx -= (nx + this->width - _screen.width);
|
||||
|
||||
const Window *wt = FindWindowById(WC_MAIN_TOOLBAR, 0);
|
||||
ny = max(ny, (wt == nullptr || this == wt || this->top == 0) ? 0 : wt->height);
|
||||
nx = max(nx, 0);
|
||||
ny = std::max(ny, (wt == nullptr || this == wt || this->top == 0) ? 0 : wt->height);
|
||||
nx = std::max(nx, 0);
|
||||
|
||||
if (this->viewport != nullptr) {
|
||||
this->viewport->left += nx - this->left;
|
||||
@@ -1734,7 +1734,7 @@ static Point GetAutoPlacePosition(int width, int height)
|
||||
*/
|
||||
int left = rtl ? _screen.width - width : 0, top = toolbar_y;
|
||||
int offset_x = rtl ? -(int)NWidgetLeaf::closebox_dimension.width : (int)NWidgetLeaf::closebox_dimension.width;
|
||||
int offset_y = max<int>(NWidgetLeaf::closebox_dimension.height, FONT_HEIGHT_NORMAL + WD_CAPTIONTEXT_TOP + WD_CAPTIONTEXT_BOTTOM);
|
||||
int offset_y = std::max<int>(NWidgetLeaf::closebox_dimension.height, FONT_HEIGHT_NORMAL + WD_CAPTIONTEXT_TOP + WD_CAPTIONTEXT_BOTTOM);
|
||||
|
||||
restart:
|
||||
FOR_ALL_WINDOWS_FROM_BACK(w) {
|
||||
@@ -1786,8 +1786,8 @@ static Point LocalGetWindowPlacement(const WindowDesc *desc, int16 sm_width, int
|
||||
Point pt;
|
||||
const Window *w;
|
||||
|
||||
int16 default_width = max(desc->GetDefaultWidth(), sm_width);
|
||||
int16 default_height = max(desc->GetDefaultHeight(), sm_height);
|
||||
int16 default_width = std::max(desc->GetDefaultWidth(), sm_width);
|
||||
int16 default_height = std::max(desc->GetDefaultHeight(), sm_height);
|
||||
|
||||
if (desc->parent_cls != WC_NONE && (w = FindWindowById(desc->parent_cls, window_number)) != nullptr) {
|
||||
bool rtl = _current_text_dir == TD_RTL;
|
||||
@@ -1800,16 +1800,16 @@ static Point LocalGetWindowPlacement(const WindowDesc *desc, int16 sm_width, int
|
||||
* - Y position: closebox of parent + closebox of child + statusbar
|
||||
* - X position: closebox on left/right, resizebox on right/left (depending on ltr/rtl)
|
||||
*/
|
||||
int indent_y = max<int>(NWidgetLeaf::closebox_dimension.height, FONT_HEIGHT_NORMAL + WD_CAPTIONTEXT_TOP + WD_CAPTIONTEXT_BOTTOM);
|
||||
int indent_y = std::max<int>(NWidgetLeaf::closebox_dimension.height, FONT_HEIGHT_NORMAL + WD_CAPTIONTEXT_TOP + WD_CAPTIONTEXT_BOTTOM);
|
||||
if (w->top + 3 * indent_y < _screen.height) {
|
||||
pt.y = w->top + indent_y;
|
||||
int indent_close = NWidgetLeaf::closebox_dimension.width;
|
||||
int indent_resize = NWidgetLeaf::resizebox_dimension.width;
|
||||
if (_current_text_dir == TD_RTL) {
|
||||
pt.x = max(w->left + w->width - default_width - indent_close, 0);
|
||||
pt.x = std::max(w->left + w->width - default_width - indent_close, 0);
|
||||
if (pt.x + default_width >= indent_close && pt.x + indent_resize <= _screen.width) return pt;
|
||||
} else {
|
||||
pt.x = min(w->left + indent_close, _screen.width - default_width);
|
||||
pt.x = std::min(w->left + indent_close, _screen.width - default_width);
|
||||
if (pt.x + default_width >= indent_resize && pt.x + indent_close <= _screen.width) return pt;
|
||||
}
|
||||
}
|
||||
@@ -1968,10 +1968,15 @@ void ResetWindowSystem()
|
||||
|
||||
static void DecreaseWindowCounters()
|
||||
{
|
||||
static byte hundredth_tick_timeout = 100;
|
||||
|
||||
if (_scroller_click_timeout != 0) _scroller_click_timeout--;
|
||||
if (hundredth_tick_timeout != 0) hundredth_tick_timeout--;
|
||||
|
||||
Window *w;
|
||||
FOR_ALL_WINDOWS_FROM_FRONT(w) {
|
||||
if (!_network_dedicated && hundredth_tick_timeout == 0) w->OnHundredthTick();
|
||||
|
||||
if (_scroller_click_timeout == 0) {
|
||||
/* Unclick scrollbar buttons if they are pressed. */
|
||||
for (uint i = 0; i < w->nested_array_size; i++) {
|
||||
@@ -2003,6 +2008,8 @@ static void DecreaseWindowCounters()
|
||||
w->RaiseButtons(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (hundredth_tick_timeout == 0) hundredth_tick_timeout = 100;
|
||||
}
|
||||
|
||||
static void HandlePlacePresize()
|
||||
@@ -2175,14 +2182,14 @@ 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, max(1U, w->nested_root->resize_x));
|
||||
if (new_bottom >= (int)_cur_resolution.height) delta_y -= Ceil(new_bottom - _cur_resolution.height, max(1U, w->nested_root->resize_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));
|
||||
}
|
||||
|
||||
w->SetDirtyAsBlocks();
|
||||
|
||||
uint new_xinc = max(0, (w->nested_root->resize_x == 0) ? 0 : (int)(w->nested_root->current_x - w->nested_root->smallest_x) + delta_x);
|
||||
uint new_yinc = max(0, (w->nested_root->resize_y == 0) ? 0 : (int)(w->nested_root->current_y - w->nested_root->smallest_y) + delta_y);
|
||||
uint new_xinc = std::max(0, (w->nested_root->resize_x == 0) ? 0 : (int)(w->nested_root->current_x - w->nested_root->smallest_x) + delta_x);
|
||||
uint new_yinc = std::max(0, (w->nested_root->resize_y == 0) ? 0 : (int)(w->nested_root->current_y - w->nested_root->smallest_y) + delta_y);
|
||||
assert(w->nested_root->resize_x == 0 || new_xinc % w->nested_root->resize_x == 0);
|
||||
assert(w->nested_root->resize_y == 0 || new_yinc % w->nested_root->resize_y == 0);
|
||||
|
||||
@@ -2466,8 +2473,8 @@ static void HandleScrollbarScrolling(Window *w)
|
||||
}
|
||||
|
||||
/* Find the item we want to move to and make sure it's inside bounds. */
|
||||
int pos = min(RoundDivSU(max(0, i + _scrollbar_start_pos) * sb->GetCount(), _scrollbar_size), max(0, sb->GetCount() - sb->GetCapacity()));
|
||||
if (rtl) pos = max(0, sb->GetCount() - sb->GetCapacity() - pos);
|
||||
int pos = std::min(RoundDivSU(std::max(0, i + _scrollbar_start_pos) * sb->GetCount(), _scrollbar_size), std::max(0, sb->GetCount() - sb->GetCapacity()));
|
||||
if (rtl) pos = std::max(0, sb->GetCount() - sb->GetCapacity() - pos);
|
||||
if (pos != sb->GetPosition()) {
|
||||
sb->SetPosition(pos);
|
||||
w->SetDirty();
|
||||
@@ -3216,9 +3223,15 @@ void UpdateWindows()
|
||||
NetworkChatMessageLoop();
|
||||
}
|
||||
|
||||
_window_update_number++;
|
||||
|
||||
Window *w;
|
||||
|
||||
_window_update_number++;
|
||||
/* Process invalidations before anything else. */
|
||||
FOR_ALL_WINDOWS_FROM_FRONT(w) {
|
||||
w->ProcessScheduledInvalidations();
|
||||
w->ProcessHighlightedInvalidations();
|
||||
}
|
||||
|
||||
static GUITimer window_timer = GUITimer(1);
|
||||
if (window_timer.Elapsed(delta_ms)) {
|
||||
@@ -3241,24 +3254,10 @@ void UpdateWindows()
|
||||
|
||||
if (!_pause_mode || _game_mode == GM_EDITOR || _settings_game.construction.command_pause_level > CMDPL_NO_CONSTRUCTION) MoveAllTextEffects(delta_ms);
|
||||
|
||||
FOR_ALL_WINDOWS_FROM_FRONT(w) {
|
||||
w->ProcessScheduledInvalidations();
|
||||
w->ProcessHighlightedInvalidations();
|
||||
}
|
||||
|
||||
/* Skip the actual drawing on dedicated servers without screen.
|
||||
* But still empty the invalidation queues above. */
|
||||
if (_network_dedicated) return;
|
||||
|
||||
static GUITimer hundredth_timer = GUITimer(1);
|
||||
if (hundredth_timer.Elapsed(delta_ms)) {
|
||||
hundredth_timer.SetInterval(3000); // Historical reason: 100 * MILLISECONDS_PER_TICK
|
||||
|
||||
FOR_ALL_WINDOWS_FROM_FRONT(w) {
|
||||
w->OnHundredthTick();
|
||||
}
|
||||
}
|
||||
|
||||
if (window_timer.HasElapsed()) {
|
||||
window_timer.SetInterval(MILLISECONDS_PER_TICK);
|
||||
|
||||
@@ -3651,7 +3650,7 @@ void RelocateAllWindows(int neww, int newh)
|
||||
continue;
|
||||
|
||||
case WC_MAIN_TOOLBAR:
|
||||
ResizeWindow(w, min(neww, _toolbar_width) - w->width, 0, false);
|
||||
ResizeWindow(w, std::min<uint>(neww, _toolbar_width) - w->width, 0, false);
|
||||
|
||||
top = w->top;
|
||||
left = PositionMainToolbar(w); // changes toolbar orientation
|
||||
@@ -3663,14 +3662,14 @@ void RelocateAllWindows(int neww, int newh)
|
||||
break;
|
||||
|
||||
case WC_STATUS_BAR:
|
||||
ResizeWindow(w, min(neww, _toolbar_width) - w->width, 0, false);
|
||||
ResizeWindow(w, std::min<uint>(neww, _toolbar_width) - w->width, 0, false);
|
||||
|
||||
top = newh - w->height;
|
||||
left = PositionStatusbar(w);
|
||||
break;
|
||||
|
||||
case WC_SEND_NETWORK_MSG:
|
||||
ResizeWindow(w, min(neww, _toolbar_width) - w->width, 0, false);
|
||||
ResizeWindow(w, std::min<uint>(neww, _toolbar_width) - w->width, 0, false);
|
||||
|
||||
top = newh - w->height - FindWindowById(WC_STATUS_BAR, 0)->height;
|
||||
left = PositionNetworkChatWindow(w);
|
||||
|
Reference in New Issue
Block a user