mirror of
https://github.com/Xevion/project-cybersyn.git
synced 2025-12-07 11:16:03 -06:00
re-implemented item search via choose-elem-button for exact matching regardless of locale
This commit is contained in:
@@ -57,8 +57,8 @@ requested=Requested
|
||||
returning-to-depot=Returning to depot
|
||||
route=Route
|
||||
runtime=Runtime
|
||||
search-label=Search:
|
||||
search-item-label=Search by item:
|
||||
search-label=Station Name:
|
||||
search-item-label=Item Filter:
|
||||
shipments-description=Green = Inbound\nBlue = Outbound
|
||||
shipment=Shipment
|
||||
shipments=Shipments
|
||||
|
||||
@@ -108,7 +108,7 @@ function inventory_tab.build(map_data, player_data)
|
||||
for _, signal_ID in pairs(comb1_signals) do
|
||||
local item = signal_ID.signal.name
|
||||
if item then
|
||||
if string.match(item, search_item) then
|
||||
if item == search_item then
|
||||
goto has_match
|
||||
end
|
||||
end
|
||||
|
||||
@@ -71,12 +71,7 @@ function manager.create(player)
|
||||
},
|
||||
--item search box commented out. It *works*, but, the filtering logic only checks delivieres, so I'm not sure what Mami intended it for, so I'm leaving it off for now...
|
||||
{ type = "label", style = "subheader_caption_label", caption = { "cybersyn-gui.search-item-label" } },
|
||||
{
|
||||
name = "manager_item_search_field",
|
||||
type = "textfield",
|
||||
clear_and_focus_on_right_click = true,
|
||||
handler = manager.handle.manager_update_item_search, --on_gui_text_changed
|
||||
},
|
||||
{ type= "choose-elem-button", name="manager_item_filter", style="slot_button_in_shallow_frame", elem_type="signal", handler=manager.handle.manager_update_item_search, },
|
||||
{ type = "empty-widget", style = "flib_horizontal_pusher" },
|
||||
{ type = "label", style = "caption_label", caption = { "cybersyn-gui.network-name-label" } },
|
||||
{ type= "choose-elem-button", name="network", style="slot_button_in_shallow_frame", elem_type="signal", tooltip={"cybersyn-gui.network-tooltip"}, handler=manager.handle.manager_update_network_name, },
|
||||
@@ -273,14 +268,13 @@ end
|
||||
--- @param refs table<string, LuaGuiElement>
|
||||
--- @param e GuiEventData
|
||||
function manager.handle.manager_update_item_search(player, player_data, refs, e)
|
||||
local query = e.element.text
|
||||
if query then
|
||||
-- Input sanitization
|
||||
for pattern, replacement in pairs(constants.input_sanitizers) do
|
||||
query = string.gsub(query, pattern, replacement)
|
||||
end
|
||||
local element = e.element
|
||||
local signal = element.elem_value
|
||||
if signal then
|
||||
player_data.search_item = signal.name
|
||||
else
|
||||
player_data.search_item = nil
|
||||
end
|
||||
player_data.search_item = query
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ function stations_tab.build(map_data, player_data, query_limit)
|
||||
for _, signal_ID in pairs(comb1_signals) do
|
||||
local item = signal_ID.signal.name
|
||||
if item then
|
||||
if string.match(item, search_item) then
|
||||
if item == search_item then
|
||||
goto has_match
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user