mirror of
https://github.com/Xevion/project-cybersyn.git
synced 2025-12-11 02:08:16 -06:00
Trains Tab v1
This commit is contained in:
@@ -34,6 +34,7 @@ history=History
|
|||||||
in-transit=In transit
|
in-transit=In transit
|
||||||
inventory=Inventory
|
inventory=Inventory
|
||||||
keep-open=Keep open
|
keep-open=Keep open
|
||||||
|
layout=Train Layout
|
||||||
loading-at=Loading at
|
loading-at=Loading at
|
||||||
name=Name
|
name=Name
|
||||||
network-name-label=Network Filter:
|
network-name-label=Network Filter:
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ constants.gui = {
|
|||||||
trains = {
|
trains = {
|
||||||
train_id = 90,
|
train_id = 90,
|
||||||
status = 378,
|
status = 378,
|
||||||
composition = 200,
|
layout = 200,
|
||||||
depot = 149,
|
depot = 149,
|
||||||
shipment = 36 * 6,
|
shipment = 36 * 6,
|
||||||
shipment_columns = 6,
|
shipment_columns = 6,
|
||||||
|
|||||||
@@ -28,8 +28,9 @@ function trains_tab.create(widths)
|
|||||||
{
|
{
|
||||||
type = "frame",
|
type = "frame",
|
||||||
style = "ltnm_table_toolbar_frame",
|
style = "ltnm_table_toolbar_frame",
|
||||||
|
templates.sort_checkbox(widths, "trains", "train_id", false),
|
||||||
templates.sort_checkbox(widths, "trains", "status", false),
|
templates.sort_checkbox(widths, "trains", "status", false),
|
||||||
templates.sort_checkbox(widths, "trains", "layout", false, { "cybersyn-gui.composition-description" }),
|
templates.sort_checkbox(widths, "trains", "layout", false),
|
||||||
templates.sort_checkbox(widths, "trains", "depot", false),
|
templates.sort_checkbox(widths, "trains", "depot", false),
|
||||||
templates.sort_checkbox(widths, "trains", "shipment", false),
|
templates.sort_checkbox(widths, "trains", "shipment", false),
|
||||||
},
|
},
|
||||||
@@ -61,6 +62,8 @@ function trains_tab.build(map_data, player_data, query_limit)
|
|||||||
|
|
||||||
local trains_sorted = {}
|
local trains_sorted = {}
|
||||||
|
|
||||||
|
local layouts_table = util.build_train_layout_table(map_data)
|
||||||
|
|
||||||
local i = 0
|
local i = 0
|
||||||
for id, train in pairs(trains) do
|
for id, train in pairs(trains) do
|
||||||
if not train.entity.valid then
|
if not train.entity.valid then
|
||||||
@@ -108,7 +111,7 @@ function trains_tab.build(map_data, player_data, query_limit)
|
|||||||
goto continue
|
goto continue
|
||||||
end
|
end
|
||||||
for i, v in ipairs(train.manifest) do
|
for i, v in ipairs(train.manifest) do
|
||||||
if string.match(v.name, search_item) then
|
if v.name == search_item then
|
||||||
goto has_match
|
goto has_match
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -204,7 +207,12 @@ function trains_tab.build(map_data, player_data, query_limit)
|
|||||||
if train.manifest ~= nil then
|
if train.manifest ~= nil then
|
||||||
manifest = train.manifest
|
manifest = train.manifest
|
||||||
end
|
end
|
||||||
|
local network_sprite = "utility/close_black"
|
||||||
|
local network_name = train.network_name
|
||||||
|
local network_id = train.network_flag
|
||||||
|
if network_name then
|
||||||
|
network_sprite, _, _ = util.generate_item_references(network_name)
|
||||||
|
end
|
||||||
local color = idx % 2 == 0 and "dark" or "light"
|
local color = idx % 2 == 0 and "dark" or "light"
|
||||||
gui.add(scroll_pane, {
|
gui.add(scroll_pane, {
|
||||||
type = "frame",
|
type = "frame",
|
||||||
@@ -216,7 +224,8 @@ function trains_tab.build(map_data, player_data, query_limit)
|
|||||||
type = "minimap",
|
type = "minimap",
|
||||||
name = "train_minimap",
|
name = "train_minimap",
|
||||||
style = "ltnm_train_minimap",
|
style = "ltnm_train_minimap",
|
||||||
{ type = "label", style = "ltnm_minimap_label" },
|
|
||||||
|
{ type = "label", style = "ltnm_minimap_label", caption = train_id },
|
||||||
{
|
{
|
||||||
type = "button",
|
type = "button",
|
||||||
style = "ltnm_train_minimap_button",
|
style = "ltnm_train_minimap_button",
|
||||||
@@ -226,10 +235,16 @@ function trains_tab.build(map_data, player_data, query_limit)
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
type = "frame",
|
||||||
|
style = "ltnm_table_row_frame_" .. color,
|
||||||
|
style_mods = { width = widths.trains.status },
|
||||||
|
{ type = "sprite-button", style = "ltnm_small_slot_button_default", enabled = false, sprite = network_sprite, number = network_id },
|
||||||
|
},
|
||||||
{
|
{
|
||||||
type = "label",
|
type = "label",
|
||||||
style_mods = { width = widths.trains.composition },
|
style_mods = { width = widths.trains.layout },
|
||||||
caption = train.layout_id,
|
caption = layouts_table[train.layout_id],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type = "label",
|
type = "label",
|
||||||
|
|||||||
@@ -245,4 +245,20 @@ function util.close_manager_window(player, player_data, refs)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function util.build_train_layout_table(map_data)
|
||||||
|
local layouts = map_data.layouts
|
||||||
|
local layouts_table = {}
|
||||||
|
for i, v in pairs(layouts) do
|
||||||
|
local layout_string = table.concat(v, ",")
|
||||||
|
layout_string = layout_string.gsub(layout_string, "0", "[item=locomotive]")
|
||||||
|
layout_string = layout_string.gsub(layout_string, "1", "[item=cargo-wagon]")
|
||||||
|
layout_string = layout_string.gsub(layout_string, "2", "[item=fluid-wagon]")
|
||||||
|
layout_string = layout_string.gsub(layout_string, ",", "")
|
||||||
|
layouts_table[i] = layout_string
|
||||||
|
end
|
||||||
|
return layouts_table
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
return util
|
return util
|
||||||
|
|||||||
Reference in New Issue
Block a user