Refactor Selection Util (#409)
* Add Selection to ExpUtil * Convert modules to use new lib * Bug Fixes
This commit is contained in:
@@ -5,8 +5,9 @@ Adds a Gui which creates an selection planner to insert modules into buildings
|
||||
local Gui = require("modules/exp_gui")
|
||||
local AABB = require("modules/exp_util/aabb")
|
||||
local Roles = require("modules/exp_legacy/expcore/roles")
|
||||
local Selection = require("modules/exp_legacy/modules/control/selection")
|
||||
local SelectionModuleArea = "ModuleArea"
|
||||
|
||||
local Selection = require("modules/exp_util/selection")
|
||||
local SelectArea = Selection.connect("ModuleArea")
|
||||
|
||||
local config = require("modules/exp_legacy/config/module")
|
||||
|
||||
@@ -76,7 +77,7 @@ Elements.create_selection_planner = Gui.define("module_inserter/create_selection
|
||||
)
|
||||
:on_click(function(def, player, element)
|
||||
--- @cast def ExpGui_ModuleInserter.elements.create_selection_planner
|
||||
Selection.start(player, SelectionModuleArea, false, def.data[element])
|
||||
SelectArea:start(player, def.data[element])
|
||||
end) --[[ @as any ]]
|
||||
|
||||
--- Used to select the machine to apply modules to
|
||||
@@ -311,7 +312,7 @@ end
|
||||
--- When an area is selected to have module changes applied to it
|
||||
--- @param event EventData.on_player_selected_area
|
||||
--- @param module_table LuaGuiElement
|
||||
Selection.on_selection(SelectionModuleArea, function(event, module_table)
|
||||
SelectArea:on_selection(function(event, module_table)
|
||||
local player = Gui.get_player(event)
|
||||
local area = AABB.expand(event.area)
|
||||
|
||||
|
||||
@@ -301,8 +301,9 @@ end
|
||||
--- @param force LuaForce
|
||||
--- @return number
|
||||
function Elements.container.calculate_starting_research_index(force)
|
||||
local force_data = Elements.container.data[force]
|
||||
local force_data = Elements.container.data[force] or {}
|
||||
local research_index = research_targets.length
|
||||
Elements.container.data[force] = force_data -- needed because of @clusterio/research_sync
|
||||
|
||||
-- # does not work here because it returned the array alloc size
|
||||
for i = 1, research_targets.length do
|
||||
|
||||
Reference in New Issue
Block a user