from retail
This commit is contained in:
@@ -1216,6 +1216,17 @@ function Private.Modernize(data)
|
||||
data.forceEvents = nil
|
||||
end
|
||||
|
||||
if data.internalVersion < 62 then
|
||||
if data.regionType == "dynamicgroup" then
|
||||
if data.sort == "CUSTOM" and type(data.sortOn) ~= "string" then
|
||||
data.sortOn = "changed"
|
||||
end
|
||||
if data.grow == "CUSTOM" and type(data.growOn) ~= "string" then
|
||||
data.growOn = "changed"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if data.internalVersion < 67 or data.internalVersion > WeakAuras.InternalVersion() then
|
||||
local castMigrationNeeded = data.internalVersion < 67
|
||||
data.internalVersion = WeakAuras.InternalVersion()
|
||||
|
||||
@@ -112,6 +112,8 @@ local function create(parent)
|
||||
region.sortedChildren = {}
|
||||
region.controlledChildren = {}
|
||||
region.updatedChildren = {}
|
||||
region.sortStates = {}
|
||||
region.growStates = {}
|
||||
local background = CreateFrame("Frame", nil, region)
|
||||
region.background = background
|
||||
region.selfPoint = "TOPLEFT"
|
||||
@@ -272,7 +274,7 @@ local sorters = {
|
||||
return WeakAuras.ComposeSorts(
|
||||
WeakAuras.SortAscending({"dataIndex"}),
|
||||
WeakAuras.SortAscending({"region", "state", "index"})
|
||||
)
|
||||
), { index = true }
|
||||
end,
|
||||
hybrid = function(data)
|
||||
local sortHybridTable = data.sortHybridTable or {}
|
||||
@@ -303,23 +305,31 @@ local sorters = {
|
||||
sortHybridStatus,
|
||||
sortExpirationTime,
|
||||
WeakAuras.SortAscending({"dataIndex"})
|
||||
)
|
||||
), {expirationTime = true}
|
||||
end,
|
||||
ascending = function(data)
|
||||
return WeakAuras.ComposeSorts(
|
||||
WeakAuras.SortAscending({"region", "state", "expirationTime"}),
|
||||
WeakAuras.SortAscending({"dataIndex"})
|
||||
)
|
||||
), {expirationTime = true}
|
||||
end,
|
||||
descending = function(data)
|
||||
return WeakAuras.ComposeSorts(
|
||||
WeakAuras.SortDescending({"region", "state", "expirationTime"}),
|
||||
WeakAuras.SortAscending({"dataIndex"})
|
||||
)
|
||||
), {expirationTime = true}
|
||||
end,
|
||||
custom = function(data)
|
||||
local sortStr = data.customSort or ""
|
||||
local sortFunc = WeakAuras.LoadFunction("return " .. sortStr) or noop
|
||||
local sortOn = nil
|
||||
local events = WeakAuras.split(data.sortOn or "")
|
||||
if #events > 0 then
|
||||
sortOn = {}
|
||||
for _, event in ipairs(events) do
|
||||
events[event] = true
|
||||
end
|
||||
end
|
||||
return function(a, b)
|
||||
Private.ActivateAuraEnvironment(data.id)
|
||||
local ok, result = pcall(sortFunc, a, b)
|
||||
@@ -329,7 +339,7 @@ local sorters = {
|
||||
else
|
||||
return result
|
||||
end
|
||||
end
|
||||
end, sortOn
|
||||
end
|
||||
}
|
||||
WeakAuras.SortFunctions = sorters
|
||||
@@ -914,6 +924,14 @@ local growers = {
|
||||
CUSTOM = function(data)
|
||||
local growStr = data.customGrow or ""
|
||||
local growFunc = WeakAuras.LoadFunction("return " .. growStr) or noop
|
||||
local growOn = nil
|
||||
local events = WeakAuras.split(data.growOn or "")
|
||||
if #events > 0 then
|
||||
growOn = {}
|
||||
for _, event in ipairs(events) do
|
||||
events[event] = true
|
||||
end
|
||||
end
|
||||
return function(newPositions, activeRegions)
|
||||
Private.ActivateAuraEnvironment(data.id)
|
||||
local ok, ret = pcall(growFunc, newPositions, activeRegions)
|
||||
@@ -922,7 +940,7 @@ local growers = {
|
||||
Private.GetErrorHandlerId(data.id, L["Custom Grow"])
|
||||
wipe(newPositions)
|
||||
end
|
||||
end
|
||||
end, growOn
|
||||
end
|
||||
}
|
||||
WeakAuras.GrowFunctions = growers
|
||||
@@ -939,6 +957,50 @@ local function SafeGetPos(region, func)
|
||||
end
|
||||
end
|
||||
|
||||
local function isDifferent(regionData, cache, events)
|
||||
local id = regionData.id
|
||||
local cloneId = regionData.cloneId or ""
|
||||
local state = regionData.region.state
|
||||
if not events then
|
||||
return false
|
||||
elseif events.changed then
|
||||
return true -- escape hatch, not super recommended
|
||||
else
|
||||
local isDifferent = false
|
||||
if not cache[id] then
|
||||
isDifferent = true
|
||||
local cachedState = {}
|
||||
cache[id] = {[cloneId] = cachedState}
|
||||
for event in pairs(events) do
|
||||
cachedState[event] = state[event]
|
||||
end
|
||||
elseif not cache[id][cloneId] then
|
||||
isDifferent = true
|
||||
local cachedState = {}
|
||||
cache[id][cloneId] = cachedState
|
||||
for event in pairs(events) do
|
||||
cachedState[event] = state[event]
|
||||
end
|
||||
else
|
||||
local cachedState = cache[id][cloneId]
|
||||
for event in pairs(events) do
|
||||
if regionData.region.state[event] ~= cachedState[event] then
|
||||
cachedState[event] = regionData.region.state[event]
|
||||
isDifferent = true
|
||||
end
|
||||
end
|
||||
end
|
||||
return isDifferent
|
||||
end
|
||||
end
|
||||
|
||||
local function clearCache(cache, id, cloneId)
|
||||
cloneId = cloneId or ""
|
||||
if cache[id] then
|
||||
cache[id][cloneId] = nil
|
||||
end
|
||||
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)
|
||||
@@ -1065,6 +1127,8 @@ local function modify(parent, region, data)
|
||||
Private.StartProfileAura(data.id)
|
||||
self.needToReload = false
|
||||
self.sortedChildren = {}
|
||||
self.sortStates = {}
|
||||
self.growStates = {}
|
||||
self.controlledChildren = {}
|
||||
self.updatedChildren = {}
|
||||
self.controlPoints:ReleaseAll()
|
||||
@@ -1128,9 +1192,14 @@ local function modify(parent, region, data)
|
||||
-- if it has been, then don't insert it again
|
||||
if not regionData.active and self.updatedChildren[regionData] == nil then
|
||||
tinsert(self.sortedChildren, regionData)
|
||||
self.updatedChildren[regionData] = true
|
||||
self:SortUpdatedChildren()
|
||||
elseif isDifferent(regionData, self.sortStates, self.sortOn) then
|
||||
self.updatedChildren[regionData] = true
|
||||
self:SortUpdatedChildren()
|
||||
elseif isDifferent(regionData, self.growStates, self.growOn) then
|
||||
self:PositionChildren()
|
||||
end
|
||||
self.updatedChildren[regionData] = true
|
||||
self:SortUpdatedChildren()
|
||||
end
|
||||
|
||||
function region:RemoveChild(childID, cloneID)
|
||||
@@ -1140,6 +1209,8 @@ local function modify(parent, region, data)
|
||||
if not regionData then return end
|
||||
releaseRegionData(regionData)
|
||||
self.updatedChildren[regionData] = false
|
||||
clearCache(self.sortStates, childID, cloneID)
|
||||
clearCache(self.growStates, childID, cloneID)
|
||||
self:SortUpdatedChildren()
|
||||
end
|
||||
|
||||
@@ -1150,10 +1221,12 @@ local function modify(parent, region, data)
|
||||
if regionData and not regionData.region.toShow then
|
||||
self.updatedChildren[regionData] = false
|
||||
end
|
||||
clearCache(self.sortStates, childID, cloneID)
|
||||
clearCache(self.growStates, childID, cloneID)
|
||||
self:SortUpdatedChildren()
|
||||
end
|
||||
|
||||
region.sortFunc = createSortFunc(data)
|
||||
region.sortFunc, region.sortOn = createSortFunc(data)
|
||||
|
||||
function region:SortUpdatedChildren()
|
||||
-- iterates through cache to insert all updated children in the right spot
|
||||
@@ -1198,7 +1271,7 @@ local function modify(parent, region, data)
|
||||
end
|
||||
end
|
||||
|
||||
region.growFunc = createGrowFunc(data)
|
||||
region.growFunc, region.growOn = createGrowFunc(data)
|
||||
region.anchorPerUnit = data.useAnchorPerUnit and data.anchorPerUnit
|
||||
|
||||
local animate = data.animate
|
||||
|
||||
@@ -2,13 +2,8 @@ if not WeakAuras.IsLibsOK() then return end
|
||||
local AddonName, Private = ...
|
||||
|
||||
local LCG = LibStub("LibCustomGlow-1.0")
|
||||
local MSQ, MSQ_Version = LibStub("Masque", true);
|
||||
if MSQ then
|
||||
if MSQ_Version <= 80100 then
|
||||
MSQ = nil
|
||||
end
|
||||
end
|
||||
local L = WeakAuras.L;
|
||||
local MSQ = LibStub("Masque", true);
|
||||
local L = WeakAuras.L
|
||||
|
||||
local default = function(parentType)
|
||||
local options = {
|
||||
@@ -177,16 +172,16 @@ local funcs = {
|
||||
if (visible) then
|
||||
self.__MSQ_Shape = self:GetParent().button.__MSQ_Shape
|
||||
self:Show()
|
||||
glowStart(self, self, color);
|
||||
glowStart(self, self, color)
|
||||
else
|
||||
self.glowStop(self);
|
||||
self.glowStop(self)
|
||||
self:Hide()
|
||||
end
|
||||
elseif (visible) then
|
||||
self:Show()
|
||||
glowStart(self, self, color);
|
||||
glowStart(self, self, color)
|
||||
else
|
||||
self.glowStop(self);
|
||||
self.glowStop(self)
|
||||
self:Hide()
|
||||
end
|
||||
end,
|
||||
|
||||
@@ -23,6 +23,9 @@ else
|
||||
end
|
||||
end
|
||||
|
||||
--- a sound from each setter
|
||||
local lastPlayedSoundFromSet
|
||||
|
||||
function OptionsPrivate.GetActionOptions(data)
|
||||
local action = {
|
||||
type = "group",
|
||||
@@ -63,9 +66,15 @@ function OptionsPrivate.GetActionOptions(data)
|
||||
data.actions[field][value] = v;
|
||||
end
|
||||
if(value == "sound" or value == "sound_path") then
|
||||
pcall(PlaySoundFile, v, "Master");
|
||||
if lastPlayedSoundFromSet ~= GetTime() then
|
||||
pcall(PlaySoundFile, v, "Master")
|
||||
lastPlayedSoundFromSet = GetTime()
|
||||
end
|
||||
elseif(value == "sound_kit_id") then
|
||||
pcall(PlaySound, v, "Master");
|
||||
if lastPlayedSoundFromSet ~= GetTime() then
|
||||
pcall(PlaySound, v, "Master")
|
||||
lastPlayedSoundFromSet = GetTime()
|
||||
end
|
||||
end
|
||||
WeakAuras.Add(data);
|
||||
if(value == "message") then
|
||||
|
||||
@@ -2474,17 +2474,18 @@ local function valuesAreEqual(t1, t2)
|
||||
if ty1 ~= ty2 then
|
||||
return false
|
||||
end
|
||||
if ty1 == "number" then
|
||||
return abs(t1 - t2) < 1e-9
|
||||
end
|
||||
if ty1 ~= "table" then
|
||||
return false
|
||||
end
|
||||
|
||||
for k1, v1 in pairs(t1) do
|
||||
local v2 = t2[k1]
|
||||
if v2 == nil or not valuesAreEqual(v1, v2) then
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
for k2, v2 in pairs(t2) do
|
||||
local v1 = t1[k2]
|
||||
if v1 == nil or not valuesAreEqual(v1, v2) then
|
||||
|
||||
@@ -187,13 +187,22 @@ local function filterUsedProperties(indexToProperty, allDisplays, usedProperties
|
||||
return filtered;
|
||||
end
|
||||
|
||||
--- a sound from each setter
|
||||
local lastPlayedSoundFromSet
|
||||
|
||||
local function wrapWithPlaySound(func, kit)
|
||||
return function(info, v)
|
||||
func(info, v);
|
||||
if (tonumber(v)) then
|
||||
pcall(PlaySound, tonumber(v), "Master");
|
||||
if lastPlayedSoundFromSet ~= GetTime() then
|
||||
pcall(PlaySound, tonumber(v), "Master")
|
||||
lastPlayedSoundFromSet = GetTime()
|
||||
end
|
||||
else
|
||||
pcall(PlaySoundFile, v, "Master");
|
||||
if lastPlayedSoundFromSet ~= GetTime() then
|
||||
pcall(PlaySoundFile, v, "Master")
|
||||
lastPlayedSoundFromSet = GetTime()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -139,6 +139,23 @@ local function createOptions(id, data)
|
||||
OptionsPrivate.ResetMoverSizer()
|
||||
end,
|
||||
},
|
||||
growOn = {
|
||||
type = "input",
|
||||
width = WeakAuras.doubleWidth,
|
||||
name = L["Run on..."],
|
||||
desc = L["You can add a comma-separated list of state values here that (when changed) WeakAuras should also run the Grow Code on.\n\nWeakAuras will always run custom grow code if you include 'changed' in this list, or when a region is added, removed, or re-ordered."],
|
||||
order = 2 - 0.1,
|
||||
get = function()
|
||||
return data.growOn or ""
|
||||
end,
|
||||
hidden = function() return data.grow ~= "CUSTOM" end,
|
||||
set = function(info, v)
|
||||
data.growOn = v
|
||||
WeakAuras.Add(data)
|
||||
WeakAuras.ClearAndUpdateOptions(data.id)
|
||||
OptionsPrivate.ResetMoverSizer()
|
||||
end
|
||||
},
|
||||
useAnchorPerUnit = {
|
||||
type = "toggle",
|
||||
order = 1.5,
|
||||
@@ -366,6 +383,23 @@ local function createOptions(id, data)
|
||||
order = 20,
|
||||
values = OptionsPrivate.Private.group_sort_types
|
||||
},
|
||||
sortOn = {
|
||||
type = "input",
|
||||
width = WeakAuras.doubleWidth,
|
||||
name = L["Run on..."],
|
||||
desc = L["You can add a comma-separated list of state values here that (when changed) WeakAuras should also run the sort code on.WeakAuras will always run custom sort code if you include 'changed' in this list, or when a region is added, removed."],
|
||||
order = 21 - 0.1,
|
||||
get = function()
|
||||
return data.sortOn or ""
|
||||
end,
|
||||
hidden = function() return data.sort ~= "custom" end,
|
||||
set = function(info, v)
|
||||
data.sortOn = v
|
||||
WeakAuras.Add(data)
|
||||
WeakAuras.ClearAndUpdateOptions(data.id)
|
||||
OptionsPrivate.ResetMoverSizer()
|
||||
end
|
||||
},
|
||||
-- custom sort option added below
|
||||
hybridPosition = {
|
||||
type = "select",
|
||||
|
||||
Reference in New Issue
Block a user