Skip to content

Commit 5000412

Browse files
committed
Added desecrated mod line background images, and gem background images
1 parent 6434f42 commit 5000412

File tree

7 files changed

+63
-13
lines changed

7 files changed

+63
-13
lines changed

src/Assets/gemhovermodbg.png

133 KB
Loading

src/Assets/hovermodbgabyss.png

66 KB
Loading

src/Classes/GemSelectControl.lua

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -717,8 +717,10 @@ function GemSelectClass:AddStatSetInfo(gemInstance, grantedEffect, statSet, noLa
717717
-- end
718718
--end
719719
local descriptions, lineMap = self.skillsTab.build.data.describeStats(stats, statSet.statDescriptionScope)
720-
for _, line in ipairs(descriptions) do
720+
for i, line in ipairs(descriptions) do
721721
local source = statSet.statMap[lineMap[line]] or self.skillsTab.build.data.skillStatMap[lineMap[line]]
722+
local bg = (i % 2 == 0) and "GemHoverModBg" or nil -- every second line gets background
723+
722724
if source then
723725
if launch.devModeAlt then
724726
local devText = lineMap[line]
@@ -730,14 +732,14 @@ function GemSelectClass:AddStatSetInfo(gemInstance, grantedEffect, statSet, noLa
730732
end
731733
line = line .. " ^2" .. devText
732734
end
733-
self.tooltip:AddLine(18, colorCodes.MAGIC .. line)
735+
self.tooltip:AddLine(18, colorCodes.MAGIC .. line, nil, bg)
734736
else
735737
if launch.devModeAlt then
736738
line = line .. " ^1" .. lineMap[line]
737739
end
738740
local line = colorCodes.UNSUPPORTED .. line
739741
line = main.notSupportedModTooltips and (line .. main.notSupportedTooltipText) or line
740-
self.tooltip:AddLine(18, line)
742+
self.tooltip:AddLine(18, line, nil, bg)
741743
end
742744
end
743745
end

src/Classes/Item.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,7 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
636636
end
637637
if modLine.desecrated then
638638
self.desecrated = true
639+
modLine.desecrated = true
639640
end
640641
if modLine.fractured then
641642
self.fractured = true

src/Classes/ItemsTab.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2884,6 +2884,7 @@ function ItemsTabClass:AddItemTooltip(tooltip, item, slot, dbMode)
28842884
if modList[1] then
28852885
for _, modLine in ipairs(modList) do
28862886
if item:CheckModLineVariant(modLine) then
2887+
local bg = modLine.desecrated and "HoverModBgAbyss" or nil
28872888
if scale ~= 1 then
28882889
local copyModLine = copyTable(modLine)
28892890
local modsList = copyTable(modLine.modList)
@@ -2904,9 +2905,9 @@ function ItemsTabClass:AddItemTooltip(tooltip, item, slot, dbMode)
29042905
copyModLine.line = copyModLine.line:gsub("%d*%.?%d+", math.abs(newValue), 1) -- Only scale first number in line
29052906
end
29062907
end
2907-
tooltip:AddLine(18, itemLib.formatModLine(copyModLine, dbMode))
2908+
tooltip:AddLine(18, itemLib.formatModLine(copyModLine, dbMode), nil, bg)
29082909
else
2909-
tooltip:AddLine(18, itemLib.formatModLine(modLine, dbMode))
2910+
tooltip:AddLine(18, itemLib.formatModLine(modLine, dbMode), nil, bg)
29102911
end
29112912

29122913
-- Show mods from granted Notables

src/Classes/Tooltip.lua

Lines changed: 53 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,25 @@ function TooltipClass:CheckForUpdate(...)
5252
end
5353
end
5454

55-
function TooltipClass:AddLine(size, text, font)
55+
function TooltipClass:AddLine(size, text, font, background)
5656
if text then
57-
for line in s_gmatch(text .. "\n", "([^\n]*)\n") do
57+
-- Capture the first color code, if any
58+
local colorPrefix = text:match("^(%^[x%dA-Fa-f]+)")
59+
60+
for line in s_gmatch(text .. "\n", "([^\n]*)\n") do
61+
-- If line doesn’t start with a color, reuse prefix
62+
if colorPrefix and not line:find("^%^[x%dA-Fa-f]+") then
63+
line = colorPrefix .. line
64+
end
65+
66+
-- Handle tooltip block heights
5867
if line:match("^.*(Equipping)") == "Equipping" or line:match("^.*(Removing)") == "Removing" then
5968
t_insert(self.blocks, { height = size + 2 })
6069
else
6170
self.blocks[#self.blocks].height = self.blocks[#self.blocks].height + size + 2
6271
end
72+
73+
-- Default font for item tooltips
6374
if (self.tooltipHeader == "UNIQUE"
6475
or self.tooltipHeader == "RARE"
6576
or self.tooltipHeader == "MAGIC"
@@ -73,12 +84,22 @@ function TooltipClass:AddLine(size, text, font)
7384
and not font then
7485
font = "FONTIN SC"
7586
end
87+
88+
-- Handle wrapping with color continuity
7689
if self.maxWidth then
77-
for _, line in ipairs(main:WrapString(line, size, self.maxWidth - H_PAD)) do
78-
t_insert(self.lines, { size = size, text = line, block = #self.blocks, font = font or "VAR" })
90+
local wrapped = main:WrapString(line, size, self.maxWidth - H_PAD)
91+
local lastColor = line:match("(%^[x%dA-Fa-f]+)[^%^]*$") or colorPrefix
92+
for i, linePart in ipairs(wrapped) do
93+
-- Ensure each wrapped segment keeps last known color
94+
if not linePart:find("^%^[x%dA-Fa-f]+") then
95+
linePart = (lastColor or "") .. linePart
96+
end
97+
-- Update lastColor if another color code appears
98+
lastColor = linePart:match("(%^[x%dA-Fa-f]+)[^%^]*$") or lastColor
99+
t_insert(self.lines, { size = size, text = linePart, block = #self.blocks, font = font or "VAR", background = background })
79100
end
80101
else
81-
t_insert(self.lines, { size = size, text = line, block = #self.blocks, font = font or "VAR" })
102+
t_insert(self.lines, { size = size, text = line, block = #self.blocks, font = font or "VAR", background = background })
82103
end
83104
end
84105
end
@@ -237,9 +258,9 @@ function TooltipClass:CalculateColumns(ttY, ttX, ttH, ttW, viewPort)
237258

238259
local font = data.font or "VAR"
239260
if self.center then
240-
t_insert(drawStack, {x + ttW / 2, y, "CENTER_X", data.size, font, data.text})
261+
t_insert(drawStack, {x + ttW / 2, y, "CENTER_X", data.size, font, data.text, background = data.background})
241262
else
242-
t_insert(drawStack, {x + 6, y, "LEFT", data.size, font, data.text})
263+
t_insert(drawStack, {x + 6, y, "LEFT", data.size, font, data.text, background = data.background})
243264
end
244265
y = y + data.size + 2
245266

@@ -422,6 +443,31 @@ function TooltipClass:Draw(x, y, w, h, viewPort)
422443
end
423444
end
424445
else
446+
-- Draw background if specified, used for gem mod lines and desecrated mods on items.
447+
local bg = line.background
448+
if bg then
449+
if type(bg) == "string" then
450+
if not self._bgHandles then
451+
self._bgHandles = {}
452+
end
453+
if not self._bgHandles[bg] then
454+
local h = NewImageHandle()
455+
h:Load("Assets/" .. bg .. ".png")
456+
self._bgHandles[bg] = h
457+
end
458+
bg = self._bgHandles[bg]
459+
end
460+
461+
local x = ttX
462+
local y = line[2] - 2
463+
local width = ttW - 8
464+
local height = line[4] + 3
465+
466+
SetDrawColor(1,1,1,1)
467+
DrawImage(bg, x + 4, y, width, height)
468+
end
469+
470+
-- Draw text line
425471
DrawString(unpack(line))
426472
end
427473
end

src/Modules/ItemTools.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ function itemLib.formatModLine(modLine, dbMode)
331331
line = line .. " ^1'" .. modLine.extra .. "'"
332332
end
333333
else
334-
colorCode = (modLine.enchant and colorCodes.ENCHANTED) or (modLine.fractured and colorCodes.FRACTURED) or (modLine.desecrated and colorCodes.DESECRATED) or (modLine.custom and colorCodes.CUSTOM) or colorCodes.MAGIC
334+
colorCode = (modLine.enchant and colorCodes.ENCHANTED) or (modLine.fractured and colorCodes.FRACTURED) or (modLine.custom and colorCodes.CUSTOM) or colorCodes.MAGIC
335335
end
336336
return colorCode..line
337337
end

0 commit comments

Comments
 (0)