from retail

This commit is contained in:
NoM0Re
2025-01-28 10:36:41 +01:00
parent d3a9fb094c
commit 8cc8d5ea62
4 changed files with 72 additions and 11 deletions
+47 -4
View File
@@ -260,12 +260,52 @@ Private.format_types = {
end
local mainFormater = simpleFormatters.time[format]
local modRateProperty = {}
local timePointProperty = {}
-- For the mod rate support, we need to know which state member is the modRate, as
-- different progressSources can have different modRates
-- Here, we only collect the names, so that the actual formatter can quickly lookup
-- the property
-- This is somewhat complicated by legacy behaviour (for %p, %t) and that %foo, can
-- be the foo of different triggers that might use different modRate properties
-- Similarly to distinguish between time formaters for durations and timepoints,
-- we maintain a lookup table for time points
-- Timepoint formatters need to run every frame, so we rturn true if we
-- are formatting a timepoint
local triggerNum, sym = string.match(symbol, "(.+)%.(.+)")
triggerNum = triggerNum and tonumber(triggerNum)
sym = sym or symbol
if triggerNum then
local progressSource = Private.GetProgressSourceFor(data, triggerNum, sym)
if progressSource then
if progressSource[2] == "timer" or progressSource[2] == "elapsedTimer" then
timePointProperty[triggerNum] = true
end
end
else
for i = 1, #data.triggers do
local progressSource = Private.GetProgressSourceFor(data, i, symbol)
if progressSource then
if progressSource[2] == "timer" or progressSource[2] == "elapsedTimer" then
timePointProperty[i] = true
end
end
end
end
local formatter
if threshold == 0 then
formatter = function(value, state, trigger)
if type(value) ~= 'number' or value == math.huge then
return ""
end
if timePointProperty[trigger] then
value = abs(GetTime() - value)
end
if value <= 0 then
return ""
end
@@ -277,6 +317,11 @@ Private.format_types = {
if type(value) ~= 'number' or value == math.huge then
return ""
end
if timePointProperty[trigger] then
value = abs(GetTime() - value)
end
if value <= 0 then
return ""
end
@@ -288,8 +333,6 @@ Private.format_types = {
end
end
local triggerNum, sym = string.match(symbol, "(.+)%.(.+)")
sym = sym or symbol
if sym == "p" or sym == "t" then
-- Special case %p and %t. Since due to how the formatting
-- work previously, the time formatter only formats %p and %t
@@ -299,9 +342,9 @@ Private.format_types = {
return value
end
return formatter(value, state, trigger)
end
end, next(timePointProperty) ~= nil
else
return formatter
return formatter, next(timePointProperty) ~= nil
end
end
},