Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
LocalIdentity committed Sep 30, 2020
2 parents b63fd01 + c2ef02d commit 7a1f9cc
Show file tree
Hide file tree
Showing 18 changed files with 2,777 additions and 2,524 deletions.
24 changes: 23 additions & 1 deletion Classes/CalcsTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,29 @@ function CalcsTabClass:PowerBuilder()
coroutine.yield()
start = GetTime()
end
end
end

-- Calculate the impact of every cluster notable
-- used for the power report screen
for nodeName, node in pairs(self.build.spec.tree.clusterNodeMap) do
if not node.power then
node.power = {}
end
wipeTable(node.power)
if not node.alloc and node.modKey ~= "" and not self.mainEnv.grantedPassives[nodeId] then
if not cache[node.modKey] then
cache[node.modKey] = calcFunc({ addNodes = { [node] = true } })
end
local output = cache[node.modKey]
if self.powerStat and self.powerStat.stat and not self.powerStat.ignoreForNodes then
node.power.singleStat = self:CalculatePowerStat(self.powerStat, output, calcBase)
end
end
if coroutine.running() and GetTime() - start > 100 then
coroutine.yield()
start = GetTime()
end
end
self.powerMax = newPowerMax
end

Expand Down
20 changes: 2 additions & 18 deletions Classes/ImportTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -788,22 +788,6 @@ function ImportTabClass:ImportItem(itemData, slotName)
end


-- parse real gem name by ommiting the first word if alt qual is set
function ImportTabClass:GetBaseNameAndQuality(gemTypeLine)
if gemTypeLine then
local firstword, otherwords = gemTypeLine:match("(%w+)%s(.+)")
if firstword and otherwords then
for indx, entry in ipairs(self.build.skillsTab.getAlternateGemQualityList()) do
if firstword == entry.label then
return otherwords, entry.type
end
end
end
end

return gemTypeLine, "Default"
end

function ImportTabClass:ImportSocketedItems(item, socketedItems, slotName)
-- Build socket group list
local itemSocketGroupList = { }
Expand All @@ -813,12 +797,12 @@ function ImportTabClass:ImportSocketedItems(item, socketedItems, slotName)
self:ImportItem(socketedItem, slotName .. " Abyssal Socket "..abyssalSocketId)
abyssalSocketId = abyssalSocketId + 1
else
local normalizedBasename, qualityType = self:GetBaseNameAndQuality(socketedItem.typeLine)
local normalizedBasename, qualityType = self.build.skillsTab:GetBaseNameAndQuality(socketedItem.typeLine)
local gemId = self.build.data.gemForBaseName[normalizedBasename]
if not gemId and socketedItem.hybrid then
-- Dual skill gems (currently just Stormbind) show the second skill as the typeLine, which won't match the actual gem
-- Luckily the primary skill name is also there, so we can find the gem using that
normalizedBasename, qualityType = self:GetBaseNameAndQuality(socketedItem.hybrid.baseTypeName)
normalizedBasename, qualityType = self.build.skillsTab:GetBaseNameAndQuality(socketedItem.hybrid.baseTypeName)
gemId = self.build.data.gemForBaseName[normalizedBasename]
end
if gemId then
Expand Down
106 changes: 102 additions & 4 deletions Classes/PowerReportListControl.lua
Original file line number Diff line number Diff line change
@@ -1,16 +1,108 @@
-- Path of Building
--
-- Class: Power Report
-- Power Report control.
--

local t_insert = table.insert
local t_remove = table.remove
local t_sort = table.sort

local PowerReportListClass = newClass("PowerReportListControl", "ListControl", function(self, anchor, x, y, width, height, report, powerLabel, nodeSelectCallback)
self.ListControl(anchor, x, y, width, height, 20, false, false, report)

self.originalList = report

self.ListControl(anchor, 0, 75, width, height-50, 20, false, false, self:ReList())

self.colList = {
{ width = width * 0.2, label = "Type" },
{ width = width * 0.55, label = "Node Name" },
{ width = width * 0.2, label = powerLabel }
{ width = width * 0.15, label = "Type" },
{ width = width * 0.50, label = "Node Name" },
{ width = width * 0.18, label = powerLabel },
{ width = width * 0.12, label = "Distance" }
}
self.label = "Click to focus node on tree"
self.colLabels = true
self.nodeSelectCallback = nodeSelectCallback
self.showClusters = false
self.onlyNotables = false

self.controls.showClusters = new("CheckBoxControl", {"BOTTOMRIGHT",self,"TOPRIGHT"}, 0, -2, 18, "Show Clusters:", function(state)
self.showClusters = state
self:ReList()
self:ReSort()
end, "Show Cluster Jewel Notables")
self.controls.onlyNotables = new("CheckBoxControl", {"BOTTOMRIGHT", self.controls.showClusters, "TOPRIGHT"}, 0, 0, 18, "Only Notables:", function(state)
self.onlyNotables = state
self:ReList()
self:ReSort()
end)

self.controls.sortLabel = new("LabelControl", {"BOTTOMLEFT", self, "TOPLEFT"}, 0, -22, 0, 16, "^7Sort by:")
self.controls.sortBy = new("DropDownControl", {"LEFT", self.controls.sortLabel, "RIGHT"}, 5, 0, 150, 20, {powerLabel, "Distance"}, function(sel)
self:ReSort()
end)

end)

function PowerReportListClass:ReSort()
if (self.controls.sortBy.selIndex == 1) then
t_sort(self.list, function (a,b)
return (a.power) > (b.power)
end)
elseif (self.controls.sortBy.selIndex == 2) then
t_sort(self.list, function (a,b)
if (a.pathDist == "Anoint") or (a.pathDist == "Cluster") then
return false
end
if (b.pathDist == "Anoint") or (b.pathDist == "Cluster") then
return true
end
if (a.pathDist == b.pathDist) then
return (a.power) > (b.power)
end
return (a.pathDist) < (b.pathDist)
end)
end
end

function PowerReportListClass:ReList()
local filteredList = { }
local iterate = 1
local insert = true

while(true) do

if (self.originalList[iterate].power <= 0) then
insert = false
end
if (not self.showClusters) and (self.originalList[iterate].pathDist == "Cluster") then
insert = false
end
if (self.onlyNotables) and (self.originalList[iterate].type ~= "Notable") then
insert = false
end

if insert then
t_insert(filteredList, self.originalList[iterate])
end

iterate = iterate + 1
insert = true

if iterate > #self.originalList then
break
end
end

if (next(filteredList)) then
self.list = filteredList
return filteredList
else
self.list = self.originalList
return self.originalList
end
end

function PowerReportListClass:OnSelClick(index, report, doubleClick)
if self.nodeSelectCallback then
self.nodeSelectCallback(report)
Expand All @@ -24,6 +116,12 @@ function PowerReportListClass:GetRowValue(column, index, report)
return report.name
elseif column == 3 then
return report.powerStr
elseif column == 4 then
if report.pathDist == 1000 then
return "Anoint"
else
return report.pathDist
end
else
return ""
end
Expand Down
34 changes: 13 additions & 21 deletions Classes/SkillsTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -158,29 +158,20 @@ will automatically apply to the skill.]]
self.controls.gemEnableHeader = new("LabelControl", {"BOTTOMLEFT",self.gemSlots[1].enabled,"TOPLEFT"}, -16, -2, 0, 16, "^7Enabled:")
end)

-- parse alt qual from existing quality list
function SkillsTabClass:ParseGemAltQuality(gemName, qualityId)
if qualityId then
return qualityId
end if gemName then
for indx, entry in ipairs(alternateGemQualityList) do
if gemName:sub(1, #entry.label) == entry.label then
return entry.type
-- parse real gem name and quality by ommiting the first word if alt qual is set
function SkillsTabClass:GetBaseNameAndQuality(gemTypeLine)
if gemTypeLine then
local firstword, otherwords = gemTypeLine:match("(%w+)%s(.+)")
if firstword and otherwords then
for indx, entry in ipairs(alternateGemQualityList) do
if firstword == entry.label then
return otherwords, entry.type
end
end
end
end
return "Default"
end

-- parse real gem name by ommiting the first word if alt qual is set
function SkillsTabClass:ParseBaseGemName(gemInstance)
if gemInstance.qualityId and gemInstance.nameSpec then
_, gemName = gemInstance.nameSpec:match("(%w+)%s(.+)")
if gemName then
return gemName
end
end
return gemInstance.nameSpec
return gemTypeLine, "Default"
end

function SkillsTabClass:Load(xml, fileName)
Expand Down Expand Up @@ -226,8 +217,9 @@ function SkillsTabClass:Load(xml, fileName)
end
gemInstance.level = tonumber(child.attrib.level)
gemInstance.quality = tonumber(child.attrib.quality)
gemInstance.qualityId = SkillsTabClass:ParseGemAltQuality(gemInstance.nameSpec, child.attrib.qualityId)
gemInstance.nameSpec = SkillsTabClass:ParseBaseGemName(gemInstance)
local nameSpecOverride, qualityOverrideId = SkillsTabClass:GetBaseNameAndQuality(gemInstance.nameSpec)
gemInstance.nameSpec=nameSpecOverride
gemInstance.qualityId=qualityOverrideId

if gemInstance.gemData then
gemInstance.qualityId.list = self:getGemAltQualityList(gemInstance.gemData)
Expand Down
52 changes: 43 additions & 9 deletions Classes/TreeTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
local ipairs = ipairs
local t_insert = table.insert
local t_sort = table.sort
local m_max = math.max
local m_min = math.min
local m_floor = math.floor
local s_format = string.format

local TreeTabClass = newClass("TreeTab", "ControlHost", function(self, build)
Expand Down Expand Up @@ -623,10 +625,39 @@ function TreeTabClass:ShowPowerReport()
name = node.dn,
power = nodePower,
powerStr = nodePowerStr,
id = nodeId,
id = node.id,
x = node.x,
y = node.y,
type = node.type
type = node.type,
pathDist = node.pathDist
})
end
end

-- search all cluster notables and add to the list
for nodeName, node in pairs(self.build.spec.tree.clusterNodeMap) do
local isAlloc = node.alloc
if not isAlloc then
local nodePower = (node.power.singleStat or 0) * ((displayStat.pc or displayStat.mod) and 100 or 1)
local nodePowerStr = s_format("%"..displayStat.fmt, nodePower)

if main.showThousandsCalcs then
nodePowerStr = formatNumSep(nodePowerStr)
end

if (nodePower > 0 and not displayStat.lowerIsBetter) or (nodePower < 0 and displayStat.lowerIsBetter) then
nodePowerStr = colorCodes.POSITIVE .. nodePowerStr
elseif (nodePower < 0 and not displayStat.lowerIsBetter) or (nodePower > 0 and displayStat.lowerIsBetter) then
nodePowerStr = colorCodes.NEGATIVE .. nodePowerStr
end

t_insert(report, {
name = node.dn,
power = nodePower,
powerStr = nodePowerStr,
id = node.id,
type = node.type,
pathDist = "Cluster"
})
end
end
Expand All @@ -644,17 +675,20 @@ function TreeTabClass:ShowPowerReport()

-- present the UI
local controls = {}
controls.list = new("PowerReportListControl", nil, 0, 40, 450, 400, report, currentStatLabel, function(selectedNode)
controls.powerReport = new("PowerReportListControl", nil, 0, 0, 550, 450, report, currentStatLabel, function(selectedNode)
-- this code is called by the list control when the user "selects" one of the passives in the list.
-- we use this to set a flag which causes the next Draw() to recenter the passive tree on the desired node.
self.jumpToNode = true
self.jumpToX = selectedNode.x
self.jumpToY = selectedNode.y
main:ClosePopup()
if(selectedNode.x) then
self.jumpToNode = true
self.jumpToX = selectedNode.x
self.jumpToY = selectedNode.y
main:ClosePopup()
end
end)
controls.done = new("ButtonControl", nil, 0, 450, 100, 20, "Close", function()

controls.done = new("ButtonControl", nil, 0, 490, 100, 20, "Close", function()
main:ClosePopup()
end)

popup = main:OpenPopup(500, 500, "Power Report: " .. currentStatLabel, controls, "done", "list")
popup = main:OpenPopup(600, 500, "Power Report: " .. currentStatLabel, controls, "done", "list")
end
Loading

0 comments on commit 7a1f9cc

Please sign in to comment.