From 1189b52042635a5f7c427a25611b4906a97fcd9f Mon Sep 17 00:00:00 2001 From: QuickStick <31533893+QuickStick123@users.noreply.github.com> Date: Tue, 6 Dec 2022 16:48:15 +1100 Subject: [PATCH 1/2] added mod tooltip --- src/Classes/ItemsTab.lua | 167 +++++++++++++++++++++++++++------------ 1 file changed, 117 insertions(+), 50 deletions(-) diff --git a/src/Classes/ItemsTab.lua b/src/Classes/ItemsTab.lua index 35da5c6e2b..696b8dd1d8 100644 --- a/src/Classes/ItemsTab.lua +++ b/src/Classes/ItemsTab.lua @@ -655,56 +655,6 @@ holding Shift will put it in the second.]]) if mod.modTags and #mod.modTags > 0 then tooltip:AddLine(16, "Tags: "..table.concat(mod.modTags, ', ')) end - - local notableName = mod[1] and mod[1]:match("1 Added Passive Skill is (.*)") - local node = notableName and self.build.spec.tree.clusterNodeMap[notableName] - if node then - tooltip:AddSeparator(14) - - -- Node name - self.socketViewer:AddNodeName(tooltip, node, self.build) - - -- Node description - if node.sd[1] then - tooltip:AddLine(16, "") - for i, line in ipairs(node.sd) do - tooltip:AddLine(16, ((node.mods[i].extra or not node.mods[i].list) and colorCodes.UNSUPPORTED or colorCodes.MAGIC)..line) - end - end - - -- Reminder text - if node.reminderText then - tooltip:AddSeparator(14) - for _, line in ipairs(node.reminderText) do - tooltip:AddLine(14, "^xA0A080"..line) - end - end - - -- Comparison - tooltip:AddSeparator(14) - self:AppendAnointTooltip(tooltip, node, "Allocating") - - -- Information of for this notable appears - local clusterInfo = self.build.data.clusterJewelInfoForNotable[notableName] - if clusterInfo then - tooltip:AddSeparator(14) - tooltip:AddLine(20, "^7"..notableName.." can appear on:") - local isFirstSize = true - for size, v in pairs(clusterInfo.size) do - tooltip:AddLine(18, colorCodes.MAGIC..size..":") - local sizeSkills = self.build.data.clusterJewels.jewels[size].skills - for i, type in ipairs(clusterInfo.jewelTypes) do - if sizeSkills[type] then - tooltip:AddLine(14, "^7 "..sizeSkills[type].name) - end - end - if not isFirstSize then - tooltip:AddLine(10, "") - end - isFirstSize = false - end - end - end else tooltip:AddLine(16, "^7"..#modList.." Tiers") local minMod = self.displayItem.affixes[modList[1]] @@ -733,6 +683,66 @@ holding Shift will put it in the second.]]) tooltip:AddLine(16, "Tags: "..table.concat(maxMod.modTags, ', ')) end end + local mod = self.displayItem.affixes[value.modId or modList[1]] + local notableName = mod[1] and mod[1]:match("1 Added Passive Skill is (.*)") + local node = notableName and self.build.spec.tree.clusterNodeMap[notableName] + if node then + tooltip:AddSeparator(14) + + -- Node name + self.socketViewer:AddNodeName(tooltip, node, self.build) + + -- Node description + if node.sd[1] then + tooltip:AddLine(16, "") + for i, line in ipairs(node.sd) do + tooltip:AddLine(16, ((node.mods[i].extra or not node.mods[i].list) and colorCodes.UNSUPPORTED or colorCodes.MAGIC)..line) + end + end + + -- Reminder text + if node.reminderText then + tooltip:AddSeparator(14) + for _, line in ipairs(node.reminderText) do + tooltip:AddLine(14, "^xA0A080"..line) + end + end + + -- Comparison + tooltip:AddSeparator(14) + self:AppendAnointTooltip(tooltip, node, "Allocating") + + -- Information of for this notable appears + local clusterInfo = self.build.data.clusterJewelInfoForNotable[notableName] + if clusterInfo then + tooltip:AddSeparator(14) + tooltip:AddLine(20, "^7"..notableName.." can appear on:") + local isFirstSize = true + for size, v in pairs(clusterInfo.size) do + tooltip:AddLine(18, colorCodes.MAGIC..size..":") + local sizeSkills = self.build.data.clusterJewels.jewels[size].skills + for i, type in ipairs(clusterInfo.jewelTypes) do + if sizeSkills[type] then + tooltip:AddLine(14, "^7 "..sizeSkills[type].name) + end + end + if not isFirstSize then + tooltip:AddLine(10, "") + end + isFirstSize = false + end + end + else + local mod = { } + if value.modId or #modList == 1 then + mod = self.displayItem.affixes[value.modId or modList[1]] + else + mod = self.displayItem.affixes[modList[1 + round((#modList - 1) * main.defaultItemAffixQuality)]] + end + + -- Adding Mod + self:AddModComparisonTooltip(tooltip, { mod }) + end end end drop.shown = function() @@ -1695,6 +1705,24 @@ function ItemsTabClass:UpdateDisplayItemRangeLines() end end +function ItemsTabClass:AddModComparisonTooltip(tooltip, mods) + local slotName = self.displayItem:GetPrimarySlot() + local newItem = new("Item", self.displayItem:BuildRaw()) + + for _, mod in ipairs(mods) do + for _, subMod in ipairs(mod) do + t_insert(newItem.explicitModLines, { line = subMod, modTags = mod.modTags, [mod.type] = true }) + end + end + + newItem:BuildAndParseRaw() + + local calcFunc = self.build.calcsTab:GetMiscCalculator() + local outputBase = calcFunc({ repSlotName = slotName, repItem = self.displayItem }, {}) + local outputNew = calcFunc({ repSlotName = slotName, repItem = newItem }, {}) + self.build:AddStatComparesToTooltip(tooltip, outputBase, outputNew, "\nAdding this mod will give: ") +end + -- Returns the first slot in which the given item is equipped function ItemsTabClass:GetEquippedSlotForItem(item) for _, slot in ipairs(self.orderedSlots) do @@ -2242,20 +2270,56 @@ function ItemsTabClass:CorruptDisplayItem(modType) controls.implicit = new("DropDownControl", {"TOPLEFT",nil,"TOPLEFT"}, 80, 45, 440, 18, nil, function() buildList(controls.implicit2, controls.implicit, currentModType) end) + controls.implicit.tooltipFunc = function(tooltip, mode, index, value) + tooltip:Clear() + if mode ~= "OUT" and value and value.mod then + for _, line in ipairs(value.mod) do + tooltip:AddLine(16, "^7"..line) + end + self:AddModComparisonTooltip(tooltip, { value.mod }) + end + end controls.implicit2Label = new("LabelControl", {"TOPRIGHT",nil,"TOPLEFT"}, 75, 65, 0, 16, "^7Implicit #2:") controls.implicit2 = new("DropDownControl", {"TOPLEFT",nil,"TOPLEFT"}, 80, 65, 440, 18, nil, function() buildList(controls.implicit, controls.implicit2, currentModType) end) + controls.implicit2.tooltipFunc = function(tooltip, mode, index, value) + tooltip:Clear() + if mode ~= "OUT" and value and value.mod then + for _, line in ipairs(value.mod) do + tooltip:AddLine(16, "^7"..line) + end + self:AddModComparisonTooltip(tooltip, { value.mod }) + end + end controls.implicit3Label = new("LabelControl", {"TOPRIGHT",nil,"TOPLEFT"}, 75, 85, 0, 16, "^7Implicit #3:") controls.implicit3 = new("DropDownControl", {"TOPLEFT",nil,"TOPLEFT"}, 80, 65, 440, 18, nil, function() buildList(controls.implicit4, controls.implicit3, "ScourgeDownside") end) + controls.implicit3.tooltipFunc = function(tooltip, mode, index, value) + tooltip:Clear() + if mode ~= "OUT" and value and value.mod then + for _, line in ipairs(value.mod) do + tooltip:AddLine(16, "^7"..line) + end + self:AddModComparisonTooltip(tooltip, { value.mod }) + end + end controls.implicit3Label.shown = false controls.implicit3.shown = false controls.implicit4Label = new("LabelControl", {"TOPRIGHT",nil,"TOPLEFT"}, 75, 105, 0, 16, "^7Implicit #4:") controls.implicit4 = new("DropDownControl", {"TOPLEFT",nil,"TOPLEFT"}, 80, 105, 440, 18, nil, function() buildList(controls.implicit3, controls.implicit4, "ScourgeDownside") end) + controls.implicit4.tooltipFunc = function(tooltip, mode, index, value) + tooltip:Clear() + if mode ~= "OUT" and value and value.mod then + for _, line in ipairs(value.mod) do + tooltip:AddLine(16, "^7"..line) + end + self:AddModComparisonTooltip(tooltip, { value.mod }) + end + end controls.implicit4Label.shown = false controls.implicit4.shown = false buildList(controls.implicit, controls.implicit2, currentModType) @@ -2445,6 +2509,7 @@ function ItemsTabClass:AddCustomModifierToDisplayItem() for _, line in ipairs(value.mod) do tooltip:AddLine(16, "^7"..line) end + self:AddModComparisonTooltip(tooltip, { value.mod }) end end controls.custom = new("EditControl", {"TOPLEFT",nil,"TOPLEFT"}, 100, 45, 440, 18) @@ -2665,6 +2730,7 @@ function ItemsTabClass:AddImplicitToDisplayItem() for _, line in ipairs(value.mod) do tooltip:AddLine(16, "^7"..line) end + self:AddModComparisonTooltip(tooltip, { value.mod }) end end controls.modSelectLabel = new("LabelControl", {"TOPRIGHT",nil,"TOPLEFT"}, 95, 70, 0, 16, "^7Modifier:") @@ -2678,6 +2744,7 @@ function ItemsTabClass:AddImplicitToDisplayItem() for _, line in ipairs(value.mod) do tooltip:AddLine(16, "^7"..line) end + self:AddModComparisonTooltip(tooltip, { value.mod }) end end controls.custom = new("EditControl", {"TOPLEFT",nil,"TOPLEFT"}, 100, 45, 440, 18) From 8ca5578b33b585137bf4b9faaf94a119f0177339 Mon Sep 17 00:00:00 2001 From: QuickStick <31533893+QuickStick123@users.noreply.github.com> Date: Wed, 7 Dec 2022 15:02:51 +1100 Subject: [PATCH 2/2] minor cleanup --- src/Classes/ItemsTab.lua | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/Classes/ItemsTab.lua b/src/Classes/ItemsTab.lua index 696b8dd1d8..405ba4cff7 100644 --- a/src/Classes/ItemsTab.lua +++ b/src/Classes/ItemsTab.lua @@ -741,7 +741,7 @@ holding Shift will put it in the second.]]) end -- Adding Mod - self:AddModComparisonTooltip(tooltip, { mod }) + self:AddModComparisonTooltip(tooltip, mod) end end end @@ -1705,14 +1705,12 @@ function ItemsTabClass:UpdateDisplayItemRangeLines() end end -function ItemsTabClass:AddModComparisonTooltip(tooltip, mods) +function ItemsTabClass:AddModComparisonTooltip(tooltip, mod) local slotName = self.displayItem:GetPrimarySlot() local newItem = new("Item", self.displayItem:BuildRaw()) - for _, mod in ipairs(mods) do - for _, subMod in ipairs(mod) do - t_insert(newItem.explicitModLines, { line = subMod, modTags = mod.modTags, [mod.type] = true }) - end + for _, subMod in ipairs(mod) do + t_insert(newItem.explicitModLines, { line = subMod, modTags = mod.modTags, [mod.type] = true }) end newItem:BuildAndParseRaw() @@ -2276,7 +2274,7 @@ function ItemsTabClass:CorruptDisplayItem(modType) for _, line in ipairs(value.mod) do tooltip:AddLine(16, "^7"..line) end - self:AddModComparisonTooltip(tooltip, { value.mod }) + self:AddModComparisonTooltip(tooltip, value.mod) end end controls.implicit2Label = new("LabelControl", {"TOPRIGHT",nil,"TOPLEFT"}, 75, 65, 0, 16, "^7Implicit #2:") @@ -2289,7 +2287,7 @@ function ItemsTabClass:CorruptDisplayItem(modType) for _, line in ipairs(value.mod) do tooltip:AddLine(16, "^7"..line) end - self:AddModComparisonTooltip(tooltip, { value.mod }) + self:AddModComparisonTooltip(tooltip, value.mod) end end controls.implicit3Label = new("LabelControl", {"TOPRIGHT",nil,"TOPLEFT"}, 75, 85, 0, 16, "^7Implicit #3:") @@ -2302,7 +2300,7 @@ function ItemsTabClass:CorruptDisplayItem(modType) for _, line in ipairs(value.mod) do tooltip:AddLine(16, "^7"..line) end - self:AddModComparisonTooltip(tooltip, { value.mod }) + self:AddModComparisonTooltip(tooltip, value.mod) end end controls.implicit3Label.shown = false @@ -2317,7 +2315,7 @@ function ItemsTabClass:CorruptDisplayItem(modType) for _, line in ipairs(value.mod) do tooltip:AddLine(16, "^7"..line) end - self:AddModComparisonTooltip(tooltip, { value.mod }) + self:AddModComparisonTooltip(tooltip, value.mod) end end controls.implicit4Label.shown = false @@ -2509,7 +2507,7 @@ function ItemsTabClass:AddCustomModifierToDisplayItem() for _, line in ipairs(value.mod) do tooltip:AddLine(16, "^7"..line) end - self:AddModComparisonTooltip(tooltip, { value.mod }) + self:AddModComparisonTooltip(tooltip, value.mod) end end controls.custom = new("EditControl", {"TOPLEFT",nil,"TOPLEFT"}, 100, 45, 440, 18) @@ -2730,7 +2728,7 @@ function ItemsTabClass:AddImplicitToDisplayItem() for _, line in ipairs(value.mod) do tooltip:AddLine(16, "^7"..line) end - self:AddModComparisonTooltip(tooltip, { value.mod }) + self:AddModComparisonTooltip(tooltip, value.mod) end end controls.modSelectLabel = new("LabelControl", {"TOPRIGHT",nil,"TOPLEFT"}, 95, 70, 0, 16, "^7Modifier:") @@ -2744,7 +2742,7 @@ function ItemsTabClass:AddImplicitToDisplayItem() for _, line in ipairs(value.mod) do tooltip:AddLine(16, "^7"..line) end - self:AddModComparisonTooltip(tooltip, { value.mod }) + self:AddModComparisonTooltip(tooltip, value.mod) end end controls.custom = new("EditControl", {"TOPLEFT",nil,"TOPLEFT"}, 100, 45, 440, 18)