KF2-YetAnotherScoreboard/ScoreboardExt/Classes/GUIStyleBase.uc

1466 lines
34 KiB
Ucode
Raw Normal View History

2020-01-10 13:14:11 +00:00
Class GUIStyleBase extends Object
abstract;
2020-01-10 13:14:11 +00:00
2021-06-12 20:11:37 +00:00
`include(Build.uci)
`include(Logger.uci)
2020-01-10 13:14:11 +00:00
var Texture2D ItemTex;
2021-06-13 03:17:40 +00:00
var array<Texture2D> BorderTextures, ArrowTextures, ButtonTextures, TabTextures, ItemBoxTextures, PerkBox, CheckBoxTextures, ProgressBarTextures, SliderTextures;
2021-06-13 02:54:35 +00:00
var Texture2D ScrollTexture, FavoriteIcon, BankNoteIcon;
2020-01-10 13:14:11 +00:00
var SoundCue MenuDown, MenuDrag, MenuEdit, MenuFade, MenuClick, MenuHover, MenuUp;
var() byte MaxFontScale;
var float DefaultHeight; // Default font text size.
var transient Canvas Canvas;
var transient KF2GUIController Owner;
2021-05-16 03:37:39 +00:00
var transient ScoreboardExtHUD HUDOwner;
2020-01-10 13:14:11 +00:00
var Font MainFont, NumberFont, InfiniteFont;
var Color BlurColor, BlurColor2;
2021-06-13 10:53:19 +00:00
enum ECornerPosition
{
ECP_TopLeft,
ECP_TopRight,
ECP_BottomLeft,
ECP_BottomRight
};
enum ECornerShape
{
ECS_Corner,
ECS_BeveledCorner,
ECS_VerticalCorner,
ECS_HorisontalCorner
};
2020-01-10 13:14:11 +00:00
struct FColorInfo
{
var name Code;
var Color Color;
2020-01-10 13:14:11 +00:00
};
2021-06-13 03:17:40 +00:00
var array<FColorInfo> ColorCodes;
2020-01-10 13:14:11 +00:00
struct FTexturePreCache
{
var string Path;
var Texture2D Tex;
2020-01-10 13:14:11 +00:00
};
2021-06-13 03:17:40 +00:00
var array<FTexturePreCache> PrecachedTextures;
2020-01-10 13:14:11 +00:00
function InitStyle()
{
local FColorInfo ColorInfo;
2021-06-13 02:54:35 +00:00
ItemTex=Texture2D(DynamicLoadObject("UI_LevelChevrons_TEX.UI_LevelChevron_Icon_02", class'Texture2D'));
2021-06-13 02:53:33 +00:00
if (ItemTex == None)
ItemTex=Texture2D'EngineMaterials.DefaultWhiteGrid';
NumberFont = Font(DynamicLoadObject("UI_Canvas_Fonts.Font_General", class'Font'));
BlurColor = MakeColor(60, 60, 60, 220);
BlurColor2 = MakeColor(40, 40, 40, 140);
ColorInfo.Code='Q';
2021-06-13 02:54:35 +00:00
ColorInfo.Color = MakeColor(0, 140, 0,255); // Dark Green
ColorCodes.AddItem(ColorInfo);
ColorInfo.Code='E';
2021-06-13 02:54:35 +00:00
ColorInfo.Color = MakeColor(210, 180, 140, 255); // Tan
ColorCodes.AddItem(ColorInfo);
ColorInfo.Code='R';
2021-06-13 02:54:35 +00:00
ColorInfo.Color = MakeColor(128, 0,0, 255); // Dark Red
ColorCodes.AddItem(ColorInfo);
ColorInfo.Code='T';
2021-06-13 02:54:35 +00:00
ColorInfo.Color = MakeColor(153, 102, 204, 255); // Purple
ColorCodes.AddItem(ColorInfo);
ColorInfo.Code='U';
2021-06-13 02:54:35 +00:00
ColorInfo.Color = MakeColor(128, 128, 128, 255); // Dark Gray
ColorCodes.AddItem(ColorInfo);
ColorInfo.Code='I';
2021-06-13 02:54:35 +00:00
ColorInfo.Color = MakeColor(255, 170, 0,255); // Orange
ColorCodes.AddItem(ColorInfo);
ColorInfo.Code='O';
2021-06-13 02:54:35 +00:00
ColorInfo.Color = MakeColor(255, 204, 153, 255); // Cream
ColorCodes.AddItem(ColorInfo);
ColorInfo.Code='P';
2021-06-13 02:54:35 +00:00
ColorInfo.Color = MakeColor(209, 216, 168, 255); // Olive
ColorCodes.AddItem(ColorInfo);
ColorInfo.Code='A';
2021-06-13 02:54:35 +00:00
ColorInfo.Color = MakeColor(204, 51, 51, 255); // Brick
ColorCodes.AddItem(ColorInfo);
ColorInfo.Code='S';
2021-06-13 02:54:35 +00:00
ColorInfo.Color = MakeColor(153, 102, 51, 255); // Brown
ColorCodes.AddItem(ColorInfo);
ColorInfo.Code='D';
2021-06-13 02:54:35 +00:00
ColorInfo.Color = MakeColor(0, 204, 0,255); // Green
ColorCodes.AddItem(ColorInfo);
ColorInfo.Code='F';
2021-06-13 02:54:35 +00:00
ColorInfo.Color = MakeColor(238, 238, 51, 255); // Yellow
ColorCodes.AddItem(ColorInfo);
ColorInfo.Code='G';
2021-06-13 02:54:35 +00:00
ColorInfo.Color = MakeColor(200, 0,0, 255); // Red
ColorCodes.AddItem(ColorInfo);
ColorInfo.Code='H';
2021-06-13 02:54:35 +00:00
ColorInfo.Color = MakeColor(153, 153, 255, 255); // Blue
ColorCodes.AddItem(ColorInfo);
ColorInfo.Code='J';
2021-06-13 02:54:35 +00:00
ColorInfo.Color = MakeColor(192, 192, 192, 255); // Silver
ColorCodes.AddItem(ColorInfo);
ColorInfo.Code='K';
2021-06-13 02:54:35 +00:00
ColorInfo.Color = MakeColor(255, 204, 0,255); // Gold
ColorCodes.AddItem(ColorInfo);
ColorInfo.Code='C';
2021-06-13 02:54:35 +00:00
ColorInfo.Color = MakeColor(255, 255, 255, 255); // White
ColorCodes.AddItem(ColorInfo);
ColorInfo.Code='V';
2021-06-13 02:54:35 +00:00
ColorInfo.Color = MakeColor(0, 191, 255, 255); // Sky Blue
ColorCodes.AddItem(ColorInfo);
ColorInfo.Code='B';
2021-06-13 02:54:35 +00:00
ColorInfo.Color = MakeColor(204, 204, 204, 255); // Gray
ColorCodes.AddItem(ColorInfo);
ColorInfo.Code='N';
2021-06-13 02:54:35 +00:00
ColorInfo.Color = MakeColor(0, 128, 255, 255); // Dark Sky Blue
ColorCodes.AddItem(ColorInfo);
ColorInfo.Code='M';
2021-06-13 02:54:35 +00:00
ColorInfo.Color = MakeColor(18, 18, 18, 255); // Black
ColorCodes.AddItem(ColorInfo);
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
function RenderFramedWindow(KFGUI_FloatingWindow P);
function RenderWindow(KFGUI_Page P);
function RenderToolTip(KFGUI_Tooltip TT);
function RenderButton(KFGUI_Button B);
function RenderScrollBar(KFGUI_ScrollBarBase S);
function RenderColumnHeader(KFGUI_ColumnTop C, float XPos, float Width, int Index, bool bFocus, bool bSort);
function RenderRightClickMenu(KFGUI_RightClickMenu C);
function RenderCheckbox(KFGUI_CheckBox C);
function RenderComboBox(KFGUI_ComboBox C);
function RenderComboList(KFGUI_ComboSelector C);
function Font PickFont(out float Scaler, optional bool bNumbersOnly, optional bool bInfinite)
2020-01-10 13:14:11 +00:00
{
Scaler = GetFontScaler();
2021-06-13 02:53:33 +00:00
if (bNumbersOnly)
return NumberFont;
2021-06-13 02:53:33 +00:00
else if (bInfinite)
return InfiniteFont;
return MainFont;
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
function PickDefaultFontSize(float YRes)
2020-01-10 13:14:11 +00:00
{
2021-06-13 02:54:35 +00:00
local int XL, YL;
local string S;
S="ABC";
2021-06-13 02:54:35 +00:00
PickFont(YRes).GetStringHeightAndWidth(S, YL, XL);
2020-01-10 13:14:11 +00:00
DefaultHeight=float(YL)*YRes;
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
final function float ScreenScale(float Size, optional float MaxRes=1080.f)
2020-01-10 13:14:11 +00:00
{
2021-06-13 03:00:19 +00:00
return Size * ( HUDOwner.SizeY / MaxRes);
2020-01-10 13:14:11 +00:00
}
2021-05-16 20:28:37 +00:00
final function float GetFontScaler(optional float Scaler=0.750f, optional float Min=0.175f, optional float Max=1.0f)
2020-01-10 13:14:11 +00:00
{
return FClamp((HUDOwner.SizeY / 1080.f) * Scaler, Min, Max);
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
final function DrawText(coerce string S)
2020-01-10 13:14:11 +00:00
{
local float Scale;
Canvas.Font=PickFont(Scale);
2021-06-13 02:54:35 +00:00
Canvas.DrawText(S, ,Scale, Scale);
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
final function DrawCenteredText(coerce string S, float X, float Y, optional float Scale=1.f, optional bool bVertical, optional bool bUseOutline)
2020-01-10 13:14:11 +00:00
{
2021-06-13 02:54:35 +00:00
local float XL, YL;
2020-01-10 13:14:11 +00:00
2021-06-13 02:54:35 +00:00
Canvas.TextSize(S, XL, YL);
2021-06-13 02:53:33 +00:00
if (bVertical)
2021-06-13 02:54:35 +00:00
Canvas.SetPos(X, Y-(YL*Scale*0.5));
else Canvas.SetPos(X-(XL*Scale*0.5), Y);
2021-06-13 02:53:33 +00:00
if (bUseOutline)
DrawTextShadow(S, Canvas.CurX, Canvas.CurY, 1, Scale);
2021-06-13 02:54:35 +00:00
else Canvas.DrawText(S, ,Scale, Scale);
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
final function string StripColorTags(coerce string S)
2020-01-10 13:14:11 +00:00
{
local int Pos;
Pos = InStr(S, "\\c");
2021-06-13 03:00:19 +00:00
while (Pos != INDEX_NONE)
{
2021-06-13 02:54:35 +00:00
S = Left(S, Pos) $ Mid(S, Pos+3);
Pos = InStr(S, "\\c");
}
return S;
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
final function DrawColoredText(coerce string S, float X, float Y, optional float Scale=1.f, optional bool bUseOutline)
2020-01-10 13:14:11 +00:00
{
2021-06-13 02:54:35 +00:00
local float XL, YL;
local int i, Index;
2021-06-13 07:29:12 +00:00
local array<string> SArray;
local string T, PrevT;
local Color TextColor;
2021-06-13 02:53:33 +00:00
if (InStr(S, "\\c") == INDEX_NONE)
{
2021-06-13 02:53:33 +00:00
if (bUseOutline)
DrawTextShadow(S, X, Y, 1, Scale);
else
{
2021-06-13 02:54:35 +00:00
Canvas.SetPos(X, Y);
Canvas.DrawText(S, ,Scale, Scale);
}
}
else
{
SArray = SplitString(S, "\\c");
2021-06-13 02:54:35 +00:00
PrevT = Left(S, InStr(S, "\\c"));
2021-06-13 02:53:33 +00:00
if (Len(PrevT) > 0)
{
2021-06-13 02:54:35 +00:00
Canvas.TextSize(PrevT, XL, YL, Scale, Scale);
2021-06-13 02:53:33 +00:00
if (bUseOutline)
DrawTextShadow(PrevT, X, Y, 1, Scale);
else
{
2021-06-13 02:54:35 +00:00
Canvas.SetPos(X, Y);
Canvas.DrawText(PrevT, ,Scale, Scale);
}
}
2021-06-13 02:53:33 +00:00
for (i=0; i < SArray.Length; i++)
{
T = SArray[i];
2021-06-13 02:53:33 +00:00
if (i > 0 || Left(S, 2)~="\\c")
{
Index = ColorCodes.Find('Code', name(Left(T, 1)));
2021-06-13 02:53:33 +00:00
if (Index != INDEX_NONE)
TextColor = ColorCodes[Index].Color;
else TextColor = class'HUD'.default.WhiteColor;
TextColor.A = Canvas.DrawColor.A;
T = Mid(T, 1);
}
Canvas.DrawColor = TextColor;
2021-06-13 02:54:35 +00:00
Canvas.TextSize(T, XL, YL, Scale, Scale);
2021-06-13 02:53:33 +00:00
if (bUseOutline)
DrawTextShadow(T, X, Y, 1, Scale);
else
{
2021-06-13 02:54:35 +00:00
Canvas.SetPos(X, Y);
Canvas.DrawText(T, ,Scale, Scale);
}
X += XL;
}
}
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
final function DrawTextBlurry(coerce string S, float X, float Y, optional float Scale=1.f)
2020-01-10 13:14:11 +00:00
{
local Color OldDrawColor;
OldDrawColor = Canvas.DrawColor;
BlurColor.A = OldDrawColor.A * 0.85;
BlurColor2.A = OldDrawColor.A * 0.55;
Canvas.DrawColor = BlurColor;
Canvas.SetPos(X + Owner.FontBlurX, Y + Owner.FontBlurY);
2021-06-13 02:54:35 +00:00
Canvas.DrawText(S, ,Scale, Scale);
Canvas.DrawColor = BlurColor2;
Canvas.SetPos(X + Owner.FontBlurX2, Y + Owner.FontBlurY2);
2021-06-13 02:54:35 +00:00
Canvas.DrawText(S, ,Scale, Scale);
Canvas.DrawColor = OldDrawColor;
Canvas.SetPos(X, Y);
2021-06-13 02:54:35 +00:00
Canvas.DrawText(S, ,Scale, Scale);
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
final function DrawTextOutline(coerce string S, float X, float Y, int Size, Color OutlineColor, optional float Scale=1.f, optional FontRenderInfo FRI)
2020-01-10 13:14:11 +00:00
{
local Color OldDrawColor;
local int XS, YS, Steps;
OldDrawColor = Canvas.DrawColor;
OutlineColor.A = OldDrawColor.A;
Size += 1;
Steps = (Size * 2) / 3;
2021-06-13 02:53:33 +00:00
if (Steps < 1 )
{
Steps = 1;
}
Canvas.DrawColor = OutlineColor;
for (XS = -Size; XS <= Size; XS+=Steps)
{
for (YS = -Size; YS <= Size; YS+=Steps)
{
Canvas.SetPos(X + XS, Y + YS);
2021-06-13 02:54:35 +00:00
Canvas.DrawText(S, , Scale, Scale, FRI);
}
}
Canvas.DrawColor = OldDrawColor;
Canvas.SetPos(X, Y);
2021-06-13 02:54:35 +00:00
Canvas.DrawText(S, , Scale, Scale, FRI);
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
final function DrawTextShadow(coerce string S, float X, float Y, float ShadowSize, optional float Scale=1.f)
2020-01-10 13:14:11 +00:00
{
local Color OldDrawColor;
OldDrawColor = Canvas.DrawColor;
Canvas.SetPos(X + ShadowSize, Y + ShadowSize);
Canvas.SetDrawColor(0, 0, 0, OldDrawColor.A);
2021-06-13 02:54:35 +00:00
Canvas.DrawText(S, , Scale, Scale);
Canvas.SetPos(X, Y);
Canvas.DrawColor = OldDrawColor;
2021-06-13 02:54:35 +00:00
Canvas.DrawText(S, , Scale, Scale);
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
final function DrawTexturedString(coerce string S, float X, float Y, optional float TextScaler=1.f, optional FontRenderInfo FRI, optional bool bUseOutline, optional bool bOnlyTexture)
2020-01-10 13:14:11 +00:00
{
local Texture2D Mat;
local string D;
local float XL, YL;
2021-06-13 02:54:35 +00:00
local int i, j;
local Color OrgC;
OrgC = Canvas.DrawColor;
Mat = FindNextTexture(S);
2021-06-13 03:00:19 +00:00
while (Mat != None)
{
2021-06-13 07:29:12 +00:00
i = InStr(S, "<TEXTURE");
j = InStr(S, ">");
2021-06-13 02:54:35 +00:00
D = Left(S, i);
S = Mid(S, j+2);
2021-06-13 02:53:33 +00:00
if (!bOnlyTexture)
{
2021-06-13 02:54:35 +00:00
Canvas.TextSize(StripColorTags(D), XL, YL, TextScaler, TextScaler);
DrawColoredText(D, X,Y, TextScaler, bUseOutline);
X += XL;
}
2021-06-13 02:54:35 +00:00
else Canvas.TextSize("W", XL, YL, TextScaler, TextScaler);
Canvas.DrawColor = class'HUD'.default.WhiteColor;
Canvas.DrawColor.A = OrgC.A;
2021-06-13 02:54:35 +00:00
Canvas.SetPos(X, Y+(Owner.HUDOwner.ScaledBorderSize/2));
Canvas.DrawRect(YL-Owner.HUDOwner.ScaledBorderSize, YL-Owner.HUDOwner.ScaledBorderSize, Mat);
X += YL-Owner.HUDOwner.ScaledBorderSize;
Canvas.DrawColor = OrgC;
Mat = FindNextTexture(S);
}
2021-06-13 02:54:35 +00:00
DrawColoredText(S, X,Y, TextScaler, bUseOutline);
2020-01-10 13:14:11 +00:00
}
final function Texture2D FindNextTexture(out string S)
{
local int i, j;
local string Path;
local Texture2D Tex;
local FTexturePreCache Cache;
Path = S;
2021-06-13 07:29:12 +00:00
i = InStr(Path, "<Icon>");
2021-06-13 02:53:33 +00:00
if (i == INDEX_NONE)
return None;
2021-06-13 07:29:12 +00:00
j = InStr(Path, " </Icon>");
S = Left(Path, i)$"<TEXTURE>"$Mid(Path, j+6);
Path = Mid(Path, i+6, j-(i+6));
i = PrecachedTextures.Find('Path', Path);
2021-06-13 02:53:33 +00:00
if (i != INDEX_NONE)
return PrecachedTextures[i].Tex;
Tex = Texture2D(FindObject(Path, class'Texture2D'));
2021-06-13 02:53:33 +00:00
if (Tex != None)
{
Cache.Path = Path;
Cache.Tex = Tex;
PrecachedTextures.AddItem(Cache);
return Tex;
}
Cache.Path = Path;
Cache.Tex = Texture2D(DynamicLoadObject(Path, class'Texture2D'));
PrecachedTextures.AddItem(Cache);
return Cache.Tex;
2020-01-10 13:14:11 +00:00
}
final function string StripTextureFromString(string S, optional bool bNoStringAdd)
{
local int i, j;
2021-06-13 03:00:19 +00:00
while (true)
{
2021-06-13 07:29:12 +00:00
i = InStr(S, "<Icon>");
2021-06-13 02:53:33 +00:00
if (i == INDEX_NONE)
break;
2020-01-10 13:14:11 +00:00
2021-06-13 07:29:12 +00:00
j = InStr(S, "</Icon>");
S = Left(S, i)$(bNoStringAdd ? "" : "W")$Mid(S, j+Len("</Icon>"));
}
return StripColorTags(S);
2020-01-10 13:14:11 +00:00
}
final function string GetTimeString(int Seconds)
{
local int Minutes, Hours;
local string Time;
2020-01-10 13:14:11 +00:00
2021-06-13 02:53:33 +00:00
if (Seconds > 3600)
{
Hours = Seconds / 3600;
Seconds -= Hours * 3600;
2020-01-10 13:14:11 +00:00
Time = Hours$":";
}
Minutes = Seconds / 60;
Seconds -= Minutes * 60;
2020-01-10 13:14:11 +00:00
2021-06-13 02:53:33 +00:00
if (Minutes >= 10)
Time = Time $ Minutes $ ":";
else Time = Time $ "0" $ Minutes $ ":";
2020-01-10 13:14:11 +00:00
2021-06-13 02:53:33 +00:00
if (Seconds >= 10)
Time = Time $ Seconds;
else Time = Time $ "0" $ Seconds;
2020-01-10 13:14:11 +00:00
return Time;
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
final function DrawCornerTexNU(int SizeX, int SizeY, byte Dir ) // Draw non-uniform corner.
2020-01-10 13:14:11 +00:00
{
2021-06-13 03:00:19 +00:00
switch (Dir)
{
case 0: // Up-left
2021-06-13 02:54:35 +00:00
Canvas.DrawTile(ItemTex, SizeX, SizeY, 77, 15, -66, 58);
break;
case 1: // Up-right
2021-06-13 02:54:35 +00:00
Canvas.DrawTile(ItemTex, SizeX, SizeY, 11, 15, 66, 58);
break;
case 2: // Down-left
2021-06-13 02:54:35 +00:00
Canvas.DrawTile(ItemTex, SizeX, SizeY, 77, 73, -66, -58);
break;
default: // Down-right
2021-06-13 02:54:35 +00:00
Canvas.DrawTile(ItemTex, SizeX, SizeY, 11, 73, 66, -58);
}
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
final function DrawCornerTex(int Size, byte Dir)
2020-01-10 13:14:11 +00:00
{
2021-06-13 03:00:19 +00:00
switch (Dir)
{
case 0: // Up-left
2021-06-13 02:54:35 +00:00
Canvas.DrawTile(ItemTex, Size, Size, 77, 15, -66, 58);
break;
case 1: // Up-right
2021-06-13 02:54:35 +00:00
Canvas.DrawTile(ItemTex, Size, Size, 11, 15, 66, 58);
break;
case 2: // Down-left
2021-06-13 02:54:35 +00:00
Canvas.DrawTile(ItemTex, Size, Size, 77, 73, -66, -58);
break;
default: // Down-right
2021-06-13 02:54:35 +00:00
Canvas.DrawTile(ItemTex, Size, Size, 11, 73, 66, -58);
}
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
final function DrawWhiteBox(float XS, float YS, optional bool bClip)
2020-01-10 13:14:11 +00:00
{
2021-06-13 02:54:35 +00:00
Canvas.DrawTile(ItemTex, XS, YS, 19, 45, 1,1, ,bClip);
2020-01-10 13:14:11 +00:00
}
2021-06-14 04:23:36 +00:00
final function DrawCornerSmart(float X, float Y, int Edge, int CornerPosition, int CornerShape)
2021-06-13 10:53:19 +00:00
{
switch (CornerPosition)
{
case ECP_TopLeft:
switch (CornerShape)
{
case ECS_Corner:
return;
case ECS_BeveledCorner:
Canvas.SetPos(X, Y);
DrawCornerTex(Edge, 0);
return;
case ECS_VerticalCorner:
Canvas.SetPos(X, Y - Edge);
DrawCornerTex(Edge, 1);
return;
case ECS_HorisontalCorner:
Canvas.SetPos(X - Edge, Y);
DrawCornerTex(Edge, 2);
return;
}
case ECP_TopRight:
switch (CornerShape)
{
case ECS_Corner:
return;
case ECS_BeveledCorner:
2021-06-14 04:23:36 +00:00
Canvas.SetPos(X - Edge, Y);
2021-06-13 10:53:19 +00:00
DrawCornerTex(Edge, 1);
return;
case ECS_VerticalCorner:
2021-06-14 04:23:36 +00:00
Canvas.SetPos(X - Edge, Y - Edge);
2021-06-13 10:53:19 +00:00
DrawCornerTex(Edge, 0);
return;
case ECS_HorisontalCorner:
Canvas.SetPos(X, Y);
DrawCornerTex(Edge, 3);
return;
}
case ECP_BottomLeft:
switch (CornerShape)
{
case ECS_Corner:
return;
case ECS_BeveledCorner:
2021-06-14 04:23:36 +00:00
Canvas.SetPos(X, Y - Edge);
2021-06-13 10:53:19 +00:00
DrawCornerTex(Edge, 2);
return;
case ECS_VerticalCorner:
Canvas.SetPos(X, Y);
DrawCornerTex(Edge, 3);
return;
case ECS_HorisontalCorner:
2021-06-14 04:23:36 +00:00
Canvas.SetPos(X - Edge, Y - Edge);
2021-06-13 10:53:19 +00:00
DrawCornerTex(Edge, 0);
return;
}
case ECP_BottomRight:
switch (CornerShape)
{
case ECS_Corner:
return;
case ECS_BeveledCorner:
2021-06-14 04:23:36 +00:00
Canvas.SetPos(X - Edge, Y - Edge);
2021-06-13 10:53:19 +00:00
DrawCornerTex(Edge, 3);
return;
case ECS_VerticalCorner:
2021-06-14 04:23:36 +00:00
Canvas.SetPos(X - Edge, Y);
2021-06-13 10:53:19 +00:00
DrawCornerTex(Edge, 2);
return;
case ECS_HorisontalCorner:
2021-06-14 04:23:36 +00:00
Canvas.SetPos(X, Y - Edge);
2021-06-13 10:53:19 +00:00
DrawCornerTex(Edge, 1);
return;
}
}
}
2021-06-14 04:23:36 +00:00
final function DrawRectBoxSmart(float X, float Y, float W, float H, int Edge, int TopLeftShape, int TopRightShape, int BottomLeftShape, int BottomRightShape)
2021-06-13 10:53:19 +00:00
{
2021-06-14 04:23:36 +00:00
local float BoxX, BoxY, BoxW, BoxH;
// Top Line
DrawCornerSmart(X, Y, Edge, ECP_TopLeft, TopLeftShape);
2021-06-14 04:23:36 +00:00
BoxX = X; BoxY = Y; BoxW = W; BoxH = Edge;
if (TopLeftShape == ECS_BeveledCorner)
{
2021-06-14 04:23:36 +00:00
BoxX += Edge;
BoxW -= Edge;
}
2021-06-14 04:23:36 +00:00
if (TopRightShape == ECS_BeveledCorner)
2021-06-13 10:53:19 +00:00
{
2021-06-14 04:23:36 +00:00
BoxW -= Edge;
2021-06-13 10:53:19 +00:00
}
2021-06-14 04:23:36 +00:00
Canvas.SetPos(BoxX, Y);
DrawWhiteBox(BoxW, Edge);
2021-06-14 04:23:36 +00:00
DrawCornerSmart(X + W, Y, Edge, ECP_TopRight, TopRightShape);
2021-06-13 10:53:19 +00:00
// Mid Line
2021-06-14 04:23:36 +00:00
Canvas.SetPos(X, Y + Edge);
DrawWhiteBox(W, H - Edge * 2);
// Bottom Line
2021-06-14 04:23:36 +00:00
DrawCornerSmart(X, Y + H, Edge, ECP_BottomLeft, BottomLeftShape);
BoxX = X; BoxY = Y + H - Edge; BoxW = W; BoxH = Edge;
if (BottomLeftShape == ECS_BeveledCorner)
{
BoxX += Edge;
BoxW -= Edge;
}
if (BottomRightShape == ECS_BeveledCorner)
{
BoxW -= Edge;
}
Canvas.SetPos(BoxX, Y + H - Edge);
DrawWhiteBox(BoxW, Edge);
DrawCornerSmart(X + W, Y + H, Edge, ECP_BottomRight, BottomRightShape);
}
final function DrawRectBox(float X, float Y, float Width, float Height, int Edge, optional byte Extrav)
{
2021-06-13 02:53:33 +00:00
if (Extrav == 2)
2021-06-13 02:54:35 +00:00
Edge=Min(FMin(Edge, (Width)*0.5), Height);// Verify size.
2021-06-06 21:21:56 +00:00
else
2021-06-13 02:54:35 +00:00
Edge=Min(FMin(Edge, (Width)*0.5), (Height)*0.5);// Verify size.
2021-06-13 02:53:33 +00:00
Canvas.PreOptimizeDrawTiles(Extrav == 0 ? 7 : 6, ItemTex);
2021-06-06 21:21:56 +00:00
switch (Extrav)
{
2021-06-14 02:07:09 +00:00
case 100:
// ______
// | |
// | |
// |______|
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_Corner, // TopLeft
ECS_Corner, // TopRight
ECS_Corner, // BottomLeft
ECS_Corner // BottomRight
);
break;
2021-06-06 21:21:56 +00:00
2021-06-14 02:07:09 +00:00
case 110:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_BeveledCorner, // TopLeft
2021-06-14 02:07:09 +00:00
ECS_Corner, // TopRight
ECS_Corner, // BottomLeft
ECS_BeveledCorner // BottomRight
);
break;
case 111:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_Corner, // TopLeft
ECS_BeveledCorner, // TopRight
ECS_BeveledCorner, // BottomLeft
2021-06-14 02:07:09 +00:00
ECS_Corner // BottomRight
);
break;
case 120:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_VerticalCorner, // TopLeft
ECS_VerticalCorner, // TopRight
ECS_VerticalCorner, // BottomLeft
ECS_VerticalCorner // BottomRight
);
break;
case 121:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_HorisontalCorner, // TopLeft
ECS_HorisontalCorner, // TopRight
ECS_HorisontalCorner, // BottomLeft
ECS_HorisontalCorner // BottomRight
);
2021-06-06 21:21:56 +00:00
break;
2021-06-14 02:07:09 +00:00
case 130:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_Corner, // TopLeft
ECS_Corner, // TopRight
ECS_Corner, // BottomLeft
ECS_BeveledCorner // BottomRight
);
break;
case 131:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_Corner, // TopLeft
ECS_BeveledCorner, // TopRight
ECS_Corner, // BottomLeft
ECS_Corner // BottomRight
);
break;
case 132:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_BeveledCorner, // TopLeft
ECS_Corner, // TopRight
ECS_Corner, // BottomLeft
ECS_Corner // BottomRight
);
break;
case 133:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_Corner, // TopLeft
ECS_Corner, // TopRight
ECS_BeveledCorner, // BottomLeft
ECS_Corner // BottomRight
);
break;
case 140:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_BeveledCorner, // TopLeft
ECS_BeveledCorner, // TopRight
ECS_BeveledCorner, // BottomLeft
ECS_Corner // BottomRight
);
break;
case 141:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_BeveledCorner, // TopLeft
ECS_Corner, // TopRight
ECS_BeveledCorner, // BottomLeft
ECS_BeveledCorner // BottomRight
);
break;
case 142:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_Corner, // TopLeft
ECS_BeveledCorner, // TopRight
ECS_BeveledCorner, // BottomLeft
ECS_BeveledCorner // BottomRight
);
break;
case 143:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_BeveledCorner, // TopLeft
ECS_BeveledCorner, // TopRight
ECS_Corner, // BottomLeft
ECS_BeveledCorner // BottomRight
);
break;
case 150:
2021-06-06 21:21:56 +00:00
// ______
// / \
// | ____ |
// |/ \|
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_BeveledCorner, // TopLeft
ECS_BeveledCorner, // TopRight
ECS_VerticalCorner, // BottomLeft
ECS_VerticalCorner // BottomRight
);
2021-06-06 21:21:56 +00:00
break;
2021-06-14 02:07:09 +00:00
case 151:
// _______
// / /
// | |
// \______\
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_BeveledCorner, // TopLeft
ECS_HorisontalCorner, // TopRight
ECS_BeveledCorner, // BottomLeft
ECS_HorisontalCorner // BottomRight
);
break;
case 152:
//
// |\____/|
// | |
// \______/
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_VerticalCorner, // TopLeft
ECS_VerticalCorner, // TopRight
ECS_BeveledCorner, // BottomLeft
ECS_BeveledCorner // BottomRight
);
break;
case 153:
2021-06-06 21:21:56 +00:00
// _______
// \ \
// | |
// /______/
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_HorisontalCorner, // TopLeft
ECS_BeveledCorner, // TopRight
ECS_HorisontalCorner, // BottomLeft
ECS_BeveledCorner // BottomRight
);
2021-06-06 21:21:56 +00:00
break;
2021-06-14 02:07:09 +00:00
case 160:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_BeveledCorner, // TopLeft
ECS_HorisontalCorner, // TopRight
ECS_BeveledCorner, // BottomLeft
ECS_BeveledCorner // BottomRight
);
break;
2021-06-06 21:58:05 +00:00
2021-06-14 02:07:09 +00:00
case 161:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_VerticalCorner, // TopLeft
2021-06-14 02:07:09 +00:00
ECS_BeveledCorner, // TopRight
ECS_BeveledCorner, // BottomLeft
ECS_BeveledCorner // BottomRight
);
break;
case 162:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_BeveledCorner, // TopLeft
ECS_BeveledCorner, // TopRight
ECS_HorisontalCorner, // BottomLeft
ECS_BeveledCorner // BottomRight
);
break;
case 163:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_BeveledCorner, // TopLeft
ECS_BeveledCorner, // TopRight
ECS_BeveledCorner, // BottomLeft
ECS_VerticalCorner // BottomRight
);
break;
case 170:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_BeveledCorner, // TopLeft
ECS_BeveledCorner, // TopRight
ECS_BeveledCorner, // BottomLeft
ECS_HorisontalCorner // BottomRight
);
break;
case 171:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_BeveledCorner, // TopLeft
ECS_VerticalCorner, // TopRight
ECS_BeveledCorner, // BottomLeft
ECS_BeveledCorner // BottomRight
);
2021-06-06 21:58:05 +00:00
break;
2021-06-06 21:21:56 +00:00
2021-06-14 02:07:09 +00:00
case 172:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_HorisontalCorner, // TopLeft
ECS_BeveledCorner, // TopRight
ECS_BeveledCorner, // BottomLeft
ECS_BeveledCorner // BottomRight
);
break;
case 173:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_BeveledCorner, // TopLeft
ECS_BeveledCorner, // TopRight
ECS_VerticalCorner, // BottomLeft
ECS_BeveledCorner // BottomRight
);
break;
2021-06-13 07:00:31 +00:00
2021-06-14 02:07:09 +00:00
case 180:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_Corner, // TopLeft
2021-06-14 02:07:09 +00:00
ECS_HorisontalCorner, // TopRight
ECS_Corner, // BottomLeft
ECS_Corner // BottomRight
);
break;
case 181:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_VerticalCorner, // TopLeft
ECS_Corner, // TopRight
ECS_Corner, // BottomLeft
ECS_Corner // BottomRight
);
2021-06-14 02:07:09 +00:00
break;
case 182:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_Corner, // TopLeft
ECS_Corner, // TopRight
ECS_HorisontalCorner, // BottomLeft
ECS_Corner // BottomRight
);
break;
case 183:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_Corner, // TopLeft
ECS_Corner, // TopRight
ECS_Corner, // BottomLeft
ECS_VerticalCorner // BottomRight
);
break;
case 190:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_Corner, // TopLeft
ECS_Corner, // TopRight
ECS_Corner, // BottomLeft
ECS_HorisontalCorner // BottomRight
);
break;
case 191:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_Corner, // TopLeft
ECS_VerticalCorner, // TopRight
ECS_Corner, // BottomLeft
ECS_Corner // BottomRight
);
break;
case 192:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_HorisontalCorner, // TopLeft
ECS_Corner, // TopRight
ECS_Corner, // BottomLeft
ECS_Corner // BottomRight
);
break;
case 193:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_Corner, // TopLeft
ECS_Corner, // TopRight
ECS_VerticalCorner, // BottomLeft
ECS_Corner // BottomRight
);
break;
case 200:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_Corner, // TopLeft
ECS_Corner, // TopRight
ECS_VerticalCorner, // BottomLeft
ECS_VerticalCorner // BottomRight
);
break;
case 201:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_Corner, // TopLeft
ECS_HorisontalCorner, // TopRight
ECS_Corner, // BottomLeft
ECS_HorisontalCorner // BottomRight
);
break;
case 202:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_VerticalCorner, // TopLeft
ECS_VerticalCorner, // TopRight
ECS_Corner, // BottomLeft
ECS_Corner // BottomRight
);
break;
case 203:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_HorisontalCorner, // TopLeft
ECS_Corner, // TopRight
ECS_HorisontalCorner, // BottomLeft
ECS_Corner // BottomRight
);
break;
case 210:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_HorisontalCorner, // TopLeft
ECS_HorisontalCorner, // TopRight
ECS_BeveledCorner, // BottomLeft
ECS_BeveledCorner // BottomRight
);
break;
case 211:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_VerticalCorner, // TopLeft
ECS_BeveledCorner, // TopRight
ECS_VerticalCorner, // BottomLeft
ECS_BeveledCorner // BottomRight
);
break;
case 212:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_BeveledCorner, // TopLeft
ECS_BeveledCorner, // TopRight
ECS_HorisontalCorner, // BottomLeft
ECS_HorisontalCorner // BottomRight
);
break;
case 213:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_BeveledCorner, // TopLeft
ECS_VerticalCorner, // TopRight
ECS_BeveledCorner, // BottomLeft
ECS_VerticalCorner // BottomRight
);
break;
case 220:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_HorisontalCorner, // TopLeft
ECS_HorisontalCorner, // TopRight
ECS_Corner, // BottomLeft
ECS_Corner // BottomRight
);
break;
case 221:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_VerticalCorner, // TopLeft
ECS_Corner, // TopRight
ECS_VerticalCorner, // BottomLeft
ECS_Corner // BottomRight
);
break;
case 222:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_Corner, // TopLeft
ECS_Corner, // TopRight
ECS_HorisontalCorner, // BottomLeft
ECS_HorisontalCorner // BottomRight
);
break;
case 223:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_Corner, // TopLeft
ECS_VerticalCorner, // TopRight
ECS_Corner, // BottomLeft
ECS_VerticalCorner // BottomRight
);
break;
case 230:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_BeveledCorner, // TopLeft
ECS_HorisontalCorner, // TopRight
ECS_HorisontalCorner, // BottomLeft
ECS_BeveledCorner // BottomRight
);
break;
case 231:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_VerticalCorner, // TopLeft
ECS_BeveledCorner, // TopRight
ECS_BeveledCorner, // BottomLeft
ECS_VerticalCorner // BottomRight
);
break;
case 232:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_HorisontalCorner, // TopLeft
ECS_BeveledCorner, // TopRight
ECS_BeveledCorner, // BottomLeft
ECS_HorisontalCorner // BottomRight
);
break;
case 233:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_BeveledCorner, // TopLeft
ECS_VerticalCorner, // TopRight
ECS_VerticalCorner, // BottomLeft
ECS_BeveledCorner // BottomRight
);
break;
case 240:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_Corner, // TopLeft
ECS_HorisontalCorner, // TopRight
ECS_HorisontalCorner, // BottomLeft
ECS_Corner // BottomRight
);
break;
case 241:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_VerticalCorner, // TopLeft
ECS_Corner, // TopRight
ECS_Corner, // BottomLeft
ECS_VerticalCorner // BottomRight
);
break;
case 242:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_HorisontalCorner, // TopLeft
ECS_Corner, // TopRight
ECS_Corner, // BottomLeft
ECS_HorisontalCorner // BottomRight
);
break;
case 243:
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_Corner, // TopLeft
ECS_VerticalCorner, // TopRight
ECS_VerticalCorner, // BottomLeft
ECS_Corner // BottomRight
);
break;
2021-06-13 08:36:10 +00:00
default: // 0
2021-06-06 21:21:56 +00:00
// ______
// / \
// | |
// \______/
DrawRectBoxSmart(X, Y, Width, Height, Edge,
ECS_BeveledCorner, // TopLeft
ECS_BeveledCorner, // TopRight
ECS_BeveledCorner, // BottomLeft
ECS_BeveledCorner // BottomRight
);
2021-06-06 21:21:56 +00:00
break;
}
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
final function DrawBoxHollow(float X, float Y, float Width, float Height, float Thickness)
2020-01-10 13:14:11 +00:00
{
Canvas.PreOptimizeDrawTiles(4, ItemTex);
2020-01-10 13:14:11 +00:00
Canvas.SetPos(X + Thickness, Y);
DrawWhiteBox(Width - Thickness * 2, Thickness);
2020-01-10 13:14:11 +00:00
Canvas.SetPos(X + Thickness, Y+Height-Thickness);
DrawWhiteBox(Width - Thickness * 2, Thickness);
2020-01-10 13:14:11 +00:00
Canvas.SetPos(X, Y);
DrawWhiteBox(Thickness, Height);
2020-01-10 13:14:11 +00:00
Canvas.SetPos(X + Width - Thickness, Y);
DrawWhiteBox(Thickness, Height);
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
final function DrawOutlinedBox(float X, float Y, float Width, float Height, float Thickness, Color BoxColor, Color OutlineColor)
2020-01-10 13:14:11 +00:00
{
Canvas.DrawColor = BoxColor;
Canvas.SetPos(X + Thickness, Y + Thickness);
DrawWhiteBox(Width - (Thickness*2), Height - (Thickness*2));
Canvas.DrawColor = OutlineColor;
DrawBoxHollow(X, Y, Width, Height, Thickness);
2020-01-10 13:14:11 +00:00
}
final function DrawBoxCorners(float BorderSize, float X, float Y, float W, float H, optional bool TopLeft, optional bool TopRight, optional bool BottomLeft, optional bool BottomRight)
{
// Top left
2021-06-13 02:54:35 +00:00
Canvas.SetPos(X, Y);
2021-06-13 02:53:33 +00:00
if (TopLeft)
2021-06-13 02:54:35 +00:00
DrawCornerTex(BorderSize, 0);
else DrawWhiteBox(BorderSize, BorderSize);
// Top right
2021-06-13 02:54:35 +00:00
Canvas.SetPos(X+W-BorderSize, Y);
2021-06-13 02:53:33 +00:00
if (TopRight)
2021-06-13 02:54:35 +00:00
DrawCornerTex(BorderSize, 1);
else DrawWhiteBox(BorderSize, BorderSize);
// Bottom left
2021-06-13 02:54:35 +00:00
Canvas.SetPos(X, Y+H-BorderSize);
2021-06-13 02:53:33 +00:00
if (BottomLeft)
2021-06-13 02:54:35 +00:00
DrawCornerTex(BorderSize, 2);
else DrawWhiteBox(BorderSize, BorderSize);
// Bottom right
2021-06-13 02:54:35 +00:00
Canvas.SetPos(X+W-BorderSize, Y+H-BorderSize);
2021-06-13 02:53:33 +00:00
if (BottomRight)
2021-06-13 02:54:35 +00:00
DrawCornerTex(BorderSize, 3);
else DrawWhiteBox(BorderSize, BorderSize);
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
final function DrawRoundedBox(float BorderSize, float X, float Y, float W, float H, Color BoxColor)
2020-01-10 13:14:11 +00:00
{
DrawRoundedBoxEx(BorderSize, X, Y, W, H, BoxColor, true, true, true, true);
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
final function DrawRoundedBoxEx(float BorderSize, float X, float Y, float W, float H, Color BoxColor, optional bool TopLeft, optional bool TopRight, optional bool BottomLeft, optional bool BottomRight)
2020-01-10 13:14:11 +00:00
{
Canvas.DrawColor = BoxColor;
2021-06-13 02:53:33 +00:00
if (BorderSize <= 0)
{
Canvas.SetPos(X, Y);
DrawWhiteBox(W, H);
return;
}
Canvas.PreOptimizeDrawTiles(7, ItemTex);
2020-01-10 13:14:11 +00:00
2021-06-13 02:54:35 +00:00
BorderSize = Min(FMin(BorderSize, (W)*0.5), (H)*0.5);
2020-01-10 13:14:11 +00:00
Canvas.SetPos(X + BorderSize, Y);
DrawWhiteBox(W - BorderSize * 2, H);
2020-01-10 13:14:11 +00:00
Canvas.SetPos(X, Y + BorderSize);
DrawWhiteBox(BorderSize, H - BorderSize * 2);
2020-01-10 13:14:11 +00:00
Canvas.SetPos(X + W - BorderSize, Y + BorderSize);
DrawWhiteBox(BorderSize, H - BorderSize * 2);
DrawBoxCorners(BorderSize, X, Y, W, H, TopLeft, TopRight, BottomLeft, BottomRight);
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
final function DrawRoundedBoxHollow(float BorderSize, float X, float Y, float W, float H, Color BoxColor)
2020-01-10 13:14:11 +00:00
{
DrawRoundedBoxHollowEx(BorderSize, X, Y, W, H, BoxColor, true, true, true, true);
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
final function DrawRoundedBoxHollowEx(float BorderSize, float X, float Y, float W, float H, Color BoxColor, optional bool TopLeft, optional bool TopRight, optional bool BottomLeft, optional bool BottomRight)
2020-01-10 13:14:11 +00:00
{
Canvas.PreOptimizeDrawTiles(8, ItemTex);
2021-06-13 02:54:35 +00:00
BorderSize = Min(FMin(BorderSize, (W)*0.5), (H)*0.5);
Canvas.DrawColor = BoxColor;
Canvas.SetPos(X + BorderSize, Y);
DrawWhiteBox(W - BorderSize * 2, BorderSize);
Canvas.SetPos(X + BorderSize, Y+H-BorderSize);
DrawWhiteBox(W - BorderSize * 2, BorderSize);
2020-01-10 13:14:11 +00:00
Canvas.SetPos(X, Y + BorderSize);
DrawWhiteBox(BorderSize, H - BorderSize * 2);
2020-01-10 13:14:11 +00:00
Canvas.SetPos(X + W - BorderSize, Y + BorderSize);
DrawWhiteBox(BorderSize, H - BorderSize * 2);
2020-01-10 13:14:11 +00:00
DrawBoxCorners(BorderSize, X, Y, W, H, TopLeft, TopRight, BottomLeft, BottomRight);
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
final function DrawRoundedBoxOutlined(float BorderSize, float X, float Y, float Width, float Height, Color BoxColor, Color OutlineColor)
2020-01-10 13:14:11 +00:00
{
Canvas.DrawColor = BoxColor;
Canvas.SetPos(X + BorderSize, Y + BorderSize);
DrawWhiteBox(Width - (BorderSize*2), Height - (BorderSize*2));
DrawRoundedBoxHollow(BorderSize, X, Y, Width, Height, OutlineColor);
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
final function DrawRoundedBoxOutlinedEx(float BorderSize, float X, float Y, float Width, float Height, Color BoxColor, Color OutlineColor, optional bool TopLeft, optional bool TopRight, optional bool BottomLeft, optional bool BottomRight)
2020-01-10 13:14:11 +00:00
{
Canvas.DrawColor = BoxColor;
Canvas.SetPos(X + BorderSize, Y + BorderSize);
DrawWhiteBox(Width - (BorderSize*2), Height - (BorderSize*2));
DrawRoundedBoxHollowEx(BorderSize, X, Y, Width, Height, OutlineColor, TopLeft, TopRight, BottomLeft, BottomRight);
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
final function DrawArrowBox(int Direction, float X, float Y, float Width, float Height)
2020-01-10 13:14:11 +00:00
{
local Texture2D DirectionMat;
2021-06-13 03:00:19 +00:00
switch (Direction)
{
case 0:
DirectionMat=ArrowTextures[`ARROW_UP];
break;
case 1:
DirectionMat=ArrowTextures[`ARROW_RIGHT];
break;
case 2:
DirectionMat=ArrowTextures[`ARROW_DOWN];
break;
case 3:
DirectionMat=ArrowTextures[`ARROW_LEFT];
break;
default:
DirectionMat=ArrowTextures[`ARROW_UP];
break;
}
2021-06-13 02:54:35 +00:00
DrawTileStretched(ScrollTexture, X,Y, Width, Height);
DrawTileStretched(DirectionMat, X,Y, Width, Height);
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
final function DrawTileStretched(Texture Tex, float X, float Y, float XS, float YS)
2020-01-10 13:14:11 +00:00
{
2021-06-13 02:54:35 +00:00
local float mW, mH, MidX, MidY, SmallTileW, SmallTileH, fX, fY;
local int OptimizeTiles;
2020-01-10 13:14:11 +00:00
2021-06-13 02:53:33 +00:00
if (Tex == None ) Tex = Texture2D'EngineMaterials.DefaultDiffuse';
2020-01-10 13:14:11 +00:00
// Get the size of the image
mW = Tex.GetSurfaceWidth();
mH = Tex.GetSurfaceHeight();
2020-01-10 13:14:11 +00:00
// Get the midpoints of the image
MidX = int(mW/2);
MidY = int(mH/2);
2020-01-10 13:14:11 +00:00
// Grab info about the scaled image
SmallTileW = XS - mW;
SmallTileH = YS - mH;
// Optimized
OptimizeTiles = 4;
2021-06-13 02:53:33 +00:00
if (mW < XS)
OptimizeTiles += 2;
2021-06-13 02:53:33 +00:00
if (mH < YS)
OptimizeTiles += 2;
2021-06-13 02:53:33 +00:00
if ((mH < YS) && (mW < XS))
OptimizeTiles += 1;
Canvas.PreOptimizeDrawTiles(OptimizeTiles, Tex);
2020-01-10 13:14:11 +00:00
// Draw the spans first
// Top and Bottom
2021-06-13 02:53:33 +00:00
if (mW < XS)
{
fX = MidX;
2020-01-10 13:14:11 +00:00
2021-06-13 02:53:33 +00:00
if (mH > YS)
fY = YS/2;
else
fY = MidY;
2020-01-10 13:14:11 +00:00
2021-06-13 02:54:35 +00:00
Canvas.SetPos(X+fX, Y);
Canvas.DrawTile(Tex, SmallTileW, fY, MidX, 0,1, fY);
Canvas.SetPos(X+fX, Y+YS-fY);
Canvas.DrawTile(Tex, SmallTileW, fY, MidX, mH-fY, 1,fY);
}
else
fX = XS / 2;
2020-01-10 13:14:11 +00:00
// Left and Right
2021-06-13 02:53:33 +00:00
if (mH < YS)
{
fY = MidY;
2020-01-10 13:14:11 +00:00
2021-06-13 02:54:35 +00:00
Canvas.SetPos(X, Y+fY);
Canvas.DrawTile(Tex, fX, SmallTileH, 0,fY, fX, 1);
Canvas.SetPos(X+XS-fX, Y+fY);
Canvas.DrawTile(Tex, fX, SmallTileH, mW-fX, fY, fX, 1);
}
else
fY = YS / 2;
2020-01-10 13:14:11 +00:00
// Center
2021-06-13 02:53:33 +00:00
if ((mH < YS) && (mW < XS))
{
2021-06-13 02:54:35 +00:00
Canvas.SetPos(X+fX, Y+fY);
Canvas.DrawTile(Tex, SmallTileW, SmallTileH, fX, fY, 1,1);
}
2020-01-10 13:14:11 +00:00
// Draw the 4 corners.
2021-06-13 02:54:35 +00:00
Canvas.SetPos(X, Y);
Canvas.DrawTile(Tex, fX, fY, 0,0, fX, fY);
Canvas.SetPos(X+XS-fX, Y);
Canvas.DrawTile(Tex, fX, fY, mW-fX, 0,fX, fY);
Canvas.SetPos(X, Y+YS-fY);
Canvas.DrawTile(Tex, fX, fY, 0,mH-fY, fX, fY);
Canvas.SetPos(X+XS-fX, Y+YS-fY);
Canvas.DrawTile(Tex, fX, fY, mW-fX, mH-fY, fX, fY);
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
final function DrawTextJustified(byte Justification, float X1, float Y1, float X2, float Y2, coerce string S, optional float XS, optional float YS)
2020-01-10 13:14:11 +00:00
{
local float XL, YL;
local float CurY, CurX;
Canvas.TextSize(S, XL, YL, XS, YS);
CurY = ((Y2-Y1) / 2) - (YL/2);
2021-06-13 02:53:33 +00:00
if (Justification == 0)
{
CurX = 0;
}
2021-06-13 02:53:33 +00:00
else if (Justification == 1)
{
2021-06-13 02:53:33 +00:00
if (XL > X2-X1)
CurX = 0;
else CurX = ((X2-X1) / 2) - (XL/2);
}
2021-06-13 02:53:33 +00:00
else if (Justification == 2)
{
CurX = (X2-X1) - XL;
}
Canvas.SetPos(CurX, CurY);
2021-06-13 02:54:35 +00:00
Canvas.DrawText(S, ,XS, YS);
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
static final function float TimeFraction(float Start, float End, float Current)
2020-01-10 13:14:11 +00:00
{
return FClamp((Current - Start) / (End - Start), 0.f, 1.f);
2020-01-10 13:14:11 +00:00
}
static final function string LTrim(coerce string S)
{
while (Left(S, 1) == " ")
S = Right(S, Len(S) - 1);
return S;
2020-01-10 13:14:11 +00:00
}
static final function string RTrim(coerce string S)
{
while (Right(S, 1) == " ")
S = Left(S, Len(S) - 1);
return S;
2020-01-10 13:14:11 +00:00
}
static final function string Trim(coerce string S)
{
return LTrim(RTrim(S));
2020-01-10 13:14:11 +00:00
}
defaultproperties
{
// Font'UI_Canvas_Fonts.Font_Main'
2021-05-16 20:28:37 +00:00
//MainFont=Font'KFScoreboardExt_Assets.Font.KFMainFont'
//InfiniteFont=Font'KFScoreboardExt_Assets.Font.KFInfiniteFont'
MainFont=Font'UI_Canvas_Fonts.Font_Main'
NumberFont=Font'UI_Canvas_Fonts.Font_General'
2021-05-16 20:28:37 +00:00
InfiniteFont=Font'UI_Canvas_Fonts.Font_Main'
2020-01-10 13:14:11 +00:00
}