X Tutup
Skip to content

Commit fe95f23

Browse files
author
Webster Sheets
authored
Merge pull request #5932 from mwerle/feat/scan_manager
feat: fix completion display of scan manager
2 parents 9cf9a6b + b8d008b commit fe95f23

File tree

23 files changed

+215
-115
lines changed

23 files changed

+215
-115
lines changed

data/lang/core/en.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,6 +1823,22 @@
18231823
"description": "Mass unit: one petatonne",
18241824
"message": "Pt"
18251825
},
1826+
"UNIT_HECTARES": {
1827+
"description": "Area unit: one hectare (ha) -10,000 m²",
1828+
"message": "ha"
1829+
},
1830+
"UNIT_SQUARE_KILOMETERS": {
1831+
"description": "Area unit: square kilometer (km²) - 1,000,000 m²",
1832+
"message": "km²"
1833+
},
1834+
"UNIT_SQUARE_MEGAMETERS": {
1835+
"description": "Area unit: square megameter (Mm²) - 10^12 m²",
1836+
"message": "Mm²"
1837+
},
1838+
"UNIT_SQUARE_METERS": {
1839+
"description": "Area unit: square meter (m²)",
1840+
"message": ""
1841+
},
18261842
"UNIT_PRESSURE_ATMOSPHERES": {
18271843
"description": "Pressure unit: one earth atmosphere (atm)",
18281844
"message": "atm"

data/lang/module-scout/en.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@
259259
"description": "",
260260
"message": "Danger:"
261261
},
262+
"DATA_COLLECTED_PROGRESS": {
263+
"description": "Label for scan card progress bar",
264+
"message": "Data Collected: {percent_completed}%"
265+
},
262266
"DEADLINE": {
263267
"description": "",
264268
"message": "Deadline:"

data/libs/utils.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ end
378378
--
379379
local object = {}
380380

381-
object.meta = { __index = object, class="object", inherits = { ["object"] = true } }
381+
object.meta = { __index = object, class="object", inherits = { object = true } }
382382

383383
--
384384
-- Function: New

data/modules/Scout/ScanDisplay.lua

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -182,36 +182,45 @@ function scanDisplay:drawScanInfo(scan, isHighlighted)
182182

183183
-- displayed when the active scanner cannot carry out the scan
184184
local altitude = string.upper(ls.INVALID_SCANNER)
185-
local target = ""
186185

187186
local params = scanMgr:GetScanParameters(sBody, scan.minResolution, scan.orbital)
188187
if params and params.canScan then
189188
altitude = ui.Format.Distance(params.maxAltitude)
190189
end
191190

192-
if scan.orbital then
193-
target = string.format("%.1f%%", scan.targetCoverage * 100.0)
194-
else
195-
target = ui.Format.Distance(scan.targetCoverage * 1000.0, "%.1f")
196-
end
197-
198-
local completion = math.min(1.0, scan.coverage / scan.targetCoverage)
191+
local target = ui.Format.Area(scan.targetCoverage * 1e6)
199192

200193
local data = {
201194
title = sBody.name .. ", " .. scan.bodyPath:GetStarSystem().name,
202195
target = target,
203-
completion = string.format("%2.1f%%", completion * 100.0),
196+
completion = ui.Format.Area(scan.coverage * 1e6),
204197
isActive = self.scanMgr:GetActiveScan() == scan,
205198
scan = scan,
206199
icon = scan.orbital and icons.map or icons.scanner,
207200
{ icons.comms, target, ls.SCAN_TARGET_COVERAGE },
208201
{ icons.scanner, ui.Format.Distance(scan.minResolution, "%.1f"), ls.SCAN_MAXIMUM_SPATIAL_RESOLUTION },
209202
{ icons.altitude, altitude, ls.SCAN_MAXIMUM_ALTITUDE },
203+
progress = (scan.targetCoverage / scan.coverage) * 100
210204
}
211205

212206
return ScanCard:draw(data, isHighlighted)
213207
end
214208

209+
---@param scan ScanData
210+
function scanDisplay:drawScanProgress(scan)
211+
local completion = math.min(1.0, scan.coverage / scan.targetCoverage)
212+
local width = ui.getContentRegion().x
213+
-- The default progress bar colour style is yellow which is very jarring
214+
-- for this display. So instead lets use a more suitable colour style.
215+
local progressBarColor = colors.uiPrimaryLight
216+
local progressBarText = ls.DATA_COLLECTED_PROGRESS % {
217+
percent_completed = string.format("%.2f", completion * 100.0)
218+
}
219+
ui.withStyleColors({ PlotHistogram = progressBarColor }, function()
220+
ui.progressBar(completion, Vector2(width, 0), progressBarText)
221+
end)
222+
end
223+
215224
-- Return a sorted copy of the given scan list for display
216225
---@param scanList ScanData[]
217226
function scanDisplay:sortScanList(scanList)
@@ -283,6 +292,8 @@ function scanDisplay:drawBody()
283292

284293
if clicked then
285294
self.scanMgr:ClearActiveScan()
295+
else
296+
self:drawScanProgress(activeScan)
286297
end
287298
else
288299
self:drawEmptyActiveScan()

data/modules/Scout/ScanGauge.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ local ls = Lang.GetResource('module-scout')
1515
gauges.registerGauge(10, {
1616
value = function()
1717
local scanMgr = Game.player:GetComponent("ScanManager")
18-
1918
local scan = scanMgr and scanMgr:GetActiveScan()
2019
if not scan then return nil end
2120

@@ -24,5 +23,8 @@ gauges.registerGauge(10, {
2423
end,
2524
unit = '%', format = '%.2f', min = 0, max = 100,
2625
icon = icons.scanner, color = colors.gaugeScanner,
27-
tooltip = ls.HUD_SCAN_PROGRESS
26+
tooltip = ls.HUD_SCAN_PROGRESS,
27+
debugReload = function()
28+
package.reimport()
29+
end
2830
})

data/modules/Scout/ScanManager.lua

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,12 @@ end
9999
--=============================================================================
100100

101101
-- Update different scan types at different rates
102+
-- TODO: these update rates cause excessive updates at high timewarp factors.
103+
-- This especially impacts the Orbial Scans. It is proposed to replace
104+
-- this mechanism with a timewarp-invariant timer instead.
105+
-- See : https://github.com/pioneerspacesim/pioneer/pull/5932#discussion_r1800544550
102106
local SURFACE_SCAN_UPDATE_RATE = 1
103-
local ORBITAL_SCAN_UPDATE_RATE = 60
107+
local ORBITAL_SCAN_UPDATE_RATE = 1
104108

105109
-- Square meters to square kilometers
106110
local SQUARE_KILOMETERS = 10^6
@@ -595,17 +599,9 @@ function ScanManager:OnUpdateScan(scan)
595599
local coverage
596600
local beamWidth = self.activeSensor.apertureWidth * altitude
597601

598-
if scan.orbital then
599-
-- percent of total coverage gained per orbit, calculated at the widest point of the body
600-
local covPctPerOrbit = beamWidth / (radius * math.pi)
601-
local orbitPercent = dS / (math.pi * 2)
602-
603-
coverage = covPctPerOrbit * orbitPercent
604-
else
605-
local distance = dS * radius
606-
-- total coverage gain in square kilometers
607-
coverage = beamWidth * distance / SQUARE_KILOMETERS
608-
end
602+
local distance = dS * radius
603+
-- total coverage gain in square kilometers
604+
coverage = beamWidth * distance / SQUARE_KILOMETERS
609605

610606
scan.coverage = scan.coverage + coverage
611607

0 commit comments

Comments
 (0)
X Tutup