from retail
This commit is contained in:
@@ -2828,10 +2828,17 @@ Private.event_prototypes = {
|
|||||||
store = true
|
store = true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
name = "extraSpellId",
|
||||||
|
display = WeakAuras.newFeatureString .. L["Extra Spell Id"],
|
||||||
|
init = "arg",
|
||||||
enable = function(trigger)
|
enable = function(trigger)
|
||||||
return trigger.subeventSuffix and (trigger.subeventSuffix == "_INTERRUPT" or trigger.subeventSuffix == "_DISPEL" or trigger.subeventSuffix == "_DISPEL_FAILED" or trigger.subeventSuffix == "_STOLEN" or trigger.subeventSuffix == "_AURA_BROKEN_SPELL")
|
return trigger.subeventSuffix and (trigger.subeventSuffix == "_INTERRUPT" or trigger.subeventSuffix == "_DISPEL" or trigger.subeventSuffix == "_DISPEL_FAILED" or trigger.subeventSuffix == "_STOLEN" or trigger.subeventSuffix == "_AURA_BROKEN_SPELL")
|
||||||
end
|
end,
|
||||||
}, -- extraSpellId ignored with SPELL_INTERRUPT
|
type = "spell",
|
||||||
|
showExactOption = false,
|
||||||
|
store = true,
|
||||||
|
conditionType = "number"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name = "extraSpellName",
|
name = "extraSpellName",
|
||||||
display = L["Extra Spell Name"],
|
display = L["Extra Spell Name"],
|
||||||
|
|||||||
+111
-56
@@ -44,7 +44,12 @@ local properties = {
|
|||||||
softMax = 72,
|
softMax = 72,
|
||||||
step = 1,
|
step = 1,
|
||||||
default = 12
|
default = 12
|
||||||
}
|
},
|
||||||
|
displayText = {
|
||||||
|
display = L["Text"],
|
||||||
|
setter = "ChangeText",
|
||||||
|
type = "string"
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
WeakAuras.regionPrototype.AddProperties(properties, default);
|
WeakAuras.regionPrototype.AddProperties(properties, default);
|
||||||
@@ -172,8 +177,13 @@ local function modify(parent, region, data)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local UpdateText
|
local containsCustomText = false
|
||||||
if Private.ContainsAnyPlaceHolders(data.displayText) then
|
if Private.ContainsCustomPlaceHolder(data.displayText) then
|
||||||
|
containsCustomText = true
|
||||||
|
end
|
||||||
|
|
||||||
|
local formatters
|
||||||
|
do
|
||||||
local getter = function(key, default)
|
local getter = function(key, default)
|
||||||
local fullKey = "displayText_format_" .. key
|
local fullKey = "displayText_format_" .. key
|
||||||
if (data[fullKey] == nil) then
|
if (data[fullKey] == nil) then
|
||||||
@@ -181,67 +191,102 @@ local function modify(parent, region, data)
|
|||||||
end
|
end
|
||||||
return data[fullKey]
|
return data[fullKey]
|
||||||
end
|
end
|
||||||
local formatters = Private.CreateFormatters(data.displayText, getter)
|
|
||||||
UpdateText = function()
|
|
||||||
local textStr = data.displayText;
|
|
||||||
textStr = Private.ReplacePlaceHolders(textStr, region, nil, false, formatters);
|
|
||||||
if (textStr == nil or textStr == "") then
|
|
||||||
textStr = " ";
|
|
||||||
end
|
|
||||||
|
|
||||||
|
local texts = {}
|
||||||
|
tinsert(texts, data.displayText)
|
||||||
|
|
||||||
|
if type(data.conditions) == "table" then
|
||||||
|
for _, condition in ipairs(data.conditions) do
|
||||||
|
if type(condition.changes) == "table" then
|
||||||
|
for _, change in ipairs(condition.changes) do
|
||||||
|
if type(change.property) == "string"
|
||||||
|
and change.property == "displayText"
|
||||||
|
and type(change.value) == "string"
|
||||||
|
and Private.ContainsAnyPlaceHolders(change.value)
|
||||||
|
then
|
||||||
|
if not containsCustomText and Private.ContainsCustomPlaceHolder(change.value) then
|
||||||
|
containsCustomText = true
|
||||||
|
end
|
||||||
|
tinsert(texts, change.value)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
formatters = Private.CreateFormatters(texts, getter)
|
||||||
|
end
|
||||||
|
|
||||||
|
local customTextFunc = nil
|
||||||
|
if containsCustomText and data.customText and data.customText ~= "" then
|
||||||
|
customTextFunc = WeakAuras.LoadFunction("return "..data.customText)
|
||||||
|
end
|
||||||
|
|
||||||
|
function region:ConfigureTextUpdate()
|
||||||
|
local UpdateText
|
||||||
|
if self.displayText and Private.ContainsAnyPlaceHolders(self.displayText) then
|
||||||
|
UpdateText = function()
|
||||||
|
local textStr = self.displayText;
|
||||||
|
textStr = Private.ReplacePlaceHolders(textStr, self, nil, false, formatters);
|
||||||
|
if (textStr == nil or textStr == "") then
|
||||||
|
textStr = " ";
|
||||||
|
end
|
||||||
|
|
||||||
|
SetText(textStr)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local Update
|
||||||
|
if customTextFunc and self.displayText and Private.ContainsCustomPlaceHolder(self.displayText) then
|
||||||
|
Update = function()
|
||||||
|
self.values.custom = Private.RunCustomTextFunc(self, customTextFunc)
|
||||||
|
UpdateText()
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Update = UpdateText or function() end
|
||||||
|
end
|
||||||
|
|
||||||
|
local TimerTick
|
||||||
|
if Private.ContainsPlaceHolders(self.displayText, "p") then
|
||||||
|
TimerTick = UpdateText
|
||||||
|
end
|
||||||
|
|
||||||
|
local FrameTick
|
||||||
|
if customTextFunc and data.customTextUpdate == "update" then
|
||||||
|
if Private.ContainsCustomPlaceHolder(self.displayText) then
|
||||||
|
FrameTick = function()
|
||||||
|
self.values.custom = Private.RunCustomTextFunc(self, customTextFunc)
|
||||||
|
UpdateText()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
self.Update = Update
|
||||||
|
self.FrameTick = FrameTick
|
||||||
|
self.TimerTick = TimerTick
|
||||||
|
|
||||||
|
if not UpdateText then
|
||||||
|
local textStr = self.displayText
|
||||||
|
textStr = textStr:gsub("\\n", "\n");
|
||||||
SetText(textStr)
|
SetText(textStr)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local customTextFunc = nil
|
function region:ConfigureSubscribers()
|
||||||
if(Private.ContainsCustomPlaceHolder(data.displayText) and data.customText) then
|
if self.FrameTick then
|
||||||
customTextFunc = WeakAuras.LoadFunction("return "..data.customText)
|
self.subRegionEvents:AddSubscriber("FrameTick", self)
|
||||||
end
|
else
|
||||||
|
self.subRegionEvents:RemoveSubscriber("FrameTick", self)
|
||||||
local Update
|
|
||||||
if customTextFunc then
|
|
||||||
if UpdateText then
|
|
||||||
Update = function()
|
|
||||||
region.values.custom = Private.RunCustomTextFunc(region, customTextFunc)
|
|
||||||
UpdateText()
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
else
|
|
||||||
Update = UpdateText or function() end
|
|
||||||
end
|
|
||||||
|
|
||||||
local TimerTick
|
if self.TimerTick then
|
||||||
if Private.ContainsPlaceHolders(data.displayText, "p") then
|
self.subRegionEvents:AddSubscriber("TimerTick", self, true)
|
||||||
TimerTick = UpdateText
|
else
|
||||||
end
|
self.subRegionEvents:RemoveSubscriber("TimerTick", self)
|
||||||
|
end
|
||||||
local FrameTick
|
if self.Update and self.state then
|
||||||
if customTextFunc and data.customTextUpdate == "update" then
|
self:Update()
|
||||||
FrameTick = function()
|
|
||||||
region.values.custom = Private.RunCustomTextFunc(region, customTextFunc)
|
|
||||||
UpdateText()
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
region.Update = Update
|
|
||||||
region.FrameTick = FrameTick
|
|
||||||
region.TimerTick = TimerTick
|
|
||||||
if TimerTick then
|
|
||||||
region.subRegionEvents:AddSubscriber("TimerTick", region, true)
|
|
||||||
else
|
|
||||||
region.subRegionEvents:RemoveSubscriber("TimerTick", region)
|
|
||||||
end
|
|
||||||
|
|
||||||
if FrameTick then
|
|
||||||
region.subRegionEvents:AddSubscriber("FrameTick", region)
|
|
||||||
else
|
|
||||||
region.subRegionEvents:RemoveSubscriber("FrameTick", region)
|
|
||||||
end
|
|
||||||
|
|
||||||
if not UpdateText then
|
|
||||||
local textStr = data.displayText
|
|
||||||
textStr = textStr:gsub("\\n", "\n");
|
|
||||||
SetText(textStr)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function region:Color(r, g, b, a)
|
function region:Color(r, g, b, a)
|
||||||
@@ -279,6 +324,16 @@ local function modify(parent, region, data)
|
|||||||
region.text:SetTextHeight(size)
|
region.text:SetTextHeight(size)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function region:ChangeText(msg)
|
||||||
|
self.displayText = msg
|
||||||
|
self:ConfigureTextUpdate()
|
||||||
|
self:ConfigureSubscribers()
|
||||||
|
end
|
||||||
|
|
||||||
|
region.displayText = data.displayText
|
||||||
|
region:ConfigureTextUpdate()
|
||||||
|
region:ConfigureSubscribers()
|
||||||
|
|
||||||
WeakAuras.regionPrototype.modifyFinish(parent, region, data);
|
WeakAuras.regionPrototype.modifyFinish(parent, region, data);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
+11
-2
@@ -4561,7 +4561,8 @@ end
|
|||||||
function Private.CreateFormatters(input, getter, withoutColor)
|
function Private.CreateFormatters(input, getter, withoutColor)
|
||||||
local seenSymbols = {}
|
local seenSymbols = {}
|
||||||
local formatters = {}
|
local formatters = {}
|
||||||
Private.ParseTextStr(input, function(symbol)
|
|
||||||
|
local parseFn = function(symbol)
|
||||||
if not seenSymbols[symbol] then
|
if not seenSymbols[symbol] then
|
||||||
local _, sym = string.match(symbol, "(.+)%.(.+)")
|
local _, sym = string.match(symbol, "(.+)%.(.+)")
|
||||||
sym = sym or symbol
|
sym = sym or symbol
|
||||||
@@ -4576,7 +4577,15 @@ function Private.CreateFormatters(input, getter, withoutColor)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
seenSymbols[symbol] = true
|
seenSymbols[symbol] = true
|
||||||
end)
|
end
|
||||||
|
|
||||||
|
if type(input) == "string" then
|
||||||
|
Private.ParseTextStr(input, parseFn)
|
||||||
|
elseif type(input) == "table" then
|
||||||
|
for _, v in ipairs(input) do
|
||||||
|
Private.ParseTextStr(v, parseFn)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return formatters
|
return formatters
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -12,6 +12,30 @@ local hiddenFontExtra = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function createOptions(id, data)
|
local function createOptions(id, data)
|
||||||
|
local function hideCustomTextOption()
|
||||||
|
if OptionsPrivate.Private.ContainsCustomPlaceHolder(data.displayText) then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if type(data.conditions) == "table" then
|
||||||
|
for _, condition in ipairs(data.conditions) do
|
||||||
|
if type(condition.changes) == "table" then
|
||||||
|
for _, change in ipairs(condition.changes) do
|
||||||
|
if type(change.property) == "string"
|
||||||
|
and change.property == "displayText"
|
||||||
|
and type(change.value) == "string"
|
||||||
|
and OptionsPrivate.Private.ContainsCustomPlaceHolder(change.value)
|
||||||
|
then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
local options = {
|
local options = {
|
||||||
__title = L["Text Settings"],
|
__title = L["Text Settings"],
|
||||||
__order = 1,
|
__order = 1,
|
||||||
@@ -38,7 +62,7 @@ local function createOptions(id, data)
|
|||||||
customTextUpdate = {
|
customTextUpdate = {
|
||||||
type = "select",
|
type = "select",
|
||||||
width = WeakAuras.doubleWidth,
|
width = WeakAuras.doubleWidth,
|
||||||
hidden = function() return not OptionsPrivate.Private.ContainsCustomPlaceHolder(data.displayText); end,
|
hidden = hideCustomTextOption,
|
||||||
name = L["Update Custom Text On..."],
|
name = L["Update Custom Text On..."],
|
||||||
values = OptionsPrivate.Private.text_check_types,
|
values = OptionsPrivate.Private.text_check_types,
|
||||||
order = 36
|
order = 36
|
||||||
@@ -267,7 +291,7 @@ local function createOptions(id, data)
|
|||||||
};
|
};
|
||||||
|
|
||||||
OptionsPrivate.commonOptions.AddCodeOption(options, data, L["Custom Function"], "customText", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#custom-text",
|
OptionsPrivate.commonOptions.AddCodeOption(options, data, L["Custom Function"], "customText", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#custom-text",
|
||||||
37, function() return not OptionsPrivate.Private.ContainsCustomPlaceHolder(data.displayText) end, {"customText"}, false);
|
37, hideCustomTextOption, {"customText"}, false);
|
||||||
|
|
||||||
-- Add Text Format Options
|
-- Add Text Format Options
|
||||||
local hidden = function()
|
local hidden = function()
|
||||||
@@ -299,11 +323,29 @@ local function createOptions(id, data)
|
|||||||
end
|
end
|
||||||
|
|
||||||
for child in OptionsPrivate.Private.TraverseLeafsOrAura(data) do
|
for child in OptionsPrivate.Private.TraverseLeafsOrAura(data) do
|
||||||
|
local texts = {}
|
||||||
|
if child.displayText ~= "" then
|
||||||
|
tinsert(texts, child.displayText)
|
||||||
|
end
|
||||||
|
for _, condition in ipairs(child.conditions) do
|
||||||
|
if type(condition.changes) == "table" then
|
||||||
|
for _, change in ipairs(condition.changes) do
|
||||||
|
if type(change.property) == "string"
|
||||||
|
and change.property == "displayText"
|
||||||
|
and type(change.value) == "string"
|
||||||
|
and change.value ~= ""
|
||||||
|
then
|
||||||
|
tinsert(texts, change.value)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local get = function(key)
|
local get = function(key)
|
||||||
return child["displayText_format_" .. key]
|
return child["displayText_format_" .. key]
|
||||||
end
|
end
|
||||||
local input = child.displayText
|
|
||||||
OptionsPrivate.AddTextFormatOption(input, true, get, addOption, hidden, setHidden, false, index, total)
|
OptionsPrivate.AddTextFormatOption(texts, true, get, addOption, hidden, setHidden, false, index, total)
|
||||||
index = index + 1
|
index = index + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1957,7 +1957,7 @@ function OptionsPrivate.AddTextFormatOption(input, withHeader, get, addOption, h
|
|||||||
|
|
||||||
|
|
||||||
local seenSymbols = {}
|
local seenSymbols = {}
|
||||||
OptionsPrivate.Private.ParseTextStr(input, function(symbol)
|
local parseFn = function(symbol)
|
||||||
if not seenSymbols[symbol] then
|
if not seenSymbols[symbol] then
|
||||||
local _, sym = string.match(symbol, "(.+)%.(.+)")
|
local _, sym = string.match(symbol, "(.+)%.(.+)")
|
||||||
sym = sym or symbol
|
sym = sym or symbol
|
||||||
@@ -1987,7 +1987,15 @@ function OptionsPrivate.AddTextFormatOption(input, withHeader, get, addOption, h
|
|||||||
seenSymbols[symbol] = true
|
seenSymbols[symbol] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end
|
||||||
|
|
||||||
|
if type(input) == "table" then
|
||||||
|
for _, txt in ipairs(input) do
|
||||||
|
OptionsPrivate.Private.ParseTextStr(txt, parseFn)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
OptionsPrivate.Private.ParseTextStr(input, parseFn)
|
||||||
|
end
|
||||||
|
|
||||||
if withHeader and (not index or index == total) then
|
if withHeader and (not index or index == total) then
|
||||||
addOption("header_anchor",
|
addOption("header_anchor",
|
||||||
|
|||||||
Reference in New Issue
Block a user