This commit is contained in:
phidias authored and GitHub committed 2026-11-12 23:26:05 +09:00
1 parent 8e10278f0d
commit fd6f2de8f9
1 file changed
+23 -45
+23 -45
View File
@@ -123,7 +123,6 @@ Elements.stat_bar = Gui.define("vlayer/stat_bar")
--- @class ExpGui_Vlayer.elements.stat_bar.display_data --- @class ExpGui_Vlayer.elements.stat_bar.display_data
--- @field value number Fraction the bar is filled --- @field value number Fraction the bar is filled
--- @field caption string --- @field caption string
--- @field tooltip string
--- Refresh a bar --- Refresh a bar
--- @param stat_bar LuaGuiElement --- @param stat_bar LuaGuiElement
@@ -131,7 +130,6 @@ Elements.stat_bar = Gui.define("vlayer/stat_bar")
function Elements.stat_bar.refresh(stat_bar, display_data) function Elements.stat_bar.refresh(stat_bar, display_data)
stat_bar.value = display_data.value stat_bar.value = display_data.value
stat_bar.caption = display_data.caption stat_bar.caption = display_data.caption
stat_bar.tooltip = display_data.tooltip
end end
--- Table of a label and bar for each statistic --- Table of a label and bar for each statistic
@@ -177,86 +175,66 @@ function Elements.stats_table.calculate_display_data(s_index)
return { return {
production = { production = {
value = production, value = production,
caption = statistics.energy_input_limit < energy_production caption = format_string(
"%s / %s, %.1f %%",
statistics.energy_input_limit < energy_production
and format_string( and format_string(
"%s (%s) / %s", "%s (%s)",
format_energy(energy_production, "W"), format_energy(energy_production, "W"),
format_energy(limit_production, "W"), format_energy(limit_production, "W")
format_energy(energy_max, "W")
) )
or format_string( or format_energy(energy_production, "W"),
"%s / %s", format_energy(energy_max, "W"),
format_energy(energy_production, "W"),
format_energy(energy_max, "W")
),
tooltip = format_string(
"%.1f %%",
production * 100 production * 100
), ),
}, },
sustained = { sustained = {
value = sustained, value = sustained,
caption = statistics.energy_input_limit < energy_sustained caption = format_string(
"%s / %s, %.1f %%",
statistics.energy_input_limit < energy_sustained
and format_string( and format_string(
"%s (%s) / %s", "%s (%s)",
format_energy(energy_sustained, "W"), format_energy(energy_sustained, "W"),
format_energy(limit_sustained, "W"), format_energy(limit_sustained, "W")
format_energy(statistics.energy_total_production, "W")
) )
or format_string( or format_energy(energy_sustained, "W"),
"%s / %s", format_energy(energy_max, "W"),
format_energy(energy_sustained, "W"),
format_energy(statistics.energy_total_production, "W")
),
tooltip = format_string(
"%.1f %%",
sustained * 100 sustained * 100
), ),
}, },
capacity = { capacity = {
value = capacity, value = capacity,
caption = format_string( caption = format_string(
"%s / %s", "%s / %s, %.1f %%",
format_energy(statistics.energy_storage, "J"), format_energy(statistics.energy_storage, "J"),
format_energy(statistics.energy_capacity, "J") format_energy(statistics.energy_capacity, "J"),
),
tooltip = format_string(
"%.1f %%",
capacity * 100 capacity * 100
), ),
}, },
["surface-area"] = { ["surface-area"] = {
value = min(max(surface_area / 0.1, 0), 1), value = min(max(surface_area / 0.1, 0), 1),
caption = format_number( caption = format_string(
statistics.remaining_surface_area, "%s, %.1f %%",
false format_number(statistics.remaining_surface_area, false),
),
tooltip = format_string(
"%.1f %%",
surface_area * 100 surface_area * 100
), ),
}, },
["solar-panel"] = { ["solar-panel"] = {
value = solar, value = solar,
caption = format_string( caption = format_string(
"%s / %s", "%s / %s, %.1f %%",
format_number(allocated_solar, false), format_number(allocated_solar, false),
format_number(items_solar, false) format_number(items_solar, false),
),
tooltip = format_string(
"%.1f %%",
solar * 100 solar * 100
), ),
}, },
["accumulator"] = { ["accumulator"] = {
value = accu, value = accu,
caption = format_string( caption = format_string(
"%s / %s", "%s / %s, %.1f %%",
format_number(allocated_accu, false), format_number(allocated_accu, false),
format_number(items_accu, false) format_number(items_accu, false),
),
tooltip = format_string(
"%.1f %%",
accu * 100 accu * 100
), ),
}, },