Improve the path select GUI (#5852)
- Allow lua to chose whatever directories or files can be selected - Fix selecting directories - Rename dialog to `guiPathSelectMenu` from `guiFileSelectMenu` - Rename lua function for opening the menu from `show_file_open_dialog` to `show_path_select_dialog` - Remove duplicate code and fix code style. Related changes - fix `clang-format` whitelist. - Regenerate minetest.conf.example
This commit is contained in:
parent
2e9ef9b4eb
commit
e6aaccee1d
|
@ -196,7 +196,7 @@ local function parse_setting_line(settings, line, read_all, base_level, allow_se
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if setting_type == "path" then
|
if setting_type == "path" or setting_type == "filepath" then
|
||||||
local default = remaining_line:match("^(.*)$")
|
local default = remaining_line:match("^(.*)$")
|
||||||
|
|
||||||
if not default then
|
if not default then
|
||||||
|
@ -206,7 +206,7 @@ local function parse_setting_line(settings, line, read_all, base_level, allow_se
|
||||||
table.insert(settings, {
|
table.insert(settings, {
|
||||||
name = name,
|
name = name,
|
||||||
readable_name = readable_name,
|
readable_name = readable_name,
|
||||||
type = "path",
|
type = setting_type,
|
||||||
default = default,
|
default = default,
|
||||||
comment = current_comment,
|
comment = current_comment,
|
||||||
})
|
})
|
||||||
|
@ -504,14 +504,14 @@ local function create_change_setting_formspec(dialogdata)
|
||||||
end
|
end
|
||||||
formspec = formspec .. ";" .. selected_index .. "]"
|
formspec = formspec .. ";" .. selected_index .. "]"
|
||||||
|
|
||||||
elseif setting.type == "path" then
|
elseif setting.type == "path" or setting.type == "filepath" then
|
||||||
local current_value = dialogdata.selected_path
|
local current_value = dialogdata.selected_path
|
||||||
if not current_value then
|
if not current_value then
|
||||||
current_value = get_current_value(setting)
|
current_value = get_current_value(setting)
|
||||||
end
|
end
|
||||||
formspec = formspec .. "field[0.5,4;7.5,1;te_setting_value;;"
|
formspec = formspec .. "field[0.5,4;7.5,1;te_setting_value;;"
|
||||||
.. core.formspec_escape(current_value) .. "]"
|
.. core.formspec_escape(current_value) .. "]"
|
||||||
.. "button[8,3.75;2,1;btn_browser_path;" .. fgettext("Browse") .. "]"
|
.. "button[8,3.75;2,1;btn_browser_" .. setting.type .. ";" .. fgettext("Browse") .. "]"
|
||||||
|
|
||||||
else
|
else
|
||||||
-- TODO: fancy input for float, int, flags, noise_params, v3f
|
-- TODO: fancy input for float, int, flags, noise_params, v3f
|
||||||
|
@ -606,7 +606,13 @@ local function handle_change_setting_buttons(this, fields)
|
||||||
end
|
end
|
||||||
|
|
||||||
if fields["btn_browser_path"] then
|
if fields["btn_browser_path"] then
|
||||||
core.show_file_open_dialog("dlg_browse_path", fgettext_ne("Select path"))
|
core.show_path_select_dialog("dlg_browse_path",
|
||||||
|
fgettext_ne("Select directory"), false)
|
||||||
|
end
|
||||||
|
|
||||||
|
if fields["btn_browser_filepath"] then
|
||||||
|
core.show_path_select_dialog("dlg_browse_path",
|
||||||
|
fgettext_ne("Select file"), true)
|
||||||
end
|
end
|
||||||
|
|
||||||
if fields["dlg_browse_path_accepted"] then
|
if fields["dlg_browse_path_accepted"] then
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
# - float
|
# - float
|
||||||
# - enum
|
# - enum
|
||||||
# - path
|
# - path
|
||||||
|
# - filepath
|
||||||
# - key (will be ignored in GUI, since a special key change dialog exists)
|
# - key (will be ignored in GUI, since a special key change dialog exists)
|
||||||
# - flags
|
# - flags
|
||||||
# - noise_params
|
# - noise_params
|
||||||
|
@ -31,6 +32,8 @@
|
||||||
# - default value1,value2,...
|
# - default value1,value2,...
|
||||||
# * path:
|
# * path:
|
||||||
# - default (if default is not specified then "" is set)
|
# - default (if default is not specified then "" is set)
|
||||||
|
# * filepath:
|
||||||
|
# - default (if default is not specified then "" is set)
|
||||||
# * key:
|
# * key:
|
||||||
# - default
|
# - default
|
||||||
# * flags:
|
# * flags:
|
||||||
|
@ -642,7 +645,7 @@ tooltip_show_delay (Tooltip delay) int 400
|
||||||
freetype (Freetype fonts) bool true
|
freetype (Freetype fonts) bool true
|
||||||
|
|
||||||
# Path to TrueTypeFont or bitmap.
|
# Path to TrueTypeFont or bitmap.
|
||||||
font_path (Font path) path fonts/liberationsans.ttf
|
font_path (Font path) filepath fonts/liberationsans.ttf
|
||||||
|
|
||||||
font_size (Font size) int 16
|
font_size (Font size) int 16
|
||||||
|
|
||||||
|
@ -652,12 +655,12 @@ font_shadow (Font shadow) int 1
|
||||||
# Font shadow alpha (opaqueness, between 0 and 255).
|
# Font shadow alpha (opaqueness, between 0 and 255).
|
||||||
font_shadow_alpha (Font shadow alpha) int 127 0 255
|
font_shadow_alpha (Font shadow alpha) int 127 0 255
|
||||||
|
|
||||||
mono_font_path (Monospace font path) path fonts/liberationmono.ttf
|
mono_font_path (Monospace font path) filepath fonts/liberationmono.ttf
|
||||||
|
|
||||||
mono_font_size (Monospace font size) int 15
|
mono_font_size (Monospace font size) int 15
|
||||||
|
|
||||||
# This font will be used for certain languages.
|
# This font will be used for certain languages.
|
||||||
fallback_font_path (Fallback font) path fonts/DroidSansFallbackFull.ttf
|
fallback_font_path (Fallback font) filepath fonts/DroidSansFallbackFull.ttf
|
||||||
fallback_font_size (Fallback font size) int 15
|
fallback_font_size (Fallback font size) int 15
|
||||||
fallback_font_shadow (Fallback font shadow) int 1
|
fallback_font_shadow (Fallback font shadow) int 1
|
||||||
fallback_font_shadow_alpha (Fallback font shadow alpha) int 128 0 255
|
fallback_font_shadow_alpha (Fallback font shadow alpha) int 128 0 255
|
||||||
|
|
Loading…
Reference in New Issue