Tweak display of searching status

When the current search produces no results, give a specific message
rather than "Page 1 of 0".  Don't display the "Filter:" label if no
filtering is currently applied.
This commit is contained in:
Zefram 2014-04-29 20:08:04 +01:00
parent 01297996a6
commit b0e10d44f4

View File

@ -54,29 +54,35 @@ function unified_inventory.get_formspec(player, page)
formspec = formspec .. "image_button[12.2,8.1;.8,.8;ui_search_icon.png;searchbutton;]" formspec = formspec .. "image_button[12.2,8.1;.8,.8;ui_search_icon.png;searchbutton;]"
-- Items list -- Items list
local list_index = unified_inventory.current_index[player_name] if #unified_inventory.filtered_items_list[player_name] == 0 then
local page = math.floor(list_index / (80) + 1) formspec = formspec.."label[8.2,0;No matching items]"
local pagemax = math.floor( else
(#unified_inventory.filtered_items_list[player_name] - 1) local list_index = unified_inventory.current_index[player_name]
/ (80) + 1) local page = math.floor(list_index / (80) + 1)
local item = {} local pagemax = math.floor(
for y = 0, 9 do (#unified_inventory.filtered_items_list[player_name] - 1)
for x = 0, 7 do / (80) + 1)
local name = unified_inventory.filtered_items_list[player_name][list_index] local item = {}
if minetest.registered_items[name] then for y = 0, 9 do
formspec = formspec.."item_image_button[" for x = 0, 7 do
..(8.2 + x * 0.7).."," local name = unified_inventory.filtered_items_list[player_name][list_index]
..(1 + y * 0.7)..";.81,.81;" if minetest.registered_items[name] then
..name..";item_button_" formspec = formspec.."item_image_button["
..name..";]" ..(8.2 + x * 0.7)..","
list_index = list_index + 1 ..(1 + y * 0.7)..";.81,.81;"
..name..";item_button_"
..name..";]"
list_index = list_index + 1
end
end end
end
formspec = formspec.."label[8.2,0;Page:]"
formspec = formspec.."label[9,0;"..page.." of "..pagemax.."]"
end end
if unified_inventory.activefilter[player_name] ~= "" then
formspec = formspec.."label[8.2,0.4;Filter:]"
formspec = formspec.."label[9,0.4;"..minetest.formspec_escape(unified_inventory.activefilter[player_name]).."]"
end end
formspec = formspec.."label[8.2,0;Page:]"
formspec = formspec.."label[9,0;"..page.." of "..pagemax.."]"
formspec = formspec.."label[8.2,0.4;Filter:]"
formspec = formspec.."label[9,0.4;"..minetest.formspec_escape(unified_inventory.activefilter[player_name]).."]"
return formspec return formspec
end end