Skip to content
Merged
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
21 changes: 21 additions & 0 deletions spec/System/TestPassiveSpec_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,27 @@ describe("TestPassiveSpec", function()
assert.is_true(ok, err)
end)

it("remaps legacy class ids only for trees before 0.4", function()
local function loadClass(treeVersion, classId)
local spec = new("PassiveSpec", build, latestTreeVersion)
spec.treeVersion = treeVersion
spec:Load({
attrib = {
title = "Legacy Class Test",
classId = tostring(classId),
ascendClassId = "0",
nodes = "",
}
}, "legacy_class.xml")
return spec.curClassName
end

assert.are.equals("Witch", loadClass("0_1", 3))
assert.are.equals("Huntress", loadClass("0_2", 1))
assert.are.equals("Monk", loadClass("0_3", 6))
assert.are.equals("Witch", loadClass("0_4", 1))
end)

local function allocNode(spec, nodeId, allocMode)
local node = spec.nodes[nodeId]
spec.allocMode = allocMode
Expand Down
10 changes: 9 additions & 1 deletion src/Classes/PassiveSpec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ local b_rshift = bit.rshift
local band = AND64 -- bit.band
local bor = OR64 -- bit.bor

local legacyClassIdMap = {
["0_1"] = { [0] = 2, [1] = 6, [2] = 9, [3] = 1, [4] = 7, [5] = 10 },
["0_2"] = { [0] = 2, [1] = 8, [2] = 6, [3] = 9, [4] = 1, [5] = 7, [6] = 10 },
["0_3"] = { [0] = 2, [1] = 8, [2] = 6, [3] = 9, [4] = 1, [5] = 7, [6] = 10 },
}

local PassiveSpecClass = newClass("PassiveSpec", "UndoHandler", function(self, build, treeVersion, convert)
self.UndoHandler()

Expand All @@ -24,7 +30,7 @@ local PassiveSpecClass = newClass("PassiveSpec", "UndoHandler", function(self, b
-- Initialise and build all tables
self:Init(treeVersion, convert)

self:SelectClass(0)
self:SelectClass(self.tree.constants.classes.DexClass)
end)

function PassiveSpecClass:Init(treeVersion, convert)
Expand Down Expand Up @@ -157,6 +163,8 @@ function PassiveSpecClass:Load(xml, dbFileName)
if self.tree.classIntegerIdMap[classInternalId] then
classId = self.tree.classIntegerIdMap[classInternalId]
end
elseif classId ~= -1 and legacyClassIdMap[self.treeVersion] then
classId = legacyClassIdMap[self.treeVersion][classId] or classId
end
if xml.attrib.ascendancyInternalId then
local ascendancyInternalId = tostring(xml.attrib.ascendancyInternalId)
Expand Down
47 changes: 41 additions & 6 deletions src/Classes/PassiveTree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,11 @@ local PassiveTreeClass = newClass("PassiveTree", function(self, treeVersion)

self.size = m_min(self.max_x - self.min_x, self.max_y - self.min_y) * self.scaleImage * 1.1

for i = 0, 6 do
self.classes[i] = self.classes[i + 1]
self.classes[i + 1] = nil
local classes = { }
for _, class in pairs(self.classes) do
classes[class.integerId] = class
end
self.classes = classes

-- Build maps of class name -> class table
self.classNameMap = { }
Expand Down Expand Up @@ -119,6 +120,7 @@ local PassiveTreeClass = newClass("PassiveTree", function(self, treeVersion)
self.orbitAnglesByOrbit = self.constants.orbitAnglesByOrbit

ConPrintf("Loading passive tree assets...")
self.assets = self.assets or {}
for name, data in pairs(self.assets) do
self:LoadImage(data[1], data, "MIPMAP")
end
Expand All @@ -139,6 +141,25 @@ local PassiveTreeClass = newClass("PassiveTree", function(self, treeVersion)
end
end

self.spriteMap = { }
self.spriteCoords = self.spriteCoords or {}
for file, fileInfo in pairs(self.spriteCoords) do
local data = { }
self:LoadImage(file, data, "CLAMP")
for name, coords in pairs(fileInfo) do
self.spriteMap[name] = {
found = data.width > 0,
handle = data.handle,
width = coords.w,
height = coords.h,
[1] = coords.x / data.width,
[2] = coords.y / data.height,
[3] = (coords.x + coords.w) / data.width,
[4] = (coords.y + coords.h) / data.height
}
end
end

for type, data in pairs(self.nodeOverlay) do
local asset = self:GetAssetByName(data.alloc)
local artWidth = asset.width * self.scaleImage
Expand Down Expand Up @@ -172,7 +193,7 @@ local PassiveTreeClass = newClass("PassiveTree", function(self, treeVersion)
node.o = node.orbit
node.oidx = node.orbitIndex
node.dn = node.name
node.sd = node.stats
node.sd = node.stats or {}

node.__index = node
node.linkedId = { }
Expand Down Expand Up @@ -241,6 +262,14 @@ local PassiveTreeClass = newClass("PassiveTree", function(self, treeVersion)
end
end

if node.aliasPassiveSocket then
local aliasPassiveSocket = node.aliasPassiveSocket:lower()
if self.notableMap[aliasPassiveSocket] then
ConPrintf("Warning: aliasPassiveSocket '"..node.aliasPassiveSocket.."' for node '"..node.dn.."' is already used by notable '"..self.notableMap[aliasPassiveSocket].dn.."'.")
end
self.notableMap[aliasPassiveSocket] = node
end

-- Find the node group
local group = self.groups[node.g]
if group then
Expand Down Expand Up @@ -304,7 +333,7 @@ local PassiveTreeClass = newClass("PassiveTree", function(self, treeVersion)
for nodeId, socket in pairs(self.sockets) do
if socket.name == "Charm Socket" then
socket.charmSocket = true
elseif not socket.containJewelSocket then
elseif not socket.containJewelSocket and not socket.noRadius then
socket.nodesInRadius = { }
socket.attributesInRadius = { }
for radiusIndex, _ in ipairs(data.jewelRadius) do
Expand Down Expand Up @@ -741,8 +770,14 @@ function PassiveTreeClass:CalcOrbitAngles(nodesInOrbit)
return orbitAngles
end

local alreadyAlertMissingAssetName = {}
function PassiveTreeClass:GetAssetByName(name, type)
return self.ddsMap[name] or self.assets[name]
local assetData = self.ddsMap[name] or self.assets[name] or self.spriteMap[name]
if not assetData and not alreadyAlertMissingAssetName[name] then
alreadyAlertMissingAssetName[name] = true
ConPrintf("missing asset with name " .. name)
end
return assetData
end

function PassiveTreeClass:GetNodeTargetSize(node)
Expand Down
19 changes: 16 additions & 3 deletions src/Classes/PassiveTreeView.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,7 @@ function PassiveTreeViewClass:Draw(build, viewPort, inputEvents)
SetDrawLayer(nil, 25)
for nodeId in pairs(tree.sockets) do
local node = spec.nodes[nodeId]
if node and node.name ~= "Charm Socket" and node.containJewelSocket ~= true and (not node.expansionJewel or node.expansionJewel.size == 2) then
if node and node.name ~= "Charm Socket" and node.containJewelSocket ~= true and (not node.expansionJewel or node.expansionJewel.size == 2) and (not node.noRadius) then
local scrX, scrY = treeToScreen(node.x, node.y)
local socket, jewel = build.itemsTab:GetSocketAndJewelForNodeID(nodeId)
local compareNode = self.compareSpec and self.compareSpec.nodes[nodeId] or nil
Expand Down Expand Up @@ -1391,7 +1391,20 @@ function PassiveTreeViewClass:DrawQuadAndRotate(data, xTree, yTree, angleRad, tr
vertActive[3], vertActive[4] = xActive + widthActive, yActive - heightActive
vertActive[5], vertActive[6] = xActive + widthActive, yActive + heightActive
vertActive[7], vertActive[8] = xActive - widthActive, yActive + heightActive
vertActive[9] = data[1] -- s1

local lengthData = #data
if lengthData == 1 then
vertActive[9] = data[1] -- s1 (stack)
elseif lengthData == 4 then
vertActive[9], vertActive[10] = data[1], data[2] -- top-left
vertActive[11], vertActive[12] = data[3], data[2] -- top-right
vertActive[13], vertActive[14] = data[3], data[4] -- bottom-right
vertActive[15], vertActive[16] = data[1], data[4] -- bottom-left
else
for iData, vData in ipairs(data) do
vertActive[9 + (iData - 1)] = vData
end
end

-- rotate the quad
vertActive[1], vertActive[2] = treeToScreen(rotate(vertActive[1], vertActive[2], xActive, yActive, angleRad))
Expand Down Expand Up @@ -1499,7 +1512,7 @@ function PassiveTreeViewClass:DoesNodeMatchSearchParams(node)
end

-- Check unlock ascendancy
if node.unlockConstraint then
if node.unlockConstraint and node.unlockConstraint.ascendancy then
err, needMatches = PCall(search, node.unlockConstraint.ascendancy:lower(), needMatches)
if err then return false end
if #needMatches == 0 then
Expand Down
Loading
Loading