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
+5 -3
View File
@@ -186,7 +186,7 @@ local function modify(parent, region, data)
containsCustomText = true
end
local formatters
local formatters, everyFrameFormatters
do
local getter = function(key, default)
local fullKey = "displayText_format_" .. key
@@ -218,7 +218,7 @@ local function modify(parent, region, data)
end
end
formatters = Private.CreateFormatters(texts, getter, false, data)
formatters, everyFrameFormatters = Private.CreateFormatters(texts, getter, false, data)
end
local customTextFunc = nil
@@ -251,7 +251,9 @@ local function modify(parent, region, data)
end
local FrameTick
if Private.ContainsPlaceHolders(self.displayText, "p") then
if Private.ContainsPlaceHolders(self.displayText, "p")
or Private.AnyEveryFrameFormatters(self.displayText, everyFrameFormatters)
then
FrameTick = UpdateText
end
+4 -2
View File
@@ -244,7 +244,7 @@ local function modify(parent, region, parentData, data, first)
end
return data[fullKey]
end
region.subTextFormatters = Private.CreateFormatters(texts, getter, false, parentData)
region.subTextFormatters, region.everyFrameFormatters = Private.CreateFormatters(texts, getter, false, parentData)
function region:ConfigureTextUpdate()
local UpdateText
@@ -274,7 +274,9 @@ local function modify(parent, region, parentData, data, first)
end
local FrameTick
if Private.ContainsPlaceHolders(region.text_text, "p") then
if Private.ContainsPlaceHolders(region.text_text, "p")
or Private.AnyEveryFrameFormatters(region.text_text, region.everyFrameFormatters)
then
FrameTick = UpdateText
end
+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
},
+16 -2
View File
@@ -4618,6 +4618,8 @@ function Private.ContainsAnyPlaceHolders(textStr)
return ContainsPlaceHolders(textStr, function(symbol) return true end, true)
end
Private.ContainsPlaceHoldersPredicate = ContainsPlaceHolders
local function ValueForSymbol(symbol, region, customFunc, regionState, regionStates, useHiddenStates, formatters)
local triggerNum, sym = string.match(symbol, "(.+)%.(.+)")
triggerNum = triggerNum and tonumber(triggerNum)
@@ -4790,6 +4792,7 @@ end
function Private.CreateFormatters(input, getter, withoutColor, data)
local seenSymbols = {}
local formatters = {}
local everyFrameFormatters = {}
local parseFn = function(symbol)
if not seenSymbols[symbol] then
@@ -4801,7 +4804,7 @@ function Private.CreateFormatters(input, getter, withoutColor, data)
local default = (sym == "p" or sym == "t") and "timed" or "none"
local selectedFormat = getter(symbol .. "_format", default)
if (Private.format_types[selectedFormat]) then
formatters[symbol] = Private.format_types[selectedFormat].CreateFormatter(symbol, getter, withoutColor, data)
formatters[symbol], everyFrameFormatters[symbol] = Private.format_types[selectedFormat].CreateFormatter(symbol, getter, withoutColor, data)
end
end
end
@@ -4816,7 +4819,18 @@ function Private.CreateFormatters(input, getter, withoutColor, data)
end
end
return formatters
return formatters, everyFrameFormatters
end
function Private.AnyEveryFrameFormatters(textStr, everyFrameFormatters)
if next(everyFrameFormatters) then
local function predicate(symbol)
if everyFrameFormatters[symbol] then
return true
end
end
return Private.ContainsPlaceHoldersPredicate(textStr, predicate)
end
end
function Private.IsAuraActive(uid)