diff options
author | Michael Lutz <michi@icosahedron.de> | 2021-01-08 22:15:06 +0100 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2021-02-14 14:16:40 +0100 |
commit | 22f5aeab07cb1c67561b9e348e2c944740233607 (patch) | |
tree | 0dbb0edbf02962e297e7d99e6d96b14ee570333b /src/gfx.cpp | |
parent | a2c3197f424daa6e02201d8304015b0eb67d0b04 (diff) | |
download | openttd-22f5aeab07cb1c67561b9e348e2c944740233607.tar.xz |
Feature: Automatic UI and font zoom levels when supported by the OS.
Diffstat (limited to 'src/gfx.cpp')
-rw-r--r-- | src/gfx.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/gfx.cpp b/src/gfx.cpp index 54851d375..786bbb25b 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -59,6 +59,10 @@ static ReusableBuffer<uint8> _cursor_backup; ZoomLevel _gui_zoom; ///< GUI Zoom level ZoomLevel _font_zoom; ///< Font Zoom level +int8 _gui_zoom_cfg; ///< GUI zoom level in config. +int8 _font_zoom_cfg; ///< Font zoom level in config. + + /** * The rect for repaint. * @@ -1876,3 +1880,23 @@ void SortResolutions() { std::sort(_resolutions.begin(), _resolutions.end()); } + +/** + * Resolve GUI zoom level, if auto-suggestion is requested. + */ +void UpdateGUIZoom() +{ + /* Determine real GUI zoom to use. */ + if (_gui_zoom_cfg == ZOOM_LVL_CFG_AUTO) { + _gui_zoom = static_cast<ZoomLevel>(Clamp(VideoDriver::GetInstance()->GetSuggestedUIZoom(), _settings_client.gui.zoom_min, _settings_client.gui.zoom_max)); + } else { + _gui_zoom = static_cast<ZoomLevel>(_gui_zoom_cfg); + } + + /* Determine real font zoom to use. */ + if (_font_zoom_cfg == ZOOM_LVL_CFG_AUTO) { + _font_zoom = static_cast<ZoomLevel>(VideoDriver::GetInstance()->GetSuggestedUIZoom()); + } else { + _font_zoom = static_cast<ZoomLevel>(_font_zoom_cfg); + } +} |