from retail

This commit is contained in:
NoM0Re
2025-01-28 10:02:47 +01:00
parent a99f7bd323
commit d3a9fb094c
2 changed files with 73 additions and 5 deletions
+47
View File
@@ -1196,6 +1196,53 @@ function Private.Modernize(data, oldSnapshot)
end end
end end
if data.internalVersion < 53 then
local function ReplaceIn(text, table, prefix)
local seenSymbols = {}
Private.ParseTextStr(text, function(symbol)
if not seenSymbols[symbol] then
if table[prefix .. symbol .. "_format"] == "timed"
and table[prefix .. symbol .. "_time_format"] == 0
then
table[prefix .. symbol .. "_time_legacy_floor"] = true
end
end
seenSymbols[symbol] = symbol
end)
end
if data.regionType == "text" then
ReplaceIn(data.displayText, data, "displayText_format_")
end
if data.subRegions then
for index, subRegionData in ipairs(data.subRegions) do
if subRegionData.type == "subtext" then
ReplaceIn(subRegionData.text_text, subRegionData, "text_text_format_")
end
end
end
if data.actions then
if data.actions.start then
ReplaceIn(data.actions.start.message, data.actions.start, "message_format_")
end
if data.actions.finish then
ReplaceIn(data.actions.finish.message, data.actions.finish, "message_format_")
end
end
if data.conditions then
for conditionIndex, condition in ipairs(data.conditions) do
for changeIndex, change in ipairs(condition.changes) do
if change.property == "chat" and change.value then
ReplaceIn(change.value.message, change.value, "message_format_")
end
end
end
end
end
if data.internalVersion < 54 then if data.internalVersion < 54 then
for _, triggerData in ipairs(data.triggers) do for _, triggerData in ipairs(data.triggers) do
if triggerData.trigger.type == "aura" then if triggerData.trigger.type == "aura" then
+26 -5
View File
@@ -122,8 +122,6 @@ Private.unit_realm_name_types = {
always = L["Always include realm"] always = L["Always include realm"]
} }
local timeFormatter = {}
local simpleFormatters = { local simpleFormatters = {
--[[ --[[
AbbreviateNumbers = function(value, state) AbbreviateNumbers = function(value, state)
@@ -156,6 +154,15 @@ local simpleFormatters = {
-- Remove the space between the value and unit -- Remove the space between the value and unit
return fmt:gsub(" ", ""):format(time) return fmt:gsub(" ", ""):format(time)
end, end,
-- Fixed built-in formatter
[99] = function(value)
value = ceil(value)
if value > 60 then
return string.format("%i:", math.floor(value / 60)) .. string.format("%02i", value % 60)
else
return string.format("%d", value)
end
end,
}, },
} }
@@ -229,16 +236,30 @@ Private.format_types = {
hidden = hidden, hidden = hidden,
disabled = function() return get(symbol .. "_time_dynamic_threshold") == 0 end disabled = function() return get(symbol .. "_time_dynamic_threshold") == 0 end
}) })
addOption(symbol .. "_time_legacy_floor", {
type = "toggle",
name = L["Use Legacy floor rounding"],
desc = L["Enables (incorrect) round down of seconds, which was the previous default behaviour."],
width = WeakAuras.normalWidth,
hidden = hidden,
disabled = function() return get(symbol .. "_time_format", 0) ~= 0 end
})
end, end,
CreateFormatter = function(symbol, get, wihoutColor, data) CreateFormatter = function(symbol, get, wihoutColor, data)
local format = get(symbol .. "_time_format", 0) local format = get(symbol .. "_time_format", 0)
local threshold = get(symbol .. "_time_dynamic_threshold", 60) local threshold = get(symbol .. "_time_dynamic_threshold", 60)
local precision = get(symbol .. "_time_precision", 1) local precision = get(symbol .. "_time_precision", 1)
local legacyRoundingMode = get(symbol .. "_time_legacy_floor", false)
local mainFormater = simpleFormatters.time[format] if format == 0 and not legacyRoundingMode then
if not mainFormater then format = 99
mainFormater = simpleFormatters.time[0]
end end
if not simpleFormatters.time[format] then
format = 99
end
local mainFormater = simpleFormatters.time[format]
local formatter local formatter
if threshold == 0 then if threshold == 0 then
formatter = function(value, state, trigger) formatter = function(value, state, trigger)