Merge remote-tracking branch 'upstream/master' into 13.0

This commit is contained in:
Pavel Stupnikov
2022-11-26 22:16:25 +04:00
508 changed files with 14617 additions and 9750 deletions

View File

@@ -17,10 +17,12 @@
#include "settings_type.h"
#include "network/network.h"
#include "network/network_func.h"
#include "window_gui.h"
#include "window_func.h"
#include "newgrf_debug.h"
#include "thread.h"
#include "core/backup_type.hpp"
#include "viewport_func.h"
#include "table/palettes.h"
#include "table/string_colours.h"
@@ -824,7 +826,7 @@ int DrawStringMultiLine(int left, int right, int top, int bottom, const char *st
for (const auto &line : layout) {
int line_height = line->GetLeading();
if (y >= top && y < bottom) {
if (y >= top && y + line_height - 1 <= bottom) {
last_line = y + line_height;
if (first_line > y) first_line = y;
@@ -2049,6 +2051,38 @@ void UpdateGUIZoom()
}
}
/**
* Resolve GUI zoom level and adjust GUI to new zoom, if auto-suggestion is requested.
* @returns true when the zoom level has changed, caller must call ReInitAllWindows(true)
* after resizing the application's window/buffer.
*/
bool AdjustGUIZoom()
{
auto old_zoom = _gui_zoom;
UpdateGUIZoom();
if (old_zoom == _gui_zoom) return false;
GfxClearSpriteCache();
VideoDriver::GetInstance()->ClearSystemSprites();
ClearFontCache();
GfxClearSpriteCache();
UpdateAllVirtCoords();
/* Adjust all window sizes to match the new zoom level, so that they don't appear
to move around when the application is moved to a screen with different DPI. */
auto zoom_shift = old_zoom - _gui_zoom;
for (Window *w : Window::Iterate()) {
w->left = AdjustByZoom(w->left, zoom_shift);
w->top = AdjustByZoom(w->top, zoom_shift);
w->width = AdjustByZoom(w->width, zoom_shift);
w->height = AdjustByZoom(w->height, zoom_shift);
if (w->viewport != nullptr) {
w->viewport->zoom = Clamp(ZoomLevel(w->viewport->zoom - zoom_shift), _settings_client.gui.zoom_min, _settings_client.gui.zoom_max);
}
}
return true;
}
void ChangeGameSpeed(bool enable_fast_forward)
{
if (enable_fast_forward) {