2022-09-03 17:26:40 +00:00
|
|
|
class ClassicStyle extends KF2Style;
|
2021-06-12 20:11:37 +00:00
|
|
|
|
2021-06-13 03:00:19 +00:00
|
|
|
function RenderFramedWindow(KFGUI_FloatingWindow P)
|
2020-01-10 13:14:11 +00:00
|
|
|
{
|
2021-06-13 02:54:35 +00:00
|
|
|
local int XS, YS, TitleHeight;
|
2021-05-16 09:40:02 +00:00
|
|
|
local float XL, YL, FontScale;
|
|
|
|
|
|
|
|
XS = Canvas.ClipX-Canvas.OrgX;
|
|
|
|
YS = Canvas.ClipY-Canvas.OrgY;
|
|
|
|
TitleHeight = DefaultHeight;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (P.bWindowFocused)
|
2021-06-13 02:54:35 +00:00
|
|
|
Canvas.SetDrawColor(105, 105, 105, 255);
|
|
|
|
else Canvas.SetDrawColor(85, 85, 85, P.FrameOpacity);
|
2021-05-16 09:40:02 +00:00
|
|
|
|
|
|
|
// Frame Header
|
|
|
|
Canvas.SetPos(0, 0);
|
2021-06-13 02:54:35 +00:00
|
|
|
Canvas.DrawTileStretched(TabTextures[`TAB_TOP], XS, TitleHeight, 0,0, 128, 16);
|
2021-05-16 09:40:02 +00:00
|
|
|
|
|
|
|
// Frame itself.
|
2022-09-08 20:11:46 +00:00
|
|
|
|
|
|
|
if (`BOX_SMALL_SLIGHTTRANSPARENT >= 0 && `BOX_SMALL_SLIGHTTRANSPARENT < BorderTextures.Length)
|
|
|
|
{
|
|
|
|
Canvas.SetPos(0, TitleHeight);
|
|
|
|
Canvas.DrawTileStretched(BorderTextures[`BOX_SMALL_SLIGHTTRANSPARENT], XS, YS-TitleHeight, 0,0, 128, 128);
|
|
|
|
}
|
2021-05-16 09:40:02 +00:00
|
|
|
|
|
|
|
// Title.
|
2021-06-13 02:53:33 +00:00
|
|
|
if (P.WindowTitle != "")
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
Canvas.Font = PickFont(FontScale);
|
2021-06-13 02:54:35 +00:00
|
|
|
Canvas.TextSize(P.WindowTitle, XL, YL, FontScale, FontScale);
|
|
|
|
Canvas.SetDrawColor(250, 250, 250, 255);
|
|
|
|
Canvas.SetPos((XS*0.5)-(XL*0.5), 0);
|
|
|
|
Canvas.DrawText(P.WindowTitle, ,FontScale, FontScale);
|
2021-05-16 09:40:02 +00:00
|
|
|
}
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
|
2021-06-13 03:00:19 +00:00
|
|
|
function RenderWindow(KFGUI_Page P)
|
2020-01-10 13:14:11 +00:00
|
|
|
{
|
2021-06-13 02:54:35 +00:00
|
|
|
local int XS, YS;
|
2021-05-16 09:40:02 +00:00
|
|
|
|
|
|
|
XS = Canvas.ClipX-Canvas.OrgX;
|
|
|
|
YS = Canvas.ClipY-Canvas.OrgY;
|
|
|
|
|
|
|
|
// Frame itself.
|
2021-06-13 02:53:33 +00:00
|
|
|
if (P.bWindowFocused)
|
2021-06-13 02:54:35 +00:00
|
|
|
Canvas.SetDrawColor(105, 105, 105, 255);
|
|
|
|
else Canvas.SetDrawColor(85, 85, 85, P.FrameOpacity);
|
2021-05-16 09:40:02 +00:00
|
|
|
|
2022-09-08 20:11:46 +00:00
|
|
|
if (`BOX_SMALL_SLIGHTTRANSPARENT >= 0 && `BOX_SMALL_SLIGHTTRANSPARENT < BorderTextures.Length)
|
|
|
|
{
|
|
|
|
Canvas.SetPos(0, 0);
|
|
|
|
Canvas.DrawTileStretched(BorderTextures[`BOX_SMALL_SLIGHTTRANSPARENT], XS, YS, 0,0, 128, 128);
|
|
|
|
}
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
|
2021-06-13 03:00:19 +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;
|
2021-06-13 02:54:35 +00:00
|
|
|
local float X, Y,XS, YS, TX, TY, TS, DefFontHeight;
|
2021-05-16 09:40:02 +00:00
|
|
|
|
|
|
|
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-06-13 02:54:35 +00:00
|
|
|
Canvas.TextSize(TT.Lines[i], XS, YS);
|
|
|
|
TX = FMax(XS, TX);
|
2021-05-16 09:40:02 +00:00
|
|
|
}
|
|
|
|
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-06-13 02:54:35 +00:00
|
|
|
TT.CurrentAlpha = Min(TT.CurrentAlpha+25, 255);
|
2021-05-16 09:40:02 +00:00
|
|
|
|
|
|
|
// Reset clipping.
|
2021-06-13 02:54:35 +00:00
|
|
|
Canvas.SetOrigin(0, 0);
|
|
|
|
Canvas.SetClip(TT.Owner.ScreenSize.X, TT.Owner.ScreenSize.Y);
|
2021-05-16 09:40:02 +00:00
|
|
|
|
|
|
|
// Draw frame.
|
2021-06-13 02:54:35 +00:00
|
|
|
Canvas.SetDrawColor(115, 115, 115, TT.CurrentAlpha);
|
|
|
|
Canvas.SetPos(X-2, Y-2);
|
|
|
|
DrawBoxHollow(X-2, Y-2, TX+4, TY+4, 2);
|
|
|
|
Canvas.SetDrawColor(5, 5,5, TT.CurrentAlpha);
|
|
|
|
Canvas.SetPos(X, Y);
|
|
|
|
DrawWhiteBox(TX, TY);
|
2021-05-16 09:40:02 +00:00
|
|
|
|
|
|
|
DefFontHeight = DefaultHeight;
|
|
|
|
|
|
|
|
// Draw text.
|
2021-06-13 02:54:35 +00:00
|
|
|
Canvas.SetDrawColor(255, 255, 255, TT.CurrentAlpha);
|
2021-05-16 09:40:02 +00:00
|
|
|
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
|
|
|
{
|
2021-06-13 02:54:35 +00:00
|
|
|
Canvas.SetPos(X, Y);
|
|
|
|
Canvas.DrawText(TT.Lines[i], ,TS, TS, TT.TextFontInfo);
|
2021-05-16 09:40:02 +00:00
|
|
|
Y+=DefFontHeight;
|
|
|
|
}
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
|
2021-06-13 03:00:19 +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);
|
|
|
|
|
2022-09-08 20:11:46 +00:00
|
|
|
if (`BOX_INNERBORDER >= 0 && `BOX_INNERBORDER < BorderTextures.Length)
|
|
|
|
{
|
|
|
|
Canvas.SetPos(0.f, 0.f);
|
|
|
|
Canvas.DrawTileStretched(BorderTextures[`BOX_INNERBORDER], S.CompPos[2], S.CompPos[3], 0,0, 128, 128);
|
|
|
|
}
|
2021-05-16 09:40:02 +00:00
|
|
|
|
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;
|
|
|
|
|
2021-06-13 02:54:35 +00:00
|
|
|
S.SliderScale = FMax(S.PageStep * (S.CompPos[i] - 32.f) / (S.MaxRange + S.PageStep), S.CalcButtonScale);
|
2021-05-16 09:40:02 +00:00
|
|
|
|
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-06-13 02:54:35 +00:00
|
|
|
Canvas.SetDrawColor(125, 125, 125, 200);
|
2021-06-13 02:53:33 +00:00
|
|
|
else if (S.bFocused)
|
2021-06-13 02:54:35 +00:00
|
|
|
Canvas.SetDrawColor(200, 200, 200, 200);
|
|
|
|
else Canvas.SetDrawColor(255, 255, 255, 200);
|
2021-05-16 09:40:02 +00:00
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (S.bVertical)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
Canvas.SetPos(0.f, S.ButtonOffset);
|
2021-06-13 02:54:35 +00:00
|
|
|
Canvas.DrawTileStretched(ScrollTexture, S.CompPos[2], S.SliderScale, 0,0, 32, 32);
|
2021-05-16 09:40:02 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Canvas.SetPos(S.ButtonOffset, 0.f);
|
2021-06-13 02:54:35 +00:00
|
|
|
Canvas.DrawTileStretched(ScrollTexture, S.SliderScale, S.CompPos[3], 0,0, 32, 32);
|
2021-05-16 09:40:02 +00:00
|
|
|
}
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
|
2021-06-13 03:00:19 +00:00
|
|
|
function RenderCheckbox(KFGUI_CheckBox C)
|
2020-01-10 13:14:11 +00:00
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local Texture CheckMark;
|
|
|
|
|
2021-06-13 02:54:35 +00:00
|
|
|
DrawTileStretched(ItemBoxTextures[`ITEMBOX_DISABLED], 0.f, 0.f, C.CompPos[2], C.CompPos[3]);
|
2021-05-16 09:40:02 +00:00
|
|
|
|
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
|
|
|
CheckMark = CheckBoxTextures[`CHECKMARK_DISABLED];
|
2021-06-13 02:53:33 +00:00
|
|
|
else if (C.bFocused)
|
2021-05-16 09:40:02 +00:00
|
|
|
CheckMark = CheckBoxTextures[`CHECKMARK_HIGHLIGHTED];
|
|
|
|
else CheckMark = CheckBoxTextures[`CHECKMARK_NORMAL];
|
|
|
|
|
2021-06-13 02:54:35 +00:00
|
|
|
Canvas.SetDrawColor(255, 255, 255, 255);
|
|
|
|
Canvas.SetPos(0.f, 0.f);
|
|
|
|
Canvas.DrawTile(CheckMark, C.CompPos[2], C.CompPos[3], 0,0, CheckMark.GetSurfaceWidth(), CheckMark.GetSurfaceHeight());
|
2021-05-16 09:40:02 +00:00
|
|
|
}
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
|
2021-06-13 03:00:19 +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-06-13 02:54:35 +00:00
|
|
|
Canvas.SetDrawColor(64, 64, 64, 255);
|
2021-06-13 02:53:33 +00:00
|
|
|
else if (C.bPressedDown)
|
2021-06-13 02:54:35 +00:00
|
|
|
Canvas.SetDrawColor(220, 220, 220, 255);
|
2021-06-13 02:53:33 +00:00
|
|
|
else if (C.bFocused)
|
2021-06-13 02:54:35 +00:00
|
|
|
Canvas.SetDrawColor(190, 190, 190, 255);
|
2021-05-16 09:40:02 +00:00
|
|
|
|
2022-09-08 20:11:46 +00:00
|
|
|
if (`BOX_INNERBORDER >= 0 && `BOX_INNERBORDER < BorderTextures.Length)
|
|
|
|
{
|
|
|
|
Canvas.SetPos(0.f, 0.f);
|
|
|
|
Canvas.DrawTileStretched(BorderTextures[`BOX_INNERBORDER], C.CompPos[2], C.CompPos[3], 0,0, 128, 128);
|
|
|
|
}
|
2021-05-16 09:40:02 +00:00
|
|
|
|
|
|
|
DrawArrowBox(3, C.CompPos[2]-32, 0.5f, 32, 32);
|
|
|
|
|
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
|
|
|
{
|
2021-06-13 02:54:35 +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;
|
2021-06-13 02:54:35 +00:00
|
|
|
Canvas.PushMaskRegion(Canvas.OrgX, Canvas.OrgY, Canvas.ClipX-C.BorderSize, Canvas.ClipY);
|
|
|
|
Canvas.DrawText(C.Values[C.SelectedIndex], ,C.TextScale, C.TextScale, C.TextFontInfo);
|
2021-05-16 09:40:02 +00:00
|
|
|
Canvas.PopMaskRegion();
|
|
|
|
}
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
|
2021-06-13 03:00:19 +00:00
|
|
|
function RenderComboList(KFGUI_ComboSelector C)
|
2020-01-10 13:14:11 +00:00
|
|
|
{
|
2021-06-13 02:54:35 +00:00
|
|
|
local float X, Y,YL, YP, Edge;
|
2021-05-16 09:40:02 +00:00
|
|
|
local int i;
|
|
|
|
local bool bCheckMouse;
|
|
|
|
|
|
|
|
// Draw background.
|
|
|
|
Edge = C.Combo.BorderSize;
|
2022-09-08 20:11:46 +00:00
|
|
|
|
|
|
|
if (`BOX_SMALL_SLIGHTTRANSPARENT >= 0 && `BOX_SMALL_SLIGHTTRANSPARENT < BorderTextures.Length)
|
|
|
|
{
|
|
|
|
Canvas.SetPos(0.f, 0.f);
|
|
|
|
Canvas.DrawTileStretched(BorderTextures[`BOX_SMALL_SLIGHTTRANSPARENT], C.CompPos[2], C.CompPos[3], 0,0, 128, 128);
|
|
|
|
}
|
2021-05-16 09:40:02 +00:00
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
2021-06-13 02:54:35 +00:00
|
|
|
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;
|
2021-06-13 02:54:35 +00:00
|
|
|
Canvas.SetPos(4.f, YP);
|
|
|
|
Canvas.SetDrawColor(128, 48, 48, 255);
|
|
|
|
DrawWhiteBox(C.CompPos[2]-(Edge*2.f), YL);
|
2021-05-16 09:40:02 +00:00
|
|
|
}
|
2021-06-13 02:54:35 +00:00
|
|
|
Canvas.SetPos(Edge, YP);
|
2021-05-16 09:40:02 +00:00
|
|
|
|
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;
|
|
|
|
|
2021-06-13 02:54:35 +00:00
|
|
|
Canvas.DrawText(C.Combo.Values[i], ,C.Combo.TextScale, C.Combo.TextScale, C.Combo.TextFontInfo);
|
2021-05-16 09:40:02 +00:00
|
|
|
|
|
|
|
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 03:00:19 +00:00
|
|
|
function RenderRightClickMenu(KFGUI_RightClickMenu C)
|
2020-01-10 13:14:11 +00:00
|
|
|
{
|
2021-06-13 02:54:35 +00:00
|
|
|
local float X, Y,XL, YL, YP, Edge, TextScale;
|
2021-05-16 09:40:02 +00:00
|
|
|
local int i;
|
|
|
|
local bool bCheckMouse;
|
|
|
|
local string S;
|
|
|
|
|
|
|
|
// Draw background.
|
|
|
|
Edge = C.EdgeSize;
|
2021-06-13 02:54:35 +00:00
|
|
|
DrawOutlinedBox(0.f, 0.f, C.CompPos[2], C.CompPos[3], Edge, C.BoxColor, C.OutlineColor);
|
2021-05-16 09:40:02 +00:00
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
PickFont(TextScale);
|
|
|
|
|
|
|
|
YP = Edge*2;
|
|
|
|
C.CurrentRow = -1;
|
|
|
|
|
2021-06-13 02:54:35 +00:00
|
|
|
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 (C.ItemRows[i].bSplitter)
|
2021-05-16 09:40:02 +00:00
|
|
|
S = "-------";
|
|
|
|
else S = C.ItemRows[i].Text;
|
|
|
|
|
2021-06-13 02:54:35 +00:00
|
|
|
Canvas.TextSize(S, XL, YL, TextScale, TextScale);
|
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;
|
2021-06-13 02:54:35 +00:00
|
|
|
Canvas.SetPos(Edge, YP);
|
|
|
|
Canvas.SetDrawColor(128, 0,0, 255);
|
|
|
|
DrawWhiteBox(C.CompPos[2]-(Edge*2.f), YL);
|
2021-05-16 09:40:02 +00:00
|
|
|
}
|
|
|
|
|
2021-06-13 02:54:35 +00:00
|
|
|
Canvas.SetPos(Edge*6, YP);
|
2021-06-13 02:53:33 +00:00
|
|
|
if (C.ItemRows[i].bSplitter)
|
2021-06-13 02:54:35 +00:00
|
|
|
Canvas.SetDrawColor(255, 255, 255, 255);
|
2021-05-16 09:40:02 +00:00
|
|
|
else
|
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
if (C.ItemRows[i].bDisabled)
|
2021-06-13 02:54:35 +00:00
|
|
|
Canvas.SetDrawColor(148, 148, 148, 255);
|
|
|
|
else Canvas.SetDrawColor(248, 248, 248, 255);
|
2021-05-16 09:40:02 +00:00
|
|
|
}
|
2021-06-13 02:54:35 +00:00
|
|
|
Canvas.DrawText(S, ,TextScale, TextScale);
|
2021-05-16 09:40:02 +00:00
|
|
|
|
|
|
|
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_FocusHover);
|
|
|
|
}
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
|
2021-06-13 03:00:19 +00:00
|
|
|
function RenderButton(KFGUI_Button B)
|
2020-01-10 13:14:11 +00:00
|
|
|
{
|
2021-06-13 02:54:35 +00:00
|
|
|
local float XL, YL, TS, AX, AY, GamepadTexSize;
|
2021-05-16 09:40:02 +00:00
|
|
|
local Texture2D Mat, ButtonTex;
|
|
|
|
local bool bDrawOverride;
|
|
|
|
|
|
|
|
bDrawOverride = B.DrawOverride(Canvas, B);
|
2021-06-13 02:53:33 +00:00
|
|
|
if (!bDrawOverride)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
if (B.bDisabled)
|
2021-05-16 09:40:02 +00:00
|
|
|
Mat = ButtonTextures[`BUTTON_DISABLED];
|
2021-06-13 02:53:33 +00:00
|
|
|
else if (B.bPressedDown)
|
2021-05-16 09:40:02 +00:00
|
|
|
Mat = ButtonTextures[`BUTTON_PRESSED];
|
2021-06-13 02:53:33 +00:00
|
|
|
else if (B.bFocused || B.bIsHighlighted)
|
2021-05-16 09:40:02 +00:00
|
|
|
Mat = ButtonTextures[`BUTTON_HIGHLIGHTED];
|
|
|
|
else Mat = ButtonTextures[`BUTTON_NORMAL];
|
|
|
|
|
2021-06-13 02:54:35 +00:00
|
|
|
Canvas.SetPos(0.f, 0.f);
|
|
|
|
Canvas.DrawTileStretched(Mat, B.CompPos[2], B.CompPos[3], 0,0, 32, 32);
|
2021-05-16 09:40:02 +00:00
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (B.OverlayTexture.Texture != None)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
2021-06-13 02:54:35 +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-05-16 09:40:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (B.ButtonText != "")
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
Canvas.Font = MainFont;
|
|
|
|
|
|
|
|
GamepadTexSize = B.CompPos[3] / 1.25;
|
|
|
|
|
|
|
|
TS = GetFontScaler();
|
|
|
|
TS *= B.FontScale;
|
|
|
|
|
2021-06-13 03:00:19 +00:00
|
|
|
while (true)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
2021-06-13 02:54:35 +00:00
|
|
|
Canvas.TextSize(B.ButtonText, XL, YL, TS, TS);
|
2021-06-13 02:53:33 +00:00
|
|
|
if (XL < (B.CompPos[2]*0.9) && YL < (B.CompPos[3]*0.9))
|
2021-05-16 09:40:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
TS -= 0.001;
|
|
|
|
}
|
|
|
|
|
2021-06-13 02:54:35 +00:00
|
|
|
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;
|
2021-06-13 02:54:35 +00:00
|
|
|
Canvas.DrawText(B.ButtonText, ,TS, TS, B.TextFontInfo);
|
2021-05-16 09:40:02 +00:00
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (B.GetUsingGamepad())
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
ButtonTex = Texture2D(DynamicLoadObject("UI_Controller."$B.GamepadButtonName$"_Asset", class'Texture2D'));
|
2021-06-13 02:53:33 +00:00
|
|
|
if (ButtonTex != None)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
B.GetRealtivePos(AX, AY);
|
2021-06-13 03:00:19 +00:00
|
|
|
while ((Canvas.CurX-(GamepadTexSize*1.25)) < AX)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
GamepadTexSize *= 0.95;
|
|
|
|
}
|
|
|
|
|
2021-06-13 03:00:19 +00:00
|
|
|
switch (ButtonTex.Name)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
case 'XboxTypeS_A_Asset':
|
|
|
|
case 'XboxTypeS_B_Asset':
|
|
|
|
case 'XboxTypeS_X_Asset':
|
|
|
|
case 'XboxTypeS_Y_Asset':
|
|
|
|
Canvas.SetDrawColor(255, 255, 255, 145);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Canvas.SetDrawColor(0, 0, 0, 145);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-06-13 02:54:35 +00:00
|
|
|
Canvas.SetPos(Canvas.CurX-(GamepadTexSize*1.25), (B.CompPos[3]-GamepadTexSize)*0.5);
|
|
|
|
Canvas.DrawRect(GamepadTexSize, GamepadTexSize, ButtonTex);
|
2021-05-16 09:40:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
defaultproperties
|
|
|
|
{
|
|
|
|
}
|