function AddPromotionIcon(controltable, promoID, iconPositionID, unit)
local promo = GameInfo.UnitPromotions[promoID]
IconHookup( promo.PortraitIndex, 32, promo.IconAtlas, controltable.UnitPromotionImage )
local hoverText = ""
if promo.SimpleHelpText then
hoverText = Locale.ConvertTextKey(promo.Help)
else
+ if unit:GetPromotionDuration(promoID) > 0 then
+ local sDurationTip = ""
+ sDurationTip = " (" .. Locale.ConvertTextKey("TXT_KEY_STR_TURNS", unit:GetPromotionDuration(promoID) - (Game.GetGameTurn() - unit:GetTurnPromotionGained(promoID))) .. ")"
+ hoverText = string.format("[COLOR_YELLOW]%s[ENDCOLOR]%s[NEWLINE]%s",
+ L(promo.Description),
+ sDurationTip,
+ L(promo.Help)
+ )
+ else
hoverText = string.format("[COLOR_YELLOW]%s[ENDCOLOR][NEWLINE]%s",
Locale.ConvertTextKey(promo.Description),
Locale.ConvertTextKey(promo.Help)
)
end
end
if PromotionFlagsSettings.Debug then hoverText = hoverText .. "[NEWLINE]" .. promo.Type end
if promo.RankNumber then
-- add earlier rank promotions to the tooltip (eg add Drill 1 if we have Drill 2)
local rankNum = promo.RankNumber - 1
while rankNum > 0 do
for nextPromo in GameInfo.UnitPromotions{RankList = promo.RankList, RankNumber = rankNum} do
if unit:IsHasPromotion(nextPromo.ID) then
if nextPromo.SimpleHelpText then
hoverText = string.format("%s[NEWLINE]%s",
hoverText,
Locale.ConvertTextKey(nextPromo.Help)
)
else
hoverText = string.format("%s[NEWLINE][COLOR_YELLOW]%s[ENDCOLOR][NEWLINE]%s",
hoverText,
Locale.ConvertTextKey(nextPromo.Description),
Locale.ConvertTextKey(nextPromo.Help)
)
end
if PromotionFlagsSettings.Debug then hoverText = hoverText .. "[NEWLINE]" .. nextPromo.Type end
end
end
rankNum = rankNum - 1
end
else
--Flag Promos not around to set up the rank list
-- so we'll just have to give up
end
controltable.EarnedPromotion:SetToolTipString( hoverText )
end