KF2-YetAnotherScoreboard/YAS/Classes/KFGUI_Frame.uc

128 lines
2.9 KiB
Ucode
Raw Normal View History

2022-09-03 17:26:40 +00:00
class KFGUI_Frame extends KFGUI_FloatingWindow;
2021-06-12 20:11:37 +00:00
2020-01-10 13:14:11 +00:00
var() float EdgeSize[4]; // Pixels wide for edges (left, top, right, bottom).
var() float HeaderSize[2]; // Pixels wide for edges (left, top).
var() Texture FrameTex;
2021-06-13 02:54:35 +00:00
var() bool bDrawHeader, bHeaderCenter, bUseLegacyDrawTile, bDrawBackground;
2020-01-10 13:14:11 +00:00
var() float FontScale;
2020-01-10 13:14:11 +00:00
function InitMenu()
{
Super(KFGUI_Page).InitMenu();
2020-01-10 13:14:11 +00:00
}
function DrawMenu()
{
local float TempSize;
2021-06-13 02:53:33 +00:00
if (bUseAnimation)
{
TempSize = `TimeSinceEx(GetPlayer(), OpenStartTime);
2021-06-13 02:53:33 +00:00
if (WindowFadeInTime - TempSize > 0 && FrameOpacity != default.FrameOpacity)
FrameOpacity = (1.f - ((WindowFadeInTime - TempSize) / WindowFadeInTime)) * default.FrameOpacity;
}
2021-06-13 02:53:33 +00:00
if (bDrawBackground)
{
OnDrawFrame(Canvas, CompPos[2], CompPos[3]);
}
2020-01-10 13:14:11 +00:00
}
delegate OnDrawFrame(Canvas C, float W, Float H)
{
2021-06-13 02:54:35 +00:00
local float T, XL, YL, HeaderH;
local FontRenderInfo FRI;
2021-06-13 02:53:33 +00:00
if (FrameTex == None)
{
return;
}
2021-06-13 02:54:35 +00:00
C.SetDrawColor(255, 255, 255, FrameOpacity);
2021-06-13 02:53:33 +00:00
if (bUseLegacyDrawTile)
{
2021-06-13 02:54:35 +00:00
Owner.CurrentStyle.DrawTileStretched(FrameTex, 0,0, W,H);
}
else
{
Canvas.SetPos(0.f, 0.f);
2021-06-13 02:54:35 +00:00
Canvas.DrawTileStretched(FrameTex, W,H, 0,0, FrameTex.GetSurfaceWidth(), FrameTex.GetSurfaceHeight());
}
2021-06-13 02:53:33 +00:00
if (bDrawHeader && WindowTitle != "")
{
FRI.bClipText = true;
FRI.bEnableShadow = true;
C.Font = Owner.CurrentStyle.MainFont;
T = Owner.CurrentStyle.ScreenScale(FontScale);
2021-06-13 02:54:35 +00:00
C.SetDrawColor(250, 250, 250, FrameOpacity);
C.TextSize(WindowTitle, XL, YL, T, T);
HeaderH = EdgeSize[1]-HeaderSize[1];
2021-06-13 02:53:33 +00:00
if (bHeaderCenter)
2021-06-13 02:54:35 +00:00
C.SetPos((W/2) - (XL/2), (HeaderH/2) - (YL/2));
else C.SetPos(HeaderSize[0], (HeaderH/2) - (YL/2));
2021-06-13 02:54:35 +00:00
C.DrawText(WindowTitle, ,T, T,FRI);
}
2020-01-10 13:14:11 +00:00
}
2020-01-10 13:14:11 +00:00
function PreDraw()
{
local int i;
local byte j;
local float Frac, CenterX, CenterY;
2021-06-13 02:53:33 +00:00
if (!bVisible)
return;
2021-06-13 02:53:33 +00:00
if (bUseAnimation)
{
Frac = Owner.CurrentStyle.TimeFraction(OpenStartTime, OpenEndTime, GetPlayer().WorldInfo.RealTimeSeconds);
XSize = Lerp(default.XSize*0.75, default.XSize, Frac);
YSize = Lerp(default.YSize*0.75, default.YSize, Frac);
CenterX = (default.XPosition + default.XSize * 0.5) - ((default.XSize*0.75)/2);
CenterY = (default.YPosition + default.YSize * 0.5) - ((default.YSize*0.75)/2);
XPosition = Lerp(CenterX, default.XPosition, Frac);
YPosition = Lerp(CenterY, default.YPosition, Frac);
}
ComputeCoords();
2021-06-13 02:54:35 +00:00
Canvas.SetDrawColor(255, 255, 255);
Canvas.SetOrigin(CompPos[0], CompPos[1]);
Canvas.SetClip(CompPos[0]+CompPos[2], CompPos[1]+CompPos[3]);
DrawMenu();
2021-06-13 02:53:33 +00:00
for (i=0; i < Components.Length; ++i)
{
Components[i].Canvas = Canvas;
2021-06-13 02:53:33 +00:00
for (j=0; j < 4; ++j)
{
Components[i].InputPos[j] = CompPos[j]+EdgeSize[j];
}
Components[i].PreDraw();
}
2020-01-10 13:14:11 +00:00
}
defaultproperties
{
bUseAnimation=false
bDrawHeader=true
bUseLegacyDrawTile=true
bDrawBackground=true
FontScale=0.35f
FrameOpacity=255
HeaderSize(0)=26.f
HeaderSize(1)=8.f
EdgeSize(0)=20
EdgeSize(1)=35
EdgeSize(2)=-40
EdgeSize(3)=-50
}