Skip to content

Commit 2adf8c6

Browse files
committed
color code summary, add name for imported build, add item hover tooltips
1 parent 6cb89ae commit 2adf8c6

2 files changed

Lines changed: 515 additions & 87 deletions

File tree

src/Classes/CompareEntry.lua

Lines changed: 159 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
-- without setting up the full UI chrome of the primary build.
66
--
77
local t_insert = table.insert
8+
local s_format = string.format
89
local m_min = math.min
910
local m_max = math.max
1011

@@ -235,8 +236,125 @@ function CompareEntryClass:RefreshStatList()
235236
-- No sidebar to refresh in comparison entry
236237
end
237238

238-
function CompareEntryClass:RefreshSkillSelectControls()
239-
-- No skill select controls in comparison entry
239+
function CompareEntryClass:SetMainSocketGroup(index)
240+
self.mainSocketGroup = index
241+
self.modFlag = true
242+
self.buildFlag = true
243+
end
244+
245+
function CompareEntryClass:RefreshSkillSelectControls(controls, mainGroup, suffix)
246+
-- Populate skill select controls (adapted from Build.lua:RefreshSkillSelectControls, lines 1444-1542)
247+
if not controls or not controls.mainSocketGroup then return end
248+
controls.mainSocketGroup.selIndex = mainGroup
249+
wipeTable(controls.mainSocketGroup.list)
250+
for i, socketGroup in pairs(self.skillsTab.socketGroupList) do
251+
controls.mainSocketGroup.list[i] = { val = i, label = socketGroup.displayLabel }
252+
end
253+
controls.mainSocketGroup:CheckDroppedWidth(true)
254+
if #controls.mainSocketGroup.list == 0 then
255+
controls.mainSocketGroup.list[1] = { val = 1, label = "<No skills added yet>" }
256+
controls.mainSkill.shown = false
257+
controls.mainSkillPart.shown = false
258+
controls.mainSkillMineCount.shown = false
259+
controls.mainSkillStageCount.shown = false
260+
controls.mainSkillMinion.shown = false
261+
controls.mainSkillMinionSkill.shown = false
262+
else
263+
local mainSocketGroup = self.skillsTab.socketGroupList[mainGroup]
264+
if not mainSocketGroup then
265+
mainSocketGroup = self.skillsTab.socketGroupList[1]
266+
mainGroup = 1
267+
end
268+
local displaySkillList = mainSocketGroup["displaySkillList"..suffix]
269+
if not displaySkillList then
270+
controls.mainSkill.shown = false
271+
controls.mainSkillPart.shown = false
272+
controls.mainSkillMineCount.shown = false
273+
controls.mainSkillStageCount.shown = false
274+
controls.mainSkillMinion.shown = false
275+
controls.mainSkillMinionSkill.shown = false
276+
return
277+
end
278+
local mainActiveSkill = mainSocketGroup["mainActiveSkill"..suffix] or 1
279+
wipeTable(controls.mainSkill.list)
280+
for i, activeSkill in ipairs(displaySkillList) do
281+
local explodeSource = activeSkill.activeEffect.srcInstance.explodeSource
282+
local explodeSourceName = explodeSource and (explodeSource.name or explodeSource.dn)
283+
local colourCoded = explodeSourceName and ("From "..colorCodes[explodeSource.rarity or "NORMAL"]..explodeSourceName)
284+
t_insert(controls.mainSkill.list, { val = i, label = colourCoded or activeSkill.activeEffect.grantedEffect.name })
285+
end
286+
controls.mainSkill.enabled = #displaySkillList > 1
287+
controls.mainSkill.selIndex = mainActiveSkill
288+
controls.mainSkill.shown = true
289+
controls.mainSkillPart.shown = false
290+
controls.mainSkillMineCount.shown = false
291+
controls.mainSkillStageCount.shown = false
292+
controls.mainSkillMinion.shown = false
293+
controls.mainSkillMinionSkill.shown = false
294+
if displaySkillList[1] then
295+
local activeSkill = displaySkillList[mainActiveSkill]
296+
if not activeSkill then
297+
activeSkill = displaySkillList[1]
298+
end
299+
local activeEffect = activeSkill.activeEffect
300+
if activeEffect then
301+
if activeEffect.grantedEffect.parts and #activeEffect.grantedEffect.parts > 1 then
302+
controls.mainSkillPart.shown = true
303+
wipeTable(controls.mainSkillPart.list)
304+
for i, part in ipairs(activeEffect.grantedEffect.parts) do
305+
t_insert(controls.mainSkillPart.list, { val = i, label = part.name })
306+
end
307+
controls.mainSkillPart.selIndex = activeEffect.srcInstance["skillPart"..suffix] or 1
308+
if activeEffect.grantedEffect.parts[controls.mainSkillPart.selIndex] and activeEffect.grantedEffect.parts[controls.mainSkillPart.selIndex].stages then
309+
controls.mainSkillStageCount.shown = true
310+
controls.mainSkillStageCount.buf = tostring(activeEffect.srcInstance["skillStageCount"..suffix] or activeEffect.grantedEffect.parts[controls.mainSkillPart.selIndex].stagesMin or 1)
311+
end
312+
end
313+
if activeSkill.skillFlags and activeSkill.skillFlags.mine then
314+
controls.mainSkillMineCount.shown = true
315+
controls.mainSkillMineCount.buf = tostring(activeEffect.srcInstance["skillMineCount"..suffix] or "")
316+
end
317+
if activeSkill.skillFlags and activeSkill.skillFlags.multiStage and not (activeEffect.grantedEffect.parts and #activeEffect.grantedEffect.parts > 1) then
318+
controls.mainSkillStageCount.shown = true
319+
controls.mainSkillStageCount.buf = tostring(activeEffect.srcInstance["skillStageCount"..suffix] or activeSkill.skillData.stagesMin or 1)
320+
end
321+
if activeSkill.skillFlags and not activeSkill.skillFlags.disable and (activeEffect.grantedEffect.minionList or (activeSkill.minionList and activeSkill.minionList[1])) then
322+
wipeTable(controls.mainSkillMinion.list)
323+
if activeEffect.grantedEffect.minionHasItemSet then
324+
for _, itemSetId in ipairs(self.itemsTab.itemSetOrderList) do
325+
local itemSet = self.itemsTab.itemSets[itemSetId]
326+
t_insert(controls.mainSkillMinion.list, {
327+
label = itemSet.title or "Default Item Set",
328+
itemSetId = itemSetId,
329+
})
330+
end
331+
controls.mainSkillMinion:SelByValue(activeEffect.srcInstance["skillMinionItemSet"..suffix] or 1, "itemSetId")
332+
else
333+
for _, minionId in ipairs(activeSkill.minionList) do
334+
t_insert(controls.mainSkillMinion.list, {
335+
label = self.data.minions[minionId] and self.data.minions[minionId].name or minionId,
336+
minionId = minionId,
337+
})
338+
end
339+
controls.mainSkillMinion:SelByValue(activeEffect.srcInstance["skillMinion"..suffix] or (controls.mainSkillMinion.list[1] and controls.mainSkillMinion.list[1].minionId), "minionId")
340+
end
341+
controls.mainSkillMinion.enabled = #controls.mainSkillMinion.list > 1
342+
controls.mainSkillMinion.shown = true
343+
wipeTable(controls.mainSkillMinionSkill.list)
344+
if activeSkill.minion then
345+
for _, minionSkill in ipairs(activeSkill.minion.activeSkillList) do
346+
t_insert(controls.mainSkillMinionSkill.list, minionSkill.activeEffect.grantedEffect.name)
347+
end
348+
controls.mainSkillMinionSkill.selIndex = activeEffect.srcInstance["skillMinionSkill"..suffix] or 1
349+
controls.mainSkillMinionSkill.shown = true
350+
controls.mainSkillMinionSkill.enabled = #controls.mainSkillMinionSkill.list > 1
351+
else
352+
t_insert(controls.mainSkillMinion.list, "<No spectres in build>")
353+
end
354+
end
355+
end
356+
end
357+
end
240358
end
241359

242360
function CompareEntryClass:UpdateClassDropdowns()
@@ -337,4 +455,43 @@ function CompareEntryClass:CompareStatList(tooltip, statList, actor, baseOutput,
337455
return count
338456
end
339457

458+
-- Add requirements to tooltip
459+
do
460+
local req = { }
461+
function CompareEntryClass:AddRequirementsToTooltip(tooltip, level, str, dex, int, strBase, dexBase, intBase)
462+
if level and level > 0 then
463+
t_insert(req, s_format("^x7F7F7FLevel %s%d", main:StatColor(level, nil, self.characterLevel), level))
464+
end
465+
if self.calcsTab.mainEnv.modDB:Flag(nil, "OmniscienceRequirements") then
466+
local omniSatisfy = self.calcsTab.mainEnv.modDB:Sum("INC", nil, "OmniAttributeRequirements")
467+
local highestAttribute = 0
468+
for i, stat in ipairs({str, dex, int}) do
469+
if((stat or 0) > highestAttribute) then
470+
highestAttribute = stat
471+
end
472+
end
473+
local omni = math.floor(highestAttribute * (100/omniSatisfy))
474+
if omni and (omni > 0 or omni > self.calcsTab.mainOutput.Omni) then
475+
t_insert(req, s_format("%s%d ^x7F7F7FOmni", main:StatColor(omni, 0, self.calcsTab.mainOutput.Omni), omni))
476+
end
477+
else
478+
if str and (str > 14 or str > self.calcsTab.mainOutput.Str) then
479+
t_insert(req, s_format("%s%d ^x7F7F7FStr", main:StatColor(str, strBase, self.calcsTab.mainOutput.Str), str))
480+
end
481+
if dex and (dex > 14 or dex > self.calcsTab.mainOutput.Dex) then
482+
t_insert(req, s_format("%s%d ^x7F7F7FDex", main:StatColor(dex, dexBase, self.calcsTab.mainOutput.Dex), dex))
483+
end
484+
if int and (int > 14 or int > self.calcsTab.mainOutput.Int) then
485+
t_insert(req, s_format("%s%d ^x7F7F7FInt", main:StatColor(int, intBase, self.calcsTab.mainOutput.Int), int))
486+
end
487+
end
488+
if req[1] then
489+
local fontSizeBig = main.showFlavourText and 18 or 16
490+
tooltip:AddLine(fontSizeBig, "^x7F7F7FRequires "..table.concat(req, "^x7F7F7F, "), "FONTIN SC")
491+
tooltip:AddSeparator(10)
492+
end
493+
wipeTable(req)
494+
end
495+
end
496+
340497
return CompareEntryClass

0 commit comments

Comments
 (0)