2020-01-10 13:14:11 +00:00
|
|
|
class KFGUI_ProgressBar extends KFGUI_Base;
|
|
|
|
|
|
|
|
var Texture BarBack;
|
|
|
|
var Texture BarTop;
|
|
|
|
var Color BarColor;
|
|
|
|
var float Low;
|
|
|
|
var float High;
|
|
|
|
var float Value;
|
|
|
|
|
|
|
|
var float CaptionWidth;
|
|
|
|
var byte CaptionAlign;
|
|
|
|
var byte ValueRightAlign;
|
|
|
|
var string Caption;
|
|
|
|
|
|
|
|
var float GraphicMargin;
|
|
|
|
var float ValueRightWidth;
|
|
|
|
var bool bShowLow;
|
|
|
|
var bool bShowHigh;
|
|
|
|
var bool bShowValue;
|
|
|
|
var int NumDecimals;
|
|
|
|
|
|
|
|
var byte BorderSize;
|
|
|
|
|
|
|
|
function DrawMenu()
|
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local float Left, Top, Width, Height;
|
|
|
|
local float W, Sc;
|
|
|
|
local string S;
|
|
|
|
|
|
|
|
Super.DrawMenu();
|
|
|
|
|
|
|
|
Left = 0.f;
|
|
|
|
Top = 0.f;
|
|
|
|
Width = CompPos[2];
|
|
|
|
Height = CompPos[3];
|
|
|
|
|
|
|
|
// Select the right font in the Canvas
|
2023-05-01 20:06:46 +00:00
|
|
|
Canvas.Font = Owner.CurrentStyle.PickFont(Sc);
|
2021-05-16 09:40:02 +00:00
|
|
|
|
|
|
|
if (CaptionWidth > 0.0 && Width > 0 && Len(Caption) > 0)
|
|
|
|
{
|
|
|
|
W = CaptionWidth;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (W < 1.0)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
W *= Width;
|
|
|
|
}
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (W > Width)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
W = Width;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Draw the label
|
|
|
|
Owner.CurrentStyle.DrawTextJustified(CaptionAlign, Left, Top, Left + W, Top + Height, Caption, Sc, Sc);
|
|
|
|
Left += W;
|
|
|
|
Width -= W;
|
|
|
|
}
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if ((bShowHigh || bShowValue) && ValueRightWidth > 0.0 && Width > 0.0)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
W = ValueRightWidth;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (W < 1.0)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
W *= Width;
|
|
|
|
}
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (W > Width)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
W = Width;
|
|
|
|
}
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (bShowValue && bShowHigh)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
S = int(Value)$"/"$int(High);
|
|
|
|
}
|
|
|
|
else if (bShowValue)
|
|
|
|
{
|
|
|
|
S = string(int(Value));
|
|
|
|
}
|
2023-05-01 20:06:46 +00:00
|
|
|
else
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
S = string(int(High));
|
|
|
|
}
|
|
|
|
|
|
|
|
Owner.CurrentStyle.DrawTextJustified(ValueRightAlign, Left + Width - W, Top, Left + Width, Top + Height, S, Sc, Sc);
|
|
|
|
|
|
|
|
Width -= W;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Width > GraphicMargin)
|
|
|
|
{
|
|
|
|
Width -= GraphicMargin;
|
|
|
|
Left += GraphicMargin / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
Canvas.SetDrawColor(255, 255, 255, 255);
|
2021-06-13 02:53:33 +00:00
|
|
|
if (Width > 0.0 && BarBack != None)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
Owner.CurrentStyle.DrawTileStretched(BarBack, Left, Top, Width, Height);
|
|
|
|
}
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (Width > 0.0 && BarTop != None && Value > Low)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
Canvas.DrawColor = BarColor;
|
|
|
|
Owner.CurrentStyle.DrawTileStretched(BarTop, Left + BorderSize, Top + BorderSize, (Width - (BorderSize * 2)) * (Value/High), Height - (BorderSize * 2));
|
|
|
|
}
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function SetValue(float val)
|
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
Value=val;
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function float GetValue()
|
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
return Value;
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
defaultproperties
|
|
|
|
{
|
2021-06-13 02:54:35 +00:00
|
|
|
BarColor=(R=255, G=255, B=255, A=255)
|
2021-05-16 09:40:02 +00:00
|
|
|
Low=0.f
|
|
|
|
High=100.f
|
|
|
|
Value=0.f
|
|
|
|
bShowLow=false
|
|
|
|
bShowHigh=false
|
|
|
|
bShowValue=true
|
|
|
|
CaptionWidth=0.45
|
|
|
|
ValueRightWidth=0.2
|
|
|
|
ValueRightAlign=0
|
|
|
|
NumDecimals=0
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|