Skip to content

Commit 37751c5

Browse files
DoubtinGiyovWires77
authored andcommitted
Added the ability to custom change max node depth for heat map (#446)
* Added the ability to change max node depth for heat map calculation to a custom value * Fixed visibility of controls on TreeTab at minimum screen width
1 parent ce92033 commit 37751c5

File tree

1 file changed

+65
-13
lines changed

1 file changed

+65
-13
lines changed

src/Classes/TreeTab.lua

Lines changed: 65 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ local TreeTabClass = newClass("TreeTab", "ControlHost", function(self, build)
2424

2525
self.build = build
2626
self.isComparing = false;
27+
self.isCustomMaxDepth = false;
2728

2829
self.viewer = new("PassiveTreeView")
2930

@@ -188,7 +189,20 @@ local TreeTabClass = newClass("TreeTab", "ControlHost", function(self, build)
188189
end)
189190

190191
-- Control for setting max node depth to limit calculation time of the heat map
191-
self.controls.nodePowerMaxDepthSelect = new("DropDownControl", { "LEFT", self.controls.treeHeatMap, "RIGHT" }, { 8, 0, 50, 20 }, { "All", 5, 10, 15 }, function(index, value)
192+
self.controls.nodePowerMaxDepthSelect = new("DropDownControl", { "LEFT", self.controls.treeHeatMap, "RIGHT" }, { 8, 0, 55, 20 }, { "All", 5, 10, 15, "Custom" }, function(index, value)
193+
-- Show custom value control and resize/move elements
194+
self.isCustomMaxDepth = value == "Custom"
195+
if self.isCustomMaxDepth then
196+
self.controls.nodePowerMaxDepthSelect.width = 70
197+
self.controls.nodePowerMaxDepthCustom.shown = true
198+
self.controls.treeHeatMapStatSelect:SetAnchor("LEFT", self.controls.nodePowerMaxDepthCustom, "RIGHT", nil, nil, nil)
199+
return
200+
end
201+
202+
self.controls.nodePowerMaxDepthSelect.width = 55
203+
self.controls.nodePowerMaxDepthCustom.shown = false
204+
self.controls.treeHeatMapStatSelect:SetAnchor("LEFT", self.controls.nodePowerMaxDepthSelect, "RIGHT", nil, nil, nil)
205+
192206
local oldMax = self.build.calcsTab.nodePowerMaxDepth
193207

194208
if type(value) == "number" then
@@ -207,6 +221,17 @@ local TreeTabClass = newClass("TreeTab", "ControlHost", function(self, build)
207221
end)
208222
self.controls.nodePowerMaxDepthSelect.tooltipText = "Limit of Node distance to search (lower = faster)"
209223

224+
-- Control for setting max node depth by custom value
225+
self.controls.nodePowerMaxDepthCustom = new("EditControl", { "LEFT", self.controls.nodePowerMaxDepthSelect, "RIGHT" }, { 8, 0, 70, 20 }, "0", nil, "%D", nil, function(value)
226+
self.build.calcsTab.nodePowerMaxDepth = tonumber(value)
227+
228+
-- If the heat map is shown, recalculate it with new value
229+
if self.viewer.showHeatMap then
230+
self:SetPowerCalc(self.build.calcsTab.powerStat)
231+
end
232+
end)
233+
self.controls.nodePowerMaxDepthCustom.shown = false
234+
210235
-- Control for selecting the power stat to sort by (Defense, DPS, etc)
211236
self.controls.treeHeatMapStatSelect = new("DropDownControl", { "LEFT", self.controls.nodePowerMaxDepthSelect, "RIGHT" }, { 8, 0, 150, 20 }, nil, function(index, value)
212237
self:SetPowerCalc(value)
@@ -314,15 +339,42 @@ function TreeTabClass:Draw(viewPort, inputEvents)
314339
self:ProcessControlsInput(inputEvents, viewPort)
315340

316341
-- Determine positions if one line of controls doesn't fit in the screen width
317-
local twoLineHeight = 24
318-
if viewPort.width >= 1336 + (self.isComparing and 198 or 0) + (self.viewer.showHeatMap and 316 or 0) then
319-
twoLineHeight = 0
342+
local linesHeight = 24
343+
local rightMargin = 10
344+
local widthFirstLineControls = self.controls.specSelect.width + 8
345+
+ self.controls.compareCheck.width + self.controls.compareCheck.x
346+
+ self.controls.reset.width + self.controls.reset.x
347+
+ self.controls.versionText.width() + self.controls.versionText.x
348+
+ self.controls.versionSelect.width + self.controls.versionSelect.x
349+
+ (self.isComparing and (self.controls.compareSelect.width + self.controls.compareSelect.x) or 0)
350+
351+
local widthSecondLineControls = self.controls.treeSearch.width + 8
352+
+ self.controls.findTimelessJewel.width + self.controls.findTimelessJewel.x
353+
+ self.controls.treeHeatMap.width + 130
354+
+ self.controls.nodePowerMaxDepthSelect.width + self.controls.nodePowerMaxDepthSelect.x
355+
+ (self.isCustomMaxDepth and (self.controls.nodePowerMaxDepthCustom.width + self.controls.nodePowerMaxDepthCustom.x) or 0)
356+
+ (self.viewer.showHeatMap and (self.controls.treeHeatMapStatSelect.width + self.controls.treeHeatMapStatSelect.x
357+
+ self.controls.powerReport.width + self.controls.powerReport.x) or 0)
358+
359+
-- Check first line
360+
if viewPort.width >= widthFirstLineControls + widthSecondLineControls + rightMargin then
361+
linesHeight = 0
320362
self.controls.treeSearch:SetAnchor("LEFT", self.controls.versionSelect, "RIGHT", 8, 0)
321-
self.controls.powerReportList:SetAnchor("TOPLEFT", self.controls.specSelect, "BOTTOMLEFT", 0, self.controls.specSelect.height + 4)
363+
self.controls.powerReportList:SetAnchor("TOPLEFT", self.controls.specSelect, "BOTTOMLEFT", 0, self.controls.specSelect.height + 6)
322364
else
323365
self.controls.treeSearch:SetAnchor("TOPLEFT", self.controls.specSelect, "BOTTOMLEFT", 0, 4)
324-
self.controls.powerReportList:SetAnchor("TOPLEFT", self.controls.treeSearch, "BOTTOMLEFT", 0, self.controls.treeHeatMap.y + self.controls.treeHeatMap.height + 4)
366+
self.controls.powerReportList:SetAnchor("TOPLEFT", self.controls.treeSearch, "BOTTOMLEFT", 0, self.controls.treeSearch.height + 6)
325367
end
368+
369+
-- Check second line
370+
if viewPort.width >= widthSecondLineControls + rightMargin then
371+
self.controls.treeHeatMap:SetAnchor("LEFT", self.controls.findTimelessJewel, "RIGHT", 130, 0)
372+
else
373+
linesHeight = linesHeight * 2
374+
self.controls.treeHeatMap:SetAnchor("TOPLEFT", self.controls.treeSearch, "BOTTOMLEFT", 124, 4)
375+
self.controls.powerReportList:SetAnchor("TOPLEFT", self.controls.treeHeatMap, "BOTTOMLEFT", -124, self.controls.treeHeatMap.height + 6)
376+
end
377+
326378
-- determine positions for convert line of controls
327379
local convertTwoLineHeight = 24
328380
local convertMaxWidth = 900
@@ -336,9 +388,9 @@ function TreeTabClass:Draw(viewPort, inputEvents)
336388
end
337389

338390
local bottomDrawerHeight = self.controls.powerReportList.shown and 194 or 0
339-
self.controls.specSelect.y = -bottomDrawerHeight - twoLineHeight
391+
self.controls.specSelect.y = -bottomDrawerHeight - linesHeight
340392

341-
local treeViewPort = { x = viewPort.x, y = viewPort.y, width = viewPort.width, height = viewPort.height - (self.showConvert and 64 + bottomDrawerHeight + twoLineHeight or 32 + bottomDrawerHeight + twoLineHeight)}
393+
local treeViewPort = { x = viewPort.x, y = viewPort.y, width = viewPort.width, height = viewPort.height - (self.showConvert and 64 + bottomDrawerHeight + linesHeight or 32 + bottomDrawerHeight + linesHeight)}
342394
if self.jumpToNode then
343395
self.viewer:Focus(self.jumpToX, self.jumpToY, treeViewPort, self.build)
344396
self.jumpToNode = false
@@ -369,17 +421,17 @@ function TreeTabClass:Draw(viewPort, inputEvents)
369421
SetDrawLayer(1)
370422

371423
SetDrawColor(0.05, 0.05, 0.05)
372-
DrawImage(nil, viewPort.x, viewPort.y + viewPort.height - (28 + bottomDrawerHeight + twoLineHeight), viewPort.width, 28 + bottomDrawerHeight + twoLineHeight)
424+
DrawImage(nil, viewPort.x, viewPort.y + viewPort.height - (28 + bottomDrawerHeight + linesHeight), viewPort.width, 28 + bottomDrawerHeight + linesHeight)
373425
if self.showConvert then
374-
local height = viewPort.width < convertMaxWidth and (bottomDrawerHeight + twoLineHeight) or 0
426+
local height = viewPort.width < convertMaxWidth and (bottomDrawerHeight + linesHeight) or 0
375427
SetDrawColor(0.05, 0.05, 0.05)
376-
DrawImage(nil, viewPort.x, viewPort.y + viewPort.height - (60 + bottomDrawerHeight + twoLineHeight + convertTwoLineHeight), viewPort.width, 28 + height)
428+
DrawImage(nil, viewPort.x, viewPort.y + viewPort.height - (60 + bottomDrawerHeight + linesHeight + convertTwoLineHeight), viewPort.width, 28 + height)
377429
SetDrawColor(0.85, 0.85, 0.85)
378-
DrawImage(nil, viewPort.x, viewPort.y + viewPort.height - (64 + bottomDrawerHeight + twoLineHeight + convertTwoLineHeight), viewPort.width, 4)
430+
DrawImage(nil, viewPort.x, viewPort.y + viewPort.height - (64 + bottomDrawerHeight + linesHeight + convertTwoLineHeight), viewPort.width, 4)
379431
end
380432
-- let white lines overwrite the black sections, regardless of showConvert
381433
SetDrawColor(0.85, 0.85, 0.85)
382-
DrawImage(nil, viewPort.x, viewPort.y + viewPort.height - (32 + bottomDrawerHeight + twoLineHeight), viewPort.width, 4)
434+
DrawImage(nil, viewPort.x, viewPort.y + viewPort.height - (32 + bottomDrawerHeight + linesHeight), viewPort.width, 4)
383435

384436
self:DrawControls(viewPort)
385437
end

0 commit comments

Comments
 (0)