Skip to content

Commit 87583ea

Browse files
committed
Add initial support for logistic groups
Can now link the CS signals to a logistic group.
1 parent 3368589 commit 87583ea

File tree

3 files changed

+563
-6
lines changed

3 files changed

+563
-6
lines changed

src/control.lua

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
local constants = require "scripts.constants"
22
local config = require "scripts.config"
33
local log = require("scripts.logger").control
4+
local cc_util = require "scripts.cc_util"
45
local cc_gui = require "scripts.gui"
56
local cc_remote = require "scripts.remote"
67
local CybersynCombinator = require "scripts.combinator"
@@ -50,6 +51,7 @@ script.on_configuration_changed(function(data)
5051
-- end
5152
if not cc_changes then return end
5253
for player_index, player in pairs(game.players) do
54+
player.request_translation({ "gui-train.empty-train-group" })
5355
if player.gui.screen[cc_gui.WINDOW_ID] then
5456
cc_gui:close(player_index, true)
5557
end
@@ -178,6 +180,33 @@ script.on_event(defines.events.on_entity_settings_pasted, function(event)
178180
dest_combinator:set_section_index(CybersynCombinator.NETWORK_SECTION_ID, src_combinator:get_or_create_section(CybersynCombinator.NETWORK_SECTION_ID).index)
179181
end)
180182

183+
script.on_event(defines.events.on_string_translated, function(event)
184+
log:debug("on_string_translated: ", serpent.line(event))
185+
if not event.translated then return end
186+
if not type(event.localised_string) == "table" then return end
187+
local key = event.localised_string[1]
188+
if key ~= "gui-train.empty-train-group" then return end
189+
local player_data = cc_util.get_player_data(event.player_index)
190+
if not player_data then return end
191+
if not player_data.translations then player_data.translations = {} end
192+
player_data.translations[key] = event.result
193+
log:debug("on_string_translated: ", key, " = ", event.result)
194+
end)
195+
196+
script.on_event(defines.events.on_player_joined_game, function(event)
197+
local player = game.get_player(event.player_index)
198+
if not player then return end
199+
log:debug("Player ", event.player_index, " joined, requesting translation")
200+
player.request_translation({ "gui-train.empty-train-group" })
201+
end)
202+
203+
script.on_event(defines.events.on_player_locale_changed, function(event)
204+
local player = game.get_player(event.player_index)
205+
if not player then return end
206+
log:debug("Locale changed for player ", event.player_index, ", requesting translation")
207+
player.request_translation({ "gui-train.empty-train-group" })
208+
end)
209+
181210
local function sort_combinator(command)
182211
local player = game.get_player(command.player_index)
183212
if not player then return end

src/prototypes/styles.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ styles["cybersyn-combinator_network-list_item-active"] = {
8989
default_vertical_offset = styles.button.selected_vertical_offset
9090
}
9191

92+
styles["cybersyn-combinator_group-list_scroll-pane"] = {
93+
type = "scroll_pane_style",
94+
parent = "list_box_in_shallow_frame_under_subheader_scroll_pane",
95+
padding = 0,
96+
vertical_flow_style = {
97+
type = "vertical_flow_style",
98+
vertical_spacing = 0
99+
}
100+
}
101+
92102
styles["cybersyn-combinator_frame_semitransparent"] = {
93103
type = "frame_style",
94104
graphical_set = {

0 commit comments

Comments
 (0)