mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-08-13 00:45:11 +09:00
Make the @as casts actually apply
emmylua only parses the inline cast as `--[[@as T]]`, the spaced form `--[[ @as T ]]` is treated as a plain comment, so all 149 of them were doing nothing. LuaGuiElement.style is a union because a style name can be assigned to it, so reading it back needs the cast. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -90,7 +90,7 @@ Elements.toggle_section_button = Gui.define("rocket_info/toggle_section_button")
|
||||
element.sprite = "utility/expand"
|
||||
element.tooltip = { "exp-gui_rocket-info.tooltip-toggle-section-expand" }
|
||||
end
|
||||
end) --[[ @as any ]]
|
||||
end) --[[@as any]]
|
||||
|
||||
--- A clickable coordinate label which opens the silo location on the map when pressed
|
||||
--- @class ExpGui_RocketInfo.elements.position_label: ExpElement
|
||||
@@ -114,7 +114,7 @@ Elements.position_label = Gui.define("rocket_info/position_label")
|
||||
local entity = def.data[element]
|
||||
if not entity or not entity.valid then return end
|
||||
player.set_controller{ type = defines.controllers.remote, position = entity.position, surface = entity.surface }
|
||||
end) --[[ @as any ]]
|
||||
end) --[[@as any]]
|
||||
|
||||
--- Data table showing the launch statistics for a force
|
||||
--- @class ExpGui_RocketInfo.elements.stats_table: ExpElement
|
||||
@@ -125,7 +125,7 @@ Elements.stats_table = Gui.define("rocket_info/stats_table")
|
||||
:element_data{}
|
||||
:draw(function(def, parent)
|
||||
return Gui.elements.scroll_table(parent, 215, 2)
|
||||
end) --[[ @as any ]]
|
||||
end) --[[@as any]]
|
||||
|
||||
--- @class ExpGui_RocketInfo.elements.stats_table.row_data
|
||||
--- @field key string Unique key used to look up the value label
|
||||
@@ -218,7 +218,7 @@ end
|
||||
--- Refresh the stats table for a player, adding any rows that do not yet exist
|
||||
--- @param player LuaPlayer
|
||||
function Elements.stats_table.refresh_player(player)
|
||||
local force = player.force --[[ @as LuaForce ]]
|
||||
local force = player.force --[[@as LuaForce]]
|
||||
local row_data = Elements.stats_table.calculate_row_data(force)
|
||||
for _, stats_table in Elements.stats_table:online_elements(player) do
|
||||
Elements.stats_table.refresh(stats_table, row_data)
|
||||
@@ -243,7 +243,7 @@ Elements.milestones_table = Gui.define("rocket_info/milestones_table")
|
||||
:element_data{}
|
||||
:draw(function(def, parent)
|
||||
return Gui.elements.scroll_table(parent, 215, 2)
|
||||
end) --[[ @as any ]]
|
||||
end) --[[@as any]]
|
||||
|
||||
--- @class ExpGui_RocketInfo.elements.milestones_table.row_data
|
||||
--- @field milestone number The milestone this row represents
|
||||
@@ -315,7 +315,7 @@ end
|
||||
--- Refresh the milestones table for a player, adding rows as new milestones become visible
|
||||
--- @param player LuaPlayer
|
||||
function Elements.milestones_table.refresh_player(player)
|
||||
local force = player.force --[[ @as LuaForce ]]
|
||||
local force = player.force --[[@as LuaForce]]
|
||||
local row_data = Elements.stats_table.calculate_row_data(force)
|
||||
for _, stats_table in Elements.stats_table:online_elements(player) do
|
||||
Elements.stats_table.refresh(stats_table, row_data)
|
||||
@@ -359,7 +359,7 @@ Elements.progress_table = Gui.define("rocket_info/progress_table")
|
||||
|
||||
def.data[progress_table] = { rows = {}, no_silos = no_silos }
|
||||
return progress_table
|
||||
end) --[[ @as any ]]
|
||||
end) --[[@as any]]
|
||||
|
||||
--- @class ExpGui_RocketInfo.elements.progress_table.row_data
|
||||
--- @field entity LuaEntity
|
||||
@@ -500,7 +500,7 @@ end
|
||||
--- Refresh the progress table for a player, reconciling rows with the current set of silos
|
||||
--- @param player LuaPlayer
|
||||
function Elements.progress_table.refresh_player(player)
|
||||
local force = player.force --[[ @as LuaForce ]]
|
||||
local force = player.force --[[@as LuaForce]]
|
||||
local silos = Elements.container.get_silos(force)
|
||||
local row_data = Elements.progress_table.calculate_row_data_all(silos)
|
||||
for _, progress_table in Elements.progress_table:online_elements(player) do
|
||||
@@ -543,7 +543,7 @@ Elements.container = Gui.define("rocket_info/container")
|
||||
container.style.padding = 0
|
||||
|
||||
local player = Gui.get_player(parent)
|
||||
local force = player.force --[[ @as LuaForce ]]
|
||||
local force = player.force --[[@as LuaForce]]
|
||||
local force_data = def._get_force_data(force)
|
||||
|
||||
if config.stats.show_stats then
|
||||
@@ -622,7 +622,7 @@ end
|
||||
--- Add a silo to the list of current silos for a force
|
||||
--- @param entity LuaEntity
|
||||
function Elements.container.add_silo(entity)
|
||||
local force = entity.force --[[ @as LuaForce ]]
|
||||
local force = entity.force --[[@as LuaForce]]
|
||||
local silos = Elements.container._get_force_data(force).silos
|
||||
local unit_number = entity.unit_number
|
||||
--- @cast unit_number uint
|
||||
@@ -636,7 +636,7 @@ end
|
||||
--- Increment the launch count for a silo
|
||||
--- @param entity LuaEntity
|
||||
function Elements.container.increment_silo(entity)
|
||||
local force = entity.force --[[ @as LuaForce ]]
|
||||
local force = entity.force --[[@as LuaForce]]
|
||||
local silos = Elements.container._get_force_data(force).silos
|
||||
local unit_number = entity.unit_number
|
||||
--- @cast unit_number uint
|
||||
@@ -696,7 +696,7 @@ end
|
||||
--- @param event EventData.on_rocket_launch_ordered
|
||||
local function on_rocket_launch_ordered(event)
|
||||
Elements.container.increment_silo(event.rocket_silo)
|
||||
Elements.progress_table.refresh_force(event.rocket_silo.force --[[ @as LuaForce ]])
|
||||
Elements.progress_table.refresh_force(event.rocket_silo.force --[[@as LuaForce]])
|
||||
end
|
||||
|
||||
--- Refresh the gui when a player joins the game as it may be outdated
|
||||
@@ -714,7 +714,7 @@ local function on_built(event)
|
||||
local entity = event.entity
|
||||
if not entity.valid or entity.name ~= "rocket-silo" then return end
|
||||
Elements.container.add_silo(entity)
|
||||
Elements.progress_table.refresh_force(entity.force --[[ @as LuaForce ]])
|
||||
Elements.progress_table.refresh_force(entity.force --[[@as LuaForce]])
|
||||
end
|
||||
|
||||
--- Refresh the progress for all forces that own at least one silo
|
||||
|
||||
Reference in New Issue
Block a user