This commit is contained in:
Bunny67
2020-06-02 23:40:06 +03:00
commit f2e1a0928d
516 changed files with 185320 additions and 0 deletions
+155
View File
@@ -0,0 +1,155 @@
if not WeakAuras.IsCorrectVersion() then return end
local SharedMedia = LibStub("LibSharedMedia-3.0");
local L = WeakAuras.L;
local default = function(parentType)
return {
bar_model_visible = true,
bar_model_alpha = 1,
model_x = 0,
model_y = 0,
model_z = 0,
rotation = 0,
model_path = "235338",
bar_model_clip = true
}
end
local properties = {
bar_model_visible = {
display = L["Visibility"],
setter = "SetVisible",
type = "bool",
defaultProperty = true
},
bar_model_alpha = {
display = L["Alpha"],
setter = "SetAlpha",
type = "number",
min = 0,
max = 1,
bigStep = 0.1
}
}
local function CreateModel()
return CreateFrame("PlayerModel", nil, UIParent)
end
-- Keep the two model apis separate
local pool = CreateObjectPool(CreateModel)
local function AcquireModel(region, data)
local model = pool:Acquire()
model:ClearAllPoints()
if region.parentType == "aurabar" then
model:SetAllPoints(region.parent.bar)
else
model:SetAllPoints(region.parent)
end
model:SetParent(region)
--model:SetKeepModelOnHide(true)
model:Show()
-- Adjust model
model:SetModel(data.model_path)
model:SetPosition(data.model_z, data.model_x, data.model_y);
model:SetScript("OnShow", function()
model:SetModel(data.model_path)
model:SetPosition(data.model_z, data.model_x, data.model_y);
end)
model:SetFacing(0);
return model
end
local function ReleaseModel(model)
--model:SetKeepModelOnHide(false)
model:Hide()
pool:Release(model)
end
local function create()
local subRegion = CreateFrame("FRAME", nil, UIParent)
--subRegion:SetClipsChildren(true)
return subRegion
end
local function onAcquire(subRegion)
subRegion:Show()
end
local function onRelease(subRegion)
subRegion:Hide()
end
local funcs = {
SetVisible = function(self, visible)
self.visible = visible
if visible then
if not self.model then
self.model = AcquireModel(self, self.data)
self.model:SetAlpha(self.alpha)
end
self:Show()
else
self:Hide()
if self.model then
ReleaseModel(self.model)
self.model = nil
end
end
end,
SetAlpha = function(self, alpha)
if self.model then
self.model:SetAlpha(alpha)
end
self.alpha = alpha
end,
AlphaChanged = function(self)
self:SetAlpha(self.alpha)
end
}
local function modify(parent, region, parentData, data, first)
if region.model then
ReleaseModel(region.model)
region.model = nil
end
region.data = data
region.parentType = parentData.regionType
region.parent = parent
region:SetParent(parent)
if parentData.regionType == "aurabar" then
if data.bar_model_clip then
region:SetAllPoints(parent.bar.fgFrame)
else
region:SetAllPoints(parent.bar)
end
else
region:SetAllPoints(parent)
end
for k, v in pairs(funcs) do
region[k] = v
end
region:SetAlpha(data.bar_model_alpha)
region:SetVisible(data.bar_model_visible)
parent.subRegionEvents:AddSubscriber("AlphaChanged", region)
end
local function supports(regionType)
return regionType == "aurabar" or regionType == "icon"
end
WeakAuras.RegisterSubRegionType("subbarmodel", L["Model"], supports, create, modify, onAcquire, onRelease, default, nil, properties);
+84
View File
@@ -0,0 +1,84 @@
if not WeakAuras.IsCorrectVersion() then return end
local SharedMedia = LibStub("LibSharedMedia-3.0");
local L = WeakAuras.L;
local default = function(parentType)
local options = {
border_visible = true,
border_color = {1, 1, 1, 1},
border_edge = "Square Full White",
border_offset = 0,
border_size = 2,
}
if parentType == "aurabar" then
options["border_anchor"] = "bar"
end
return options
end
local properties = {
border_visible = {
display = L["Show Border"],
setter = "SetVisible",
type = "bool",
defaultProperty = true
},
border_color = {
display = L["Border Color"],
setter = "SetBorderColor",
type = "color"
},
}
local function create()
return CreateFrame("FRAME", nil, UIParent)
end
local function onAcquire(subRegion)
subRegion:Show()
end
local function onRelease(subRegion)
subRegion:Hide()
end
local function modify(parent, region, parentData, data, first)
region:SetParent(parent)
parent:AnchorSubRegion(region, "area", parentData.regionType == "aurabar" and data.border_anchor, nil, data.border_offset, data.border_offset)
region:SetBackdrop({
edgeFile = SharedMedia:Fetch("border", data.border_edge) or "",
edgeSize = data.border_size,
bgFile = nil,
});
region:SetBackdropBorderColor(data.border_color[1], data.border_color[2], data.border_color[3], data.border_color[4])
region:SetBackdropColor(0, 0, 0, 0)
function region:SetBorderColor(r, g, b, a)
self:SetBackdropBorderColor(r, g, b, a or 1)
end
region:SetBorderColor(data.border_color[1], data.border_color[2], data.border_color[3], data.border_color[4]);
function region:SetVisible(visible)
if visible then
self:Show()
else
self:Hide()
end
end
region:SetVisible(data.border_visible)
end
local function supports(regionType)
return regionType == "texture"
or regionType == "progresstexture"
or regionType == "icon"
or regionType == "aurabar"
end
WeakAuras.RegisterSubRegionType("subborder", L["Border"], supports, create, modify, onAcquire, onRelease, default, nil, properties);
+390
View File
@@ -0,0 +1,390 @@
if not WeakAuras.IsCorrectVersion() then return end
local SharedMedia = LibStub("LibSharedMedia-3.0");
local LCG = LibStub("LibCustomGlow-1.0")
local MSQ, MSQ_Version = LibStub("Masque", true);
if MSQ then
if MSQ_Version <= 80100 then
MSQ = nil
end
end
local L = WeakAuras.L;
local default = function(parentType)
local options = {
glow = false,
useGlowColor = false,
glowColor = {1, 1, 1, 1},
glowType = "buttonOverlay",
glowLines = 8,
glowFrequency = 0.25,
glowLength = 10,
glowThickness = 1,
glowScale = 1,
glowBorder = false,
glowXOffset = 0,
glowYOffset = 0,
}
if parentType == "aurabar" then
options["glow_anchor"] = "bar"
end
return options
end
local properties = {
glow = {
display = L["Show Glow"],
setter = "SetVisible",
type = "bool",
defaultProperty = true
},
glowType = {
display =L["Type"],
setter = "SetGlowType",
type = "list",
values = WeakAuras.glow_types,
},
useGlowColor = {
display = L["Use Custom Color"],
setter = "SetUseGlowColor",
type = "bool"
},
glowColor = {
display = L["Custom Color"],
setter = "SetGlowColor",
type = "color"
},
glowLines = {
display = L["Lines & Particles"],
setter = "SetGlowLines",
type = "number",
min = 1,
softMax = 30,
bigStep = 1,
default = 4
},
glowFrequency = {
display = L["Frequency"],
setter = "SetGlowFrequency",
type = "number",
softMin = -2,
softMax = 2,
bigStep = 0.1,
default = 0.25
},
glowLength = {
display = L["Length"],
setter = "SetGlowLength",
type = "number",
min = 1,
softMax = 20,
bigStep = 1,
default = 10
},
glowThickness = {
display = L["Thickness"],
setter = "SetGlowThickness",
type = "number",
min = 1,
softMax = 20,
bigStep = 1,
default = 1
},
glowScale = {
display = L["Scale"],
setter = "SetGlowScale",
type = "number",
min = 0.05,
softMax = 10,
bigStep = 0.05,
default = 1,
isPercent = true
},
glowBorder = {
display = L["Border"],
setter = "SetGlowBorder",
type = "bool"
},
glowXOffset = {
display = L["X-Offset"],
setter = "SetGlowXOffset",
type = "number",
softMin = -100,
softMax = 100,
bigStep = 1,
default = 0
},
glowYOffset = {
display = L["Y-Offset"],
setter = "SetGlowYOffset",
type = "number",
softMin = -100,
softMax = 100,
bigStep = 1,
default = 0
},
}
local function glowStart(self, frame, color)
if frame:GetWidth() < 1 or frame:GetHeight() < 1 then
self.glowStop(frame)
return
end
if self.glowType == "buttonOverlay" then
self.glowStart(frame, color, self.glowFrequency, 0)
elseif self.glowType == "Pixel" then
self.glowStart(
frame,
color,
self.glowLines,
self.glowFrequency,
self.glowLength,
self.glowThickness,
self.glowXOffset,
self.glowYOffset,
self.glowBorder,
nil,
0
)
elseif self.glowType == "ACShine" then
self.glowStart(
frame,
color,
self.glowLines,
self.glowFrequency,
self.glowScale,
self.glowXOffset,
self.glowYOffset,
nil,
0
)
end
end
local funcs = {
SetVisible = function(self, visible)
local color
self.glow = visible
if self.useGlowColor then
color = self.glowColor
end
if MSQ and self.parentType == "icon" then
if (visible) then
self.__MSQ_Shape = self:GetParent().button.__MSQ_Shape
glowStart(self, self, color);
else
self.glowStop(self);
end
elseif (visible) then
glowStart(self, self, color);
else
self.glowStop(self);
end
if visible then
self:Show()
else
self:Hide()
end
end,
SetGlowType = function(self, newType)
newType = newType or "buttonOverlay"
if newType == self.glowType then
return
end
local isGlowing = self.glow
if isGlowing then
self:SetVisible(false)
end
if newType == "buttonOverlay" then
self.glowStart = LCG.ButtonGlow_Start
self.glowStop = LCG.ButtonGlow_Stop
if self.parentRegionType ~= "aurabar" then
self.parent:AnchorSubRegion(self, "area", "region")
end
elseif newType == "ACShine" then
self.glowStart = LCG.AutoCastGlow_Start
self.glowStop = LCG.AutoCastGlow_Stop
if self.parentRegionType ~= "aurabar" then
self.parent:AnchorSubRegion(self, "area")
end
elseif newType == "Pixel" then
self.glowStart = LCG.PixelGlow_Start
self.glowStop = LCG.PixelGlow_Stop
if self.parentRegionType ~= "aurabar" then
self.parent:AnchorSubRegion(self, "area")
end
end
self.glowType = newType
if isGlowing then
self:SetVisible(true)
end
end,
SetUseGlowColor = function(self, useGlowColor)
self.useGlowColor = useGlowColor
if self.glow then
self:SetVisible(true)
end
end,
SetGlowColor = function(self, r, g, b, a)
self.glowColor = {r, g, b, a}
if self.glow then
self:SetVisible(true)
end
end,
SetGlowLines = function(self, lines)
self.glowLines = lines
if self.glow then
if self.glowType == "ACShine" then -- workaround ACShine not updating numbers of dots
self:SetVisible(false)
end
self:SetVisible(true)
end
end,
SetGlowFrequency = function(self, frequency)
self.glowFrequency = frequency
if self.glow then
self:SetVisible(true)
end
end,
SetGlowLength = function(self, length)
self.glowLength = length
if self.glow then
self:SetVisible(true)
end
end,
SetGlowThickness = function(self, thickness)
self.glowThickness = thickness
if self.glow then
self:SetVisible(true)
end
end,
SetGlowScale = function(self, scale)
self.glowScale = scale
if self.glow then
self:SetVisible(true)
end
end,
SetGlowBorder = function(self, border)
self.glowBorder = border
if self.glow then
self:SetVisible(true)
end
end,
SetGlowXOffset = function(self, xoffset)
self.glowXOffset = xoffset
if self.glow then
self:SetVisible(true)
end
end,
SetGlowYOffset = function(self, yoffset)
self.glowYOffset = yoffset
if self.glow then
self:SetVisible(true)
end
end,
UpdateSize = function(self, ...)
if self.glow then
self:SetVisible(true)
end
end
}
local function create()
local region = CreateFrame("FRAME", nil, UIParent)
for name, func in pairs(funcs) do
region[name] = func
end
return region
end
local function onAcquire(subRegion)
subRegion:Show()
end
local function onRelease(subRegion)
subRegion.glowType = nil
subRegion:Hide()
subRegion:ClearAllPoints()
subRegion:SetParent(UIParent)
end
local function modify(parent, region, parentData, data, first)
region:SetParent(parent)
region.parentRegionType = parentData.regionType
if parentData.regionType == "aurabar" then
parent:AnchorSubRegion(region, "area", data.glow_anchor)
else
parent:AnchorSubRegion(region, "area", data.glowType == "buttonOverlay" and "region")
end
region.parent = parent
region.parentType = parentData.regionType
region.useGlowColor = data.useGlowColor
region.glowColor = data.glowColor
region.glowLines = data.glowLines
region.glowFrequency = data.glowFrequency
region.glowLength = data.glowLength
region.glowThickness = data.glowThickness
region.glowScale = data.glowScale
region.glowBorder = data.glowBorder
region.glowXOffset = data.glowXOffset
region.glowYOffset = data.glowYOffset
region:SetGlowType(data.glowType)
region:SetVisible(data.glow)
region:SetScript("OnSizeChanged", region.UpdateSize)
end
function WeakAuras.getDefaultGlow(regionType)
if regionType == "aurabar" then
return {
["type"] = "subglow",
glow = false,
useGlowColor = false,
glowColor = {1, 1, 1, 1},
glowType = "Pixel",
glowLines = 8,
glowFrequency = 0.25,
glowLength = 10,
glowThickness = 1,
glowScale = 1,
glowBorder = false,
glowXOffset = 0,
glowYOffset = 0,
glow_anchor = "bar"
}
elseif regionType == "icon" then
return {
["type"] = "subglow",
glow = false,
useGlowColor = false,
glowColor = {1, 1, 1, 1},
glowType = "buttonOverlay",
glowLines = 8,
glowFrequency = 0.25,
glowLength = 10,
glowThickness = 1,
glowScale = 1,
glowBorder = false,
glowXOffset = 0,
glowYOffset = 0,
}
end
end
local function supports(regionType)
return regionType == "icon"
or regionType == "aurabar"
end
WeakAuras.RegisterSubRegionType("subglow", L["Glow"], supports, create, modify, onAcquire, onRelease, default, nil, properties);
+473
View File
@@ -0,0 +1,473 @@
if not WeakAuras.IsCorrectVersion() then return end
local SharedMedia = LibStub("LibSharedMedia-3.0");
local L = WeakAuras.L;
local defaultFont = WeakAuras.defaultFont
local defaultFontSize = WeakAuras.defaultFontSize
local default = function(parentType)
if parentType == "icon" then
-- No Shadow, but Outline
return {
text_text = "%p",
text_color = {1, 1, 1, 1},
text_font = defaultFont,
text_fontSize = defaultFontSize,
text_fontType = "OUTLINE",
text_visible = true,
text_justify = "CENTER",
text_selfPoint = "AUTO",
text_anchorPoint = "CENTER",
anchorXOffset = 0,
anchorYOffset = 0,
text_shadowColor = { 0, 0, 0, 1},
text_shadowXOffset = 0,
text_shadowYOffset = 0,
rotateText = "NONE",
text_automaticWidth = "Auto",
text_fixedWidth = 64,
text_wordWrap = "WordWrap",
}
else
-- With Shadow, without Outline
return {
text_text = "%n",
text_color = {1, 1, 1, 1},
text_font = defaultFont,
text_fontSize = defaultFontSize,
text_fontType = "None",
text_visible = true,
text_justify = "CENTER",
text_selfPoint = "AUTO",
text_anchorPoint = parentType == "aurabar" and "INNER_RIGHT" or "BOTTOMLEFT",
anchorXOffset = 0,
anchorYOffset = 0,
text_shadowColor = { 0, 0, 0, 1},
text_shadowXOffset = 1,
text_shadowYOffset = -1,
rotateText = "NONE",
text_automaticWidth = "Auto",
text_fixedWidth = 64,
text_wordWrap = "WordWrap",
}
end
end
local properties = {
text_visible = {
display = L["Visibility"],
setter = "SetVisible",
type = "bool",
defaultProperty = true
},
text_color = {
display = L["Color"],
setter = "Color",
type = "color",
},
text_fontSize = {
display = L["Font Size"],
setter = "SetTextHeight",
type = "number",
min = 6,
softMax = 72,
step = 1,
default = 12
}
}
-- Rotate object around its origin
local function animRotate(object, degrees, anchor)
if (not anchor) then
anchor = "CENTER";
end
-- Something to rotate
if object.animationGroup or degrees ~= 0 then
-- Create AnimatioGroup and rotation animation
object.animationGroup = object.animationGroup or object:CreateAnimationGroup();
local group = object.animationGroup;
group.rotate = group.rotate or group:CreateAnimation("rotation");
local rotate = group.rotate;
if rotate:GetDegrees() == degrees and rotate:GetOrigin() == anchor then
return
end
rotate:SetOrigin(anchor, 0, 0);
rotate:SetDegrees(degrees);
rotate:SetDuration(0);
rotate:SetEndDelay(2147483647);
group:Play();
rotate:SetSmoothProgress(1);
group:Pause();
end
end
-- Calculate offset after rotation
local function getRotateOffset(object, degrees, point)
-- Any rotation at all?
if degrees ~= 0 then
-- Basic offset
local originoffset = object:GetStringHeight() / 2;
local xo = -1 * originoffset * sin(degrees);
local yo = originoffset * (cos(degrees) - 1);
-- Alignment dependant offset
if point:find("BOTTOM", 1, true) then
yo = yo + (1 - cos(degrees)) * (object:GetStringWidth() / 2 - originoffset);
elseif point:find("TOP", 1, true) then
yo = yo - (1 - cos(degrees)) * (object:GetStringWidth() / 2 - originoffset);
end
if point:find("RIGHT", 1, true) then
xo = xo + (1 - cos(degrees)) * (object:GetStringWidth() / 2 - originoffset);
elseif point:find("LEFT", 1, true) then
xo = xo - (1 - cos(degrees)) * (object:GetStringWidth() / 2 - originoffset);
end
-- Done
return xo, yo;
-- No rotation
else
return 0, 0;
end
end
local function create()
local region = CreateFrame("FRAME", nil, UIParent);
local text = region:CreateFontString(nil, "OVERLAY");
region.text = text;
-- WOW's layout system works best if frames and all their parents are anchored
-- In this case, it appears that a text doesn't get the right size on the initial
-- load with a custom font. (Though it works if the font is non-custom or after
-- a reloadui). Just moving the normal AnchorSubRegion to the start of modify was not enough
-- But anchoring the text to UIParent before reanchoring it correctly does seem to fix
-- the issue. Also see #1778
text:SetPoint("CENTER", UIParent, "CENTER")
text:SetWordWrap(true)
text:SetNonSpaceWrap(true)
return region;
end
local function onAcquire(subRegion)
subRegion:Show()
end
local function onRelease(subRegion)
subRegion:Hide()
end
local function modify(parent, region, parentData, data, first)
region:SetParent(parent)
local text = region.text;
-- Legacy members in icon
-- Can we remove them with 9.0 ?
if parentData.regionType == "icon" then
if not parent.stacks then
parent.stacks = text
elseif not parent.text2 then
parent.text2 = text
end
elseif parentData.regionType == "aurabar" then
if not parent.timer then
parent.timer = text
elseif not parent.text then
parent.text = text
elseif not parent.stacks then
parent.stacks = text
end
end
local fontPath = SharedMedia:Fetch("font", data.text_font);
text:SetFont(fontPath, data.text_fontSize, data.text_fontType);
if not text:GetFont() then -- Font invalid, set the font but keep the setting
text:SetFont(STANDARD_TEXT_FONT, data.text_fontSize, data.text_fontType);
end
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")
if (data.text_automaticWidth == "Fixed") then
if (data.text_wordWrap == "WordWrap") then
text:SetWordWrap(true);
text:SetNonSpaceWrap(true);
else
text:SetWordWrap(false);
text:SetNonSpaceWrap(false);
end
text:SetWidth(data.text_fixedWidth);
region:SetWidth(data.text_fixedWidth);
region.width = data.text_fixedWidth;
else
text:SetWidth(0);
text:SetWordWrap(true);
text:SetNonSpaceWrap(true);
end
if first then
-- Certain data is stored directly on the parent, because it's shared between multiple texts
-- And shared by other code paths e.g. SendChatMessage
-- That is partly for legacy reasons
parent.progressPrecision = parentData.progressPrecision
parent.totalPrecision = parentData.totalPrecision
local containsCustomText = false
for index, subRegion in ipairs(parentData.subRegions) do
if subRegion.type == "subtext" and WeakAuras.ContainsCustomPlaceHolder(subRegion.text_text) then
containsCustomText = true
break
end
end
if containsCustomText and parentData.customText and parentData.customText ~= "" then
parent.customTextFunc = WeakAuras.LoadFunction("return "..parentData.customText, parentData.id, "custom text")
else
parent.customTextFunc = nil
end
parent.values.custom = nil
end
local UpdateText
if data.text_text and WeakAuras.ContainsAnyPlaceHolders(data.text_text) then
UpdateText = function()
local textStr = data.text_text or ""
textStr = WeakAuras.ReplacePlaceHolders(textStr, parent, nil)
if text:GetFont() then
text:SetText(WeakAuras.ReplaceRaidMarkerSymbols(textStr))
end
region:UpdateAnchor()
end
end
local Update
if first and parent.customTextFunc then
if UpdateText then
Update = function()
parent.values.custom = WeakAuras.RunCustomTextFunc(parent, parent.customTextFunc)
UpdateText()
end
else
Update = function()
parent.values.custom = WeakAuras.RunCustomTextFunc(parent, parent.customTextFunc)
end
end
else
Update = UpdateText
end
local TimerTick
if WeakAuras.ContainsPlaceHolders(data.text_text, "p") then
TimerTick = UpdateText
end
local FrameTick
if parent.customTextFunc and parentData.customTextUpdate == "update" then
if first then
if WeakAuras.ContainsCustomPlaceHolder(data.text_text) then
FrameTick = function()
parent.values.custom = WeakAuras.RunCustomTextFunc(parent, parent.customTextFunc)
UpdateText()
end
else
FrameTick = function()
parent.values.custom = WeakAuras.RunCustomTextFunc(parent, parent.customTextFunc)
end
end
else
if WeakAuras.ContainsCustomPlaceHolder(data.text_text) then
FrameTick = UpdateText
end
end
end
region.Update = Update
region.FrameTick = FrameTick
region.TimerTick = TimerTick
if Update then
parent.subRegionEvents:AddSubscriber("Update", region)
end
if FrameTick then
parent.subRegionEvents:AddSubscriber("FrameTick", region)
end
if TimerTick then
parent.subRegionEvents:AddSubscriber("TimerTick", region)
end
if not UpdateText then
if text:GetFont() then
text:SetText(WeakAuras.ReplaceRaidMarkerSymbols(data.text_text))
end
end
function region:Color(r, g, b, a)
region.color_r = r;
region.color_g = g;
region.color_b = b;
region.color_a = a;
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
region:Color(data.text_color[1], data.text_color[2], data.text_color[3], data.text_color[4]);
function region:SetTextHeight(size)
local fontPath = SharedMedia:Fetch("font", data.text_font);
region.text:SetFont(fontPath, size, data.text_fontType);
region.text:SetTextHeight(size)
region:UpdateAnchor();
end
function region:SetVisible(visible)
if visible then
self:Show()
else
self:Hide()
end
end
region:SetVisible(data.text_visible)
local selfPoint = data.text_selfPoint
if selfPoint == "AUTO" then
if parentData.regionType == "icon" then
local anchorPoint = data.text_anchorPoint or "CENTER"
if anchorPoint:sub(1, 6) == "INNER_" then
selfPoint = anchorPoint:sub(7)
elseif anchorPoint:sub(1, 6) == "OUTER_" then
anchorPoint = anchorPoint:sub(7)
selfPoint = WeakAuras.inverse_point_types[anchorPoint] or "CENTER"
else
selfPoint = "CENTER"
end
elseif parentData.regionType == "aurabar" then
selfPoint = data.text_anchorPoint or "CENTER"
if selfPoint:sub(1, 5) == "ICON_" then
selfPoint = selfPoint:sub(6)
elseif selfPoint:sub(1, 6) == "INNER_" then
selfPoint = selfPoint:sub(7)
end
selfPoint = WeakAuras.point_types[selfPoint] and selfPoint or "CENTER"
else
selfPoint = WeakAuras.inverse_point_types[data.text_anchorPoint or "CENTER"] or "CENTER"
end
end
local textDegrees = data.rotateText == "LEFT" and 90 or data.rotateText == "RIGHT" and -90 or 0;
local xo, yo = getRotateOffset(text, textDegrees, selfPoint)
parent:AnchorSubRegion(text, "point", selfPoint, data.text_anchorPoint, (data.text_anchorXOffset or 0) + xo, (data.text_anchorYOffset or 0) + yo)
animRotate(text, textDegrees, selfPoint)
if textDegrees == 0 then
region.UpdateAnchor = function() end
else
region.UpdateAnchor = function(self)
local xo, yo = getRotateOffset(self.text, textDegrees, selfPoint)
parent:AnchorSubRegion(self.text, "point", selfPoint, data.text_anchorPoint, (data.text_anchorXOffset or 0) + xo, (data.text_anchorYOffset or 0) + yo)
end
end
end
local function addDefaultsForNewAura(data)
if data.regionType == "aurabar" then
tinsert(data.subRegions, {
["type"] = "subtext",
text_text = "%p",
text_color = {1, 1, 1, 1},
text_font = defaultFont,
text_fontSize = defaultFontSize,
text_fontType = "None",
text_justify = "CENTER",
text_visible = true,
text_selfPoint = "AUTO",
text_anchorPoint = "INNER_LEFT",
anchorXOffset = 0,
anchorYOffset = 0,
text_shadowColor = { 0, 0, 0, 1},
text_shadowXOffset = 1,
text_shadowYOffset = -1,
rotateText = "NONE",
});
tinsert(data.subRegions, {
["type"] = "subtext",
text_text = "%n",
text_color = {1, 1, 1, 1},
text_font = defaultFont,
text_fontSize = defaultFontSize,
text_fontType = "None",
text_justify = "CENTER",
text_visible = true,
text_selfPoint = "AUTO",
text_anchorPoint = "INNER_RIGHT",
anchorXOffset = 0,
anchorYOffset = 0,
text_shadowColor = { 0, 0, 0, 1},
text_shadowXOffset = 1,
text_shadowYOffset = -1,
rotateText = "NONE",
});
elseif data.regionType == "icon" then
tinsert(data.subRegions, {
["type"] = "subtext",
text_text = "%s",
text_color = {1, 1, 1, 1},
text_font = defaultFont,
text_fontSize = defaultFontSize,
text_fontType = "OUTLINE",
text_justify = "CENTER",
text_visible = true,
text_selfPoint = "AUTO",
text_anchorPoint = "INNER_BOTTOMRIGHT",
anchorXOffset = 0,
anchorYOffset = 0,
text_shadowColor = { 0, 0, 0, 1},
text_shadowXOffset = 0,
text_shadowYOffset = 0,
rotateText = "NONE",
});
end
end
local function supports(regionType)
return regionType == "texture"
or regionType == "progresstexture"
or regionType == "icon"
or regionType == "aurabar"
end
WeakAuras.RegisterSubRegionType("subtext", L["Text"], supports, create, modify, onAcquire, onRelease, default, addDefaultsForNewAura, properties);