Add seperate button for resetting search

This commit is contained in:
Wuzzy 2016-08-06 23:31:53 +02:00
parent dba69b1f71
commit 2a516ac22b
4 changed files with 17 additions and 4 deletions

View File

@ -14,9 +14,10 @@ Unified inventory code is licensed under the GNU LGPLv2+.
Licenses for textures:
VanessaE: (WTFPL)
* ui\_group.png
* `ui_group.png`
RealBadAngel: (WTFPL)
* Everything else.
Tango Project: (WTFPL)
* `ui_reset_icon.png

View File

@ -153,11 +153,17 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
if fields.searchbutton then
unified_inventory.apply_filter(player, unified_inventory.current_searchbox[player_name], "nochange")
unified_inventory.current_searchbox[player_name] = ""
unified_inventory.set_inventory_formspec(player,
unified_inventory.current_page[player_name])
minetest.sound_play("paperflip2",
{to_player=player_name, gain = 1.0})
elseif fields.searchresetbutton then
unified_inventory.apply_filter(player, "", "nochange")
unified_inventory.current_searchbox[player_name] = ""
unified_inventory.set_inventory_formspec(player,
unified_inventory.current_page[player_name])
minetest.sound_play("click",
{to_player=player_name, gain = 0.1})
end
-- alternate buttons

View File

@ -179,13 +179,19 @@ function unified_inventory.get_formspec(player, page)
.. minetest.formspec_escape(unified_inventory.current_searchbox[player_name]) .. "]"
formspec[n+1] = "image_button[12.2,8.1;.8,.8;ui_search_icon.png;searchbutton;]"
.. "tooltip[searchbutton;" ..F("Search") .. "]"
formspec[n+2] = "image_button[12.9,8.1;.8,.8;ui_reset_icon.png;searchresetbutton;]"
.. "tooltip[searchbutton;" ..F("Search") .. "]"
.. "tooltip[searchresetbutton;" ..F("Reset search and display everything") .. "]"
else
formspec[n] = "field[8.5,5.225;2.2,1;searchbox;;"
.. minetest.formspec_escape(unified_inventory.current_searchbox[player_name]) .. "]"
formspec[n+1] = "image_button[10.3,5;.8,.8;ui_search_icon.png;searchbutton;]"
.. "tooltip[searchbutton;" ..F("Search") .. "]"
formspec[n+2] = "image_button[11,5;.8,.8;ui_reset_icon.png;searchresetbutton;]"
.. "tooltip[searchbutton;" ..F("Search") .. "]"
.. "tooltip[searchresetbutton;" ..F("Reset search and display everything") .. "]"
end
n = n+2
n = n+3
local no_matches = "No matching items"
if draw_lite_mode then

BIN
textures/ui_reset_icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB