summaryrefslogtreecommitdiff
path: root/builtin/mainmenu
diff options
context:
space:
mode:
authorred-001 <red-001@outlook.ie>2017-06-11 08:43:31 +0100
committerLoïc Blot <nerzhul@users.noreply.github.com>2017-06-11 09:43:31 +0200
commit26e2eb019afa60c66c4dc89cf24bbf5b25c6a383 (patch)
treea2ac098a32d4b7c97775c9161a29b12ec54e3fad /builtin/mainmenu
parent6c5e5e202394ce8063e3c2d9b663145bc4f8efce (diff)
downloadminetest-26e2eb019afa60c66c4dc89cf24bbf5b25c6a383.tar.gz
minetest-26e2eb019afa60c66c4dc89cf24bbf5b25c6a383.tar.bz2
minetest-26e2eb019afa60c66c4dc89cf24bbf5b25c6a383.zip
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
Diffstat (limited to 'builtin/mainmenu')
-rw-r--r--builtin/mainmenu/dlg_settings_advanced.lua16
1 files changed, 11 insertions, 5 deletions
diff --git a/builtin/mainmenu/dlg_settings_advanced.lua b/builtin/mainmenu/dlg_settings_advanced.lua
index 206ce1620..cac9f6983 100644
--- a/builtin/mainmenu/dlg_settings_advanced.lua
+++ b/builtin/mainmenu/dlg_settings_advanced.lua
@@ -196,7 +196,7 @@ local function parse_setting_line(settings, line, read_all, base_level, allow_se
return
end
- if setting_type == "path" then
+ if setting_type == "path" or setting_type == "filepath" then
local default = remaining_line:match("^(.*)$")
if not default then
@@ -206,7 +206,7 @@ local function parse_setting_line(settings, line, read_all, base_level, allow_se
table.insert(settings, {
name = name,
readable_name = readable_name,
- type = "path",
+ type = setting_type,
default = default,
comment = current_comment,
})
@@ -504,14 +504,14 @@ local function create_change_setting_formspec(dialogdata)
end
formspec = formspec .. ";" .. selected_index .. "]"
- elseif setting.type == "path" then
+ elseif setting.type == "path" or setting.type == "filepath" then
local current_value = dialogdata.selected_path
if not current_value then
current_value = get_current_value(setting)
end
formspec = formspec .. "field[0.5,4;7.5,1;te_setting_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
-- TODO: fancy input for float, int, flags, noise_params, v3f
@@ -606,7 +606,13 @@ local function handle_change_setting_buttons(this, fields)
end
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
if fields["dlg_browse_path_accepted"] then