Skip to content

Commit

Permalink
Add support for changing Tree Version (#6312)
Browse files Browse the repository at this point in the history
* add version selector in TreeTab, reuse convert function

* function for versions list
  • Loading branch information
Peechey authored Aug 13, 2023
1 parent 6f4e95b commit 9b3ae13
Showing 1 changed file with 30 additions and 10 deletions.
40 changes: 30 additions & 10 deletions src/Classes/TreeTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,35 @@ local TreeTabClass = newClass("TreeTab", "ControlHost", function(self, build)
self.controls.export = new("ButtonControl", { "LEFT", self.controls.import, "RIGHT" }, 8, 0, 90, 20, "Export Tree", function()
self:OpenExportPopup()
end)
self.controls.treeSearch = new("EditControl", { "LEFT", self.controls.export, "RIGHT" }, 8, 0, main.portraitMode and 200 or 300, 20, "", "Search", "%c", 100, function(buf)
local function convertToVersion(version)
local newSpec = new("PassiveSpec", self.build, version, true)
newSpec.title = self.build.spec.title
newSpec.jewels = copyTable(self.build.spec.jewels)
newSpec:RestoreUndoState(self.build.spec:CreateUndoState(), version)
newSpec:BuildClusterJewelGraphs()
t_insert(self.specList, self.activeSpec + 1, newSpec)
self:SetActiveSpec(self.activeSpec + 1)
self.modFlag = true
main:OpenMessagePopup("Tree Converted", "The tree has been converted to "..treeVersions[version].display..".\nNote that some or all of the passives may have been de-allocated due to changes in the tree.\n\nYou can switch back to the old tree using the tree selector at the bottom left.")
end
self.treeVersions = { }
for _, num in ipairs(treeVersionList) do
if not num:find("^2") then
local vers = num:gsub("%_", ".")
t_insert(self.treeVersions, vers)
end
end
self.controls.versionText = new("LabelControl", { "LEFT", self.controls.export, "RIGHT" }, 8, 0, 0, 16, "Version:")
self.controls.versionSelect = new("DropDownControl", { "LEFT", self.controls.versionText, "RIGHT" }, 8, 0, 55, 20, self.treeVersions, function(index, value)
if value ~= self.build.spec.treeVersion then
convertToVersion(value:gsub("%.", "_"))
end
end)
self.controls.versionSelect.maxDroppedWidth = 1000
self.controls.versionSelect.enableDroppedWidth = true
self.controls.versionSelect.enableChangeBoxWidth = true
self.controls.versionSelect.selIndex = #self.treeVersions
self.controls.treeSearch = new("EditControl", { "LEFT", self.controls.versionSelect, "RIGHT" }, 8, 0, main.portraitMode and 200 or 300, 20, "", "Search", "%c", 100, function(buf)
self.viewer.searchStr = buf
self.searchFlag = buf ~= self.viewer.searchStrSaved
end)
Expand Down Expand Up @@ -172,15 +200,7 @@ local TreeTabClass = newClass("TreeTab", "ControlHost", function(self, build)
return self.showConvert
end
self.controls.specConvert = new("ButtonControl", { "LEFT", self.controls.specConvertText, "RIGHT" }, 8, 0, 120, 20, "^2Convert to "..treeVersions[latestTreeVersion].display, function()
local newSpec = new("PassiveSpec", self.build, latestTreeVersion, true)
newSpec.title = self.build.spec.title
newSpec.jewels = copyTable(self.build.spec.jewels)
newSpec:RestoreUndoState(self.build.spec:CreateUndoState(), latestTreeVersion)
newSpec:BuildClusterJewelGraphs()
t_insert(self.specList, self.activeSpec + 1, newSpec)
self:SetActiveSpec(self.activeSpec + 1)
self.modFlag = true
main:OpenMessagePopup("Tree Converted", "The tree has been converted to "..treeVersions[latestTreeVersion].display..".\nNote that some or all of the passives may have been de-allocated due to changes in the tree.\n\nYou can switch back to the old tree using the tree selector at the bottom left.")
convertToVersion(latestTreeVersion)
end)
self.jumpToNode = false
self.jumpToX = 0
Expand Down

0 comments on commit 9b3ae13

Please sign in to comment.