KF2-Server-Extension/ServerExt/Classes/KFGUI_ComboBox.uc

67 lines
1.5 KiB
Ucode
Raw Normal View History

2017-10-20 02:00:49 +00:00
Class KFGUI_ComboBox extends KFGUI_EditControl;
var KFGUI_ComboSelector Selection;
var float BorderSize;
var() array<string> Values;
var() int SelectedIndex;
var() color SelectedTextColor,TextColor;
var() bool bButtonStretched;
function UpdateSizes()
{
// Update height.
2020-11-28 20:12:58 +00:00
if (bScaleByFontSize)
2017-10-20 02:00:49 +00:00
YSize = (TextHeight + (BorderSize*2)) / InputPos[3];
}
function DrawMenu()
{
Owner.CurrentStyle.RenderComboBox(Self);
}
2020-11-28 20:04:55 +00:00
function HandleMouseClick(bool bRight)
2017-10-20 02:00:49 +00:00
{
PlayMenuSound(MN_Dropdown);
2020-11-28 20:12:58 +00:00
if (Selection==None)
2017-10-20 02:00:49 +00:00
{
Selection = New(None)Class'KFGUI_ComboSelector';
Selection.Owner = Owner;
Selection.Combo = Self;
Selection.InitMenu();
}
Selection.XPosition = CompPos[0] / Owner.ScreenSize.X;
Selection.YPosition = (CompPos[1]+CompPos[3]) / Owner.ScreenSize.Y;
Selection.XSize = CompPos[2] / Owner.ScreenSize.X;
Selection.YSize = (TextHeight / Owner.ScreenSize.Y) * Values.Length + ((BorderSize*2) / Owner.ScreenSize.Y);
2020-11-28 20:12:58 +00:00
if ((Selection.YPosition+Selection.YSize)>1.f)
2017-10-20 02:00:49 +00:00
Selection.YPosition-=((Selection.YPosition+Selection.YSize)-1.f);
Selection.GetInputFocus();
}
2020-11-28 21:54:57 +00:00
2017-10-20 02:00:49 +00:00
final function string GetCurrent()
{
2020-11-28 20:12:58 +00:00
if (SelectedIndex<Values.Length)
2017-10-20 02:00:49 +00:00
return Values[SelectedIndex];
return "";
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
final function bool SetValue(string S)
2017-10-20 02:00:49 +00:00
{
local int i;
i = Values.Find(S);
2020-11-28 20:12:58 +00:00
if (i==-1)
2017-10-20 02:00:49 +00:00
return false;
SelectedIndex = i;
return true;
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
Delegate OnComboChanged(KFGUI_ComboBox Sender);
2017-10-20 02:00:49 +00:00
defaultproperties
{
SelectedTextColor=(R=255,G=128,B=128,A=255)
TextColor=(R=255,G=255,B=255,A=255)
BorderSize=4
}