init
This commit is contained in:
@@ -0,0 +1,772 @@
|
||||
if not WeakAuras.IsCorrectVersion() then return end
|
||||
|
||||
local SharedMedia = LibStub("LibSharedMedia-3.0");
|
||||
local L = WeakAuras.L;
|
||||
|
||||
-- Create region options table
|
||||
local function createOptions(id, data)
|
||||
-- Region options
|
||||
local screenWidth, screenHeight = math.ceil(GetScreenWidth() / 20) * 20, math.ceil(GetScreenHeight() / 20) * 20;
|
||||
local options = {
|
||||
__title = L["Progress Bar Settings"],
|
||||
__order = 1,
|
||||
texture = {
|
||||
type = "select",
|
||||
dialogControl = "LSM30_Statusbar",
|
||||
order = 1,
|
||||
width = WeakAuras.doubleWidth,
|
||||
name = L["Bar Texture"],
|
||||
values = AceGUIWidgetLSMlists.statusbar
|
||||
},
|
||||
orientation = {
|
||||
type = "select",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Orientation"],
|
||||
order = 25,
|
||||
values = WeakAuras.orientation_types,
|
||||
set = function(info, v)
|
||||
if(
|
||||
(
|
||||
data.orientation:find("INVERSE")
|
||||
and not v:find("INVERSE")
|
||||
)
|
||||
or (
|
||||
v:find("INVERSE")
|
||||
and not data.orientation:find("INVERSE")
|
||||
)
|
||||
) then
|
||||
data.icon_side = data.icon_side == "LEFT" and "RIGHT" or "LEFT";
|
||||
end
|
||||
|
||||
if(
|
||||
(
|
||||
data.orientation:find("HORIZONTAL")
|
||||
and v:find("VERTICAL")
|
||||
)
|
||||
or (
|
||||
data.orientation:find("VERTICAL")
|
||||
and v:find("HORIZONTAL")
|
||||
)
|
||||
) then
|
||||
local temp = data.width;
|
||||
data.width = data.height;
|
||||
data.height = temp;
|
||||
data.icon_side = data.icon_side == "LEFT" and "RIGHT" or "LEFT";
|
||||
|
||||
if(data.rotateText == "LEFT" or data.rotateText == "RIGHT") then
|
||||
data.rotateText = "NONE";
|
||||
elseif(data.rotateText == "NONE") then
|
||||
data.rotateText = "LEFT"
|
||||
end
|
||||
end
|
||||
|
||||
data.orientation = v;
|
||||
WeakAuras.Add(data);
|
||||
WeakAuras.UpdateThumbnail(data);
|
||||
WeakAuras.SetIconNames(data);
|
||||
WeakAuras.ResetMoverSizer();
|
||||
end
|
||||
},
|
||||
inverse = {
|
||||
type = "toggle",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Inverse"],
|
||||
order = 35
|
||||
},
|
||||
smoothProgress = {
|
||||
type = "toggle",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Smooth Progress"],
|
||||
desc = L["Animates progress changes"],
|
||||
order = 37
|
||||
},
|
||||
useTooltip = {
|
||||
type = "toggle",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Tooltip on Mouseover"],
|
||||
hidden = function() return not WeakAuras.CanHaveTooltip(data) end,
|
||||
order = 38
|
||||
},
|
||||
bar_header = {
|
||||
type = "header",
|
||||
name = L["Bar Color Settings"],
|
||||
order = 39
|
||||
},
|
||||
barColor = {
|
||||
type = "color",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Bar Color"],
|
||||
hasAlpha = true,
|
||||
order = 39.1
|
||||
},
|
||||
backgroundColor = {
|
||||
type = "color",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Background Color"],
|
||||
hasAlpha = true,
|
||||
order = 39.2
|
||||
},
|
||||
alpha = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Bar Alpha"],
|
||||
order = 39.3,
|
||||
min = 0,
|
||||
max = 1,
|
||||
bigStep = 0.01,
|
||||
isPercent = true
|
||||
},
|
||||
icon_header = {
|
||||
type = "header",
|
||||
name = L["Icon Settings"],
|
||||
order = 40.1
|
||||
},
|
||||
icon = {
|
||||
type = "toggle",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Show Icon"],
|
||||
order = 40.2,
|
||||
},
|
||||
auto = {
|
||||
type = "toggle",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Auto"],
|
||||
desc = L["Choose whether the displayed icon is automatic or defined manually"],
|
||||
order = 40.3,
|
||||
disabled = function() return not WeakAuras.CanHaveAuto(data); end,
|
||||
get = function() return WeakAuras.CanHaveAuto(data) and data.auto end,
|
||||
hidden = function() return not data.icon end,
|
||||
},
|
||||
displayIcon = {
|
||||
type = "input",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Display Icon"],
|
||||
hidden = function() return WeakAuras.CanHaveAuto(data) and data.auto or not data.icon; end,
|
||||
disabled = function() return not data.icon end,
|
||||
order = 40.4,
|
||||
get = function()
|
||||
return data.displayIcon and tostring(data.displayIcon) or "";
|
||||
end,
|
||||
set = function(info, v)
|
||||
data.displayIcon = v;
|
||||
WeakAuras.Add(data);
|
||||
WeakAuras.UpdateThumbnail(data);
|
||||
WeakAuras.SetIconNames(data);
|
||||
end
|
||||
},
|
||||
chooseIcon = {
|
||||
type = "execute",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Choose"],
|
||||
hidden = function() return WeakAuras.CanHaveAuto(data) and data.auto or not data.icon; end,
|
||||
disabled = function() return not data.icon end,
|
||||
order = 40.5,
|
||||
func = function() WeakAuras.OpenIconPicker(data, "displayIcon"); end
|
||||
},
|
||||
icon_side = {
|
||||
type = "select",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Icon Position"],
|
||||
values = WeakAuras.icon_side_types,
|
||||
hidden = function() return data.orientation:find("VERTICAL") or not data.icon end,
|
||||
order = 40.6,
|
||||
},
|
||||
icon_side2 = {
|
||||
type = "select",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Icon Position"],
|
||||
values = WeakAuras.rotated_icon_side_types,
|
||||
hidden = function() return data.orientation:find("HORIZONTAL") or not data.icon end,
|
||||
order = 40.7,
|
||||
get = function()
|
||||
return data.icon_side;
|
||||
end,
|
||||
set = function(info, v)
|
||||
data.icon_side = v;
|
||||
WeakAuras.Add(data);
|
||||
WeakAuras.UpdateThumbnail(data);
|
||||
WeakAuras.SetIconNames(data);
|
||||
end
|
||||
},
|
||||
desaturate = {
|
||||
type = "toggle",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Desaturate"],
|
||||
order = 40.8,
|
||||
hidden = function() return not data.icon end,
|
||||
},
|
||||
icon_color = {
|
||||
type = "color",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Color"],
|
||||
hasAlpha = true,
|
||||
order = 40.9,
|
||||
hidden = function() return not data.icon end,
|
||||
},
|
||||
zoom = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Zoom"],
|
||||
order = 40.91,
|
||||
min = 0,
|
||||
max = 1,
|
||||
bigStep = 0.01,
|
||||
isPercent = true,
|
||||
hidden = function() return not data.icon end,
|
||||
},
|
||||
spark_header = {
|
||||
type = "header",
|
||||
name = L["Spark Settings"],
|
||||
order = 42
|
||||
},
|
||||
spark = {
|
||||
type = "toggle",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Show Spark"],
|
||||
order = 43
|
||||
},
|
||||
sparkTexture = {
|
||||
type = "input",
|
||||
name = L["Spark Texture"],
|
||||
order = 44,
|
||||
width = WeakAuras.doubleWidth,
|
||||
disabled = function() return not data.spark end,
|
||||
hidden = function() return not data.spark end,
|
||||
},
|
||||
sparkDesaturate = {
|
||||
type = "toggle",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Desaturate"],
|
||||
order = 44.1,
|
||||
disabled = function() return not data.spark end,
|
||||
hidden = function() return not data.spark end,
|
||||
},
|
||||
spaceSpark = {
|
||||
type = "execute",
|
||||
name = "",
|
||||
width = WeakAuras.halfWidth,
|
||||
order = 44.2,
|
||||
image = function() return "", 0, 0 end,
|
||||
disabled = function() return not data.spark end,
|
||||
hidden = function() return not data.spark end,
|
||||
},
|
||||
sparkChooseTexture = {
|
||||
type = "execute",
|
||||
name = L["Choose"],
|
||||
width = WeakAuras.halfWidth,
|
||||
order = 44.3,
|
||||
func = function()
|
||||
WeakAuras.OpenTexturePicker(data, "sparkTexture", WeakAuras.texture_types);
|
||||
end,
|
||||
disabled = function() return not data.spark end,
|
||||
hidden = function() return not data.spark end,
|
||||
},
|
||||
sparkColor = {
|
||||
type = "color",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Color"],
|
||||
hasAlpha = true,
|
||||
order = 44.4,
|
||||
disabled = function() return not data.spark end,
|
||||
hidden = function() return not data.spark end,
|
||||
},
|
||||
sparkBlendMode = {
|
||||
type = "select",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Blend Mode"],
|
||||
order = 44.5,
|
||||
values = WeakAuras.blend_types,
|
||||
disabled = function() return not data.spark end,
|
||||
hidden = function() return not data.spark end,
|
||||
},
|
||||
sparkWidth = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Width"],
|
||||
order = 44.6,
|
||||
min = 1,
|
||||
softMax = screenWidth,
|
||||
bigStep = 1,
|
||||
disabled = function() return not data.spark end,
|
||||
hidden = function() return not data.spark end,
|
||||
},
|
||||
sparkHeight = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Height"],
|
||||
order = 44.7,
|
||||
min = 1,
|
||||
softMax = screenHeight,
|
||||
bigStep = 1,
|
||||
disabled = function() return not data.spark end,
|
||||
hidden = function() return not data.spark end,
|
||||
},
|
||||
sparkOffsetX = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["X Offset"],
|
||||
order = 44.8,
|
||||
min = -screenWidth,
|
||||
max = screenWidth,
|
||||
bigStep = 1,
|
||||
disabled = function() return not data.spark end,
|
||||
hidden = function() return not data.spark end,
|
||||
},
|
||||
sparkOffsetY = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Y Offset"],
|
||||
order = 44.9,
|
||||
min = -screenHeight,
|
||||
max = screenHeight,
|
||||
bigStep = 1,
|
||||
disabled = function() return not data.spark end,
|
||||
hidden = function() return not data.spark end,
|
||||
},
|
||||
sparkRotationMode = {
|
||||
type = "select",
|
||||
width = WeakAuras.normalWidth,
|
||||
values = WeakAuras.spark_rotation_types,
|
||||
name = L["Rotation Mode"],
|
||||
order = 45,
|
||||
disabled = function() return not data.spark end,
|
||||
hidden = function() return not data.spark end,
|
||||
},
|
||||
sparkRotation = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Rotation"],
|
||||
min = 0,
|
||||
max = 360,
|
||||
step = 90,
|
||||
order = 45.1,
|
||||
disabled = function() return not data.spark or data.sparkRotationMode == "AUTO" end,
|
||||
hidden = function() return not data.spark or data.sparkRotationMode == "AUTO" end,
|
||||
},
|
||||
sparkMirror = {
|
||||
type = "toggle",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Mirror"],
|
||||
order = 45.2,
|
||||
disabled = function() return not data.spark end,
|
||||
hidden = function() return not data.spark end,
|
||||
},
|
||||
sparkHidden = {
|
||||
type = "select",
|
||||
width = WeakAuras.normalWidth,
|
||||
values = WeakAuras.spark_hide_types,
|
||||
name = L["Hide on"],
|
||||
order = 45.3,
|
||||
disabled = function() return not data.spark end,
|
||||
hidden = function() return not data.spark end,
|
||||
},
|
||||
endHeader = {
|
||||
type = "header",
|
||||
order = 100,
|
||||
name = "",
|
||||
},
|
||||
};
|
||||
|
||||
options = WeakAuras.regionPrototype.AddAdjustedDurationOptions(options, data, 36.5);
|
||||
|
||||
local overlayInfo = WeakAuras.GetOverlayInfo(data);
|
||||
if (overlayInfo and next(overlayInfo)) then
|
||||
options["overlayheader"] = {
|
||||
type = "header",
|
||||
name = L["Overlays"],
|
||||
order = 58
|
||||
}
|
||||
local index = 0.01
|
||||
for id, display in ipairs(overlayInfo) do
|
||||
options["overlaycolor" .. id] = {
|
||||
type = "color",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = string.format(L["%s Color"], display),
|
||||
hasAlpha = true,
|
||||
order = 58 + index,
|
||||
get = function()
|
||||
if (data.overlays and data.overlays[id]) then
|
||||
return unpack(data.overlays[id]);
|
||||
end
|
||||
return 1, 1, 1, 1;
|
||||
end,
|
||||
set = function(info, r, g, b, a)
|
||||
if (not data.overlays) then
|
||||
data.overlays = {};
|
||||
end
|
||||
data.overlays[id] = { r, g, b, a};
|
||||
WeakAuras.Add(data);
|
||||
end
|
||||
}
|
||||
index = index + 0.01
|
||||
end
|
||||
|
||||
options["overlayclip"] = {
|
||||
type = "toggle",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Clip Overlays"],
|
||||
order = 58 + index;
|
||||
}
|
||||
|
||||
end
|
||||
|
||||
return {
|
||||
aurabar = options,
|
||||
position = WeakAuras.PositionOptions(id, data),
|
||||
};
|
||||
end
|
||||
|
||||
-- Create preview thumbnail
|
||||
local function createThumbnail()
|
||||
-- Preview frame
|
||||
local borderframe = CreateFrame("FRAME", nil, UIParent);
|
||||
borderframe:SetWidth(32);
|
||||
borderframe:SetHeight(32);
|
||||
|
||||
-- Preview border
|
||||
local border = borderframe:CreateTexture(nil, "OVERLAY");
|
||||
border:SetAllPoints(borderframe);
|
||||
border:SetTexture("Interface\\BUTTONS\\UI-Quickslot2.blp");
|
||||
border:SetTexCoord(0.2, 0.8, 0.2, 0.8);
|
||||
|
||||
-- Main region
|
||||
local region = CreateFrame("FRAME", nil, borderframe);
|
||||
borderframe.region = region;
|
||||
region:SetWidth(32);
|
||||
region:SetHeight(32);
|
||||
|
||||
-- Status-bar frame
|
||||
local bar = CreateFrame("FRAME", nil, region);
|
||||
borderframe.bar = bar;
|
||||
|
||||
-- Fake status-bar
|
||||
local texture = bar:CreateTexture(nil, "OVERLAY");
|
||||
borderframe.texture = texture;
|
||||
|
||||
-- Fake icon
|
||||
local icon = region:CreateTexture();
|
||||
borderframe.icon = icon;
|
||||
icon:SetTexture("Interface\\Icons\\INV_Misc_QuestionMark");
|
||||
|
||||
-- Return preview
|
||||
return borderframe;
|
||||
end
|
||||
|
||||
-- Modify preview thumbnail
|
||||
local function modifyThumbnail(parent, borderframe, data, fullModify, width, height)
|
||||
-- Localize
|
||||
local region, bar, texture, icon = borderframe.region, borderframe.bar, borderframe.texture, borderframe.icon;
|
||||
|
||||
borderframe:SetParent(parent)
|
||||
|
||||
-- Defaut size
|
||||
width = width or 26;
|
||||
height = height or 15;
|
||||
|
||||
-- Fake orientation (main region)
|
||||
if(data.orientation:find("HORIZONTAL")) then
|
||||
region:SetWidth(width);
|
||||
region:SetHeight(height);
|
||||
region:ClearAllPoints();
|
||||
if(data.orientation == "HORIZONTAL_INVERSE") then
|
||||
region:SetPoint("RIGHT", borderframe, "RIGHT", -2, 0);
|
||||
else
|
||||
region:SetPoint("LEFT", borderframe, "LEFT", 2, 0);
|
||||
end
|
||||
else
|
||||
region:SetWidth(height);
|
||||
region:SetHeight(width);
|
||||
region:ClearAllPoints();
|
||||
if(data.orientation == "VERTICAL_INVERSE") then
|
||||
region:SetPoint("TOP", borderframe, "TOP", 0, -2);
|
||||
else
|
||||
region:SetPoint("BOTTOM", borderframe, "BOTTOM", 0, 2);
|
||||
end
|
||||
end
|
||||
|
||||
-- Fake status-bar style
|
||||
texture:SetTexture(SharedMedia:Fetch("statusbar", data.texture));
|
||||
texture:SetVertexColor(data.barColor[1], data.barColor[2], data.barColor[3], data.barColor[4]);
|
||||
|
||||
-- Fake icon size
|
||||
local iconsize = height;
|
||||
icon:SetWidth(iconsize);
|
||||
icon:SetHeight(iconsize);
|
||||
|
||||
-- Fake layout variables
|
||||
local percent, length;
|
||||
if(data.icon) then
|
||||
length = width - height;
|
||||
percent = 1 - (width / 100);
|
||||
else
|
||||
length = width;
|
||||
percent = 1 - (width / 100);
|
||||
end
|
||||
|
||||
-- Reset region members
|
||||
icon:ClearAllPoints();
|
||||
bar:ClearAllPoints();
|
||||
texture:ClearAllPoints();
|
||||
|
||||
-- Fake orientation (region members)
|
||||
if(data.orientation == "HORIZONTAL_INVERSE") then
|
||||
icon:SetPoint("LEFT", region, "LEFT");
|
||||
bar:SetPoint("BOTTOMRIGHT", region, "BOTTOMRIGHT");
|
||||
if(data.icon) then
|
||||
bar:SetPoint("TOPLEFT", icon, "TOPRIGHT");
|
||||
else
|
||||
bar:SetPoint("TOPLEFT", region, "TOPLEFT");
|
||||
end
|
||||
texture:SetPoint("BOTTOMRIGHT", bar, "BOTTOMRIGHT");
|
||||
texture:SetPoint("TOPRIGHT", bar, "TOPRIGHT");
|
||||
texture:SetTexCoord(1, 0, 1, 1, percent, 0, percent, 1);
|
||||
texture:SetWidth(length);
|
||||
elseif(data.orientation == "HORIZONTAL") then
|
||||
icon:SetPoint("RIGHT", region, "RIGHT");
|
||||
bar:SetPoint("BOTTOMLEFT", region, "BOTTOMLEFT");
|
||||
if(data.icon) then
|
||||
bar:SetPoint("TOPRIGHT", icon, "TOPLEFT");
|
||||
else
|
||||
bar:SetPoint("TOPRIGHT", region, "TOPRIGHT");
|
||||
end
|
||||
texture:SetPoint("BOTTOMLEFT", bar, "BOTTOMLEFT");
|
||||
texture:SetPoint("TOPLEFT", bar, "TOPLEFT");
|
||||
texture:SetTexCoord(percent, 0, percent, 1, 1, 0, 1, 1);
|
||||
texture:SetWidth(length);
|
||||
elseif(data.orientation == "VERTICAL_INVERSE") then
|
||||
icon:SetPoint("BOTTOM", region, "BOTTOM");
|
||||
bar:SetPoint("TOPLEFT", region, "TOPLEFT");
|
||||
if(data.icon) then
|
||||
bar:SetPoint("BOTTOMRIGHT", icon, "TOPRIGHT");
|
||||
else
|
||||
bar:SetPoint("BOTTOMRIGHT", region, "BOTTOMRIGHT");
|
||||
end
|
||||
texture:SetPoint("TOPLEFT", bar, "TOPLEFT");
|
||||
texture:SetPoint("TOPRIGHT", bar, "TOPRIGHT");
|
||||
texture:SetTexCoord(percent, 0, 1, 0, percent, 1, 1, 1);
|
||||
texture:SetHeight(length);
|
||||
elseif(data.orientation == "VERTICAL") then
|
||||
icon:SetPoint("TOP", region, "TOP");
|
||||
bar:SetPoint("BOTTOMRIGHT", region, "BOTTOMRIGHT");
|
||||
if(data.icon) then
|
||||
bar:SetPoint("TOPLEFT", icon, "BOTTOMLEFT");
|
||||
else
|
||||
bar:SetPoint("TOPLEFT", region, "TOPLEFT");
|
||||
end
|
||||
texture:SetPoint("BOTTOMLEFT", bar, "BOTTOMLEFT");
|
||||
texture:SetPoint("BOTTOMRIGHT", bar, "BOTTOMRIGHT");
|
||||
texture:SetTexCoord(1, 0, percent, 0, 1, 1, percent, 1);
|
||||
texture:SetHeight(length);
|
||||
end
|
||||
|
||||
-- Fake icon (code)
|
||||
if(data.icon) then
|
||||
function borderframe:SetIcon(path)
|
||||
local success = icon:SetTexture(data.auto and path or data.displayIcon) and (data.auto and path or data.displayIcon);
|
||||
if not(success) then
|
||||
icon:SetTexture("Interface\\Icons\\INV_Misc_QuestionMark");
|
||||
end
|
||||
end
|
||||
|
||||
icon:Show();
|
||||
else
|
||||
icon:Hide();
|
||||
end
|
||||
end
|
||||
|
||||
-- Create "new region" preview
|
||||
local function createIcon()
|
||||
-- Default data
|
||||
local data = {
|
||||
icon = true,
|
||||
auto = true,
|
||||
texture = "Runes",
|
||||
orientation = "HORIZONTAL",
|
||||
alpha = 1.0,
|
||||
barColor = {1, 0, 0, 1}
|
||||
};
|
||||
|
||||
-- Create and configure thumbnail
|
||||
local thumbnail = createThumbnail(UIParent);
|
||||
modifyThumbnail(UIParent, thumbnail, data, nil, 32, 18);
|
||||
thumbnail:SetIcon("Interface\\Icons\\INV_Sword_62");
|
||||
|
||||
-- Return thumbnail
|
||||
return thumbnail;
|
||||
end
|
||||
|
||||
local templates = {
|
||||
{
|
||||
title = L["Horizontal Bar"],
|
||||
data = {
|
||||
width = 200,
|
||||
height = 30,
|
||||
barColor = { 0, 1, 0, 1},
|
||||
inverse = true,
|
||||
smoothProgress = true,
|
||||
}
|
||||
},
|
||||
{
|
||||
title = L["Vertical Bar"],
|
||||
data = {
|
||||
width = 30,
|
||||
height = 200,
|
||||
barColor = { 0, 1, 0, 1},
|
||||
rotateText = "LEFT",
|
||||
orientation = "VERTICAL_INVERSE",
|
||||
inverse = true,
|
||||
smoothProgress = true,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
local anchorPoints = {
|
||||
BOTTOMLEFT = {
|
||||
display = { L["Bar"], L["Bottom Left"] },
|
||||
type = "point"
|
||||
},
|
||||
BOTTOM = {
|
||||
display = { L["Bar"], L["Bottom"] },
|
||||
type = "point"
|
||||
},
|
||||
BOTTOMRIGHT = {
|
||||
display = { L["Bar"], L["Bottom Right"] },
|
||||
type = "point"
|
||||
},
|
||||
RIGHT = {
|
||||
display = { L["Bar"], L["Right"] },
|
||||
type = "point"
|
||||
},
|
||||
TOPRIGHT = {
|
||||
display = { L["Bar"], L["Top Right"] },
|
||||
type = "point"
|
||||
},
|
||||
TOP = {
|
||||
display = { L["Bar"], L["Top"] },
|
||||
type = "point"
|
||||
},
|
||||
TOPLEFT = {
|
||||
display = { L["Bar"], L["Top Left"] },
|
||||
type = "point"
|
||||
},
|
||||
LEFT = {
|
||||
display = { L["Bar"], L["Left"] },
|
||||
type = "point"
|
||||
},
|
||||
CENTER = {
|
||||
display = { L["Bar"], L["Center"] },
|
||||
type = "point"
|
||||
},
|
||||
|
||||
INNER_BOTTOMLEFT = {
|
||||
display = { L["Bar Inner"], L["Bottom Left"] },
|
||||
type = "point"
|
||||
},
|
||||
INNER_BOTTOM = {
|
||||
display = { L["Bar Inner"], L["Bottom"] },
|
||||
type = "point"
|
||||
},
|
||||
INNER_BOTTOMRIGHT = {
|
||||
display = { L["Bar Inner"], L["Bottom Right"] },
|
||||
type = "point"
|
||||
},
|
||||
INNER_RIGHT = {
|
||||
display = { L["Bar Inner"], L["Right"] },
|
||||
type = "point"
|
||||
},
|
||||
INNER_TOPRIGHT = {
|
||||
display = { L["Bar Inner"], L["Top Right"] },
|
||||
type = "point"
|
||||
},
|
||||
INNER_TOP = {
|
||||
display = { L["Bar Inner"], L["Top"] },
|
||||
type = "point"
|
||||
},
|
||||
INNER_TOPLEFT = {
|
||||
display = { L["Bar Inner"], L["Top Left"] },
|
||||
type = "point"
|
||||
},
|
||||
INNER_LEFT = {
|
||||
display = { L["Bar Inner"], L["Left"] },
|
||||
type = "point"
|
||||
},
|
||||
INNER_CENTER = {
|
||||
display = { L["Bar Inner"], L["Center"] },
|
||||
type = "point"
|
||||
},
|
||||
|
||||
ICON_BOTTOMLEFT = {
|
||||
display = { L["Icon"], L["Bottom Left"] },
|
||||
type = "point"
|
||||
},
|
||||
ICON_BOTTOM = {
|
||||
display = { L["Icon"], L["Bottom"] },
|
||||
type = "point"
|
||||
},
|
||||
ICON_BOTTOMRIGHT = {
|
||||
display = { L["Icon"], L["Bottom Right"] },
|
||||
type = "point"
|
||||
},
|
||||
ICON_RIGHT = {
|
||||
display = { L["Icon"], L["Right"] },
|
||||
type = "point"
|
||||
},
|
||||
ICON_TOPRIGHT = {
|
||||
display = { L["Icon"], L["Top Right"] },
|
||||
type = "point"
|
||||
},
|
||||
ICON_TOP = {
|
||||
display = { L["Icon"], L["Top"] },
|
||||
type = "point"
|
||||
},
|
||||
ICON_TOPLEFT = {
|
||||
display = { L["Icon"], L["Top Left"] },
|
||||
type = "point"
|
||||
},
|
||||
ICON_LEFT = {
|
||||
display = { L["Icon"], L["Left"] },
|
||||
type = "point"
|
||||
},
|
||||
ICON_CENTER = {
|
||||
display = { L["Icon"], L["Center"] },
|
||||
type = "point"
|
||||
},
|
||||
|
||||
SPARK = {
|
||||
display = L["Spark"],
|
||||
type = "point"
|
||||
},
|
||||
ALL = {
|
||||
display = L["Whole Area"],
|
||||
type = "area"
|
||||
},
|
||||
}
|
||||
|
||||
local function GetAnchors(data)
|
||||
return anchorPoints;
|
||||
end
|
||||
|
||||
local function subCreateOptions(parentData, data, index, subIndex)
|
||||
local order = 9
|
||||
local options = {
|
||||
__title = L["Foreground"],
|
||||
__order = 1,
|
||||
__up = function()
|
||||
if (WeakAuras.ApplyToDataOrChildData(parentData, WeakAuras.MoveSubRegionUp, index, "aurabar_bar")) then
|
||||
WeakAuras.ReloadOptions2(parentData.id, parentData)
|
||||
end
|
||||
end,
|
||||
__down = function()
|
||||
if (WeakAuras.ApplyToDataOrChildData(parentData, WeakAuras.MoveSubRegionDown, index, "aurabar_bar")) then
|
||||
WeakAuras.ReloadOptions2(parentData.id, parentData)
|
||||
end
|
||||
end,
|
||||
__nooptions = true
|
||||
}
|
||||
return options
|
||||
end
|
||||
|
||||
-- Register new region type options with WeakAuras
|
||||
WeakAuras.RegisterRegionOptions("aurabar", createOptions, createIcon, L["Progress Bar"], createThumbnail, modifyThumbnail, L["Shows a progress bar with name, timer, and icon"], templates, GetAnchors);
|
||||
|
||||
WeakAuras.RegisterSubRegionOptions("aurabar_bar", subCreateOptions, L["Foreground"]);
|
||||
@@ -0,0 +1,535 @@
|
||||
if not WeakAuras.IsCorrectVersion() then return end
|
||||
|
||||
local L = WeakAuras.L
|
||||
|
||||
local selfPoints = {
|
||||
default = "CENTER",
|
||||
RIGHT = function(data)
|
||||
if data.align == "LEFT" then
|
||||
return "TOPLEFT"
|
||||
elseif data.align == "RIGHT" then
|
||||
return "BOTTOMLEFT"
|
||||
else
|
||||
return "LEFT"
|
||||
end
|
||||
end,
|
||||
LEFT = function(data)
|
||||
if data.align == "LEFT" then
|
||||
return "TOPRIGHT"
|
||||
elseif data.align == "RIGHT" then
|
||||
return "BOTTOMRIGHT"
|
||||
else
|
||||
return "RIGHT"
|
||||
end
|
||||
end,
|
||||
UP = function(data)
|
||||
if data.align == "LEFT" then
|
||||
return "BOTTOMLEFT"
|
||||
elseif data.align == "RIGHT" then
|
||||
return "BOTTOMRIGHT"
|
||||
else
|
||||
return "BOTTOM"
|
||||
end
|
||||
end,
|
||||
DOWN = function(data)
|
||||
if data.align == "LEFT" then
|
||||
return "TOPLEFT"
|
||||
elseif data.align == "RIGHT" then
|
||||
return "TOPRIGHT"
|
||||
else
|
||||
return "TOP"
|
||||
end
|
||||
end,
|
||||
HORIZONTAL = function(data)
|
||||
if data.align == "LEFT" then
|
||||
return "TOP"
|
||||
elseif data.align == "RIGHT" then
|
||||
return "BOTTOM"
|
||||
else
|
||||
return "CENTER"
|
||||
end
|
||||
end,
|
||||
VERTICAL = function(data)
|
||||
if data.align == "LEFT" then
|
||||
return "LEFT"
|
||||
elseif data.align == "RIGHT" then
|
||||
return "RIGHT"
|
||||
else
|
||||
return "CENTER"
|
||||
end
|
||||
end,
|
||||
CIRCLE = "CENTER",
|
||||
COUNTERCIRCLE = "CENTER",
|
||||
}
|
||||
|
||||
local gridSelfPoints = {
|
||||
RU = "BOTTOMLEFT",
|
||||
UR = "BOTTOMLEFT",
|
||||
LU = "BOTTOMRIGHT",
|
||||
UL = "BOTTOMRIGHT",
|
||||
RD = "TOPLEFT",
|
||||
DR = "TOPLEFT",
|
||||
LD = "TOPRIGHT",
|
||||
DL = "TOPRIGHT",
|
||||
}
|
||||
|
||||
local function createOptions(id, data)
|
||||
local options = {
|
||||
__title = L["Dynamic Group Settings"],
|
||||
__order = 1,
|
||||
groupIcon = {
|
||||
type = "input",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = WeakAuras.newFeatureString..L["Group Icon"],
|
||||
desc = L["Set Thumbnail Icon"],
|
||||
order = 0.5,
|
||||
get = function()
|
||||
return data.groupIcon and tostring(data.groupIcon) or ""
|
||||
end,
|
||||
set = function(info, v)
|
||||
data.groupIcon = v
|
||||
WeakAuras.Add(data)
|
||||
WeakAuras.UpdateThumbnail(data)
|
||||
WeakAuras.SetIconNames(data)
|
||||
end
|
||||
},
|
||||
chooseIcon = {
|
||||
type = "execute",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Choose"],
|
||||
order = 0.51,
|
||||
func = function() WeakAuras.OpenIconPicker(data, "groupIcon", true) end
|
||||
},
|
||||
-- grow options
|
||||
grow = {
|
||||
type = "select",
|
||||
width = WeakAuras.doubleWidth,
|
||||
name = L["Grow"],
|
||||
order = 1,
|
||||
values = WeakAuras.grow_types,
|
||||
set = function(info, v)
|
||||
data.grow = v
|
||||
local selfPoint = selfPoints[data.grow] or selfPoints.default
|
||||
if type(selfPoint) == "function" then
|
||||
selfPoint = selfPoint(data)
|
||||
end
|
||||
data.selfPoint = selfPoint
|
||||
WeakAuras.Add(data)
|
||||
WeakAuras.ReloadTriggerOptions(data)
|
||||
WeakAuras.ResetMoverSizer()
|
||||
end,
|
||||
},
|
||||
useAnchorPerUnit = {
|
||||
type = "toggle",
|
||||
order = 1.5,
|
||||
width = WeakAuras.normalWidth,
|
||||
name = WeakAuras.newFeatureString..L["Group by Frame"],
|
||||
desc = L[
|
||||
[[Group and anchor each auras by frame.
|
||||
|
||||
- Unit Frames: attach to unit frame buttons per unit.
|
||||
- Custom Frames: choose which frame each region should be anchored to.]]
|
||||
],
|
||||
hidden = function() return data.grow == "CUSTOM" end,
|
||||
},
|
||||
anchorPerUnit = {
|
||||
type = "select",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = WeakAuras.newFeatureString..L["Group by Frame"],
|
||||
order = 1.6,
|
||||
values = {
|
||||
["UNITFRAME"] = L["Unit Frames"],
|
||||
["CUSTOM"] = L["Custom Frames"],
|
||||
},
|
||||
hidden = function() return data.grow == "CUSTOM" end,
|
||||
disabled = function() return not data.useAnchorPerUnit end
|
||||
},
|
||||
-- custom grow option added below
|
||||
align = {
|
||||
type = "select",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Align"],
|
||||
order = 2,
|
||||
values = WeakAuras.align_types,
|
||||
set = function(info, v)
|
||||
data.align = v
|
||||
local selfPoint = selfPoints[data.grow] or selfPoints.default
|
||||
if type(selfPoint) == "function" then
|
||||
selfPoint = selfPoint(data)
|
||||
end
|
||||
data.selfPoint = selfPoint
|
||||
WeakAuras.Add(data)
|
||||
WeakAuras.ReloadTriggerOptions(data)
|
||||
WeakAuras.ResetMoverSizer()
|
||||
end,
|
||||
hidden = function() return (data.grow == "CUSTOM" or data.grow == "LEFT" or data.grow == "RIGHT" or data.grow == "HORIZONTAL" or data.grow == "CIRCLE" or data.grow == "COUNTERCIRCLE" or data.grow == "GRID") end,
|
||||
disabled = function() return data.grow == "CIRCLE" or data.grow == "COUNTERCIRCLE" end
|
||||
},
|
||||
rotated_align = {
|
||||
type = "select",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Align"],
|
||||
order = 3,
|
||||
values = WeakAuras.rotated_align_types,
|
||||
hidden = function() return (data.grow == "CUSTOM" or data.grow == "UP" or data.grow == "DOWN" or data.grow == "VERTICAL" or data.grow == "CIRCLE" or data.grow == "COUNTERCIRCLE" or data.grow == "GRID") end,
|
||||
get = function() return data.align; end,
|
||||
set = function(info, v)
|
||||
data.align = v
|
||||
local selfPoint = selfPoints[data.grow] or selfPoints.default
|
||||
if type(selfPoint) == "function" then
|
||||
selfPoint = selfPoint(data)
|
||||
end
|
||||
data.selfPoint = selfPoint
|
||||
WeakAuras.Add(data)
|
||||
WeakAuras.ReloadTriggerOptions(data)
|
||||
WeakAuras.ResetMoverSizer()
|
||||
end,
|
||||
},
|
||||
-- circle grow options
|
||||
constantFactor = {
|
||||
type = "select",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Constant Factor"],
|
||||
order = 4,
|
||||
values = WeakAuras.circular_group_constant_factor_types,
|
||||
hidden = function() return data.grow ~= "CIRCLE" and data.grow ~= "COUNTERCIRCLE" end
|
||||
},
|
||||
rotation = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Start Angle"],
|
||||
order = 5,
|
||||
min = 0,
|
||||
max = 360,
|
||||
bigStep = 3,
|
||||
hidden = function() return data.grow ~= "CIRCLE" and data.grow ~= "COUNTERCIRCLE" end
|
||||
},
|
||||
arcLength = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Arc Length"],
|
||||
order = 7,
|
||||
min = 0,
|
||||
max = 360,
|
||||
bigStep = 3,
|
||||
hidden = function() return data.grow ~= "CIRCLE" and data.grow ~= "COUNTERCIRCLE" end
|
||||
},
|
||||
radius = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Radius"],
|
||||
order = 6,
|
||||
softMin = 0,
|
||||
softMax = 500,
|
||||
bigStep = 1,
|
||||
hidden = function() return data.grow == "CUSTOM" or not((data.grow == "CIRCLE" or data.grow == "COUNTERCIRCLE") and data.constantFactor == "RADIUS") end
|
||||
},
|
||||
-- grid grow options
|
||||
gridType = {
|
||||
type = "select",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Grid direction"],
|
||||
order = 8,
|
||||
values = WeakAuras.grid_types,
|
||||
hidden = function() return data.grow ~= "GRID" end,
|
||||
set = function(info, value)
|
||||
data.selfPoint = gridSelfPoints[value]
|
||||
data.gridType = value
|
||||
WeakAuras.Add(data)
|
||||
WeakAuras.ResetMoverSizer()
|
||||
end,
|
||||
},
|
||||
gridWidth = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = function()
|
||||
if not data.gridType then return "" end
|
||||
if data.gridType:find("^[RL]") then
|
||||
return L["Row Width"]
|
||||
else
|
||||
return L["Column Height"]
|
||||
end
|
||||
end,
|
||||
order = 9,
|
||||
min = 1,
|
||||
softMax = 20,
|
||||
step = 1,
|
||||
hidden = function() return data.grow ~= "GRID" end,
|
||||
},
|
||||
rowSpace = {
|
||||
type = "range",
|
||||
name = L["Row Space"],
|
||||
width = WeakAuras.normalWidth,
|
||||
order = 10,
|
||||
softMin = 0,
|
||||
softMax = 300,
|
||||
step = 1,
|
||||
hidden = function() return data.grow ~= "GRID" end,
|
||||
},
|
||||
columnSpace = {
|
||||
type = "range",
|
||||
name = L["Column Space"],
|
||||
width = WeakAuras.normalWidth,
|
||||
order = 11,
|
||||
softMin = 0,
|
||||
softMax = 300,
|
||||
step = 1,
|
||||
hidden = function() return data.grow ~= "GRID" end,
|
||||
},
|
||||
-- generic grow options
|
||||
space = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Space"],
|
||||
order = 7,
|
||||
softMin = 0,
|
||||
softMax = 300,
|
||||
bigStep = 1,
|
||||
hidden = function()
|
||||
return data.grow == "CUSTOM"
|
||||
or data.grow == "GRID"
|
||||
or ((data.grow == "CIRCLE" or data.grow == "COUNTERCIRCLE") and data.constantFactor == "RADIUS")
|
||||
end
|
||||
},
|
||||
stagger = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Stagger"],
|
||||
order = 8,
|
||||
min = -50,
|
||||
max = 50,
|
||||
step = 0.1,
|
||||
bigStep = 1,
|
||||
hidden = function()
|
||||
return data.grow == "CUSTOM"
|
||||
or data.grow == "CIRCLE"
|
||||
or data.grow == "COUNTERCIRCLE"
|
||||
or data.grow == "GRID"
|
||||
end
|
||||
},
|
||||
-- sort options
|
||||
sort = {
|
||||
type = "select",
|
||||
width = WeakAuras.doubleWidth,
|
||||
name = L["Sort"],
|
||||
order = 20,
|
||||
values = WeakAuras.group_sort_types
|
||||
},
|
||||
-- custom sort option added below
|
||||
hybridPosition = {
|
||||
type = "select",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Hybrid Position"],
|
||||
order = 21,
|
||||
values = WeakAuras.group_hybrid_position_types,
|
||||
hidden = function() return not(data.sort == "hybrid") end,
|
||||
},
|
||||
hybridSortMode = {
|
||||
type = "select",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Hybrid Sort Mode"],
|
||||
order = 22,
|
||||
values = WeakAuras.group_hybrid_sort_types,
|
||||
hidden = function() return not(data.sort == "hybrid") end,
|
||||
},
|
||||
sortHybrid = {
|
||||
type = "multiselect",
|
||||
width = "full",
|
||||
name = L["Select the auras you always want to be listed first"],
|
||||
order = 23,
|
||||
hidden = function() return not(data.sort == "hybrid") end,
|
||||
values = function()
|
||||
return data.controlledChildren
|
||||
end,
|
||||
get = function(info, index)
|
||||
local id = data.controlledChildren[index]
|
||||
return data.sortHybridTable and data.sortHybridTable[id] or false;
|
||||
end,
|
||||
set = function(info, index)
|
||||
if not data.sortHybridTable then data.sortHybridTable = {}; end
|
||||
local id = data.controlledChildren[index]
|
||||
local cur = data.sortHybridTable and data.sortHybridTable[id] or false;
|
||||
data.sortHybridTable[id] = not(cur);
|
||||
end,
|
||||
},
|
||||
sortSpace = {
|
||||
type = "description",
|
||||
name = "",
|
||||
width = WeakAuras.doubleWidth,
|
||||
order = 24,
|
||||
hidden = function() return data.sort == "hybrid" end
|
||||
},
|
||||
useLimit = {
|
||||
type = "toggle",
|
||||
order = 25,
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Limit"],
|
||||
hidden = function() return data.grow == "CUSTOM" end,
|
||||
},
|
||||
limit = {
|
||||
type = "range",
|
||||
order = 26,
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Limit"],
|
||||
min = 0,
|
||||
softMax = 20,
|
||||
step = 1,
|
||||
disabled = function() return not data.useLimit end,
|
||||
hidden = function() return data.grow == "CUSTOM" end,
|
||||
},
|
||||
animate = {
|
||||
type = "toggle",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Animated Expand and Collapse"],
|
||||
order = 27
|
||||
},
|
||||
scale = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Group Scale"],
|
||||
order = 28,
|
||||
min = 0.05,
|
||||
softMax = 2,
|
||||
bigStep = 0.05,
|
||||
get = function()
|
||||
return data.scale or 1
|
||||
end,
|
||||
set = function(info, v)
|
||||
data.scale = data.scale or 1
|
||||
local change = 1 - (v/data.scale)
|
||||
data.xOffset = data.xOffset/(1-change)
|
||||
data.yOffset = data.yOffset/(1-change)
|
||||
data.scale = v
|
||||
WeakAuras.Add(data);
|
||||
WeakAuras.ResetMoverSizer();
|
||||
end
|
||||
},
|
||||
endHeader = {
|
||||
type = "header",
|
||||
order = 100,
|
||||
name = "",
|
||||
},
|
||||
};
|
||||
|
||||
WeakAuras.AddCodeOption(options, data, L["Custom Grow"], "custom_grow", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Dynamic-Group",
|
||||
2, function() return data.grow ~= "CUSTOM" end, {"customGrow"}, nil, nil, nil, nil, nil, true)
|
||||
WeakAuras.AddCodeOption(options, data, L["Custom Sort"], "custom_sort", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Dynamic-Group",
|
||||
21, function() return data.sort ~= "custom" end, {"customSort"}, nil, nil, nil, nil, nil, true)
|
||||
WeakAuras.AddCodeOption(options, data, L["Custom Anchor"], "custom_anchor_per_unit", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Dynamic-Group",
|
||||
1.7, function() return not(data.grow ~= "CUSTOM" and data.useAnchorPerUnit and data.anchorPerUnit == "CUSTOM") end, {"customAnchorPerUnit"}, nil, nil, nil, nil, nil, true)
|
||||
|
||||
local borderHideFunc = function() return data.useAnchorPerUnit or data.grow == "CUSTOM" end
|
||||
local disableSelfPoint = function() return data.grow ~= "CUSTOM" and data.grow ~= "GRID" and not data.useAnchorPerUnit end
|
||||
|
||||
for k, v in pairs(WeakAuras.BorderOptions(id, data, nil, borderHideFunc, 70)) do
|
||||
options[k] = v
|
||||
end
|
||||
|
||||
return {
|
||||
dynamicgroup = options,
|
||||
position = WeakAuras.PositionOptions(id, data, nil, true, disableSelfPoint),
|
||||
};
|
||||
end
|
||||
|
||||
local function createThumbnail()
|
||||
-- frame
|
||||
local thumbnail = CreateFrame("FRAME", nil, UIParent);
|
||||
thumbnail:SetWidth(32);
|
||||
thumbnail:SetHeight(32);
|
||||
|
||||
-- border
|
||||
local border = thumbnail:CreateTexture(nil, "OVERLAY");
|
||||
border:SetAllPoints(thumbnail);
|
||||
border:SetTexture("Interface\\BUTTONS\\UI-Quickslot2.blp");
|
||||
border:SetTexCoord(0.2, 0.8, 0.2, 0.8);
|
||||
|
||||
return thumbnail
|
||||
end
|
||||
|
||||
local function defaultIconAnimation(self, elapsed)
|
||||
self.elapsed = self.elapsed + elapsed
|
||||
if(self.elapsed < 0.5) then
|
||||
self.t2:SetPoint("TOP", self.t1, "BOTTOM", 0, -2 + (28 * self.elapsed))
|
||||
self.t2:SetAlpha(1 - (2 * self.elapsed))
|
||||
elseif(self.elapsed < 1.5) then
|
||||
-- do nothing
|
||||
elseif(self.elapsed < 2) then
|
||||
self.t2:SetPoint("TOP", self.t1, "BOTTOM", 0, -2 + (28 * (2 - self.elapsed)))
|
||||
self.t2:SetAlpha((2 * self.elapsed) - 3)
|
||||
elseif(self.elapsed < 3) then
|
||||
-- do nothing
|
||||
else
|
||||
self.elapsed = self.elapsed - 3
|
||||
end
|
||||
end
|
||||
|
||||
local function createAnimatedDefaultIcon(parent)
|
||||
local defaultIcon = CreateFrame("FRAME", nil, parent);
|
||||
parent.defaultIcon = defaultIcon;
|
||||
|
||||
local t1 = defaultIcon:CreateTexture(nil, "ARTWORK");
|
||||
t1:SetWidth(24);
|
||||
t1:SetHeight(6);
|
||||
t1:SetTexture(0.8, 0, 0);
|
||||
t1:SetPoint("TOP", parent, "TOP", 0, -6);
|
||||
local t2 = defaultIcon:CreateTexture(nil, "ARTWORK");
|
||||
t2:SetWidth(12);
|
||||
t2:SetHeight(12);
|
||||
t2:SetTexture(0.2, 0.8, 0.2);
|
||||
t2:SetPoint("TOP", t1, "BOTTOM", 0, -2);
|
||||
local t3 = defaultIcon:CreateTexture(nil, "ARTWORK");
|
||||
t3:SetWidth(30);
|
||||
t3:SetHeight(4);
|
||||
t3:SetTexture(0.1, 0.25, 1);
|
||||
t3:SetPoint("TOP", t2, "BOTTOM", 0, -2);
|
||||
local t4 = defaultIcon:CreateTexture(nil, "OVERLAY");
|
||||
t4:SetWidth(1);
|
||||
t4:SetHeight(36);
|
||||
t4:SetTexture(1, 1, 1);
|
||||
t4:SetPoint("CENTER", parent, "CENTER");
|
||||
|
||||
defaultIcon.t1 = t1
|
||||
defaultIcon.t2 = t2
|
||||
|
||||
defaultIcon.elapsed = 0;
|
||||
defaultIcon:SetScript("OnUpdate", defaultIconAnimation)
|
||||
defaultIcon:SetScript("OnHide", function(self) self:SetScript("OnUpdate", nil) end)
|
||||
defaultIcon:SetScript("OnShow", function(self) self:SetScript("OnUpdate", defaultIconAnimation) end)
|
||||
|
||||
return defaultIcon
|
||||
end
|
||||
|
||||
-- Modify preview thumbnail
|
||||
local function modifyThumbnail(parent, frame, data)
|
||||
function frame:SetIcon(path)
|
||||
if not frame.icon then
|
||||
local icon = frame:CreateTexture(nil, "OVERLAY")
|
||||
icon:SetAllPoints(frame)
|
||||
frame.icon = icon
|
||||
end
|
||||
local success = frame.icon:SetTexture(path or data.groupIcon) and (path or data.groupIcon)
|
||||
if success then
|
||||
if frame.defaultIcon then
|
||||
frame.defaultIcon:Hide()
|
||||
end
|
||||
frame.icon:Show()
|
||||
else
|
||||
if frame.icon then
|
||||
frame.icon:Hide()
|
||||
end
|
||||
if not frame.defaultIcon then
|
||||
frame.defaultIcon = createAnimatedDefaultIcon(frame)
|
||||
end
|
||||
frame.defaultIcon:Show()
|
||||
end
|
||||
end
|
||||
frame:SetIcon()
|
||||
end
|
||||
|
||||
local function createIcon()
|
||||
local thumbnail = createThumbnail(UIParent)
|
||||
thumbnail.defaultIcon = createAnimatedDefaultIcon(thumbnail)
|
||||
return thumbnail
|
||||
end
|
||||
|
||||
WeakAuras.RegisterRegionOptions("dynamicgroup", createOptions, createIcon, L["Dynamic Group"], createThumbnail, modifyThumbnail, L["A group that dynamically controls the positioning of its children"]);
|
||||
@@ -0,0 +1,647 @@
|
||||
if not WeakAuras.IsCorrectVersion() then return end
|
||||
|
||||
local L = WeakAuras.L;
|
||||
|
||||
-- Calculate bounding box
|
||||
local function getRect(data)
|
||||
-- Temp variables
|
||||
local blx, bly, trx, try;
|
||||
blx, bly = data.xOffset or 0, data.yOffset or 0;
|
||||
|
||||
if (data.width == nil or data.height == nil) then
|
||||
return blx, bly, blx, bly;
|
||||
end
|
||||
|
||||
-- Calc bounding box
|
||||
if(data.selfPoint:find("LEFT")) then
|
||||
trx = blx + data.width;
|
||||
elseif(data.selfPoint:find("RIGHT")) then
|
||||
trx = blx;
|
||||
blx = blx - data.width;
|
||||
else
|
||||
blx = blx - (data.width/2);
|
||||
trx = blx + data.width;
|
||||
end
|
||||
if(data.selfPoint:find("BOTTOM")) then
|
||||
try = bly + data.height;
|
||||
elseif(data.selfPoint:find("TOP")) then
|
||||
try = bly;
|
||||
bly = bly - data.height;
|
||||
else
|
||||
bly = bly - (data.height/2);
|
||||
try = bly + data.height;
|
||||
end
|
||||
|
||||
-- Return data
|
||||
return blx, bly, trx, try;
|
||||
end
|
||||
|
||||
-- Create region options table
|
||||
local function createOptions(id, data)
|
||||
-- Region options
|
||||
local options = {
|
||||
__title = L["Group Settings"],
|
||||
__order = 1,
|
||||
groupIcon = {
|
||||
type = "input",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = WeakAuras.newFeatureString..L["Group Icon"],
|
||||
desc = L["Set Thumbnail Icon"],
|
||||
order = 0.50,
|
||||
get = function()
|
||||
return data.groupIcon and tostring(data.groupIcon) or ""
|
||||
end,
|
||||
set = function(info, v)
|
||||
data.groupIcon = v
|
||||
WeakAuras.Add(data)
|
||||
WeakAuras.UpdateThumbnail(data)
|
||||
WeakAuras.SetIconNames(data)
|
||||
end
|
||||
},
|
||||
chooseIcon = {
|
||||
type = "execute",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Choose"],
|
||||
order = 0.51,
|
||||
func = function() WeakAuras.OpenIconPicker(data, "groupIcon", true) end
|
||||
},
|
||||
align_h = {
|
||||
type = "select",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Horizontal Align"],
|
||||
order = 10,
|
||||
values = WeakAuras.align_types,
|
||||
get = function()
|
||||
if(#data.controlledChildren < 1) then
|
||||
return nil;
|
||||
end
|
||||
local alignedCenter, alignedRight, alignedLeft = "CENTER", "RIGHT", "LEFT";
|
||||
for index, childId in pairs(data.controlledChildren) do
|
||||
local childData = WeakAuras.GetData(childId);
|
||||
if(childData) then
|
||||
local left, _, right = getRect(childData);
|
||||
local center = (left + right) / 2;
|
||||
if(math.abs(right) >= 0.01) then
|
||||
alignedRight = nil;
|
||||
end
|
||||
if(math.abs(left) >= 0.01) then
|
||||
alignedLeft = nil;
|
||||
end
|
||||
if(math.abs(center) >= 0.01) then
|
||||
alignedCenter = nil;
|
||||
end
|
||||
end
|
||||
end
|
||||
return (alignedCenter or alignedRight or alignedLeft);
|
||||
end,
|
||||
set = function(info, v)
|
||||
for index, childId in pairs(data.controlledChildren) do
|
||||
local childData = WeakAuras.GetData(childId);
|
||||
local childRegion = WeakAuras.GetRegion(childId)
|
||||
if(childData and childRegion) then
|
||||
if(v == "CENTER") then
|
||||
if(childData.selfPoint:find("LEFT")) then
|
||||
childData.xOffset = 0 - ((childData.width or childRegion.width) / 2);
|
||||
elseif(childData.selfPoint:find("RIGHT")) then
|
||||
childData.xOffset = 0 + ((childData.width or childRegion.width) / 2);
|
||||
else
|
||||
childData.xOffset = 0;
|
||||
end
|
||||
elseif(v == "LEFT") then
|
||||
if(childData.selfPoint:find("LEFT")) then
|
||||
childData.xOffset = 0;
|
||||
elseif(childData.selfPoint:find("RIGHT")) then
|
||||
childData.xOffset = 0 + (childData.width or childRegion.width);
|
||||
else
|
||||
childData.xOffset = 0 + ((childData.width or childRegion.width) / 2);
|
||||
end
|
||||
elseif(v == "RIGHT") then
|
||||
if(childData.selfPoint:find("LEFT")) then
|
||||
childData.xOffset = 0 - (childData.width or childRegion.width);
|
||||
elseif(childData.selfPoint:find("RIGHT")) then
|
||||
childData.xOffset = 0;
|
||||
else
|
||||
childData.xOffset = 0 - ((childData.width or childRegion.width) / 2);
|
||||
end
|
||||
end
|
||||
WeakAuras.Add(childData);
|
||||
end
|
||||
end
|
||||
WeakAuras.Add(data);
|
||||
WeakAuras.ResetMoverSizer();
|
||||
end
|
||||
},
|
||||
align_v = {
|
||||
type = "select",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Vertical Align"],
|
||||
order = 15,
|
||||
values = WeakAuras.rotated_align_types,
|
||||
get = function()
|
||||
if(#data.controlledChildren < 1) then
|
||||
return nil;
|
||||
end
|
||||
local alignedCenter, alignedBottom, alignedTop = "CENTER", "RIGHT", "LEFT";
|
||||
for index, childId in pairs(data.controlledChildren) do
|
||||
local childData = WeakAuras.GetData(childId);
|
||||
if(childData) then
|
||||
local _, bottom, _, top = getRect(childData);
|
||||
local center = (bottom + top) / 2;
|
||||
if(math.abs(bottom) >= 0.01) then
|
||||
alignedBottom = nil;
|
||||
end
|
||||
if(math.abs(top) >= 0.01) then
|
||||
alignedTop = nil;
|
||||
end
|
||||
if(math.abs(center) >= 0.01) then
|
||||
alignedCenter = nil;
|
||||
end
|
||||
end
|
||||
end
|
||||
return alignedCenter or alignedBottom or alignedTop;
|
||||
end,
|
||||
set = function(info, v)
|
||||
for index, childId in pairs(data.controlledChildren) do
|
||||
local childData = WeakAuras.GetData(childId);
|
||||
local childRegion = WeakAuras.GetRegion(childId)
|
||||
if(childData and childRegion) then
|
||||
if(v == "CENTER") then
|
||||
if(childData.selfPoint:find("BOTTOM")) then
|
||||
childData.yOffset = 0 - ((childData.height or childRegion.height) / 2);
|
||||
elseif(childData.selfPoint:find("TOP")) then
|
||||
childData.yOffset = 0 + ((childData.height or childRegion.height) / 2);
|
||||
else
|
||||
childData.yOffset = 0;
|
||||
end
|
||||
elseif(v == "RIGHT") then
|
||||
if(childData.selfPoint:find("BOTTOM")) then
|
||||
childData.yOffset = 0;
|
||||
elseif(childData.selfPoint:find("TOP")) then
|
||||
childData.yOffset = 0 + (childData.height or childRegion.height);
|
||||
else
|
||||
childData.yOffset = 0 + ((childData.height or childRegion.height) / 2);
|
||||
end
|
||||
elseif(v == "LEFT") then
|
||||
if(childData.selfPoint:find("BOTTOM")) then
|
||||
childData.yOffset = 0 - ( childData.height or childRegion.height);
|
||||
elseif(childData.selfPoint:find("TOP")) then
|
||||
childData.yOffset = 0;
|
||||
else
|
||||
childData.yOffset = 0 - ((childData.height or childRegion.height) / 2);
|
||||
end
|
||||
end
|
||||
WeakAuras.Add(childData);
|
||||
end
|
||||
end
|
||||
WeakAuras.Add(data);
|
||||
WeakAuras.ResetMoverSizer();
|
||||
end
|
||||
},
|
||||
distribute_h = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Distribute Horizontally"],
|
||||
order = 20,
|
||||
softMin = -100,
|
||||
softMax = 100,
|
||||
bigStep = 1,
|
||||
get = function()
|
||||
if(#data.controlledChildren < 2) then
|
||||
return nil;
|
||||
end
|
||||
local spaced;
|
||||
local previousData;
|
||||
for index, childId in pairs(data.controlledChildren) do
|
||||
local childData = WeakAuras.GetData(childId);
|
||||
if(childData) then
|
||||
local left, _, right = getRect(childData);
|
||||
if not(previousData) then
|
||||
if not(math.abs(left) < 0.01 or math.abs(right) < 0.01) then
|
||||
return nil;
|
||||
end
|
||||
previousData = childData;
|
||||
else
|
||||
local pleft, _, pright = getRect(previousData);
|
||||
if(left - pleft > 0) then
|
||||
if not(spaced) then
|
||||
spaced = left - pleft;
|
||||
else
|
||||
if(math.abs(spaced - (left - pleft)) > 0.01) then
|
||||
return nil;
|
||||
end
|
||||
end
|
||||
elseif(right - pright < 0) then
|
||||
if not(spaced) then
|
||||
spaced = right - pright;
|
||||
else
|
||||
if(math.abs(spaced - (right - pright)) > 0.01) then
|
||||
return nil;
|
||||
end
|
||||
end
|
||||
else
|
||||
return nil;
|
||||
end
|
||||
end
|
||||
previousData = childData;
|
||||
end
|
||||
end
|
||||
return spaced;
|
||||
end,
|
||||
set = function(info, v)
|
||||
local xOffset = 0;
|
||||
for index, childId in pairs(data.controlledChildren) do
|
||||
local childData = WeakAuras.GetData(childId);
|
||||
local childRegion = WeakAuras.GetRegion(childId)
|
||||
if(childData and childRegion) then
|
||||
if(v > 0) then
|
||||
if(childData.selfPoint:find("LEFT")) then
|
||||
childData.xOffset = xOffset;
|
||||
elseif(childData.selfPoint:find("RIGHT")) then
|
||||
childData.xOffset = xOffset + (childData.width or childRegion.width);
|
||||
else
|
||||
childData.xOffset = xOffset + ((childData.width or childRegion.width) / 2);
|
||||
end
|
||||
xOffset = xOffset + v;
|
||||
elseif(v < 0) then
|
||||
if(childData.selfPoint:find("LEFT")) then
|
||||
childData.xOffset = xOffset - (childData.width or childRegion.width);
|
||||
elseif(childData.selfPoint:find("RIGHT")) then
|
||||
childData.xOffset = xOffset;
|
||||
else
|
||||
childData.xOffset = xOffset - ((childData.width or childRegion.width) / 2);
|
||||
end
|
||||
xOffset = xOffset + v;
|
||||
end
|
||||
WeakAuras.Add(childData);
|
||||
end
|
||||
end
|
||||
|
||||
WeakAuras.Add(data);
|
||||
WeakAuras.ResetMoverSizer();
|
||||
end
|
||||
},
|
||||
distribute_v = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Distribute Vertically"],
|
||||
order = 25,
|
||||
softMin = -100,
|
||||
softMax = 100,
|
||||
bigStep = 1,
|
||||
get = function()
|
||||
if(#data.controlledChildren < 2) then
|
||||
return nil;
|
||||
end
|
||||
local spaced;
|
||||
local previousData;
|
||||
for index, childId in pairs(data.controlledChildren) do
|
||||
local childData = WeakAuras.GetData(childId);
|
||||
if(childData) then
|
||||
local _, bottom, _, top = getRect(childData);
|
||||
if not(previousData) then
|
||||
if not(math.abs(bottom) < 0.01 or math.abs(top) < 0.01) then
|
||||
return nil;
|
||||
end
|
||||
previousData = childData;
|
||||
else
|
||||
local _, pbottom, _, ptop = getRect(previousData);
|
||||
if(bottom - pbottom > 0) then
|
||||
if not(spaced) then
|
||||
spaced = bottom - pbottom;
|
||||
else
|
||||
if(math.abs(spaced - (bottom - pbottom)) > 0.01) then
|
||||
return nil;
|
||||
end
|
||||
end
|
||||
elseif(top - ptop < 0) then
|
||||
if not(spaced) then
|
||||
spaced = top - ptop;
|
||||
else
|
||||
if(math.abs(spaced - (top - ptop)) > 0.01) then
|
||||
return nil;
|
||||
end
|
||||
end
|
||||
else
|
||||
return nil;
|
||||
end
|
||||
end
|
||||
previousData = childData;
|
||||
end
|
||||
end
|
||||
return spaced;
|
||||
end,
|
||||
set = function(info, v)
|
||||
local yOffset = 0;
|
||||
for index, childId in pairs(data.controlledChildren) do
|
||||
local childData = WeakAuras.GetData(childId);
|
||||
local childRegion = WeakAuras.GetRegion(childId)
|
||||
if(childData and childRegion) then
|
||||
if(v > 0) then
|
||||
if(childData.selfPoint:find("BOTTOM")) then
|
||||
childData.yOffset = yOffset;
|
||||
elseif(childData.selfPoint:find("TOP")) then
|
||||
childData.yOffset = yOffset + (childData.height or childRegion.height);
|
||||
else
|
||||
childData.yOffset = yOffset + ((childData.height or childRegion.height) / 2);
|
||||
end
|
||||
yOffset = yOffset + v;
|
||||
elseif(v < 0) then
|
||||
if(childData.selfPoint:find("BOTTOM")) then
|
||||
childData.yOffset = yOffset - (childData.height or childRegion.height);
|
||||
elseif(childData.selfPoint:find("TOP")) then
|
||||
childData.yOffset = yOffset;
|
||||
else
|
||||
childData.yOffset = yOffset - ((childData.height or childRegion.height) / 2);
|
||||
end
|
||||
yOffset = yOffset + v;
|
||||
end
|
||||
WeakAuras.Add(childData);
|
||||
end
|
||||
end
|
||||
|
||||
WeakAuras.Add(data);
|
||||
WeakAuras.ResetMoverSizer();
|
||||
end
|
||||
},
|
||||
space_h = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Space Horizontally"],
|
||||
order = 30,
|
||||
softMin = -100,
|
||||
softMax = 100,
|
||||
bigStep = 1,
|
||||
get = function()
|
||||
if(#data.controlledChildren < 2) then
|
||||
return nil;
|
||||
end
|
||||
local spaced;
|
||||
local previousData;
|
||||
for index, childId in pairs(data.controlledChildren) do
|
||||
local childData = WeakAuras.GetData(childId);
|
||||
if(childData) then
|
||||
local left, _, right = getRect(childData);
|
||||
if not(previousData) then
|
||||
if not(math.abs(left) < 0.01 or math.abs(right) < 0.01) then
|
||||
return nil;
|
||||
end
|
||||
previousData = childData;
|
||||
else
|
||||
local pleft, _, pright = getRect(previousData);
|
||||
if(left - pright > 0) then
|
||||
if not(spaced) then
|
||||
spaced = left - pright;
|
||||
else
|
||||
if(math.abs(spaced - (left - pright)) > 0.01) then
|
||||
return nil;
|
||||
end
|
||||
end
|
||||
elseif(right - pleft < 0) then
|
||||
if not(spaced) then
|
||||
spaced = right - pleft;
|
||||
else
|
||||
if(math.abs(spaced - (right - pleft)) > 0.01) then
|
||||
return nil;
|
||||
end
|
||||
end
|
||||
else
|
||||
return nil;
|
||||
end
|
||||
end
|
||||
previousData = childData;
|
||||
end
|
||||
end
|
||||
return spaced;
|
||||
end,
|
||||
set = function(info, v)
|
||||
local xOffset = 0;
|
||||
for index, childId in pairs(data.controlledChildren) do
|
||||
local childData = WeakAuras.GetData(childId);
|
||||
local childRegion = WeakAuras.GetRegion(childId)
|
||||
if(childData and childRegion) then
|
||||
if(v > 0) then
|
||||
if(childData.selfPoint:find("LEFT")) then
|
||||
childData.xOffset = xOffset;
|
||||
elseif(childData.selfPoint:find("RIGHT")) then
|
||||
childData.xOffset = xOffset + (childData.width or childRegion.width);
|
||||
else
|
||||
childData.xOffset = xOffset + ((childData.width or childRegion.width) / 2);
|
||||
end
|
||||
xOffset = xOffset + v + (childData.width or childRegion.width);
|
||||
elseif(v < 0) then
|
||||
if(childData.selfPoint:find("LEFT")) then
|
||||
childData.xOffset = xOffset - (childData.width or childRegion.width);
|
||||
elseif(childData.selfPoint:find("RIGHT")) then
|
||||
childData.xOffset = xOffset;
|
||||
else
|
||||
childData.xOffset = xOffset - ((childData.width or childRegion.width) / 2);
|
||||
end
|
||||
xOffset = xOffset + v - (childData.width or childRegion.width);
|
||||
end
|
||||
WeakAuras.Add(childData);
|
||||
end
|
||||
end
|
||||
|
||||
WeakAuras.Add(data);
|
||||
WeakAuras.ResetMoverSizer();
|
||||
end
|
||||
},
|
||||
space_v = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Space Vertically"],
|
||||
order = 35,
|
||||
softMin = -100,
|
||||
softMax = 100,
|
||||
bigStep = 1,
|
||||
get = function()
|
||||
if(#data.controlledChildren < 2) then
|
||||
return nil;
|
||||
end
|
||||
local spaced;
|
||||
local previousData;
|
||||
for index, childId in pairs(data.controlledChildren) do
|
||||
local childData = WeakAuras.GetData(childId);
|
||||
if(childData) then
|
||||
local _, bottom, _, top = getRect(childData);
|
||||
if not(previousData) then
|
||||
if not(math.abs(bottom) < 0.01 or math.abs(top) < 0.01) then
|
||||
return nil;
|
||||
end
|
||||
previousData = childData;
|
||||
else
|
||||
local _, pbottom, _, ptop = getRect(previousData);
|
||||
if(bottom - ptop > 0) then
|
||||
if not(spaced) then
|
||||
spaced = bottom - ptop;
|
||||
else
|
||||
if(math.abs(spaced - (bottom - ptop)) > 0.01) then
|
||||
return nil;
|
||||
end
|
||||
end
|
||||
elseif(top - pbottom < 0) then
|
||||
if not(spaced) then
|
||||
spaced = top - pbottom;
|
||||
else
|
||||
if(math.abs(spaced - (top - pbottom)) > 0.01) then
|
||||
return nil;
|
||||
end
|
||||
end
|
||||
else
|
||||
return nil;
|
||||
end
|
||||
end
|
||||
previousData = childData;
|
||||
end
|
||||
end
|
||||
return spaced;
|
||||
end,
|
||||
set = function(info, v)
|
||||
local yOffset = 0;
|
||||
for index, childId in pairs(data.controlledChildren) do
|
||||
local childData = WeakAuras.GetData(childId);
|
||||
local childRegion = WeakAuras.GetRegion(childId)
|
||||
if(childData and childRegion) then
|
||||
if(v > 0) then
|
||||
if(childData.selfPoint:find("BOTTOM")) then
|
||||
childData.yOffset = yOffset;
|
||||
elseif(childData.selfPoint:find("TOP")) then
|
||||
childData.yOffset = yOffset + (childData.height or childRegion.height);
|
||||
else
|
||||
childData.yOffset = yOffset + ((childData.height or childRegion.height) / 2);
|
||||
end
|
||||
yOffset = yOffset + v + (childData.height or childRegion.height);
|
||||
elseif(v < 0) then
|
||||
if(childData.selfPoint:find("BOTTOM")) then
|
||||
childData.yOffset = yOffset - (childData.height or childRegion.height);
|
||||
elseif(childData.selfPoint:find("TOP")) then
|
||||
childData.yOffset = yOffset;
|
||||
else
|
||||
childData.yOffset = yOffset - ((childData.height or childRegion.height) / 2);
|
||||
end
|
||||
yOffset = yOffset + v - (childData.height or childRegion.height);
|
||||
end
|
||||
WeakAuras.Add(childData);
|
||||
end
|
||||
end
|
||||
|
||||
WeakAuras.Add(data);
|
||||
WeakAuras.ResetMoverSizer();
|
||||
end
|
||||
},
|
||||
scale = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Group Scale"],
|
||||
order = 45,
|
||||
min = 0.05,
|
||||
softMax = 2,
|
||||
bigStep = 0.05,
|
||||
get = function()
|
||||
return data.scale or 1
|
||||
end,
|
||||
set = function(info, v)
|
||||
data.scale = data.scale or 1
|
||||
local change = 1 - (v/data.scale)
|
||||
data.xOffset = data.xOffset/(1-change)
|
||||
data.yOffset = data.yOffset/(1-change)
|
||||
data.scale = v
|
||||
WeakAuras.Add(data);
|
||||
WeakAuras.ResetMoverSizer();
|
||||
end
|
||||
},
|
||||
endHeader = {
|
||||
type = "header",
|
||||
order = 100,
|
||||
name = "",
|
||||
},
|
||||
};
|
||||
|
||||
for k, v in pairs(WeakAuras.BorderOptions(id, data, nil, nil, 70)) do
|
||||
options[k] = v
|
||||
end
|
||||
|
||||
return {
|
||||
group = options,
|
||||
position = WeakAuras.PositionOptions(id, data, nil, true, true),
|
||||
};
|
||||
end
|
||||
|
||||
local function createThumbnail()
|
||||
-- frame
|
||||
local thumbnail = CreateFrame("FRAME", nil, UIParent);
|
||||
thumbnail:SetWidth(32);
|
||||
thumbnail:SetHeight(32);
|
||||
|
||||
-- border
|
||||
local border = thumbnail:CreateTexture(nil, "OVERLAY");
|
||||
border:SetAllPoints(thumbnail);
|
||||
border:SetTexture("Interface\\BUTTONS\\UI-Quickslot2.blp");
|
||||
border:SetTexCoord(0.2, 0.8, 0.2, 0.8);
|
||||
|
||||
local icon = thumbnail:CreateTexture(nil, "OVERLAY")
|
||||
icon:SetAllPoints(thumbnail)
|
||||
thumbnail.icon = icon
|
||||
|
||||
return thumbnail
|
||||
end
|
||||
|
||||
local function createDefaultIcon(parent)
|
||||
-- default Icon
|
||||
local defaultIcon = CreateFrame("FRAME", nil, parent);
|
||||
parent.defaultIcon = defaultIcon;
|
||||
|
||||
local t1 = defaultIcon:CreateTexture(nil, "ARTWORK");
|
||||
t1:SetWidth(24);
|
||||
t1:SetHeight(8);
|
||||
t1:SetTexture(0.8, 0, 0, 0.5);
|
||||
t1:SetPoint("TOP", parent, "TOP", 0, -6);
|
||||
local t2 = defaultIcon:CreateTexture(nil, "ARTWORK");
|
||||
t2:SetWidth(20);
|
||||
t2:SetHeight(20);
|
||||
t2:SetTexture(0.2, 0.8, 0.2, 0.5);
|
||||
t2:SetPoint("TOP", t1, "BOTTOM", 0, 5);
|
||||
local t3 = defaultIcon:CreateTexture(nil, "ARTWORK");
|
||||
t3:SetWidth(20);
|
||||
t3:SetHeight(12);
|
||||
t3:SetTexture(0.1, 0.25, 1, 0.5);
|
||||
t3:SetPoint("TOP", t2, "BOTTOM", -5, 8);
|
||||
|
||||
return defaultIcon
|
||||
end
|
||||
|
||||
-- Modify preview thumbnail
|
||||
local function modifyThumbnail(parent, frame, data)
|
||||
function frame:SetIcon(path)
|
||||
if data.groupIcon then
|
||||
local success = frame.icon:SetTexture(data.groupIcon)
|
||||
if success then
|
||||
if frame.defaultIcon then
|
||||
frame.defaultIcon:Hide()
|
||||
end
|
||||
frame.icon:Show()
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if frame.icon then
|
||||
frame.icon:Hide()
|
||||
end
|
||||
if not frame.defaultIcon then
|
||||
frame.defaultIcon = createDefaultIcon(frame)
|
||||
end
|
||||
frame.defaultIcon:Show()
|
||||
end
|
||||
|
||||
frame:SetIcon(nil)
|
||||
end
|
||||
|
||||
-- Create "new region" preview
|
||||
local function createIcon()
|
||||
local thumbnail = createThumbnail(UIParent)
|
||||
thumbnail.defaultIcon = createDefaultIcon(thumbnail)
|
||||
return thumbnail
|
||||
end
|
||||
|
||||
-- Register new region type options with WeakAuras
|
||||
WeakAuras.RegisterRegionOptions("group", createOptions, createIcon, L["Group"], createThumbnail, modifyThumbnail, L["Controls the positioning and configuration of multiple displays at the same time"]);
|
||||
@@ -0,0 +1,410 @@
|
||||
if not WeakAuras.IsCorrectVersion() then return end
|
||||
|
||||
local Masque = LibStub("Masque", true)
|
||||
local L = WeakAuras.L
|
||||
|
||||
local function createOptions(id, data)
|
||||
local hiddenIconExtra = function()
|
||||
return WeakAuras.IsCollapsed("icon", "icon", "iconextra", true);
|
||||
end
|
||||
local indentWidth = 0.15
|
||||
|
||||
local options = {
|
||||
__title = L["Icon Settings"],
|
||||
__order = 1,
|
||||
color = {
|
||||
type = "color",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Color"],
|
||||
hasAlpha = true,
|
||||
order = 1
|
||||
},
|
||||
auto = {
|
||||
type = "toggle",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Automatic Icon"],
|
||||
order = 2,
|
||||
disabled = function() return not WeakAuras.CanHaveAuto(data); end,
|
||||
get = function() return WeakAuras.CanHaveAuto(data) and data.auto; end
|
||||
},
|
||||
displayIcon = {
|
||||
type = "input",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Display Icon"],
|
||||
hidden = function() return WeakAuras.CanHaveAuto(data) and data.auto; end,
|
||||
order = 3,
|
||||
get = function()
|
||||
return data.displayIcon and tostring(data.displayIcon) or "";
|
||||
end,
|
||||
set = function(info, v)
|
||||
data.displayIcon = v;
|
||||
WeakAuras.Add(data);
|
||||
WeakAuras.UpdateThumbnail(data);
|
||||
WeakAuras.SetIconNames(data);
|
||||
end
|
||||
},
|
||||
chooseIcon = {
|
||||
type = "execute",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Choose"],
|
||||
hidden = function() return WeakAuras.CanHaveAuto(data) and data.auto; end,
|
||||
order = 4,
|
||||
func = function() WeakAuras.OpenIconPicker(data, "displayIcon"); end
|
||||
},
|
||||
desaturate = {
|
||||
type = "toggle",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Desaturate"],
|
||||
order = 5,
|
||||
},
|
||||
useTooltip = {
|
||||
type = "toggle",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Tooltip on Mouseover"],
|
||||
hidden = function() return not WeakAuras.CanHaveTooltip(data) end,
|
||||
order = 6
|
||||
},
|
||||
iconExtraDescription = {
|
||||
type = "execute",
|
||||
control = "WeakAurasExpandSmall",
|
||||
name = function()
|
||||
local line = L["|cFFffcc00Extra Options:|r"]
|
||||
local changed = false
|
||||
if data.alpha ~= 1 then
|
||||
line = L["%s Alpha: %d%%"]:format(line, data.alpha*100)
|
||||
changed = true
|
||||
end
|
||||
if data.zoom ~= 0 then
|
||||
line = L["%s Zoom: %d%%"]:format(line, data.zoom*100)
|
||||
changed = true
|
||||
end
|
||||
if data.iconInset and data.iconInset ~= 0 then
|
||||
line = L["%s Inset: %d%%"]:format(line, data.iconInset*100)
|
||||
changed = true
|
||||
end
|
||||
if data.keepAspectRatio then
|
||||
line = L["%s Keep Aspect Ratio"]:format(line)
|
||||
changed = true
|
||||
end
|
||||
if not changed then
|
||||
line = L["%s Default Alpha, Zoom, Icon Inset, Aspect Ratio"]:format(line)
|
||||
end
|
||||
return line
|
||||
end,
|
||||
width = WeakAuras.doubleWidth,
|
||||
order = 7,
|
||||
image = function()
|
||||
local collapsed = WeakAuras.IsCollapsed("icon", "icon", "iconextra", true);
|
||||
return collapsed and "Interface\\AddOns\\WeakAuras\\Media\\Textures\\edit" or "Interface\\AddOns\\WeakAuras\\Media\\Textures\\editdown"
|
||||
end,
|
||||
imageWidth = 24,
|
||||
imageHeight = 24,
|
||||
func = function()
|
||||
local collapsed = WeakAuras.IsCollapsed("icon", "icon", "iconextra", true);
|
||||
WeakAuras.SetCollapsed("icon", "icon", "iconextra", not collapsed);
|
||||
end,
|
||||
},
|
||||
iconExtra_space1 = {
|
||||
type = "description",
|
||||
name = "",
|
||||
width = indentWidth,
|
||||
order = 7.02,
|
||||
hidden = hiddenIconExtra,
|
||||
},
|
||||
alpha = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth - indentWidth,
|
||||
name = L["Alpha"],
|
||||
order = 7.03,
|
||||
min = 0,
|
||||
max = 1,
|
||||
bigStep = 0.01,
|
||||
isPercent = true,
|
||||
hidden = hiddenIconExtra,
|
||||
},
|
||||
zoom = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Zoom"],
|
||||
order = 7.04,
|
||||
min = 0,
|
||||
max = 1,
|
||||
bigStep = 0.01,
|
||||
isPercent = true,
|
||||
hidden = hiddenIconExtra,
|
||||
},
|
||||
iconExtra_space2 = {
|
||||
type = "description",
|
||||
name = "",
|
||||
width = indentWidth,
|
||||
order = 7.05,
|
||||
hidden = hiddenIconExtra,
|
||||
},
|
||||
iconInset = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth - indentWidth,
|
||||
name = L["Icon Inset"],
|
||||
order = 7.06,
|
||||
min = 0,
|
||||
max = 1,
|
||||
bigStep = 0.01,
|
||||
isPercent = true,
|
||||
hidden = function()
|
||||
return not Masque or hiddenIconExtra();
|
||||
end
|
||||
},
|
||||
keepAspectRatio = {
|
||||
type = "toggle",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Keep Aspect Ratio"],
|
||||
order = 7.07,
|
||||
hidden = hiddenIconExtra,
|
||||
},
|
||||
cooldownHeader = {
|
||||
type = "header",
|
||||
order = 11,
|
||||
name = L["Cooldown Settings"],
|
||||
},
|
||||
cooldown = {
|
||||
type = "toggle",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Show Cooldown"],
|
||||
order = 11.1,
|
||||
disabled = function() return not WeakAuras.CanHaveDuration(data); end,
|
||||
get = function() return WeakAuras.CanHaveDuration(data) and data.cooldown; end
|
||||
},
|
||||
inverse = {
|
||||
type = "toggle",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Inverse"],
|
||||
order = 11.2,
|
||||
disabled = function() return not (WeakAuras.CanHaveDuration(data) and data.cooldown); end,
|
||||
get = function() return data.inverse and WeakAuras.CanHaveDuration(data) and data.cooldown; end,
|
||||
hidden = function() return not data.cooldown end
|
||||
},
|
||||
cooldownEdge = {
|
||||
type = "toggle",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Cooldown Edge"],
|
||||
order = 11.3,
|
||||
disabled = function() return not WeakAuras.CanHaveDuration(data) end,
|
||||
hidden = function() return not data.cooldown end,
|
||||
},
|
||||
endHeader = {
|
||||
type = "header",
|
||||
order = 100,
|
||||
name = "",
|
||||
},
|
||||
};
|
||||
|
||||
return {
|
||||
icon = options,
|
||||
position = WeakAuras.PositionOptions(id, data),
|
||||
};
|
||||
end
|
||||
|
||||
local function createThumbnail()
|
||||
local frame = CreateFrame("FRAME", nil, UIParent)
|
||||
local icon = frame:CreateTexture();
|
||||
icon:SetTexture("Interface\\Icons\\INV_Misc_QuestionMark");
|
||||
icon:SetAllPoints(frame)
|
||||
frame.icon = icon
|
||||
return frame;
|
||||
end
|
||||
|
||||
local function modifyThumbnail(parent, frame, data)
|
||||
local texWidth = 0.25 * data.zoom;
|
||||
frame.icon:SetTexCoord(texWidth, 1 - texWidth, texWidth, 1 - texWidth);
|
||||
frame:SetParent(parent)
|
||||
|
||||
function frame:SetIcon(path)
|
||||
local success = self.icon:SetTexture(data.auto and path or data.displayIcon) and (data.auto and path or data.displayIcon);
|
||||
if not(success) then
|
||||
self.icon:SetTexture("Interface\\Icons\\INV_Misc_QuestionMark");
|
||||
end
|
||||
end
|
||||
|
||||
if data then
|
||||
local name, icon = WeakAuras.GetNameAndIcon(data);
|
||||
frame:SetIcon(icon)
|
||||
end
|
||||
end
|
||||
|
||||
local templates = {
|
||||
{
|
||||
title = L["Default"],
|
||||
icon = "Interface\\ICONS\\Temp.blp",
|
||||
data = {
|
||||
cooldown = true,
|
||||
inverse = true,
|
||||
};
|
||||
},
|
||||
{
|
||||
title = L["Tiny Icon"],
|
||||
description = L["A 20x20 pixels icon"],
|
||||
icon = "Interface\\ICONS\\Temp.blp",
|
||||
data = {
|
||||
width = 20,
|
||||
height = 20,
|
||||
cooldown = true,
|
||||
inverse = true,
|
||||
};
|
||||
},
|
||||
{
|
||||
title = L["Small Icon"],
|
||||
description = L["A 32x32 pixels icon"],
|
||||
icon = "Interface\\ICONS\\Temp.blp",
|
||||
data = {
|
||||
width = 32,
|
||||
height = 32,
|
||||
cooldown = true,
|
||||
inverse = true,
|
||||
};
|
||||
},
|
||||
{
|
||||
title = L["Medium Icon"],
|
||||
description = L["A 40x40 pixels icon"],
|
||||
icon = "Interface\\ICONS\\Temp.blp",
|
||||
data = {
|
||||
width = 40,
|
||||
height = 40,
|
||||
cooldown = true,
|
||||
inverse = true,
|
||||
};
|
||||
},
|
||||
{
|
||||
title = L["Big Icon"],
|
||||
description = L["A 48x48 pixels icon"],
|
||||
icon = "Interface\\ICONS\\Temp.blp",
|
||||
data = {
|
||||
width = 48,
|
||||
height = 48,
|
||||
cooldown = true,
|
||||
inverse = true,
|
||||
};
|
||||
},
|
||||
{
|
||||
title = L["Huge Icon"],
|
||||
description = L["A 64x64 pixels icon"],
|
||||
icon = "Interface\\ICONS\\Temp.blp",
|
||||
data = {
|
||||
width = 64,
|
||||
height = 64,
|
||||
cooldown = true,
|
||||
inverse = true,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
local anchorPoints = {
|
||||
BOTTOMLEFT = {
|
||||
display = { L["Edge"], L["Bottom Left"] },
|
||||
type = "point"
|
||||
},
|
||||
BOTTOM = {
|
||||
display = { L["Edge"], L["Bottom"] },
|
||||
type = "point"
|
||||
},
|
||||
BOTTOMRIGHT = {
|
||||
display = { L["Edge"], L["Bottom Right"] },
|
||||
type = "point"
|
||||
},
|
||||
RIGHT = {
|
||||
display = { L["Edge"], L["Right"] },
|
||||
type = "point"
|
||||
},
|
||||
TOPRIGHT = {
|
||||
display = { L["Edge"], L["Top Right"] },
|
||||
type = "point"
|
||||
},
|
||||
TOP = {
|
||||
display = { L["Edge"], L["Top"] },
|
||||
type = "point"
|
||||
},
|
||||
TOPLEFT = {
|
||||
display = { L["Edge"], L["Top Left"] },
|
||||
type = "point"
|
||||
},
|
||||
LEFT = {
|
||||
display = { L["Edge"], L["Left"] },
|
||||
type = "point"
|
||||
},
|
||||
CENTER = {
|
||||
display = L["Center"],
|
||||
type = "point"
|
||||
},
|
||||
INNER_BOTTOMLEFT = {
|
||||
display = { L["Inner"], L["Bottom Left"] },
|
||||
type = "point"
|
||||
},
|
||||
INNER_BOTTOM = {
|
||||
display = { L["Inner"], L["Bottom"] },
|
||||
type = "point"
|
||||
},
|
||||
INNER_BOTTOMRIGHT = {
|
||||
display = { L["Inner"], L["Bottom Right"] },
|
||||
type = "point"
|
||||
},
|
||||
INNER_RIGHT = {
|
||||
display = { L["Inner"], L["Right"] },
|
||||
type = "point"
|
||||
},
|
||||
INNER_TOPRIGHT = {
|
||||
display = { L["Inner"], L["Top Right"] },
|
||||
type = "point"
|
||||
},
|
||||
INNER_TOP = {
|
||||
display = { L["Inner"], L["Top"] },
|
||||
type = "point"
|
||||
},
|
||||
INNER_TOPLEFT = {
|
||||
display = { L["Inner"], L["Top Left"] },
|
||||
type = "point"
|
||||
},
|
||||
INNER_LEFT = {
|
||||
display = { L["Inner"], L["Left"] },
|
||||
type = "point"
|
||||
},
|
||||
OUTER_BOTTOMLEFT = {
|
||||
display = { L["Outer"], L["Bottom Left"] },
|
||||
type = "point"
|
||||
},
|
||||
OUTER_BOTTOM = {
|
||||
display = { L["Outer"], L["Bottom"] },
|
||||
type = "point"
|
||||
},
|
||||
OUTER_BOTTOMRIGHT = {
|
||||
display = { L["Outer"], L["Bottom Right"] },
|
||||
type = "point"
|
||||
},
|
||||
OUTER_RIGHT = {
|
||||
display = { L["Outer"], L["Right"] },
|
||||
type = "point"
|
||||
},
|
||||
OUTER_TOPRIGHT = {
|
||||
display = { L["Outer"], L["Top Right"] },
|
||||
type = "point"
|
||||
},
|
||||
OUTER_TOP = {
|
||||
display = { L["Outer"], L["Top"] },
|
||||
type = "point"
|
||||
},
|
||||
OUTER_TOPLEFT = {
|
||||
display = { L["Outer"], L["Top Left"] },
|
||||
type = "point"
|
||||
},
|
||||
OUTER_LEFT = {
|
||||
display = { L["Outer"], L["Left"] },
|
||||
type = "point"
|
||||
},
|
||||
ALL = {
|
||||
display = L["Whole Area"],
|
||||
type = "area"
|
||||
}
|
||||
}
|
||||
|
||||
local function GetAnchors(data)
|
||||
return anchorPoints;
|
||||
end
|
||||
|
||||
WeakAuras.RegisterRegionOptions("icon", createOptions, "interface\\icons\\spell_holy_sealofsalvation.blp", L["Icon"], createThumbnail, modifyThumbnail, L["Shows a spell icon with an optional cooldown overlay"], templates, GetAnchors);
|
||||
@@ -0,0 +1,296 @@
|
||||
if not WeakAuras.IsCorrectVersion() then return end
|
||||
|
||||
local L = WeakAuras.L;
|
||||
|
||||
local function createOptions(id, data)
|
||||
local options = {
|
||||
__title = L["Model Settings"],
|
||||
__order = 1,
|
||||
modelIsUnit = {
|
||||
type = "toggle",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Show model of unit "],
|
||||
order = 0.5,
|
||||
hidden = function() return data.modelDisplayInfo and WeakAuras.BuildInfo > 80100 end
|
||||
},
|
||||
-- Option for modelIsDisplayInfo added below
|
||||
|
||||
-- Option for path/id added below
|
||||
space2 = {
|
||||
type = "execute",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = "",
|
||||
order = 1.5,
|
||||
image = function() return "", 0, 0 end,
|
||||
hidden = function() return data.modelIsUnit end
|
||||
},
|
||||
chooseModel = {
|
||||
type = "execute",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Choose"],
|
||||
order = 2,
|
||||
func = function()
|
||||
WeakAuras.OpenModelPicker(data);
|
||||
end,
|
||||
hidden = function() return data.modelIsUnit end
|
||||
},
|
||||
advance = {
|
||||
type = "toggle",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Animate"],
|
||||
order = 5,
|
||||
},
|
||||
sequence = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Animation Sequence"],
|
||||
min = 0,
|
||||
max = 150,
|
||||
step = 1,
|
||||
bigStep = 1,
|
||||
order = 6,
|
||||
disabled = function() return not data.advance end
|
||||
},
|
||||
model_z = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Z Offset"],
|
||||
softMin = -20,
|
||||
softMax = 20,
|
||||
step = .001,
|
||||
bigStep = 0.05,
|
||||
order = 20,
|
||||
},
|
||||
model_x = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["X Offset"],
|
||||
softMin = -20,
|
||||
softMax = 20,
|
||||
step = .001,
|
||||
bigStep = 0.05,
|
||||
order = 30,
|
||||
},
|
||||
model_y = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Y Offset"],
|
||||
softMin = -20,
|
||||
softMax = 20,
|
||||
step = .001,
|
||||
bigStep = 0.05,
|
||||
order = 40,
|
||||
},
|
||||
rotation = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Rotation"],
|
||||
min = 0,
|
||||
max = 360,
|
||||
step = 1,
|
||||
bigStep = 3,
|
||||
order = 45,
|
||||
},
|
||||
endHeader = {
|
||||
type = "header",
|
||||
order = 100,
|
||||
name = "",
|
||||
},
|
||||
};
|
||||
|
||||
if WeakAuras.BuildInfo > 80100 then
|
||||
options.modelDisplayInfo = {
|
||||
type = "toggle",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Use Display Info Id"],
|
||||
order = 0.6,
|
||||
hidden = function() return data.modelIsUnit end
|
||||
}
|
||||
else
|
||||
options.model_path = {
|
||||
type = "input",
|
||||
width = WeakAuras.doubleWidth,
|
||||
name = L["Model"],
|
||||
order = 1
|
||||
}
|
||||
end
|
||||
|
||||
for k, v in pairs(WeakAuras.BorderOptions(id, data, nil, nil, 70)) do
|
||||
options[k] = v
|
||||
end
|
||||
|
||||
return {
|
||||
model = options,
|
||||
position = WeakAuras.PositionOptions(id, data, nil, nil, nil),
|
||||
};
|
||||
end
|
||||
|
||||
local function createThumbnail()
|
||||
local borderframe = CreateFrame("FRAME", nil, UIParent);
|
||||
borderframe:SetWidth(32);
|
||||
borderframe:SetHeight(32);
|
||||
|
||||
local border = borderframe:CreateTexture(nil, "Overlay");
|
||||
border:SetAllPoints(borderframe);
|
||||
border:SetTexture("Interface\\BUTTONS\\UI-Quickslot2.blp");
|
||||
border:SetTexCoord(0.2, 0.8, 0.2, 0.8);
|
||||
|
||||
local model = CreateFrame("PlayerModel", nil, borderframe);
|
||||
borderframe.model = model;
|
||||
model:SetFrameStrata("FULLSCREEN");
|
||||
|
||||
return borderframe;
|
||||
end
|
||||
|
||||
local function modifyThumbnail(parent, region, data)
|
||||
region:SetParent(parent)
|
||||
|
||||
local model = region.model
|
||||
region:SetScript("OnUpdate", function()
|
||||
local optionsFrame = WeakAuras.OptionsFrame();
|
||||
if optionsFrame then
|
||||
model:SetParent(optionsFrame)
|
||||
region:SetScript("OnUpdate", nil)
|
||||
end
|
||||
end);
|
||||
model:SetAllPoints(region);
|
||||
model:SetFrameStrata(region:GetParent():GetFrameStrata());
|
||||
model:SetWidth(region:GetWidth() - 2);
|
||||
model:SetHeight(region:GetHeight() - 2);
|
||||
model:SetPoint("center", region, "center");
|
||||
WeakAuras.SetModel(model, data.model_path, data.modelIsUnit, data.modelDisplayInfo)
|
||||
model:SetScript("OnShow", function()
|
||||
WeakAuras.SetModel(model, data.model_path, data.modelIsUnit, data.modelDisplayInfo)
|
||||
model:SetPosition(data.model_z, data.model_x, data.model_y);
|
||||
model:SetFacing(rad(data.rotation));
|
||||
end);
|
||||
|
||||
model:SetPosition(data.model_z, data.model_x, data.model_y);
|
||||
model:SetFacing(rad(data.rotation));
|
||||
end
|
||||
|
||||
local function createIcon()
|
||||
local data = {
|
||||
model_path = "Creature/Arthaslichking/arthaslichking.m2",
|
||||
modelIsUnit = false,
|
||||
model_x = 0,
|
||||
model_y = 0,
|
||||
model_z = 0.35,
|
||||
sequence = 1,
|
||||
advance = false,
|
||||
rotation = 0,
|
||||
scale = 1,
|
||||
height = 40,
|
||||
width = 40
|
||||
};
|
||||
|
||||
local thumbnail = createThumbnail(UIParent);
|
||||
modifyThumbnail(UIParent, thumbnail, data, nil, 50);
|
||||
|
||||
return thumbnail;
|
||||
end
|
||||
|
||||
local templates = {
|
||||
{
|
||||
title = L["Default"],
|
||||
data = {
|
||||
};
|
||||
},
|
||||
{
|
||||
title = L["Fire Orb"],
|
||||
description = "",
|
||||
data = {
|
||||
width = 100,
|
||||
height = 100,
|
||||
model_path = "spells/6fx_smallfire.m2",
|
||||
model_x = 0,
|
||||
model_y = -0.5,
|
||||
model_z = -1.5
|
||||
},
|
||||
},
|
||||
{
|
||||
title = L["Blue Sparkle Orb"],
|
||||
description = "",
|
||||
data = {
|
||||
width = 100,
|
||||
height = 100,
|
||||
advance = true,
|
||||
sequence = 1,
|
||||
model_path = "spells/7fx_druid_halfmoon_missile.m2",
|
||||
model_x = 0,
|
||||
model_y = 0.7,
|
||||
model_z = 1.5
|
||||
},
|
||||
},
|
||||
{
|
||||
title = L["Arcane Orb"],
|
||||
description = "",
|
||||
data = {
|
||||
width = 100,
|
||||
height = 100,
|
||||
advance = true,
|
||||
sequence = 1,
|
||||
model_path = "spells/proc_arcane_impact_low.m2",
|
||||
model_x = 0,
|
||||
model_y = 0.8,
|
||||
model_z = 2
|
||||
},
|
||||
},
|
||||
{
|
||||
title = L["Orange Rune"],
|
||||
description = "",
|
||||
data = {
|
||||
width = 100,
|
||||
height = 100,
|
||||
advance = true,
|
||||
sequence = 1,
|
||||
model_path = "spells/7fx_godking_orangerune_state.m2",
|
||||
},
|
||||
},
|
||||
{
|
||||
title = L["Blue Rune"],
|
||||
description = "",
|
||||
data = {
|
||||
width = 100,
|
||||
height = 100,
|
||||
advance = true,
|
||||
sequence = 1,
|
||||
model_path = "spells/7fx_godking_bluerune_state.m2",
|
||||
}
|
||||
},
|
||||
{
|
||||
title = L["Yellow Rune"],
|
||||
description = "",
|
||||
data = {
|
||||
width = 100,
|
||||
height = 100,
|
||||
advance = true,
|
||||
sequence = 1,
|
||||
model_path = "spells/7fx_godking_yellowrune_state.m2",
|
||||
}
|
||||
},
|
||||
{
|
||||
title = L["Purple Rune"],
|
||||
description = "",
|
||||
data = {
|
||||
width = 100,
|
||||
height = 100,
|
||||
advance = true,
|
||||
sequence = 1,
|
||||
model_path = "spells/7fx_godking_purplerune_state.m2",
|
||||
}
|
||||
},
|
||||
{
|
||||
title = L["Green Rune"],
|
||||
description = "",
|
||||
data = {
|
||||
width = 100,
|
||||
height = 100,
|
||||
advance = true,
|
||||
sequence = 1,
|
||||
model_path = "spells/7fx_godking_greenrune_state.m2",
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
WeakAuras.RegisterRegionOptions("model", createOptions, createIcon, L["Model"], createThumbnail, modifyThumbnail, L["Shows a 3D model from the game files"], templates);
|
||||
@@ -0,0 +1,819 @@
|
||||
if not WeakAuras.IsCorrectVersion() then return end
|
||||
|
||||
local L = WeakAuras.L;
|
||||
|
||||
local function createOptions(id, data)
|
||||
local options = {
|
||||
__title = L["Progress Texture Settings"],
|
||||
__order = 1,
|
||||
foregroundTexture = {
|
||||
width = WeakAuras.normalWidth,
|
||||
type = "input",
|
||||
name = L["Foreground Texture"],
|
||||
order = 1
|
||||
},
|
||||
backgroundTexture = {
|
||||
type = "input",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Background Texture"],
|
||||
order = 5,
|
||||
disabled = function() return data.sameTexture; end,
|
||||
get = function() return data.sameTexture and data.foregroundTexture or data.backgroundTexture; end
|
||||
},
|
||||
mirror = {
|
||||
type = "toggle",
|
||||
width = WeakAuras.halfWidth,
|
||||
name = L["Mirror"],
|
||||
order = 10,
|
||||
disabled = function() return data.orientation == "CLOCKWISE" or data.orientation == "ANTICLOCKWISE"; end
|
||||
},
|
||||
chooseForegroundTexture = {
|
||||
type = "execute",
|
||||
name = L["Choose"],
|
||||
width = WeakAuras.halfWidth,
|
||||
order = 12,
|
||||
func = function()
|
||||
WeakAuras.OpenTexturePicker(data, "foregroundTexture", WeakAuras.texture_types);
|
||||
end
|
||||
},
|
||||
sameTexture = {
|
||||
type = "toggle",
|
||||
name = L["Same"],
|
||||
width = WeakAuras.halfWidth,
|
||||
order = 15
|
||||
},
|
||||
chooseBackgroundTexture = {
|
||||
type = "execute",
|
||||
name = L["Choose"],
|
||||
width = WeakAuras.halfWidth,
|
||||
order = 17,
|
||||
func = function()
|
||||
WeakAuras.OpenTexturePicker(data, "backgroundTexture", WeakAuras.texture_types);
|
||||
end,
|
||||
disabled = function() return data.sameTexture; end
|
||||
},
|
||||
desaturateForeground = {
|
||||
type = "toggle",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Desaturate"],
|
||||
order = 17.5,
|
||||
},
|
||||
desaturateBackground = {
|
||||
type = "toggle",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Desaturate"],
|
||||
order = 17.6,
|
||||
},
|
||||
blendMode = {
|
||||
type = "select",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Blend Mode"],
|
||||
order = 20,
|
||||
values = WeakAuras.blend_types
|
||||
},
|
||||
backgroundOffset = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Background Offset"],
|
||||
min = 0,
|
||||
softMax = 25,
|
||||
bigStep = 1,
|
||||
order = 25
|
||||
},
|
||||
orientation = {
|
||||
type = "select",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Orientation"],
|
||||
order = 35,
|
||||
values = WeakAuras.orientation_with_circle_types
|
||||
},
|
||||
compress = {
|
||||
type = "toggle",
|
||||
width = WeakAuras.halfWidth,
|
||||
name = L["Compress"],
|
||||
order = 40,
|
||||
disabled = function() return data.orientation == "CLOCKWISE" or data.orientation == "ANTICLOCKWISE"; end
|
||||
},
|
||||
inverse = {
|
||||
type = "toggle",
|
||||
width = WeakAuras.halfWidth,
|
||||
name = L["Inverse"],
|
||||
order = 41
|
||||
},
|
||||
foregroundColor = {
|
||||
type = "color",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Foreground Color"],
|
||||
hasAlpha = true,
|
||||
order = 30
|
||||
},
|
||||
backgroundColor = {
|
||||
type = "color",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Background Color"],
|
||||
hasAlpha = true,
|
||||
order = 37
|
||||
},
|
||||
user_x = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
order = 42,
|
||||
name = L["Re-center X"],
|
||||
min = -0.5,
|
||||
max = 0.5,
|
||||
bigStep = 0.01,
|
||||
hidden = function() return data.orientation == "CLOCKWISE" or data.orientation == "ANTICLOCKWISE"; end
|
||||
},
|
||||
user_y = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
order = 44,
|
||||
name = L["Re-center Y"],
|
||||
min = -0.5,
|
||||
max = 0.5,
|
||||
bigStep = 0.01,
|
||||
hidden = function() return data.orientation == "CLOCKWISE" or data.orientation == "ANTICLOCKWISE"; end
|
||||
},
|
||||
startAngle = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
order = 42,
|
||||
name = L["Start Angle"],
|
||||
min = 0,
|
||||
max = 360,
|
||||
bigStep = 1,
|
||||
hidden = function() return data.orientation ~= "CLOCKWISE" and data.orientation ~= "ANTICLOCKWISE"; end
|
||||
},
|
||||
endAngle = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
order = 44,
|
||||
name = L["End Angle"],
|
||||
min = 0,
|
||||
max = 360,
|
||||
bigStep = 1,
|
||||
hidden = function() return data.orientation ~= "CLOCKWISE" and data.orientation ~= "ANTICLOCKWISE"; end
|
||||
},
|
||||
crop_x = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Crop X"],
|
||||
order = 46,
|
||||
min = 0,
|
||||
softMax = 2,
|
||||
bigStep = 0.01,
|
||||
isPercent = true,
|
||||
set = function(info, v)
|
||||
data.width = data.width * ((1 + data.crop_x) / (1 + v));
|
||||
data.crop_x = v;
|
||||
WeakAuras.Add(data);
|
||||
WeakAuras.UpdateThumbnail(data);
|
||||
WeakAuras.SetIconNames(data);
|
||||
if(data.parent) then
|
||||
local parentData = WeakAuras.GetData(data.parent);
|
||||
if(parentData) then
|
||||
WeakAuras.Add(parentData);
|
||||
end
|
||||
end
|
||||
WeakAuras.ResetMoverSizer();
|
||||
end,
|
||||
},
|
||||
crop_y = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Crop Y"],
|
||||
order = 47,
|
||||
min = 0,
|
||||
softMax = 2,
|
||||
bigStep = 0.01,
|
||||
isPercent = true,
|
||||
set = function(info, v)
|
||||
data.height = data.height * ((1 + data.crop_y) / (1 + v));
|
||||
data.crop_y = v;
|
||||
WeakAuras.Add(data);
|
||||
WeakAuras.UpdateThumbnail(data);
|
||||
WeakAuras.SetIconNames(data);
|
||||
if(data.parent) then
|
||||
local parentData = WeakAuras.GetData(data.parent);
|
||||
if(parentData) then
|
||||
WeakAuras.Add(parentData);
|
||||
end
|
||||
end
|
||||
WeakAuras.ResetMoverSizer();
|
||||
end,
|
||||
},
|
||||
rotation = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Rotation"],
|
||||
order = 52,
|
||||
min = 0,
|
||||
max = 360,
|
||||
bigStep = 1
|
||||
},
|
||||
alpha = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Alpha"],
|
||||
order = 48,
|
||||
min = 0,
|
||||
max = 1,
|
||||
bigStep = 0.01,
|
||||
isPercent = true
|
||||
},
|
||||
smoothProgress = {
|
||||
type = "toggle",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Smooth Progress"],
|
||||
desc = L["Animates progress changes"],
|
||||
order = 55.1
|
||||
},
|
||||
textureWrapMode = {
|
||||
type = "select",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Texture Wrap"],
|
||||
order = 55.2,
|
||||
values = WeakAuras.texture_wrap_types
|
||||
},
|
||||
slanted = {
|
||||
type = "toggle",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Slanted"],
|
||||
order = 55.3,
|
||||
hidden = function() return data.orientation == "CLOCKWISE" or data.orientation == "ANTICLOCKWISE"; end
|
||||
},
|
||||
slant = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Slant Amount"],
|
||||
order = 55.4,
|
||||
min = 0,
|
||||
max = 1,
|
||||
bigStep = 0.1,
|
||||
hidden = function() return not data.slanted or data.orientation == "CLOCKWISE" or data.orientation == "ANTICLOCKWISE" end
|
||||
},
|
||||
slantFirst = {
|
||||
type = "toggle",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Inverse Slant"],
|
||||
order = 55.5,
|
||||
hidden = function() return not data.slanted or data.orientation == "CLOCKWISE" or data.orientation == "ANTICLOCKWISE" end
|
||||
},
|
||||
slantMode = {
|
||||
type = "select",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Slant Mode"],
|
||||
order = 55.6,
|
||||
hidden = function() return not data.slanted or data.orientation == "CLOCKWISE" or data.orientation == "ANTICLOCKWISE" end,
|
||||
values = WeakAuras.slant_mode
|
||||
},
|
||||
spacer = {
|
||||
type = "header",
|
||||
name = "",
|
||||
order = 56
|
||||
},
|
||||
endHeader = {
|
||||
type = "header",
|
||||
order = 100,
|
||||
name = "",
|
||||
},
|
||||
};
|
||||
options = WeakAuras.regionPrototype.AddAdjustedDurationOptions(options, data, 57);
|
||||
|
||||
local overlayInfo = WeakAuras.GetOverlayInfo(data);
|
||||
if (overlayInfo and next(overlayInfo)) then
|
||||
options["overlayheader"] = {
|
||||
type = "header",
|
||||
name = L["Overlays"],
|
||||
order = 58
|
||||
}
|
||||
local index = 58.01
|
||||
for id, display in ipairs(overlayInfo) do
|
||||
options["overlaycolor" .. id] = {
|
||||
type = "color",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = string.format(L["%s Color"], display),
|
||||
hasAlpha = true,
|
||||
order = index,
|
||||
get = function()
|
||||
if (data.overlays and data.overlays[id]) then
|
||||
return unpack(data.overlays[id]);
|
||||
end
|
||||
return 1, 1, 1, 1;
|
||||
end,
|
||||
set = function(info, r, g, b, a)
|
||||
if (not data.overlays) then
|
||||
data.overlays = {};
|
||||
end
|
||||
data.overlays[id] = { r, g, b, a};
|
||||
WeakAuras.Add(data);
|
||||
end
|
||||
}
|
||||
index = index + 0.01
|
||||
end
|
||||
|
||||
options["overlayclip"] = {
|
||||
type = "toggle",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Clip Overlays"],
|
||||
order = index
|
||||
}
|
||||
end
|
||||
|
||||
return {
|
||||
progresstexture = options,
|
||||
position = WeakAuras.PositionOptions(id, data),
|
||||
};
|
||||
end
|
||||
|
||||
-- Credit to CommanderSirow for taking the time to properly craft the ApplyTransform function
|
||||
-- to the enhance the abilities of Progress Textures.
|
||||
|
||||
-- NOTES:
|
||||
-- Most SetValue() changes are quite equal (among compress/non-compress)
|
||||
-- (There is no GUI button for mirror_v, but mirror_h)
|
||||
-- New/Used variables
|
||||
-- region.user_x (0) - User defined center x-shift [-1, 1]
|
||||
-- region.user_y (0) - User defined center y-shift [-1, 1]
|
||||
-- region.mirror_v (false) - Mirroring along x-axis [bool]
|
||||
-- region.mirror_h (false) - Mirroring along y-axis [bool]
|
||||
-- region.cos_rotation (1) - cos(ANGLE), precalculated cos-function for given ANGLE [-1, 1]
|
||||
-- region.sin_rotation (0) - sin(ANGLE), precalculated cos-function for given ANGLE [-1, 1]
|
||||
-- region.scale (1.0) - user defined scaling [1, INF]
|
||||
-- region.full_rotation (false) - Allow full rotation [bool]
|
||||
|
||||
|
||||
local function ApplyTransform(x, y, region)
|
||||
-- 1) Translate texture-coords to user-defined center
|
||||
x = x - 0.5
|
||||
y = y - 0.5
|
||||
|
||||
-- 2) Shrink texture by 1/sqrt(2)
|
||||
x = x * 1.4142
|
||||
y = y * 1.4142
|
||||
|
||||
-- 3) Scale texture by user-defined amount
|
||||
x = x / region.scale_x
|
||||
y = y / region.scale_y
|
||||
|
||||
-- 4) Apply mirroring if defined
|
||||
if region.mirror_h then
|
||||
x = -x
|
||||
end
|
||||
if region.mirror_v then
|
||||
y = -y
|
||||
end
|
||||
|
||||
-- 5) Rotate texture by user-defined value
|
||||
--[[local x_tmp = region.cos_rotation * x - region.sin_rotation * y
|
||||
local y_tmp = region.sin_rotation * x + region.cos_rotation * y
|
||||
x = x_tmp
|
||||
y = y_tmp]]
|
||||
x, y = region.cos_rotation * x - region.sin_rotation * y, region.sin_rotation * x + region.cos_rotation * y
|
||||
|
||||
-- 6) Translate texture-coords back to (0,0)
|
||||
x = x + 0.5 + region.user_x
|
||||
y = y + 0.5 + region.user_y
|
||||
|
||||
-- Return results
|
||||
return x, y
|
||||
end
|
||||
|
||||
local function Transform(tx, x, y, angle, aspect) -- Translates texture to x, y and rotates about its center
|
||||
local c, s = cos(angle), sin(angle)
|
||||
y = y / aspect
|
||||
local oy = 0.5 / aspect
|
||||
local ULx, ULy = 0.5 + (x - 0.5) * c - (y - oy) * s, (oy + (y - oy) * c + (x - 0.5) * s) * aspect
|
||||
local LLx, LLy = 0.5 + (x - 0.5) * c - (y + oy) * s, (oy + (y + oy) * c + (x - 0.5) * s) * aspect
|
||||
local URx, URy = 0.5 + (x + 0.5) * c - (y - oy) * s, (oy + (y - oy) * c + (x + 0.5) * s) * aspect
|
||||
local LRx, LRy = 0.5 + (x + 0.5) * c - (y + oy) * s, (oy + (y + oy) * c + (x + 0.5) * s) * aspect
|
||||
tx:SetTexCoord(ULx, ULy, LLx, LLy, URx, URy, LRx, LRy)
|
||||
end
|
||||
|
||||
local function createThumbnail()
|
||||
local borderframe = CreateFrame("FRAME", nil, UIParent);
|
||||
borderframe:SetWidth(32);
|
||||
borderframe:SetHeight(32);
|
||||
|
||||
local border = borderframe:CreateTexture(nil, "OVERLAY");
|
||||
border:SetAllPoints(borderframe);
|
||||
border:SetTexture("Interface\\BUTTONS\\UI-Quickslot2.blp");
|
||||
border:SetTexCoord(0.2, 0.8, 0.2, 0.8);
|
||||
|
||||
local region = CreateFrame("FRAME", nil, borderframe);
|
||||
borderframe.region = region;
|
||||
region:SetWidth(32);
|
||||
region:SetHeight(32);
|
||||
|
||||
local background = region:CreateTexture(nil, "BACKGROUND");
|
||||
borderframe.background = background;
|
||||
|
||||
local foreground = region:CreateTexture(nil, "ART");
|
||||
borderframe.foreground = foreground;
|
||||
|
||||
local OrgSetTexture = foreground.SetTexture;
|
||||
-- WORKAROUND, setting the same texture with a different wrap mode does not change the wrap mode
|
||||
foreground.SetTexture = function(self, texture, horWrapMode, verWrapMode)
|
||||
local needToClear = (self.horWrapMode and self.horWrapMode ~= horWrapMode) or (self.verWrapMode and self.verWrapMode ~= verWrapMode);
|
||||
self.horWrapMode = horWrapMode;
|
||||
self.verWrapMode = verWrapMode;
|
||||
if (needToClear) then
|
||||
OrgSetTexture(self, nil);
|
||||
end
|
||||
OrgSetTexture(self, texture, horWrapMode, verWrapMode);
|
||||
end
|
||||
background.SetTexture = foreground.SetTexture;
|
||||
|
||||
borderframe.backgroundSpinner = WeakAuras.createSpinner(region, "BACKGROUND", 1);
|
||||
borderframe.foregroundSpinner = WeakAuras.createSpinner(region, "ARTWORK", 1);
|
||||
|
||||
return borderframe;
|
||||
end
|
||||
|
||||
local function modifyThumbnail(parent, borderframe, data, fullModify, size)
|
||||
local region, background, foreground = borderframe.region, borderframe.background, borderframe.foreground;
|
||||
local foregroundSpinner, backgroundSpinner = borderframe.foregroundSpinner, borderframe.backgroundSpinner;
|
||||
|
||||
size = size or 30;
|
||||
local scale;
|
||||
if(data.height > data.width) then
|
||||
scale = size/data.height;
|
||||
region:SetWidth(scale * data.width);
|
||||
region:SetHeight(size);
|
||||
foreground:SetWidth(scale * data.width);
|
||||
foreground:SetHeight(size);
|
||||
foregroundSpinner:SetWidth(scale * data.width);
|
||||
foregroundSpinner:SetHeight(size);
|
||||
backgroundSpinner:SetWidth(scale * data.width)
|
||||
backgroundSpinner:SetHeight(size);
|
||||
region.width = scale * data.width;
|
||||
region.height = size;
|
||||
else
|
||||
scale = size/data.width;
|
||||
region:SetWidth(size);
|
||||
region:SetHeight(scale * data.height);
|
||||
foreground:SetWidth(size);
|
||||
foreground:SetHeight(scale * data.height);
|
||||
foregroundSpinner:SetWidth(size);
|
||||
foregroundSpinner:SetHeight(scale * data.height);
|
||||
backgroundSpinner:SetWidth(size)
|
||||
backgroundSpinner:SetHeight(scale * data.height);
|
||||
region.width = size;
|
||||
region.height = scale * data.height;
|
||||
end
|
||||
|
||||
region:ClearAllPoints();
|
||||
region:SetPoint("CENTER", borderframe, "CENTER");
|
||||
|
||||
background:SetTexture(data.sameTexture and data.foregroundTexture or data.backgroundTexture);
|
||||
background:SetDesaturated(data.desaturateBackground)
|
||||
background:SetVertexColor(data.backgroundColor[1], data.backgroundColor[2], data.backgroundColor[3], data.backgroundColor[4]);
|
||||
background:SetBlendMode(data.blendMode);
|
||||
|
||||
backgroundSpinner:SetTexture(data.sameTexture and data.foregroundTexture or data.backgroundTexture);
|
||||
backgroundSpinner:SetDesaturated(data.desaturateBackground)
|
||||
backgroundSpinner:Color(data.backgroundColor[1], data.backgroundColor[2], data.backgroundColor[3], data.backgroundColor[4]);
|
||||
backgroundSpinner:SetBlendMode(data.blendMode);
|
||||
|
||||
foreground:SetTexture(data.foregroundTexture);
|
||||
foreground:SetVertexColor(data.foregroundColor[1], data.foregroundColor[2], data.foregroundColor[3], data.foregroundColor[4]);
|
||||
foreground:SetBlendMode(data.blendMode);
|
||||
|
||||
foregroundSpinner:SetTexture(data.foregroundTexture);
|
||||
foregroundSpinner:SetDesaturated(data.desaturateForeground);
|
||||
foregroundSpinner:Color(data.foregroundColor[1], data.foregroundColor[2], data.foregroundColor[3], data.foregroundColor[4])
|
||||
foregroundSpinner:SetBlendMode(data.blendMode);
|
||||
|
||||
background:ClearAllPoints();
|
||||
foreground:ClearAllPoints();
|
||||
background:SetPoint("BOTTOMLEFT", region, "BOTTOMLEFT");
|
||||
background:SetPoint("TOPRIGHT", region, "TOPRIGHT");
|
||||
|
||||
region.mirror_h = data.mirror;
|
||||
region.scale_x = 1 + (data.crop_x or 0.41);
|
||||
region.scale_y = 1 + (data.crop_y or 0.41);
|
||||
region.rotation = data.rotation or 0;
|
||||
region.cos_rotation = cos(region.rotation);
|
||||
region.sin_rotation = sin(region.rotation);
|
||||
region.user_x = -1 * (data.user_x or 0);
|
||||
region.user_y = data.user_y or 0;
|
||||
region.aspect = 1;
|
||||
|
||||
local function orientHorizontal()
|
||||
foreground:ClearAllPoints();
|
||||
foreground:SetPoint("LEFT", region, "LEFT");
|
||||
region.orientation = "HORIZONTAL_INVERSE";
|
||||
if(data.compress) then
|
||||
function region:SetValue(progress)
|
||||
region.progress = progress;
|
||||
|
||||
local ULx, ULy = ApplyTransform(0, 0, region)
|
||||
local LLx, LLy = ApplyTransform(0, 1, region)
|
||||
local URx, URy = ApplyTransform(1, 0, region)
|
||||
local LRx, LRy = ApplyTransform(1, 1, region)
|
||||
|
||||
foreground:SetTexCoord(ULx, ULy, LLx, LLy, URx, URy, LRx, LRy);
|
||||
foreground:SetWidth(region:GetWidth() * progress);
|
||||
background:SetTexCoord(ULx, ULy, LLx, LLy, URx, URy, LRx, LRy);
|
||||
end
|
||||
else
|
||||
function region:SetValue(progress)
|
||||
region.progress = progress;
|
||||
|
||||
local ULx , ULy = ApplyTransform(0, 0, region)
|
||||
local LLx , LLy = ApplyTransform(0, 1, region)
|
||||
local URx , URy = ApplyTransform(progress, 0, region)
|
||||
local URx_, URy_ = ApplyTransform(1, 0, region)
|
||||
local LRx , LRy = ApplyTransform(progress, 1, region)
|
||||
local LRx_, LRy_ = ApplyTransform(1, 1, region)
|
||||
|
||||
foreground:SetTexCoord(ULx, ULy, LLx, LLy, URx , URy , LRx , LRy );
|
||||
foreground:SetWidth(region:GetWidth() * progress);
|
||||
background:SetTexCoord(ULx, ULy, LLx, LLy, URx_, URy_, LRx_, LRy_);
|
||||
end
|
||||
end
|
||||
end
|
||||
local function orientHorizontalInverse()
|
||||
foreground:ClearAllPoints();
|
||||
foreground:SetPoint("RIGHT", region, "RIGHT");
|
||||
region.orientation = "HORIZONTAL";
|
||||
if(data.compress) then
|
||||
function region:SetValue(progress)
|
||||
region.progress = progress;
|
||||
|
||||
local ULx, ULy = ApplyTransform(0, 0, region)
|
||||
local LLx, LLy = ApplyTransform(0, 1, region)
|
||||
local URx, URy = ApplyTransform(1, 0, region)
|
||||
local LRx, LRy = ApplyTransform(1, 1, region)
|
||||
|
||||
foreground:SetTexCoord(ULx, ULy, LLx, LLy, URx, URy, LRx, LRy);
|
||||
foreground:SetWidth(region:GetWidth() * progress);
|
||||
background:SetTexCoord(ULx, ULy, LLx, LLy, URx, URy, LRx, LRy);
|
||||
end
|
||||
else
|
||||
function region:SetValue(progress)
|
||||
region.progress = progress;
|
||||
|
||||
local ULx , ULy = ApplyTransform(1-progress, 0, region)
|
||||
local ULx_, ULy_ = ApplyTransform(0, 0, region)
|
||||
local LLx , LLy = ApplyTransform(1-progress, 1, region)
|
||||
local LLx_, LLy_ = ApplyTransform(0, 1, region)
|
||||
local URx , URy = ApplyTransform(1, 0, region)
|
||||
local LRx , LRy = ApplyTransform(1, 1, region)
|
||||
|
||||
foreground:SetTexCoord(ULx , ULy , LLx , LLy , URx, URy, LRx, LRy);
|
||||
foreground:SetWidth(region:GetWidth() * progress);
|
||||
background:SetTexCoord(ULx_, ULy_, LLx_, LLy_, URx, URy, LRx, LRy);
|
||||
end
|
||||
end
|
||||
end
|
||||
local function orientVertical()
|
||||
foreground:ClearAllPoints();
|
||||
foreground:SetPoint("BOTTOM", region, "BOTTOM");
|
||||
region.orientation = "VERTICAL_INVERSE";
|
||||
if(data.compress) then
|
||||
function region:SetValue(progress)
|
||||
region.progress = progress;
|
||||
|
||||
|
||||
local ULx, ULy = ApplyTransform(0, 0, region)
|
||||
local LLx, LLy = ApplyTransform(0, 1, region)
|
||||
local URx, URy = ApplyTransform(1, 0, region)
|
||||
local LRx, LRy = ApplyTransform(1, 1, region)
|
||||
|
||||
foreground:SetTexCoord(ULx, ULy, LLx, LLy, URx, URy, LRx, LRy);
|
||||
foreground:SetHeight(region:GetHeight() * progress);
|
||||
background:SetTexCoord(ULx, ULy, LLx, LLy, URx, URy, LRx, LRy);
|
||||
end
|
||||
else
|
||||
function region:SetValue(progress)
|
||||
region.progress = progress;
|
||||
|
||||
local ULx , ULy = ApplyTransform(0, 1-progress, region)
|
||||
local ULx_, ULy_ = ApplyTransform(0, 0, region)
|
||||
local LLx , LLy = ApplyTransform(0, 1, region)
|
||||
local URx , URy = ApplyTransform(1, 1-progress, region)
|
||||
local URx_, URy_ = ApplyTransform(1, 0, region)
|
||||
local LRx , LRy = ApplyTransform(1, 1, region)
|
||||
|
||||
foreground:SetTexCoord(ULx, ULy, LLx, LLy, URx, URy, LRx, LRy);
|
||||
foreground:SetHeight(region:GetHeight() * progress);
|
||||
background:SetTexCoord(ULx_, ULy_, LLx, LLy, URx_, URy_, LRx, LRy);
|
||||
end
|
||||
end
|
||||
end
|
||||
local function orientVerticalInverse()
|
||||
foreground:ClearAllPoints();
|
||||
foreground:SetPoint("TOP", region, "TOP");
|
||||
region.orientation = "VERTICAL";
|
||||
if(data.compress) then
|
||||
function region:SetValue(progress)
|
||||
region.progress = progress;
|
||||
|
||||
|
||||
local ULx, ULy = ApplyTransform(0, 0, region)
|
||||
local LLx, LLy = ApplyTransform(0, 1, region)
|
||||
local URx, URy = ApplyTransform(1, 0, region)
|
||||
local LRx, LRy = ApplyTransform(1, 1, region)
|
||||
|
||||
foreground:SetTexCoord(ULx, ULy, LLx, LLy, URx, URy, LRx, LRy);
|
||||
foreground:SetHeight(region:GetHeight() * progress);
|
||||
background:SetTexCoord(ULx, ULy, LLx, LLy, URx, URy, LRx, LRy);
|
||||
end
|
||||
else
|
||||
function region:SetValue(progress)
|
||||
region.progress = progress;
|
||||
|
||||
local ULx , ULy = ApplyTransform(0, 0, region)
|
||||
local LLx , LLy = ApplyTransform(0, progress, region)
|
||||
local LLx_, LLy_ = ApplyTransform(0, 1, region)
|
||||
local URx , URy = ApplyTransform(1, 0, region)
|
||||
local LRx , LRy = ApplyTransform(1, progress, region)
|
||||
local LRx_, LRy_ = ApplyTransform(1, 1, region)
|
||||
|
||||
foreground:SetTexCoord(ULx, ULy, LLx, LLy, URx, URy, LRx, LRy);
|
||||
foreground:SetHeight(region:GetHeight() * progress);
|
||||
background:SetTexCoord(ULx, ULy, LLx_, LLy_, URx, URy, LRx_, LRy_);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function orientCircular(clockwise)
|
||||
local startAngle = data.startAngle % 360;
|
||||
local endAngle = data.endAngle % 360;
|
||||
|
||||
if (endAngle <= startAngle) then
|
||||
endAngle = endAngle + 360;
|
||||
end
|
||||
|
||||
backgroundSpinner:SetProgress(region, startAngle, endAngle);
|
||||
foregroundSpinner:SetProgress(region, startAngle, endAngle);
|
||||
|
||||
function region:SetValue(progress)
|
||||
region.progress = progress;
|
||||
|
||||
if (progress < 0) then
|
||||
progress = 0;
|
||||
end
|
||||
|
||||
if (progress > 1) then
|
||||
progress = 1;
|
||||
end
|
||||
|
||||
if (not clockwise) then
|
||||
progress = 1 - progress;
|
||||
end
|
||||
|
||||
local pAngle = (endAngle - startAngle) * progress + startAngle;
|
||||
|
||||
if (clockwise) then
|
||||
foregroundSpinner:SetProgress(region, startAngle, pAngle);
|
||||
else
|
||||
foregroundSpinner:SetProgress(region, pAngle, endAngle);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function showCircularProgress()
|
||||
foreground:Hide();
|
||||
background:Hide();
|
||||
foregroundSpinner:Show();
|
||||
backgroundSpinner:Show();
|
||||
end
|
||||
|
||||
local function hideCircularProgress()
|
||||
foreground:Show();
|
||||
background:Show();
|
||||
foregroundSpinner:Hide();
|
||||
backgroundSpinner:Hide();
|
||||
end
|
||||
|
||||
if(data.orientation == "HORIZONTAL_INVERSE") then
|
||||
hideCircularProgress();
|
||||
orientHorizontalInverse();
|
||||
elseif(data.orientation == "HORIZONTAL") then
|
||||
hideCircularProgress();
|
||||
orientHorizontal();
|
||||
elseif(data.orientation == "VERTICAL_INVERSE") then
|
||||
hideCircularProgress();
|
||||
orientVerticalInverse();
|
||||
elseif(data.orientation == "VERTICAL") then
|
||||
hideCircularProgress();
|
||||
orientVertical();
|
||||
elseif(data.orientation == "CLOCKWISE") then
|
||||
showCircularProgress();
|
||||
orientCircular(true);
|
||||
elseif(data.orientation == "ANTICLOCKWISE") then
|
||||
showCircularProgress();
|
||||
orientCircular(false);
|
||||
end
|
||||
|
||||
if (region.SetValue) then
|
||||
region:SetValue(3/5);
|
||||
end
|
||||
end
|
||||
|
||||
local function createIcon()
|
||||
local data = {
|
||||
foregroundTexture = "Interface\\Addons\\WeakAuras\\PowerAurasMedia\\Auras\\Aura3",
|
||||
backgroundTexture = "Interface\\Addons\\WeakAuras\\PowerAurasMedia\\Auras\\Aura3",
|
||||
sameTexture = true,
|
||||
backgroundOffset = 2,
|
||||
blendMode = "BLEND",
|
||||
width = 200,
|
||||
height = 200,
|
||||
orientation = "VERTICAL",
|
||||
alpha = 1.0,
|
||||
foregroundColor = {1, 1, 1, 1},
|
||||
backgroundColor = {0.5, 0.5, 0.5, 0.5}
|
||||
};
|
||||
|
||||
local thumbnail = createThumbnail(UIParent);
|
||||
modifyThumbnail(UIParent, thumbnail, data, nil, 32);
|
||||
|
||||
thumbnail.elapsed = 0;
|
||||
thumbnail:SetScript("OnUpdate", function(self, elapsed)
|
||||
thumbnail.elapsed = thumbnail.elapsed + elapsed;
|
||||
if(thumbnail.elapsed > 4) then
|
||||
thumbnail.elapsed = thumbnail.elapsed - 4;
|
||||
end
|
||||
thumbnail.region:SetValue((4 - thumbnail.elapsed) / 4);
|
||||
end);
|
||||
|
||||
return thumbnail;
|
||||
end
|
||||
|
||||
local templates = {
|
||||
{
|
||||
title = L["Default"],
|
||||
data = {
|
||||
inverse = true,
|
||||
};
|
||||
},
|
||||
{
|
||||
title = L["Top HUD position"],
|
||||
description = L["At the same position as Blizzard's spell alert"],
|
||||
data = {
|
||||
width = 200,
|
||||
height = 100,
|
||||
xOffset = 0,
|
||||
yOffset = 150,
|
||||
mirror = true,
|
||||
foregroundTexture = "Textures\\SpellActivationOverlays\\Backlash",
|
||||
orientation = "HORIZONTAL",
|
||||
inverse = true,
|
||||
},
|
||||
},
|
||||
{
|
||||
title = L["Left HUD position"],
|
||||
description = L["At the same position as Blizzard's spell alert"],
|
||||
data = {
|
||||
width = 100,
|
||||
height = 200,
|
||||
xOffset = -150,
|
||||
yOffset = 0,
|
||||
inverse = true,
|
||||
},
|
||||
},
|
||||
{
|
||||
title = L["Left 2 HUD position"],
|
||||
description = L["At a position a bit left of Left HUD position."],
|
||||
data = {
|
||||
width = 100,
|
||||
height = 200,
|
||||
xOffset = -200,
|
||||
yOffset = 0,
|
||||
inverse = true,
|
||||
},
|
||||
},
|
||||
{
|
||||
title = L["Right HUD position"],
|
||||
description = L["At the same position as Blizzard's spell alert"],
|
||||
data = {
|
||||
width = 100,
|
||||
height = 200,
|
||||
xOffset = 150,
|
||||
yOffset = 0,
|
||||
mirror = true,
|
||||
inverse = true,
|
||||
},
|
||||
},
|
||||
{
|
||||
title = L["Right 2 HUD position"],
|
||||
description = L["At a position a bit left of Right HUD position"],
|
||||
data = {
|
||||
width = 100,
|
||||
height = 200,
|
||||
xOffset = 200,
|
||||
yOffset = 0,
|
||||
mirror = true,
|
||||
inverse = true,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
local function GetAnchors(data)
|
||||
return WeakAuras.default_types_for_anchor
|
||||
end
|
||||
|
||||
WeakAuras.RegisterRegionOptions("progresstexture", createOptions, createIcon, L["Progress Texture"], createThumbnail, modifyThumbnail, L["Shows a texture that changes based on duration"], templates, GetAnchors);
|
||||
@@ -0,0 +1,387 @@
|
||||
if not WeakAuras.IsCorrectVersion() then return end
|
||||
|
||||
local SharedMedia = LibStub("LibSharedMedia-3.0");
|
||||
local L = WeakAuras.L;
|
||||
|
||||
local screenWidth, screenHeight = math.ceil(GetScreenWidth() / 20) * 20, math.ceil(GetScreenHeight() / 20) * 20;
|
||||
|
||||
local indentWidth = 0.15
|
||||
local hiddenFontExtra = function()
|
||||
return WeakAuras.IsCollapsed("text", "text", "fontflags", true)
|
||||
end
|
||||
|
||||
local function createOptions(id, data)
|
||||
local options = {
|
||||
__title = L["Text Settings"],
|
||||
__order = 1,
|
||||
displayText = {
|
||||
type = "input",
|
||||
width = WeakAuras.doubleWidth,
|
||||
desc = function()
|
||||
return L["Dynamic text tooltip"] .. WeakAuras.GetAdditionalProperties(data)
|
||||
end,
|
||||
multiline = true,
|
||||
name = L["Display Text"],
|
||||
order = 10,
|
||||
get = function()
|
||||
return data.displayText;
|
||||
end,
|
||||
set = function(info, v)
|
||||
data.displayText = WeakAuras.ReplaceLocalizedRaidMarkers(v);
|
||||
WeakAuras.Add(data);
|
||||
WeakAuras.UpdateThumbnail(data);
|
||||
WeakAuras.SetIconNames(data);
|
||||
WeakAuras.ResetMoverSizer();
|
||||
end
|
||||
},
|
||||
customTextUpdate = {
|
||||
type = "select",
|
||||
width = WeakAuras.doubleWidth,
|
||||
hidden = function() return not WeakAuras.ContainsCustomPlaceHolder(data.displayText); end,
|
||||
name = L["Update Custom Text On..."],
|
||||
values = WeakAuras.text_check_types,
|
||||
order = 36
|
||||
},
|
||||
-- code editor added below
|
||||
progressPrecision = {
|
||||
type = "select",
|
||||
width = WeakAuras.normalWidth,
|
||||
order = 39,
|
||||
name = L["Remaining Time Precision"],
|
||||
values = WeakAuras.precision_types,
|
||||
get = function() return data.progressPrecision or 1 end,
|
||||
hidden = function() return not (WeakAuras.ContainsPlaceHolders(data.displayText, "pt"));
|
||||
end,
|
||||
disabled = function()
|
||||
return not WeakAuras.ContainsPlaceHolders(data.displayText, "p");
|
||||
end
|
||||
},
|
||||
totalPrecision = {
|
||||
type = "select",
|
||||
width = WeakAuras.normalWidth,
|
||||
order = 39.5,
|
||||
name = L["Total Time Precision"],
|
||||
values = WeakAuras.precision_types,
|
||||
get = function() return data.totalPrecision or 1 end,
|
||||
hidden = function()
|
||||
return not (WeakAuras.ContainsPlaceHolders(data.displayText, "pt"));
|
||||
end,
|
||||
disabled = function()
|
||||
return not WeakAuras.ContainsPlaceHolders(data.displayText, "t");
|
||||
end
|
||||
},
|
||||
|
||||
font = {
|
||||
type = "select",
|
||||
width = WeakAuras.normalWidth,
|
||||
dialogControl = "LSM30_Font",
|
||||
name = L["Font"],
|
||||
order = 45,
|
||||
values = AceGUIWidgetLSMlists.font
|
||||
},
|
||||
fontSize = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Size"],
|
||||
order = 46,
|
||||
min = 6,
|
||||
softMax = 72,
|
||||
step = 1
|
||||
},
|
||||
color = {
|
||||
type = "color",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Text Color"],
|
||||
hasAlpha = true,
|
||||
order = 47
|
||||
},
|
||||
|
||||
fontFlagsDescription = {
|
||||
order = 48,
|
||||
width = WeakAuras.doubleWidth,
|
||||
type = "execute",
|
||||
control = "WeakAurasExpandSmall",
|
||||
name = function()
|
||||
local textFlags = WeakAuras.font_flags[data.outline]
|
||||
local color = format("%02x%02x%02x%02x",
|
||||
data.shadowColor[4] * 255, data.shadowColor[1] * 255,
|
||||
data.shadowColor[2] * 255, data.shadowColor[3]*255)
|
||||
|
||||
local textJustify = ""
|
||||
if data.justify == "CENTER" then
|
||||
|
||||
elseif data.justify == "LEFT" then
|
||||
textJustify = " " .. L["and aligned left"]
|
||||
elseif data.justify == "RIGHT" then
|
||||
textJustify = " " .. L["and aligned right"]
|
||||
end
|
||||
|
||||
local textWidth = ""
|
||||
if data.automaticWidth == "Fixed" then
|
||||
local wordWarp = ""
|
||||
if data.wordWrap == "WordWrap" then
|
||||
wordWarp = L["wrapping"]
|
||||
else
|
||||
wordWarp = L["eliding"]
|
||||
end
|
||||
textWidth = " "..L["and with width |cFFFF0000%s|r and %s"]:format(data.fixedWidth, wordWarp)
|
||||
end
|
||||
|
||||
local secondline = L["|cFFffcc00Font Flags:|r |cFFFF0000%s|r and shadow |c%sColor|r with offset |cFFFF0000%s/%s|r%s%s"]:format(textFlags, color, data.shadowXOffset, data.shadowYOffset, textJustify, textWidth)
|
||||
|
||||
return secondline
|
||||
end,
|
||||
func = function()
|
||||
local collapsed = WeakAuras.IsCollapsed("text", "text", "fontflags", true)
|
||||
WeakAuras.SetCollapsed("text", "text", "fontflags", not collapsed)
|
||||
end,
|
||||
image = function()
|
||||
local collapsed = WeakAuras.IsCollapsed("text", "text", "fontflags", true)
|
||||
return collapsed and "Interface\\AddOns\\WeakAuras\\Media\\Textures\\edit" or "Interface\\AddOns\\WeakAuras\\Media\\Textures\\editdown"
|
||||
end,
|
||||
imageWidth = 24,
|
||||
imageHeight = 24
|
||||
},
|
||||
|
||||
text_font_space = {
|
||||
type = "description",
|
||||
name = "",
|
||||
order = 48.1,
|
||||
hidden = hiddenFontExtra,
|
||||
width = indentWidth
|
||||
},
|
||||
outline = {
|
||||
type = "select",
|
||||
width = WeakAuras.normalWidth - indentWidth,
|
||||
name = L["Outline"],
|
||||
order = 48.2,
|
||||
values = WeakAuras.font_flags,
|
||||
hidden = hiddenFontExtra
|
||||
},
|
||||
shadowColor = {
|
||||
type = "color",
|
||||
hasAlpha = true,
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Shadow Color"],
|
||||
order = 48.3,
|
||||
hidden = hiddenFontExtra
|
||||
},
|
||||
|
||||
text_font_space3 = {
|
||||
type = "description",
|
||||
name = "",
|
||||
order = 48.4,
|
||||
hidden = hiddenFontExtra,
|
||||
width = indentWidth
|
||||
},
|
||||
shadowXOffset = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth - indentWidth,
|
||||
name = L["Shadow X Offset"],
|
||||
softMin = -15,
|
||||
softMax = 15,
|
||||
bigStep = 1,
|
||||
order = 48.5,
|
||||
hidden = hiddenFontExtra
|
||||
},
|
||||
shadowYOffset = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Shadow Y Offset"],
|
||||
softMin = -15,
|
||||
softMax = 15,
|
||||
bigStep = 1,
|
||||
order = 48.6,
|
||||
hidden = hiddenFontExtra
|
||||
},
|
||||
|
||||
text_font_space4 = {
|
||||
type = "description",
|
||||
name = "",
|
||||
order = 48.7,
|
||||
hidden = hiddenFontExtra,
|
||||
width = indentWidth
|
||||
},
|
||||
justify = {
|
||||
type = "select",
|
||||
width = WeakAuras.normalWidth - indentWidth,
|
||||
name = L["Justify"],
|
||||
order = 48.8,
|
||||
values = WeakAuras.justify_types,
|
||||
hidden = hiddenFontExtra,
|
||||
},
|
||||
text_font_space55 = {
|
||||
type = "description",
|
||||
name = "",
|
||||
order = 48.85,
|
||||
hidden = hiddenFontExtra,
|
||||
width = WeakAuras.normalWidth
|
||||
},
|
||||
|
||||
text_font_space5 = {
|
||||
type = "description",
|
||||
name = "",
|
||||
order = 48.9,
|
||||
hidden = hiddenFontExtra,
|
||||
width = indentWidth
|
||||
},
|
||||
automaticWidth = {
|
||||
type = "select",
|
||||
width = WeakAuras.normalWidth - indentWidth,
|
||||
name = L["Width"],
|
||||
order = 49,
|
||||
values = WeakAuras.text_automatic_width,
|
||||
hidden = hiddenFontExtra,
|
||||
},
|
||||
fixedWidth = {
|
||||
name = L["Width"],
|
||||
width = WeakAuras.normalWidth,
|
||||
order = 49.1,
|
||||
type = "range",
|
||||
min = 1,
|
||||
softMax = screenWidth,
|
||||
bigStep = 1,
|
||||
hidden = function() return hiddenFontExtra() or data.automaticWidth ~= "Fixed" end
|
||||
},
|
||||
text_font_space7 = {
|
||||
type = "description",
|
||||
name = "",
|
||||
order = 49.3,
|
||||
width = indentWidth,
|
||||
hidden = function() return hiddenFontExtra() or data.automaticWidth ~= "Fixed" end
|
||||
},
|
||||
wordWrap = {
|
||||
type = "select",
|
||||
width = WeakAuras.normalWidth - indentWidth,
|
||||
name = L["Overflow"],
|
||||
order = 49.4,
|
||||
values = WeakAuras.text_word_wrap,
|
||||
hidden = function() return hiddenFontExtra() or data.automaticWidth ~= "Fixed" end
|
||||
},
|
||||
|
||||
endHeader = {
|
||||
type = "header",
|
||||
order = 100,
|
||||
name = "",
|
||||
},
|
||||
};
|
||||
|
||||
WeakAuras.AddCodeOption(options, data, L["Custom Function"], "customText", "https://github.com/WeakAuras/WeakAuras2/wiki/Text-Replacements",
|
||||
37, function() return not WeakAuras.ContainsCustomPlaceHolder(data.displayText) end, {"customText"}, false);
|
||||
|
||||
return {
|
||||
text = options;
|
||||
position = WeakAuras.PositionOptions(id, data, nil, true);
|
||||
};
|
||||
end
|
||||
|
||||
local function createThumbnail()
|
||||
local borderframe = CreateFrame("FRAME", nil, UIParent);
|
||||
borderframe:SetWidth(32);
|
||||
borderframe:SetHeight(32);
|
||||
|
||||
local border = borderframe:CreateTexture(nil, "OVERLAY");
|
||||
border:SetAllPoints(borderframe);
|
||||
border:SetTexture("Interface\\BUTTONS\\UI-Quickslot2.blp");
|
||||
border:SetTexCoord(0.2, 0.8, 0.2, 0.8);
|
||||
|
||||
local mask = CreateFrame("ScrollFrame", nil, borderframe);
|
||||
borderframe.mask = mask;
|
||||
mask:SetPoint("BOTTOMLEFT", borderframe, "BOTTOMLEFT", 2, 2);
|
||||
mask:SetPoint("TOPRIGHT", borderframe, "TOPRIGHT", -2, -2);
|
||||
|
||||
local content = CreateFrame("Frame", nil, mask);
|
||||
borderframe.content = content;
|
||||
content:SetPoint("CENTER", mask, "CENTER");
|
||||
mask:SetScrollChild(content);
|
||||
|
||||
local text = content:CreateFontString(nil, "OVERLAY");
|
||||
borderframe.text = text;
|
||||
text:SetNonSpaceWrap(true);
|
||||
|
||||
borderframe.values = {};
|
||||
|
||||
return borderframe;
|
||||
end
|
||||
|
||||
local function modifyThumbnail(parent, borderframe, data, fullModify, size)
|
||||
local mask, content, text = borderframe.mask, borderframe.content, borderframe.text;
|
||||
|
||||
size = size or 28;
|
||||
|
||||
local fontPath = SharedMedia:Fetch("font", data.font) or data.font;
|
||||
text:SetFont(fontPath, data.fontSize, data.outline and "OUTLINE" or nil);
|
||||
text:SetTextHeight(data.fontSize);
|
||||
text:SetText(data.displayText);
|
||||
text:SetTextColor(data.color[1], data.color[2], data.color[3], data.color[4]);
|
||||
text:SetJustifyH(data.justify);
|
||||
|
||||
text:ClearAllPoints();
|
||||
text:SetPoint("CENTER", UIParent, "CENTER");
|
||||
content:SetWidth(math.max(text:GetStringWidth(), size));
|
||||
content:SetHeight(math.max(text:GetStringHeight(), size));
|
||||
text:ClearAllPoints();
|
||||
text:SetPoint("CENTER", content, "CENTER");
|
||||
|
||||
local function rescroll()
|
||||
content:SetWidth(math.max(text:GetStringWidth(), size));
|
||||
content:SetHeight(math.max(text:GetStringHeight(), size));
|
||||
local xo = 0;
|
||||
if(data.justify == "CENTER") then
|
||||
xo = mask:GetHorizontalScrollRange() / 2;
|
||||
elseif(data.justify == "RIGHT") then
|
||||
xo = mask:GetHorizontalScrollRange();
|
||||
end
|
||||
mask:SetHorizontalScroll(xo);
|
||||
mask:SetVerticalScroll(mask:GetVerticalScrollRange() / 2);
|
||||
end
|
||||
|
||||
rescroll();
|
||||
mask:SetScript("OnScrollRangeChanged", rescroll);
|
||||
|
||||
local function UpdateText()
|
||||
local textStr = data.displayText;
|
||||
textStr = WeakAuras.ReplacePlaceHolders(textStr, borderframe);
|
||||
text:SetText(textStr);
|
||||
rescroll();
|
||||
end
|
||||
|
||||
function borderframe:SetIcon(path)
|
||||
UpdateText();
|
||||
end
|
||||
|
||||
function borderframe:SetName(name)
|
||||
UpdateText();
|
||||
end
|
||||
|
||||
UpdateText();
|
||||
end
|
||||
|
||||
local function createIcon()
|
||||
local data = {
|
||||
outline = true,
|
||||
color = {1, 1, 0, 1},
|
||||
justify = "CENTER",
|
||||
font = "Friz Quadrata TT",
|
||||
fontSize = 12,
|
||||
displayText = "World\nof\nWarcraft";
|
||||
};
|
||||
|
||||
local thumbnail = createThumbnail(UIParent);
|
||||
modifyThumbnail(UIParent, thumbnail, data);
|
||||
thumbnail.mask:SetPoint("BOTTOMLEFT", thumbnail, "BOTTOMLEFT", 3, 3);
|
||||
thumbnail.mask:SetPoint("TOPRIGHT", thumbnail, "TOPRIGHT", -3, -3);
|
||||
|
||||
return thumbnail;
|
||||
end
|
||||
|
||||
local templates = {
|
||||
{
|
||||
title = L["Default"],
|
||||
description = L["Displays a text, works best in combination with other displays"],
|
||||
data = {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
WeakAuras.RegisterRegionOptions("text", createOptions, createIcon, L["Text"], createThumbnail, modifyThumbnail, L["Shows one or more lines of text, which can include dynamic information such as progress or stacks"], templates);
|
||||
@@ -0,0 +1,235 @@
|
||||
if not WeakAuras.IsCorrectVersion() then return end
|
||||
|
||||
local L = WeakAuras.L
|
||||
|
||||
local function createOptions(id, data)
|
||||
local options = {
|
||||
__title = L["Texture Settings"],
|
||||
__order = 1,
|
||||
texture = {
|
||||
type = "input",
|
||||
width = WeakAuras.doubleWidth,
|
||||
name = L["Texture"],
|
||||
order = 1
|
||||
},
|
||||
desaturate = {
|
||||
type = "toggle",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Desaturate"],
|
||||
order = 2,
|
||||
},
|
||||
space2 = {
|
||||
type = "execute",
|
||||
name = "",
|
||||
width = WeakAuras.halfWidth,
|
||||
order = 5,
|
||||
image = function() return "", 0, 0 end,
|
||||
},
|
||||
chooseTexture = {
|
||||
type = "execute",
|
||||
name = L["Choose"],
|
||||
width = WeakAuras.halfWidth,
|
||||
order = 7,
|
||||
func = function()
|
||||
WeakAuras.OpenTexturePicker(data, "texture", WeakAuras.texture_types);
|
||||
end
|
||||
},
|
||||
color = {
|
||||
type = "color",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Color"],
|
||||
hasAlpha = true,
|
||||
order = 10
|
||||
},
|
||||
blendMode = {
|
||||
type = "select",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Blend Mode"],
|
||||
order = 12,
|
||||
values = WeakAuras.blend_types
|
||||
},
|
||||
mirror = {
|
||||
type = "toggle",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Mirror"],
|
||||
order = 20
|
||||
},
|
||||
alpha = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Alpha"],
|
||||
order = 25,
|
||||
min = 0,
|
||||
max = 1,
|
||||
bigStep = 0.01,
|
||||
isPercent = true
|
||||
},
|
||||
rotate = {
|
||||
type = "toggle",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Allow Full Rotation"],
|
||||
order = 30
|
||||
},
|
||||
rotation = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Rotation"],
|
||||
min = 0,
|
||||
max = 360,
|
||||
step = 1,
|
||||
bigStep = 3,
|
||||
order = 35,
|
||||
hidden = function() return not data.rotate end
|
||||
},
|
||||
discrete_rotation = {
|
||||
type = "range",
|
||||
width = WeakAuras.normalWidth,
|
||||
name = L["Discrete Rotation"],
|
||||
min = 0,
|
||||
max = 360,
|
||||
step = 90,
|
||||
order = 35,
|
||||
hidden = function() return data.rotate end
|
||||
},
|
||||
endHeader = {
|
||||
type = "header",
|
||||
order = 100,
|
||||
name = "",
|
||||
},
|
||||
};
|
||||
|
||||
return {
|
||||
texture = options,
|
||||
position = WeakAuras.PositionOptions(id, data),
|
||||
};
|
||||
end
|
||||
|
||||
local function createThumbnail()
|
||||
local borderframe = CreateFrame("FRAME", nil, UIParent);
|
||||
borderframe:SetWidth(32);
|
||||
borderframe:SetHeight(32);
|
||||
|
||||
local border = borderframe:CreateTexture(nil, "OVERLAY");
|
||||
border:SetAllPoints(borderframe);
|
||||
border:SetTexture("Interface\\BUTTONS\\UI-Quickslot2.blp");
|
||||
border:SetTexCoord(0.2, 0.8, 0.2, 0.8);
|
||||
|
||||
local texture = borderframe:CreateTexture();
|
||||
borderframe.texture = texture;
|
||||
texture:SetPoint("CENTER", borderframe, "CENTER");
|
||||
|
||||
return borderframe;
|
||||
end
|
||||
|
||||
local function modifyThumbnail(parent, region, data, fullModify, size)
|
||||
size = size or 30;
|
||||
local scale;
|
||||
if(data.height > data.width) then
|
||||
scale = size/data.height;
|
||||
region.texture:SetWidth(scale * data.width);
|
||||
region.texture:SetHeight(size);
|
||||
else
|
||||
scale = size/data.width;
|
||||
region.texture:SetWidth(size);
|
||||
region.texture:SetHeight(scale * data.height);
|
||||
end
|
||||
|
||||
WeakAuras.SetTexture(region.texture, data.texture);
|
||||
region.texture:SetVertexColor(data.color[1], data.color[2], data.color[3], data.color[4]);
|
||||
region.texture:SetBlendMode(data.blendMode);
|
||||
|
||||
local ulx,uly , llx,lly , urx,ury , lrx,lry;
|
||||
if(data.rotate) then
|
||||
local angle = rad(135 - data.rotation);
|
||||
local vx = math.cos(angle);
|
||||
local vy = math.sin(angle);
|
||||
|
||||
ulx,uly , llx,lly , urx,ury , lrx,lry = 0.5+vx,0.5-vy , 0.5-vy,0.5-vx , 0.5+vy,0.5+vx , 0.5-vx,0.5+vy;
|
||||
else
|
||||
if(data.discrete_rotation == 0 or data.discrete_rotation == 360) then
|
||||
ulx,uly , llx,lly , urx,ury , lrx,lry = 0,0 , 0,1 , 1,0 , 1,1;
|
||||
elseif(data.discrete_rotation == 90) then
|
||||
ulx,uly , llx,lly , urx,ury , lrx,lry = 1,0 , 0,0 , 1,1 , 0,1;
|
||||
elseif(data.discrete_rotation == 180) then
|
||||
ulx,uly , llx,lly , urx,ury , lrx,lry = 1,1 , 1,0 , 0,1 , 0,0;
|
||||
elseif(data.discrete_rotation == 270) then
|
||||
ulx,uly , llx,lly , urx,ury , lrx,lry = 0,1 , 1,1 , 0,0 , 1,0;
|
||||
end
|
||||
end
|
||||
if(data.mirror) then
|
||||
region.texture:SetTexCoord(urx,ury , lrx,lry , ulx,uly , llx,lly);
|
||||
else
|
||||
region.texture:SetTexCoord(ulx,uly , llx,lly , urx,ury , lrx,lry);
|
||||
end
|
||||
end
|
||||
|
||||
local function createIcon()
|
||||
local data = {
|
||||
height = 40,
|
||||
width = 40,
|
||||
texture = "Interface\\Addons\\WeakAuras\\PowerAurasMedia\\Auras\\Aura3",
|
||||
color = {1, 1, 1, 1},
|
||||
blendMode = "ADD",
|
||||
rotate = true;
|
||||
rotation = 0;
|
||||
};
|
||||
|
||||
local thumbnail = createThumbnail(UIParent);
|
||||
modifyThumbnail(UIParent, thumbnail, data, nil, 50);
|
||||
|
||||
return thumbnail;
|
||||
end
|
||||
|
||||
local templates = {
|
||||
{
|
||||
title = L["Default"],
|
||||
data = {
|
||||
};
|
||||
},
|
||||
{
|
||||
title = L["Star"],
|
||||
data = {
|
||||
texture = "Spells\\T_Star3",
|
||||
blendMode = "ADD",
|
||||
width = 200,
|
||||
height = 200,
|
||||
discrete_rotation = 0,
|
||||
}
|
||||
},
|
||||
{
|
||||
title = L["Leaf"],
|
||||
data = {
|
||||
texture = "Spells\\Nature_Rune_128",
|
||||
blendMode = "ADD",
|
||||
width = 200,
|
||||
height = 200,
|
||||
discrete_rotation = 0,
|
||||
}
|
||||
},
|
||||
{
|
||||
title = L["Hawk"],
|
||||
data = {
|
||||
texture = "Spells\\Aspect_Hawk",
|
||||
blendMode = "ADD",
|
||||
width = 200,
|
||||
height = 200,
|
||||
discrete_rotation = 0,
|
||||
}
|
||||
},
|
||||
{
|
||||
title = L["Low Mana"],
|
||||
data = {
|
||||
texture = "Interface\\Addons\\WeakAuras\\PowerAurasMedia\\Auras\\Aura70",
|
||||
blendMode = "ADD",
|
||||
width = 200,
|
||||
height = 200,
|
||||
discrete_rotation = 0,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
local function GetAnchors(data)
|
||||
return WeakAuras.default_types_for_anchor
|
||||
end
|
||||
|
||||
WeakAuras.RegisterRegionOptions("texture", createOptions, createIcon, L["Texture"], createThumbnail, modifyThumbnail, L["Shows a custom texture"], templates, GetAnchors);
|
||||
Reference in New Issue
Block a user