@@ -53,6 +53,7 @@ function TooltipClass:Clear()
5353 self .titleYOffset = 0
5454 self .recipe = nil
5555 self .center = false
56+ self .maxWidth = nil
5657 self .color = { 0.5 , 0.3 , 0 }
5758 t_insert (self .blocks , { height = 0 })
5859end
@@ -92,11 +93,11 @@ function TooltipClass:AddLine(size, text, font)
9293 self .blocks [# self .blocks ].height = self .blocks [# self .blocks ].height + size + 2
9394 end
9495 if self .maxWidth then
95- for _ , line in ipairs (main :WrapString (line , size , self .maxWidth - H_PAD )) do
96- t_insert (self .lines , { size = size , text = line , block = # self .blocks , font = fontToUse })
96+ for _ , wrappedLine in ipairs (main :WrapString (line , size , self .maxWidth - H_PAD )) do
97+ t_insert (self .lines , { size = size , text = wrappedLine , block = # self .blocks , font = fontToUse , center = self . center })
9798 end
9899 else
99- t_insert (self .lines , { size = size , text = line , block = # self .blocks , font = fontToUse })
100+ t_insert (self .lines , { size = size , text = line , block = # self .blocks , font = fontToUse , center = self . center })
100101 end
101102 end
102103 end
@@ -263,11 +264,14 @@ function TooltipClass:CalculateColumns(ttY, ttX, ttH, ttW, viewPort)
263264 end
264265 currentBlock = data .block
265266
266- if self .center then
267- t_insert (drawStack , {x + ttW / 2 , y , " CENTER_X" , data .size , font , data .text })
268- else
269- t_insert (drawStack , {x + 6 , y , " LEFT" , data .size , font , data .text })
267+ local lineCentered = data .center
268+ if lineCentered == nil then
269+ lineCentered = self .center
270270 end
271+ local lineX = lineCentered and (x + ttW / 2 ) or (x + 6 )
272+ local lineAlign = lineCentered and " CENTER_X" or " LEFT"
273+
274+ t_insert (drawStack , {lineX , y , lineAlign , data .size , font , data .text })
271275 y = y + data .size + 2
272276
273277 elseif data .separatorImage and main .showFlavourText then
0 commit comments