KF2-YetAnotherScoreboard/YAS/Classes/KFGUI_EditControl.uc

105 lines
2.2 KiB
Ucode
Raw Normal View History

2020-01-10 13:14:11 +00:00
Class KFGUI_EditControl extends KFGUI_Clickable;
2021-06-12 20:11:37 +00:00
`include(Build.uci)
`include(Logger.uci)
2020-01-10 13:14:11 +00:00
var export editinline KFGUI_TextLable TextLable;
2021-06-13 02:54:35 +00:00
var transient float TextHeight, TextScale;
2020-01-10 13:14:11 +00:00
var transient Font TextFont;
var Canvas.FontRenderInfo TextFontInfo;
var(Lable) float LableWidth;
var(Lable) string LableString;
var(Lable) color LableColor; // Label text color.
var(Lable) byte FontScale;
var(Lable) bool bScaleByFontSize; // Scale this component height by font height.
function InitMenu()
{
2021-06-13 02:53:33 +00:00
if (LableString == "")
TextLable = None;
else
{
TextLable.SetText(LableString);
TextLable.FontScale = FontScale;
TextLable.XPosition = XPosition;
TextLable.YPosition = YPosition;
TextLable.XSize = (XSize*LableWidth*0.975);
TextLable.YSize = YSize;
TextLable.Owner = Owner;
TextLable.TextColor = LableColor;
TextLable.ParentComponent = Self;
TextLable.InitMenu();
XPosition+=(XSize*LableWidth);
XSize*=(1.f-LableWidth);
}
Super.InitMenu();
bClickable = !bDisabled;
2020-01-10 13:14:11 +00:00
}
function UpdateSizes()
{
// Update height.
2021-06-13 02:53:33 +00:00
if (bScaleByFontSize)
YSize = ((TextHeight*1.05) + 6) / InputPos[3];
2020-01-10 13:14:11 +00:00
}
function PreDraw()
{
local float XS;
local byte i;
2020-01-10 13:14:11 +00:00
Canvas.Font = Owner.CurrentStyle.PickFont(TextScale);
2020-01-10 13:14:11 +00:00
TextScale *= FontScale;
TextFont = Canvas.Font;
2021-06-13 02:54:35 +00:00
Canvas.TextSize("ABC", XS, TextHeight, TextScale, TextScale);
UpdateSizes();
Super.PreDraw();
2021-06-13 02:53:33 +00:00
if (TextLable != None)
{
TextLable.YSize = YSize;
TextLable.Canvas = Canvas;
2021-06-13 02:53:33 +00:00
for (i=0; i < 4; ++i)
TextLable.InputPos[i] = InputPos[i];
TextLable.PreDraw();
}
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
final function DrawClippedText(string S, float TScale, float MaxX)
2020-01-10 13:14:11 +00:00
{
2021-06-13 02:54:35 +00:00
local int i, l;
local float X, XL, YL;
l = Len(S);
2021-06-13 02:53:33 +00:00
for (i=0; i < l; ++i)
{
2021-06-13 02:54:35 +00:00
Canvas.TextSize(Mid(S, i,1), XL, YL, TScale, TScale);
2021-06-13 02:53:33 +00:00
if ((Canvas.CurX+X+XL) > MaxX)
{
--i;
break;
}
X+=XL;
}
2021-06-13 02:54:35 +00:00
Canvas.DrawText(Left(S, i), ,TScale, TScale, TextFontInfo);
2020-01-10 13:14:11 +00:00
}
defaultproperties
{
2021-06-13 02:54:35 +00:00
LableColor=(R=255, G=255, B=255, A=255)
FontScale=1
LableWidth=0.5
bScaleByFontSize=true
2021-06-13 02:54:35 +00:00
TextFontInfo=(bClipText=true, bEnableShadow=true)
2020-01-10 13:14:11 +00:00
Begin Object Class=KFGUI_TextLable Name=MyBoxLableText
AlignX=0
AlignY=1
2021-06-13 02:54:35 +00:00
TextFontInfo=(bClipText=true, bEnableShadow=true)
End Object
TextLable=MyBoxLableText
2020-01-10 13:14:11 +00:00
}