2020-01-10 13:14:11 +00:00
|
|
|
Class KFGUI_Frame extends KFGUI_FloatingWindow;
|
2021-06-12 20:11:37 +00:00
|
|
|
|
|
|
|
`include(Build.uci)
|
|
|
|
`include(Logger.uci)
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
function InitMenu()
|
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
Super(KFGUI_Page).InitMenu();
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function DrawMenu()
|
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local float TempSize;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (bUseAnimation)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
TempSize = `TimeSinceEx(GetPlayer(), OpenStartTime);
|
2021-06-13 02:53:33 +00:00
|
|
|
if (WindowFadeInTime - TempSize > 0 && FrameOpacity != default.FrameOpacity)
|
2021-05-16 09:40:02 +00:00
|
|
|
FrameOpacity = (1.f - ((WindowFadeInTime - TempSize) / WindowFadeInTime)) * default.FrameOpacity;
|
|
|
|
}
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (bDrawBackground)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
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;
|
2021-05-16 09:40:02 +00:00
|
|
|
local FontRenderInfo FRI;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (FrameTex == None)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
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-05-16 09:40:02 +00:00
|
|
|
{
|
2021-06-13 02:54:35 +00:00
|
|
|
Owner.CurrentStyle.DrawTileStretched(FrameTex, 0,0, W,H);
|
2021-05-16 09:40:02 +00:00
|
|
|
}
|
|
|
|
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-05-16 09:40:02 +00:00
|
|
|
}
|
2020-01-10 13:14:11 +00:00
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (bDrawHeader && WindowTitle != "")
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
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);
|
2021-05-16 09:40:02 +00:00
|
|
|
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-05-16 09:40:02 +00:00
|
|
|
|
2021-06-13 02:54:35 +00:00
|
|
|
C.DrawText(WindowTitle, ,T, T,FRI);
|
2021-05-16 09:40:02 +00:00
|
|
|
}
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function PreDraw()
|
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local int i;
|
|
|
|
local byte j;
|
|
|
|
local float Frac, CenterX, CenterY;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (!bVisible)
|
2021-05-16 09:40:02 +00:00
|
|
|
return;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (bUseAnimation)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
2020-01-10 13:14:11 +00:00
|
|
|
|
2021-05-16 09:40:02 +00:00
|
|
|
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]);
|
2021-05-16 09:40:02 +00:00
|
|
|
DrawMenu();
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
for (i=0; i < Components.Length; ++i)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
Components[i].Canvas = Canvas;
|
2021-06-13 02:53:33 +00:00
|
|
|
for (j=0; j < 4; ++j)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
Components[i].InputPos[j] = CompPos[j]+EdgeSize[j];
|
|
|
|
}
|
|
|
|
Components[i].PreDraw();
|
|
|
|
}
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
defaultproperties
|
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
bUseAnimation=false
|
|
|
|
bDrawHeader=true
|
|
|
|
bUseLegacyDrawTile=true
|
|
|
|
bDrawBackground=true
|
|
|
|
|
|
|
|
FontScale=0.35f
|
|
|
|
FrameOpacity=255
|
|
|
|
|
|
|
|
HeaderSize(0)=26.f
|
|
|
|
HeaderSize(1)=8.f
|
2020-01-10 13:14:11 +00:00
|
|
|
|
2021-05-16 09:40:02 +00:00
|
|
|
EdgeSize(0)=20
|
|
|
|
EdgeSize(1)=35
|
|
|
|
EdgeSize(2)=-40
|
|
|
|
EdgeSize(3)=-50
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|