From 39f4d26177ec1c8f246133c532a42ef7429bc36d Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Mon, 27 Feb 2023 22:58:41 +0000 Subject: Add minetest.get_player_window_information() (#12367) --- games/devtest/mods/testfullscreenfs/init.lua | 29 ++++++++++++++++++++++++++++ games/devtest/mods/testfullscreenfs/mod.conf | 2 ++ 2 files changed, 31 insertions(+) create mode 100644 games/devtest/mods/testfullscreenfs/init.lua create mode 100644 games/devtest/mods/testfullscreenfs/mod.conf (limited to 'games/devtest') diff --git a/games/devtest/mods/testfullscreenfs/init.lua b/games/devtest/mods/testfullscreenfs/init.lua new file mode 100644 index 000000000..b9d20610b --- /dev/null +++ b/games/devtest/mods/testfullscreenfs/init.lua @@ -0,0 +1,29 @@ +local function show_fullscreen_fs(name) + local window = minetest.get_player_window_information(name) + if not window then + return false, "Unable to get window info" + end + + print(dump(window)) + + local size = { x = window.max_formspec_size.x * 1.1, y = window.max_formspec_size.y * 1.1 } + local fs = { + "formspec_version[4]", + ("size[%f,%f]"):format(size.x, size.y), + "padding[-0.01,-0.01]", + ("button[%f,%f;1,1;%s;%s]"):format(0, 0, "tl", "TL"), + ("button[%f,%f;1,1;%s;%s]"):format(size.x - 1, 0, "tr", "TR"), + ("button[%f,%f;1,1;%s;%s]"):format(size.x - 1, size.y - 1, "br", "BR"), + ("button[%f,%f;1,1;%s;%s]"):format(0, size.y - 1, "bl", "BL"), + + ("label[%f,%f;%s]"):format(size.x / 2, size.y / 2, "Fullscreen") + } + + minetest.show_formspec(name, "testfullscreenfs:fs", table.concat(fs)) + return true, ("Calculated size of %f, %f"):format(size.x, size.y) +end + + +minetest.register_chatcommand("testfullscreenfs", { + func = show_fullscreen_fs, +}) diff --git a/games/devtest/mods/testfullscreenfs/mod.conf b/games/devtest/mods/testfullscreenfs/mod.conf new file mode 100644 index 000000000..84dc87e95 --- /dev/null +++ b/games/devtest/mods/testfullscreenfs/mod.conf @@ -0,0 +1,2 @@ +name = testfullscreenfs +description = Test mod to use minetest.get_player_window_information() -- cgit v1.2.3