mirror of
https://github.com/minetest/minetest.git
synced 2024-11-30 11:33:44 +01:00
Optimize formspec form size (#10144)
This commit is contained in:
parent
5bda36143f
commit
471497fa91
@ -3112,42 +3112,42 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
|
|||||||
// and default scaling (1.00).
|
// and default scaling (1.00).
|
||||||
use_imgsize = 0.5555 * screen_dpi * gui_scaling;
|
use_imgsize = 0.5555 * screen_dpi * gui_scaling;
|
||||||
} else {
|
} else {
|
||||||
// In variable-size mode, we prefer to make the
|
// Variables for the maximum imgsize that can fit in the screen.
|
||||||
// inventory image size 1/15 of screen height,
|
double fitx_imgsize;
|
||||||
// multiplied by the gui_scaling config parameter.
|
double fity_imgsize;
|
||||||
// If the preferred size won't fit the whole
|
|
||||||
// form on the screen, either horizontally or
|
// Pad the screensize with 5% of the screensize on all sides to ensure
|
||||||
// vertically, then we scale it down to fit.
|
// that even the largest formspecs don't touch the screen borders.
|
||||||
// (The magic numbers in the computation of what
|
v2f padded_screensize(
|
||||||
// fits arise from the scaling factors in the
|
mydata.screensize.X * 0.9f,
|
||||||
// following stanza, including the form border,
|
mydata.screensize.Y * 0.9f
|
||||||
// help text space, and 0.1 inventory slot spare.)
|
);
|
||||||
// However, a minimum size is also set, that
|
|
||||||
// the image size can't be less than 0.3 inch
|
if (mydata.real_coordinates) {
|
||||||
// multiplied by gui_scaling, even if this means
|
fitx_imgsize = padded_screensize.X / mydata.invsize.X;
|
||||||
// the form doesn't fit the screen.
|
fity_imgsize = padded_screensize.Y / mydata.invsize.Y;
|
||||||
#ifdef __ANDROID__
|
} else {
|
||||||
// For mobile devices these magic numbers are
|
// The maximum imgsize in the old coordinate system also needs to
|
||||||
// different and forms should always use the
|
// factor in padding and spacing along with 0.1 inventory slot spare
|
||||||
// maximum screen space available.
|
// and help text space, hence the magic numbers.
|
||||||
double prefer_imgsize = mydata.screensize.Y / 10 * gui_scaling;
|
fitx_imgsize = padded_screensize.X /
|
||||||
double fitx_imgsize = mydata.screensize.X /
|
|
||||||
((12.0 / 8.0) * (0.5 + mydata.invsize.X));
|
|
||||||
double fity_imgsize = mydata.screensize.Y /
|
|
||||||
((15.0 / 11.0) * (0.85 + mydata.invsize.Y));
|
|
||||||
use_imgsize = MYMIN(prefer_imgsize,
|
|
||||||
MYMIN(fitx_imgsize, fity_imgsize));
|
|
||||||
#else
|
|
||||||
double prefer_imgsize = mydata.screensize.Y / 15 * gui_scaling;
|
|
||||||
double fitx_imgsize = mydata.screensize.X /
|
|
||||||
((5.0 / 4.0) * (0.5 + mydata.invsize.X));
|
((5.0 / 4.0) * (0.5 + mydata.invsize.X));
|
||||||
double fity_imgsize = mydata.screensize.Y /
|
fity_imgsize = padded_screensize.Y /
|
||||||
((15.0 / 13.0) * (0.85 * mydata.invsize.Y));
|
((15.0 / 13.0) * (0.85 + mydata.invsize.Y));
|
||||||
double screen_dpi = RenderingEngine::getDisplayDensity() * 96;
|
}
|
||||||
double min_imgsize = 0.3 * screen_dpi * gui_scaling;
|
|
||||||
use_imgsize = MYMAX(min_imgsize, MYMIN(prefer_imgsize,
|
#ifdef __ANDROID__
|
||||||
MYMIN(fitx_imgsize, fity_imgsize)));
|
// In Android, the preferred imgsize should be larger to accommodate the
|
||||||
|
// smaller screensize.
|
||||||
|
double prefer_imgsize = padded_screensize.Y / 10 * gui_scaling;
|
||||||
|
#else
|
||||||
|
// Desktop computers have more space, so try to fit 15 coordinates.
|
||||||
|
double prefer_imgsize = padded_screensize.Y / 15 * gui_scaling;
|
||||||
#endif
|
#endif
|
||||||
|
// Try to use the preferred imgsize, but if that's bigger than the maximum
|
||||||
|
// size, use the maximum size.
|
||||||
|
use_imgsize = std::min(prefer_imgsize,
|
||||||
|
std::min(fitx_imgsize, fity_imgsize));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Everything else is scaled in proportion to the
|
// Everything else is scaled in proportion to the
|
||||||
|
Loading…
Reference in New Issue
Block a user