forked from Mirrorlandia_minetest/minetest
master #6
@ -5350,6 +5350,12 @@ Utilities
|
|||||||
-- HUD Scaling multiplier
|
-- HUD Scaling multiplier
|
||||||
-- Equal to the setting `hud_scaling` multiplied by `dpi / 96`
|
-- Equal to the setting `hud_scaling` multiplied by `dpi / 96`
|
||||||
real_hud_scaling = 1,
|
real_hud_scaling = 1,
|
||||||
|
|
||||||
|
-- Whether the touchscreen controls are enabled.
|
||||||
|
-- Usually (but not always) `true` on Android.
|
||||||
|
-- Requires at least Minetest 5.9.0 on the client. For older clients, it
|
||||||
|
-- is always set to `false`.
|
||||||
|
touch_controls = false,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -249,6 +249,10 @@ GUI
|
|||||||
-- HUD Scaling multiplier
|
-- HUD Scaling multiplier
|
||||||
-- Equal to the setting `hud_scaling` multiplied by `dpi / 96`
|
-- Equal to the setting `hud_scaling` multiplied by `dpi / 96`
|
||||||
real_hud_scaling = 1,
|
real_hud_scaling = 1,
|
||||||
|
|
||||||
|
-- Whether the touchscreen controls are enabled.
|
||||||
|
-- Usually (but not always) `true` on Android.
|
||||||
|
touch_controls = false,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -7,6 +7,8 @@ local function show_fullscreen_fs(name)
|
|||||||
print(dump(window))
|
print(dump(window))
|
||||||
|
|
||||||
local size = { x = window.max_formspec_size.x * 1.1, y = window.max_formspec_size.y * 1.1 }
|
local size = { x = window.max_formspec_size.x * 1.1, y = window.max_formspec_size.y * 1.1 }
|
||||||
|
local touch_text = window.touch_controls and "Touch controls enabled" or
|
||||||
|
"Touch controls disabled"
|
||||||
local fs = {
|
local fs = {
|
||||||
"formspec_version[4]",
|
"formspec_version[4]",
|
||||||
("size[%f,%f]"):format(size.x, size.y),
|
("size[%f,%f]"):format(size.x, size.y),
|
||||||
@ -16,7 +18,8 @@ local function show_fullscreen_fs(name)
|
|||||||
("button[%f,%f;1,1;%s;%s]"):format(size.x - 1, size.y - 1, "br", "BR"),
|
("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"),
|
("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")
|
("label[%f,%f;%s]"):format(size.x / 2, size.y / 2, "Fullscreen"),
|
||||||
|
("label[%f,%f;%s]"):format(size.x / 2, size.y / 2 + 1, touch_text),
|
||||||
}
|
}
|
||||||
|
|
||||||
minetest.show_formspec(name, "testfullscreenfs:fs", table.concat(fs))
|
minetest.show_formspec(name, "testfullscreenfs:fs", table.concat(fs))
|
||||||
|
@ -1439,6 +1439,7 @@ void Client::sendUpdateClientInfo(const ClientDynamicInfo& info)
|
|||||||
pkt << info.real_gui_scaling;
|
pkt << info.real_gui_scaling;
|
||||||
pkt << info.real_hud_scaling;
|
pkt << info.real_hud_scaling;
|
||||||
pkt << (f32)info.max_fs_size.X << (f32)info.max_fs_size.Y;
|
pkt << (f32)info.max_fs_size.X << (f32)info.max_fs_size.Y;
|
||||||
|
pkt << info.touch_controls;
|
||||||
|
|
||||||
Send(&pkt);
|
Send(&pkt);
|
||||||
}
|
}
|
||||||
|
@ -33,11 +33,13 @@ public:
|
|||||||
f32 real_gui_scaling;
|
f32 real_gui_scaling;
|
||||||
f32 real_hud_scaling;
|
f32 real_hud_scaling;
|
||||||
v2f32 max_fs_size;
|
v2f32 max_fs_size;
|
||||||
|
bool touch_controls;
|
||||||
|
|
||||||
bool equal(const ClientDynamicInfo &other) const {
|
bool equal(const ClientDynamicInfo &other) const {
|
||||||
return render_target_size == other.render_target_size &&
|
return render_target_size == other.render_target_size &&
|
||||||
abs(real_gui_scaling - other.real_gui_scaling) < 0.001f &&
|
abs(real_gui_scaling - other.real_gui_scaling) < 0.001f &&
|
||||||
abs(real_hud_scaling - other.real_hud_scaling) < 0.001f;
|
abs(real_hud_scaling - other.real_hud_scaling) < 0.001f &&
|
||||||
|
touch_controls == other.touch_controls;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef SERVER
|
#ifndef SERVER
|
||||||
@ -48,10 +50,16 @@ public:
|
|||||||
f32 hud_scaling = g_settings->getFloat("hud_scaling", 0.5f, 20.0f);
|
f32 hud_scaling = g_settings->getFloat("hud_scaling", 0.5f, 20.0f);
|
||||||
f32 real_gui_scaling = gui_scaling * density;
|
f32 real_gui_scaling = gui_scaling * density;
|
||||||
f32 real_hud_scaling = hud_scaling * density;
|
f32 real_hud_scaling = hud_scaling * density;
|
||||||
|
#ifdef HAVE_TOUCHSCREENGUI
|
||||||
|
bool touch_controls = true;
|
||||||
|
#else
|
||||||
|
bool touch_controls = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
return {
|
return {
|
||||||
screen_size, real_gui_scaling, real_hud_scaling,
|
screen_size, real_gui_scaling, real_hud_scaling,
|
||||||
ClientDynamicInfo::calculateMaxFSSize(screen_size, gui_scaling)
|
ClientDynamicInfo::calculateMaxFSSize(screen_size, gui_scaling),
|
||||||
|
touch_controls
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1873,6 +1873,12 @@ void Server::handleCommand_UpdateClientInfo(NetworkPacket *pkt)
|
|||||||
*pkt >> info.real_hud_scaling;
|
*pkt >> info.real_hud_scaling;
|
||||||
*pkt >> info.max_fs_size.X;
|
*pkt >> info.max_fs_size.X;
|
||||||
*pkt >> info.max_fs_size.Y;
|
*pkt >> info.max_fs_size.Y;
|
||||||
|
try {
|
||||||
|
// added in 5.9.0
|
||||||
|
*pkt >> info.touch_controls;
|
||||||
|
} catch (PacketError &e) {
|
||||||
|
info.touch_controls = false;
|
||||||
|
}
|
||||||
|
|
||||||
session_t peer_id = pkt->getPeerId();
|
session_t peer_id = pkt->getPeerId();
|
||||||
RemoteClient *client = getClient(peer_id, CS_Invalid);
|
RemoteClient *client = getClient(peer_id, CS_Invalid);
|
||||||
|
@ -946,6 +946,10 @@ int ModApiMainMenu::l_get_window_info(lua_State *L)
|
|||||||
lua_pushnumber(L, info.real_hud_scaling);
|
lua_pushnumber(L, info.real_hud_scaling);
|
||||||
lua_settable(L, top);
|
lua_settable(L, top);
|
||||||
|
|
||||||
|
lua_pushstring(L, "touch_controls");
|
||||||
|
lua_pushboolean(L, info.touch_controls);
|
||||||
|
lua_settable(L, top);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,6 +317,11 @@ int ModApiServer::l_get_player_window_information(lua_State *L)
|
|||||||
lua_pushstring(L, "real_hud_scaling");
|
lua_pushstring(L, "real_hud_scaling");
|
||||||
lua_pushnumber(L, dynamic->real_hud_scaling);
|
lua_pushnumber(L, dynamic->real_hud_scaling);
|
||||||
lua_settable(L, dyn_table);
|
lua_settable(L, dyn_table);
|
||||||
|
|
||||||
|
lua_pushstring(L, "touch_controls");
|
||||||
|
lua_pushboolean(L, dynamic->touch_controls);
|
||||||
|
lua_settable(L, dyn_table);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user