from retail

This commit is contained in:
NoM0Re
2025-01-14 02:10:45 +01:00
parent 74cc0c7ee8
commit 9d6005c82f
7 changed files with 189 additions and 90 deletions
+134 -84
View File
@@ -68,6 +68,11 @@ local properties = {
type = "bool",
defaultProperty = true
},
text_text = {
display = L["Text"],
setter = "ChangeText",
type = "string"
},
text_color = {
display = L["Color"],
setter = "Color",
@@ -137,11 +142,12 @@ local function modify(parent, region, parentData, data, first)
if not text:GetFont() then -- Font invalid, set the font but keep the setting
text:SetFont(STANDARD_TEXT_FONT, data.text_fontSize < 33 and data.text_fontSize or 33, data.text_fontType);
end
text:SetTextHeight(data.text_fontSize);
if text:GetFont() then
text:SetText(WeakAuras.ReplaceRaidMarkerSymbols(data.text_text));
end
text:SetTextHeight(data.text_fontSize);
text:SetShadowColor(unpack(data.text_shadowColor))
text:SetShadowOffset(data.text_shadowXOffset, data.text_shadowYOffset)
text:SetJustifyH(data.text_justify or "CENTER")
@@ -173,6 +179,23 @@ local function modify(parent, region, parentData, data, first)
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
end
end
end
end
end
if containsCustomText and parentData.customText and parentData.customText ~= "" then
parent.customTextFunc = WeakAuras.LoadFunction("return "..parentData.customText)
else
@@ -182,67 +205,127 @@ local function modify(parent, region, parentData, data, first)
parent.values.lastCustomTextUpdate = nil
end
local UpdateText
if data.text_text and Private.ContainsAnyPlaceHolders(data.text_text) then
local getter = function(key, default)
local fullKey = "text_text_format_" .. key
if data[fullKey] == nil then
data[fullKey] = default
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
return data[fullKey]
end
local formatters = Private.CreateFormatters(data.text_text, getter)
UpdateText = function()
local textStr = data.text_text or ""
textStr = Private.ReplacePlaceHolders(textStr, parent, nil, false, formatters)
local formatters = Private.CreateFormatters(region.text_text, getter)
UpdateText = function()
local textStr = region.text_text or ""
textStr = Private.ReplacePlaceHolders(textStr, parent, nil, false, formatters)
if text:GetFont() then
text:SetText(WeakAuras.ReplaceRaidMarkerSymbols(textStr))
if text:GetFont() then
text:SetText(WeakAuras.ReplaceRaidMarkerSymbols(textStr))
end
region:UpdateAnchor()
end
end
end
local Update
if parent.customTextFunc and UpdateText then
Update = function()
if parent.values.lastCustomTextUpdate ~= GetTime() then
parent.values.custom = Private.RunCustomTextFunc(parent, parent.customTextFunc)
parent.values.lastCustomTextUpdate = GetTime()
end
UpdateText()
end
else
Update = UpdateText
end
local TimerTick
if Private.ContainsPlaceHolders(data.text_text, "p") then
TimerTick = UpdateText
end
local FrameTick
if parent.customTextFunc and parentData.customTextUpdate == "update" then
if Private.ContainsCustomPlaceHolder(data.text_text) then
FrameTick = function()
local Update
if parent.customTextFunc and UpdateText then
Update = function()
if parent.values.lastCustomTextUpdate ~= GetTime() then
parent.values.custom = Private.RunCustomTextFunc(parent, parent.customTextFunc)
parent.values.lastCustomTextUpdate = GetTime()
end
UpdateText()
end
else
Update = UpdateText
end
local TimerTick
if Private.ContainsPlaceHolders(region.text_text, "p") then
TimerTick = UpdateText
end
local FrameTick
if parent.customTextFunc and parentData.customTextUpdate == "update" then
if Private.ContainsCustomPlaceHolder(region.text_text) then
FrameTick = function()
if parent.values.lastCustomTextUpdate ~= GetTime() then
parent.values.custom = Private.RunCustomTextFunc(parent, parent.customTextFunc)
parent.values.lastCustomTextUpdate = GetTime()
end
UpdateText()
end
end
end
region.Update = Update
region.FrameTick = FrameTick
region.TimerTick = TimerTick
if not UpdateText then
if text:GetFont() then
local textStr = region.text_text
textStr = textStr:gsub("\\n", "\n");
text:SetText(WeakAuras.ReplaceRaidMarkerSymbols(textStr))
end
end
end
region.Update = Update
region.FrameTick = FrameTick
region.TimerTick = TimerTick
if not UpdateText then
if text:GetFont() then
local textStr = data.text_text
textStr = textStr:gsub("\\n", "\n");
text:SetText(WeakAuras.ReplaceRaidMarkerSymbols(textStr))
function region:ConfigureSubscribers()
local visible = self:IsShown()
if self.Update then
if visible then
parent.subRegionEvents:AddSubscriber("Update", region)
end
else
parent.subRegionEvents:RemoveSubscriber("Update", region)
end
if self.FrameTick then
if visible then
parent.subRegionEvents:AddSubscriber("FrameTick", region)
end
else
parent.subRegionEvents:RemoveSubscriber("FrameTick", region)
end
if self.TimerTick then
if visible then
parent.subRegionEvents:AddSubscriber("TimerTick", region)
end
else
parent.subRegionEvents:RemoveSubscriber("TimerTick", region)
end
if self.Update and parent.state and visible then
self:Update()
end
end
function region:ChangeText(msg)
region.text_text = msg
region:ConfigureTextUpdate()
region:ConfigureSubscribers()
end
region.text_text = data.text_text
region:ConfigureTextUpdate()
function region:SetTextHeight(size)
local fontPath = SharedMedia:Fetch("font", data.text_font);
if not text:GetFont() then -- Font invalid, set the font but keep the setting
text:SetFont(STANDARD_TEXT_FONT, size < 33 and size or 33, data.text_fontType);
else
region.text:SetFont(fontPath, size < 33 and size or 33, data.text_fontType);
end
region.text:SetTextHeight(size)
region:UpdateAnchor();
end
function region:SetVisible(visible)
if visible then
self:Show()
else
self:Hide()
end
region:ConfigureSubscribers()
end
function region:Color(r, g, b, a)
@@ -253,42 +336,8 @@ local function modify(parent, region, parentData, data, first)
if (r or g or b) then
a = a or 1;
end
text:SetTextColor(region.color_anim_r or r, region.color_anim_g or g, region.color_anim_b or b, region.color_anim_a or a);
end
function region:SetTextHeight(size)
local fontPath = SharedMedia:Fetch("font", data.text_font);
region.text:SetFont(fontPath, size < 33 and size or 33, data.text_fontType);
region.text:SetTextHeight(size)
end
function region:SetVisible(visible)
if visible then
self:Show()
if self.Update then
parent.subRegionEvents:AddSubscriber("Update", region)
end
if self.FrameTick then
parent.subRegionEvents:AddSubscriber("FrameTick", region)
end
if self.TimerTick then
parent.subRegionEvents:AddSubscriber("TimerTick", region)
end
if self.Update and parent.state then
self:Update()
end
else
if self.Update then
parent.subRegionEvents:RemoveSubscriber("Update", region)
end
if self.FrameTick then
parent.subRegionEvents:RemoveSubscriber("FrameTick", region)
end
if self.TimerTick then
parent.subRegionEvents:RemoveSubscriber("TimerTick", region)
end
self:Hide()
end
text:SetTextColor(region.color_anim_r or r, region.color_anim_g or g,
region.color_anim_b or b, region.color_anim_a or a)
end
local selfPoint = data.text_selfPoint
@@ -415,4 +464,5 @@ local function supports(regionType)
or regionType == "aurabar"
end
WeakAuras.RegisterSubRegionType("subtext", L["Text"], supports, create, modify, onAcquire, onRelease, default, addDefaultsForNewAura, properties);
WeakAuras.RegisterSubRegionType("subtext", L["Text"], supports, create, modify, onAcquire, onRelease,
default, addDefaultsForNewAura, properties)