2017-10-20 02:00:49 +00:00
|
|
|
Class KF2Style extends GUIStyleBase;
|
|
|
|
|
|
|
|
var Texture2D LoadedTex[2];
|
|
|
|
var Font DrawFonts[3];
|
|
|
|
|
|
|
|
const TOOLTIP_BORDER=4;
|
|
|
|
|
|
|
|
function InitStyle()
|
|
|
|
{
|
|
|
|
local byte i;
|
|
|
|
|
|
|
|
Super.InitStyle();
|
|
|
|
|
|
|
|
LoadedTex[0] = Texture2D(DynamicLoadObject("EditorMaterials.CASC_ModuleEnable",class'Texture2D'));
|
|
|
|
LoadedTex[1] = Texture2D(DynamicLoadObject("EditorMaterials.Tick",class'Texture2D'));
|
2020-11-28 20:12:58 +00:00
|
|
|
for (i=0; i<ArrayCount(LoadedTex); ++i)
|
|
|
|
if (LoadedTex[i]==None)
|
2017-10-20 02:00:49 +00:00
|
|
|
LoadedTex[i] = Texture2D'EngineMaterials.DefaultWhiteGrid';
|
2020-09-01 10:16:01 +00:00
|
|
|
// TODO: SmallFont/TinyFont not support unicode
|
2020-12-12 10:44:34 +00:00
|
|
|
DrawFonts[0] = Font(DynamicLoadObject("UI_Canvas_Fonts.Font_Main",class'Font'));
|
2017-10-20 02:00:49 +00:00
|
|
|
DrawFonts[1] = Font(DynamicLoadObject("EngineFonts.SmallFont",class'Font'));
|
|
|
|
DrawFonts[2] = Font(DynamicLoadObject("EngineFonts.TinyFont",class'Font'));
|
2020-11-28 20:12:58 +00:00
|
|
|
for (i=0; i<ArrayCount(DrawFonts); ++i)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
if (DrawFonts[i]==None)
|
2017-10-20 02:00:49 +00:00
|
|
|
DrawFonts[i] = class'Engine'.Static.GetMediumFont();
|
|
|
|
}
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
function RenderFramedWindow(KFGUI_FloatingWindow P)
|
2017-10-20 02:00:49 +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
|
2020-11-28 20:12:58 +00:00
|
|
|
if (P.bWindowFocused)
|
2017-10-20 02:00:49 +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.
|
2020-11-28 20:12:58 +00:00
|
|
|
if (P.bWindowFocused)
|
2017-10-20 02:00:49 +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.
|
2020-11-28 20:12:58 +00:00
|
|
|
if (P.WindowTitle!="")
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
Canvas.SetDrawColor(250,250,250,P.FrameOpacity);
|
|
|
|
Canvas.SetPos(CornerSlope,0);
|
|
|
|
DrawText(DefaultFontSize,P.WindowTitle);
|
|
|
|
}
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
function RenderWindow(KFGUI_Page P)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
local int XS,YS,CornerSlope;
|
|
|
|
|
|
|
|
XS = Canvas.ClipX-Canvas.OrgX;
|
|
|
|
YS = Canvas.ClipY-Canvas.OrgY;
|
|
|
|
CornerSlope = DefaultHeight*0.4;
|
|
|
|
|
|
|
|
// Frame itself.
|
2020-11-28 20:12:58 +00:00
|
|
|
if (P.bWindowFocused)
|
2017-10-20 02:00:49 +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-11-28 21:54:57 +00:00
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
function RenderToolTip(KFGUI_Tooltip TT)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
local int i;
|
|
|
|
local float X,Y,XS,YS,TX,TY,TS;
|
|
|
|
|
|
|
|
Canvas.Font = PickFont(DefaultFontSize,TS);
|
|
|
|
|
|
|
|
// First compute textbox size.
|
|
|
|
TY = DefaultHeight*TT.Lines.Length;
|
2020-11-28 20:12:58 +00:00
|
|
|
for (i=0; i<TT.Lines.Length; ++i)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
if (TT.Lines[i]!="")
|
2017-10-20 02:00:49 +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.
|
2020-11-28 20:12:58 +00:00
|
|
|
if ((X+TX)>TT.Owner.ScreenSize.X)
|
2017-10-20 02:00:49 +00:00
|
|
|
X = TT.Owner.ScreenSize.X-TX;
|
2020-11-28 20:12:58 +00:00
|
|
|
if ((Y+TY)>TT.Owner.ScreenSize.Y)
|
2017-10-20 02:00:49 +00:00
|
|
|
Y = TT.CompPos[1]-TY;
|
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
if (TT.CurrentAlpha<255)
|
2017-10-20 02:00:49 +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);
|
|
|
|
DrawWhiteBox(TX+4,TY+4);
|
|
|
|
Canvas.SetDrawColor(80,10,80,TT.CurrentAlpha);
|
|
|
|
Canvas.SetPos(X,Y);
|
|
|
|
DrawWhiteBox(TX,TY);
|
|
|
|
|
|
|
|
// Draw text.
|
|
|
|
Canvas.SetDrawColor(255,255,255,TT.CurrentAlpha);
|
|
|
|
X+=TOOLTIP_BORDER;
|
|
|
|
Y+=TOOLTIP_BORDER;
|
2020-11-28 20:12:58 +00:00
|
|
|
for (i=0; i<TT.Lines.Length; ++i)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
Canvas.SetPos(X,Y);
|
|
|
|
Canvas.DrawText(TT.Lines[i],,TS,TS,TT.TextFontInfo);
|
|
|
|
Y+=DefaultHeight;
|
|
|
|
}
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
function RenderButton(KFGUI_Button B)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
local float XL,YL,TS;
|
|
|
|
local byte i;
|
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
if (B.bDisabled)
|
2017-10-20 02:00:49 +00:00
|
|
|
Canvas.SetDrawColor(32,0,0,255);
|
2020-11-28 20:12:58 +00:00
|
|
|
else if (B.bPressedDown)
|
2017-10-20 02:00:49 +00:00
|
|
|
Canvas.SetDrawColor(255,64,64,255);
|
2020-11-28 20:12:58 +00:00
|
|
|
else if (B.bFocused)
|
2017-10-20 02:00:49 +00:00
|
|
|
Canvas.SetDrawColor(180,45,45,255);
|
|
|
|
else Canvas.SetDrawColor(164,8,8,255);
|
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
if (B.bIsHighlighted)
|
2017-10-20 02:00:49 +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);
|
2020-11-28 20:12:58 +00:00
|
|
|
if (B.ExtravDir==255)
|
2017-10-20 02:00:49 +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);
|
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
if (B.OverlayTexture.Texture!=None)
|
2017-10-20 02:00:49 +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);
|
|
|
|
}
|
2020-11-28 20:12:58 +00:00
|
|
|
if (B.ButtonText!="")
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
// Chose the best font to fit this button.
|
|
|
|
i = Min(B.FontScale+DefaultFontSize,MaxFontScale);
|
2020-11-28 20:12:58 +00:00
|
|
|
while (true)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
Canvas.Font = PickFont(i,TS);
|
|
|
|
Canvas.TextSize(B.ButtonText,XL,YL,TS,TS);
|
2020-11-28 20:12:58 +00:00
|
|
|
if (i==0 || (XL<(B.CompPos[2]*0.95) && YL<(B.CompPos[3]*0.95)))
|
2017-10-20 02:00:49 +00:00
|
|
|
break;
|
|
|
|
--i;
|
|
|
|
}
|
|
|
|
Canvas.SetPos((B.CompPos[2]-XL)*0.5,(B.CompPos[3]-YL)*0.5);
|
2020-11-28 20:12:58 +00:00
|
|
|
if (B.bDisabled)
|
2017-10-20 02:00:49 +00:00
|
|
|
Canvas.DrawColor = B.TextColor*0.5f;
|
|
|
|
else Canvas.DrawColor = B.TextColor;
|
|
|
|
Canvas.DrawText(B.ButtonText,,TS,TS,B.TextFontInfo);
|
|
|
|
}
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
function RenderEditBox(KFGUI_EditBox E)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
local color C;
|
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
if (E.bDisabled)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
Canvas.SetDrawColor(4,4,32,255);
|
|
|
|
C = MakeColor(52,52,52,255);
|
|
|
|
}
|
2020-11-28 20:12:58 +00:00
|
|
|
else if (E.bPressedDown)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
Canvas.SetDrawColor(110,110,255,255);
|
|
|
|
C = MakeColor(16,16,186,255);
|
|
|
|
}
|
2020-11-28 20:12:58 +00:00
|
|
|
else if (E.bFocused || E.bIsTyping)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
Canvas.SetDrawColor(120,120,230,255);
|
|
|
|
C = MakeColor(8,8,96,255);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Canvas.SetDrawColor(50,50,186,255);
|
|
|
|
C = MakeColor(8,8,50,255);
|
|
|
|
}
|
|
|
|
|
|
|
|
Canvas.SetPos(0.f,0.f);
|
|
|
|
DrawRectBox(0,0,E.CompPos[2],E.CompPos[3],E.TextHeight*0.15,1);
|
|
|
|
|
|
|
|
Canvas.SetPos(3.f,3.f);
|
|
|
|
Canvas.DrawColor = C;
|
|
|
|
DrawWhiteBox(E.CompPos[2]-6,E.CompPos[3]-6);
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
function RenderScrollBar(KFGUI_ScrollBarBase S)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
local float A;
|
|
|
|
local byte i;
|
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
if (S.bDisabled)
|
2017-10-20 02:00:49 +00:00
|
|
|
Canvas.SetDrawColor(48,2,2,255);
|
2020-11-28 20:12:58 +00:00
|
|
|
else if (S.bFocused || S.bGrabbedScroller)
|
2017-10-20 02:00:49 +00:00
|
|
|
Canvas.SetDrawColor(86,8,8,255);
|
|
|
|
else Canvas.SetDrawColor(74,4,4,255);
|
|
|
|
|
|
|
|
Canvas.SetPos(0.f,0.f);
|
|
|
|
DrawWhiteBox(S.CompPos[2],S.CompPos[3]);
|
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
if (S.bDisabled)
|
2017-10-20 02:00:49 +00:00
|
|
|
return;
|
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
if (S.bVertical)
|
2017-10-20 02:00:49 +00:00
|
|
|
i = 3;
|
|
|
|
else i = 2;
|
|
|
|
|
|
|
|
S.SliderScale = FMax(S.PageStep * (S.CompPos[i] - 32.f) / (S.MaxRange + S.PageStep),S.CalcButtonScale);
|
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
if (S.bGrabbedScroller)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
// Track mouse.
|
2020-11-28 20:12:58 +00:00
|
|
|
if (S.bVertical)
|
2017-10-20 02:00:49 +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);
|
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
if (S.bGrabbedScroller)
|
2017-10-20 02:00:49 +00:00
|
|
|
Canvas.SetDrawColor(140,86,8,255);
|
2020-11-28 20:12:58 +00:00
|
|
|
else if (S.bFocused)
|
2017-10-20 02:00:49 +00:00
|
|
|
Canvas.SetDrawColor(175,48,8,255);
|
|
|
|
else Canvas.SetDrawColor(150,36,4,255);
|
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
if (S.bVertical)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
Canvas.SetPos(0.f,S.ButtonOffset);
|
|
|
|
DrawWhiteBox(S.CompPos[2],S.SliderScale);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Canvas.SetPos(S.ButtonOffset,0.f);
|
|
|
|
DrawWhiteBox(S.SliderScale,S.CompPos[3]);
|
|
|
|
}
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
function RenderColumnHeader(KFGUI_ColumnTop C, float XPos, float Width, int Index, bool bFocus, bool bSort)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
local int XS;
|
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
if (bSort)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
if (bFocus)
|
2017-10-20 02:00:49 +00:00
|
|
|
Canvas.SetDrawColor(175,240,8,255);
|
|
|
|
else Canvas.SetDrawColor(128,200,56,255);
|
|
|
|
}
|
2020-11-28 20:12:58 +00:00
|
|
|
else if (bFocus)
|
2017-10-20 02:00:49 +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-11-28 21:54:57 +00:00
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
function RenderCheckbox(KFGUI_CheckBox C)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
if (C.bDisabled)
|
2017-10-20 02:00:49 +00:00
|
|
|
Canvas.SetDrawColor(86,86,86,255);
|
2020-11-28 20:12:58 +00:00
|
|
|
else if (C.bPressedDown)
|
2017-10-20 02:00:49 +00:00
|
|
|
Canvas.SetDrawColor(128,255,128,255);
|
2020-11-28 20:12:58 +00:00
|
|
|
else if (C.bFocused)
|
2017-10-20 02:00:49 +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());
|
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
if (C.bChecked)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
if (C.bDisabled)
|
2017-10-20 02:00:49 +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-11-28 21:54:57 +00:00
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
function RenderComboBox(KFGUI_ComboBox C)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
if (C.bDisabled)
|
2017-10-20 02:00:49 +00:00
|
|
|
Canvas.SetDrawColor(64,4,4,255);
|
2020-11-28 20:12:58 +00:00
|
|
|
else if (C.bPressedDown)
|
2017-10-20 02:00:49 +00:00
|
|
|
Canvas.SetDrawColor(220,56,56,255);
|
2020-11-28 20:12:58 +00:00
|
|
|
else if (C.bFocused)
|
2017-10-20 02:00:49 +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]);
|
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
if (C.SelectedIndex<C.Values.Length && C.Values[C.SelectedIndex]!="")
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
Canvas.SetPos(C.BorderSize,(C.CompPos[3]-C.TextHeight)*0.5);
|
2020-11-28 20:12:58 +00:00
|
|
|
if (C.bDisabled)
|
2017-10-20 02:00:49 +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-11-28 21:54:57 +00:00
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
function RenderComboList(KFGUI_ComboSelector C)
|
2017-10-20 02:00:49 +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;
|
|
|
|
|
|
|
|
bCheckMouse = (X>0.f && X<C.CompPos[2] && Y>0.f && Y<C.CompPos[3]);
|
|
|
|
|
|
|
|
Canvas.Font = C.Combo.TextFont;
|
|
|
|
YL = C.Combo.TextHeight;
|
|
|
|
|
|
|
|
YP = Edge;
|
|
|
|
C.CurrentRow = -1;
|
|
|
|
|
|
|
|
Canvas.PushMaskRegion(Canvas.OrgX,Canvas.OrgY,Canvas.ClipX,Canvas.ClipY);
|
2020-11-28 20:12:58 +00:00
|
|
|
for (i=0; i<C.Combo.Values.Length; ++i)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
if (bCheckMouse && Y>=YP && Y<=(YP+YL))
|
2017-10-20 02:00:49 +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);
|
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
if (i==C.Combo.SelectedIndex)
|
2017-10-20 02:00:49 +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();
|
2020-11-28 20:12:58 +00:00
|
|
|
if (C.OldRow!=C.CurrentRow)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
C.OldRow = C.CurrentRow;
|
|
|
|
C.PlayMenuSound(MN_DropdownChange);
|
|
|
|
}
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
function RenderRightClickMenu(KFGUI_RightClickMenu C)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
local float X,Y,YP,Edge,TextScale;
|
|
|
|
local int i;
|
|
|
|
local bool bCheckMouse;
|
|
|
|
|
|
|
|
// Draw background.
|
|
|
|
Edge = C.EdgeSize;
|
|
|
|
Canvas.SetPos(0.f,0.f);
|
|
|
|
Canvas.SetDrawColor(148,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;
|
|
|
|
|
|
|
|
bCheckMouse = (X>0.f && X<C.CompPos[2] && Y>0.f && Y<C.CompPos[3]);
|
|
|
|
|
|
|
|
Canvas.Font = PickFont(DefaultFontSize,TextScale);
|
|
|
|
|
|
|
|
YP = Edge;
|
|
|
|
C.CurrentRow = -1;
|
|
|
|
|
|
|
|
Canvas.PushMaskRegion(Canvas.OrgX,Canvas.OrgY,Canvas.ClipX,Canvas.ClipY);
|
2020-11-28 20:12:58 +00:00
|
|
|
for (i=0; i<C.ItemRows.Length; ++i)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
if (bCheckMouse && Y>=YP && Y<=(YP+DefaultHeight))
|
2017-10-20 02:00:49 +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),DefaultHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
Canvas.SetPos(Edge,YP);
|
2020-11-28 20:12:58 +00:00
|
|
|
if (C.ItemRows[i].bSplitter)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
Canvas.SetDrawColor(0,0,0,255);
|
|
|
|
Canvas.DrawText("-------",,TextScale,TextScale);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
if (C.ItemRows[i].bDisabled)
|
2017-10-20 02:00:49 +00:00
|
|
|
Canvas.SetDrawColor(148,148,148,255);
|
|
|
|
else Canvas.SetDrawColor(248,248,248,255);
|
|
|
|
Canvas.DrawText(C.ItemRows[i].Text,,TextScale,TextScale);
|
|
|
|
}
|
|
|
|
|
|
|
|
YP+=DefaultHeight;
|
|
|
|
}
|
|
|
|
Canvas.PopMaskRegion();
|
2020-11-28 20:12:58 +00:00
|
|
|
if (C.OldRow!=C.CurrentRow)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
C.OldRow = C.CurrentRow;
|
|
|
|
C.PlayMenuSound(MN_DropdownChange);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
function Font PickFont(byte i, out float Scaler)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
switch (i)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
case 0:
|
2020-12-12 10:44:34 +00:00
|
|
|
Scaler = 0.55;
|
|
|
|
return DrawFonts[0];
|
2017-10-20 02:00:49 +00:00
|
|
|
case 1:
|
2020-12-12 10:44:34 +00:00
|
|
|
Scaler = 0.65;
|
|
|
|
return DrawFonts[0];
|
2017-10-20 02:00:49 +00:00
|
|
|
case 2:
|
2020-12-12 10:44:34 +00:00
|
|
|
Scaler = 0.70;
|
2017-10-20 02:00:49 +00:00
|
|
|
return DrawFonts[0];
|
|
|
|
case 3:
|
2020-12-12 10:44:34 +00:00
|
|
|
Scaler = 0.75;
|
2017-10-20 02:00:49 +00:00
|
|
|
return DrawFonts[0];
|
|
|
|
case 4:
|
2020-12-12 11:04:45 +00:00
|
|
|
Scaler = 0.85;
|
2017-10-20 02:00:49 +00:00
|
|
|
return DrawFonts[0];
|
|
|
|
case 5:
|
2020-12-12 10:44:34 +00:00
|
|
|
Scaler = 0.90;
|
2017-10-20 02:00:49 +00:00
|
|
|
return DrawFonts[0];
|
|
|
|
default:
|
|
|
|
Scaler = 1.0;
|
|
|
|
return DrawFonts[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
defaultproperties
|
|
|
|
{
|
|
|
|
MaxFontScale=6
|
|
|
|
}
|