Skip to content

Commit d31ce1d

Browse files
author
justjuangui
committed
Passive tree parser from ggg web data
1 parent 6694a55 commit d31ce1d

109 files changed

Lines changed: 127756 additions & 4 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/Classes/PassiveTree.lua

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ local PassiveTreeClass = newClass("PassiveTree", function(self, treeVersion)
119119
self.orbitAnglesByOrbit = self.constants.orbitAnglesByOrbit
120120

121121
ConPrintf("Loading passive tree assets...")
122+
self.assets = self.assets or {}
122123
for name, data in pairs(self.assets) do
123124
self:LoadImage(data[1], data, "MIPMAP")
124125
end
@@ -139,6 +140,25 @@ local PassiveTreeClass = newClass("PassiveTree", function(self, treeVersion)
139140
end
140141
end
141142

143+
self.spriteMap = { }
144+
self.spriteCoords = self.spriteCoords or {}
145+
for file, fileInfo in pairs(self.spriteCoords) do
146+
local data = { }
147+
self:LoadImage(file, data, "CLAMP")
148+
for name, coords in pairs(fileInfo) do
149+
self.spriteMap[name] = {
150+
found = data.width > 0,
151+
handle = data.handle,
152+
width = coords.w,
153+
height = coords.h,
154+
[1] = coords.x / data.width,
155+
[2] = coords.y / data.height,
156+
[3] = (coords.x + coords.w) / data.width,
157+
[4] = (coords.y + coords.h) / data.height
158+
}
159+
end
160+
end
161+
142162
for type, data in pairs(self.nodeOverlay) do
143163
local asset = self:GetAssetByName(data.alloc)
144164
local artWidth = asset.width * self.scaleImage
@@ -741,8 +761,14 @@ function PassiveTreeClass:CalcOrbitAngles(nodesInOrbit)
741761
return orbitAngles
742762
end
743763

764+
local alreadyAlertMissingAssetName = {}
744765
function PassiveTreeClass:GetAssetByName(name, type)
745-
return self.ddsMap[name] or self.assets[name]
766+
local assetData = self.ddsMap[name] or self.assets[name] or self.spriteMap[name]
767+
if not assetData and not alreadyAlertMissingAssetName[name] then
768+
alreadyAlertMissingAssetName[name] = true
769+
ConPrintf("missing asset with name " .. name)
770+
end
771+
return assetData
746772
end
747773

748774
function PassiveTreeClass:GetNodeTargetSize(node)

src/Classes/PassiveTreeView.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ function PassiveTreeViewClass:Draw(build, viewPort, inputEvents)
604604
local angleRad = (math.pi / 2) + math.atan2(startNode.y - yActive, startNode.x - xActive)
605605
treeCenterActive.width = class.background['active'].width
606606
treeCenterActive.height = class.background['active'].height
607-
self:DrawQuadAndRotate(treeCenterActive, class.background.x * tree.scaleImage, class.background.y * tree.scaleImage, angleRad, treeToScreen)
607+
-- self:DrawQuadAndRotate(treeCenterActive, class.background.x * tree.scaleImage, class.background.y * tree.scaleImage, angleRad, treeToScreen)
608608

609609
treeCenter.width = class.background['bg'].width
610610
treeCenter.height = class.background['bg'].height
@@ -1361,7 +1361,9 @@ function PassiveTreeViewClass:DrawQuadAndRotate(data, xTree, yTree, angleRad, tr
13611361
vertActive[3], vertActive[4] = xActive + widthActive, yActive - heightActive
13621362
vertActive[5], vertActive[6] = xActive + widthActive, yActive + heightActive
13631363
vertActive[7], vertActive[8] = xActive - widthActive, yActive + heightActive
1364-
vertActive[9] = data[1] -- s1
1364+
for iData, vData in ipairs(data) do
1365+
vertActive[9 + (iData - 1)] = vData -- s1
1366+
end
13651367

13661368
-- rotate the quad
13671369
vertActive[1], vertActive[2] = treeToScreen(rotate(vertActive[1], vertActive[2], xActive, yActive, angleRad))

0 commit comments

Comments
 (0)