This commit is contained in:
Bunny67
2020-07-31 19:46:21 +03:00
parent 549b04ce78
commit 02c047002d
49 changed files with 850 additions and 451 deletions
+95 -3
View File
@@ -1,4 +1,5 @@
if not WeakAuras.IsCorrectVersion() then return end
local AddonName, Private = ...
local SharedMedia = LibStub("LibSharedMedia-3.0");
local L = WeakAuras.L;
@@ -12,6 +13,14 @@ local default = function(parentType)
automatic_length = true,
tick_thickness = 2,
tick_length = 30,
use_texture = false,
tick_texture = [[Interface\CastingBar\UI-CastingBar-Spark]],
tick_blend_mode = "ADD",
tick_desaturate = false,
tick_rotation = 0,
tick_xOffset = 0,
tick_yOffset = 0,
tick_mirror = false,
}
end
@@ -61,6 +70,26 @@ local properties = {
bigStep = 1,
default = 30,
},
tick_desaturate = {
display = L["Desaturate"],
setter = "SetTickDesaturated",
type = "bool",
default = true,
},
tick_rotation = {
display = L["Rotation"],
setter = "SetTickRotation",
type = "number",
min = 0,
max = 360,
default = 0,
},
tick_mirror = {
display = L["Mirror"],
setter = "SetTickMirror",
type = "bool",
default = true,
},
}
local auraBarAnchor = {
@@ -145,7 +174,12 @@ local funcs = {
end,
SetTickColor = function(self, r, g, b, a)
self.tick_color[1], self.tick_color[2], self.tick_color[3], self.tick_color[4] = r, g, b, a or 1
self.texture:SetTexture(r, g, b, a or 1)
if self.use_texture then
self.texture:SetVertexColor(r, g, b, a or 1)
self:UpdateTickDesaturated()
else
self.texture:SetTexture(r, g, b, a or 1)
end
end,
SetTickPlacementMode = function(self, placement_mode)
if self.tick_placement_mode ~= placement_mode then
@@ -232,7 +266,7 @@ local funcs = {
end
local side = inverse and auraBarAnchorInverse or auraBarAnchor
self:ClearAllPoints()
self:SetPoint("CENTER", self.parent.bar, side[self.orientation], offsetx, offsety)
self:SetPoint("CENTER", self.parent.bar, side[self.orientation], offsetx + self.tick_xOffset, offsety + self.tick_yOffset)
end,
SetAutomaticLength = function(self, automatic_length)
if self.automatic_length ~= automatic_length then
@@ -265,7 +299,52 @@ local funcs = {
else
self:SetHeight(length)
end
end
end,
SetTickDesaturated = function(self, desaturate)
if self.use_texture and self.tick_desaturate ~= desaturate then
self.tick_desaturate = desaturate
self:UpdateTickDesaturated()
end
end,
UpdateTickDesaturated = function(self)
self.texture:SetDesaturated(self.tick_desaturate)
end,
SetTickRotation = function(self, degrees)
if self.tick_rotation ~= degrees then
self.tick_rotation = degrees
self:UpdateTickRotation()
end
end,
UpdateTickRotation = function(self)
local rad = math.rad(self.tick_rotation)
self.texture:SetRotation(rad)
end,
SetTickMirror = function(self, mirror)
if self.mirror ~= mirror then
self.mirror = mirror
self:UpdateTickMirror()
end
end,
UpdateTickMirror = function(self)
if self.mirror then
self.texture:SetTexCoord(0, 1, 1, 1, 0, 0, 1, 0)
else
self.texture:SetTexCoord(0, 0, 1, 0, 0, 1, 1, 1)
end
end,
SetTickBlendMode = function(self, mode)
if self.tick_blend_mode ~= mode then
self.tick_blend_mode = mode
self:UpdateTickBlendMode()
end
end,
UpdateTickBlendMode = function(self)
if self.use_texture then
self.texture:SetBlendMode(self.tick_blend_mode)
else
self.texture:SetBlendMode("BLEND")
end
end,
}
local function modify(parent, region, parentData, data, first)
@@ -290,13 +369,26 @@ local function modify(parent, region, parentData, data, first)
region.automatic_length = data.automatic_length
region.tick_thickness = data.tick_thickness
region.tick_length = data.tick_length
region.use_texture = data.use_texture
region.tick_texture = data.tick_texture
region.tick_xOffset = data.tick_xOffset
region.tick_yOffset = data.tick_yOffset
for k, v in pairs(funcs) do
region[k] = v
end
if data.use_texture then
region.texture:SetTexture(data.tick_texture)
end
region:SetVisible(data.tick_visible)
region:SetTickColor(unpack(data.tick_color))
region:SetTickDesaturated(data.tick_desaturate)
region:SetTickBlendMode(data.tick_blend_mode)
region:SetTickRotation(data.tick_rotation)
region:SetTickMirror(data.tick_mirror)
region:UpdateTickSize()