manager gui stations: include station control signals in control signal column

This commit is contained in:
Shadowsvoices
2023-09-10 23:49:42 +02:00
parent 67a611c713
commit bd28d8a3fc
2 changed files with 65 additions and 2 deletions

View File

@@ -250,7 +250,7 @@ function stations_tab.build(map_data, player_data, query_limit)
gui.add(refs.provided_requested_table, util.slot_table_build_from_station(station)) gui.add(refs.provided_requested_table, util.slot_table_build_from_station(station))
gui.add(refs.shipments_table, util.slot_table_build_from_deliveries(station)) gui.add(refs.shipments_table, util.slot_table_build_from_deliveries(station))
gui.add(refs.control_signals_table, util.slot_table_build_from_control_signals(station)) gui.add(refs.control_signals_table, util.slot_table_build_from_control_signals(station, map_data))
end end

View File

@@ -171,10 +171,11 @@ end
--- @param station Station --- @param station Station
--- @return GuiElemDef[] --- @return GuiElemDef[]
function util.slot_table_build_from_control_signals(station) function util.slot_table_build_from_control_signals(station, map_data)
---@type GuiElemDef[] ---@type GuiElemDef[]
local children = {} local children = {}
local comb1_signals, comb2_signals = get_signals(station) local comb1_signals, comb2_signals = get_signals(station)
if comb1_signals then if comb1_signals then
for _, v in pairs(comb1_signals) do for _, v in pairs(comb1_signals) do
local item = v.signal local item = v.signal
@@ -205,6 +206,68 @@ function util.slot_table_build_from_control_signals(station)
::continue:: ::continue::
end end
end end
if comb2_signals then
for _, v in pairs(comb2_signals) do
local item = v.signal
local count = v.count
local name = item.name
local sprite = ""
local color = "default"
if item.type == "item" or item.type == "fluid" then
local sprite, img_path, item_string = util.generate_item_references(name)
if sprite ~= nil then
local color
if count > 0 then
color = "green"
else
color = "blue"
end
end
if station.is_stack and item.type == "item" then
count = count * get_stack_size(map_data, name)
end
if game.is_valid_sprite_path(sprite) then
children[#children + 1] = {
type = "sprite-button",
enabled = false,
style = "ltnm_small_slot_button_" .. color,
sprite = sprite,
tooltip = {
"",
img_path,
item_string,
"\n"..format.number(count),
},
number = count
}
end
elseif item.type == "virtual" then
sprite = "virtual-signal" .. "/" .. name
if game.is_valid_sprite_path(sprite) then
children[#children + 1] = {
type = "sprite-button",
enabled = false,
style = "ltnm_small_slot_button_" .. color,
sprite = sprite,
tooltip = {
"",
"[img=virtual-signal." .. name .. "]",
{ "virtual-signal-name." .. name },
"\n"..format.number(count),
},
number = count
}
end
end
::continue::
end
end
return children return children
end end