mirror of
https://github.com/minetest/minetest.git
synced 2024-11-20 06:33:45 +01:00
split enable_touch to touch_controls (for touchscreen controls) and touch_gui
touch_gui provide adjustment to the interface, so it's more touch friendly Signed-off-by: David Heidelberg <david@ixit.cz>
This commit is contained in:
parent
1977517d7a
commit
3a59fabefe
@ -19,7 +19,7 @@
|
||||
|
||||
local BASE_SPACING = 0.1
|
||||
local function get_scroll_btn_width()
|
||||
return core.settings:get_bool("enable_touch") and 0.8 or 0.5
|
||||
return core.settings:get_bool("touch_gui") and 0.8 or 0.5
|
||||
end
|
||||
|
||||
local function buttonbar_formspec(self)
|
||||
|
@ -181,7 +181,7 @@ local function get_info_formspec(text)
|
||||
return table.concat({
|
||||
"formspec_version[6]",
|
||||
"size[15.75,9.5]",
|
||||
core.settings:get_bool("enable_touch") and "padding[0.01,0.01]" or "position[0.5,0.55]",
|
||||
core.settings:get_bool("touch_gui") and "padding[0.01,0.01]" or "position[0.5,0.55]",
|
||||
|
||||
"label[4,4.35;", text, "]",
|
||||
"container[0,", H - 0.8 - 0.375, "]",
|
||||
@ -212,7 +212,7 @@ local function get_formspec(dlgdata)
|
||||
local formspec = {
|
||||
"formspec_version[6]",
|
||||
"size[15.75,9.5]",
|
||||
core.settings:get_bool("enable_touch") and "padding[0.01,0.01]" or "position[0.5,0.55]",
|
||||
core.settings:get_bool("touch_gui") and "padding[0.01,0.01]" or "position[0.5,0.55]",
|
||||
|
||||
"style[status,downloading,queued;border=false]",
|
||||
|
||||
@ -463,7 +463,7 @@ end
|
||||
local function handle_events(event)
|
||||
if event == "DialogShow" then
|
||||
-- On touchscreen, don't show the "MINETEST" header behind the dialog.
|
||||
mm_game_theme.set_engine(core.settings:get_bool("enable_touch"))
|
||||
mm_game_theme.set_engine(core.settings:get_bool("touch_gui"))
|
||||
|
||||
-- If ContentDB is already loaded, auto-install packages here.
|
||||
do_auto_install()
|
||||
|
@ -22,13 +22,13 @@ end
|
||||
|
||||
|
||||
local function get_loading_formspec()
|
||||
local ENABLE_TOUCH = core.settings:get_bool("enable_touch")
|
||||
local w = ENABLE_TOUCH and 14 or 7
|
||||
local TOUCH_GUI = core.settings:get_bool("touch_gui")
|
||||
local w = TOUCH_GUI and 14 or 7
|
||||
|
||||
local formspec = {
|
||||
"formspec_version[3]",
|
||||
"size[", w, ",9.05]",
|
||||
ENABLE_TOUCH and "padding[0.01,0.01]" or "position[0.5,0.55]",
|
||||
TOUCH_GUI and "padding[0.01,0.01]" or "position[0.5,0.55]",
|
||||
"label[3,4.525;", fgettext("Loading..."), "]",
|
||||
}
|
||||
return table.concat(formspec)
|
||||
@ -110,18 +110,18 @@ local function get_formspec(data)
|
||||
message_bg = mt_color_orange
|
||||
end
|
||||
|
||||
local ENABLE_TOUCH = core.settings:get_bool("enable_touch")
|
||||
local TOUCH_GUI = core.settings:get_bool("touch_gui")
|
||||
|
||||
local w = ENABLE_TOUCH and 14 or 7
|
||||
local w = TOUCH_GUI and 14 or 7
|
||||
local padded_w = w - 2*0.375
|
||||
local dropdown_w = ENABLE_TOUCH and 10.2 or 4.25
|
||||
local dropdown_w = TOUCH_GUI and 10.2 or 4.25
|
||||
local button_w = (padded_w - 0.25) / 3
|
||||
local button_pad = button_w / 2
|
||||
|
||||
local formspec = {
|
||||
"formspec_version[3]",
|
||||
"size[", w, ",9.05]",
|
||||
ENABLE_TOUCH and "padding[0.01,0.01]" or "position[0.5,0.55]",
|
||||
TOUCH_GUI and "padding[0.01,0.01]" or "position[0.5,0.55]",
|
||||
"style[title;border=false]",
|
||||
"box[0,0;", w, ",0.8;#3333]",
|
||||
"button[0,0;", w, ",0.8;title;", fgettext("Install $1", package.title) , "]",
|
||||
|
@ -110,7 +110,7 @@ local function load()
|
||||
local change_keys = {
|
||||
query_text = "Controls",
|
||||
requires = {
|
||||
keyboard_mouse = true,
|
||||
touch_controls = false,
|
||||
},
|
||||
get_formspec = function(self, avail_w)
|
||||
local btn_w = math.min(avail_w, 3)
|
||||
@ -324,8 +324,6 @@ local function check_requirements(name, requires)
|
||||
local special = {
|
||||
android = PLATFORM == "Android",
|
||||
desktop = PLATFORM ~= "Android",
|
||||
touchscreen_gui = core.settings:get_bool("enable_touch"),
|
||||
keyboard_mouse = not core.settings:get_bool("enable_touch"),
|
||||
shaders_support = shaders_support,
|
||||
shaders = core.settings:get_bool("enable_shaders") and shaders_support,
|
||||
opengl = video_driver == "opengl",
|
||||
@ -457,13 +455,13 @@ local function get_formspec(dialogdata)
|
||||
|
||||
local extra_h = 1 -- not included in tabsize.height
|
||||
local tabsize = {
|
||||
width = core.settings:get_bool("enable_touch") and 16.5 or 15.5,
|
||||
height = core.settings:get_bool("enable_touch") and (10 - extra_h) or 12,
|
||||
width = core.settings:get_bool("touch_gui") and 16.5 or 15.5,
|
||||
height = core.settings:get_bool("touch_gui") and (10 - extra_h) or 12,
|
||||
}
|
||||
|
||||
local scrollbar_w = core.settings:get_bool("enable_touch") and 0.6 or 0.4
|
||||
local scrollbar_w = core.settings:get_bool("touch_gui") and 0.6 or 0.4
|
||||
|
||||
local left_pane_width = core.settings:get_bool("enable_touch") and 4.5 or 4.25
|
||||
local left_pane_width = core.settings:get_bool("touch_gui") and 4.5 or 4.25
|
||||
local left_pane_padding = 0.25
|
||||
local search_width = left_pane_width + scrollbar_w - (0.75 * 2)
|
||||
|
||||
@ -477,7 +475,7 @@ local function get_formspec(dialogdata)
|
||||
local fs = {
|
||||
"formspec_version[6]",
|
||||
"size[", tostring(tabsize.width), ",", tostring(tabsize.height + extra_h), "]",
|
||||
core.settings:get_bool("enable_touch") and "padding[0.01,0.01]" or "",
|
||||
core.settings:get_bool("touch_gui") and "padding[0.01,0.01]" or "",
|
||||
"bgcolor[#0000]",
|
||||
|
||||
-- HACK: this is needed to allow resubmitting the same formspec
|
||||
@ -652,15 +650,15 @@ local function buttonhandler(this, fields)
|
||||
write_settings_early()
|
||||
end
|
||||
|
||||
-- enable_touch is a checkbox in a setting component. We handle this
|
||||
-- touch_controls is a checkbox in a setting component. We handle this
|
||||
-- setting differently so we can hide/show pages using the next if-statement
|
||||
if fields.enable_touch ~= nil then
|
||||
local value = core.is_yes(fields.enable_touch)
|
||||
core.settings:set_bool("enable_touch", value)
|
||||
if fields.touch_controls ~= nil then
|
||||
local value = core.is_yes(fields.touch_controls)
|
||||
core.settings:set_bool("touch_controls", value)
|
||||
write_settings_early()
|
||||
end
|
||||
|
||||
if fields.show_advanced ~= nil or fields.enable_touch ~= nil then
|
||||
if fields.show_advanced ~= nil or fields.touch_controls ~= nil then
|
||||
local suggested_page_id = update_filtered_pages(dialogdata.query)
|
||||
|
||||
dialogdata.components = nil
|
||||
|
@ -94,7 +94,7 @@ function singleplayer_refresh_gamebar()
|
||||
|
||||
local btnbar = buttonbar_create(
|
||||
"game_button_bar",
|
||||
core.settings:get_bool("enable_touch") and {x = 0, y = 7.25} or {x = 0, y = 7.475},
|
||||
core.settings:get_bool("touch_gui") and {x = 0, y = 7.25} or {x = 0, y = 7.475},
|
||||
{x = 15.5, y = 1.25},
|
||||
"#000000",
|
||||
game_buttonbar_button_handler)
|
||||
|
@ -61,7 +61,7 @@
|
||||
#
|
||||
# # This is a comment
|
||||
# #
|
||||
# # Requires: shaders, enable_dynamic_shadows, !touchscreen_gui
|
||||
# # Requires: shaders, enable_dynamic_shadows, !touch_controls
|
||||
# name (Readable name) type type_args
|
||||
#
|
||||
# A requirement can be the name of a boolean setting or an engine-defined value.
|
||||
@ -72,7 +72,6 @@
|
||||
# * shaders_support (a video driver that supports shaders, may not be enabled)
|
||||
# * shaders (both enable_shaders and shaders_support)
|
||||
# * desktop / android
|
||||
# * touchscreen_gui / keyboard_mouse
|
||||
# * opengl / gles
|
||||
# * You can negate any requirement by prepending with !
|
||||
#
|
||||
@ -92,7 +91,7 @@ camera_smoothing (Camera smoothing) float 0.0 0.0 0.99
|
||||
|
||||
# Smooths rotation of camera when in cinematic mode, 0 to disable. Enter cinematic mode by using the key set in Controls.
|
||||
#
|
||||
# Requires: keyboard_mouse
|
||||
# Requires: !touch_controls
|
||||
cinematic_camera_smoothing (Camera smoothing in cinematic mode) float 0.7 0.0 0.99
|
||||
|
||||
# If enabled, you can place nodes at the position (feet + eye level) where you stand.
|
||||
@ -113,7 +112,7 @@ always_fly_fast (Always fly fast) bool true
|
||||
# The time in seconds it takes between repeated node placements when holding
|
||||
# the place button.
|
||||
#
|
||||
# Requires: keyboard_mouse
|
||||
# Requires: !touch_controls
|
||||
repeat_place_time (Place repetition interval) float 0.25 0.16 2.0
|
||||
|
||||
# The minimum time in seconds it takes between digging nodes when holding
|
||||
@ -132,62 +131,62 @@ safe_dig_and_place (Safe digging and placing) bool false
|
||||
|
||||
# Invert vertical mouse movement.
|
||||
#
|
||||
# Requires: keyboard_mouse
|
||||
# Requires: !touch_controls
|
||||
invert_mouse (Invert mouse) bool false
|
||||
|
||||
# Mouse sensitivity multiplier.
|
||||
#
|
||||
# Requires: keyboard_mouse
|
||||
# Requires: !touch_controls
|
||||
mouse_sensitivity (Mouse sensitivity) float 0.2 0.001 10.0
|
||||
|
||||
# Enable mouse wheel (scroll) for item selection in hotbar.
|
||||
#
|
||||
# Requires: keyboard_mouse
|
||||
# Requires: !touch_controls
|
||||
enable_hotbar_mouse_wheel (Hotbar: Enable mouse wheel for selection) bool true
|
||||
|
||||
# Invert mouse wheel (scroll) direction for item selection in hotbar.
|
||||
#
|
||||
# Requires: keyboard_mouse
|
||||
# Requires: !touch_controls
|
||||
invert_hotbar_mouse_wheel (Hotbar: Invert mouse wheel direction) bool false
|
||||
|
||||
[*Touchscreen]
|
||||
|
||||
# Enables touchscreen mode, allowing you to play the game with a touchscreen.
|
||||
# Enables the touchscreen controls, allowing you to play the game with a touchscreen.
|
||||
#
|
||||
# Requires: !android
|
||||
enable_touch (Enable touchscreen) bool true
|
||||
touch_controls (Enable touchscreen controls) bool true
|
||||
|
||||
# Touchscreen sensitivity multiplier.
|
||||
#
|
||||
# Requires: touchscreen_gui
|
||||
# Requires: touch_controls
|
||||
touchscreen_sensitivity (Touchscreen sensitivity) float 0.2 0.001 10.0
|
||||
|
||||
# The length in pixels after which a touch interaction is considered movement.
|
||||
#
|
||||
# Requires: touchscreen_gui
|
||||
# Requires: touch_controls
|
||||
touchscreen_threshold (Movement threshold) int 20 0 100
|
||||
|
||||
# The delay in milliseconds after which a touch interaction is considered a long tap.
|
||||
#
|
||||
# Requires: touchscreen_gui
|
||||
# Requires: touch_controls
|
||||
touch_long_tap_delay (Threshold for long taps) int 400 100 1000
|
||||
|
||||
# Use crosshair to select object instead of whole screen.
|
||||
# If enabled, a crosshair will be shown and will be used for selecting object.
|
||||
#
|
||||
# Requires: touchscreen_gui
|
||||
# Requires: touch_controls
|
||||
touch_use_crosshair (Use crosshair for touch screen) bool false
|
||||
|
||||
# Fixes the position of virtual joystick.
|
||||
# If disabled, virtual joystick will center to first-touch's position.
|
||||
#
|
||||
# Requires: touchscreen_gui
|
||||
# Requires: touch_controls
|
||||
fixed_virtual_joystick (Fixed virtual joystick) bool false
|
||||
|
||||
# Use virtual joystick to trigger "Aux1" button.
|
||||
# If enabled, virtual joystick will also tap "Aux1" button when out of main circle.
|
||||
#
|
||||
# Requires: touchscreen_gui
|
||||
# Requires: touch_controls
|
||||
virtual_joystick_triggers_aux1 (Virtual joystick triggers Aux1 button) bool false
|
||||
|
||||
# The gesture for punching players/entities.
|
||||
@ -200,7 +199,7 @@ virtual_joystick_triggers_aux1 (Virtual joystick triggers Aux1 button) bool fals
|
||||
# Known from the classic Minetest mobile controls.
|
||||
# Combat is more or less impossible.
|
||||
#
|
||||
# Requires: touchscreen_gui
|
||||
# Requires: touch_controls
|
||||
touch_punch_gesture (Punch gesture) enum short_tap short_tap,long_tap
|
||||
|
||||
|
||||
@ -687,6 +686,10 @@ language (Language) enum ,be,bg,ca,cs,da,de,el,en,eo,es,et,eu,fi,fr,gd,gl,hu,i
|
||||
|
||||
[**GUI]
|
||||
|
||||
# When enabled, the GUI is optimized to be more usable on touchscreens.
|
||||
# Whether this is enabled by default depends on your hardware form-factor.
|
||||
touch_gui (Optimize GUI for touchscreens) bool false
|
||||
|
||||
# Scale GUI by a user specified value.
|
||||
# Use a nearest-neighbor-anti-alias filter to scale the GUI.
|
||||
# This will smooth over some of the rough edges, and blend
|
||||
|
@ -1578,7 +1578,7 @@ bool Game::initGui()
|
||||
gui_chat_console = new GUIChatConsole(guienv, guienv->getRootGUIElement(),
|
||||
-1, chat_backend, client, &g_menumgr);
|
||||
|
||||
if (g_settings->getBool("enable_touch"))
|
||||
if (g_settings->getBool("touch_controls"))
|
||||
g_touchcontrols = new TouchControls(device, texture_src);
|
||||
|
||||
return true;
|
||||
|
@ -44,7 +44,7 @@ ClientDynamicInfo ClientDynamicInfo::getCurrent()
|
||||
|
||||
v2f32 ClientDynamicInfo::calculateMaxFSSize(v2u32 render_target_size, f32 gui_scaling)
|
||||
{
|
||||
f32 factor = (g_settings->getBool("enable_touch") ? 10 : 15) / gui_scaling;
|
||||
f32 factor = (g_settings->getBool("touch_gui") ? 10 : 15) / gui_scaling;
|
||||
f32 ratio = (f32)render_target_size.X / (f32)render_target_size.Y;
|
||||
if (ratio < 1)
|
||||
return { factor, factor / ratio };
|
||||
|
@ -97,7 +97,8 @@ void set_default_settings()
|
||||
// Client
|
||||
settings->setDefault("address", "");
|
||||
settings->setDefault("enable_sound", "true");
|
||||
settings->setDefault("enable_touch", bool_to_cstr(has_touch));
|
||||
settings->setDefault("touch_controls", bool_to_cstr(has_touch));
|
||||
settings->setDefault("touch_gui", bool_to_cstr(has_touch));
|
||||
settings->setDefault("sound_volume", "0.8");
|
||||
settings->setDefault("sound_volume_unfocused", "0.3");
|
||||
settings->setDefault("mute_sound", "false");
|
||||
|
@ -315,7 +315,7 @@ void GUIFormSpecMenu::parseSize(parserData* data, const std::string &element)
|
||||
data->invsize.Y = MYMAX(0, stof(parts[1]));
|
||||
|
||||
lockSize(false);
|
||||
if (!g_settings->getBool("enable_touch") && parts.size() == 3) {
|
||||
if (!g_settings->getBool("touch_gui") && parts.size() == 3) {
|
||||
if (parts[2] == "true") {
|
||||
lockSize(true,v2u32(800,600));
|
||||
}
|
||||
@ -3166,7 +3166,7 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
|
||||
s32 min_screen_dim = std::min(padded_screensize.X, padded_screensize.Y);
|
||||
|
||||
double prefer_imgsize;
|
||||
if (g_settings->getBool("enable_touch")) {
|
||||
if (g_settings->getBool("touch_gui")) {
|
||||
// The preferred imgsize should be larger to accommodate the
|
||||
// smaller screensize.
|
||||
prefer_imgsize = min_screen_dim / 10 * gui_scaling;
|
||||
|
@ -11,4 +11,12 @@ void migrate_settings()
|
||||
g_settings->getBool("opaque_water") ? "false" : "true");
|
||||
g_settings->remove("opaque_water");
|
||||
}
|
||||
|
||||
// Converts enable_touch to touch_controls/touch_gui
|
||||
if (g_settings->existsLocal("enable_touch")) {
|
||||
bool value = g_settings->getBool("enable_touch");
|
||||
g_settings->setBool("touch_controls", value);
|
||||
g_settings->setBool("touch_gui", value);
|
||||
g_settings->remove("enable_touch");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user