from retail

This commit is contained in:
NoM0Re
2025-01-25 23:37:36 +01:00
parent 4a326118da
commit 667a2f3f50
34 changed files with 788 additions and 242 deletions
+48 -21
View File
@@ -739,6 +739,7 @@ local function BuildUidMap(data, children, type)
for _, childUid in ipairs(children) do
self:EnsureUniqueIdOfUnmatched(childUid, IncProgress)
end
coroutine.yield(0.1, "ensure unique uids")
end
uidMap.InsertUnmatchedPhase1 = function(self, otherUidMap, otherUid, IncProgress)
@@ -777,10 +778,10 @@ local function BuildUidMap(data, children, type)
end
else
IncProgress()
coroutine.yield()
coroutine.yield(0.1)
end
end
coroutine.yield()
coroutine.yield(0.1)
end
for uid, otherList in pairs(matchToInsert) do
@@ -800,8 +801,9 @@ local function BuildUidMap(data, children, type)
otherUidMap:SetUIDMatch(otherUid, otherUid) -- Uids are the same!
self:SetUIDMatch(otherUid, otherUid)
IncProgress()
coroutine.yield()
coroutine.yield(0.1)
end
coroutine.yield(0.1)
end
if otherList.after then
@@ -815,11 +817,12 @@ local function BuildUidMap(data, children, type)
otherUidMap:SetUIDMatch(otherUid, otherUid) -- Uids are the same!
self:SetUIDMatch(otherUid, otherUid)
IncProgress()
coroutine.yield()
coroutine.yield(0.1)
end
coroutine.yield(0.1)
end
end
coroutine.yield()
coroutine.yield(0.1)
end
for _, otherUid in ipairs(waitingForMatch) do
@@ -839,7 +842,7 @@ local function BuildUidMap(data, children, type)
otherUidMap:SetUIDMatch(otherUid, otherUid) -- Uids are the same!
self:SetUIDMatch(otherUid, otherUid)
IncProgress()
coroutine.yield()
coroutine.yield(0.1)
end
return #waitingForMatch > 0
@@ -1621,7 +1624,7 @@ local methods = {
end
end,
Import = function(self)
OptionsPrivate.Private.dynFrame:AddAction("import", coroutine.create(function()
OptionsPrivate.Private.Threads:Add("import", coroutine.create(function()
self:ImportImpl()
end))
end,
@@ -1634,27 +1637,34 @@ local methods = {
self.closeButton:Disable()
self.viewCodeButton:Disable()
OptionsPrivate.Private.SetImporting(true)
coroutine.yield(10, "init")
-- Adjust UI
self:ReleaseChildren()
self:AddBasicInformationWidgets(pendingData.data, pendingData.sender)
self:AddProgressWidgets()
local copies = {}
local pendingPickData
if userChoices.mode == "import" then
coroutine.yield(0.1, "start import")
self:InitializeProgress(2 * (#pendingData.children + 1))
EnsureUniqueUid(pendingData.data)
coroutine.yield(0.1, "ensure unique uids")
for i, child in ipairs(pendingData.children) do
EnsureUniqueUid(child)
coroutine.yield(0.1, "ensure unique uids")
end
coroutine.yield(1, "build uid map")
local uidMap = BuildUidMap(pendingData.data, pendingData.children, "new")
local phase2Order = {}
coroutine.yield(1, "start phase 1")
self:ImportPhase1(uidMap, uidMap:GetRootUID(), phase2Order)
self:ImportPhase2(uidMap, phase2Order)
coroutine.yield(1, "start phase 2")
self:ImportPhase2(uidMap, phase2Order, copies)
pendingPickData = {
id = uidMap:GetIdFor(uidMap:GetRootUID())
@@ -1662,9 +1672,10 @@ local methods = {
if #pendingData.children > 0 then
pendingPickData.tabToShow = "group"
end
coroutine.yield(1, "update ui")
OptionsPrivate.SortDisplayButtons()
elseif userChoices.mode == "update" then
coroutine.yield(0.1, "start update")
local onePhaseProgress = matchInfo.oldUidMap:GetTotalCount() + matchInfo.newUidMap:GetTotalCount()
local IncProgress = function() self:IncProgress() end
@@ -1677,9 +1688,9 @@ local methods = {
-- On update, we won't match A_new to A_old, because A_old is outside the matched parent group
-- Thus on import A_new needs to get its own uid
-- On next import, the auras uids won't match either, there's not much we can do about that.
coroutine.yield(0.1, "ensure unique uids")
matchInfo.newUidMap:EnsureUniqueIdOfUnmatched(nil, IncProgress)
self:SetMinimumProgress(1 * onePhaseProgress)
coroutine.yield()
local removeOldGroups = matchInfo.activeCategories.arrangement and userChoices.activeCategories.arrangement
if userChoices.activeCategories.oldchildren or removeOldGroups then
@@ -1709,6 +1720,7 @@ local methods = {
if not userChoices.activeCategories.oldchildren then
-- Keep old children
matchInfo.newUidMap:InsertUnmatchedFrom(matchInfo.oldUidMap, IncProgress)
coroutine.yield(0.1, "keep old children done")
end
self:SetMinimumProgress(4 * onePhaseProgress)
@@ -1775,17 +1787,26 @@ local methods = {
end
end
coroutine.yield(10, "prep done")
local phase2Order = {}
self:UpdatePhase1(structureUidMap, structureUidMap:GetRootUID(), GetPhase1Data, phase2Order)
self:SetMinimumProgress(16 * onePhaseProgress)
coroutine.yield(10, " phase 1 done")
self:UpdatePhase2(structureUidMap, GetPhase2Data, phase2Order, copies)
self:UpdatePhase2(structureUidMap, GetPhase2Data, phase2Order)
self:SetMinimumProgress(26 * onePhaseProgress)
coroutine.yield(10, " phase 2 done")
local renameTries = 0
while(self:RenameAuras(targetNames)) do
-- Try renaming again and again...
renameTries = renameTries + 1
if renameTries % 10 == 0 then
coroutine.yield(0.1, "renaming auras")
end
end
self:SetMaxProgress()
coroutine.yield()
coroutine.yield(0.1, "renaming auras done")
pendingPickData = {
id = OptionsPrivate.Private.GetDataByUID(matchInfo.oldUidMap:GetRootUID()).id
@@ -1796,7 +1817,7 @@ local methods = {
OptionsPrivate.SortDisplayButtons()
end
coroutine.yield(0.1, "winding down")
OptionsPrivate.Private.SetImporting(false)
self.viewCodeButton:Enable()
self.importButton:Enable()
@@ -1809,6 +1830,12 @@ local methods = {
OptionsPrivate.ClearPicks()
WeakAuras.PickDisplay(pendingPickData.id, pendingPickData.tabToShow)
end
OptionsPrivate.Private.Threads:Add("history_update", coroutine.create(function()
for _, copy in ipairs(copies) do
OptionsPrivate.Private.SetHistory(copy.uid, copy.data, copy.source)
coroutine.yield()
end
end), "background")
end,
-- This ensures that the id that we are adding is either
-- same for existing uids
@@ -1930,7 +1957,7 @@ local methods = {
end
end
self:IncProgress()
coroutine.yield()
coroutine.yield(0.1, "remove unmatched old")
return false
end,
RemoveUnmatchedNew = function(self, uidMap, uid, otherMap, removeAuras, removeGroups)
@@ -1966,7 +1993,7 @@ local methods = {
end
end
self:IncProgress()
coroutine.yield()
coroutine.yield(0.1, "remove unmatched new")
return false
end,
UpdatePhase1 = function(self, structureUidMap, uid, GetPhase1Data, phase2Order)
@@ -1980,7 +2007,7 @@ local methods = {
WeakAuras.Add(data)
WeakAuras.NewDisplayButton(data, true)
self:IncProgress10()
coroutine.yield()
coroutine.yield(1, "adding phase 1 data")
local children = structureUidMap:GetChildren(uid)
local parentIsDynamicGroup = data.regionType == "dynamicgroup"
@@ -1990,14 +2017,14 @@ local methods = {
structureUidMap:SetParentIsDynamicGroup(childUid, parentIsDynamicGroup)
end
end,
UpdatePhase2 = function(self, structureUidMap, GetPhase2Data, phase2Order)
UpdatePhase2 = function(self, structureUidMap, GetPhase2Data, phase2Order, copies)
for i = #phase2Order, 1, -1 do
local uid = phase2Order[i]
local data = GetPhase2Data(uid)
data.preferToUpdate = true
data.authorMode = nil
WeakAuras.Add(data)
OptionsPrivate.Private.SetHistory(data.uid, data, "import")
table.insert(copies, {uid = uid, data = CopyTable(data), source = "update"})
local button = OptionsPrivate.GetDisplayButton(data.id)
button:SetData(data)
if (data.parent) then
@@ -2051,14 +2078,14 @@ local methods = {
uidMap:SetParentIsDynamicGroup(childUid, parentIsDynamicGroup)
end
end,
ImportPhase2 = function(self, uidMap, phase2Order)
ImportPhase2 = function(self, uidMap, phase2Order, copies)
for i = #phase2Order, 1, -1 do
local uid = phase2Order[i]
local data = uidMap:GetPhase2Data(uid)
data.preferToUpdate = false
data.authorMode = nil
WeakAuras.Add(data)
OptionsPrivate.Private.SetHistory(data.uid, data, "import")
table.insert(copies, {uid = uid, data = CopyTable(data), source = "import"})
local button = OptionsPrivate.GetDisplayButton(data.id)
button:SetData(data)