mirror of
https://github.com/Xevion/project-cybersyn.git
synced 2025-12-08 12:08:09 -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
|
returning-to-depot=Returning to depot
|
||||||
route=Route
|
route=Route
|
||||||
runtime=Runtime
|
runtime=Runtime
|
||||||
search-label=Search:
|
search-label=Station Name:
|
||||||
search-item-label=Search by item:
|
search-item-label=Item Filter:
|
||||||
shipments-description=Green = Inbound\nBlue = Outbound
|
shipments-description=Green = Inbound\nBlue = Outbound
|
||||||
shipment=Shipment
|
shipment=Shipment
|
||||||
shipments=Shipments
|
shipments=Shipments
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ function inventory_tab.build(map_data, player_data)
|
|||||||
for _, signal_ID in pairs(comb1_signals) do
|
for _, signal_ID in pairs(comb1_signals) do
|
||||||
local item = signal_ID.signal.name
|
local item = signal_ID.signal.name
|
||||||
if item then
|
if item then
|
||||||
if string.match(item, search_item) then
|
if item == search_item then
|
||||||
goto has_match
|
goto has_match
|
||||||
end
|
end
|
||||||
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...
|
--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" } },
|
{ type = "label", style = "subheader_caption_label", caption = { "cybersyn-gui.search-item-label" } },
|
||||||
{
|
{ type= "choose-elem-button", name="manager_item_filter", style="slot_button_in_shallow_frame", elem_type="signal", handler=manager.handle.manager_update_item_search, },
|
||||||
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 = "empty-widget", style = "flib_horizontal_pusher" },
|
{ type = "empty-widget", style = "flib_horizontal_pusher" },
|
||||||
{ type = "label", style = "caption_label", caption = { "cybersyn-gui.network-name-label" } },
|
{ 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, },
|
{ 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 refs table<string, LuaGuiElement>
|
||||||
--- @param e GuiEventData
|
--- @param e GuiEventData
|
||||||
function manager.handle.manager_update_item_search(player, player_data, refs, e)
|
function manager.handle.manager_update_item_search(player, player_data, refs, e)
|
||||||
local query = e.element.text
|
local element = e.element
|
||||||
if query then
|
local signal = element.elem_value
|
||||||
-- Input sanitization
|
if signal then
|
||||||
for pattern, replacement in pairs(constants.input_sanitizers) do
|
player_data.search_item = signal.name
|
||||||
query = string.gsub(query, pattern, replacement)
|
else
|
||||||
end
|
player_data.search_item = nil
|
||||||
end
|
end
|
||||||
player_data.search_item = query
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ function stations_tab.build(map_data, player_data, query_limit)
|
|||||||
for _, signal_ID in pairs(comb1_signals) do
|
for _, signal_ID in pairs(comb1_signals) do
|
||||||
local item = signal_ID.signal.name
|
local item = signal_ID.signal.name
|
||||||
if item then
|
if item then
|
||||||
if string.match(item, search_item) then
|
if item == search_item then
|
||||||
goto has_match
|
goto has_match
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user