I was investigating how I could make use of minetest.get_player_window_information, but I'm running into something that I think is a bug. The max_formspec_size y value always returns exactly 15 even after changing the game window size. It's always a whole number, no decimal places. The x value does change and has decimal places. I normally run Minetest via an appimage, so I downloaded the flatpak version just to test and it's the same result. Also tried Minetest 5.7 and 5.8.
Is anyone else able to reproduce this? If this is a bug, could someone who has a Github account report it?
[Solved] Bug with max_formspec_size?
[Solved] Bug with max_formspec_size?
Last edited by isaiah658 on Tue Aug 06, 2024 01:21, edited 1 time in total.
Re: Bug with max_formspec_size?
This is not a bug. Formspec coordinates are automatically scaled according to the window size. Roughly speaking, the coordinate size is the width or height of the window (whichever is smaller) divided by 15 on desktop or 10 on mobile. If you resize the window such that the width is smaller than the height, you should see that the X value stays at 15 while the Y value changes.
There area a few other calculations taken into account, such as the padding of the formspec, but that's the general gist.
There area a few other calculations taken into account, such as the padding of the formspec, but that's the general gist.
Re: Bug with max_formspec_size?
Thank you! That seems to be correct. I was able to get values over 15 for y.
I think my confusion was because I was trying to use these values for a formspec that is a fixed size. My mod has a few formspecs that need precise placement for fonts and sizing for fonts. I've been using fixed sized formspecs along with scaling the font size. Players have control over the size of the formspec. My plan is to utilize the new screen info to automatically scale the formspec to an appropriate size and eliminate the need for the player to choose the size.
I think my confusion was because I was trying to use these values for a formspec that is a fixed size. My mod has a few formspecs that need precise placement for fonts and sizing for fonts. I've been using fixed sized formspecs along with scaling the font size. Players have control over the size of the formspec. My plan is to utilize the new screen info to automatically scale the formspec to an appropriate size and eliminate the need for the player to choose the size.
Re: [Solved] Bug with max_formspec_size?
Fixed size formspecs have a much simpler calculation: it's simply floor(0.5555 * dpi * gui_scaling). In Lua, this should be:
Code: Select all
local win = minetest.get_player_window_information(player)
local coord_size = math.floor(0.5555 * 96 * win.real_gui_scaling)
Re: [Solved] Bug with max_formspec_size?
Awesome! I'm was able to convert between the two sizes to emulate how a normal formspec resizes. There's just one more issue that maybe you would know. I might be wrong, but it appears that fixed size formspecs have a minimum padding of 800 x 600. Whenever the window size is smaller than either of those, the formspec no longer perfectly centered. Is there any way to disable this or perhaps counter the effects of this using the position formspec element? It's probably not that big of a deal as I haven't had anyone complain about it. It's about the only difference I noticed between a normal formspec.v-rob wrote: ↑Sat Aug 10, 2024 04:37Fixed size formspecs have a much simpler calculation: it's simply floor(0.5555 * dpi * gui_scaling). In Lua, this should be:
Code: Select all
local win = minetest.get_player_window_information(player) local coord_size = math.floor(0.5555 * 96 * win.real_gui_scaling)
Re: [Solved] Bug with max_formspec_size?
Unfortunately, this behavior is by design. I have absolutely zero idea why they do this, but if the window size is less than 800 x 600, fixed size formspecs pretend that the window is 800 x 600 rather than whatever the actual size is. You might be able to counteract the effects of this by reverse-calculating the correct position to pass to position[].isaiah658 wrote: ↑Sat Aug 10, 2024 16:15I might be wrong, but it appears that fixed size formspecs have a minimum padding of 800 x 600. Whenever the window size is smaller than either of those, the formspec no longer perfectly centered. Is there any way to disable this or perhaps counter the effects of this using the position formspec element?
Formspecs are so bad.
Who is online
Users browsing this forum: No registered users and 0 guests