This commit is contained in:
Bunny67
2020-09-14 10:12:22 +03:00
parent 6c3f9d925e
commit 0f4f16b6f0
71 changed files with 2302 additions and 2431 deletions
+59 -66
View File
@@ -39,8 +39,6 @@ local versionString = WeakAuras.versionString;
local regionOptions = WeakAuras.regionOptions;
local regionTypes = WeakAuras.regionTypes;
local event_types = WeakAuras.event_types;
local status_types = WeakAuras.status_types;
-- Local functions
local decodeB64, GenerateUniqueID
@@ -140,9 +138,8 @@ function CompressDisplay(data)
end
end
local copiedData = {}
WeakAuras.DeepCopy(data, copiedData)
stripNonTransmissableFields(copiedData, WeakAuras.non_transmissable_fields)
local copiedData = CopyTable(data)
stripNonTransmissableFields(copiedData, Private.non_transmissable_fields)
copiedData.tocversion = WeakAuras.BuildInfo
return copiedData;
end
@@ -224,11 +221,11 @@ showCodeButton:SetSize(90, 22)
local checkButtons, radioButtons, keyToButton, pendingData = {}, {}, {}, {}
for _, key in pairs(WeakAuras.internal_fields) do
for _, key in pairs(Private.internal_fields) do
keyToButton[key] = false
end
for index,category in pairs(WeakAuras.update_categories) do
for index,category in pairs(Private.update_categories) do
local button = CreateFrame("checkButton", "WeakAurasTooltipCheckButton"..index, buttonAnchor, "ChatConfigCheckButtonTemplate")
for k, v in pairs(category) do
button[k] = v
@@ -275,7 +272,7 @@ for index, button in ipairs(radioButtons) do
button:SetChecked(button == self)
end
pendingData.mode = index
WeakAuras.RefreshTooltipButtons()
Private.RefreshTooltipButtons()
end)
end
@@ -285,6 +282,36 @@ end
-- Such that all of the display tab settings are in their own subtable
setmetatable(keyToButton,{__index = function(_, key) return key and checkButtons.display end,})
local deleted = {} -- magic value
local function recurseUpdate(data, chunk)
for k,v in pairs(chunk) do
if v == deleted then
data[k] = nil
elseif type(v) == 'table' and type(data[k]) == 'table' then
recurseUpdate(data[k], v)
else
data[k] = v
end
end
end
local function Update(data, diff)
-- modifies the installed data such that it matches the pending import, sans user-specified options
-- diff is expected to be output generated by diff
if not diff then
WeakAuras.Add(data)
return
end
if data then
WeakAuras.DeleteOption(data)
else
return
end
recurseUpdate(data, diff)
WeakAuras.Add(data)
return data
end
local function install(data, oldData, patch, mode, isParent)
-- munch the provided data and add, update, or delete as appropriate
-- return the data which the SV knows about afterwards (if there is any)
@@ -343,13 +370,13 @@ local function install(data, oldData, patch, mode, isParent)
if data.uid and data.uid ~= oldData.uid then
oldData.uid = data.uid
end
WeakAuras.Update(oldData, patch)
Update(oldData, patch)
oldData.preferToUpdate = true
installedUID = oldData.uid
imported = data
end
-- if at this point, then some change has been made in the db. Update History to reflect the change
WeakAuras.SetHistory(installedUID, imported, "import")
Private.SetHistory(installedUID, imported, "import")
return Private.GetDataByUID(installedUID)
end
@@ -561,7 +588,7 @@ ItemRefTooltip:HookScript("OnHide", function(self)
end)
importButton:SetScript("OnClick", function()
WeakAuras.dynFrame:AddAction("import", coroutine.create(importPendingData))
Private.dynFrame:AddAction("import", coroutine.create(importPendingData))
end)
showCodeButton:SetScript("OnClick", function()
@@ -725,9 +752,6 @@ function WeakAuras.DisplayToString(id, forChat)
v = 1421, -- Version of Transmisson, won't change anymore.
s = versionString
};
if(WeakAuras.transmitCache and WeakAuras.transmitCache[id]) then
transmit.i = WeakAuras.transmitCache[id];
end
local firstTrigger = data.triggers[1].trigger
if(firstTrigger.type == "aura" and WeakAurasOptionsSaved and WeakAurasOptionsSaved.spellCache) then
transmit.a = {};
@@ -792,21 +816,21 @@ local function recurseStringify(data, level, lines)
end
end
function WeakAuras.DataToString(id)
function Private.DataToString(id)
local data = WeakAuras.GetData(id)
if data then
return WeakAuras.SerializeTable(data):gsub("|", "||")
return Private.SerializeTable(data):gsub("|", "||")
end
end
function WeakAuras.SerializeTable(data)
function Private.SerializeTable(data)
local lines = {"{"}
recurseStringify(data, 1, lines)
tinsert(lines, "}")
return table.concat(lines, "\n")
end
function WeakAuras.RefreshTooltipButtons()
function Private.RefreshTooltipButtons()
importButton:Disable()
importButton.tooltipText = nil
showCodeButton:Enable()
@@ -857,7 +881,7 @@ function WeakAuras.RefreshTooltipButtons()
local importWidth = WeakAurasTooltipImportButtonText:GetStringWidth()
importButton:SetWidth(importWidth + 30)
end
buttonAnchor:SetScript("OnEvent", WeakAuras.RefreshTooltipButtons)
buttonAnchor:SetScript("OnEvent", Private.RefreshTooltipButtons)
local function SetCheckButtonStates(radioButtonAnchor, activeCategories)
if activeCategories then
@@ -913,7 +937,7 @@ function ShowTooltip(lines, linesFromTop, activeCategories)
if pendingData.newData then
local checkButtonAnchor = _G["ItemRefTooltipTextLeft" .. (linesFromTop or 1)]
SetCheckButtonStates(checkButtonAnchor, activeCategories)
WeakAuras.RefreshTooltipButtons()
Private.RefreshTooltipButtons()
buttonAnchor:Show()
else
buttonAnchor:Hide()
@@ -1113,8 +1137,8 @@ local function scamCheck(codes, data)
end
end
local internalFields = WeakAuras.internal_fields
local nonTransmissableFields = WeakAuras.non_transmissable_fields
local internalFields = Private.internal_fields
local nonTransmissableFields = Private.non_transmissable_fields
local deleted = {} -- magic value
local function recurseDiff(ours, theirs)
local diff, seen, same = {}, {}, true
@@ -1163,7 +1187,7 @@ local function recurseSerial(lines, depth, chunk)
end
end
function WeakAuras.diff(ours, theirs)
local function diff(ours, theirs)
-- generates a diff which WeakAuras.Update can use
local debug = false
if not ours or not theirs then return end
@@ -1229,7 +1253,7 @@ local function findMatch(data, children)
return oldParent
end
function WeakAuras.MatchInfo(data, children, target)
local function MatchInfo(data, children, target)
-- match the parent/single aura (if no children)
local oldParent = target or findMatch(data, children)
if not oldParent then return nil end
@@ -1255,7 +1279,7 @@ function WeakAuras.MatchInfo(data, children, target)
info.mode = 2
end
info.newData[0] = data
info.diffs[0] = WeakAuras.diff(oldParent, data)
info.diffs[0] = diff(oldParent, data)
if info.diffs[0] then
info.modified = info.modified + 1
end
@@ -1358,7 +1382,7 @@ function WeakAuras.MatchInfo(data, children, target)
else
lastMatch = oldIndex
end
local childDiff = WeakAuras.diff(oldChild, newChild, true)
local childDiff = diff(oldChild, newChild, true)
if childDiff then
info.modified = info.modified + 1
info.diffs[newIndex] = childDiff
@@ -1393,37 +1417,7 @@ function WeakAuras.MatchInfo(data, children, target)
return modified and info or false
end
local function recurseUpdate(data, chunk)
for k,v in pairs(chunk) do
if v == deleted then
data[k] = nil
elseif type(v) == 'table' and type(data[k]) == 'table' then
recurseUpdate(data[k], v)
else
data[k] = v
end
end
end
function WeakAuras.Update(data, diff)
-- modifies the installed data such that it matches the pending import, sans user-specified options
-- diff is expected to be output generated by WeakAuras.diff
if not diff then
WeakAuras.Add(data)
return
end
if data then
WeakAuras.DeleteOption(data)
else
return
end
recurseUpdate(data, diff)
WeakAuras.Add(data)
return data
end
function WeakAuras.ShowDisplayTooltip(data, children, matchInfo, icon, icons, import, compressed)
local function ShowDisplayTooltip(data, children, matchInfo, icon, icons, import, compressed)
-- since we have new data, wipe the old pending data
wipe(pendingData)
@@ -1561,12 +1555,12 @@ function WeakAuras.ShowDisplayTooltip(data, children, matchInfo, icon, icons, im
tinsert(tooltip, {2, L["Trigger:"], L["Aura"], 1, 1, 1, 1, 1, 1});
elseif(trigger.type == "event" or trigger.type == "status") then
if(trigger.type == "event") then
tinsert(tooltip, {2, L["Trigger:"], (event_types[trigger.event] or L["Undefined"]), 1, 1, 1, 1, 1, 1});
tinsert(tooltip, {2, L["Trigger:"], (Private.event_types[trigger.event] or L["Undefined"]), 1, 1, 1, 1, 1, 1});
else
tinsert(tooltip, {2, L["Trigger:"], (status_types[trigger.event] or L["Undefined"]), 1, 1, 1, 1, 1, 1});
tinsert(tooltip, {2, L["Trigger:"], (Private.status_types[trigger.event] or L["Undefined"]), 1, 1, 1, 1, 1, 1});
end
if(trigger.event == "Combat Log" and trigger.subeventPrefix and trigger.subeventSuffix) then
tinsert(tooltip, {2, L["Message type:"], (WeakAuras.subevent_prefix_types[trigger.subeventPrefix] or L["Undefined"]).." "..(WeakAuras.subevent_suffix_types[trigger.subeventSuffix] or L["Undefined"]), 1, 1, 1, 1, 1, 1});
tinsert(tooltip, {2, L["Message type:"], (Private.subevent_prefix_types[trigger.subeventPrefix] or L["Undefined"]).." "..(Private.subevent_suffix_types[trigger.subeventSuffix] or L["Undefined"]), 1, 1, 1, 1, 1, 1});
end
else
tinsert(tooltip, {2, L["Trigger:"], L["Custom"], 1, 1, 1, 1, 1, 1});
@@ -1584,6 +1578,7 @@ function WeakAuras.ShowDisplayTooltip(data, children, matchInfo, icon, icons, im
if excessChildren <= 0 then
tinsert(tooltip, {2, " ", child.id, 1, 1, 1, 1, 1, 1})
end
tocversion = tocversion or child.tocversion
end
if excessChildren > 0 then
tinsert(tooltip, {2, " ", "[...]", 1, 1, 1, 1, 1, 1})
@@ -1632,8 +1627,6 @@ function WeakAuras.ShowDisplayTooltip(data, children, matchInfo, icon, icons, im
local i;
if(icon) then
i = icon;
elseif(WeakAuras.transmitCache and WeakAuras.transmitCache[data.id]) then
i = WeakAuras.transmitCache[data.id];
end
if (i) then
thumbnail:SetIcon(i);
@@ -1700,8 +1693,8 @@ function WeakAuras.Import(inData, target)
end
end
tooltipLoading = nil;
local matchInfo = WeakAuras.MatchInfo(data, children, target)
WeakAuras.ShowDisplayTooltip(data, children, matchInfo, icon, icons, "unknown")
local matchInfo = MatchInfo(data, children, target)
ShowDisplayTooltip(data, children, matchInfo, icon, icons, "unknown")
return status, msg
end
@@ -1808,8 +1801,8 @@ Comm:RegisterComm("WeakAuras", function(prefix, message, distribution, sender)
WeakAuras.PreAdd(child)
end
end
local matchInfo = WeakAuras.MatchInfo(data, children)
WeakAuras.ShowDisplayTooltip(data, children, matchInfo, icon, icons, sender, true)
local matchInfo = MatchInfo(data, children)
ShowDisplayTooltip(data, children, matchInfo, icon, icons, sender, true)
elseif(received.m == "dR") then
--if(WeakAuras.linked[received.d]) then
TransmitDisplay(received.d, sender);