2017-10-25 22:21:13 +00:00
|
|
|
Class KFGUI_Tooltip_CD extends KFGUI_Tooltip;
|
|
|
|
|
|
|
|
function PreDraw()
|
|
|
|
{
|
|
|
|
local int i;
|
|
|
|
local float X,Y,XS,YS,TX,TY,TS;
|
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
if (Owner.CurrentStyle == None)
|
2017-10-25 22:21:13 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
Canvas.Font = Owner.CurrentStyle.PickFont(Owner.CurrentStyle.DefaultFontSize,TS);
|
|
|
|
|
|
|
|
// First compute textbox size.
|
|
|
|
TY = Owner.CurrentStyle.DefaultHeight*Lines.Length;
|
2020-11-28 20:12:58 +00:00
|
|
|
for (i=0; i<Lines.Length; ++i)
|
2017-10-25 22:21:13 +00:00
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
if (Lines[i]!="")
|
2017-10-25 22:21:13 +00:00
|
|
|
Canvas.TextSize(Lines[i],XS,YS);
|
|
|
|
TX = FMax(XS,TX);
|
|
|
|
}
|
|
|
|
TX*=TS;
|
|
|
|
|
|
|
|
// Give some borders.
|
|
|
|
TX += KF2Style(Owner.CurrentStyle).TOOLTIP_BORDER*2;
|
|
|
|
TY += KF2Style(Owner.CurrentStyle).TOOLTIP_BORDER*2;
|
|
|
|
|
|
|
|
X = CompPos[0];
|
|
|
|
Y = CompPos[1]+24.f;
|
|
|
|
|
|
|
|
// Then check if too close to window edge, then move it to another pivot.
|
2020-11-28 20:12:58 +00:00
|
|
|
if ((X+TX)>Owner.ScreenSize.X)
|
2017-10-25 22:21:13 +00:00
|
|
|
X = Owner.ScreenSize.X-TX;
|
2020-11-28 20:12:58 +00:00
|
|
|
if ((Y+TY)>Owner.ScreenSize.Y)
|
2017-10-25 22:21:13 +00:00
|
|
|
Y = CompPos[1]-TY;
|
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
if (CurrentAlpha<255)
|
2017-10-25 22:21:13 +00:00
|
|
|
CurrentAlpha = Min(CurrentAlpha+25,255);
|
|
|
|
|
|
|
|
// Reset clipping.
|
|
|
|
Canvas.SetOrigin(0,0);
|
|
|
|
Canvas.SetClip(Owner.ScreenSize.X,Owner.ScreenSize.Y);
|
|
|
|
|
|
|
|
// Draw frame.
|
|
|
|
//Canvas.SetDrawColor(200,200,80,CurrentAlpha);
|
|
|
|
Canvas.SetDrawColor(45, 45, 45, 160);
|
|
|
|
Canvas.SetPos(X-2,Y-2);
|
|
|
|
Owner.CurrentStyle.DrawWhiteBox(TX+4,TY+4);
|
|
|
|
//Canvas.SetDrawColor(80,10,80,CurrentAlpha);
|
|
|
|
Canvas.SetDrawColor(10, 10, 10, 160);
|
|
|
|
Canvas.SetPos(X,Y);
|
|
|
|
Owner.CurrentStyle.DrawWhiteBox(TX,TY);
|
|
|
|
|
|
|
|
// Draw text.
|
|
|
|
Canvas.SetDrawColor(255,255,255,CurrentAlpha);
|
|
|
|
X+=KF2Style(Owner.CurrentStyle).TOOLTIP_BORDER;
|
|
|
|
Y+=KF2Style(Owner.CurrentStyle).TOOLTIP_BORDER;
|
2020-11-28 20:12:58 +00:00
|
|
|
for (i=0; i<Lines.Length; ++i)
|
2017-10-25 22:21:13 +00:00
|
|
|
{
|
|
|
|
Canvas.SetPos(X,Y);
|
|
|
|
Canvas.DrawText(Lines[i],,TS,TS,TextFontInfo);
|
|
|
|
Y+=Owner.CurrentStyle.DefaultHeight;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
defaultproperties
|
|
|
|
{
|
|
|
|
}
|