Skip to content

Commit

Permalink
Move regionPrototype to Private
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbuds authored and InfusOnWoW committed Sep 24, 2023
1 parent a1f33b2 commit de7f8e2
Show file tree
Hide file tree
Showing 14 changed files with 58 additions and 59 deletions.
1 change: 0 additions & 1 deletion WeakAuras/AuraEnvironment.lua
Expand Up @@ -472,7 +472,6 @@ local FakeWeakAurasMixin = {
},
blockedTables = {
ModelPaths = true,
regionPrototype = true,
RealTimeProfilingWindow = true,
-- Note these shouldn't exist in the WeakAuras namespace, but moving them takes a bit of effort,
-- so for now just block them and clean them up later
Expand Down
12 changes: 6 additions & 6 deletions WeakAuras/RegionTypes/AuraBar.lua
Expand Up @@ -42,8 +42,8 @@ local default = {
zoom = 0
};

WeakAuras.regionPrototype.AddAdjustedDurationToDefault(default);
WeakAuras.regionPrototype.AddAlphaToDefault(default);
Private.regionPrototype.AddAdjustedDurationToDefault(default);
Private.regionPrototype.AddAlphaToDefault(default);

local screenWidth, screenHeight = math.ceil(GetScreenWidth() / 20) * 20, math.ceil(GetScreenHeight() / 20) * 20;

Expand Down Expand Up @@ -152,7 +152,7 @@ local properties = {
},
};

WeakAuras.regionPrototype.AddProperties(properties, default);
Private.regionPrototype.AddProperties(properties, default);

local function GetProperties(data)
local overlayInfo = Private.GetOverlayInfo(data);
Expand Down Expand Up @@ -1129,7 +1129,7 @@ local function create(parent)
end
end

WeakAuras.regionPrototype.create(region);
Private.regionPrototype.create(region);

for k, f in pairs(funcs) do
region[k] = f
Expand All @@ -1153,7 +1153,7 @@ local function modify(parent, region, data)
region.text = nil
region.stacks = nil

WeakAuras.regionPrototype.modify(parent, region, data);
Private.regionPrototype.modify(parent, region, data);
-- Localize
local bar, iconFrame, icon = region.bar, region.iconFrame, region.icon;

Expand Down Expand Up @@ -1417,7 +1417,7 @@ local function modify(parent, region, data)
--- Update internal bar alignment
region.bar:Update();

WeakAuras.regionPrototype.modifyFinish(parent, region, data);
Private.regionPrototype.modifyFinish(parent, region, data);
end

local function validate(data)
Expand Down
6 changes: 3 additions & 3 deletions WeakAuras/RegionTypes/DynamicGroup.lua
Expand Up @@ -121,7 +121,7 @@ local function create(parent)
region.selfPoint = "TOPLEFT"
region.controlPoints = CreateObjectPool(createControlPoint, releaseControlPoint)
region.controlPoints.parent = region
WeakAuras.regionPrototype.create(region)
Private.regionPrototype.create(region)
region.suspended = 0

local oldSetFrameLevel = region.SetFrameLevel
Expand Down Expand Up @@ -1042,7 +1042,7 @@ end
local function modify(parent, region, data)
Private.FixGroupChildrenOrderForGroup(data)
region:SetScale(data.scale and data.scale > 0 and data.scale <= 10 and data.scale or 1)
WeakAuras.regionPrototype.modify(parent, region, data)
Private.regionPrototype.modify(parent, region, data)

if data.border and not data.useAnchorPerUnit then
local background = region.background
Expand Down Expand Up @@ -1553,7 +1553,7 @@ local function modify(parent, region, data)

region:ReloadControlledChildren()

WeakAuras.regionPrototype.modifyFinish(parent, region, data)
Private.regionPrototype.modifyFinish(parent, region, data)
end

WeakAuras.RegisterRegionType("dynamicgroup", create, modify, default)
6 changes: 3 additions & 3 deletions WeakAuras/RegionTypes/Group.lua
Expand Up @@ -36,7 +36,7 @@ local function create(parent)
local border = CreateFrame("Frame", nil, region, "BackdropTemplate")
region.border = border;

WeakAuras.regionPrototype.create(region);
Private.regionPrototype.create(region);

local oldSetFrameLevel = region.SetFrameLevel
region.SetFrameLevel = function(self, level)
Expand Down Expand Up @@ -91,7 +91,7 @@ local function modify(parent, region, data)
else
data.selfPoint = "CENTER";
end
WeakAuras.regionPrototype.modify(parent, region, data);
Private.regionPrototype.modify(parent, region, data);
-- Localize
local border = region.border;

Expand Down Expand Up @@ -180,7 +180,7 @@ local function modify(parent, region, data)
region.border:Hide()
end

WeakAuras.regionPrototype.modifyFinish(parent, region, data);
Private.regionPrototype.modifyFinish(parent, region, data);
end

-- Register new region type with WeakAuras
Expand Down
12 changes: 6 additions & 6 deletions WeakAuras/RegionTypes/Icon.lua
Expand Up @@ -34,7 +34,7 @@ local default = {
useCooldownModRate = true
};

WeakAuras.regionPrototype.AddAlphaToDefault(default);
Private.regionPrototype.AddAlphaToDefault(default);

local screenWidth, screenHeight = math.ceil(GetScreenWidth() / 20) * 20, math.ceil(GetScreenHeight() / 20) * 20;

Expand Down Expand Up @@ -110,7 +110,7 @@ local properties = {
}
};

WeakAuras.regionPrototype.AddProperties(properties, default);
Private.regionPrototype.AddProperties(properties, default);

local function GetProperties(data)
local result = CopyTable(properties)
Expand Down Expand Up @@ -151,7 +151,7 @@ end

local function AnchorSubRegion(self, subRegion, anchorType, selfPoint, anchorPoint, anchorXOffset, anchorYOffset)
if anchorType == "area" then
WeakAuras.regionPrototype.AnchorSubRegion(selfPoint == "region" and self or self.icon,
Private.regionPrototype.AnchorSubRegion(selfPoint == "region" and self or self.icon,
subRegion, anchorType, selfPoint, anchorPoint, anchorXOffset, anchorYOffset)
else
subRegion:ClearAllPoints()
Expand Down Expand Up @@ -286,7 +286,7 @@ local function create(parent, data)
end
end

WeakAuras.regionPrototype.create(region);
Private.regionPrototype.create(region);

region.AnchorSubRegion = AnchorSubRegion

Expand All @@ -298,7 +298,7 @@ local function modify(parent, region, data)
region.stacks = nil
region.text2 = nil

WeakAuras.regionPrototype.modify(parent, region, data);
Private.regionPrototype.modify(parent, region, data);

local button, icon, cooldown = region.button, region.icon, region.cooldown;

Expand Down Expand Up @@ -648,7 +648,7 @@ local function modify(parent, region, data)
end
end

WeakAuras.regionPrototype.modifyFinish(parent, region, data);
Private.regionPrototype.modifyFinish(parent, region, data);

--- WORKAROUND
-- This fixes a issue with barmodels not appearing on icons if the
Expand Down
10 changes: 5 additions & 5 deletions WeakAuras/RegionTypes/Model.lua
Expand Up @@ -67,7 +67,7 @@ local properties = {
},
}

WeakAuras.regionPrototype.AddProperties(properties, default);
Private.regionPrototype.AddProperties(properties, default);

local function GetProperties(data)
return properties;
Expand All @@ -94,13 +94,13 @@ local function create(parent)
local border = CreateFrame("Frame", nil, region, "BackdropTemplate");
region.border = border;

WeakAuras.regionPrototype.create(region);
Private.regionPrototype.create(region);

for k, v in pairs (regionFunctions) do
region[k] = v
end

region.AnchorSubRegion = WeakAuras.regionPrototype.AnchorSubRegion
region.AnchorSubRegion = Private.regionPrototype.AnchorSubRegion

-- Return complete region
return region;
Expand Down Expand Up @@ -210,7 +210,7 @@ end

-- Modify a given region/display
local function modify(parent, region, data)
WeakAuras.regionPrototype.modify(parent, region, data);
Private.regionPrototype.modify(parent, region, data);
-- Localize
local border = region.border;

Expand Down Expand Up @@ -327,7 +327,7 @@ local function modify(parent, region, data)
end
end

WeakAuras.regionPrototype.modifyFinish(parent, region, data);
Private.regionPrototype.modifyFinish(parent, region, data);
end

-- Work around for movies and world map hiding all models
Expand Down
12 changes: 6 additions & 6 deletions WeakAuras/RegionTypes/ProgressTexture.lua
Expand Up @@ -58,9 +58,9 @@ local default = {
slantMode = "INSIDE"
};

WeakAuras.regionPrototype.AddAlphaToDefault(default);
Private.regionPrototype.AddAlphaToDefault(default);

WeakAuras.regionPrototype.AddAdjustedDurationToDefault(default);
Private.regionPrototype.AddAdjustedDurationToDefault(default);

local screenWidth, screenHeight = math.ceil(GetScreenWidth() / 20) * 20, math.ceil(GetScreenHeight() / 20) * 20;

Expand Down Expand Up @@ -139,7 +139,7 @@ local properties = {
}
}

WeakAuras.regionPrototype.AddProperties(properties, default);
Private.regionPrototype.AddProperties(properties, default);

local function GetProperties(data)
local overlayInfo = Private.GetOverlayInfo(data);
Expand Down Expand Up @@ -1030,7 +1030,7 @@ local function create(parent)

region.SetOrientation = SetOrientation;

WeakAuras.regionPrototype.create(region);
Private.regionPrototype.create(region);

return region;
end
Expand All @@ -1042,7 +1042,7 @@ local function TimerTick(self)
end

local function modify(parent, region, data)
WeakAuras.regionPrototype.modify(parent, region, data);
Private.regionPrototype.modify(parent, region, data);

local background, foreground = region.background, region.foreground;
local foregroundSpinner, backgroundSpinner = region.foregroundSpinner, region.backgroundSpinner;
Expand Down Expand Up @@ -1482,7 +1482,7 @@ local function modify(parent, region, data)
end
end

WeakAuras.regionPrototype.modifyFinish(parent, region, data);
Private.regionPrototype.modifyFinish(parent, region, data);
end

local function validate(data)
Expand Down
22 changes: 11 additions & 11 deletions WeakAuras/RegionTypes/RegionPrototype.lua
Expand Up @@ -6,21 +6,21 @@ local WeakAuras = WeakAuras;
local L = WeakAuras.L;
local GetAtlasInfo = C_Texture and C_Texture.GetAtlasInfo or GetAtlasInfo

WeakAuras.regionPrototype = {};
Private.regionPrototype = {};

-- Alpha
function WeakAuras.regionPrototype.AddAlphaToDefault(default)
function Private.regionPrototype.AddAlphaToDefault(default)
default.alpha = 1.0;
end

-- Adjusted Duration

function WeakAuras.regionPrototype.AddAdjustedDurationToDefault(default)
function Private.regionPrototype.AddAdjustedDurationToDefault(default)
default.useAdjustededMax = false;
default.useAdjustededMin = false;
end

function WeakAuras.regionPrototype.AddAdjustedDurationOptions(options, data, order)
function Private.regionPrototype.AddAdjustedDurationOptions(options, data, order)
options.useAdjustededMin = {
type = "toggle",
width = WeakAuras.normalWidth,
Expand Down Expand Up @@ -102,7 +102,7 @@ function Private.GetAnchorsForData(parentData, type)
end

-- Sound / Chat Message / Custom Code
function WeakAuras.regionPrototype.AddProperties(properties, defaultsForRegion)
function Private.regionPrototype.AddProperties(properties, defaultsForRegion)
properties["sound"] = {
display = L["Sound"],
action = "SoundPlay",
Expand Down Expand Up @@ -443,9 +443,9 @@ local function AnchorSubRegion(self, subRegion, anchorType, selfPoint, anchorPoi
end
end

WeakAuras.regionPrototype.AnchorSubRegion = AnchorSubRegion
Private.regionPrototype.AnchorSubRegion = AnchorSubRegion

function WeakAuras.regionPrototype.create(region)
function Private.regionPrototype.create(region)
local defaultsForRegion = Private.regionTypes[region.regionType] and Private.regionTypes[region.regionType].default;
region.SoundPlay = SoundPlay;
region.SoundStop = SoundStop;
Expand Down Expand Up @@ -492,7 +492,7 @@ end

-- SetDurationInfo

function WeakAuras.regionPrototype.modify(parent, region, data)
function Private.regionPrototype.modify(parent, region, data)
region.state = nil
region.states = nil
region.subRegionEvents:ClearSubscribers()
Expand Down Expand Up @@ -579,7 +579,7 @@ function WeakAuras.regionPrototype.modify(parent, region, data)
end, true)
end

function WeakAuras.regionPrototype.modifyFinish(parent, region, data)
function Private.regionPrototype.modifyFinish(parent, region, data)
-- Sync subRegions
if region.subRegions then
for index, subRegion in pairs(region.subRegions) do
Expand Down Expand Up @@ -666,7 +666,7 @@ local function TimerTickForSetDuration(self)
self:SetTime(max - adjustMin, self.expirationTime - adjustMin, self.inverse);
end

function WeakAuras.regionPrototype.AddSetDurationInfo(region)
function Private.regionPrototype.AddSetDurationInfo(region)
if (region.SetValue and region.SetTime) then
region.generatedSetDurationInfo = true;

Expand Down Expand Up @@ -696,7 +696,7 @@ function WeakAuras.regionPrototype.AddSetDurationInfo(region)
end

-- Expand/Collapse function
function WeakAuras.regionPrototype.AddExpandFunction(data, region, cloneId, parent, parentRegionType)
function Private.regionPrototype.AddExpandFunction(data, region, cloneId, parent, parentRegionType)
local uid = data.uid
local id = data.id
local inDynamicGroup = parentRegionType == "dynamicgroup";
Expand Down
6 changes: 3 additions & 3 deletions WeakAuras/RegionTypes/StopMotion.lua
Expand Up @@ -83,7 +83,7 @@ local properties = {
},
}

WeakAuras.regionPrototype.AddProperties(properties, default);
Private.regionPrototype.AddProperties(properties, default);

local function create(parent)
local frame = CreateFrame("Frame", nil, UIParent);
Expand All @@ -104,7 +104,7 @@ local function create(parent)
frame.foreground = foreground;
foreground:SetAllPoints(frame);

WeakAuras.regionPrototype.create(frame);
Private.regionPrototype.create(frame);

return frame;
end
Expand Down Expand Up @@ -158,7 +158,7 @@ local function SetFrameViaFrames(self, texture, frame)
end

local function modify(parent, region, data)
WeakAuras.regionPrototype.modify(parent, region, data);
Private.regionPrototype.modify(parent, region, data);
region.foreground = region.foreground or {}
region.background = region.background or {}
local pattern = "%.x(%d+)y(%d+)f(%d+)%.[tb][gl][ap]"
Expand Down

0 comments on commit de7f8e2

Please sign in to comment.