2017-10-20 02:00:49 +00:00
|
|
|
// Menu system written by Marco.
|
|
|
|
Class KFGUI_Base extends Object
|
|
|
|
abstract;
|
|
|
|
|
|
|
|
var KF2GUIController Owner;
|
|
|
|
var KFGUI_Base ParentComponent; // Parent component if any.
|
|
|
|
var transient Canvas Canvas;
|
|
|
|
|
|
|
|
enum EMenuSound
|
|
|
|
{
|
|
|
|
MN_Focus,
|
|
|
|
MN_LostFocus,
|
|
|
|
MN_ClickButton,
|
|
|
|
MN_ClickCheckboxOn,
|
|
|
|
MN_ClickCheckboxOff,
|
|
|
|
MN_Dropdown,
|
|
|
|
MN_DropdownChange,
|
|
|
|
};
|
|
|
|
|
|
|
|
var() float XPosition,YPosition,XSize,YSize;
|
|
|
|
var() name ID; // Just for internal purposes, you can give the components unique ID values.
|
|
|
|
var() int IDValue; // Integer ID value.
|
|
|
|
var transient float CompPos[4],InputPos[4];
|
|
|
|
var float TimerRate,TimerCounter;
|
|
|
|
|
2020-06-26 04:17:32 +00:00
|
|
|
var localized string Caption;
|
|
|
|
var localized string Hint;
|
|
|
|
|
2017-10-20 02:00:49 +00:00
|
|
|
var transient KFGUI_Base MouseArea; // Next in recurse line of the mouse pointer focus area.
|
|
|
|
|
|
|
|
var() bool bDisabled,bClickable,bCanFocus;
|
|
|
|
var bool bFocusedPostDrawItem; // If this component has been given input focus, should it receive draw menu call after everything else been drawn?
|
|
|
|
var bool bTimerActive,bLoopTimer;
|
|
|
|
var transient bool bFocused;
|
|
|
|
|
|
|
|
function InitMenu(); // Menu was initialized for the first time.
|
|
|
|
function ShowMenu(); // Menu was opened.
|
|
|
|
function PreDraw()
|
|
|
|
{
|
|
|
|
ComputeCoords();
|
|
|
|
Canvas.SetDrawColor(255,255,255);
|
|
|
|
Canvas.SetOrigin(CompPos[0],CompPos[1]);
|
|
|
|
Canvas.SetClip(CompPos[0]+CompPos[2],CompPos[1]+CompPos[3]);
|
|
|
|
DrawMenu();
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2017-10-20 02:00:49 +00:00
|
|
|
function DrawMenu(); // Draw menu now.
|
|
|
|
function CloseMenu(); // Menu was closed.
|
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
function MenuTick(float DeltaTime)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
if (bTimerActive && (TimerCounter-=DeltaTime)<=0.f)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
if (bLoopTimer)
|
2017-10-20 02:00:49 +00:00
|
|
|
TimerCounter = TimerRate;
|
|
|
|
else bTimerActive = false;
|
|
|
|
Timer();
|
|
|
|
}
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
final function SetTimer(float Rate, optional bool bLoop)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
bTimerActive = (Rate>0.f);
|
2020-11-28 20:12:58 +00:00
|
|
|
if (bTimerActive)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
bLoopTimer = bLoop;
|
|
|
|
TimerRate = Rate;
|
|
|
|
TimerCounter = Rate;
|
|
|
|
}
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2017-10-20 02:00:49 +00:00
|
|
|
function Timer();
|
|
|
|
|
|
|
|
function MouseEnter()
|
|
|
|
{
|
|
|
|
bFocused = true;
|
|
|
|
OnFocus(Self,True);
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2017-10-20 02:00:49 +00:00
|
|
|
function MouseLeave()
|
|
|
|
{
|
|
|
|
bFocused = false;
|
|
|
|
OnFocus(Self,False);
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
function MouseClick(bool bRight);
|
|
|
|
function MouseRelease(bool bRight);
|
|
|
|
function DoubleMouseClick(bool bRight) // User rapidly double clicked this component.
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
MouseClick(bRight);
|
|
|
|
}
|
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
function ScrollMouseWheel(bool bUp);
|
2017-10-20 02:00:49 +00:00
|
|
|
|
|
|
|
final function PlayerController GetPlayer()
|
|
|
|
{
|
|
|
|
return Owner.PlayerOwner;
|
|
|
|
}
|
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
function SetDisabled(bool bDisable)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
bDisabled = bDisable;
|
|
|
|
}
|
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
Delegate OnFocus(KFGUI_Base Sender, bool bBecame);
|
2017-10-20 02:00:49 +00:00
|
|
|
|
|
|
|
final function ComputeCoords()
|
|
|
|
{
|
|
|
|
CompPos[0] = XPosition*InputPos[2]+InputPos[0];
|
|
|
|
CompPos[1] = YPosition*InputPos[3]+InputPos[1];
|
|
|
|
CompPos[2] = XSize*InputPos[2];
|
|
|
|
CompPos[3] = YSize*InputPos[3];
|
|
|
|
}
|
|
|
|
|
|
|
|
function bool CaptureMouse()
|
|
|
|
{
|
2020-11-28 20:04:55 +00:00
|
|
|
return (Owner.MousePosition.X>=CompPos[0] && Owner.MousePosition.Y>=CompPos[1] && Owner.MousePosition.X<=(CompPos[0]+CompPos[2]) && Owner.MousePosition.Y<=(CompPos[1]+CompPos[3]));
|
2017-10-20 02:00:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
final function KFGUI_Base GetMouseFocus()
|
|
|
|
{
|
|
|
|
local KFGUI_Base M;
|
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
for (M=Self; M.MouseArea!=None; M=M.MouseArea)
|
2017-10-20 02:00:49 +00:00
|
|
|
{}
|
|
|
|
return M;
|
|
|
|
}
|
|
|
|
|
|
|
|
function DoClose()
|
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
if (ParentComponent!=None)
|
2017-10-20 02:00:49 +00:00
|
|
|
ParentComponent.DoClose();
|
|
|
|
else Owner.PopCloseMenu(Self);
|
|
|
|
}
|
|
|
|
|
|
|
|
function byte GetCursorStyle()
|
|
|
|
{
|
|
|
|
return (bClickable ? 1 : 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
function UserPressedEsc() // user pressed escape while this menu was active.
|
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
if (ParentComponent!=None)
|
2017-10-20 02:00:49 +00:00
|
|
|
ParentComponent.UserPressedEsc();
|
|
|
|
else DoClose();
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2017-10-20 02:00:49 +00:00
|
|
|
function bool BringPageToFront()
|
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
if (ParentComponent!=None)
|
2017-10-20 02:00:49 +00:00
|
|
|
return ParentComponent.BringPageToFront();
|
|
|
|
return true; // Allow user to bring this page to front.
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2017-10-20 02:00:49 +00:00
|
|
|
final function bool IsTopMenu()
|
|
|
|
{
|
|
|
|
return (Owner.ActiveMenus.Length>0 && GetPageTop()==Owner.ActiveMenus[0]);
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2017-10-20 02:00:49 +00:00
|
|
|
final function KFGUI_Page GetPageTop()
|
|
|
|
{
|
|
|
|
local KFGUI_Base M;
|
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
for (M=Self; M.ParentComponent!=None; M=M.ParentComponent)
|
2017-10-20 02:00:49 +00:00
|
|
|
{}
|
|
|
|
return KFGUI_Page(M);
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
function KFGUI_Base FindComponentID(name InID)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
if (ID==InID)
|
2017-10-20 02:00:49 +00:00
|
|
|
return Self;
|
|
|
|
return None;
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
function FindAllComponentID(name InID, out array<KFGUI_Base> Res)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
if (ID==InID)
|
2017-10-20 02:00:49 +00:00
|
|
|
Res[Res.Length] = Self;
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
function RemoveComponent(KFGUI_Base B);
|
2017-10-20 02:00:49 +00:00
|
|
|
|
|
|
|
function GetInputFocus()
|
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
if (Owner.InputFocus!=None)
|
2017-10-20 02:00:49 +00:00
|
|
|
Owner.InputFocus.LostInputFocus();
|
|
|
|
Owner.InputFocus = Self;
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2017-10-20 02:00:49 +00:00
|
|
|
function DropInputFocus()
|
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
if (Owner.InputFocus==Self)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
Owner.InputFocus.LostInputFocus();
|
|
|
|
Owner.InputFocus = None;
|
|
|
|
}
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2017-10-20 02:00:49 +00:00
|
|
|
function LostInputFocus();
|
|
|
|
|
|
|
|
// Obtain keyboard focus.
|
|
|
|
final function GrabKeyFocus()
|
|
|
|
{
|
|
|
|
Owner.GrabInputFocus(Self);
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2017-10-20 02:00:49 +00:00
|
|
|
final function ReleaseKeyFocus()
|
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
if (Owner.KeyboardFocus==Self)
|
2017-10-20 02:00:49 +00:00
|
|
|
Owner.GrabInputFocus(None);
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2017-10-20 02:00:49 +00:00
|
|
|
function LostKeyFocus();
|
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
function bool NotifyInputKey(int ControllerId, name Key, EInputEvent Event, float AmountDepressed, bool bGamepad)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
function bool NotifyInputChar(int ControllerId, string Unicode)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// While on input focus mode, notify that mouse just moved over the threshold.
|
|
|
|
function InputMouseMoved();
|
|
|
|
|
|
|
|
// Notify any focused menu element that mouse has been idle over it.
|
|
|
|
function NotifyMousePaused();
|
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
final function GetActualPos(out float X, out float Y)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
X = ((XPosition+X)*InputPos[2]) + InputPos[0];
|
|
|
|
Y = ((YPosition+Y)*InputPos[3]) + InputPos[1];
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
final function GetRealtivePos(out float X, out float Y)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
X = X / CompPos[2];
|
|
|
|
Y = Y / CompPos[2];
|
|
|
|
}
|
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
simulated final function PlayMenuSound(EMenuSound Slot)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
/*local SoundCue S;
|
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
switch (Slot)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
case MN_Focus:
|
|
|
|
S = SoundCue'a_interface.menu.UT3MenuMouseOverCue';
|
|
|
|
break;
|
|
|
|
case MN_LostFocus:
|
|
|
|
S = SoundCue'a_interface.menu.UT3MenuNavigateDownCue';
|
|
|
|
break;
|
|
|
|
case MN_ClickButton:
|
|
|
|
S = SoundCue'a_interface.menu.UT3MenuSliderBarMoveCue';
|
|
|
|
break;
|
|
|
|
case MN_ClickCheckboxOn:
|
|
|
|
S = SoundCue'a_interface.menu.UT3MenuCheckboxSelectCue';
|
|
|
|
break;
|
|
|
|
case MN_ClickCheckboxOff:
|
|
|
|
S = SoundCue'a_interface.menu.UT3MenuCheckboxDeselectCue';
|
|
|
|
break;
|
|
|
|
case MN_Dropdown:
|
|
|
|
S = SoundCue'a_interface.menu.UT3MenuScreenSlideCue';
|
|
|
|
break;
|
|
|
|
case MN_DropdownChange:
|
|
|
|
S = SoundCue'a_interface.menu.UT3MenuNavigateUpCue';
|
|
|
|
break;
|
|
|
|
}
|
2020-11-28 20:12:58 +00:00
|
|
|
if (S!=None)
|
2017-10-20 02:00:49 +00:00
|
|
|
GetPlayer().PlaySound(S,true,,false);*/
|
|
|
|
}
|
|
|
|
|
|
|
|
// Pre level change notification.
|
|
|
|
function NotifyLevelChange();
|
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
final function SetPosition(float X, float Y, float XS, float YS)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
XPosition = X;
|
|
|
|
YPosition = Y;
|
|
|
|
XSize = XS;
|
|
|
|
YSize = YS;
|
|
|
|
}
|
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
static final function string MakeSortStr(int Value)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
local string S;
|
|
|
|
local int i;
|
|
|
|
|
|
|
|
// Prefix with zeroes to properly sort this string.
|
|
|
|
S = string(Value);
|
|
|
|
i = Len(S);
|
2020-11-28 20:12:58 +00:00
|
|
|
if (i<10)
|
2017-10-20 02:00:49 +00:00
|
|
|
return Mid("0000000000",i)$S;
|
|
|
|
return S;
|
|
|
|
}
|
|
|
|
|
|
|
|
defaultproperties
|
|
|
|
{
|
|
|
|
XSize=1
|
|
|
|
YSize=1
|
|
|
|
bCanFocus=true
|
|
|
|
}
|