Skip to content

Commit

Permalink
Add configuration option for showing tooltips for all slots
Browse files Browse the repository at this point in the history
Add "Show tooltips only for affected slots" configuration option that
will show tooltips only affected slot instead of all slots (this
significantly reduces clutter when viewing jewel sockets for example).

Signed-off-by: Tomas Slusny <[email protected]>
  • Loading branch information
deathbeam committed Mar 18, 2022
1 parent cc01e87 commit 3596f1a
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 60 deletions.
122 changes: 62 additions & 60 deletions src/Classes/ItemsTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ local m_ceil = math.ceil
local m_floor = math.floor
local m_modf = math.modf

local rarityDropList = {
local rarityDropList = {
{ label = colorCodes.NORMAL.."Normal", rarity = "NORMAL" },
{ label = colorCodes.MAGIC.."Magic", rarity = "MAGIC" },
{ label = colorCodes.RARE.."Rare", rarity = "RARE" },
Expand Down Expand Up @@ -53,7 +53,7 @@ local ItemsTabClass = newClass("ItemsTab", "UndoHandler", "ControlHost", "Contro
self.Control()

self.build = build

self.socketViewer = new("PassiveTreeView")

self.items = { }
Expand Down Expand Up @@ -108,7 +108,7 @@ local ItemsTabClass = newClass("ItemsTab", "UndoHandler", "ControlHost", "Contro
return self.activeItemSet.useSecondWeaponSet
end
for i = 1, 6 do
local abyssal = new("ItemSlotControl", {"TOPLEFT",prevSlot,"BOTTOMLEFT"}, 0, 2, self, slotName.."Swap Abyssal Socket "..i, "Abyssal #"..i)
local abyssal = new("ItemSlotControl", {"TOPLEFT",prevSlot,"BOTTOMLEFT"}, 0, 2, self, slotName.."Swap Abyssal Socket "..i, "Abyssal #"..i)
addSlot(abyssal)
abyssal.parentSlot = swapSlot
abyssal.weaponSet = 2
Expand All @@ -121,7 +121,7 @@ local ItemsTabClass = newClass("ItemsTab", "UndoHandler", "ControlHost", "Contro
if slotName == "Weapon 1" or slotName == "Weapon 2" or slotName == "Helmet" or slotName == "Gloves" or slotName == "Body Armour" or slotName == "Boots" or slotName == "Belt" then
-- Add Abyssal Socket slots
for i = 1, 6 do
local abyssal = new("ItemSlotControl", {"TOPLEFT",prevSlot,"BOTTOMLEFT"}, 0, 2, self, slotName.." Abyssal Socket "..i, "Abyssal #"..i)
local abyssal = new("ItemSlotControl", {"TOPLEFT",prevSlot,"BOTTOMLEFT"}, 0, 2, self, slotName.." Abyssal Socket "..i, "Abyssal #"..i)
addSlot(abyssal)
abyssal.parentSlot = slot
if slotName:match("Weapon") then
Expand Down Expand Up @@ -246,23 +246,23 @@ local ItemsTabClass = newClass("ItemsTab", "UndoHandler", "ControlHost", "Contro
self:CraftItem()
end)
self.controls.craftDisplayItem.shown = function()
return self.displayItem == nil
return self.displayItem == nil
end
self.controls.newDisplayItem = new("ButtonControl", {"TOPLEFT",self.controls.craftDisplayItem,"TOPRIGHT"}, 8, 0, 120, 20, "Create custom...", function()
self:EditDisplayItemText()
end)
self.controls.displayItemTip = new("LabelControl", {"TOPLEFT",self.controls.craftDisplayItem,"BOTTOMLEFT"}, 0, 8, 100, 16,
self.controls.displayItemTip = new("LabelControl", {"TOPLEFT",self.controls.craftDisplayItem,"BOTTOMLEFT"}, 0, 8, 100, 16,
[[^7Double-click an item from one of the lists,
or copy and paste an item from in game
(hover over the item and Ctrl+C) to view or edit
the item and add it to your build. You can
also clone an item within Path of Building by
the item and add it to your build. You can
also clone an item within Path of Building by
copying and pasting it with Ctrl+C and Ctrl+V.
You can Control + Click an item to equip it, or
drag it onto the slot. This will also add it to
You can Control + Click an item to equip it, or
drag it onto the slot. This will also add it to
your build if it's from the unique/template list.
If there's 2 slots an item can go in,
If there's 2 slots an item can go in,
holding Shift will put it in the second.]])
self.controls.sharedItemList = new("SharedItemListControl", {"TOPLEFT",self.controls.craftDisplayItem, "BOTTOMLEFT"}, 0, 232, 340, 308, self)

Expand Down Expand Up @@ -292,11 +292,11 @@ holding Shift will put it in the second.]])
if not self.controls.displayItemVariant:IsShown() then
return 0
end
return (28 +
(self.displayItem.hasAltVariant and 24 or 0) +
(self.displayItem.hasAltVariant2 and 24 or 0) +
return (28 +
(self.displayItem.hasAltVariant and 24 or 0) +
(self.displayItem.hasAltVariant2 and 24 or 0) +
(self.displayItem.hasAltVariant3 and 24 or 0) +
(self.displayItem.hasAltVariant4 and 24 or 0) +
(self.displayItem.hasAltVariant4 and 24 or 0) +
(self.displayItem.hasAltVariant5 and 24 or 0))
end)
self.controls.displayItemVariant = new("DropDownControl", {"TOPLEFT", self.controls.displayItemSectionVariant,"TOPLEFT"}, 0, 0, 300, 20, nil, function(index, value)
Expand Down Expand Up @@ -410,7 +410,7 @@ holding Shift will put it in the second.]])
self.controls.displayItemAddSocket.shown = function()
return #self.displayItem.sockets < self.displayItem.selectableSocketCount + self.displayItem.abyssalSocketCount
end

-- Section: Enchant / Anoint / Corrupt
self.controls.displayItemSectionEnchant = new("Control", {"TOPLEFT",self.controls.displayItemSectionSockets,"BOTTOMLEFT"}, 0, 0, 0, function()
return (self.controls.displayItemEnchant:IsShown() or self.controls.displayItemEnchant2:IsShown() or self.controls.displayItemAnoint:IsShown() or self.controls.displayItemAnoint2:IsShown() or self.controls.displayItemCorrupt:IsShown() ) and 28 or 0
Expand Down Expand Up @@ -922,17 +922,17 @@ function ItemsTabClass:Save(xml)
}
for _, id in ipairs(self.itemOrderList) do
local item = self.items[id]
local child = {
elem = "Item",
attrib = {
id = tostring(id),
variant = item.variant and tostring(item.variant),
variantAlt = item.variantAlt and tostring(item.variantAlt),
local child = {
elem = "Item",
attrib = {
id = tostring(id),
variant = item.variant and tostring(item.variant),
variantAlt = item.variantAlt and tostring(item.variantAlt),
variantAlt2 = item.variantAlt2 and tostring(item.variantAlt2),
variantAlt3 = item.variantAlt3 and tostring(item.variantAlt3),
variantAlt4 = item.variantAlt4 and tostring(item.variantAlt4),
variantAlt3 = item.variantAlt3 and tostring(item.variantAlt3),
variantAlt4 = item.variantAlt4 and tostring(item.variantAlt4),
variantAlt5 = item.variantAlt5 and tostring(item.variantAlt5)
}
}
}
item:BuildAndParseRaw()
t_insert(child, item.raw)
Expand Down Expand Up @@ -1020,9 +1020,9 @@ function ItemsTabClass:Draw(viewPort, inputEvents)
end
self.x = self.x - self.controls.scrollBarH.offset
self.y = self.y - self.controls.scrollBarV.offset

for id, event in ipairs(inputEvents) do
if event.type == "KeyDown" then
if event.type == "KeyDown" then
if event.key == "v" and IsKeyDown("CTRL") then
local newItem = Paste()
if newItem then
Expand Down Expand Up @@ -1242,12 +1242,12 @@ function ItemsTabClass:AddItem(item, noAutoEquip, index)
end
end
end

-- Add it to the list
local replacing = self.items[item.id]
self.items[item.id] = item
item:BuildModList()

if replacing and (replacing.clusterJewel or item.clusterJewel or replacing.baseName == "Timeless Jewel") then
-- We're replacing an existing item, and either the new or old one is a cluster jewel
if isValueInTable(self.build.spec.jewels, item.id) then
Expand Down Expand Up @@ -1509,7 +1509,7 @@ function ItemsTabClass:UpdateAffixControls()
for i = 1, item.affixLimit/2 do
self:UpdateAffixControl(self.controls["displayItemAffix"..i], item, "Prefix", "prefixes", i)
self:UpdateAffixControl(self.controls["displayItemAffix"..(i+item.affixLimit/2)], item, "Suffix", "suffixes", i)
end
end
-- The custom affixes may have had their indexes changed, so the custom control UI is also rebuilt so that it will
-- reference the correct affix index.
self:UpdateCustomControls()
Expand All @@ -1535,7 +1535,7 @@ function ItemsTabClass:UpdateAffixControl(control, item, type, outputTable, outp
end
end
end
if item.clusterJewel and item.clusterJewelSkill then
if item.clusterJewel and item.clusterJewelSkill then
local skill = item.clusterJewel.skills[item.clusterJewelSkill]
if skill then
extraTags[skill.tag] = true
Expand Down Expand Up @@ -1650,7 +1650,7 @@ function ItemsTabClass:UpdateCustomControls()
local id = item.id
self:CreateDisplayItemFromRaw(item:BuildRaw())
self.displayItem.id = id
end
end
i = i + 1
end
end
Expand Down Expand Up @@ -1873,7 +1873,7 @@ function ItemsTabClass:EditDisplayItemText()
tooltip:AddLine(14, "For Normal and Magic items, the base name must be somewhere in the first line. E.g.:")
tooltip:AddLine(14, "Scholar's Platinum Kris of Joy")
end
end
end
controls.cancel = new("ButtonControl", nil, 45, 470, 80, 20, "Cancel", function()
main:ClosePopup()
end)
Expand All @@ -1884,7 +1884,7 @@ end
function ItemsTabClass:EnchantDisplayItem(enchantSlot)
self.enchantSlot = enchantSlot or 1

local controls = { }
local controls = { }
local enchantments = self.displayItem.enchantments
local haveSkills = true
for _, source in ipairs(self.build.data.enchantmentSource) do
Expand All @@ -1898,7 +1898,7 @@ function ItemsTabClass:EnchantDisplayItem(enchantSlot)
if haveSkills then
for _, socketGroup in ipairs(self.build.skillsTab.socketGroupList) do
for _, gemInstance in ipairs(socketGroup.gemList) do
if gemInstance.gemData then
if gemInstance.gemData then
for _, grantedEffect in ipairs(gemInstance.gemData.grantedEffectList) do
if not grantedEffect.support and enchantments[grantedEffect.name] then
skillsUsed[grantedEffect.name] = true
Expand Down Expand Up @@ -1993,7 +1993,7 @@ function ItemsTabClass:EnchantDisplayItem(enchantSlot)
controls.save.tooltipFunc = function(tooltip)
tooltip:Clear()
self:AddItemTooltip(tooltip, enchantItem(), nil, true)
end
end
controls.close = new("ButtonControl", nil, 45, 100, 80, 20, "Cancel", function()
main:ClosePopup()
end)
Expand Down Expand Up @@ -2084,7 +2084,7 @@ end
function ItemsTabClass:AnointDisplayItem(enchantSlot)
self.anointEnchantSlot = enchantSlot or 1

local controls = { }
local controls = { }
controls.notableDB = new("NotableDBControl", {"TOPLEFT",nil,"TOPLEFT"}, 10, 60, 360, 360, self, self.build.spec.tree.nodes, "ANOINT")

local function saveLabel()
Expand Down Expand Up @@ -2113,7 +2113,7 @@ function ItemsTabClass:AnointDisplayItem(enchantSlot)
controls.save.tooltipFunc = function(tooltip)
tooltip:Clear()
self:AppendAnointTooltip(tooltip, controls.notableDB.selValue)
end
end
controls.close = new("ButtonControl", {"TOPLEFT", controls.save, "TOPRIGHT" }, 10, 0, 80, 20, "Cancel", function()
main:ClosePopup()
end)
Expand All @@ -2122,7 +2122,7 @@ end

-- Opens the item corrupting popup
function ItemsTabClass:CorruptDisplayItem(modType)
local controls = { }
local controls = { }
local implicitList = { }
for modId, mod in pairs(self.displayItem.affixes) do
if mod.type == modType and self.displayItem:GetModSpawnWeight(mod) > 0 then
Expand Down Expand Up @@ -2194,7 +2194,7 @@ function ItemsTabClass:CorruptDisplayItem(modType)
controls.save.tooltipFunc = function(tooltip)
tooltip:Clear()
self:AddItemTooltip(tooltip, corruptItem(), nil, true)
end
end
controls.close = new("ButtonControl", nil, 45, 70, 80, 20, "Cancel", function()
main:ClosePopup()
end)
Expand Down Expand Up @@ -2250,7 +2250,7 @@ function ItemsTabClass:AddCustomModifierToDisplayItem()
end
table.sort(modList, function(a, b)
if a.essence.type ~= b.essence.type then
return a.essence.type > b.essence.type
return a.essence.type > b.essence.type
else
return a.essence.tier > b.essence.tier
end
Expand All @@ -2265,7 +2265,7 @@ function ItemsTabClass:AddCustomModifierToDisplayItem()
})
end
end
table.sort(modList, function(a, b)
table.sort(modList, function(a, b)
local modA = a.mod
local modB = b.mod
for i = 1, m_max(#modA, #modB) do
Expand Down Expand Up @@ -2384,11 +2384,11 @@ function ItemsTabClass:AddCustomModifierToDisplayItem()
controls.save.tooltipFunc = function(tooltip)
tooltip:Clear()
self:AddItemTooltip(tooltip, addModifier())
end
end
controls.close = new("ButtonControl", nil, 45, 75, 80, 20, "Cancel", function()
main:ClosePopup()
end)
main:OpenPopup(710, 105, "Add Modifier to Item", controls, "save", sourceList[controls.source.selIndex].sourceId == "CUSTOM" and "custom")
main:OpenPopup(710, 105, "Add Modifier to Item", controls, "save", sourceList[controls.source.selIndex].sourceId == "CUSTOM" and "custom")
end

function ItemsTabClass:AddItemSetTooltip(tooltip, itemSet)
Expand Down Expand Up @@ -2484,7 +2484,7 @@ function ItemsTabClass:AddItemTooltip(tooltip, item, slot, dbMode)
end
tooltip:AddLine(16, elemLine)
tooltip:AddLine(16, s_format("^x7F7F7FElemental DPS: "..colorCodes.MAGIC.."%.1f", weaponData.ElementalDPS))
totalDamageTypes = totalDamageTypes + 1
totalDamageTypes = totalDamageTypes + 1
end
if weaponData.ChaosDPS then
tooltip:AddLine(16, s_format("^x7F7F7FChaos Damage: "..colorCodes.CHAOS.."%d-%d "..colorCodes.MAGIC.."(%.1f DPS)", weaponData.ChaosMin, weaponData.ChaosMax, weaponData.ChaosDPS))
Expand Down Expand Up @@ -2582,7 +2582,7 @@ function ItemsTabClass:AddItemTooltip(tooltip, item, slot, dbMode)
end
end
end

if item.catalyst and item.catalyst > 0 and item.catalyst <= #catalystQualityFormat and item.catalystQuality and item.catalystQuality > 0 then
tooltip:AddLine(16, s_format(catalystQualityFormat[item.catalyst], item.catalystQuality))
tooltip:AddSeparator(10)
Expand Down Expand Up @@ -2625,8 +2625,8 @@ function ItemsTabClass:AddItemTooltip(tooltip, item, slot, dbMode)
end

-- Requirements
self.build:AddRequirementsToTooltip(tooltip, item.requirements.level,
item.requirements.strMod, item.requirements.dexMod, item.requirements.intMod,
self.build:AddRequirementsToTooltip(tooltip, item.requirements.level,
item.requirements.strMod, item.requirements.dexMod, item.requirements.intMod,
item.requirements.str or 0, item.requirements.dex or 0, item.requirements.int or 0)

-- Modifiers
Expand Down Expand Up @@ -2858,19 +2858,21 @@ function ItemsTabClass:AddItemTooltip(tooltip, item, slot, dbMode)
end)

-- Add comparisons for each slot
for _, slot in pairs(compareSlots) do
local selItem = self.items[slot.selItemId]
local storedGlobalCacheDPSView = GlobalCache.useFullDPS
GlobalCache.useFullDPS = GlobalCache.numActiveSkillInFullDPS > 0
local output = calcFunc({ repSlotName = slot.slotName, repItem = item ~= selItem and item }, {})
GlobalCache.useFullDPS = storedGlobalCacheDPSView
local header
if item == selItem then
header = "^7Removing this item from "..slot.label.." will give you:"
else
header = string.format("^7Equipping this item in %s will give you:%s", slot.label, selItem and "\n(replacing "..colorCodes[selItem.rarity]..selItem.name.."^7)" or "")
for _, compareSlot in pairs(compareSlots) do
if not main.slotOnlyTooltips or (slot and (slot.nodeId == compareSlot.nodeId or slot.slotName == compareSlot.slotName)) or not slot or slot == compareSlot then
local selItem = self.items[compareSlot.selItemId]
local storedGlobalCacheDPSView = GlobalCache.useFullDPS
GlobalCache.useFullDPS = GlobalCache.numActiveSkillInFullDPS > 0
local output = calcFunc({ repSlotName = compareSlot.slotName, repItem = item ~= selItem and item }, {})
GlobalCache.useFullDPS = storedGlobalCacheDPSView
local header
if item == selItem then
header = "^7Removing this item from "..compareSlot.label.." will give you:"
else
header = string.format("^7Equipping this item in %s will give you:%s", compareSlot.label, selItem and "\n(replacing "..colorCodes[selItem.rarity]..selItem.name.."^7)" or "")
end
self.build:AddStatComparesToTooltip(tooltip, calcBase, output, header)
end
self.build:AddStatComparesToTooltip(tooltip, calcBase, output, header)
end
end

Expand Down
12 changes: 12 additions & 0 deletions src/Modules/Main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ the "Releases" section of the GitHub page.]])
self.decimalSeparator = "."
self.showTitlebarName = true
self.showWarnings = true
self.slotOnlyTooltips = true

local ignoreBuild
if arg[1] then
Expand Down Expand Up @@ -524,6 +525,9 @@ function main:LoadSettings(ignoreBuild)
if node.attrib.showWarnings then
self.showWarnings = node.attrib.showWarnings == "true"
end
if node.attrib.slotOnlyTooltips then
self.slotOnlyTooltips = node.attrib.slotOnlyTooltips == "true"
end
end
end
end
Expand Down Expand Up @@ -576,6 +580,7 @@ function main:SaveSettings()
defaultCharLevel = tostring(self.defaultCharLevel or 1),
lastExportWebsite = self.lastExportWebsite,
showWarnings = tostring(self.showWarnings),
slotOnlyTooltips = tostring(self.slotOnlyTooltips),
} })
local res, errMsg = common.xml.SaveXMLFile(setXML, self.userPath.."Settings.xml")
if not res then
Expand Down Expand Up @@ -708,10 +713,15 @@ function main:OpenOptionsPopup()
controls.showWarnings = new("CheckBoxControl", {"TOPLEFT",nil,"TOPLEFT"}, defaultLabelPlacementX, currentY, 20, "^7Show build warnings:", function(state)
self.showWarnings = state
end)
nextRow()
controls.slotOnlyTooltips = new("CheckBoxControl", {"TOPLEFT",nil,"TOPLEFT"}, defaultLabelPlacementX, currentY, 20, "^7Show tooltips only for affected slots:", function(state)
self.slotOnlyTooltips = state
end)

controls.betaTest.state = self.betaTest
controls.titlebarName.state = self.showTitlebarName
controls.showWarnings.state = self.showWarnings
controls.slotOnlyTooltips.state = self.slotOnlyTooltips
local initialNodePowerTheme = self.nodePowerTheme
local initialThousandsSeparatorDisplay = self.showThousandsSeparators
local initialTitlebarName = self.showTitlebarName
Expand All @@ -721,6 +731,7 @@ function main:OpenOptionsPopup()
local initialDefaultGemQuality = self.defaultGemQuality or 0
local initialDefaultCharLevel = self.defaultCharLevel or 1
local initialshowWarnings = self.showWarnings
local initialSlotOnlyTooltips = self.slotOnlyTooltips

-- last line with buttons has more spacing
nextRow(1.5)
Expand Down Expand Up @@ -759,6 +770,7 @@ function main:OpenOptionsPopup()
self.defaultGemQuality = initialDefaultGemQuality
self.defaultCharLevel = initialDefaultCharLevel
self.showWarnings = initialshowWarnings
self.slotOnlyTooltips = initialSlotOnlyTooltips
main:ClosePopup()
end)
nextRow(1.5)
Expand Down

0 comments on commit 3596f1a

Please sign in to comment.