This commit is contained in:
Bunny67
2020-11-15 23:43:10 +03:00
parent ca4a2660ec
commit 7cbc40c959
70 changed files with 7175 additions and 3055 deletions
+59 -25
View File
@@ -8,7 +8,7 @@ local L = WeakAuras.L;
local default = {
icon = false,
desaturate = false,
auto = true,
iconSource = -1,
texture = "Blizzard",
width = 200,
height = 15,
@@ -55,17 +55,28 @@ local properties = {
type = "color",
},
icon_visible = {
display = L["Icon Visible"],
display = {L["Icon"], L["Visible"]},
setter = "SetIconVisible",
type = "bool"
},
icon_color = {
display = L["Icon Color"],
display = {L["Icon"], L["Color"]},
setter = "SetIconColor",
type = "color"
},
iconSource = {
display = {L["Icon"], L["Source"]},
setter = "SetIconSource",
type = "list",
values = {}
},
displayIcon = {
display = {L["Icon"], L["Fallback"]},
setter = "SetIcon",
type = "icon",
},
desaturate = {
display = L["Icon Desaturate"],
display = {L["Icon"], L["Desaturate"]},
setter = "SetIconDesaturated",
type = "bool",
},
@@ -75,12 +86,12 @@ local properties = {
type = "color"
},
sparkColor = {
display = L["Spark Color"],
display = {L["Spark"], L["Color"]},
setter = "SetSparkColor",
type = "color"
},
sparkHeight = {
display = L["Spark Height"],
display = {L["Spark"], L["Height"]},
setter = "SetSparkHeight",
type = "number",
min = 1,
@@ -88,7 +99,7 @@ local properties = {
bigStep = 1
},
sparkWidth = {
display = L["Spark Width"],
display = {L["Spark"], L["Width"]},
setter = "SetSparkWidth",
type = "number",
min = 1,
@@ -123,16 +134,15 @@ local properties = {
display = L["Inverse"],
setter = "SetInverse",
type = "bool"
}
},
};
WeakAuras.regionPrototype.AddProperties(properties, default);
local function GetProperties(data)
local overlayInfo = Private.GetOverlayInfo(data);
local auraProperties = CopyTable(properties)
if (overlayInfo and next(overlayInfo)) then
local auraProperties = CopyTable(properties)
for id, display in ipairs(overlayInfo) do
auraProperties["overlays." .. id] = {
display = string.format(L["%s Overlay Color"], display),
@@ -141,11 +151,10 @@ local function GetProperties(data)
type = "color",
}
end
return auraProperties;
else
return CopyTable(properties);
end
auraProperties.iconSource.values = Private.IconSources(data)
return auraProperties;
end
-- Returns tex Coord for 90° rotations + x or y flip
@@ -417,6 +426,7 @@ local barPrototype = {
["OnSizeChanged"] = function(self, width, height)
self:UpdateProgress();
self:UpdateAdditionalBars();
self:GetParent().subRegionEvents:Notify("OnRegionSizeChanged")
end,
-- Blizzard like SetMinMaxValues
@@ -866,6 +876,38 @@ local funcs = {
self:ReOrient()
self.subRegionEvents:Notify("OrientationChanged")
end,
SetIcon = function(self, iconPath)
if self.displayIcon == iconPath then
return
end
self.displayIcon = iconPath
self:UpdateIcon()
end,
SetIconSource = function(self, source)
if self.iconSource == source then
return
end
self.iconSource = source
self:UpdateIcon()
end,
UpdateIcon = function(self)
local iconPath
if self.iconSource == -1 then
iconPath = self.state.icon
elseif self.iconSource == 0 then
iconPath = self.displayIcon
else
local triggernumber = self.iconSource
if triggernumber and self.states[triggernumber] then
iconPath = self.states[triggernumber].icon
end
end
iconPath = iconPath or self.displayIcon or "Interface\\Icons\\INV_Misc_QuestionMark"
self.icon:SetTexture(iconPath)
self.icon:SetDesaturated(self.desaturateIcon);
end,
SetOverlayColor = function(self, id, r, g, b, a)
self.bar:SetAdditionalBarColor(id, { r, g, b, a});
end,
@@ -987,7 +1029,8 @@ local function modify(parent, region, data)
-- Localize
local bar, iconFrame, icon = region.bar, region.iconFrame, region.icon;
region.useAuto = data.auto and Private.CanHaveAuto(data);
region.iconSource = data.iconSource
region.displayIcon = data.displayIcon
-- Adjust region size
region:SetWidth(data.width);
@@ -1176,16 +1219,7 @@ local function modify(parent, region, data)
end
end
local path = state.icon or "Interface\\Icons\\INV_Misc_QuestionMark"
local iconPath = (
region.useAuto
and path ~= ""
and path
or data.displayIcon
or "Interface\\Icons\\INV_Misc_QuestionMark"
);
icon:SetTexture(iconPath);
icon:SetDesaturated(data.desaturate);
region:UpdateIcon()
local duration = state.duration or 0
local effectiveInverse = (state.inverse and not region.inverseDirection) or (not state.inverse and region.inverseDirection);
+5 -1
View File
@@ -78,7 +78,11 @@ end
-- Modify a given region/display
local function modify(parent, region, data)
data.selfPoint = "BOTTOMLEFT";
if data.information.groupOffset then
data.selfPoint = "BOTTOMLEFT";
else
data.selfPoint = "CENTER";
end
WeakAuras.regionPrototype.modify(parent, region, data);
-- Localize
local border = region.border;
+55 -14
View File
@@ -19,7 +19,7 @@ local _G = _G
local default = {
icon = true,
desaturate = false,
auto = true,
iconSource = -1,
inverse = false,
width = 64,
height = 64,
@@ -90,10 +90,27 @@ local properties = {
default = 0,
isPercent = true
},
iconSource = {
display = {L["Icon"], L["Source"]},
setter = "SetIconSource",
type = "list",
values = {}
},
displayIcon = {
display = {L["Icon"], L["Fallback"]},
setter = "SetIcon",
type = "icon",
}
};
WeakAuras.regionPrototype.AddProperties(properties, default);
local function GetProperties(data)
local result = CopyTable(properties)
result.iconSource.values = Private.IconSources(data)
return result
end
local function GetTexCoord(region, texWidth, aspectRatio)
region.currentCoord = region.currentCoord or {}
local usesMasque = false
@@ -256,7 +273,8 @@ local function modify(parent, region, data)
local button, icon, cooldown = region.button, region.icon, region.cooldown;
region.useAuto = data.auto and Private.CanHaveAuto(data);
region.iconSource = data.iconSource
region.displayIcon = data.displayIcon
if MSQ then
local masqueId = data.id:lower():gsub(" ", "_");
@@ -383,16 +401,39 @@ local function modify(parent, region, data)
region:Color(data.color[1], data.color[2], data.color[3], data.color[4]);
function region:SetIcon(path)
local iconPath = (
region.useAuto
and path ~= ""
and path
or data.displayIcon
or "Interface\\Icons\\INV_Misc_QuestionMark"
);
function region:SetIcon(iconPath)
if self.displayIcon == iconPath then
return
end
self.displayIcon = iconPath
self:UpdateIcon()
end
function region:SetIconSource(source)
if self.iconSource == source then
return
end
self.iconSource = source
self:UpdateIcon()
end
function region:UpdateIcon()
local iconPath
if self.iconSource == -1 then
iconPath = self.state.icon
elseif self.iconSource == 0 then
iconPath = self.displayIcon
else
local triggernumber = self.iconSource
if triggernumber and self.states[triggernumber] then
iconPath = self.states[triggernumber].icon
end
end
iconPath = iconPath or self.displayIcon or "Interface\\Icons\\INV_Misc_QuestionMark"
icon:SetTexture(iconPath)
icon:SetDesaturated(data.desaturate);
icon:SetDesaturated(data.desaturate)
end
function region:Scale(scalex, scaley)
@@ -505,7 +546,7 @@ local function modify(parent, region, data)
region:SetTime(0, math.huge)
end
region:SetIcon(state.icon or "Interface\\Icons\\INV_Misc_QuestionMark")
region:UpdateIcon()
end
else
region.SetValue = nil
@@ -513,7 +554,7 @@ local function modify(parent, region, data)
function region:Update()
local state = region.state
region:SetIcon(state.icon or "Interface\\Icons\\INV_Misc_QuestionMark")
region:UpdateIcon()
end
end
@@ -535,4 +576,4 @@ local function modify(parent, region, data)
region:SetHeight(region:GetHeight())
end
WeakAuras.RegisterRegionType("icon", create, modify, default, properties);
WeakAuras.RegisterRegionType("icon", create, modify, default, GetProperties)
+11 -8
View File
@@ -376,11 +376,7 @@ local function SetRegionAlpha(self, alpha)
end
self.alpha = alpha;
if (WeakAuras.IsOptionsOpen()) then
self:SetAlpha(max(self.animAlpha or self.alpha or 1, 0.5));
else
self:SetAlpha(self.animAlpha or self.alpha or 1);
end
self:SetAlpha(self.animAlpha or self.alpha or 1);
self.subRegionEvents:Notify("AlphaChanged")
end
@@ -496,6 +492,10 @@ function WeakAuras.regionPrototype.modify(parent, region, data)
if (defaultsForRegion and defaultsForRegion.alpha) then
region:SetRegionAlpha(data.alpha);
end
if region.SetRegionAlpha then
region:SetRegionAlpha(data.alpha)
end
local hasAdjustedMin = defaultsForRegion and defaultsForRegion.useAdjustededMin ~= nil and data.useAdjustededMin
and data.adjustedMin;
local hasAdjustedMax = defaultsForRegion and defaultsForRegion.useAdjustededMax ~= nil and data.useAdjustededMax
@@ -709,12 +709,13 @@ end
-- Expand/Collapse function
function WeakAuras.regionPrototype.AddExpandFunction(data, region, cloneId, parent, parentRegionType)
local uid = data.uid
local id = data.id
local inDynamicGroup = parentRegionType == "dynamicgroup";
local inGroup = parentRegionType == "group";
local startMainAnimation = function()
Private.Animate("display", data.uid, "main", data.animation.main, region, false, nil, true, cloneId);
Private.Animate("display", uid, "main", data.animation.main, region, false, nil, true, cloneId);
end
function region:OptionsClosed()
@@ -739,7 +740,8 @@ function WeakAuras.regionPrototype.AddExpandFunction(data, region, cloneId, pare
region:PreHide()
end
Private.RunConditions(region, id, true)
Private.RunConditions(region, uid, true)
region.subRegionEvents:Notify("PreHide")
region:Hide();
if (cloneId) then
Private.ReleaseClone(region.id, cloneId, data.regionType);
@@ -753,7 +755,8 @@ function WeakAuras.regionPrototype.AddExpandFunction(data, region, cloneId, pare
if region.PreHide then
region:PreHide()
end
Private.RunConditions(region, id, true)
Private.RunConditions(region, uid, true)
region.subRegionEvents:Notify("PreHide")
region:Hide();
if (cloneId) then
Private.ReleaseClone(region.id, cloneId, data.regionType);
+31 -13
View File
@@ -31,7 +31,7 @@ local default = {
endPercent = 1,
backgroundPercent = 1,
frameRate = 15,
animationType = "progress",
animationType = "loop",
inverse = false,
customForegroundFrames = 0,
customForegroundRows = 16,
@@ -143,6 +143,7 @@ end
local function modify(parent, region, data)
WeakAuras.regionPrototype.modify(parent, region, data);
local pattern = "%.x(%d+)y(%d+)f(%d+)%.[tb][gl][ap]"
local tdata = texture_data[data.foregroundTexture];
if (tdata) then
local lastFrame = tdata.count - 1;
@@ -151,11 +152,20 @@ local function modify(parent, region, data)
region.foreground.rows = tdata.rows;
region.foreground.columns = tdata.columns;
else
local lastFrame = (data.customForegroundFrames or 256) - 1;
region.startFrame = floor( (data.startPercent or 0) * lastFrame) + 1;
region.endFrame = floor( (data.endPercent or 1) * lastFrame) + 1;
region.foreground.rows = data.customForegroundRows;
region.foreground.columns = data.customForegroundColumns;
local rows, columns, frames = data.foregroundTexture:lower():match(pattern)
if rows and columns and frames then
local lastFrame = frames - 1;
region.startFrame = floor( (data.startPercent or 0) * lastFrame) + 1;
region.endFrame = floor( (data.endPercent or 1) * lastFrame) + 1;
region.foreground.rows = rows;
region.foreground.columns = columns;
else
local lastFrame = (data.customForegroundFrames or 256) - 1;
region.startFrame = floor( (data.startPercent or 0) * lastFrame) + 1;
region.endFrame = floor( (data.endPercent or 1) * lastFrame) + 1;
region.foreground.rows = data.customForegroundRows;
region.foreground.columns = data.customForegroundColumns;
end
end
local backgroundTexture = data.sameTexture
@@ -169,13 +179,21 @@ local function modify(parent, region, data)
region.background.rows = tbdata.rows;
region.background.columns = tbdata.columns;
else
local lastFrame = (data.sameTexture and data.customForegroundFrames
or data.customBackgroundFrames or 256) - 1;
region.backgroundFrame = floor( (data.backgroundPercent or 1) * lastFrame + 1);
region.background.rows = data.sameTexture and data.customForegroundRows
or data.customBackgroundRows;
region.background.columns = data.sameTexture and data.customForegroundColumns
or data.customBackgroundColumns;
local rows, columns, frames = backgroundTexture:lower():match(pattern)
if rows and columns and frames then
local lastFrame = frames - 1;
region.backgroundFrame = floor( (data.backgroundPercent or 1) * lastFrame + 1);
region.background.rows = rows;
region.background.columns = columns;
else
local lastFrame = (data.sameTexture and data.customForegroundFrames
or data.customBackgroundFrames or 256) - 1;
region.backgroundFrame = floor( (data.backgroundPercent or 1) * lastFrame + 1);
region.background.rows = data.sameTexture and data.customForegroundRows
or data.customBackgroundRows;
region.background.columns = data.sameTexture and data.customForegroundColumns
or data.customBackgroundColumns;
end
end
if (region.foreground.rows and region.foreground.columns) then
-2
View File
@@ -75,8 +75,6 @@ local function modify(parent, region, data)
WeakAuras.regionPrototype.modify(parent, region, data);
local text = region.text;
region.useAuto = Private.CanHaveAuto(data);
local fontPath = SharedMedia:Fetch("font", data.font);
text:SetFont(fontPath, data.fontSize < 33 and data.fontSize or 33, data.outline);
if not text:GetFont() then -- Font invalid, set the font but keep the setting