Skip to content

Commit e702771

Browse files
PeecheyLocalIdentity
andauthored
Add QoL when comparing Gear with Eldritch Implicits (#9285)
* qol for maintaining eldritch implicits across new gear * fix toggle saving and accounting for new item has any influence at all * comments, whitespace * nil checks, update to check for newItem base implicits, wording on toggle tooltip * update for corrupted newItem * rebase from cord belt PR * modcache * stop passing all of self and instead only the parts we need --------- Co-authored-by: LocalIdentity <localidentity2@gmail.com>
1 parent ab637a5 commit e702771

2 files changed

Lines changed: 50 additions & 11 deletions

File tree

src/Classes/ItemsTab.lua

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,19 +1581,44 @@ function ItemsTabClass:DeleteItem(item, deferUndoState)
15811581
end
15821582
end
15831583

1584+
local function copyAnointsAndEldritchImplicits(newItem, activeItemSet, items)
1585+
local newItemType = newItem.base.type
1586+
if activeItemSet[newItemType] then
1587+
local currentItem = activeItemSet[newItemType].selItemId and items[activeItemSet[newItemType].selItemId]
1588+
-- if you don't have an equipped item that matches the type of the newItem, no need to do anything
1589+
if currentItem then
1590+
-- if the new item is anointable and does not have an anoint and your current respective item does, apply that anoint to the new item
1591+
if isAnointable(newItem) and #newItem.enchantModLines == 0 and activeItemSet[newItemType].selItemId > 0 then
1592+
local currentAnoint = currentItem.enchantModLines
1593+
if currentAnoint and #currentAnoint == 1 then -- skip if amulet has more than one anoint e.g. Stranglegasp
1594+
newItem.enchantModLines = currentAnoint
1595+
end
1596+
end
1597+
-- if the new item is a non-corrupted Normal, Magic, or Rare Helmet, Body Armour, Gloves, or Boots and does not have any influence
1598+
-- and your current respective item is Eater and/or Exarch, apply those implicits and influence to the new item
1599+
local eldritchBaseTypes = { "Helmet", "Body Armour", "Gloves", "Boots" }
1600+
local eldritchRarities = { "NORMAL", "MAGIC", "RARE" }
1601+
for _, influence in ipairs(itemLib.influenceInfo.default) do
1602+
if newItem[influence.key] then
1603+
return
1604+
end
1605+
end
1606+
if main.migrateEldritchImplicits and isValueInTable(eldritchBaseTypes, newItem.base.type) and isValueInTable(eldritchRarities, newItem.rarity)
1607+
and #newItem.implicitModLines == 0 and not newItem.corrupted and (currentItem.cleansing or currentItem.tangle) and currentItem.implicitModLines then
1608+
newItem.implicitModLines = currentItem.implicitModLines
1609+
newItem.tangle = currentItem.tangle
1610+
newItem.cleansing = currentItem.cleansing
1611+
end
1612+
newItem:BuildAndParseRaw()
1613+
end
1614+
end
1615+
end
1616+
15841617
-- Attempt to create a new item from the given item raw text and sets it as the new display item
15851618
function ItemsTabClass:CreateDisplayItemFromRaw(itemRaw, normalise)
15861619
local newItem = new("Item", itemRaw)
15871620
if newItem.base then
1588-
local itemType = newItem.base.type
1589-
-- if the new item is anointable and does not have an anoint and your current respective item does, apply that anoint to the new item
1590-
if isAnointable(newItem) and #newItem.enchantModLines == 0 and self.activeItemSet[itemType].selItemId > 0 then
1591-
local currentAnoint = self.items[self.activeItemSet[itemType].selItemId].enchantModLines
1592-
if currentAnoint and #currentAnoint == 1 then -- skip if amulet has more than one anoint e.g. Stranglegasp
1593-
newItem.enchantModLines = currentAnoint
1594-
newItem:BuildAndParseRaw()
1595-
end
1596-
end
1621+
copyAnointsAndEldritchImplicits(newItem, self.activeItemSet, self.items)
15971622
if normalise then
15981623
newItem:NormaliseQuality()
15991624
newItem:BuildModList()

src/Modules/Main.lua

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ function main:Init()
107107
self.dpiScaleOverridePercent = GetDPIScaleOverridePercent and GetDPIScaleOverridePercent() or 0
108108
self.showWarnings = true
109109
self.slotOnlyTooltips = true
110+
self.migrateEldritchImplicits = true
110111
self.notSupportedModTooltips = true
111112
self.notSupportedTooltipText = " ^8(Not supported in PoB yet)"
112113
self.POESESSID = ""
@@ -632,6 +633,9 @@ function main:LoadSettings(ignoreBuild)
632633
if node.attrib.slotOnlyTooltips then
633634
self.slotOnlyTooltips = node.attrib.slotOnlyTooltips == "true"
634635
end
636+
if node.attrib.migrateEldritchImplicits then
637+
self.migrateEldritchImplicits = node.attrib.migrateEldritchImplicits == "true"
638+
end
635639
if node.attrib.notSupportedModTooltips then
636640
self.notSupportedModTooltips = node.attrib.notSupportedModTooltips == "true"
637641
end
@@ -782,6 +786,7 @@ function main:SaveSettings()
782786
lastExportedWebsite = self.lastExportedWebsite,
783787
showWarnings = tostring(self.showWarnings),
784788
slotOnlyTooltips = tostring(self.slotOnlyTooltips),
789+
migrateEldritchImplicits = tostring(self.migrateEldritchImplicits),
785790
notSupportedModTooltips = tostring(self.notSupportedModTooltips),
786791
POESESSID = self.POESESSID,
787792
invertSliderScrollDirection = tostring(self.invertSliderScrollDirection),
@@ -867,7 +872,7 @@ function main:OpenOptionsPopup()
867872
end
868873

869874
local defaultLabelSpacingPx = -4
870-
local defaultLabelPlacementX = 240
875+
local defaultLabelPlacementX = popupWidth*0.45
871876

872877
drawSectionHeader("app", "Application options")
873878

@@ -1064,7 +1069,14 @@ function main:OpenOptionsPopup()
10641069
self.slotOnlyTooltips = state
10651070
end)
10661071
controls.slotOnlyTooltips.state = self.slotOnlyTooltips
1067-
1072+
1073+
nextRow()
1074+
controls.migrateEldritchImplicits = new("CheckBoxControl", { "TOPLEFT", nil, "TOPLEFT" }, { defaultLabelPlacementX, currentY, 20 }, "^7Copy Eldritch Implicits onto Display Item:", function(state)
1075+
self.migrateEldritchImplicits = state
1076+
end)
1077+
controls.migrateEldritchImplicits.tooltipText = "Apply Eldritch Implicits from current gear when comparing new gear, given the new item doesn't have any influence"
1078+
controls.migrateEldritchImplicits.state = self.migrateEldritchImplicits
1079+
10681080
nextRow()
10691081
controls.notSupportedModTooltips = new("CheckBoxControl", { "TOPLEFT", nil, "TOPLEFT" }, { defaultLabelPlacementX, currentY, 20 }, "^7Show tooltip for unsupported mods :", function(state)
10701082
self.notSupportedModTooltips = state
@@ -1110,6 +1122,7 @@ function main:OpenOptionsPopup()
11101122
local initialDefaultItemAffixQuality = self.defaultItemAffixQuality or 0.5
11111123
local initialShowWarnings = self.showWarnings
11121124
local initialSlotOnlyTooltips = self.slotOnlyTooltips
1125+
local initialMigrateEldritchImplicits = self.migrateEldritchImplicits
11131126
local initialNotSupportedModTooltips = self.notSupportedModTooltips
11141127
local initialInvertSliderScrollDirection = self.invertSliderScrollDirection
11151128
local initialDisableDevAutoSave = self.disableDevAutoSave
@@ -1166,6 +1179,7 @@ function main:OpenOptionsPopup()
11661179
self.defaultItemAffixQuality = initialDefaultItemAffixQuality
11671180
self.showWarnings = initialShowWarnings
11681181
self.slotOnlyTooltips = initialSlotOnlyTooltips
1182+
self.migrateEldritchImplicits = initialMigrateEldritchImplicits
11691183
self.notSupportedModTooltips = initialNotSupportedModTooltips
11701184
self.invertSliderScrollDirection = initialInvertSliderScrollDirection
11711185
self.disableDevAutoSave = initialDisableDevAutoSave

0 commit comments

Comments
 (0)