mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-22 17:18:39 +00:00
Improve formspec scaling (#14840)
This commit is contained in:
parent
1527cdf6a4
commit
041d67ceca
11 changed files with 176 additions and 87 deletions
|
@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
|
||||
#include "settings.h"
|
||||
#include "client/renderingengine.h"
|
||||
#include "gui/guiFormSpecMenu.h"
|
||||
#include "gui/touchcontrols.h"
|
||||
|
||||
ClientDynamicInfo ClientDynamicInfo::getCurrent()
|
||||
|
@ -37,19 +38,22 @@ ClientDynamicInfo ClientDynamicInfo::getCurrent()
|
|||
|
||||
return {
|
||||
screen_size, real_gui_scaling, real_hud_scaling,
|
||||
ClientDynamicInfo::calculateMaxFSSize(screen_size, gui_scaling),
|
||||
ClientDynamicInfo::calculateMaxFSSize(screen_size, density, gui_scaling),
|
||||
touch_controls
|
||||
};
|
||||
}
|
||||
|
||||
v2f32 ClientDynamicInfo::calculateMaxFSSize(v2u32 render_target_size, f32 gui_scaling)
|
||||
v2f32 ClientDynamicInfo::calculateMaxFSSize(v2u32 render_target_size, f32 density, f32 gui_scaling)
|
||||
{
|
||||
f32 factor = (g_settings->getBool("touch_gui") ? 10 : 15) / gui_scaling;
|
||||
f32 ratio = (f32)render_target_size.X / (f32)render_target_size.Y;
|
||||
if (ratio < 1)
|
||||
return { factor, factor / ratio };
|
||||
else
|
||||
return { factor * ratio, factor };
|
||||
// must stay in sync with GUIFormSpecMenu::calculateImgsize
|
||||
|
||||
const double screen_dpi = density * 96;
|
||||
|
||||
// assume padding[0,0] since max_formspec_size is used for fullscreen formspecs
|
||||
double prefer_imgsize = GUIFormSpecMenu::getImgsize(render_target_size,
|
||||
screen_dpi, gui_scaling);
|
||||
return v2f32(render_target_size.X / prefer_imgsize,
|
||||
render_target_size.Y / prefer_imgsize);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue