Skip to content

Commit 636e7cb

Browse files
authored
ui: add sort mode for build "save as" menu (#9489)
1 parent 9c88d1c commit 636e7cb

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

src/Classes/FolderListControl.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ local t_insert = table.insert
99
local FolderListClass = newClass("FolderListControl", "ListControl", function(self, anchor, rect, subPath, onChange)
1010
self.ListControl(anchor, rect, 16, "VERTICAL", false, { })
1111
self.subPath = subPath or ""
12+
self.sortMode = "NAME"
1213
self.onChangeCallback = onChange
1314

1415
self.controls.path = new("PathControl", {"BOTTOM",self,"TOP"}, {0, -2, self.width, 24}, main.buildPath, self.subPath, function(newSubPath)
@@ -25,7 +26,7 @@ end)
2526

2627
function FolderListClass:SortList()
2728
if not self.list then return end
28-
local sortMode = main.buildSortMode or "NAME"
29+
local sortMode = self.sortMode
2930

3031
table.sort(self.list, function(a, b)
3132
if sortMode == "EDITED" then
@@ -91,4 +92,4 @@ function FolderListClass:OnSelDelete(index, folder)
9192
self.selIndex = nil
9293
self.selValue = nil
9394
end
94-
end
95+
end

src/Modules/Build.lua

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ function buildMode:Init(dbFileName, buildName, buildXML, convertBuild, importLin
6868
if not buildName then
6969
main:SetMode("LIST")
7070
end
71+
self.saveAsSortMode = "NAME"
7172

7273
-- Load build file
7374
self.xmlSectionList = { }
@@ -1310,18 +1311,22 @@ function buildMode:OpenSaveAsPopup()
13101311
end
13111312
end)
13121313
end)
1313-
controls.folder = new("FolderListControl", nil, {0, 115, 450, 100}, self.dbFileSubPath, function(subPath)
1314+
1315+
controls.folder = new("FolderListControl", nil, {0, 115, 450, 400}, self.dbFileSubPath, function(subPath)
13141316
updateBuildName()
13151317
end)
1316-
controls.save = new("ButtonControl", nil, {-45, 225, 80, 20}, "Save", function()
1318+
controls.folder.sortMode = self.saveAsSortMode
1319+
controls.folder:SortList()
1320+
1321+
controls.save = new("ButtonControl", nil, {-45, 525, 80, 20}, "Save", function()
13171322
main:ClosePopup()
13181323
self.dbFileName = newFileName
13191324
self.buildName = newBuildName
13201325
self.dbFileSubPath = controls.folder.subPath
13211326
self:SaveDBFile()
13221327
self.spec:SetWindowTitleWithBuildClass()
13231328
end)
1324-
controls.close = new("ButtonControl", nil, {45, 225, 80, 20}, "Cancel", function()
1329+
controls.close = new("ButtonControl", nil, {45, 525, 80, 20}, "Cancel", function()
13251330
main:ClosePopup()
13261331
self.actionOnSave = nil
13271332
end)
@@ -1333,7 +1338,18 @@ function buildMode:OpenSaveAsPopup()
13331338
controls.save.enabled = false
13341339
end
13351340

1336-
main:OpenPopup(470, 255, self.dbFileName and "Save As" or "Save", controls, "save", "edit", "close")
1341+
controls.buildSortMode = new("DropDownControl", { "TOPRIGHT", nil, "TOPRIGHT" }, { -10, 70, 120, 18 }, {
1342+
{ label = "Sort By Name", mode = "NAME" },
1343+
{ label = "Sort By Last Edited", mode = "EDITED" },
1344+
}, function(index, value)
1345+
self.saveAsSortMode = value.mode
1346+
controls.folder.sortMode = value.mode
1347+
controls.folder:SortList()
1348+
end)
1349+
controls.buildSortMode.tooltipText = "Sort folders by name or date modified."
1350+
controls.buildSortMode:SelByValue(self.saveAsSortMode, "mode")
1351+
1352+
main:OpenPopup(470, 555, self.dbFileName and "Save As" or "Save", controls, "save", "edit", "close")
13371353
end
13381354

13391355
-- Open the spectre library popup

0 commit comments

Comments
 (0)