@@ -3112,42 +3112,42 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
3112
3112
// and default scaling (1.00).
3113
3113
use_imgsize = 0.5555 * screen_dpi * gui_scaling;
3114
3114
} else {
3115
- // In variable-size mode, we prefer to make the
3116
- // inventory image size 1/15 of screen height,
3117
- // multiplied by the gui_scaling config parameter.
3118
- // If the preferred size won't fit the whole
3119
- // form on the screen, either horizontally or
3120
- // vertically, then we scale it down to fit.
3121
- // (The magic numbers in the computation of what
3122
- // fits arise from the scaling factors in the
3123
- // following stanza, including the form border,
3124
- // help text space, and 0.1 inventory slot spare.)
3125
- // However, a minimum size is also set, that
3126
- // the image size can't be less than 0.3 inch
3127
- // multiplied by gui_scaling, even if this means
3128
- // the form doesn't fit the screen.
3115
+ // Variables for the maximum imgsize that can fit in the screen.
3116
+ double fitx_imgsize;
3117
+ double fity_imgsize;
3118
+
3119
+ // Pad the screensize with 5% of the screensize on all sides to ensure
3120
+ // that even the largest formspecs don't touch the screen borders.
3121
+ v2f padded_screensize (
3122
+ mydata.screensize .X * 0 .9f ,
3123
+ mydata.screensize .Y * 0 .9f
3124
+ );
3125
+
3126
+ if (mydata.real_coordinates ) {
3127
+ fitx_imgsize = padded_screensize.X / mydata.invsize .X ;
3128
+ fity_imgsize = padded_screensize.Y / mydata.invsize .Y ;
3129
+ } else {
3130
+ // The maximum imgsize in the old coordinate system also needs to
3131
+ // factor in padding and spacing along with 0.1 inventory slot spare
3132
+ // and help text space, hence the magic numbers.
3133
+ fitx_imgsize = padded_screensize.X /
3134
+ ((5.0 / 4.0 ) * (0.5 + mydata.invsize .X ));
3135
+ fity_imgsize = padded_screensize.Y /
3136
+ ((15.0 / 13.0 ) * (0.85 + mydata.invsize .Y ));
3137
+ }
3138
+
3129
3139
#ifdef __ANDROID__
3130
- // For mobile devices these magic numbers are
3131
- // different and forms should always use the
3132
- // maximum screen space available.
3133
- double prefer_imgsize = mydata.screensize .Y / 10 * gui_scaling;
3134
- double fitx_imgsize = mydata.screensize .X /
3135
- ((12.0 / 8.0 ) * (0.5 + mydata.invsize .X ));
3136
- double fity_imgsize = mydata.screensize .Y /
3137
- ((15.0 / 11.0 ) * (0.85 + mydata.invsize .Y ));
3138
- use_imgsize = MYMIN (prefer_imgsize,
3139
- MYMIN (fitx_imgsize, fity_imgsize));
3140
+ // In Android, the preferred imgsize should be larger to accommodate the
3141
+ // smaller screensize.
3142
+ double prefer_imgsize = padded_screensize.Y / 10 * gui_scaling;
3140
3143
#else
3141
- double prefer_imgsize = mydata.screensize .Y / 15 * gui_scaling;
3142
- double fitx_imgsize = mydata.screensize .X /
3143
- ((5.0 / 4.0 ) * (0.5 + mydata.invsize .X ));
3144
- double fity_imgsize = mydata.screensize .Y /
3145
- ((15.0 / 13.0 ) * (0.85 * mydata.invsize .Y ));
3146
- double screen_dpi = RenderingEngine::getDisplayDensity () * 96 ;
3147
- double min_imgsize = 0.3 * screen_dpi * gui_scaling;
3148
- use_imgsize = MYMAX (min_imgsize, MYMIN (prefer_imgsize,
3149
- MYMIN (fitx_imgsize, fity_imgsize)));
3144
+ // Desktop computers have more space, so try to fit 15 coordinates.
3145
+ double prefer_imgsize = padded_screensize.Y / 15 * gui_scaling;
3150
3146
#endif
3147
+ // Try to use the preferred imgsize, but if that's bigger than the maximum
3148
+ // size, use the maximum size.
3149
+ use_imgsize = std::min (prefer_imgsize,
3150
+ std::min (fitx_imgsize, fity_imgsize));
3151
3151
}
3152
3152
3153
3153
// Everything else is scaled in proportion to the
0 commit comments