KF2-YetAnotherScoreboard/YAS/Classes/KFGUI_ComboBox.uc

67 lines
1.5 KiB
Ucode
Raw Normal View History

2020-01-10 13:14:11 +00:00
Class KFGUI_ComboBox extends KFGUI_EditControl;
2021-06-12 20:11:37 +00:00
`include(Build.uci)
`include(Logger.uci)
2020-01-10 13:14:11 +00:00
var KFGUI_ComboSelector Selection;
var float BorderSize;
2021-06-13 03:17:40 +00:00
var() array<string> Values;
2020-01-10 13:14:11 +00:00
var() int SelectedIndex;
2021-06-13 02:54:35 +00:00
var() color SelectedTextColor, TextColor;
2020-01-10 13:14:11 +00:00
var() bool bButtonStretched;
function UpdateSizes()
{
// Update height.
2021-06-13 02:53:33 +00:00
if (bScaleByFontSize)
YSize = (TextHeight + (BorderSize*2)) / InputPos[3];
2020-01-10 13:14:11 +00:00
}
function DrawMenu()
{
Owner.CurrentStyle.RenderComboBox(Self);
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
function HandleMouseClick(bool bRight)
2020-01-10 13:14:11 +00:00
{
PlayMenuSound(MN_Dropdown);
2021-06-13 02:53:33 +00:00
if (Selection == None)
{
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);
2021-06-13 02:53:33 +00:00
if ((Selection.YPosition+Selection.YSize) > 1.f)
Selection.YPosition -= ((Selection.YPosition+Selection.YSize)-1.f);
Selection.GetInputFocus();
2020-01-10 13:14:11 +00:00
}
final function string GetCurrent()
{
2021-06-13 02:53:33 +00:00
if (SelectedIndex < Values.Length)
return Values[SelectedIndex];
return "";
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
final function bool SetValue(string S)
2020-01-10 13:14:11 +00:00
{
local int i;
i = Values.Find(S);
2021-06-13 02:53:33 +00:00
if (i == -1)
return false;
SelectedIndex = i;
return true;
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
Delegate OnComboChanged(KFGUI_ComboBox Sender);
2020-01-10 13:14:11 +00:00
defaultproperties
{
2021-06-13 02:54:35 +00:00
SelectedTextColor=(R=255, G=128, B=128, A=255)
TextColor=(R=255, G=255, B=255, A=255)
BorderSize=4
2020-01-10 13:14:11 +00:00
}