Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions spec/System/TestImport_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,36 @@ Implicits: 0]])
end
assert.truthy(found)
end)

for _, target in ipairs({ { "NOTES", "notesTab", "edit" }, { "PARTY", "partyTab", "editAuras" } }) do
it("keeps " .. target[1] .. " changes unsaved after exporting a build", function()
build:ResetModFlags()
local tab = build[target[2]]
tab.controls[target[3]]:SetText("Unsaved text")
build.viewMode = target[1]
runCallback("OnFrame")
assert.is_true(build.unsaved)
local xml = build:SaveDB("code")
assert.is_truthy(xml:find("Unsaved text", 1, true))
runCallback("OnFrame")
assert.is_true(build.unsaved)
assert.is_true(tab.modFlag)

local openFile = io.open
local written
io.open = function()
return { write = function(_, text) written = text; return true end, close = function() return true end }
end
build.dbFileName = "test.xml"
local ok, err = pcall(build.SaveDBFile, build)
io.open = openFile
build.dbFileName = nil
assert.is_true(ok, err)
assert.is_truthy(written:find("Unsaved text", 1, true))
runCallback("OnFrame")
assert.is_false(build.unsaved)
assert.is_false(tab.modFlag)
end)
end

end)
4 changes: 4 additions & 0 deletions src/Classes/NotesTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ end
function NotesTabClass:Save(xml)
self:SetShowColorCodes(false)
t_insert(xml, self.controls.edit.buf)
end

function NotesTabClass:ResetModFlags()
self.lastContent = self.controls.edit.buf
self.modFlag = false
end

function NotesTabClass:Draw(viewPort, inputEvents)
Expand Down
14 changes: 9 additions & 5 deletions src/Classes/PartyTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,14 @@ function PartyTabClass:Save(xml)
t_insert(child, exportString)
t_insert(xml, child)
end
xml.attrib = {
destination = self.controls.importCodeDestination.list[self.controls.importCodeDestination.selIndex],
append = tostring(self.controls.appendNotReplace.state),
ShowAdvanceTools = tostring(self.controls.ShowAdvanceTools.state)
}
end

function PartyTabClass:ResetModFlags()
self.lastContent.PartyMemberStats = self.controls.editPartyMemberStats.buf
self.lastContent.Aura = self.controls.editAuras.buf
self.lastContent.Curse = self.controls.editCurses.buf
Expand All @@ -659,12 +667,8 @@ function PartyTabClass:Save(xml)
self.lastContent.EnemyCond = self.controls.enemyCond.buf
self.lastContent.EnemyMods = self.controls.enemyMods.buf
self.lastContent.EnableExportBuffs = self.enableExportBuffs
xml.attrib = {
destination = self.controls.importCodeDestination.list[self.controls.importCodeDestination.selIndex],
append = tostring(self.controls.appendNotReplace.state),
ShowAdvanceTools = tostring(self.controls.ShowAdvanceTools.state)
}
self.lastContent.showAdvancedTools = self.controls.ShowAdvanceTools.state
self.modFlag = false
end

function PartyTabClass:Draw(viewPort, inputEvents)
Expand Down
4 changes: 2 additions & 2 deletions src/Modules/Build.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1099,8 +1099,8 @@ end

function buildMode:ResetModFlags()
self.modFlag = false
self.notesTab.modFlag = false
self.partyTab.modFlag = false
self.notesTab:ResetModFlags()
self.partyTab:ResetModFlags()
self.configTab.modFlag = false
self.treeTab.modFlag = false
self.treeTab.searchFlag = false
Expand Down
Loading