diff --git a/Classes/BuildListControl.lua b/Classes/BuildListControl.lua index c264ebb5..d6138bfa 100644 --- a/Classes/BuildListControl.lua +++ b/Classes/BuildListControl.lua @@ -126,6 +126,9 @@ function BuildListClass:OnKeyDown(key, doubleClick) if not self:IsMouseOver() and key:match("BUTTON") then return end + if self.listMode.edit then + return self + end if key == "LEFTBUTTON" then self.listMode.sel = nil local x, y = self:GetPos() diff --git a/Classes/PassiveTreeView.lua b/Classes/PassiveTreeView.lua index 62ac8d52..8c13798e 100644 --- a/Classes/PassiveTreeView.lua +++ b/Classes/PassiveTreeView.lua @@ -9,6 +9,7 @@ local launch, main = ... local pairs = pairs local ipairs = ipairs local t_insert = table.insert +local t_remove = table.remove local m_min = math.min local m_max = math.max local m_floor = math.floor @@ -165,8 +166,13 @@ function PassiveTreeViewClass:Draw(build, viewPort, inputEvents) else local lastPathNode = self.tracePath[#self.tracePath] if hoverNode ~= lastPathNode then - -- If node is not in the trace path, but is directly linked to the last node in the path, then add it - if not isValueInArray(hoverNode, self.tracePath) and isValueInArray(hoverNode.linked, lastPathNode) then + -- If node is directly linked to the last node in the path, add it + if isValueInArray(hoverNode.linked, lastPathNode) then + local index = isValueInArray(self.tracePath, hoverNode) + if index then + -- Node is already in the trace path, remove it first + t_remove(self.tracePath, index) + end t_insert(self.tracePath, hoverNode) else hoverNode = nil @@ -208,11 +214,13 @@ function PassiveTreeViewClass:Draw(build, viewPort, inputEvents) end elseif treeClick == "RIGHT" then if hoverNode and hoverNode.alloc and hoverNode.type == "socket" then - -- User right-clicked a jewel socket, jump to the item page and focus the corresponding item slot control - build.viewMode = "ITEMS" local slot = build.itemsTab.sockets[hoverNode.id] - slot.dropped = true - build.itemsTab:SelectControl(slot) + if slot:IsEnabled() then + -- User right-clicked a jewel socket, jump to the item page and focus the corresponding item slot control + slot.dropped = true + build.itemsTab:SelectControl(slot) + build.viewMode = "ITEMS" + end end end @@ -513,8 +521,10 @@ function PassiveTreeViewClass:AddNodeTooltip(node, build) else main:AddTooltipLine(24, "^7"..node.dn..(launch.devMode and IsKeyDown("ALT") and " ["..node.id.."]" or "")) end - main:AddTooltipSeparator(14) - main:AddTooltipLine(14, "^x80A080Tip: Right click this socket to go to the items page and choose the jewel for this socket.") + if socket:IsEnabled() then + main:AddTooltipSeparator(14) + main:AddTooltipLine(14, "^x80A080Tip: Right click this socket to go to the items page and choose the jewel for this socket.") + end return end @@ -590,11 +600,15 @@ function PassiveTreeViewClass:AddNodeTooltip(node, build) -- Pathing distance if node.path and #node.path > 0 then main:AddTooltipSeparator(14) - main:AddTooltipLine(14, "^7"..#node.path .. " points to node") - if #node.path > 1 then - -- Handy hint! - main:AddTooltipLine(14, "^x80A080") - main:AddTooltipLine(14, "Tip: To reach this node by a different path, hold Shift, then trace the path and click this node") + if self.traceMode and isValueInArray(self.tracePath, node) then + main:AddTooltipLine(14, "^7"..#self.tracePath .. " nodes in trace path") + else + main:AddTooltipLine(14, "^7"..#node.path .. " points to node") + if #node.path > 1 then + -- Handy hint! + main:AddTooltipLine(14, "^x80A080") + main:AddTooltipLine(14, "Tip: To reach this node by a different path, hold Shift, then trace the path and click this node") + end end end if node.depends and #node.depends > 1 then diff --git a/Launch.lua b/Launch.lua index 89641799..f1df8e1b 100644 --- a/Launch.lua +++ b/Launch.lua @@ -72,6 +72,19 @@ function launch:OnInit() end end +function launch:CanExit() + if self.main and self.main.CanExit and not self.promptMsg then + local errMsg, ret = PCall(self.main.CanExit, self.main) + if errMsg then + self:ShowErrMsg("In 'CanExit': %s", errMsg) + return false + else + return ret + end + end + return true +end + function launch:OnExit() if self.main and self.main.Shutdown then PCall(self.main.Shutdown, self.main) diff --git a/Modules/Build.lua b/Modules/Build.lua index 7165c8a4..11f3f81a 100644 --- a/Modules/Build.lua +++ b/Modules/Build.lua @@ -128,6 +128,7 @@ function buildMode:Init(dbFileName, buildName) end self.controls.characterLevel = common.New("EditControl", {"LEFT",self.anchorTopBarRight,"RIGHT"}, 0, 0, 106, 20, "", "Level", "%D", 3, function(buf) self.characterLevel = m_min(tonumber(buf) or 1, 100) + self.modFlag = true self.buildFlag = true end) self.controls.characterLevel.tooltip = function() @@ -380,6 +381,28 @@ function buildMode:Init(dbFileName, buildName) self.abortSave = false end +function buildMode:CanExit() + if not self.unsaved then + return true + end + main:OpenPopup(280, 100, "Save Changes", { + common.New("LabelControl", nil, 0, 20, 0, 16, "^7This build has unsaved changes.\nDo you want to save them before exiting?"), + common.New("ButtonControl", nil, -90, 70, 80, 20, "Save", function() + self:SaveDBFile() + main:ClosePopup() + Exit() + end), + common.New("ButtonControl", nil, 0, 70, 80, 20, "Don't Save", function() + main:ClosePopup() + Exit() + end), + common.New("ButtonControl", nil, 90, 70, 80, 20, "Cancel", function() + main:ClosePopup() + end), + }) + return false +end + function buildMode:Shutdown() if launch.devMode and not self.abortSave then self:SaveDBFile() diff --git a/Modules/BuildList.lua b/Modules/BuildList.lua index 4e78ed94..0f490e45 100644 --- a/Modules/BuildList.lua +++ b/Modules/BuildList.lua @@ -17,25 +17,30 @@ function listMode:Init(selBuildName) return main.screenW / 2 end - self.controls.new = common.New("ButtonControl", {"TOP",self.anchor,"TOP"}, -68*2, 0, 60, 20, "New", function() + self.controls.new = common.New("ButtonControl", {"TOP",self.anchor,"TOP"}, -210, 0, 60, 20, "New", function() self:New() end) - self.controls.open = common.New("ButtonControl", {"TOP",self.anchor,"TOP"}, -68, 0, 60, 20, "Open", function() + self.controls.open = common.New("ButtonControl", {"LEFT",self.controls.new,"RIGHT"}, 8, 0, 60, 20, "Open", function() self:LoadSel() end) self.controls.open.enabled = function() return self.sel ~= nil end - self.controls.copy = common.New("ButtonControl", {"TOP",self.anchor,"TOP"}, 0, 0, 60, 20, "Copy", function() + self.controls.copy = common.New("ButtonControl", {"LEFT",self.controls.open,"RIGHT"}, 8, 0, 60, 20, "Copy", function() self:CopySel() end) self.controls.copy.enabled = function() return self.sel ~= nil end - self.controls.rename = common.New("ButtonControl", {"TOP",self.anchor,"TOP"}, 68, 0, 60, 20, "Rename", function() + self.controls.rename = common.New("ButtonControl", {"LEFT",self.controls.copy,"RIGHT"}, 8, 0, 60, 20, "Rename", function() self:RenameSel() end) self.controls.rename.enabled = function() return self.sel ~= nil end - self.controls.delete = common.New("ButtonControl", {"TOP",self.anchor,"TOP"}, 68*2, 0, 60, 20, "Delete", function() + self.controls.delete = common.New("ButtonControl", {"LEFT",self.controls.rename,"RIGHT"}, 8, 0, 60, 20, "Delete", function() self:DeleteSel() end) self.controls.delete.enabled = function() return self.sel ~= nil end + self.controls.sort = common.New("DropDownControl", {"LEFT",self.controls.delete,"RIGHT"}, 8, 0, 140, 20, {{val="NAME",label="Sort by Name"},{val="CLASS",label="Sort by Class"},{val="EDITED",label="Sort by Last Edited"}}, function(sel, val) + main.buildSortMode = val.val + self:SortList() + end) + self.controls.sort:SelByValue(main.buildSortMode) self.controls.buildList = common.New("BuildList", {"TOP",self.anchor,"TOP"}, 0, 24, 500, 0, self) self.controls.buildList.height = function() @@ -81,6 +86,7 @@ function listMode:BuildList() local fileName = handle:GetFileName() local build = { } build.fileName = fileName + build.modified = handle:GetFileModifiedTime() build.buildName = fileName:gsub("%.xml$","") local dbXML = common.xml.LoadXMLFile(main.buildPath..fileName) if dbXML and dbXML[1].elem == "PathOfBuilding" then @@ -102,7 +108,22 @@ end function listMode:SortList() local oldSelFileName = self.sel and self.list[self.sel] and self.list[self.sel].fileName - table.sort(self.list, function(a, b) return a.fileName:upper() < b.fileName:upper() end) + table.sort(self.list, function(a, b) + if main.buildSortMode == "EDITED" then + return a.modified > b.modified + elseif main.buildSortMode == "CLASS" then + if a.className and not b.className then + return false + elseif not a.className and b.className then + return true + elseif a.className ~= b.className then + return a.className < b.className + elseif a.ascendClassName ~= b.ascendClassName then + return a.ascendClassName < b.ascendClassName + end + end + return a.fileName:upper() < b.fileName:upper() + end) if oldSelFileName then self:SelByFileName(oldSelFileName) end @@ -169,7 +190,7 @@ function listMode:New() outFile:close() self.list[self.edit].fileName = fileName self.list[self.edit].buildName = buf - self:SortList() + self:BuildList() end) end @@ -211,7 +232,7 @@ function listMode:CopySel() outFile:close() self.list[self.edit].fileName = dstName self.list[self.edit].buildName = buf - self:SortList() + self:BuildList() end) end diff --git a/Modules/Main.lua b/Modules/Main.lua index 00c08ee3..186e36e7 100644 --- a/Modules/Main.lua +++ b/Modules/Main.lua @@ -196,11 +196,22 @@ function main:Init() self.accountSessionIDs = { } + self.buildSortMode = "NAME" + self:SetMode("LIST") self:LoadSettings() end +function main:CanExit() + local ret = self:CallMode("CanExit") + if ret ~= nil then + return ret + else + return true + end +end + function main:Shutdown() self:CallMode("Shutdown") @@ -264,7 +275,7 @@ end function main:CallMode(func, ...) local modeTbl = self.modes[self.mode] if modeTbl[func] then - modeTbl[func](modeTbl, ...) + return modeTbl[func](modeTbl, ...) end end @@ -305,6 +316,10 @@ function main:LoadSettings() self.accountSessionIDs[child.attrib.accountName] = child.attrib.sessionID end end + elseif node.elem == "Misc" then + if node.attrib.buildSortMode then + self.buildSortMode = node.attrib.buildSortMode + end end end end @@ -330,6 +345,7 @@ function main:SaveSettings() t_insert(accounts, { elem = "Account", attrib = { accountName = accountName, sessionID = sessionID } }) end t_insert(setXML, accounts) + t_insert(setXML, { elem = "Misc", attrib = { buildSortMode = self.buildSortMode } }) local res, errMsg = common.xml.SaveXMLFile(setXML, self.userPath.."Settings.xml") if not res then launch:ShowErrMsg("Error saving 'Settings.xml': %s", errMsg) diff --git a/README.md b/README.md index 37b5129c..cd5954e6 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,12 @@ Head over to the [Releases](https://github.com/Openarl/PathOfBuilding/releases) ![ss3](https://cloud.githubusercontent.com/assets/19189971/18089780/f0ff234a-6f04-11e6-8c88-6193fe59a5c4.png) ## Changelog +### 1.2.16 - 2016/11/25 + * The build list can now be sorted by name, class or time of last edit + * The save prompt will now show when closing the program if there are unsaved changes + * Fixed issue caused by right-clicking a jewel socket on the passive tree when there's no jewels in the build + * Various minor tweaks and fixes + ### 1.2.15 - 2016/11/25 * Added all uniques so far announced for 2.5.0 * Most of their special modifiers should be working; as usual anything in blue should work, anything in red won't diff --git a/changelog.txt b/changelog.txt index 8803dc08..4fbdc78f 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,8 @@ +VERSION[1.2.16][2016/11/25] + * The build list can now be sorted by name, class or time of last edit + * The save prompt will now show when closing the program if there are unsaved changes + * Fixed issue caused by right-clicking a jewel socket on the passive tree when there's no jewels in the build + * Various minor tweaks and fixes VERSION[1.2.15][2016/11/25] * Added all uniques so far announced for 2.5.0 * Most of their special modifiers should be working; as usual anything in blue should work, anything in red won't diff --git a/manifest.xml b/manifest.xml index da4955d2..92edf132 100644 --- a/manifest.xml +++ b/manifest.xml @@ -1,14 +1,14 @@ - + - + - - + + @@ -31,7 +31,7 @@ - + @@ -42,14 +42,14 @@ - - + + - + @@ -101,10 +101,10 @@ - + - + diff --git a/runtime-win32.zip b/runtime-win32.zip index 3e09860f..9ed98166 100644 Binary files a/runtime-win32.zip and b/runtime-win32.zip differ