diff options
author | Andrey <AndreyT2203@gmail.com> | 2020-12-20 00:00:20 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-19 22:00:20 +0100 |
commit | 5066fe75830b98f592717b593099a757337c952d (patch) | |
tree | a04d7aae17198f8a64880d5217ebb2e0e56a5cb6 | |
parent | ccbf8029ea6bfc5bb5d4af340bd4c2c0d58fe0ff (diff) | |
download | minetest-5066fe75830b98f592717b593099a757337c952d.tar.gz minetest-5066fe75830b98f592717b593099a757337c952d.tar.bz2 minetest-5066fe75830b98f592717b593099a757337c952d.zip |
MainMenu: Add clear button and icon for search input (#10363)
-rw-r--r-- | LICENSE.txt | 2 | ||||
-rw-r--r-- | builtin/mainmenu/dlg_contentstore.lua | 11 | ||||
-rw-r--r-- | builtin/mainmenu/tab_online.lua | 9 | ||||
-rw-r--r-- | textures/base/pack/clear.png | bin | 0 -> 708 bytes | |||
-rw-r--r-- | textures/base/pack/search.png | bin | 0 -> 1908 bytes |
5 files changed, 19 insertions, 3 deletions
diff --git a/LICENSE.txt b/LICENSE.txt index f5c51833b..9fbd23723 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -23,6 +23,8 @@ paramat: textures/base/pack/menu_header.png textures/base/pack/next_icon.png textures/base/pack/prev_icon.png + textures/base/pack/clear.png + textures/base/pack/search.png rubenwardy, paramat: textures/base/pack/start_icon.png diff --git a/builtin/mainmenu/dlg_contentstore.lua b/builtin/mainmenu/dlg_contentstore.lua index 6525f6013..7a96df2a5 100644 --- a/builtin/mainmenu/dlg_contentstore.lua +++ b/builtin/mainmenu/dlg_contentstore.lua @@ -340,7 +340,6 @@ function store.get_formspec(dlgdata) local W = 15.75 local H = 9.5 - local formspec if #store.packages_full > 0 then formspec = { @@ -353,7 +352,8 @@ function store.get_formspec(dlgdata) "container[0.375,0.375]", "field[0,0;7.225,0.8;search_string;;", core.formspec_escape(search_string), "]", "field_close_on_enter[search_string;false]", - "button[7.225,0;2,0.8;search;", fgettext("Search"), "]", + "image_button[7.3,0;0.8,0.8;", core.formspec_escape(defaulttexturedir .. "search.png"), ";search;]", + "image_button[8.125,0;0.8,0.8;", core.formspec_escape(defaulttexturedir .. "clear.png"), ";clear;]", "dropdown[9.6,0;2.4,0.8;type;", table.concat(filter_types_titles, ","), ";", filter_type, "]", "container_end[]", @@ -504,6 +504,13 @@ function store.handle_submit(this, fields) return true end + if fields.clear then + search_string = "" + cur_page = 1 + store.filter_packages("") + return true + end + if fields.back then this:delete() return true diff --git a/builtin/mainmenu/tab_online.lua b/builtin/mainmenu/tab_online.lua index 7985fd84a..8f1341161 100644 --- a/builtin/mainmenu/tab_online.lua +++ b/builtin/mainmenu/tab_online.lua @@ -34,7 +34,8 @@ local function get_formspec(tabview, name, tabdata) local retval = -- Search "field[0.15,0.075;5.91,1;te_search;;" .. core.formspec_escape(tabdata.search_for) .. "]" .. - "button[5.62,-0.25;1.5,1;btn_mp_search;" .. fgettext("Search") .. "]" .. + "image_button[5.63,-.165;.83,.83;" .. core.formspec_escape(defaulttexturedir .. "search.png") .. ";btn_mp_search;]" .. + "image_button[6.3,-.165;.83,.83;" .. core.formspec_escape(defaulttexturedir .. "clear.png") .. ";btn_mp_clear;]" .. "image_button[6.97,-.165;.83,.83;" .. core.formspec_escape(defaulttexturedir .. "refresh.png") .. ";btn_mp_refresh;]" .. @@ -243,6 +244,12 @@ local function main_button_handler(tabview, fields, name, tabdata) return true end + if fields.btn_mp_clear then + tabdata.search_for = "" + menudata.search_result = nil + return true + end + if fields.btn_mp_search or fields.key_enter_field == "te_search" then tabdata.fav_selected = 1 local input = fields.te_search:lower() diff --git a/textures/base/pack/clear.png b/textures/base/pack/clear.png Binary files differnew file mode 100644 index 000000000..9244264ad --- /dev/null +++ b/textures/base/pack/clear.png diff --git a/textures/base/pack/search.png b/textures/base/pack/search.png Binary files differnew file mode 100644 index 000000000..aace8044a --- /dev/null +++ b/textures/base/pack/search.png |