diff --git a/src/Classes/Item.lua b/src/Classes/Item.lua index 67476cf1f8c..793b779760a 100644 --- a/src/Classes/Item.lua +++ b/src/Classes/Item.lua @@ -85,6 +85,7 @@ local lineFlags = { ["crafted"] = true, ["crucible"] = true, ["custom"] = true, + ["disabled"] = true, ["eater"] = true, ["enchant"] = true, ["exarch"] = true, @@ -1530,6 +1531,9 @@ function ItemClass:BuildRaw() if modLine.corruptedRange then line = "{corruptedRange:" .. round(modLine.corruptedRange, 2) .. "}" .. line end + if modLine.disabled then + line = "{disabled}" .. line + end if modLine.crafted then line = "{crafted}" .. line end @@ -2148,6 +2152,9 @@ function ItemClass:BuildModList() end end local function processModLine(modLine) + if modLine.disabled then + return + end if self:CheckModLineVariant(modLine) then -- special section for variant over-ride of pre-modifier item parameters if modLine.line:find("Requires Class") then diff --git a/src/Classes/ItemsTab.lua b/src/Classes/ItemsTab.lua index 7171ea2db24..ade682d23f6 100644 --- a/src/Classes/ItemsTab.lua +++ b/src/Classes/ItemsTab.lua @@ -1455,6 +1455,27 @@ function ItemsTabClass:Draw(viewPort, inputEvents) if self.displayItem then local x, y = self.controls.displayItemTooltipAnchor:GetPos() self.displayItemTooltip:Draw(x, y, nil, nil, viewPort) + + -- Toggle mods + local cursorX, cursorY = GetCursorPos() + for _, line in ipairs(self.displayItemTooltip.lines) do + if line.modLine and line.bounds then + local b = line.bounds + if cursorX >= b.x and cursorX <= b.x + b.width and cursorY >= b.y and cursorY <= b.y + b.height then + SetDrawColor(1, 1, 1, 0.15) + DrawImage(nil, b.x, b.y, b.width, b.height) + SetDrawColor(1, 1, 1) + + for id, event in ipairs(inputEvents) do + if event.type == "KeyDown" and event.key:match("BUTTON") then + inputEvents[id] = nil + self:ToggleDisplayItemModLine(line.modLine) + break + end + end + end + end + end end self:UpdateSockets() @@ -1869,6 +1890,21 @@ function ItemsTabClass:UpdateDisplayItemTooltip() self.displayItemTooltip.center = true end +function ItemsTabClass:ToggleDisplayItemModLine(modLine) + if not self.displayItem or not modLine then + return + end + modLine.disabled = not modLine.disabled + self.displayItem:BuildAndParseRaw() + self:UpdateDisplayItemTooltip() + self:UpdateDisplayItemRangeLines() + self:UpdateCustomControls() + if self.displayItem.crafted then + self:UpdateAffixControls() + end + self.build.buildFlag = true +end + function ItemsTabClass:UpdateSocketControls() local sockets = self.displayItem.sockets for i = 1, #sockets - self.displayItem.abyssalSocketCount do @@ -4324,7 +4360,10 @@ function ItemsTabClass:AddItemTooltip(tooltip, item, slot, dbMode, maxWidth) if modList[1] then for _, modLine in ipairs(modList) do if item:CheckModLineVariant(modLine) then - tooltip:AddLine(fontSizeBig, itemLib.formatModLine(modLine, dbMode), "FONTIN SC") + local formatted = itemLib.formatModLine(modLine, dbMode) + if formatted then + tooltip:AddLine(fontSizeBig, formatted, "FONTIN SC", modLine) + end end end tooltip:AddSeparator(10) diff --git a/src/Classes/Tooltip.lua b/src/Classes/Tooltip.lua index 51cc09b93c6..a8cb7b22ada 100644 --- a/src/Classes/Tooltip.lua +++ b/src/Classes/Tooltip.lua @@ -84,7 +84,7 @@ function TooltipClass:CheckForUpdate(...) end end -function TooltipClass:AddLine(size, text, font) +function TooltipClass:AddLine(size, text, font, modLine) if text then local fontToUse if main.showFlavourText then @@ -100,10 +100,10 @@ function TooltipClass:AddLine(size, text, font) end if self.maxWidth then for _, wrappedLine in ipairs(main:WrapString(line, size, self.maxWidth - H_PAD)) do - t_insert(self.lines, { size = size, text = wrappedLine, block = #self.blocks, font = fontToUse, center = self.center }) + t_insert(self.lines, { size = size, text = wrappedLine, block = #self.blocks, font = fontToUse, center = self.center, modLine = modLine }) end else - t_insert(self.lines, { size = size, text = line, block = #self.blocks, font = fontToUse, center = self.center }) + t_insert(self.lines, { size = size, text = line, block = #self.blocks, font = fontToUse, center = self.center, modLine = modLine }) end end end @@ -294,7 +294,12 @@ function TooltipClass:CalculateColumns(ttY, ttX, ttH, ttW, viewPort) local lineX = lineCentered and (x + ttW / 2) or (x + (H_PAD / 2)) local lineAlign = lineCentered and "CENTER_X" or "LEFT" - t_insert(drawStack, {lineX, y, lineAlign, data.size, font, data.text}) + local stackEntry = {lineX, y, lineAlign, data.size, font, data.text} + if data.modLine and data.modLine.disabled then + stackEntry.strikethrough = true + end + t_insert(drawStack, stackEntry) + data.bounds = { x = x + (H_PAD / 2), y = y, width = ttW - H_PAD, height = data.size + 2 } y = y + data.size + 2 -- track max width for extra columns @@ -595,6 +600,19 @@ function TooltipClass:Draw(x, y, w, h, viewPort) end else DrawString(unpack(line)) + if line.strikethrough then + local textX = line[1] + local textY = line[2] + local align = line[3] + local size = line[4] + local font = line[5] + local text = line[6] + local textW = DrawStringWidth(size, font, text) + local strikeX = align == "CENTER_X" and (textX - textW / 2) or textX + local strikeY = textY + size / 2 + SetDrawColor(0.75, 0.75, 0.75, 0.35) + DrawImage(nil, strikeX, strikeY, textW, 1.0) + end end end diff --git a/src/Modules/ItemTools.lua b/src/Modules/ItemTools.lua index 70331dad442..0b7e0ba2b50 100644 --- a/src/Modules/ItemTools.lua +++ b/src/Modules/ItemTools.lua @@ -354,6 +354,9 @@ function itemLib.formatModLine(modLine, dbMode) if line:match("^%+?0%%? ") or (line:match(" %+?0%%? ") and not line:match("0 to [1-9]")) or line:match(" 0%-0 ") or line:match(" 0 to 0 ") then -- Hack to hide 0-value modifiers return end + if modLine.disabled then + return "^x7F7F7F" .. line + end local colorCode if modLine.extra then colorCode = colorCodes.UNSUPPORTED