Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

groups 2: dynamic boogaloo #3094

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
861 changes: 407 additions & 454 deletions WeakAuras/RegionTypes/DynamicGroup.lua

Large diffs are not rendered by default.

1,263 changes: 1,263 additions & 0 deletions WeakAuras/RegionTypes/DynamicGroupOld.lua

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions WeakAuras/RegionTypes/RegionPrototype.lua
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ function WeakAuras.regionPrototype.modify(parent, region, data)
region.customAnchorFunc = nil
end

if not parent or parent.regionType ~= "dynamicgroup" then
if not parent or not parent.regionType or not parent.regionType:find("dynamicgroup") then
if
-- Don't anchor single Auras that with custom anchoring,
-- these will be anchored in expand
Expand All @@ -564,8 +564,7 @@ function WeakAuras.regionPrototype.modify(parent, region, data)
)
-- Group Auras that will never be expanded, so those need
-- to be always anchored here
or data.regionType == "dynamicgroup"
or data.regionType == "group"
or data.regionType:find("group")
then
Private.AnchorFrame(data, region, parent);
end
Expand Down Expand Up @@ -731,7 +730,7 @@ end
function WeakAuras.regionPrototype.AddExpandFunction(data, region, cloneId, parent, parentRegionType)
local uid = data.uid
local id = data.id
local inDynamicGroup = parentRegionType == "dynamicgroup";
local inDynamicGroup = parentRegionType and parentRegionType:find("dynamicgroup");
local inGroup = parentRegionType == "group";

local startMainAnimation = function()
Expand Down
2 changes: 1 addition & 1 deletion WeakAuras/Transmission.lua
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ local function importPendingData()
tinsert(parentData.controlledChildren, installedChild.id)
WeakAuras.NewDisplayButton(installedChild)
local childButton = WeakAuras.GetDisplayButton(installedChild.id)
childButton:SetGroup(parentData.id, parentData.regionType == "dynamicgroup")
childButton:SetGroup(parentData.id)
childButton:SetGroupOrder(index, #parentData.controlledChildren)
coroutine.yield()
end
Expand Down
8 changes: 8 additions & 0 deletions WeakAuras/Types.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ Private.group_sort_types = {
custom = L["Custom"]
}

Private.group_distribute_types = {
-- TODO: bikeshed these strings
self = L["None"],
nameplate = L["Nameplate Unit"],
unit = L["Unit Frames"],
custom = L["Custom"],
}

Private.group_hybrid_position_types = {
hybridFirst = L["Marked First"],
hybridLast = L["Marked Last"]
Expand Down
12 changes: 6 additions & 6 deletions WeakAuras/WeakAuras.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2347,12 +2347,12 @@ function WeakAuras.AddMany(table, takeSnapshots)
local groups = {}
for id, data in pairs(idtable) do
load(id, {});
if data.regionType == "dynamicgroup" or data.regionType == "group" then
if data.controlledChildren then
groups[data] = true
end
end
for data in pairs(groups) do
if data.type == "dynamicgroup" then
if data.regionType:find("dynamicgroup", 1, true) then
regions[data.id].region:ReloadControlledChildren()
else
WeakAuras.Add(data)
Expand Down Expand Up @@ -2866,11 +2866,11 @@ function WeakAuras.SetRegion(data, cloneId)
regionType = regionType,
region = region
};
if regionType ~= "dynamicgroup" and regionType ~= "group" then
if data.controlledChildren then
region.toShow = true
else
region.toShow = false
region:Hide()
else
region.toShow = true
end
else
region = regions[id].region;
Expand Down Expand Up @@ -5001,7 +5001,7 @@ local anchorFrameDeferred = {}

function Private.AnchorFrame(data, region, parent)
if data.anchorFrameType == "CUSTOM"
and (data.regionType == "group" or data.regionType == "dynamicgroup")
and data.controlledChildren
and not WeakAuras.IsLoginFinished()
and not anchorFrameDeferred[data.id]
then
Expand Down
1 change: 1 addition & 0 deletions WeakAuras/WeakAuras.toc
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ RegionTypes\Icon.lua
RegionTypes\Text.lua
RegionTypes\Group.lua
RegionTypes\DynamicGroup.lua
RegionTypes\DynamicGroupOld.lua
RegionTypes\StopMotion.lua
RegionTypes\Model.lua

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ local fullName;
local clipboard = {};

local function IsRegionAGroup(data)
return data and (data.regionType == "group" or data.regionType == "dynamicgroup");
return data and data.controlledChildren;
end

local ignoreForCopyingDisplay = {
Expand Down Expand Up @@ -599,7 +599,7 @@ local methods = {
if childData.parent then
childButton:Ungroup();
end
childButton:SetGroup(data.id, data.regionType == "dynamicgroup");
childButton:SetGroup(data.id);
childButton:SetGroupOrder(#data.controlledChildren, #data.controlledChildren);
childData.parent = data.id;
WeakAuras.Add(childData);
Expand All @@ -608,13 +608,13 @@ local methods = {
else
tinsert(data.controlledChildren, self.grouping.id);
local childButton = WeakAuras.GetDisplayButton(self.grouping.id);
childButton:SetGroup(data.id, data.regionType == "dynamicgroup");
childButton:SetGroup(data.id);
childButton:SetGroupOrder(#data.controlledChildren, #data.controlledChildren);
self.grouping.parent = data.id;
WeakAuras.Add(self.grouping);
WeakAuras.ClearAndUpdateOptions(self.grouping.id);
end
if (data.regionType == "dynamicgroup") then
if (data.regionType:find("dynamicgroup", 1, true)) then
self.grouping.xOffset = 0;
self.grouping.yOffset = 0;
end
Expand Down Expand Up @@ -910,7 +910,7 @@ local methods = {
if (not data.controlledChildren) then
local convertMenu = {};
for regionType, regionData in pairs(WeakAuras.regionOptions) do
if(regionType ~= "group" and regionType ~= "dynamicgroup" and regionType ~= "timer" and regionType ~= data.regionType) then
if(regionType ~= data.regionType) then
tinsert(convertMenu, {
text = regionData.displayName,
notCheckable = true,
Expand Down Expand Up @@ -1107,7 +1107,7 @@ local methods = {
self.frame:SetScript("OnClick", self.callbacks.OnClickGroupingSelf);
self:SetDescription(L["Cancel"], L["Do not group this display"]);
else
if(self.data.regionType == "group" or self.data.regionType == "dynamicgroup") then
if(self.data.controlledChildren) then
self.frame:SetScript("OnClick", self.callbacks.OnClickGrouping);
self:SetDescription(self.data.id, L["Add to group %s"]:format(self.data.id));
else
Expand Down Expand Up @@ -1359,7 +1359,7 @@ local methods = {
return self.frame.dgroup;
end,
["IsGroup"] = function(self)
return self.data.regionType == "group" or self.data.regionType == "dynamicgroup"
return self.data.controlledChildren
end,
["SetData"] = function(self, data)
self.data = data;
Expand Down
2 changes: 1 addition & 1 deletion WeakAurasOptions/AnimationOptions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ local function filterAnimPresetTypes(intable, id)
for key, value in pairs(intable) do
local preset = OptionsPrivate.Private.anim_presets[key];
if(preset) then
if(regionType == "group" or regionType == "dynamicgroup") then
if(data.controlledChildren) then
local valid = true;
for index, childId in pairs(data.controlledChildren) do
local childRegion = WeakAuras.regions[childId] and WeakAuras.regions[childId].region
Expand Down
4 changes: 2 additions & 2 deletions WeakAurasOptions/CommonOptions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ local function PositionOptions(id, data, _, hideWidthHeight, disableSelfPoint, g
local function IsParentDynamicGroup()
if data.parent then
local parentData = WeakAuras.GetData(data.parent)
return parentData and parentData.regionType == "dynamicgroup"
return parentData and parentData.regionType:find("dynamicgroup", 1, true)
end
end

Expand Down Expand Up @@ -1065,7 +1065,7 @@ local function PositionOptions(id, data, _, hideWidthHeight, disableSelfPoint, g
name = L["Anchored To"],
order = 72,
hidden = IsParentDynamicGroup,
values = (data.regionType == "group" or data.regionType == "dynamicgroup") and OptionsPrivate.Private.anchor_frame_types_group or OptionsPrivate.Private.anchor_frame_types,
values = data.controlledChildren and OptionsPrivate.Private.anchor_frame_types_group or OptionsPrivate.Private.anchor_frame_types,
},
-- Input field to select frame to anchor on
anchorFrameFrame = {
Expand Down
4 changes: 2 additions & 2 deletions WeakAurasOptions/ExternalAddons.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function OptionsPrivate.CreateImportButtons()
if(data) then
for index, childId in pairs(data.controlledChildren) do
local childButton = WeakAuras.GetDisplayButton(childId);
childButton:SetGroup(groupId, data.regionType == "dynamicgroup");
childButton:SetGroup(groupId);
childButton:SetGroupOrder(index, #data.controlledChildren);
end

Expand Down Expand Up @@ -163,7 +163,7 @@ function OptionsPrivate.CreateImportButtons()
if(data) then
for index, childId in pairs(data.controlledChildren) do
local childButton = WeakAuras.GetDisplayButton(childId);
childButton:SetGroup(id, data.regionType == "dynamicgroup");
childButton:SetGroup(id);
childButton:SetGroupOrder(index, #data.controlledChildren);
end

Expand Down
37 changes: 17 additions & 20 deletions WeakAurasOptions/InformationOptions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -125,27 +125,24 @@ function OptionsPrivate.GetInformationOptions(data)
end
end

-- Show warnings only for single selection for now
if not isGroup then
local icon, title, message = OptionsPrivate.Private.AuraWarnings.FormatWarnings(data.uid)
if title and message then
args.warningTitle = {
type = "header",
name = title,
width = WeakAuras.doubleWidth,
order = order,
}
order = order + 1
local icon, title, messages = OptionsPrivate.Private.AuraWarnings.FormatWarnings(data.uid)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You want a not isTmpGroup check here and change the old comment to something like:

-- Warnings
-- One Aura/Group: Show warning of aura/group
-- Multi-selection: Nothing

The story behind that is, that for the information tab almost every setting behaves in a non-standard way. E.g. url is set on everything selected, whereas description is only edited on one aura. That doesn't fit the old common options code, and I didn't want to add even more baggage to it.

So the information code is very bare-bones and does the merging itself with some duplicated code. The idea being that some day in the future I'll rewrite it to something better and then port the other pages to a new common infrastructure...

if title and messages then
args.warningTitle = {
type = "header",
name = title,
width = WeakAuras.doubleWidth,
order = order,
}
order = order + 1

args.warnings = {
type = "description",
name = message,
width = WeakAuras.doubleWidth,
order = order,
fontSize = "medium"
}
order = order + 1
end
args.warnings = {
type = "description",
name = messages,
width = WeakAuras.doubleWidth,
order = order,
fontSize = "medium"
}
order = order + 1
end

-- compatibility Options
Expand Down
2 changes: 1 addition & 1 deletion WeakAurasOptions/OptionsFrames/FrameChooser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function OptionsPrivate.StartFrameChooser(data, path)
local focusIsGroup = false;
for id, regionData in pairs(WeakAuras.regions) do
if(regionData.region:IsVisible() and MouseIsOver(regionData.region)) then
local isGroup = regionData.regionType == "group" or regionData.regionType == "dynamicgroup";
local isGroup = regionData.data.controlledChildren;
if (not focusName or (not isGroup and focusIsGroup)) then
focus = regionData.region;
focusName = "WeakAuras:"..id;
Expand Down
4 changes: 2 additions & 2 deletions WeakAurasOptions/OptionsFrames/MoverSizer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ local function ConstructMoverSizer(parent)
frame.lineX:Hide()
end

if data.parent and db.displays[data.parent] and db.displays[data.parent].regionType == "dynamicgroup" then
if data.parent and db.displays[data.parent] and db.displays[data.parent].regionType:find("dynamicgroup", 1, true) then
mover:SetScript("OnMouseDown", nil)
mover:SetScript("OnMouseUp", nil)
mover:SetScript("OnEvent", nil)
Expand Down Expand Up @@ -903,7 +903,7 @@ local function ConstructMoverSizer(parent)
self.anchorPointIcon:SetPoint("CENTER", self.anchor, self.anchorPoint)
local anchorX, anchorY = self.anchorPointIcon:GetCenter()
anchorX, anchorY = anchorX or 0, anchorY or 0
if data.parent and db.displays[data.parent] and db.displays[data.parent].regionType == "dynamicgroup" then
if data.parent and db.displays[data.parent] and db.displays[data.parent].regionType:find("dynamicgroup", 1, true) then
self.selfPointIcon:Hide()
self.anchorPointIcon:Hide()
else
Expand Down
2 changes: 1 addition & 1 deletion WeakAurasOptions/OptionsFrames/OptionsFrame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,7 @@ function OptionsPrivate.CreateFrame()

for index, regionType in ipairs(regionTypesSorted) do
local regionData = regionOptions[regionType]
if (not (fromGroup and (regionType == "group" or regionType == "dynamicgroup"))) then
if (not (fromGroup and (regionType:find("group")))) then
local button = AceGUI:Create("WeakAurasNewButton")
button:SetTitle(regionData.displayName)
if(type(regionData.icon) == "string" or type(regionData.icon) == "table") then
Expand Down
44 changes: 12 additions & 32 deletions WeakAurasOptions/RegionOptions/DynamicGroup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -129,33 +129,6 @@ local function createOptions(id, data)
OptionsPrivate.ResetMoverSizer()
end,
},
useAnchorPerUnit = {
type = "toggle",
order = 1.5,
width = WeakAuras.normalWidth,
name = L["Group by Frame"],
desc = L[
[[Group and anchor each auras by frame.

- Nameplates: attach to nameplates per unit.
- 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 = L["Group by Frame"],
order = 1.6,
values = {
["UNITFRAME"] = L["Unit Frames"],
["NAMEPLATE"] = L["Nameplates"],
["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",
Expand Down Expand Up @@ -397,17 +370,24 @@ local function createOptions(id, data)
disabled = function() return not data.useLimit end,
hidden = function() return data.grow == "CUSTOM" end,
},
distribute = {
type = "select",
width = WeakAuras.doubleWidth,
name = L["Distribute"], -- TODO: bikeshed
order = 27,
values = OptionsPrivate.Private.group_distribute_types
},
animate = {
type = "toggle",
width = WeakAuras.normalWidth,
name = L["Animated Expand and Collapse"],
order = 27
order = 28
},
scale = {
type = "range",
width = WeakAuras.normalWidth,
name = L["Group Scale"],
order = 28,
order = 29,
min = 0.05,
softMax = 2,
max = 10,
Expand Down Expand Up @@ -436,8 +416,8 @@ local function createOptions(id, data)
2, function() return data.grow ~= "CUSTOM" end, {"customGrow"}, false, { setOnParent = true })
OptionsPrivate.commonOptions.AddCodeOption(options, data, L["Custom Sort"], "custom_sort", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#custom-sort",
21, function() return data.sort ~= "custom" end, {"customSort"}, false, { setOnParent = true })
OptionsPrivate.commonOptions.AddCodeOption(options, data, L["Custom Anchor"], "custom_anchor_per_unit", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#group-by-frame",
1.7, function() return not(data.grow ~= "CUSTOM" and data.useAnchorPerUnit and data.anchorPerUnit == "CUSTOM") end, {"customAnchorPerUnit"}, false, { setOnParent = true })
OptionsPrivate.commonOptions.AddCodeOption(options, data, L["Custom Distribute"], "custom_distribute", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#group-by-frame",
27.5, function() return data.distribute ~= "custom" end, {"customDistribute"}, false, { setOnParent = 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
Expand Down Expand Up @@ -553,4 +533,4 @@ local function createIcon()
return thumbnail
end

WeakAuras.RegisterRegionOptions("dynamicgroup", createOptions, createIcon, L["Dynamic Group"], createThumbnail, modifyThumbnail, L["A group that dynamically controls the positioning of its children"]);
WeakAuras.RegisterRegionOptions("dynamicgroup2", createOptions, createIcon, L["Dynamic Group"], createThumbnail, modifyThumbnail, L["A group that dynamically controls the positioning of its children"]);
Loading