Minor refactoring, fixed localization for EN on GUI, added incompatibility with LtnManager due to potential issues with collisions, renamed some LtnManager references in code.

This commit is contained in:
Will Berry
2023-03-07 11:34:09 -05:00
parent 732d63d65b
commit d5fb6417fa
16 changed files with 111 additions and 98 deletions

View File

@@ -85,14 +85,14 @@ constants.gui_content_frame_height = 744
constants.gui_inventory_table_height = 40 * 18 constants.gui_inventory_table_height = 40 * 18
constants.gui_translations = { constants.gui_translations = {
delivering_to = { "gui.ltnm-delivering-to" }, delivering_to = { "cybersyn-gui.delivering-to" },
fetching_from = { "gui.ltnm-fetching-from" }, fetching_from = { "cybersyn-gui.fetching-from" },
loading_at = { "gui.ltnm-loading-at" }, loading_at = { "cybersyn-gui.loading-at" },
not_available = { "gui.ltnm-not-available" }, not_available = { "cybersyn-gui.not-available" },
parked_at_depot_with_residue = { "gui.ltnm-parked-at-depot-with-residue" }, parked_at_depot_with_residue = { "cybersyn-gui.parked-at-depot-with-residue" },
parked_at_depot = { "gui.ltnm-parked-at-depot" }, parked_at_depot = { "cybersyn-gui.parked-at-depot" },
returning_to_depot = { "gui.ltnm-returning-to-depot" }, returning_to_depot = { "cybersyn-gui.returning-to-depot" },
unloading_at = { "gui.ltnm-unloading-at" }, unloading_at = { "cybersyn-gui.unloading-at" },
} }
constants.input_sanitizers = { constants.input_sanitizers = {
@@ -144,8 +144,8 @@ constants.ltn_event_names = {
if script then if script then
constants.open_station_gui_tooltip = { constants.open_station_gui_tooltip = {
"", "",
{ "gui.ltnm-open-station-gui" }, { "cybersyn-gui.open-station-gui" },
remote.interfaces["ltn-combinator"] and { "", "\n", { "gui.ltnm-open-ltn-combinator-gui" } } or nil, remote.interfaces["ltn-combinator"] and { "", "\n", { "cybersyn-gui.open-ltn-combinator-gui" } } or nil,
} }
end end

View File

@@ -26,14 +26,14 @@ data:extend({
--{ --{
-- type = "shortcut", -- type = "shortcut",
-- name = "ltnm-toggle-gui", -- name = "cybersyn-toggle-gui",
-- icon = data_util.build_sprite(nil, { 0, 0 }, util.paths.shortcut_icons, 32, 2), -- icon = data_util.build_sprite(nil, { 0, 0 }, util.paths.shortcut_icons, 32, 2),
-- disabled_icon = data_util.build_sprite(nil, { 48, 0 }, util.paths.shortcut_icons, 32, 2), -- disabled_icon = data_util.build_sprite(nil, { 48, 0 }, util.paths.shortcut_icons, 32, 2),
-- small_icon = data_util.build_sprite(nil, { 0, 32 }, util.paths.shortcut_icons, 24, 2), -- small_icon = data_util.build_sprite(nil, { 0, 32 }, util.paths.shortcut_icons, 24, 2),
-- disabled_small_icon = data_util.build_sprite(nil, { 36, 32 }, util.paths.shortcut_icons, 24, 2), -- disabled_small_icon = data_util.build_sprite(nil, { 36, 32 }, util.paths.shortcut_icons, 24, 2),
-- toggleable = true, -- toggleable = true,
-- action = "lua", -- action = "lua",
-- associated_control_input = "ltnm-toggle-gui", -- associated_control_input = "cybersyn-toggle-gui",
-- technology_to_unlock = "logistic-train-network", -- technology_to_unlock = "logistic-train-network",
--}, --},
}) })

View File

@@ -11,6 +11,7 @@
"? space-exploration >= 0.6.94", "? space-exploration >= 0.6.94",
"? miniloader", "? miniloader",
"? nullius", "? nullius",
"? pypostprocessing" "? pypostprocessing",
"! LtnManager"
] ]
} }

View File

@@ -1,5 +1,8 @@
[mod-name]
cybersyn=Cybersyn GUI
[controls] [controls]
cybersyn-toggle-gui=Toggle LTN Manager cybersyn-toggle-gui=Toggle Cybersyn Manager
[cybersyn-gui] [cybersyn-gui]
alert-delivery-failed=Delivery failed alert-delivery-failed=Delivery failed
@@ -60,7 +63,7 @@ shipment=Shipment
shipments=Shipments shipments=Shipments
stations=Stations stations=Stations
status-description=[img=flib_indicator_green]1 = normal status\n[img=flib_indicator_blue]n = LTN Controlled Train parked at stop, n = number of trains\n[img=flib_indicator_yellow]n = Stop is part of a scheduled delivery, n = number of trains\n[img=flib_indicator_white]1 = Error - not initialized\n[img=flib_indicator_red]1 = Error - short circuit\n[img=flib_indicator_red]2 = Error - deactivated stop status-description=[img=flib_indicator_green]1 = normal status\n[img=flib_indicator_blue]n = LTN Controlled Train parked at stop, n = number of trains\n[img=flib_indicator_yellow]n = Stop is part of a scheduled delivery, n = number of trains\n[img=flib_indicator_white]1 = Error - not initialized\n[img=flib_indicator_red]1 = Error - short circuit\n[img=flib_indicator_red]2 = Error - deactivated stop
status=Status status=Network Signal
surface-label=Surface: surface-label=Surface:
time=Time time=Time
train-id=Train ID train-id=Train ID
@@ -81,4 +84,4 @@ history-length=History length
iterations-per-tick=Iterations per tick [img=info] iterations-per-tick=Iterations per tick [img=info]
[shortcut-name] [shortcut-name]
cybersyn-toggle-gui=Toggle LTN Manager cybersyn-toggle-gui=Toggle Cybersyn Manager

View File

@@ -364,7 +364,7 @@ data:extend({
-- custom inputs -- custom inputs
--{ --{
-- type = "custom-input", -- type = "custom-input",
-- name = "ltnm-toggle-gui", -- name = "cybersyn-toggle-gui",
-- key_sequence = "CONTROL + T", -- key_sequence = "CONTROL + T",
--}, --},
--{ --{
@@ -376,14 +376,14 @@ data:extend({
-- shortcuts -- shortcuts
{ {
type = "shortcut", type = "shortcut",
name = "ltnm-toggle-gui", name = "cybersyn-toggle-gui",
icon = data_util.build_sprite(nil, { 0, 0 }, util.paths.shortcut_icons, 32, 2), icon = data_util.build_sprite(nil, { 0, 0 }, util.paths.shortcut_icons, 32, 2),
disabled_icon = data_util.build_sprite(nil, { 48, 0 }, util.paths.shortcut_icons, 32, 2), disabled_icon = data_util.build_sprite(nil, { 48, 0 }, util.paths.shortcut_icons, 32, 2),
small_icon = data_util.build_sprite(nil, { 0, 32 }, util.paths.shortcut_icons, 24, 2), small_icon = data_util.build_sprite(nil, { 0, 32 }, util.paths.shortcut_icons, 24, 2),
disabled_small_icon = data_util.build_sprite(nil, { 36, 32 }, util.paths.shortcut_icons, 24, 2), disabled_small_icon = data_util.build_sprite(nil, { 36, 32 }, util.paths.shortcut_icons, 24, 2),
toggleable = true, toggleable = true,
action = "lua", action = "lua",
--associated_control_input = "ltnm-toggle-gui", --associated_control_input = "cybersyn-toggle-gui",
technology_to_unlock = "cybersyn-train-network", technology_to_unlock = "cybersyn-train-network",
}, },
}) })

View File

@@ -12,7 +12,7 @@ function alerts_tab.build(widths)
return { return {
tab = { tab = {
type = "tab", type = "tab",
caption = { "gui.ltnm-alerts" }, caption = { "cybersyn-gui.alerts" },
ref = { "alerts", "tab" }, ref = { "alerts", "tab" },
actions = { actions = {
on_click = { gui = "main", action = "change_tab", tab = "alerts" }, on_click = { gui = "main", action = "change_tab", tab = "alerts" },
@@ -36,7 +36,7 @@ function alerts_tab.build(widths)
type = "sprite-button", type = "sprite-button",
style = "tool_button_red", style = "tool_button_red",
sprite = "utility/trash", sprite = "utility/trash",
tooltip = { "gui.ltnm-delete-all-alerts" }, tooltip = { "cybersyn-gui.delete-all-alerts" },
ref = { "alerts", "delete_all_button" }, ref = { "alerts", "delete_all_button" },
actions = { actions = {
on_click = { gui = "main", action = "delete_all_alerts" }, on_click = { gui = "main", action = "delete_all_alerts" },
@@ -52,7 +52,7 @@ function alerts_tab.build(widths)
{ {
type = "label", type = "label",
style = "ltnm_semibold_label", style = "ltnm_semibold_label",
caption = { "gui.ltnm-no-alerts" }, caption = { "cybersyn-gui.no-alerts" },
ref = { "alerts", "warning_label" }, ref = { "alerts", "warning_label" },
}, },
}, },
@@ -121,7 +121,7 @@ function alerts_tab.update(self)
type = "label", type = "label",
style = "ltnm_clickable_semibold_label", style = "ltnm_clickable_semibold_label",
style_mods = { width = widths.alerts.train_id, horizontal_align = "center" }, style_mods = { width = widths.alerts.train_id, horizontal_align = "center" },
tooltip = { "gui.ltnm-open-train-gui" }, tooltip = { "cybersyn-gui.open-train-gui" },
}, },
{ {
type = "flow", type = "flow",
@@ -153,7 +153,7 @@ function alerts_tab.update(self)
type = "sprite-button", type = "sprite-button",
style = "tool_button_red", style = "tool_button_red",
sprite = "utility/trash", sprite = "utility/trash",
tooltip = { "gui.ltnm-delete-alert" }, tooltip = { "cybersyn-gui.delete-alert" },
}, },
}) })
end end
@@ -185,8 +185,8 @@ function alerts_tab.update(self)
{ elem_mods = { caption = util.signed_int32(alerts_entry.train.network_id) } }, { elem_mods = { caption = util.signed_int32(alerts_entry.train.network_id) } },
{ {
elem_mods = { elem_mods = {
caption = { "gui.ltnm-alert-" .. string.gsub(alerts_entry.type, "_", "-") }, caption = { "cybersyn-gui.alert-" .. string.gsub(alerts_entry.type, "_", "-") },
tooltip = { "gui.ltnm-alert-" .. string.gsub(alerts_entry.type, "_", "-") .. "-description" }, tooltip = { "cybersyn-gui.alert-" .. string.gsub(alerts_entry.type, "_", "-") .. "-description" },
}, },
}, },
{}, {},

View File

@@ -85,14 +85,14 @@ constants.gui_content_frame_height = 744
constants.gui_inventory_table_height = 40 * 18 constants.gui_inventory_table_height = 40 * 18
constants.gui_translations = { constants.gui_translations = {
delivering_to = { "gui.ltnm-delivering-to" }, delivering_to = { "cybersyn-gui.delivering-to" },
fetching_from = { "gui.ltnm-fetching-from" }, fetching_from = { "cybersyn-gui.fetching-from" },
loading_at = { "gui.ltnm-loading-at" }, loading_at = { "cybersyn-gui.loading-at" },
not_available = { "gui.ltnm-not-available" }, not_available = { "cybersyn-gui.not-available" },
parked_at_depot_with_residue = { "gui.ltnm-parked-at-depot-with-residue" }, parked_at_depot_with_residue = { "cybersyn-gui.parked-at-depot-with-residue" },
parked_at_depot = { "gui.ltnm-parked-at-depot" }, parked_at_depot = { "cybersyn-gui.parked-at-depot" },
returning_to_depot = { "gui.ltnm-returning-to-depot" }, returning_to_depot = { "cybersyn-gui.returning-to-depot" },
unloading_at = { "gui.ltnm-unloading-at" }, unloading_at = { "cybersyn-gui.unloading-at" },
} }
constants.input_sanitizers = { constants.input_sanitizers = {
@@ -144,8 +144,8 @@ constants.ltn_event_names = {
if script then if script then
constants.open_station_gui_tooltip = { constants.open_station_gui_tooltip = {
"", "",
{ "gui.ltnm-open-station-gui" }, { "cybersyn-gui.open-station-gui" },
remote.interfaces["ltn-combinator"] and { "", "\n", { "gui.ltnm-open-ltn-combinator-gui" } } or nil, remote.interfaces["ltn-combinator"] and { "", "\n", { "cybersyn-gui.open-ltn-combinator-gui" } } or nil,
} }
end end

View File

@@ -8,7 +8,7 @@ function depots_tab.build(widths)
return { return {
tab = { tab = {
type = "tab", type = "tab",
caption = { "gui.ltnm-depots" }, caption = { "cybersyn-gui.depots" },
ref = { "depots", "tab" }, ref = { "depots", "tab" },
actions = { actions = {
on_click = { gui = "main", action = "change_tab", tab = "depots" }, on_click = { gui = "main", action = "change_tab", tab = "depots" },
@@ -25,7 +25,7 @@ function depots_tab.build(widths)
style_mods = { right_padding = 4 }, style_mods = { right_padding = 4 },
templates.sort_checkbox(widths, "depots", "name", true, nil, true), templates.sort_checkbox(widths, "depots", "name", true, nil, true),
templates.sort_checkbox(widths, "depots", "network_id", false), templates.sort_checkbox(widths, "depots", "network_id", false),
templates.sort_checkbox(widths, "depots", "status", false, { "gui.ltnm-status-description" }), templates.sort_checkbox(widths, "depots", "status", false, { "cybersyn-gui.status-description" }),
templates.sort_checkbox(widths, "depots", "trains", false), templates.sort_checkbox(widths, "depots", "trains", false),
}, },
{ type = "scroll-pane", style = "ltnm_table_scroll_pane", ref = { "depots", "scroll_pane" } }, { type = "scroll-pane", style = "ltnm_table_scroll_pane", ref = { "depots", "scroll_pane" } },
@@ -37,7 +37,7 @@ function depots_tab.build(widths)
{ {
type = "label", type = "label",
style = "ltnm_semibold_label", style = "ltnm_semibold_label",
caption = { "gui.ltnm-no-depots" }, caption = { "cybersyn-gui.no-depots" },
ref = { "depots", "warning_label" }, ref = { "depots", "warning_label" },
}, },
}, },

View File

@@ -12,7 +12,7 @@ function history_tab.build(widths)
return { return {
tab = { tab = {
type = "tab", type = "tab",
caption = { "gui.ltnm-history" }, caption = { "cybersyn-gui.history" },
ref = { "history", "tab" }, ref = { "history", "tab" },
actions = { actions = {
on_click = { gui = "main", action = "change_tab", tab = "history" }, on_click = { gui = "main", action = "change_tab", tab = "history" },
@@ -38,7 +38,7 @@ function history_tab.build(widths)
type = "sprite-button", type = "sprite-button",
style = "tool_button_red", style = "tool_button_red",
sprite = "utility/trash", sprite = "utility/trash",
tooltip = { "gui.ltnm-clear-history" }, tooltip = { "cybersyn-gui.clear-history" },
ref = { "history", "clear_button" }, ref = { "history", "clear_button" },
actions = { actions = {
on_click = { gui = "main", action = "clear_history" }, on_click = { gui = "main", action = "clear_history" },
@@ -54,7 +54,7 @@ function history_tab.build(widths)
{ {
type = "label", type = "label",
style = "ltnm_semibold_label", style = "ltnm_semibold_label",
caption = { "gui.ltnm-no-history" }, caption = { "cybersyn-gui.no-history" },
ref = { "history", "warning_label" }, ref = { "history", "warning_label" },
}, },
}, },

View File

@@ -2,7 +2,7 @@ local gui = require("__flib__.gui-lite")
local util = require("scripts.gui.util") local util = require("scripts.gui.util")
local templates = require("scripts.gui.templates") local templates = require("scripts.gui.templates")
local misc = require("__flib__.misc") local format = require("__flib__.format")
local inventory_tab = {} local inventory_tab = {}
@@ -11,7 +11,7 @@ function inventory_tab.create()
tab = { tab = {
name = "manager_inventory_tab", name = "manager_inventory_tab",
type = "tab", type = "tab",
caption = { "gui.ltnm-inventory" }, caption = { "cybersyn-gui.inventory" },
ref = { "inventory", "tab" }, ref = { "inventory", "tab" },
actions = { actions = {
on_click = { gui = "main", action = "change_tab", tab = "inventory" }, on_click = { gui = "main", action = "change_tab", tab = "inventory" },
@@ -149,7 +149,7 @@ function inventory_tab.build(map_data, player_data)
local i = 0 local i = 0
for item, count in pairs(inventory_provided) do for item, count in pairs(inventory_provided) do
i = i + 1 i = i + 1
local sprite = util.build_sprite_path(item) local sprite, img_path, item_string = util.generate_item_references(item)
if game.is_valid_sprite_path(sprite) then if game.is_valid_sprite_path(sprite) then
provided_children[#provided_children+1] = { provided_children[#provided_children+1] = {
type = "sprite-button", type = "sprite-button",
@@ -157,12 +157,13 @@ function inventory_tab.build(map_data, player_data)
enabled = false, enabled = false,
sprite = sprite, sprite = sprite,
number = count, number = count,
tooltip = "[img=" tooltip = { "",
.. string.gsub(item, ",", "/") img_path,
.. "] [font=default-semibold]" " [font=default-semibold]",
.. item { item_string },
.. "[/font]\n" "[/font]\n"..format.number(count),
.. misc.delineate_number(count)} },
}
end end
end end
@@ -172,7 +173,7 @@ function inventory_tab.build(map_data, player_data)
local i = 0 local i = 0
for item, count in pairs(inventory_requested) do for item, count in pairs(inventory_requested) do
i = i + 1 i = i + 1
local sprite = util.build_sprite_path(item) local sprite, img_path, item_string = util.generate_item_references(item)
if game.is_valid_sprite_path(sprite) then if game.is_valid_sprite_path(sprite) then
requested_children[#requested_children+1] = { requested_children[#requested_children+1] = {
type = "sprite-button", type = "sprite-button",
@@ -180,12 +181,13 @@ function inventory_tab.build(map_data, player_data)
enabled = false, enabled = false,
sprite = sprite, sprite = sprite,
number = count, number = count,
tooltip = "[img=" tooltip = { "",
.. string.gsub(item, ",", "/") img_path,
.. "] [font=default-semibold]" " [font=default-semibold]",
.. item { item_string },
.. "[/font]\n" "[/font]\n"..format.number(count),
.. misc.delineate_number(count)} },
}
end end
end end
@@ -195,7 +197,7 @@ function inventory_tab.build(map_data, player_data)
local i = 0 local i = 0
for item, count in pairs(inventory_in_transit) do for item, count in pairs(inventory_in_transit) do
i = i + 1 i = i + 1
local sprite = util.build_sprite_path(item) local sprite, img_path, item_string = util.generate_item_references(item)
if game.is_valid_sprite_path(sprite) then if game.is_valid_sprite_path(sprite) then
in_transit_children[#in_transit_children+1] = { in_transit_children[#in_transit_children+1] = {
type = "sprite-button", type = "sprite-button",
@@ -203,12 +205,13 @@ function inventory_tab.build(map_data, player_data)
enabled = false, enabled = false,
sprite = sprite, sprite = sprite,
number = count, number = count,
tooltip = "[img=" tooltip = { "",
.. string.gsub(item, ",", "/") img_path,
.. "] [font=default-semibold]" " [font=default-semibold]",
.. item { item_string },
.. "[/font]\n" "[/font]\n"..format.number(count),
.. misc.delineate_number(count)} },
}
end end
end end

View File

@@ -46,7 +46,7 @@ end
local manager_gui = {} local manager_gui = {}
function manager_gui.on_lua_shortcut(e) function manager_gui.on_lua_shortcut(e)
if e.prototype_name == "ltnm-toggle-gui" then if e.prototype_name == "cybersyn-toggle-gui" then
manager.wrapper(e, manager.handle.manager_toggle) manager.wrapper(e, manager.handle.manager_toggle)
end end
end end

View File

@@ -36,19 +36,19 @@ function manager.create(player)
style = "flib_titlebar_flow", style = "flib_titlebar_flow",
handler = manager.handle.manager_titlebar_click, handler = manager.handle.manager_titlebar_click,
children = { children = {
{ type = "label", style = "frame_title", caption = { "mod-name.LtnManager" }, ignored_by_interaction = true }, { type = "label", style = "frame_title", caption = { "mod-name.cybersyn" }, ignored_by_interaction = true },
{ type = "empty-widget", style = "flib_titlebar_drag_handle", ignored_by_interaction = true }, { type = "empty-widget", style = "flib_titlebar_drag_handle", ignored_by_interaction = true },
{ {
name = "manager_dispatcher_status_label", name = "manager_dispatcher_status_label",
type = "label", type = "label",
style = "bold_label", style = "bold_label",
style_mods = { font_color = constants.colors.red.tbl, left_margin = -4, top_margin = 1 }, style_mods = { font_color = constants.colors.red.tbl, left_margin = -4, top_margin = 1 },
caption = { "gui.ltnm-dispatcher-disabled" }, caption = { "cybersyn-gui.dispatcher-disabled" },
tooltip = { "gui.ltnm-dispatcher-disabled-description" }, tooltip = { "cybersyn-gui.dispatcher-disabled-description" },
visible = not settings.global["cybersyn-enable-planner"].value, visible = not settings.global["cybersyn-enable-planner"].value,
}, },
templates.frame_action_button("manager_pin_button", "ltnm_pin", { "gui.ltnm-keep-open" }, manager.handle.manager_pin),--on_gui_clicked templates.frame_action_button("manager_pin_button", "ltnm_pin", { "cybersyn-gui.keep-open" }, manager.handle.manager_pin),--on_gui_clicked
templates.frame_action_button("manager_refresh_button", "ltnm_refresh", { "gui.ltnm-refresh-tooltip" }, manager.handle.manager_refresh_click),--on_gui_clicked templates.frame_action_button("manager_refresh_button", "ltnm_refresh", { "cybersyn-gui.refresh-tooltip" }, manager.handle.manager_refresh_click),--on_gui_clicked
templates.frame_action_button(nil, "utility/close", { "gui.close-instruction" }, manager.handle.manager_close),--on_gui_clicked templates.frame_action_button(nil, "utility/close", { "gui.close-instruction" }, manager.handle.manager_close),--on_gui_clicked
}, },
}, },
@@ -61,7 +61,7 @@ function manager.create(player)
type = "frame", type = "frame",
style = "ltnm_main_toolbar_frame", style = "ltnm_main_toolbar_frame",
children = { children = {
{ type = "label", style = "subheader_caption_label", caption = { "gui.ltnm-search-label" } }, { type = "label", style = "subheader_caption_label", caption = { "cybersyn-gui.search-label" } },
{ {
name = "manager_text_search_field", name = "manager_text_search_field",
type = "textfield", type = "textfield",
@@ -69,7 +69,7 @@ function manager.create(player)
handler = manager.handle.manager_update_text_search, --on_gui_text_changed handler = manager.handle.manager_update_text_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 = { "gui.ltnm-network-id-label" } }, { type = "label", style = "caption_label", caption = { "cybersyn-gui.network-id-label" } },
{ {
name = "manager_network_mask_field", name = "manager_network_mask_field",
type = "textfield", type = "textfield",
@@ -80,7 +80,7 @@ function manager.create(player)
text = "-1", text = "-1",
handler = manager.handle.manager_update_network_mask, --on_gui_text_changed handler = manager.handle.manager_update_network_mask, --on_gui_text_changed
}, },
{ type = "label", style = "caption_label", caption = { "gui.ltnm-surface-label" } }, { type = "label", style = "caption_label", caption = { "cybersyn-gui.surface-label" } },
{ {
name = "manager_surface_dropdown", name = "manager_surface_dropdown",
type = "drop-down", type = "drop-down",
@@ -155,7 +155,7 @@ function manager.handle.manager_open(player, player_data, refs)
end end
player_data.is_manager_open = true player_data.is_manager_open = true
player.set_shortcut_toggled("ltnm-toggle-gui", true) player.set_shortcut_toggled("cybersyn-toggle-gui", true)
end end
@@ -175,7 +175,7 @@ function manager.handle.manager_close(player, player_data, refs)
end end
player_data.is_manager_open = false player_data.is_manager_open = false
player.set_shortcut_toggled("ltnm-toggle-gui", false) player.set_shortcut_toggled("cybersyn-toggle-gui", false)
player_data.refs.manager_window.destroy() player_data.refs.manager_window.destroy()

View File

@@ -11,7 +11,7 @@ function stations_tab.create(widths)
tab = { tab = {
name = "manager_stations_tab", name = "manager_stations_tab",
type = "tab", type = "tab",
caption = { "gui.ltnm-stations" }, caption = { "cybersyn-gui.stations" },
ref = { "stations", "tab" }, ref = { "stations", "tab" },
actions = { actions = {
on_click = { gui = "main", action = "change_tab", tab = "stations" }, on_click = { gui = "main", action = "change_tab", tab = "stations" },
@@ -27,16 +27,16 @@ function stations_tab.create(widths)
type = "frame", type = "frame",
style = "ltnm_table_toolbar_frame", style = "ltnm_table_toolbar_frame",
templates.sort_checkbox(widths, "stations", "name", true), templates.sort_checkbox(widths, "stations", "name", true),
templates.sort_checkbox(widths, "stations", "status", false, { "gui.ltnm-status-description" }), templates.sort_checkbox(widths, "stations", "status", false), --repurposed status column, description no longer necessary
templates.sort_checkbox(widths, "stations", "network_id", false), templates.sort_checkbox(widths, "stations", "network_id", false),
templates.sort_checkbox( templates.sort_checkbox(
widths, widths,
"stations", "stations",
"provided_requested", "provided_requested",
false, false,
{ "gui.ltnm-provided-requested-description" } { "cybersyn-gui-provided-requested-description" }
), ),
templates.sort_checkbox(widths, "stations", "shipments", false, { "gui.ltnm-shipments-description" }), templates.sort_checkbox(widths, "stations", "shipments", false, { "cybersyn-gui-shipments-description" }),
templates.sort_checkbox(widths, "stations", "control_signals", false), templates.sort_checkbox(widths, "stations", "control_signals", false),
}, },
{ name = "manager_stations_tab_scroll_pane", type = "scroll-pane", style = "ltnm_table_scroll_pane", ref = { "stations", "scroll_pane" } }, { name = "manager_stations_tab_scroll_pane", type = "scroll-pane", style = "ltnm_table_scroll_pane", ref = { "stations", "scroll_pane" } },
@@ -48,7 +48,7 @@ function stations_tab.create(widths)
{ {
type = "label", type = "label",
style = "ltnm_semibold_label", style = "ltnm_semibold_label",
caption = { "gui.ltnm-no-stations" }, caption = { "cybersyn-gui-no-stations" },
ref = { "stations", "warning_label" }, ref = { "stations", "warning_label" },
}, },
}, },

View File

@@ -30,7 +30,7 @@ function templates.inventory_slot_table(name, columns)
return { return {
type = "flow", type = "flow",
direction = "vertical", direction = "vertical",
{ type = "label", style = "bold_label", caption = { "gui.ltnm-" .. string.gsub(name, "_", "-") } }, { type = "label", style = "bold_label", caption = { "cybersyn-gui." .. string.gsub(name, "_", "-") } },
{ {
type = "frame", type = "frame",
style = "deep_frame_in_shallow_frame", style = "deep_frame_in_shallow_frame",
@@ -77,7 +77,7 @@ function templates.sort_checkbox(widths, tab, column, selected, tooltip, state)
type = "checkbox", type = "checkbox",
style = selected and "ltnm_selected_sort_checkbox" or "ltnm_sort_checkbox", style = selected and "ltnm_selected_sort_checkbox" or "ltnm_sort_checkbox",
style_mods = { width = widths and widths[tab][column] or nil, horizontally_stretchable = not widths }, style_mods = { width = widths and widths[tab][column] or nil, horizontally_stretchable = not widths },
caption = { "gui.ltnm-" .. string.gsub(column, "_", "-") }, caption = { "cybersyn-gui." .. string.gsub(column, "_", "-") },
tooltip = tooltip, tooltip = tooltip,
state = state, state = state,
ref = { tab, "toolbar", column .. "_checkbox" }, ref = { tab, "toolbar", column .. "_checkbox" },

View File

@@ -133,7 +133,7 @@ function trains_tab.build(map_data, player_data)
train_list[1] = { train_list[1] = {
type = "label", type = "label",
style = "ltnm_semibold_label", style = "ltnm_semibold_label",
caption = { "gui.ltnm-no-trains" }, caption = { "cybersyn-gui.no-trains" },
} }
else else
for idx, train_id in ipairs(trains_sorted) do for idx, train_id in ipairs(trains_sorted) do
@@ -156,7 +156,7 @@ function trains_tab.build(map_data, player_data)
{ {
type = "button", type = "button",
style = "ltnm_train_minimap_button", style = "ltnm_train_minimap_button",
tooltip = { "gui.ltnm-open-train-gui" }, tooltip = { "cybersyn-gui.open-train-gui" },
elem_mods = { entity = get_any_train_entity(train.entity) }, elem_mods = { entity = get_any_train_entity(train.entity) },
handler = trains_tab.handle.open_train_gui, --on_click handler = trains_tab.handle.open_train_gui, --on_click
tags = { train_id = train_id }, tags = { train_id = train_id },
@@ -197,7 +197,7 @@ function trains_tab.build(map_data, player_data)
tab = { tab = {
name = "trains_tab", name = "trains_tab",
type = "tab", type = "tab",
caption = #trains_sorted == 0 and { "gui.ltnm-trains" } or { "gui.ltnm-trains", #train_list }, caption = #trains_sorted == 0 and { "cybersyn-gui.trains" } or { "cybersyn-gui.trains", #train_list },
--badge_text = format.number(#ltn_data.sorted_trains.composition), --badge_text = format.number(#ltn_data.sorted_trains.composition),
handler = trains_tab.handle.change_tab, --on_click handler = trains_tab.handle.change_tab, --on_click
tags = { tab = "trains_tab" }, tags = { tab = "trains_tab" },
@@ -212,7 +212,7 @@ function trains_tab.build(map_data, player_data)
type = "frame", type = "frame",
style = "ltnm_table_toolbar_frame", style = "ltnm_table_toolbar_frame",
templates.sort_checkbox(widths, "trains", "status", false), templates.sort_checkbox(widths, "trains", "status", false),
templates.sort_checkbox(widths, "trains", "layout", false, { "gui.ltnm-composition-description" }), templates.sort_checkbox(widths, "trains", "layout", false, { "cybersyn-gui.composition-description" }),
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),
}, },

View File

@@ -35,15 +35,21 @@ end
--- Builds a valid sprite path or returns nil --- Builds a valid sprite path or returns nil
--- @param item string --- @param item string
--- @return string --- @return string, string, string
function util.build_sprite_path(item) function util.generate_item_references(item)
local sprite = nil local sprite = nil
local image_path = ""
local item_name = ""
if game.is_valid_sprite_path("item/" .. item) then if game.is_valid_sprite_path("item/" .. item) then
sprite = "item/" .. item sprite = "item/" .. item
image_path = "[img=item." .. item .. "]"
item_name = "item-name." .. item
elseif game.is_valid_sprite_path("fluid/" .. item) then elseif game.is_valid_sprite_path("fluid/" .. item) then
sprite = "fluid/" .. item sprite = "fluid/" .. item
image_path = "[img=fluid." .. item .. "]"
item_name = "fluid-name." .. item
end end
return sprite return sprite, image_path, item_name
end end
@@ -92,7 +98,7 @@ function util.slot_table_build_from_station(station)
local item = v.signal local item = v.signal
local count = v.count local count = v.count
local name = item.name local name = item.name
local sprite = util.build_sprite_path(name) local sprite, img_path, item_string = util.generate_item_references(name)
if sprite ~= nil then if sprite ~= nil then
local color local color
if count > 0 then if count > 0 then
@@ -108,8 +114,8 @@ function util.slot_table_build_from_station(station)
sprite = sprite, sprite = sprite,
tooltip = { tooltip = {
"", "",
"[img=" .. sprite .. "]", img_path,
{ "item-name." .. name }, { item_string },
"\n"..format.number(count), "\n"..format.number(count),
}, },
number = count number = count
@@ -128,7 +134,7 @@ function util.slot_table_build_from_deliveries(station)
for item, count in pairs(deliveries) do for item, count in pairs(deliveries) do
local sprite = util.build_sprite_path(item) local sprite, img_path, item_string = util.generate_item_references(item)
if sprite ~= nil then if sprite ~= nil then
local color local color
if count > 0 then if count > 0 then
@@ -144,8 +150,8 @@ function util.slot_table_build_from_deliveries(station)
sprite = sprite, sprite = sprite,
tooltip = { tooltip = {
"", "",
"[img=" .. sprite .. "]", img_path,
{ item }, { item_string },
"\n"..format.number(count), "\n"..format.number(count),
}, },
number = count number = count
@@ -182,8 +188,8 @@ function util.slot_table_build_from_control_signals(station)
sprite = sprite, sprite = sprite,
tooltip = { tooltip = {
"", "",
"[img=" .. sprite .. "]", "[img=virtual-signal." .. name .. "]",
{ "item-name." .. name }, { "virtual-signal-name." .. name },
"\n"..format.number(count), "\n"..format.number(count),
}, },
number = count number = count