2020-01-10 13:14:11 +00:00
|
|
|
Class KF2Style extends GUIStyleBase;
|
|
|
|
|
2021-06-12 20:11:37 +00:00
|
|
|
`include(Build.uci)
|
|
|
|
`include(Logger.uci)
|
|
|
|
|
2020-01-10 13:14:11 +00:00
|
|
|
var Texture2D LoadedTex[2];
|
|
|
|
const TOOLTIP_BORDER=4;
|
|
|
|
|
|
|
|
function InitStyle()
|
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local byte i;
|
|
|
|
|
|
|
|
Super.InitStyle();
|
|
|
|
|
|
|
|
LoadedTex[0] = Texture2D(DynamicLoadObject("EditorMaterials.CASC_ModuleEnable",class'Texture2D'));
|
|
|
|
LoadedTex[1] = Texture2D(DynamicLoadObject("EditorMaterials.Tick",class'Texture2D'));
|
2021-06-13 02:53:33 +00:00
|
|
|
for (i=0; i < ArrayCount(LoadedTex); ++i)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
if (LoadedTex[i] == None)
|
2021-05-16 09:40:02 +00:00
|
|
|
LoadedTex[i] = Texture2D'EngineMaterials.DefaultWhiteGrid';
|
|
|
|
}
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
2021-06-13 02:53:33 +00:00
|
|
|
function RenderFramedWindow( KFGUI_FloatingWindow P)
|
2020-01-10 13:14:11 +00:00
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local int XS,YS,CornerSlope,TitleHeight;
|
|
|
|
|
|
|
|
XS = Canvas.ClipX-Canvas.OrgX;
|
|
|
|
YS = Canvas.ClipY-Canvas.OrgY;
|
|
|
|
CornerSlope = DefaultHeight*0.4;
|
|
|
|
TitleHeight = DefaultHeight;
|
|
|
|
|
|
|
|
// Frame Header
|
2021-06-13 02:53:33 +00:00
|
|
|
if (P.bWindowFocused)
|
2021-05-16 09:40:02 +00:00
|
|
|
Canvas.SetDrawColor(220,2,2,255);
|
|
|
|
else Canvas.SetDrawColor(100,1,1,P.FrameOpacity);
|
|
|
|
Canvas.SetPos(0,0);
|
|
|
|
DrawCornerTex(CornerSlope,0);
|
|
|
|
Canvas.SetPos(0,TitleHeight);
|
|
|
|
DrawCornerTex(CornerSlope,3);
|
|
|
|
Canvas.SetPos(XS-CornerSlope,0);
|
|
|
|
DrawCornerTex(CornerSlope,1);
|
|
|
|
Canvas.SetPos(XS-CornerSlope,TitleHeight);
|
|
|
|
DrawCornerTex(CornerSlope,2);
|
|
|
|
|
|
|
|
// Header filling
|
|
|
|
Canvas.SetPos(0,CornerSlope);
|
|
|
|
DrawWhiteBox(XS,TitleHeight-CornerSlope);
|
|
|
|
Canvas.SetPos(CornerSlope,0);
|
|
|
|
DrawWhiteBox(XS-(CornerSlope*2),CornerSlope);
|
|
|
|
|
|
|
|
// Frame itself.
|
2021-06-13 02:53:33 +00:00
|
|
|
if (P.bWindowFocused)
|
2021-05-16 09:40:02 +00:00
|
|
|
Canvas.SetDrawColor(32,6,6,255);
|
|
|
|
else Canvas.SetDrawColor(16,2,2,P.FrameOpacity);
|
|
|
|
Canvas.SetPos(0,TitleHeight);
|
|
|
|
DrawCornerTex(CornerSlope,0);
|
|
|
|
Canvas.SetPos(XS-CornerSlope,TitleHeight);
|
|
|
|
DrawCornerTex(CornerSlope,1);
|
|
|
|
Canvas.SetPos(0,YS-CornerSlope);
|
|
|
|
DrawCornerTex(CornerSlope,2);
|
|
|
|
Canvas.SetPos(XS-CornerSlope,YS-CornerSlope);
|
|
|
|
DrawCornerTex(CornerSlope,3);
|
|
|
|
|
|
|
|
// Filling
|
|
|
|
Canvas.SetPos(CornerSlope,TitleHeight);
|
|
|
|
DrawWhiteBox(XS-(CornerSlope*2),YS-TitleHeight);
|
|
|
|
Canvas.SetPos(0,TitleHeight+CornerSlope);
|
|
|
|
DrawWhiteBox(CornerSlope,YS-(CornerSlope*2)-TitleHeight);
|
|
|
|
Canvas.SetPos(XS-CornerSlope,TitleHeight+CornerSlope);
|
|
|
|
DrawWhiteBox(CornerSlope,YS-(CornerSlope*2)-TitleHeight);
|
|
|
|
|
|
|
|
// Title.
|
2021-06-13 02:53:33 +00:00
|
|
|
if (P.WindowTitle != "")
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
Canvas.SetDrawColor(250,250,250,P.FrameOpacity);
|
|
|
|
Canvas.SetPos(CornerSlope,0);
|
|
|
|
DrawText(P.WindowTitle);
|
|
|
|
}
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
2021-06-13 02:53:33 +00:00
|
|
|
function RenderWindow( KFGUI_Page P)
|
2020-01-10 13:14:11 +00:00
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local int XS,YS,CornerSlope;
|
|
|
|
|
|
|
|
XS = Canvas.ClipX-Canvas.OrgX;
|
|
|
|
YS = Canvas.ClipY-Canvas.OrgY;
|
|
|
|
CornerSlope = DefaultHeight*0.4;
|
|
|
|
|
|
|
|
// Frame itself.
|
2021-06-13 02:53:33 +00:00
|
|
|
if (P.bWindowFocused)
|
2021-05-16 09:40:02 +00:00
|
|
|
Canvas.SetDrawColor(64,64,64,255);
|
|
|
|
else Canvas.SetDrawColor(32,32,32,P.FrameOpacity);
|
|
|
|
Canvas.SetPos(0,0);
|
|
|
|
DrawCornerTex(CornerSlope,0);
|
|
|
|
Canvas.SetPos(XS-CornerSlope,0);
|
|
|
|
DrawCornerTex(CornerSlope,1);
|
|
|
|
Canvas.SetPos(0,YS-CornerSlope);
|
|
|
|
DrawCornerTex(CornerSlope,2);
|
|
|
|
Canvas.SetPos(XS-CornerSlope,YS-CornerSlope);
|
|
|
|
DrawCornerTex(CornerSlope,3);
|
|
|
|
|
|
|
|
// Filling
|
|
|
|
Canvas.SetPos(CornerSlope,0);
|
|
|
|
DrawWhiteBox(XS-(CornerSlope*2),YS);
|
|
|
|
Canvas.SetPos(0,CornerSlope);
|
|
|
|
DrawWhiteBox(CornerSlope,YS-(CornerSlope*2));
|
|
|
|
Canvas.SetPos(XS-CornerSlope,CornerSlope);
|
|
|
|
DrawWhiteBox(CornerSlope,YS-(CornerSlope*2));
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
2021-06-13 02:53:33 +00:00
|
|
|
function RenderToolTip( KFGUI_Tooltip TT)
|
2020-01-10 13:14:11 +00:00
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local int i;
|
|
|
|
local float X,Y,XS,YS,TX,TY,TS,DefFontHeight;
|
|
|
|
|
|
|
|
Canvas.Font = PickFont(TS);
|
|
|
|
|
|
|
|
// First compute textbox size.
|
|
|
|
TY = DefaultHeight*TT.Lines.Length;
|
2021-06-13 02:53:33 +00:00
|
|
|
for (i=0; i < TT.Lines.Length; ++i)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
if (TT.Lines[i] != "")
|
2021-05-16 09:40:02 +00:00
|
|
|
Canvas.TextSize(TT.Lines[i],XS,YS);
|
|
|
|
TX = FMax(XS,TX);
|
|
|
|
}
|
|
|
|
TX*=TS;
|
|
|
|
|
|
|
|
// Give some borders.
|
|
|
|
TX += TOOLTIP_BORDER*2;
|
|
|
|
TY += TOOLTIP_BORDER*2;
|
|
|
|
|
|
|
|
X = TT.CompPos[0];
|
|
|
|
Y = TT.CompPos[1]+24.f;
|
|
|
|
|
|
|
|
// Then check if too close to window edge, then move it to another pivot.
|
2021-06-13 02:53:33 +00:00
|
|
|
if ((X+TX) > TT.Owner.ScreenSize.X)
|
2021-05-16 09:40:02 +00:00
|
|
|
X = TT.Owner.ScreenSize.X-TX;
|
2021-06-13 02:53:33 +00:00
|
|
|
if ((Y+TY) > TT.Owner.ScreenSize.Y)
|
2021-05-16 09:40:02 +00:00
|
|
|
Y = TT.CompPos[1]-TY;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (TT.CurrentAlpha < 255)
|
2021-05-16 09:40:02 +00:00
|
|
|
TT.CurrentAlpha = Min(TT.CurrentAlpha+25,255);
|
|
|
|
|
|
|
|
// Reset clipping.
|
|
|
|
Canvas.SetOrigin(0,0);
|
|
|
|
Canvas.SetClip(TT.Owner.ScreenSize.X,TT.Owner.ScreenSize.Y);
|
|
|
|
|
|
|
|
// Draw frame.
|
|
|
|
Canvas.SetDrawColor(200,200,80,TT.CurrentAlpha);
|
|
|
|
Canvas.SetPos(X-2,Y-2);
|
|
|
|
DrawBoxHollow(X-2,Y-2,TX+4,TY+4,2);
|
|
|
|
Canvas.SetDrawColor(80,10,80,TT.CurrentAlpha);
|
|
|
|
Canvas.SetPos(X,Y);
|
|
|
|
DrawWhiteBox(TX,TY);
|
|
|
|
|
|
|
|
DefFontHeight = DefaultHeight;
|
|
|
|
|
|
|
|
// Draw text.
|
|
|
|
Canvas.SetDrawColor(255,255,255,TT.CurrentAlpha);
|
|
|
|
X+=TOOLTIP_BORDER;
|
|
|
|
Y+=TOOLTIP_BORDER;
|
2021-06-13 02:53:33 +00:00
|
|
|
for (i=0; i < TT.Lines.Length; ++i)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
Canvas.SetPos(X,Y);
|
|
|
|
Canvas.DrawText(TT.Lines[i],,TS,TS,TT.TextFontInfo);
|
|
|
|
Y+=DefFontHeight;
|
|
|
|
}
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
2021-06-13 02:53:33 +00:00
|
|
|
function RenderScrollBar( KFGUI_ScrollBarBase S)
|
2020-01-10 13:14:11 +00:00
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local float A;
|
|
|
|
local byte i;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (S.bDisabled)
|
2021-05-16 09:40:02 +00:00
|
|
|
Canvas.SetDrawColor(5, 5, 5, 0);
|
2021-06-13 02:53:33 +00:00
|
|
|
else if (S.bFocused || S.bGrabbedScroller)
|
2021-05-16 09:40:02 +00:00
|
|
|
Canvas.SetDrawColor(15, 15, 15, 160);
|
|
|
|
else Canvas.SetDrawColor(15, 15, 15, 160);
|
|
|
|
|
|
|
|
DrawRectBox (0.f, 0.f, S.CompPos[2], S.CompPos[3], 4);
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (S.bDisabled)
|
2021-05-16 09:40:02 +00:00
|
|
|
return;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (S.bVertical)
|
2021-05-16 09:40:02 +00:00
|
|
|
i = 3;
|
|
|
|
else i = 2;
|
|
|
|
|
|
|
|
S.SliderScale = FMax(S.PageStep * (S.CompPos[i] - 32.f) / (S.MaxRange + S.PageStep),S.CalcButtonScale);
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (S.bGrabbedScroller)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
// Track mouse.
|
2021-06-13 02:53:33 +00:00
|
|
|
if (S.bVertical)
|
2021-05-16 09:40:02 +00:00
|
|
|
A = S.Owner.MousePosition.Y - S.CompPos[1] - S.GrabbedOffset;
|
|
|
|
else A = S.Owner.MousePosition.X - S.CompPos[0] - S.GrabbedOffset;
|
|
|
|
|
|
|
|
A /= ((S.CompPos[i]-S.SliderScale) / float(S.MaxRange));
|
|
|
|
S.SetValue(A);
|
|
|
|
}
|
|
|
|
|
|
|
|
A = float(S.CurrentScroll) / float(S.MaxRange);
|
|
|
|
S.ButtonOffset = A*(S.CompPos[i]-S.SliderScale);
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (S.bGrabbedScroller)
|
2021-05-16 09:40:02 +00:00
|
|
|
Canvas.SetDrawColor(255,0,0,200);
|
2021-06-13 02:53:33 +00:00
|
|
|
else if (S.bFocused)
|
2021-05-16 09:40:02 +00:00
|
|
|
Canvas.SetDrawColor(200,0,0,200);
|
|
|
|
else Canvas.SetDrawColor(150,0,0,200);
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (S.bVertical)
|
2021-05-16 09:40:02 +00:00
|
|
|
DrawRectBox (0.f, S.ButtonOffset, S.CompPos[2], S.SliderScale, 4);
|
|
|
|
else DrawRectBox (S.ButtonOffset, 0.f, S.SliderScale, S.CompPos[3], 4);
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
2021-06-13 02:53:33 +00:00
|
|
|
function RenderColumnHeader( KFGUI_ColumnTop C, float XPos, float Width, int Index, bool bFocus, bool bSort)
|
2020-01-10 13:14:11 +00:00
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local int XS;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (bSort)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
if (bFocus)
|
2021-05-16 09:40:02 +00:00
|
|
|
Canvas.SetDrawColor(175,240,8,255);
|
|
|
|
else Canvas.SetDrawColor(128,200,56,255);
|
|
|
|
}
|
2021-06-13 02:53:33 +00:00
|
|
|
else if (bFocus)
|
2021-05-16 09:40:02 +00:00
|
|
|
Canvas.SetDrawColor(220,220,8,255);
|
|
|
|
else Canvas.SetDrawColor(220,86,56,255);
|
|
|
|
|
|
|
|
XS = DefaultHeight*0.125;
|
|
|
|
Canvas.SetPos(XPos,0.f);
|
|
|
|
DrawCornerTexNU(XS,C.CompPos[3],0);
|
|
|
|
Canvas.SetPos(XPos+XS,0.f);
|
|
|
|
DrawWhiteBox(Width-(XS*2),C.CompPos[3]);
|
|
|
|
Canvas.SetPos(XPos+Width-(XS*2),0.f);
|
|
|
|
DrawCornerTexNU(XS,C.CompPos[3],1);
|
|
|
|
|
|
|
|
Canvas.SetDrawColor(250,250,250,255);
|
|
|
|
Canvas.SetPos(XPos+XS,(C.CompPos[3]-C.ListOwner.TextHeight)*0.5f);
|
|
|
|
C.ListOwner.DrawStrClipped(C.ListOwner.Columns[Index].Text);
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
2021-06-13 02:53:33 +00:00
|
|
|
function RenderCheckbox( KFGUI_CheckBox C)
|
2020-01-10 13:14:11 +00:00
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
if (C.bDisabled)
|
2021-05-16 09:40:02 +00:00
|
|
|
Canvas.SetDrawColor(86,86,86,255);
|
2021-06-13 02:53:33 +00:00
|
|
|
else if (C.bPressedDown)
|
2021-05-16 09:40:02 +00:00
|
|
|
Canvas.SetDrawColor(128,255,128,255);
|
2021-06-13 02:53:33 +00:00
|
|
|
else if (C.bFocused)
|
2021-05-16 09:40:02 +00:00
|
|
|
Canvas.SetDrawColor(150,200,128,255);
|
|
|
|
else Canvas.SetDrawColor(128,186,128,255);
|
|
|
|
|
|
|
|
Canvas.SetPos(0.f,0.f);
|
|
|
|
Canvas.DrawTileStretched(LoadedTex[0],C.CompPos[2],C.CompPos[3],0,0,LoadedTex[0].GetSurfaceWidth(),LoadedTex[0].GetSurfaceHeight());
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (C.bChecked)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
if (C.bDisabled)
|
2021-05-16 09:40:02 +00:00
|
|
|
Canvas.SetDrawColor(128,128,128,255);
|
|
|
|
else Canvas.SetDrawColor(255,255,255,255);
|
|
|
|
Canvas.SetPos(0.f,0.f);
|
|
|
|
Canvas.DrawTile(LoadedTex[1],C.CompPos[2],C.CompPos[3],0,0,LoadedTex[1].GetSurfaceWidth(),LoadedTex[1].GetSurfaceHeight());
|
|
|
|
}
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
2021-06-13 02:53:33 +00:00
|
|
|
function RenderComboBox( KFGUI_ComboBox C)
|
2020-01-10 13:14:11 +00:00
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
if (C.bDisabled)
|
2021-05-16 09:40:02 +00:00
|
|
|
Canvas.SetDrawColor(64,4,4,255);
|
2021-06-13 02:53:33 +00:00
|
|
|
else if (C.bPressedDown)
|
2021-05-16 09:40:02 +00:00
|
|
|
Canvas.SetDrawColor(220,56,56,255);
|
2021-06-13 02:53:33 +00:00
|
|
|
else if (C.bFocused)
|
2021-05-16 09:40:02 +00:00
|
|
|
Canvas.SetDrawColor(190,48,48,255);
|
|
|
|
else Canvas.SetDrawColor(186,4,4,255);
|
|
|
|
|
|
|
|
Canvas.SetPos(0.f,0.f);
|
|
|
|
DrawWhiteBox(C.CompPos[2],C.CompPos[3]);
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (C.SelectedIndex < C.Values.Length && C.Values[C.SelectedIndex] != "")
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
Canvas.SetPos(C.BorderSize,(C.CompPos[3]-C.TextHeight)*0.5);
|
2021-06-13 02:53:33 +00:00
|
|
|
if (C.bDisabled)
|
2021-05-16 09:40:02 +00:00
|
|
|
Canvas.DrawColor = C.TextColor*0.5f;
|
|
|
|
else Canvas.DrawColor = C.TextColor;
|
|
|
|
Canvas.PushMaskRegion(Canvas.OrgX,Canvas.OrgY,Canvas.ClipX-C.BorderSize,Canvas.ClipY);
|
|
|
|
Canvas.DrawText(C.Values[C.SelectedIndex],,C.TextScale,C.TextScale,C.TextFontInfo);
|
|
|
|
Canvas.PopMaskRegion();
|
|
|
|
}
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
2021-06-13 02:53:33 +00:00
|
|
|
function RenderComboList( KFGUI_ComboSelector C)
|
2020-01-10 13:14:11 +00:00
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local float X,Y,YL,YP,Edge;
|
|
|
|
local int i;
|
|
|
|
local bool bCheckMouse;
|
|
|
|
|
|
|
|
// Draw background.
|
|
|
|
Edge = C.Combo.BorderSize;
|
|
|
|
Canvas.SetPos(0.f,0.f);
|
|
|
|
Canvas.SetDrawColor(128,4,4,255);
|
|
|
|
DrawWhiteBox(C.CompPos[2],C.CompPos[3]);
|
|
|
|
Canvas.SetPos(Edge,Edge);
|
|
|
|
Canvas.SetDrawColor(64,4,4,255);
|
|
|
|
DrawWhiteBox(C.CompPos[2]-(Edge*2.f),C.CompPos[3]-(Edge*2.f));
|
|
|
|
|
|
|
|
// While rendering, figure out mouse focus row.
|
|
|
|
X = C.Owner.MousePosition.X - Canvas.OrgX;
|
|
|
|
Y = C.Owner.MousePosition.Y - Canvas.OrgY;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
bCheckMouse = (X > 0.f && X < C.CompPos[2] && Y > 0.f && Y < C.CompPos[3]);
|
2021-05-16 09:40:02 +00:00
|
|
|
|
|
|
|
Canvas.Font = C.Combo.TextFont;
|
|
|
|
YL = C.Combo.TextHeight;
|
|
|
|
|
|
|
|
YP = Edge;
|
|
|
|
C.CurrentRow = -1;
|
|
|
|
|
|
|
|
Canvas.PushMaskRegion(Canvas.OrgX,Canvas.OrgY,Canvas.ClipX,Canvas.ClipY);
|
2021-06-13 02:53:33 +00:00
|
|
|
for (i=0; i < C.Combo.Values.Length; ++i)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
if (bCheckMouse && Y >= YP && Y <= (YP+YL))
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
bCheckMouse = false;
|
|
|
|
C.CurrentRow = i;
|
|
|
|
Canvas.SetPos(4.f,YP);
|
|
|
|
Canvas.SetDrawColor(128,48,48,255);
|
|
|
|
DrawWhiteBox(C.CompPos[2]-(Edge*2.f),YL);
|
|
|
|
}
|
|
|
|
Canvas.SetPos(Edge,YP);
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (i == C.Combo.SelectedIndex)
|
2021-05-16 09:40:02 +00:00
|
|
|
Canvas.DrawColor = C.Combo.SelectedTextColor;
|
|
|
|
else Canvas.DrawColor = C.Combo.TextColor;
|
|
|
|
|
|
|
|
Canvas.DrawText(C.Combo.Values[i],,C.Combo.TextScale,C.Combo.TextScale,C.Combo.TextFontInfo);
|
|
|
|
|
|
|
|
YP+=YL;
|
|
|
|
}
|
|
|
|
Canvas.PopMaskRegion();
|
2021-06-13 02:53:33 +00:00
|
|
|
if (C.OldRow != C.CurrentRow)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
C.OldRow = C.CurrentRow;
|
|
|
|
C.PlayMenuSound(MN_DropdownChange);
|
|
|
|
}
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
2021-06-13 02:53:33 +00:00
|
|
|
function RenderRightClickMenu( KFGUI_RightClickMenu C)
|
2020-01-10 13:14:11 +00:00
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local float X,Y,YP,Edge,TextScale,TexDefHieght;
|
|
|
|
local int i;
|
|
|
|
local bool bCheckMouse;
|
|
|
|
|
|
|
|
// Draw background.
|
|
|
|
Edge = C.EdgeSize;
|
|
|
|
Canvas.SetDrawColor(148,4,4,255);
|
|
|
|
DrawBoxHollow(0.f,0.f,C.CompPos[2],C.CompPos[3],Edge);
|
|
|
|
Canvas.SetPos(Edge,Edge);
|
|
|
|
Canvas.SetDrawColor(64,4,4,200);
|
|
|
|
DrawWhiteBox(C.CompPos[2]-(Edge*2.f),C.CompPos[3]-(Edge*2.f));
|
|
|
|
|
|
|
|
// While rendering, figure out mouse focus row.
|
|
|
|
X = C.Owner.MousePosition.X - Canvas.OrgX;
|
|
|
|
Y = C.Owner.MousePosition.Y - Canvas.OrgY;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
bCheckMouse = (X > 0.f && X < C.CompPos[2] && Y > 0.f && Y < C.CompPos[3]);
|
2021-05-16 09:40:02 +00:00
|
|
|
|
|
|
|
Canvas.Font = PickFont(TextScale);
|
|
|
|
|
|
|
|
YP = Edge;
|
|
|
|
C.CurrentRow = -1;
|
|
|
|
|
|
|
|
TexDefHieght = DefaultHeight;
|
|
|
|
|
|
|
|
Canvas.PushMaskRegion(Canvas.OrgX,Canvas.OrgY,Canvas.ClipX,Canvas.ClipY);
|
2021-06-13 02:53:33 +00:00
|
|
|
for (i=0; i < C.ItemRows.Length; ++i)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
if (bCheckMouse && Y >= YP && Y <= (YP+TexDefHieght))
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
bCheckMouse = false;
|
|
|
|
C.CurrentRow = i;
|
|
|
|
Canvas.SetPos(4.f,YP);
|
|
|
|
Canvas.SetDrawColor(128,48,48,255);
|
|
|
|
DrawWhiteBox(C.CompPos[2]-(Edge*2.f),TexDefHieght);
|
|
|
|
}
|
|
|
|
|
|
|
|
Canvas.SetPos(Edge,YP);
|
2021-06-13 02:53:33 +00:00
|
|
|
if (C.ItemRows[i].bSplitter)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
Canvas.SetDrawColor(0,0,0,255);
|
|
|
|
Canvas.DrawText("-------",,TextScale,TextScale);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
if (C.ItemRows[i].bDisabled)
|
2021-05-16 09:40:02 +00:00
|
|
|
Canvas.SetDrawColor(148,148,148,255);
|
|
|
|
else Canvas.SetDrawColor(248,248,248,255);
|
|
|
|
Canvas.DrawText(C.ItemRows[i].Text,,TextScale,TextScale);
|
|
|
|
}
|
|
|
|
|
|
|
|
YP+=TexDefHieght;
|
|
|
|
}
|
|
|
|
Canvas.PopMaskRegion();
|
2021-06-13 02:53:33 +00:00
|
|
|
if (C.OldRow != C.CurrentRow)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
C.OldRow = C.CurrentRow;
|
|
|
|
C.PlayMenuSound(MN_DropdownChange);
|
|
|
|
}
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
2021-06-13 02:53:33 +00:00
|
|
|
function RenderButton( KFGUI_Button B)
|
2020-01-10 13:14:11 +00:00
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local float XL,YL,TS;
|
|
|
|
local byte i;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (B.bDisabled)
|
2021-05-16 09:40:02 +00:00
|
|
|
Canvas.SetDrawColor(32,0,0,255);
|
2021-06-13 02:53:33 +00:00
|
|
|
else if (B.bPressedDown)
|
2021-05-16 09:40:02 +00:00
|
|
|
Canvas.SetDrawColor(255,64,64,255);
|
2021-06-13 02:53:33 +00:00
|
|
|
else if (B.bFocused)
|
2021-05-16 09:40:02 +00:00
|
|
|
Canvas.SetDrawColor(180,45,45,255);
|
|
|
|
else Canvas.SetDrawColor(164,8,8,255);
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (B.bIsHighlighted)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
Canvas.DrawColor.R = Min(Canvas.DrawColor.R+25,255);
|
|
|
|
Canvas.DrawColor.G = Min(Canvas.DrawColor.G+25,255);
|
|
|
|
Canvas.DrawColor.B = Min(Canvas.DrawColor.B+25,255);
|
|
|
|
}
|
|
|
|
|
|
|
|
Canvas.SetPos(0.f,0.f);
|
2021-06-13 02:53:33 +00:00
|
|
|
if (B.ExtravDir == 255)
|
2021-05-16 09:40:02 +00:00
|
|
|
DrawWhiteBox(B.CompPos[2],B.CompPos[3]);
|
|
|
|
else DrawRectBox(0,0,B.CompPos[2],B.CompPos[3],Min(B.CompPos[2],B.CompPos[3])*0.2,B.ExtravDir);
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (B.OverlayTexture.Texture != None)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
Canvas.SetPos(0.f,0.f);
|
|
|
|
Canvas.DrawTile(B.OverlayTexture.Texture,B.CompPos[2],B.CompPos[3],B.OverlayTexture.U,B.OverlayTexture.V,B.OverlayTexture.UL,B.OverlayTexture.VL);
|
|
|
|
}
|
2021-06-13 02:53:33 +00:00
|
|
|
if (B.ButtonText != "")
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
// Chose the best font to fit this button.
|
|
|
|
i = Min(B.FontScale,MaxFontScale);
|
2021-06-13 02:53:33 +00:00
|
|
|
while( true)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
Canvas.Font = PickFont(TS);
|
|
|
|
Canvas.TextSize(B.ButtonText,XL,YL,TS,TS);
|
2021-06-13 02:53:33 +00:00
|
|
|
if (i == 0 || (XL < (B.CompPos[2]*0.95) && YL < (B.CompPos[3]*0.95)))
|
2021-05-16 09:40:02 +00:00
|
|
|
break;
|
|
|
|
--i;
|
|
|
|
}
|
|
|
|
Canvas.SetPos((B.CompPos[2]-XL)*0.5,(B.CompPos[3]-YL)*0.5);
|
2021-06-13 02:53:33 +00:00
|
|
|
if (B.bDisabled)
|
2021-05-16 09:40:02 +00:00
|
|
|
Canvas.DrawColor = B.TextColor*0.5f;
|
|
|
|
else Canvas.DrawColor = B.TextColor;
|
|
|
|
Canvas.DrawText(B.ButtonText,,TS,TS,B.TextFontInfo);
|
|
|
|
}
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
defaultproperties
|
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
MaxFontScale=5
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|