Minor UI improvement

This commit is contained in:
Jean-Patrick Guerrero 2022-06-30 01:53:07 +02:00
parent b2c8447971
commit 662c938afb
3 changed files with 20 additions and 5 deletions

View File

@ -610,6 +610,7 @@ local function reset_data(data)
data.scrbar_rcp = 1
data.scrbar_usg = 1
data.query_item = nil
data.enable_search = nil
data.recipes = nil
data.usages = nil
data.export_rcp = nil

View File

@ -309,13 +309,21 @@ end
local function rcp_fields(player, data, fields)
local sb_rcp, sb_usg = fields.scrbar_rcp, fields.scrbar_usg
if fields.filter and fields.filter == "" then
data.enable_search = nil
end
if fields.cancel then
reset_data(data)
elseif fields.exit then
data.query_item = nil
elseif fields.key_enter_field == "filter" or fields.search then
elseif fields.enable_search then
data.enable_search = true
return set_fs(player)
elseif fields.filter and (fields.key_enter_field == "filter" or fields.search) then
if fields.filter == "" then
reset_data(data)
return set_fs(player)

View File

@ -1325,10 +1325,16 @@ local function get_items_fs(fs, data, player, full_height)
bg9(data.inv_width + 0.1, 0, 7.9, full_height, PNG.bg_full, 10)
fs("set_focus[filter]",
"style[filter;font_size=18;textcolor=#ccc]",
fmt("field[%f,0.2;3.35,0.6;filter;;%s]", data.inv_width + 0.85, ESC(data.filter)),
"field_close_on_enter[filter;false]")
if data.enable_search then
fs("set_focus[filter]",
"style[filter;font_size=18;textcolor=#ccc]",
fmt("field[%f,0.2;3.35,0.6;filter;;%s]", data.inv_width + 0.85, ESC(data.filter)),
"field_close_on_enter[filter;false]")
else
fs"style_type[label;font=italic;font_size=18]"
label(data.inv_width + 0.9, 0.49, clr("#aaa", ES"Search..."))
button(data.inv_width + 0.8, 0.2, 4, 1, "enable_search", "")
end
image_button(data.inv_width + 0.35, 0.32, 0.35, 0.35, "", "search", "")
image_button(data.inv_width + 5.27, 0.3, 0.35, 0.35, "", "prev_page", "")