aboutsummaryrefslogtreecommitdiff
path: root/src/clientdynamicinfo.h
diff options
context:
space:
mode:
authorrubenwardy <rw@rubenwardy.com>2023-02-27 22:58:41 +0000
committerGitHub <noreply@github.com>2023-02-27 22:58:41 +0000
commit39f4d26177ec1c8f246133c532a42ef7429bc36d (patch)
tree910b6a6635adf37eaba1d7410e83fad14f15bb90 /src/clientdynamicinfo.h
parentfbbdae93ee324584089efaf8e880a1378f6a2ad6 (diff)
downloadminetest-39f4d26177ec1c8f246133c532a42ef7429bc36d.tar.xz
Add minetest.get_player_window_information() (#12367)
Diffstat (limited to 'src/clientdynamicinfo.h')
-rw-r--r--src/clientdynamicinfo.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/clientdynamicinfo.h b/src/clientdynamicinfo.h
new file mode 100644
index 000000000..ebe596400
--- /dev/null
+++ b/src/clientdynamicinfo.h
@@ -0,0 +1,51 @@
+/*
+Minetest
+Copyright (C) 2022-3 rubenwardy <rw@rubenwardy.com>
+
+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 };
+ }
+};