@@ -1283,15 +1283,26 @@ local function UpdatePanelWidthsIfNeeded(caption, parentPanel, otherPanel)
12831283 if parentPanel .name ~= " leftPanel" or caption == nil then
12841284 return
12851285 end
1286+ local isTooltipVersion = parentPanel .parent .name == " tooltipWindow"
12861287 local n = string.len (caption )
1287- if nMaxCaptionCharacters ~= nil and n <= nMaxCaptionCharacters then
1288+ local nMax = nil
1289+ if isTooltipVersion then
1290+ nMax = nMaxCaptionCharactersForTooltip
1291+ else
1292+ nMax = nMaxCaptionCharactersForSelection
1293+ end
1294+ if nMax ~= nil and n <= nMax then
12881295 return
12891296 end
1290- nMaxCaptionCharacters = n
1297+ if isTooltipVersion then
1298+ nMaxCaptionCharactersForTooltip = n
1299+ else
1300+ nMaxCaptionCharactersForSelection = n
1301+ end
12911302 local w = LEFT_WIDTH
1292- if nMaxCaptionCharacters > 10 then
1303+ if n > 10 then
12931304 -- icon, characters minus the color tags (HACK this assumes that the string has color tags)
1294- w = ICON_SIZE + nMaxCaptionCharacters * 5 - 4
1305+ w = ICON_SIZE + n * 5 - 4
12951306 end
12961307 if w ~= parentPanel .minWidth then
12971308 parentPanel .minWidth = w
@@ -2465,6 +2476,15 @@ local function GetSingleUnitInfoPanel(parentControl, isTooltipVersion)
24652476 rightPanel :SetVisibility (newVisible )
24662477 end
24672478
2479+ function externalFunctions .ResetPanelWidths ()
2480+ local w = LEFT_WIDTH
2481+ if leftPanel .minWidth ~= w then
2482+ leftPanel .minWidth = w
2483+ leftPanel :Resize (w , leftPanel .height )
2484+ rightPanel :SetPos (w , 0 )
2485+ end
2486+ end
2487+
24682488 return externalFunctions
24692489end
24702490
@@ -2744,7 +2764,7 @@ local function UpdateTooltip(dt, requiredOnly)
27442764 if visible then
27452765 tooltipWindow .SetPosition (mx + 20 / (WG .uiScale or 1 ), my - 20 / (WG .uiScale or 1 ))
27462766 else
2747- nMaxCaptionCharacters = 0
2767+ nMaxCaptionCharactersForTooltip = 0
27482768 end
27492769end
27502770
@@ -2820,6 +2840,8 @@ local function GetSelectionWindow()
28202840
28212841 function externalFunctions .ShowSingleUnit (unitID , unitDefID )
28222842 singleUnitID , singleUnitDefID = unitID , unitDefID or spGetUnitDefID (unitID )
2843+ nMaxCaptionCharactersForSelection = 0
2844+ singleUnitDisplay .ResetPanelWidths ()
28232845 singleUnitDisplay .SetDisplay (unitID , singleUnitDefID )
28242846 singleUnitDisplay .SetVisible (true )
28252847 multiUnitDisplay .SetUnitDisplay ()
@@ -2956,7 +2978,8 @@ local function InitializeWindParameters()
29562978 econMultEnabled = (Spring .GetGameRulesParam (" econ_mult_enabled" ) and true ) or false
29572979end
29582980
2959- local nMaxCaptionCharacters = 0
2981+ local nMaxCaptionCharactersForTooltip = 0
2982+ local nMaxCaptionCharactersForSelection = 0
29602983
29612984local updateTimer = 0
29622985function widget :Update (dt )
0 commit comments