2022-09-03 17:26:40 +00:00
|
|
|
class KFGUI_ComboBox extends KFGUI_EditControl;
|
2021-06-12 20:11:37 +00:00
|
|
|
|
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()
|
|
|
|
{
|
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 + (BorderSize*2)) / InputPos[3];
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function DrawMenu()
|
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
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
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
PlayMenuSound(MN_Dropdown);
|
2021-06-13 02:53:33 +00:00
|
|
|
if (Selection == None)
|
2021-05-16 09:40:02 +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);
|
2021-06-13 02:53:33 +00:00
|
|
|
if ((Selection.YPosition+Selection.YSize) > 1.f)
|
|
|
|
Selection.YPosition -= ((Selection.YPosition+Selection.YSize)-1.f);
|
2021-05-16 09:40:02 +00:00
|
|
|
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)
|
2021-05-16 09:40:02 +00:00
|
|
|
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
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local int i;
|
|
|
|
|
|
|
|
i = Values.Find(S);
|
2021-06-13 02:53:33 +00:00
|
|
|
if (i == -1)
|
2021-05-16 09:40:02 +00:00
|
|
|
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)
|
2021-05-16 09:40:02 +00:00
|
|
|
BorderSize=4
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|