-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add minetest.get_player_window_information() #12367
Conversation
492499c
to
95557f8
Compare
wow, what an amazingly great and awsome thing. |
Any reason to separate these?
Definitely, "you call the API and get 20 values of which you need only two" is already an issue with
Considering the above formula the fractional part of DPI will change the scale of things by less than ~0.01, so rounding to integer is safe to do.
Current enablement state of the touchscreen GUI. |
@sfan5, yes the usecase is sizing elements. with this information, it is possible to make fullscreen formspecs! I have made fullscreen formspecs in the mainmenu using this information (which passes it) , and it works pretty well. also, its possible to just make sure that elements fit well on the screen. |
Looking into it, yeah it would make sense to combine these. Raw DPI is only useful if you want to know the physical size of the screen, but this dpi value can be overridden by
This seems a bit derived to me, It's not minimized, it's the same number of numbers just a derived value rather than the raw values
The use case is knowing how much space is available so that you can 1) make a formspec fullsize 2) make the best use of space If a modder wants to make a formspec full size, then they just need the ratio to calculate a large
Makes sense, side-by-side mode means that only half of the window's width is used
guiFormspecMenu uses it as a double, which is a bit overkill. Given that we've decided to combine this into the _scaling settings, there's no need for a change here
See #12264. This should be sent as part of the ClientDynamicInfo packet, but I don't know what the Lua API should be |
A value that may be useful would be something like this: -- Max formspec size before Minetest starts scaling down, assuming
-- `fixed_size` is true in `size[]` and`padding[0,0]`.
--
-- This can be used to make fullscreen formspecs by using a padding
-- of `padding[-0.01,-0.01]` and a small inset `0.1` between the edge
-- of the formspec and the elements.
max_formspec_size = {
x = 10.3,
y = 5.4,
} |
Added a mod to devtest to test fullscreen formspecs |
This value is calculated by: local function calculate_max_fs_size(name)
local window = minetest.get_player_window_information(name)
local slot_size = 0.5555 * 96 * window.real_gui_scaling
return {
x = window.size.x / slot_size,
y = window.size.y / slot_size,
}
end This 0.5555 is taken from guiFormspecMenu.cpp: https://github.com/minetest/minetest/blob/master/src/gui/guiFormSpecMenu.cpp#L3216-L3223 This is only the case when true is provided to |
3a4afe3
to
395052b
Compare
For the API it'd be useful if this was event-driven rather than a getter (or probably both) - as a modder I prefer not to poll. |
That can come later |
@rubenwardy rebase needed |
af973ac
to
39fdfdc
Compare
This comment was marked as outdated.
This comment was marked as outdated.
81f6386
to
1611add
Compare
b334fe8
to
c63412a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works.
my test code:
local thing = {}
minetest.register_on_joinplayer(function(player)
local name = player:get_player_name()
thing[name] = {
hud = player:hud_add({
hud_elem_type = "text",
position = {x = 0.22, y = 0.22},
alignment = {x = 1, y = 0},
scale = {x = 2, y = 2},
number = 0xFFFFFF,
style = 4,
}),
text = ""
}
end)
minetest.register_on_leaveplayer(function(player)
thing[player:get_player_name()] = nil
end)
minetest.register_globalstep(function(dtime)
for _, player in ipairs(minetest.get_connected_players()) do
local name = player:get_player_name()
local c = thing[name]
if c then
local s = dump(minetest.get_player_window_information(name))
if s ~= c.text then
player:hud_change(c.hud, "text", s)
c.text = s
end
end
end
end)
\Adds a new packet to send dynamic client info to the server, and
minetest.get_player_window_information()
Fixes #10632
To do
This PR is ready for review
Resist fingerprintingHow to test
/testfullscreenfs
sidebyside
3d mode