from retail

This commit is contained in:
NoM0Re
2025-01-16 20:55:38 +01:00
parent e924932d63
commit ba4039dae2
2 changed files with 81 additions and 42 deletions
+49 -22
View File
@@ -178,24 +178,22 @@ local function modify(parent, region, parentData, data, first)
break
end
end
if type(parentData.conditions) == "table" then
for _, condition in ipairs(parentData.conditions) do
if type(condition.changes) == "table" then
for _, change in ipairs(condition.changes) do
if type(change.property) == "string"
and change.property:match("sub%.%d+%.text_text")
and type(change.value) == "string"
and Private.ContainsCustomPlaceHolder(change.value)
then
containsCustomText = true
break
if not containsCustomText then
if type(parentData.conditions) == "table" then
for _, condition in ipairs(parentData.conditions) do
if type(condition.changes) == "table" then
for _, change in ipairs(condition.changes) do
if type(change.property) == "string"
and change.property:match("sub%.%d+%.text_text")
then
containsCustomText = true
break
end
end
end
end
end
end
if containsCustomText and parentData.customText and parentData.customText ~= "" then
parent.customTextFunc = WeakAuras.LoadFunction("return "..parentData.customText)
else
@@ -205,20 +203,49 @@ local function modify(parent, region, parentData, data, first)
parent.values.lastCustomTextUpdate = nil
end
local texts = {}
local textStr = data.text_text or ""
if textStr ~= "" then
tinsert(texts, textStr)
end
local subRegionIndex = 1
for index, subRegion in ipairs(parentData.subRegions) do
if subRegion == data then
subRegionIndex = index
break;
end
end
if type(parentData.conditions) == "table" then
local conditionName = "sub."..subRegionIndex..".text_text"
for _, condition in ipairs(parentData.conditions) do
if type(condition.changes) == "table" then
for _, change in ipairs(condition.changes) do
if type(change.property) == "string" and change.property == conditionName then
if type(change.value ) == "string" and change.value ~= "" then
tinsert(texts, change.value)
end
end
end
end
end
end
local getter = function(key, default)
local fullKey = "text_text_format_" .. key
if (data[fullKey] == nil) then
data[fullKey] = default
end
return data[fullKey]
end
region.subTextFormatters = Private.CreateFormatters(texts, getter)
function region:ConfigureTextUpdate()
local UpdateText
if region.text_text and Private.ContainsAnyPlaceHolders(region.text_text) then
local getter = function(key, default)
local fullKey = "text_text_format_" .. key
if data[fullKey] == nil then
data[fullKey] = default
end
return data[fullKey]
end
local formatters = Private.CreateFormatters(region.text_text, getter)
UpdateText = function()
local textStr = region.text_text or ""
textStr = Private.ReplacePlaceHolders(textStr, parent, nil, false, formatters)
textStr = Private.ReplacePlaceHolders(textStr, parent, nil, false, self.subTextFormatters)
if text:GetFont() then
text:SetText(WeakAuras.ReplaceRaidMarkerSymbols(textStr))
+32 -20
View File
@@ -465,30 +465,42 @@ local function createOptions(parentData, data, index, subIndex)
options["text_text_format_" .. key] = option
end
if parentData.controlledChildren then
local list = {}
for child in OptionsPrivate.Private.TraverseLeafs(parentData) do
if child.subRegions then
local childSubRegion = child.subRegions[index]
if childSubRegion then
tinsert(list, childSubRegion)
local list = {}
for child in OptionsPrivate.Private.TraverseLeafsOrAura(parentData) do
if child.subRegions then
local childSubRegion = child.subRegions[index]
if childSubRegion then
tinsert(list, child)
end
end
end
for listIndex, child in ipairs(list) do
local childSubRegion = child.subRegions[index]
local get = function(key)
return childSubRegion["text_text_format_" .. key]
end
local texts = {}
if type(childSubRegion.text_text) == "string" and childSubRegion.text_text ~= "" then
-- found text of subregion
tinsert(texts, childSubRegion.text_text)
end
for _, condition in ipairs(child.conditions) do
if type(condition.changes) == "table" then
for _, change in ipairs(condition.changes) do
if change.property == "sub."..index..".text_text"
and type(change.value) == "string"
and change.value ~= ""
then
-- found a condition editing text of that subregion
tinsert(texts, change.value)
end
end
end
end
for listIndex, childSubRegion in ipairs(list) do
local get = function(key)
return childSubRegion["text_text_format_" .. key]
end
local input = childSubRegion["text_text"]
OptionsPrivate.AddTextFormatOption(input, true, get, addOption, hidden, setHidden, false, listIndex, #list)
end
else
local get = function(key)
return data["text_text_format_" .. key]
end
local input = data["text_text"]
OptionsPrivate.AddTextFormatOption(input, true, get, addOption, hidden, setHidden, false)
OptionsPrivate.AddTextFormatOption(texts, true, get, addOption, hidden, setHidden, false, listIndex, #list)
end
addOption("footer", {