Skip to content

Commit e048fea

Browse files
committed
handling unsaved changes for compared build
1 parent 0baf967 commit e048fea

3 files changed

Lines changed: 24 additions & 2 deletions

File tree

src/Classes/CompareTab.lua

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ function CompareTabClass:InitControls()
266266
local entry = self:GetActiveCompare()
267267
if entry and entry.treeTab and entry.treeTab.specList[index] then
268268
entry:SetActiveSpec(index)
269+
self.modFlag = true
269270
-- Restore primary build's window title (SetActiveSpec changes it)
270271
if self.primaryBuild.spec then
271272
self.primaryBuild.spec:SetWindowTitleWithBuildClass()
@@ -283,6 +284,7 @@ function CompareTabClass:InitControls()
283284
local entry = self:GetActiveCompare()
284285
if entry and entry.skillsTab and entry.skillsTab.skillSetOrderList[index] then
285286
entry:SetActiveSkillSet(entry.skillsTab.skillSetOrderList[index])
287+
self.modFlag = true
286288
end
287289
end)
288290
self.controls.compareSkillSetSelect.enabled = setsEnabled
@@ -293,6 +295,7 @@ function CompareTabClass:InitControls()
293295
local entry = self:GetActiveCompare()
294296
if entry and entry.itemsTab and entry.itemsTab.itemSetOrderList[index] then
295297
entry:SetActiveItemSet(entry.itemsTab.itemSetOrderList[index])
298+
self.modFlag = true
296299
end
297300
end)
298301
self.controls.compareItemSetSelect.enabled = setsEnabled
@@ -306,6 +309,7 @@ function CompareTabClass:InitControls()
306309
if setId then
307310
entry.configTab:SetActiveConfigSet(setId)
308311
entry.buildFlag = true
312+
self.modFlag = true
309313
self.configNeedsRebuild = true
310314
end
311315
end
@@ -338,6 +342,7 @@ function CompareTabClass:InitControls()
338342
if mainSocketGroup then
339343
mainSocketGroup.mainActiveSkill = index
340344
entry.modFlag = true
345+
self.modFlag = true
341346
entry.buildFlag = true
342347
end
343348
end
@@ -355,6 +360,7 @@ function CompareTabClass:InitControls()
355360
if activeSkill and activeSkill.activeEffect then
356361
activeSkill.activeEffect.srcInstance.skillPart = index
357362
entry.modFlag = true
363+
self.modFlag = true
358364
entry.buildFlag = true
359365
end
360366
end
@@ -375,6 +381,7 @@ function CompareTabClass:InitControls()
375381
if activeSkill and activeSkill.activeEffect then
376382
activeSkill.activeEffect.srcInstance.skillStageCount = tonumber(buf)
377383
entry.modFlag = true
384+
self.modFlag = true
378385
entry.buildFlag = true
379386
end
380387
end
@@ -395,6 +402,7 @@ function CompareTabClass:InitControls()
395402
if activeSkill and activeSkill.activeEffect then
396403
activeSkill.activeEffect.srcInstance.skillMineCount = tonumber(buf)
397404
entry.modFlag = true
405+
self.modFlag = true
398406
entry.buildFlag = true
399407
end
400408
end
@@ -419,6 +427,7 @@ function CompareTabClass:InitControls()
419427
activeSkill.activeEffect.srcInstance.skillMinion = selected.minionId
420428
end
421429
entry.modFlag = true
430+
self.modFlag = true
422431
entry.buildFlag = true
423432
end
424433
end
@@ -438,6 +447,7 @@ function CompareTabClass:InitControls()
438447
if activeSkill and activeSkill.activeEffect then
439448
activeSkill.activeEffect.srcInstance.skillMinionSkill = index
440449
entry.modFlag = true
450+
self.modFlag = true
441451
entry.buildFlag = true
442452
end
443453
end
@@ -515,6 +525,7 @@ function CompareTabClass:InitControls()
515525
local entry = self:GetActiveCompare()
516526
if entry and entry.itemsTab and entry.itemsTab.itemSetOrderList[index] then
517527
entry:SetActiveItemSet(entry.itemsTab.itemSetOrderList[index])
528+
self.modFlag = true
518529
end
519530
end)
520531
self.controls.compareItemSetSelect2.enabled = itemsShown
@@ -541,6 +552,7 @@ function CompareTabClass:InitControls()
541552
local entry = self:GetActiveCompare()
542553
if entry and entry.treeTab and entry.treeTab.specList[index] then
543554
entry:SetActiveSpec(index)
555+
self.modFlag = true
544556
if self.primaryBuild.spec then
545557
self.primaryBuild.spec:SetWindowTitleWithBuildClass()
546558
end
@@ -588,6 +600,7 @@ function CompareTabClass:InitControls()
588600
local entry = self:GetActiveCompare()
589601
if entry and entry.treeTab and entry.treeTab.specList[index] then
590602
entry:SetActiveSpec(index)
603+
self.modFlag = true
591604
-- Restore primary build's window title (compare entry's SetActiveSpec changes it)
592605
if self.primaryBuild.spec then
593606
self.primaryBuild.spec:SetWindowTitleWithBuildClass()
@@ -1029,7 +1042,11 @@ function CompareTabClass:ImportFromCode(code)
10291042
if not xmlText then
10301043
return false
10311044
end
1032-
return self:ImportBuild(xmlText, "Imported build")
1045+
if self:ImportBuild(xmlText, "Imported build") then
1046+
self.modFlag = true
1047+
return true
1048+
end
1049+
return false
10331050
end
10341051

10351052
-- Save comparison builds to the build file
@@ -1105,6 +1122,7 @@ end
11051122
function CompareTabClass:RemoveBuild(index)
11061123
if index >= 1 and index <= #self.compareEntries then
11071124
t_remove(self.compareEntries, index)
1125+
self.modFlag = true
11081126
if self.activeCompareIndex > #self.compareEntries then
11091127
self.activeCompareIndex = #self.compareEntries
11101128
end
@@ -1688,6 +1706,7 @@ function CompareTabClass:OpenImportPopup()
16881706
local xmlText = Inflate(common.base64.decode(codeData:gsub("-","+"):gsub("_","/")))
16891707
if xmlText then
16901708
self:ImportBuild(xmlText, customName or ("Imported from " .. site.label))
1709+
self.modFlag = true
16911710
main:ClosePopup()
16921711
else
16931712
stateText = colorCodes.NEGATIVE .. "Failed to decode build data"
@@ -1704,6 +1723,7 @@ function CompareTabClass:OpenImportPopup()
17041723
local xmlText = Inflate(common.base64.decode(buf:gsub("-","+"):gsub("_","/")))
17051724
if xmlText then
17061725
self:ImportBuild(xmlText, customName or "Imported build")
1726+
self.modFlag = true
17071727
main:ClosePopup()
17081728
else
17091729
stateText = colorCodes.NEGATIVE .. "Invalid build code"

src/Classes/ImportTab.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ You can get this from your web browser's cookies while logged into the Path of E
318318
-- Import as comparison build
319319
if self.build.compareTab then
320320
if self.build.compareTab:ImportBuild(self.importCodeXML, "Imported comparison") then
321+
self.build.compareTab.modFlag = true
321322
self.build.viewMode = "COMPARE"
322323
else
323324
main:OpenMessagePopup("Import Error", "Failed to import build for comparison.")

src/Modules/Build.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,7 @@ function buildMode:ResetModFlags()
10641064
self.skillsTab.modFlag = false
10651065
self.itemsTab.modFlag = false
10661066
self.calcsTab.modFlag = false
1067+
self.compareTab.modFlag = false
10671068
end
10681069

10691070
function buildMode:OnFrame(inputEvents)
@@ -1212,7 +1213,7 @@ function buildMode:OnFrame(inputEvents)
12121213
self.compareTab:Draw(tabViewPort, inputEvents)
12131214
end
12141215

1215-
self.unsaved = self.modFlag or self.notesTab.modFlag or self.partyTab.modFlag or self.configTab.modFlag or self.treeTab.modFlag or self.treeTab.searchFlag or self.spec.modFlag or self.skillsTab.modFlag or self.itemsTab.modFlag or self.calcsTab.modFlag
1216+
self.unsaved = self.modFlag or self.notesTab.modFlag or self.partyTab.modFlag or self.configTab.modFlag or self.treeTab.modFlag or self.treeTab.searchFlag or self.spec.modFlag or self.skillsTab.modFlag or self.itemsTab.modFlag or self.calcsTab.modFlag or self.compareTab.modFlag
12161217

12171218
SetDrawLayer(5)
12181219

0 commit comments

Comments
 (0)