-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add minetest.get_player_window_information() (#12367)
- Loading branch information
1 parent
fbbdae9
commit 39f4d26
Showing
23 changed files
with
345 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
name = testfullscreenfs | ||
description = Test mod to use minetest.get_player_window_information() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
Minetest | ||
Copyright (C) 2022-3 rubenwardy <[email protected]> | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU Lesser General Public License as published by | ||
the Free Software Foundation; either version 2.1 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public License along | ||
with this program; if not, write to the Free Software Foundation, Inc., | ||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "irrTypes.h" | ||
|
||
|
||
struct ClientDynamicInfo | ||
{ | ||
v2u32 render_target_size; | ||
f32 real_gui_scaling; | ||
f32 real_hud_scaling; | ||
v2f32 max_fs_size; | ||
|
||
bool equal(const ClientDynamicInfo &other) const { | ||
return render_target_size == other.render_target_size && | ||
abs(real_gui_scaling - other.real_gui_scaling) < 0.001f && | ||
abs(real_hud_scaling - other.real_hud_scaling) < 0.001f; | ||
} | ||
|
||
static v2f32 calculateMaxFSSize(v2u32 render_target_size) { | ||
f32 factor = | ||
#ifdef HAVE_TOUCHSCREENGUI | ||
10; | ||
#else | ||
15; | ||
#endif | ||
f32 ratio = (f32)render_target_size.X / (f32)render_target_size.Y; | ||
if (ratio < 1) | ||
return { factor, factor / ratio }; | ||
else | ||
return { factor * ratio, factor }; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.