2017-10-20 02:00:49 +00:00
|
|
|
Class KFGUI_EditControl extends KFGUI_Clickable;
|
|
|
|
|
|
|
|
var export editinline KFGUI_TextLable TextLable;
|
|
|
|
var transient float TextHeight,TextScale;
|
|
|
|
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()
|
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
if (LableString=="")
|
2017-10-20 02:00:49 +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;
|
|
|
|
}
|
|
|
|
|
|
|
|
function UpdateSizes()
|
|
|
|
{
|
|
|
|
// Update height.
|
2020-11-28 20:12:58 +00:00
|
|
|
if (bScaleByFontSize)
|
2017-10-20 02:00:49 +00:00
|
|
|
YSize = ((TextHeight*1.05) + 6) / InputPos[3];
|
|
|
|
}
|
|
|
|
|
|
|
|
function PreDraw()
|
|
|
|
{
|
|
|
|
local float XS;
|
|
|
|
local byte i;
|
|
|
|
|
|
|
|
Canvas.Font = Owner.CurrentStyle.PickFont(Min(FontScale+Owner.CurrentStyle.DefaultFontSize,Owner.CurrentStyle.MaxFontScale),TextScale);
|
|
|
|
TextFont = Canvas.Font;
|
|
|
|
Canvas.TextSize("ABC",XS,TextHeight,TextScale,TextScale);
|
2023-05-14 02:49:12 +00:00
|
|
|
|
2017-10-20 02:00:49 +00:00
|
|
|
UpdateSizes();
|
|
|
|
|
|
|
|
Super.PreDraw();
|
2020-11-28 20:12:58 +00:00
|
|
|
if (TextLable!=None)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
TextLable.YSize = YSize;
|
|
|
|
TextLable.Canvas = Canvas;
|
2020-11-28 20:12:58 +00:00
|
|
|
for (i=0; i<4; ++i)
|
2017-10-20 02:00:49 +00:00
|
|
|
TextLable.InputPos[i] = InputPos[i];
|
|
|
|
TextLable.PreDraw();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
final function DrawClippedText(string S, float TScale, float MaxX)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
local int i,l;
|
|
|
|
local float X,XL,YL;
|
2023-05-14 02:49:12 +00:00
|
|
|
|
2017-10-20 02:00:49 +00:00
|
|
|
l = Len(S);
|
2020-11-28 20:12:58 +00:00
|
|
|
for (i=0; i<l; ++i)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
Canvas.TextSize(Mid(S,i,1),XL,YL,TScale,TScale);
|
2020-11-28 20:12:58 +00:00
|
|
|
if ((Canvas.CurX+X+XL)>MaxX)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
--i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
X+=XL;
|
|
|
|
}
|
|
|
|
Canvas.DrawText(Left(S,i),,TScale,TScale,TextFontInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
defaultproperties
|
|
|
|
{
|
|
|
|
LableColor=(R=255,G=255,B=255,A=255)
|
|
|
|
FontScale=0
|
|
|
|
LableWidth=0.5
|
|
|
|
bScaleByFontSize=true
|
|
|
|
TextFontInfo=(bClipText=true,bEnableShadow=true)
|
|
|
|
|
|
|
|
Begin Object Class=KFGUI_TextLable Name=MyBoxLableText
|
|
|
|
AlignX=0
|
|
|
|
AlignY=1
|
|
|
|
TextFontInfo=(bClipText=true,bEnableShadow=true)
|
|
|
|
End Object
|
|
|
|
TextLable=MyBoxLableText
|
|
|
|
}
|