Skip to content

Commit

Permalink
Add initial support for logistic groups
Browse files Browse the repository at this point in the history
Can now link the CS signals to a logistic group.
  • Loading branch information
Sharparam committed Nov 7, 2024
1 parent 3368589 commit 87583ea
Show file tree
Hide file tree
Showing 3 changed files with 563 additions and 6 deletions.
29 changes: 29 additions & 0 deletions src/control.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
local constants = require "scripts.constants"
local config = require "scripts.config"
local log = require("scripts.logger").control
local cc_util = require "scripts.cc_util"
local cc_gui = require "scripts.gui"
local cc_remote = require "scripts.remote"
local CybersynCombinator = require "scripts.combinator"
Expand Down Expand Up @@ -50,6 +51,7 @@ script.on_configuration_changed(function(data)
-- end
if not cc_changes then return end
for player_index, player in pairs(game.players) do
player.request_translation({ "gui-train.empty-train-group" })
if player.gui.screen[cc_gui.WINDOW_ID] then
cc_gui:close(player_index, true)
end
Expand Down Expand Up @@ -178,6 +180,33 @@ script.on_event(defines.events.on_entity_settings_pasted, function(event)
dest_combinator:set_section_index(CybersynCombinator.NETWORK_SECTION_ID, src_combinator:get_or_create_section(CybersynCombinator.NETWORK_SECTION_ID).index)
end)

script.on_event(defines.events.on_string_translated, function(event)
log:debug("on_string_translated: ", serpent.line(event))
if not event.translated then return end
if not type(event.localised_string) == "table" then return end
local key = event.localised_string[1]
if key ~= "gui-train.empty-train-group" then return end
local player_data = cc_util.get_player_data(event.player_index)
if not player_data then return end
if not player_data.translations then player_data.translations = {} end
player_data.translations[key] = event.result
log:debug("on_string_translated: ", key, " = ", event.result)
end)

script.on_event(defines.events.on_player_joined_game, function(event)
local player = game.get_player(event.player_index)
if not player then return end
log:debug("Player ", event.player_index, " joined, requesting translation")
player.request_translation({ "gui-train.empty-train-group" })
end)

script.on_event(defines.events.on_player_locale_changed, function(event)
local player = game.get_player(event.player_index)
if not player then return end
log:debug("Locale changed for player ", event.player_index, ", requesting translation")
player.request_translation({ "gui-train.empty-train-group" })
end)

local function sort_combinator(command)
local player = game.get_player(command.player_index)
if not player then return end
Expand Down
10 changes: 10 additions & 0 deletions src/prototypes/styles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ styles["cybersyn-combinator_network-list_item-active"] = {
default_vertical_offset = styles.button.selected_vertical_offset
}

styles["cybersyn-combinator_group-list_scroll-pane"] = {
type = "scroll_pane_style",
parent = "list_box_in_shallow_frame_under_subheader_scroll_pane",
padding = 0,
vertical_flow_style = {
type = "vertical_flow_style",
vertical_spacing = 0
}
}

styles["cybersyn-combinator_frame_semitransparent"] = {
type = "frame_style",
graphical_set = {
Expand Down
Loading

0 comments on commit 87583ea

Please sign in to comment.