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
+6 -1
View File
@@ -56,6 +56,11 @@ local function formatValueForAssignment(vType, value, pathToCustomFunction, path
return tostring(value) return tostring(value)
end end
return "nil" return "nil"
elseif (vType == "string") then
if type(value) == "string" then
return string.format("%s", Private.QuotedString(value))
end
return "nil"
elseif(vType == "color") then elseif(vType == "color") then
if (value and type(value) == "table") then if (value and type(value) == "table") then
return string.format("{%s, %s, %s, %s}", tostring(value[1]), tostring(value[2]), tostring(value[3]), tostring(value[4])); return string.format("{%s, %s, %s, %s}", tostring(value[1]), tostring(value[2]), tostring(value[3]), tostring(value[4]));
@@ -114,7 +119,7 @@ local function formatValueForAssignment(vType, value, pathToCustomFunction, path
end end
local function formatValueForCall(type, property) local function formatValueForCall(type, property)
if (type == "bool" or type == "number" or type == "list" or type == "icon") then if (type == "bool" or type == "number" or type == "list" or type == "icon" or type == "string") then
return "propertyChanges['" .. property .. "']"; return "propertyChanges['" .. property .. "']";
elseif (type == "color") then elseif (type == "color") then
local pcp = "propertyChanges['" .. property .. "']"; local pcp = "propertyChanges['" .. property .. "']";
+2 -2
View File
@@ -3080,7 +3080,7 @@ do
bar.icon = icon bar.icon = icon
bar.timerType = timerType bar.timerType = timerType
bar.spellId = tostring(spellId) bar.spellId = tostring(spellId)
bar.count = msg:match("%((%d+)%)") or "0" bar.count = msg:match("%((%d+)%)") or msg:match("(%d+)") or "0"
bar.dbmType = dbmType bar.dbmType = dbmType
local barOptions = DBM.ReleaseRevision >= 20220412000000 and DBT.Options or DBM.Bars.options local barOptions = DBM.ReleaseRevision >= 20220412000000 and DBT.Options or DBM.Bars.options
@@ -3310,7 +3310,7 @@ do
bar.bwBackgroundColor = BWColorModule:GetColorTable("barBackground", addon, spellId) bar.bwBackgroundColor = BWColorModule:GetColorTable("barBackground", addon, spellId)
local BWEmphasizedModule = BigWigs:GetPlugin("Super Emphasize") local BWEmphasizedModule = BigWigs:GetPlugin("Super Emphasize")
bar.emphasized = BWEmphasizedModule:IsSuperEmphasized(addon, spellId) and true or false bar.emphasized = BWEmphasizedModule:IsSuperEmphasized(addon, spellId) and true or false
bar.count = text:match("%((%d+)%)") or "0" bar.count = text:match("%((%d+)%)") or text:match("(%d+)") or "0"
bar.cast = not(text:match("^[^<]") and true) bar.cast = not(text:match("^[^<]") and true)
WeakAuras.ScanEvents("BigWigs_StartBar", text) WeakAuras.ScanEvents("BigWigs_StartBar", text)
+2 -2
View File
@@ -4106,7 +4106,7 @@ Private.event_prototypes = {
{ {
name = "count", name = "count",
display = L["Count"], display = L["Count"],
desc = L["Only if DBM shows it on it's bar"], desc = L["Occurence of the event, reset when aura is unloaded\nCan be a range of values\nCan have multiple values separated by a comma or a space\n\nExamples:\n2nd 5th and 6th events: 2, 5, 6\n2nd to 6th: 2-6\nevery 2 events: /2\nevery 3 events starting from 2nd: 2/3\nevery 3 events starting from 2nd and ending at 11th: 2-11/3\n\nOnly if DBM shows it on it's bar"],
type = "string", type = "string",
conditionType = "string", conditionType = "string",
}, },
@@ -4341,7 +4341,7 @@ Private.event_prototypes = {
{ {
name = "count", name = "count",
display = L["Count"], display = L["Count"],
desc = L["Only if BigWigs shows it on it's bar"], desc = L["Occurence of the event, reset when aura is unloaded\nCan be a range of values\nCan have multiple values separated by a comma or a space\n\nExamples:\n2nd 5th and 6th events: 2, 5, 6\n2nd to 6th: 2-6\nevery 2 events: /2\nevery 3 events starting from 2nd: 2/3\nevery 3 events starting from 2nd and ending at 11th: 2-11/3\n\nOnly if BigWigs shows it on it's bar"],
type = "string", type = "string",
conditionType = "string", conditionType = "string",
}, },
+134 -84
View File
@@ -68,6 +68,11 @@ local properties = {
type = "bool", type = "bool",
defaultProperty = true defaultProperty = true
}, },
text_text = {
display = L["Text"],
setter = "ChangeText",
type = "string"
},
text_color = { text_color = {
display = L["Color"], display = L["Color"],
setter = "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 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); text:SetFont(STANDARD_TEXT_FONT, data.text_fontSize < 33 and data.text_fontSize or 33, data.text_fontType);
end end
text:SetTextHeight(data.text_fontSize);
if text:GetFont() then if text:GetFont() then
text:SetText(WeakAuras.ReplaceRaidMarkerSymbols(data.text_text)); text:SetText(WeakAuras.ReplaceRaidMarkerSymbols(data.text_text));
end end
text:SetTextHeight(data.text_fontSize);
text:SetShadowColor(unpack(data.text_shadowColor)) text:SetShadowColor(unpack(data.text_shadowColor))
text:SetShadowOffset(data.text_shadowXOffset, data.text_shadowYOffset) text:SetShadowOffset(data.text_shadowXOffset, data.text_shadowYOffset)
text:SetJustifyH(data.text_justify or "CENTER") text:SetJustifyH(data.text_justify or "CENTER")
@@ -173,6 +179,23 @@ local function modify(parent, region, parentData, data, first)
end end
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 if containsCustomText and parentData.customText and parentData.customText ~= "" then
parent.customTextFunc = WeakAuras.LoadFunction("return "..parentData.customText) parent.customTextFunc = WeakAuras.LoadFunction("return "..parentData.customText)
else else
@@ -182,67 +205,127 @@ local function modify(parent, region, parentData, data, first)
parent.values.lastCustomTextUpdate = nil parent.values.lastCustomTextUpdate = nil
end end
local UpdateText function region:ConfigureTextUpdate()
if data.text_text and Private.ContainsAnyPlaceHolders(data.text_text) then local UpdateText
local getter = function(key, default) if region.text_text and Private.ContainsAnyPlaceHolders(region.text_text) then
local fullKey = "text_text_format_" .. key local getter = function(key, default)
if data[fullKey] == nil then local fullKey = "text_text_format_" .. key
data[fullKey] = default if data[fullKey] == nil then
data[fullKey] = default
end
return data[fullKey]
end end
return data[fullKey] local formatters = Private.CreateFormatters(region.text_text, getter)
end UpdateText = function()
local formatters = Private.CreateFormatters(data.text_text, getter) local textStr = region.text_text or ""
UpdateText = function() textStr = Private.ReplacePlaceHolders(textStr, parent, nil, false, formatters)
local textStr = data.text_text or ""
textStr = Private.ReplacePlaceHolders(textStr, parent, nil, false, formatters)
if text:GetFont() then if text:GetFont() then
text:SetText(WeakAuras.ReplaceRaidMarkerSymbols(textStr)) text:SetText(WeakAuras.ReplaceRaidMarkerSymbols(textStr))
end
region:UpdateAnchor()
end end
end end
end
local Update local Update
if parent.customTextFunc and UpdateText then if parent.customTextFunc and UpdateText then
Update = function() 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()
if parent.values.lastCustomTextUpdate ~= GetTime() then if parent.values.lastCustomTextUpdate ~= GetTime() then
parent.values.custom = Private.RunCustomTextFunc(parent, parent.customTextFunc) parent.values.custom = Private.RunCustomTextFunc(parent, parent.customTextFunc)
parent.values.lastCustomTextUpdate = GetTime() parent.values.lastCustomTextUpdate = GetTime()
end end
UpdateText() UpdateText()
end 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
end end
region.Update = Update function region:ConfigureSubscribers()
region.FrameTick = FrameTick local visible = self:IsShown()
region.TimerTick = TimerTick if self.Update then
if visible then
if not UpdateText then parent.subRegionEvents:AddSubscriber("Update", region)
if text:GetFont() then end
local textStr = data.text_text else
textStr = textStr:gsub("\\n", "\n"); parent.subRegionEvents:RemoveSubscriber("Update", region)
text:SetText(WeakAuras.ReplaceRaidMarkerSymbols(textStr))
end 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 end
function region:Color(r, g, b, a) 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 if (r or g or b) then
a = a or 1; a = a or 1;
end 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); text:SetTextColor(region.color_anim_r or r, region.color_anim_g or g,
end region.color_anim_b or b, region.color_anim_a or a)
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
end end
local selfPoint = data.text_selfPoint local selfPoint = data.text_selfPoint
@@ -415,4 +464,5 @@ local function supports(regionType)
or regionType == "aurabar" or regionType == "aurabar"
end 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)
+14
View File
@@ -8,6 +8,7 @@ local SubscribableObject =
{ {
ClearSubscribers = function(self) ClearSubscribers = function(self)
self.events = {} self.events = {}
self.subscribers = {}
end, end,
ClearCallbacks = function(self) ClearCallbacks = function(self)
@@ -21,6 +22,12 @@ local SubscribableObject =
end end
self.events[event] = self.events[event] or {} self.events[event] = self.events[event] or {}
self.subscribers[event] = self.subscribers[event] or {}
if self.subscribers[event][subscriber] then
-- Already subscribed, just return
return
end
self.subscribers[event][subscriber] = true
local pos = highPriority and 1 or (#self.events[event] + 1) local pos = highPriority and 1 or (#self.events[event] + 1)
if TableHasAnyEntries(self.events[event]) then if TableHasAnyEntries(self.events[event]) then
tinsert(self.events[event], pos, subscriber) tinsert(self.events[event], pos, subscriber)
@@ -34,6 +41,12 @@ local SubscribableObject =
RemoveSubscriber = function(self, event, subscriber) RemoveSubscriber = function(self, event, subscriber)
if self.events[event] then if self.events[event] then
if not self.subscribers[event][subscriber] then
-- Not subscribed
return
end
self.subscribers[event][subscriber] = nil
local index = tIndexOf(self.events[event], subscriber) local index = tIndexOf(self.events[event], subscriber)
if index then if index then
tremove(self.events[event], index) tremove(self.events[event], index)
@@ -68,6 +81,7 @@ function Private.CreateSubscribableObject()
for f, func in pairs(SubscribableObject) do for f, func in pairs(SubscribableObject) do
system[f] = func system[f] = func
system.events = {} system.events = {}
system.subscribers = {}
system.callbacks = {} system.callbacks = {}
end end
return system return system
+13
View File
@@ -466,6 +466,19 @@ local function addControlsForChange(args, order, data, conditionVariable, totalA
args["condition" .. i .. "value" .. j].validate = WeakAuras.ValidateNumeric; args["condition" .. i .. "value" .. j].validate = WeakAuras.ValidateNumeric;
end end
end end
elseif (propertyType == "string") then
args["condition" .. i .. "value" .. j] = {
type = "input",
width = WeakAuras.normalWidth,
name = blueIfNoValue(data, conditions[i].changes[j], "value", L["Text"]),
desc = descIfNoValue(data, conditions[i].changes[j], "value", propertyType),
order = order,
get = function()
return conditions[i].changes[j].value;
end,
set = setValue
}
order = order + 1;
elseif (propertyType == "icon") then elseif (propertyType == "icon") then
args["condition" .. i .. "value" .. j] = { args["condition" .. i .. "value" .. j] = {
type = "input", type = "input",
+18 -1
View File
@@ -394,11 +394,28 @@ local function createOptions(parentData, data, index, subIndex)
return true return true
end end
for index, subRegion in ipairs(parentData.subRegions) do for _, subRegion in ipairs(parentData.subRegions) do
if subRegion.type == "subtext" and OptionsPrivate.Private.ContainsCustomPlaceHolder(subRegion.text_text) then if subRegion.type == "subtext" and OptionsPrivate.Private.ContainsCustomPlaceHolder(subRegion.text_text) then
return false return false
end end
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 OptionsPrivate.Private.ContainsCustomPlaceHolder(change.value)
then
return false
end
end
end
end
end
return true return true
end end