This commit is contained in:
phidias authored and GitHub committed 2026-11-10 02:11:24 +09:00
1 parent ceb306cf57
commit 131d3e41f2
2 files changed
+17 -6

No files matched your search

+1 -1
View File
@@ -700,7 +700,7 @@ end
local function update_surface(event) local function update_surface(event)
-- global surface will have its data point to the main surface -- global surface will have its data point to the main surface
if not config.global_surface then if config.global_surface then
return return
end end
if not vlayer_data[event.surface_index] then if not vlayer_data[event.surface_index] then
+16 -5
View File
@@ -32,7 +32,7 @@ end
--- Statistics shown as progress bars, in display order --- Statistics shown as progress bars, in display order
--- @type { name: string, caption: LocalisedString, tooltip: LocalisedString }[] --- @type { name: string, caption: LocalisedString, tooltip: LocalisedString }[]
local stats = {} local stats = {}
for _, name in ipairs{ "production", "capacity", "sustained", "surface-area" } do for _, name in ipairs{ "sustained", "production", "capacity", "surface-area" } do
stats[#stats + 1] = { stats[#stats + 1] = {
name = name, name = name,
caption = { "exp-gui_vlayer.caption-stat-" .. name }, caption = { "exp-gui_vlayer.caption-stat-" .. name },
@@ -144,6 +144,10 @@ function Elements.stats_table.calculate_display_data()
local items = Vlayer.get_items(game.surfaces["nauvis"].index) local items = Vlayer.get_items(game.surfaces["nauvis"].index)
local allocated = Vlayer.get_allocated_items(game.surfaces["nauvis"].index) local allocated = Vlayer.get_allocated_items(game.surfaces["nauvis"].index)
return { return {
sustained = {
value = ceil(statistics.energy_sustained) / max(statistics.energy_total_production, 1),
caption = format_energy(statistics.energy_sustained, "W") .. " / " .. format_energy(statistics.energy_total_production, "W"),
},
production = { production = {
value = ceil(statistics.energy_production) / max(ceil(statistics.energy_max), 1), value = ceil(statistics.energy_production) / max(ceil(statistics.energy_max), 1),
caption = format_energy(statistics.energy_production, "W") .. " / " .. format_energy(statistics.energy_max, "W"), caption = format_energy(statistics.energy_production, "W") .. " / " .. format_energy(statistics.energy_max, "W"),
@@ -152,10 +156,6 @@ function Elements.stats_table.calculate_display_data()
value = statistics.energy_storage / max(statistics.energy_capacity, 1), value = statistics.energy_storage / max(statistics.energy_capacity, 1),
caption = format_energy(statistics.energy_storage, "J") .. " / " .. format_energy(statistics.energy_capacity, "J"), caption = format_energy(statistics.energy_storage, "J") .. " / " .. format_energy(statistics.energy_capacity, "J"),
}, },
sustained = {
value = ceil(statistics.energy_sustained) / max(statistics.energy_total_production, 1),
caption = format_energy(statistics.energy_sustained, "W") .. " / " .. format_energy(statistics.energy_total_production, "W"),
},
["surface-area"] = { ["surface-area"] = {
value = statistics.total_surface_area / max(statistics.surface_area, 1), value = statistics.total_surface_area / max(statistics.surface_area, 1),
caption = format_number(statistics.remaining_surface_area, false), caption = format_number(statistics.remaining_surface_area, false),
@@ -480,10 +480,21 @@ local function refresh_player_permissions(event)
Elements.controls.refresh_permissions(Gui.get_player(event)) Elements.controls.refresh_permissions(Gui.get_player(event))
end end
--- Refresh the dropdown list when surface is updated
local function update_surface(event)
-- global surface will have its data point to the main surface
if config.global_surface then
return
end
end
return feature:guard{ return feature:guard{
elements = Elements, elements = Elements,
events = { events = {
[Roles.events.on_player_roles_changed] = refresh_player_permissions, [Roles.events.on_player_roles_changed] = refresh_player_permissions,
[e.on_surface_created] = update_surface
[e.on_surface_renamed] = update_surface
[e.on_surface_imported] = update_surface
}, },
on_nth_tick = { on_nth_tick = {
[60] = Elements.stats_table.refresh_online, [60] = Elements.stats_table.refresh_online,