2022-09-03 17:26:40 +00:00
|
|
|
class KFGUI_EditControl extends KFGUI_Clickable;
|
2021-06-12 20:11:37 +00:00
|
|
|
|
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 == "")
|
2021-05-16 09:40:02 +00:00
|
|
|
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()
|
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
// Update height.
|
2021-06-13 02:53:33 +00:00
|
|
|
if (bScaleByFontSize)
|
2021-05-16 09:40:02 +00:00
|
|
|
YSize = ((TextHeight*1.05) + 6) / InputPos[3];
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function PreDraw()
|
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local float XS;
|
|
|
|
local byte i;
|
2020-01-10 13:14:11 +00:00
|
|
|
|
2021-05-16 09:40:02 +00:00
|
|
|
Canvas.Font = Owner.CurrentStyle.PickFont(TextScale);
|
2020-01-10 13:14:11 +00:00
|
|
|
|
2021-05-16 09:40:02 +00:00
|
|
|
TextScale *= FontScale;
|
|
|
|
TextFont = Canvas.Font;
|
|
|
|
|
2021-06-13 02:54:35 +00:00
|
|
|
Canvas.TextSize("ABC", XS, TextHeight, TextScale, TextScale);
|
2021-05-16 09:40:02 +00:00
|
|
|
|
|
|
|
UpdateSizes();
|
|
|
|
|
|
|
|
Super.PreDraw();
|
2021-06-13 02:53:33 +00:00
|
|
|
if (TextLable != None)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
TextLable.YSize = YSize;
|
|
|
|
TextLable.Canvas = Canvas;
|
2021-06-13 02:53:33 +00:00
|
|
|
for (i=0; i < 4; ++i)
|
2021-05-16 09:40:02 +00:00
|
|
|
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;
|
2021-05-16 09:40:02 +00:00
|
|
|
|
|
|
|
l = Len(S);
|
2021-06-13 02:53:33 +00:00
|
|
|
for (i=0; i < l; ++i)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
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)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
--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)
|
2021-05-16 09:40:02 +00:00
|
|
|
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
|
|
|
|
2021-05-16 09:40:02 +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)
|
2021-05-16 09:40:02 +00:00
|
|
|
End Object
|
|
|
|
TextLable=MyBoxLableText
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|