2022-09-03 17:26:40 +00:00
|
|
|
class KF2GUIController extends Info
|
2021-05-16 09:40:02 +00:00
|
|
|
transient;
|
2020-01-10 13:14:11 +00:00
|
|
|
|
2021-06-13 03:17:40 +00:00
|
|
|
var() class<GUIStyleBase> DefaultStyle;
|
2020-01-10 13:14:11 +00:00
|
|
|
|
|
|
|
var PlayerController PlayerOwner;
|
2022-09-03 17:26:40 +00:00
|
|
|
var YAS_HUD HUDOwner;
|
2020-01-10 13:14:11 +00:00
|
|
|
var transient KF2GUIInput CustomInput;
|
|
|
|
var transient PlayerInput BackupInput;
|
|
|
|
var transient GameViewportClient ClientViewport;
|
|
|
|
|
2021-06-13 03:17:40 +00:00
|
|
|
var delegate<Interaction.OnReceivedNativeInputKey> OldOnReceivedNativeInputKey;
|
|
|
|
var delegate<Interaction.OnReceivedNativeInputAxis> OldOnReceivedNativeInputAxis;
|
|
|
|
var delegate<Interaction.OnReceivedNativeInputChar> OldOnReceivedNativeInputChar;
|
2020-01-10 13:14:11 +00:00
|
|
|
|
2021-06-13 03:17:40 +00:00
|
|
|
var delegate<GameViewportClient.HandleInputAxis> OldHandleInputAxis;
|
2020-01-10 13:14:11 +00:00
|
|
|
|
2021-06-13 03:17:40 +00:00
|
|
|
var array<KFGUI_Page> ActiveMenus, PersistentMenus;
|
2021-06-13 02:54:35 +00:00
|
|
|
var transient KFGUI_Base MouseFocus, InputFocus, KeyboardFocus;
|
|
|
|
var IntPoint MousePosition, ScreenSize, OldMousePos, LastMousePos, LastClickPos[2];
|
|
|
|
var transient float MousePauseTime, MenuTime, LastClickTimes[2];
|
2020-01-10 13:14:11 +00:00
|
|
|
var transient GUIStyleBase CurrentStyle;
|
|
|
|
|
|
|
|
var transient Console OrgConsole;
|
|
|
|
var transient KFGUIConsoleHack HackConsole;
|
|
|
|
|
2021-06-13 03:17:40 +00:00
|
|
|
var array<Texture2D> CursorTextures;
|
2020-01-10 13:14:11 +00:00
|
|
|
var Color CursorColor;
|
|
|
|
var int CurrentCursorIndex, CursorSize;
|
|
|
|
|
|
|
|
var Texture DefaultPens[3];
|
|
|
|
var byte CursorFade, FastCursorFade, CursorFlash;
|
|
|
|
var int CursorStep, FastCursorStep;
|
2021-06-13 02:54:35 +00:00
|
|
|
var int FontBlurX, FontBlurX2, FontBlurY, FontBlurY2, FastFontBlurX, FastFontBlurX2, FastFontBlurY, FastFontBlurY2;
|
2020-01-10 13:14:11 +00:00
|
|
|
|
2021-06-13 02:54:35 +00:00
|
|
|
var bool bMouseWasIdle, bIsInMenuState, bAbsorbInput, bIsInvalid, bHideCursor, bUsingGamepad, bForceEngineCursor, bNoInputReset;
|
2020-01-10 13:14:11 +00:00
|
|
|
|
2021-06-13 03:00:19 +00:00
|
|
|
static function KF2GUIController GetGUIController(PlayerController PC)
|
2020-01-10 13:14:11 +00:00
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local KF2GUIController G;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (PC.Player == None)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
return None;
|
|
|
|
}
|
|
|
|
|
2021-06-20 05:04:22 +00:00
|
|
|
foreach PC.ChildActors(class'YAS.KF2GUIController', G)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
if (!G.bIsInvalid)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (G == None)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
2021-06-20 05:04:22 +00:00
|
|
|
G = PC.Spawn(class'YAS.KF2GUIController', PC);
|
2021-05-16 09:40:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return G;
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
simulated function PostBeginPlay()
|
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
PlayerOwner = PlayerController(Owner);
|
|
|
|
ClientViewport = LocalPlayer(PlayerOwner.Player).ViewportClient;
|
2022-09-03 17:26:40 +00:00
|
|
|
HUDOwner = YAS_HUD(PlayerOwner.myHUD);
|
2021-05-16 09:40:02 +00:00
|
|
|
|
|
|
|
CurrentStyle = new (None) DefaultStyle;
|
|
|
|
CurrentStyle.InitStyle();
|
|
|
|
CurrentStyle.Owner = self;
|
|
|
|
|
|
|
|
SetTimer(0.1, true, 'SetupFontBlur');
|
|
|
|
SetTimer(0.05, true, 'SetupFastFontBlur');
|
|
|
|
|
|
|
|
SetTimer(0.75, true, 'SetupCursorFlash');
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
simulated function SetupCursorFlash()
|
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
if (CursorFlash == 255)
|
2021-05-16 09:40:02 +00:00
|
|
|
CursorFlash = 0;
|
|
|
|
else CursorFlash = 255;
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
simulated function SetupFastFontBlur()
|
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
FastFontBlurX = RandRange(-8, 8);
|
|
|
|
FastFontBlurX2 = RandRange(-8, 8);
|
|
|
|
FastFontBlurY = RandRange(-8, 8);
|
|
|
|
FastFontBlurY2 = RandRange(-8, 8);
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
simulated function SetupFontBlur()
|
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
FontBlurX = RandRange(-8, 8);
|
|
|
|
FontBlurX2 = RandRange(-8, 8);
|
|
|
|
FontBlurY = RandRange(-8, 8);
|
|
|
|
FontBlurY2 = RandRange(-8, 8);
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
simulated function Tick(float DT)
|
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
Super.Tick(DT);
|
|
|
|
|
|
|
|
DT /= WorldInfo.TimeDilation;
|
|
|
|
|
|
|
|
CursorFade += 255 * DT * CursorStep;
|
2021-06-13 02:53:33 +00:00
|
|
|
if (CursorFade <= 0)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
CursorFade = 0;
|
|
|
|
CursorStep = 1;
|
|
|
|
}
|
2021-06-13 02:53:33 +00:00
|
|
|
else if (CursorFade >= 255)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
CursorFade = 255;
|
|
|
|
CursorStep = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
FastCursorFade += 8192 * DT * FastCursorStep;
|
2021-06-13 02:53:33 +00:00
|
|
|
if (FastCursorFade <= 0)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
FastCursorFade = 0;
|
|
|
|
FastCursorStep = 1;
|
|
|
|
}
|
2021-06-13 02:53:33 +00:00
|
|
|
else if (FastCursorFade >= 255)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
FastCursorFade = 255;
|
|
|
|
FastCursorStep = -1;
|
|
|
|
}
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
simulated function Destroyed()
|
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
if (PlayerOwner != None)
|
2021-05-16 09:40:02 +00:00
|
|
|
SetMenuState(false);
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
simulated function HandleDrawMenu()
|
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
if (HackConsole == None)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
2021-06-20 05:04:22 +00:00
|
|
|
HackConsole = new(ClientViewport)class'YAS.KFGUIConsoleHack';
|
2021-05-16 09:40:02 +00:00
|
|
|
HackConsole.OutputObject = Self;
|
|
|
|
}
|
2021-06-13 02:53:33 +00:00
|
|
|
if (HackConsole != ClientViewport.ViewportConsole)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
OrgConsole = ClientViewport.ViewportConsole;
|
|
|
|
ClientViewport.ViewportConsole = HackConsole;
|
|
|
|
|
|
|
|
// Make sure nothing overrides these settings while menu is being open.
|
2021-06-13 02:53:33 +00:00
|
|
|
if (bIsInMenuState ) PlayerOwner.PlayerInput = CustomInput;
|
2021-05-16 09:40:02 +00:00
|
|
|
}
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
2021-06-13 03:00:19 +00:00
|
|
|
simulated function RenderMenu(Canvas C)
|
2020-01-10 13:14:11 +00:00
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local int i;
|
2021-06-13 02:54:35 +00:00
|
|
|
local float OrgX, OrgY, ClipX, ClipY;
|
2021-05-16 09:40:02 +00:00
|
|
|
|
|
|
|
ClientViewport.ViewportConsole = OrgConsole;
|
|
|
|
|
|
|
|
OrgX = C.OrgX;
|
|
|
|
OrgY = C.OrgY;
|
|
|
|
ClipX = C.ClipX;
|
|
|
|
ClipY = C.ClipY;
|
|
|
|
|
|
|
|
ScreenSize.X = C.SizeX;
|
|
|
|
ScreenSize.Y = C.SizeY;
|
|
|
|
CurrentStyle.Canvas = C;
|
|
|
|
CurrentStyle.PickDefaultFontSize(C.SizeY);
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (!KFPlayerController(PlayerOwner).MyGFxManager.bMenusActive)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
HUDOwner.Canvas = C;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
for (i=(HUDOwner.HUDWidgets.Length-1); i >= 0; --i)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
HUDOwner.HUDWidgets[i].InputPos[0] = 0.f;
|
|
|
|
HUDOwner.HUDWidgets[i].InputPos[1] = 0.f;
|
|
|
|
HUDOwner.HUDWidgets[i].InputPos[2] = ScreenSize.X;
|
|
|
|
HUDOwner.HUDWidgets[i].InputPos[3] = ScreenSize.Y;
|
|
|
|
HUDOwner.HUDWidgets[i].Canvas = C;
|
|
|
|
HUDOwner.HUDWidgets[i].PreDraw();
|
|
|
|
}
|
|
|
|
|
2021-06-13 02:54:35 +00:00
|
|
|
C.SetOrigin(OrgX, OrgY);
|
|
|
|
C.SetClip(ClipX, ClipY);
|
2021-05-16 09:40:02 +00:00
|
|
|
}
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (bIsInMenuState)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
for (i=(ActiveMenus.Length-1); i >= 0; --i)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
ActiveMenus[i].bWindowFocused = (i == 0);
|
2021-05-16 09:40:02 +00:00
|
|
|
ActiveMenus[i].InputPos[0] = 0.f;
|
|
|
|
ActiveMenus[i].InputPos[1] = 0.f;
|
|
|
|
ActiveMenus[i].InputPos[2] = ScreenSize.X;
|
|
|
|
ActiveMenus[i].InputPos[3] = ScreenSize.Y;
|
|
|
|
ActiveMenus[i].Canvas = C;
|
|
|
|
ActiveMenus[i].PreDraw();
|
|
|
|
}
|
2021-06-13 02:53:33 +00:00
|
|
|
if (InputFocus != None && InputFocus.bFocusedPostDrawItem)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
InputFocus.InputPos[0] = 0.f;
|
|
|
|
InputFocus.InputPos[1] = 0.f;
|
|
|
|
InputFocus.InputPos[2] = ScreenSize.X;
|
|
|
|
InputFocus.InputPos[3] = ScreenSize.Y;
|
|
|
|
InputFocus.Canvas = C;
|
|
|
|
InputFocus.PreDraw();
|
|
|
|
}
|
2021-06-13 02:54:35 +00:00
|
|
|
C.SetOrigin(OrgX, OrgY);
|
|
|
|
C.SetClip(ClipX, ClipY);
|
2021-05-16 09:40:02 +00:00
|
|
|
|
|
|
|
if (!bHideCursor)
|
|
|
|
{
|
|
|
|
DrawCursor(C, MousePosition.X, MousePosition.Y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (OrgConsole != None)
|
2021-05-16 09:40:02 +00:00
|
|
|
OrgConsole.PostRender_Console(C);
|
|
|
|
OrgConsole = None;
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
simulated function DrawCursor(Canvas C, float PosX, float PosY)
|
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
C.SetPos(PosX, PosY);
|
|
|
|
C.DrawColor = CursorColor;
|
2021-06-13 02:54:35 +00:00
|
|
|
C.DrawTile(CursorTextures[CurrentCursorIndex], CurrentStyle.ScreenScale(CursorSize), CurrentStyle.ScreenScale(CursorSize), 0.f, 0.f, CursorTextures[CurrentCursorIndex].SizeX, CursorTextures[CurrentCursorIndex].SizeY, , true);
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
simulated final function InventoryChanged(optional KFWeapon Wep, optional bool bRemove)
|
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local int i;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
for (i=(ActiveMenus.Length-1); i >= 0; --i)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
2021-06-13 02:54:35 +00:00
|
|
|
ActiveMenus[i].InventoryChanged(Wep, bRemove);
|
2021-05-16 09:40:02 +00:00
|
|
|
}
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
|
2021-06-13 03:00:19 +00:00
|
|
|
simulated final function SetMenuState(bool bActive)
|
2020-01-10 13:14:11 +00:00
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
if (PlayerOwner.PlayerInput == None)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
NotifyLevelChange();
|
|
|
|
bActive = false;
|
|
|
|
}
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (bIsInMenuState == bActive)
|
2021-05-16 09:40:02 +00:00
|
|
|
return;
|
|
|
|
bIsInMenuState = bActive;
|
|
|
|
bHideCursor = !bActive;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (bActive)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
if (CustomInput == None)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
2021-06-20 05:04:22 +00:00
|
|
|
CustomInput = new (KFPlayerController(PlayerOwner)) class'YAS.KF2GUIInput';
|
2021-05-16 09:40:02 +00:00
|
|
|
CustomInput.ControllerOwner = Self;
|
|
|
|
CustomInput.OnReceivedNativeInputKey = ReceivedInputKey;
|
|
|
|
CustomInput.BaseInput = PlayerOwner.PlayerInput;
|
|
|
|
BackupInput = PlayerOwner.PlayerInput;
|
|
|
|
PlayerOwner.Interactions.AddItem(CustomInput);
|
|
|
|
}
|
|
|
|
|
|
|
|
OldOnReceivedNativeInputKey = BackupInput.OnReceivedNativeInputKey;
|
|
|
|
OldOnReceivedNativeInputAxis = BackupInput.OnReceivedNativeInputAxis;
|
|
|
|
OldOnReceivedNativeInputChar = BackupInput.OnReceivedNativeInputChar;
|
|
|
|
|
|
|
|
BackupInput.OnReceivedNativeInputKey = ReceivedInputKey;
|
|
|
|
BackupInput.OnReceivedNativeInputAxis = ReceivedInputAxis;
|
|
|
|
BackupInput.OnReceivedNativeInputChar = ReceivedInputChar;
|
|
|
|
|
|
|
|
OldHandleInputAxis = ClientViewport.HandleInputAxis;
|
|
|
|
ClientViewport.HandleInputAxis = ReceivedInputAxis;
|
|
|
|
|
|
|
|
PlayerOwner.PlayerInput = CustomInput;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (LastMousePos != default.LastMousePos)
|
2021-06-13 02:54:35 +00:00
|
|
|
ClientViewport.SetMouse(LastMousePos.X, LastMousePos.Y);
|
2021-05-16 09:40:02 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LastMousePos = MousePosition;
|
|
|
|
|
|
|
|
ClientViewport.HandleInputAxis = None;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (BackupInput != None)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
PlayerOwner.PlayerInput = BackupInput;
|
|
|
|
BackupInput.OnReceivedNativeInputKey = OldOnReceivedNativeInputKey;
|
|
|
|
BackupInput.OnReceivedNativeInputAxis = OldOnReceivedNativeInputAxis;
|
|
|
|
BackupInput.OnReceivedNativeInputChar = OldOnReceivedNativeInputChar;
|
|
|
|
|
|
|
|
ClientViewport.HandleInputAxis = OldHandleInputAxis;
|
|
|
|
}
|
|
|
|
LastClickTimes[0] = 0;
|
|
|
|
LastClickTimes[1] = 0;
|
|
|
|
}
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (!bNoInputReset)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
PlayerOwner.PlayerInput.ResetInput();
|
|
|
|
}
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
simulated function NotifyLevelChange()
|
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local int i;
|
2020-01-10 13:14:11 +00:00
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (bIsInvalid)
|
2021-05-16 09:40:02 +00:00
|
|
|
return;
|
|
|
|
bIsInvalid = true;
|
2020-01-10 13:14:11 +00:00
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (InputFocus != None)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
InputFocus.LostInputFocus();
|
|
|
|
InputFocus = None;
|
|
|
|
}
|
2020-01-10 13:14:11 +00:00
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
for (i=(ActiveMenus.Length-1); i >= 0; --i)
|
2021-05-16 09:40:02 +00:00
|
|
|
ActiveMenus[i].NotifyLevelChange();
|
2021-06-13 02:53:33 +00:00
|
|
|
for (i=(PersistentMenus.Length-1); i >= 0; --i)
|
2021-05-16 09:40:02 +00:00
|
|
|
PersistentMenus[i].NotifyLevelChange();
|
2020-01-10 13:14:11 +00:00
|
|
|
|
2021-05-16 09:40:02 +00:00
|
|
|
SetMenuState(false);
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
simulated function MenuInput(float DeltaTime)
|
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local int i;
|
|
|
|
local vector2D V;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (PlayerOwner.PlayerInput == None)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
NotifyLevelChange();
|
|
|
|
return;
|
|
|
|
}
|
2021-06-13 02:53:33 +00:00
|
|
|
if (InputFocus != None)
|
2021-05-16 09:40:02 +00:00
|
|
|
InputFocus.MenuTick(DeltaTime);
|
2021-06-13 02:53:33 +00:00
|
|
|
for (i=0; i < ActiveMenus.Length; ++i)
|
2021-05-16 09:40:02 +00:00
|
|
|
ActiveMenus[i].MenuTick(DeltaTime);
|
|
|
|
|
|
|
|
// Check idle.
|
2021-06-13 02:53:33 +00:00
|
|
|
if (Abs(MousePosition.X-OldMousePos.X) > 5.f || Abs(MousePosition.Y-OldMousePos.Y) > 5.f || (bMouseWasIdle && MousePauseTime < 0.5f))
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
if (bMouseWasIdle)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
bMouseWasIdle = false;
|
2021-06-13 02:53:33 +00:00
|
|
|
if (InputFocus != None)
|
2021-05-16 09:40:02 +00:00
|
|
|
InputFocus.InputMouseMoved();
|
|
|
|
}
|
|
|
|
OldMousePos = MousePosition;
|
|
|
|
MousePauseTime = 0.f;
|
|
|
|
}
|
2021-06-13 02:53:33 +00:00
|
|
|
else if (!bMouseWasIdle && (MousePauseTime+=DeltaTime) > 0.5f)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
bMouseWasIdle = true;
|
2021-06-13 02:53:33 +00:00
|
|
|
if (MouseFocus != None)
|
2021-05-16 09:40:02 +00:00
|
|
|
MouseFocus.NotifyMousePaused();
|
|
|
|
}
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (ActiveMenus.Length > 0)
|
2021-05-16 09:40:02 +00:00
|
|
|
MenuTime+=DeltaTime;
|
|
|
|
|
|
|
|
V = ClientViewport.GetMousePosition();
|
|
|
|
|
|
|
|
MousePosition.X = Clamp(V.X, 0, ScreenSize.X);
|
|
|
|
MousePosition.Y = Clamp(V.Y, 0, ScreenSize.Y);
|
|
|
|
|
|
|
|
MouseMove();
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
simulated function MouseMove()
|
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local int i;
|
|
|
|
local KFGUI_Base F;
|
|
|
|
|
|
|
|
// Capture mouse for GUI
|
2021-06-13 02:53:33 +00:00
|
|
|
if (InputFocus != None && InputFocus.bCanFocus)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
if (InputFocus.CaptureMouse())
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
F = InputFocus.GetMouseFocus();
|
2021-06-13 02:53:33 +00:00
|
|
|
if (F != MouseFocus)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
MousePauseTime = 0;
|
2021-06-13 02:53:33 +00:00
|
|
|
if (MouseFocus != None)
|
2021-05-16 09:40:02 +00:00
|
|
|
MouseFocus.MouseLeave();
|
|
|
|
MouseFocus = F;
|
|
|
|
F.MouseEnter();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else i = ActiveMenus.Length;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
for (i=0; i < ActiveMenus.Length; ++i)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
if (ActiveMenus[i].CaptureMouse())
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
F = ActiveMenus[i].GetMouseFocus();
|
2021-06-13 02:53:33 +00:00
|
|
|
if (F != MouseFocus)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
MousePauseTime = 0;
|
2021-06-13 02:53:33 +00:00
|
|
|
if (MouseFocus != None)
|
2021-05-16 09:40:02 +00:00
|
|
|
MouseFocus.MouseLeave();
|
|
|
|
MouseFocus = F;
|
|
|
|
F.MouseEnter();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2021-06-13 02:53:33 +00:00
|
|
|
else if (ActiveMenus[i].bOnlyThisFocus ) // Discard any other menus after this one.
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
i = ActiveMenus.Length;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-06-13 02:53:33 +00:00
|
|
|
if (MouseFocus != None && i == ActiveMenus.Length ) // Hovering over nothing.
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
MousePauseTime = 0;
|
2021-06-13 02:53:33 +00:00
|
|
|
if (MouseFocus != None)
|
2021-05-16 09:40:02 +00:00
|
|
|
MouseFocus.MouseLeave();
|
|
|
|
MouseFocus = None;
|
|
|
|
}
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
|
2021-06-13 03:00:19 +00:00
|
|
|
simulated final function int GetFreeIndex(bool bNewAlwaysTop ) // Find first allowed top index of the stack.
|
2020-01-10 13:14:11 +00:00
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local int i;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
for (i=0; i < ActiveMenus.Length; ++i)
|
|
|
|
if (bNewAlwaysTop || !ActiveMenus[i].bAlwaysTop)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
2021-06-13 02:54:35 +00:00
|
|
|
ActiveMenus.Insert(i, 1);
|
2021-05-16 09:40:02 +00:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
i = ActiveMenus.Length;
|
|
|
|
ActiveMenus.Length = i+1;
|
|
|
|
return i;
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
2021-06-13 07:29:12 +00:00
|
|
|
simulated function KFGUI_Base InitializeHUDWidget(class<KFGUI_Base> GUIClass)
|
2020-01-10 13:14:11 +00:00
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local KFGUI_Base Widget;
|
|
|
|
|
2022-09-03 17:26:40 +00:00
|
|
|
if (GUIclass == None)
|
2021-05-16 09:40:02 +00:00
|
|
|
return None;
|
|
|
|
|
|
|
|
Widget = New(None) GUIClass;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (Widget == None)
|
2021-05-16 09:40:02 +00:00
|
|
|
return None;
|
|
|
|
|
|
|
|
HUDOwner.HUDWidgets.AddItem(Widget);
|
|
|
|
|
|
|
|
Widget.Owner = Self;
|
|
|
|
Widget.HUDOwner = HUDOwner;
|
|
|
|
Widget.InitMenu();
|
|
|
|
Widget.ShowMenu();
|
|
|
|
Widget.bIsHUDWidget = true;
|
|
|
|
|
|
|
|
return Widget;
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
2021-06-13 07:29:12 +00:00
|
|
|
simulated function KFGUI_Page OpenMenu(class<KFGUI_Page> MenuClass)
|
2020-01-10 13:14:11 +00:00
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local int i;
|
|
|
|
local KFGUI_Page M;
|
|
|
|
|
2022-09-03 17:26:40 +00:00
|
|
|
if (Menuclass == None)
|
2021-05-16 09:40:02 +00:00
|
|
|
return None;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (KeyboardFocus != None)
|
2021-05-16 09:40:02 +00:00
|
|
|
GrabInputFocus(None);
|
2021-06-13 02:53:33 +00:00
|
|
|
if (InputFocus != None)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
InputFocus.LostInputFocus();
|
|
|
|
InputFocus = None;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Enable mouse on UI if disabled.
|
|
|
|
SetMenuState(true);
|
|
|
|
|
|
|
|
// Check if should use pre-excisting menu.
|
2021-06-13 02:53:33 +00:00
|
|
|
if (MenuClass.Default.bUnique)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
for (i=0; i < ActiveMenus.Length; ++i)
|
2022-09-03 17:26:40 +00:00
|
|
|
if (ActiveMenus[i].class == MenuClass)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
if (i > 0 && ActiveMenus[i].BringPageToFront() ) // Sort it upfront.
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
M = ActiveMenus[i];
|
2021-06-13 02:54:35 +00:00
|
|
|
ActiveMenus.Remove(i, 1);
|
2021-05-16 09:40:02 +00:00
|
|
|
i = GetFreeIndex(M.bAlwaysTop);
|
|
|
|
ActiveMenus[i] = M;
|
|
|
|
}
|
|
|
|
return M;
|
|
|
|
}
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (MenuClass.Default.bPersistant)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
for (i=0; i < PersistentMenus.Length; ++i)
|
2022-09-03 17:26:40 +00:00
|
|
|
if (PersistentMenus[i].class == MenuClass)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
M = PersistentMenus[i];
|
2021-06-13 02:54:35 +00:00
|
|
|
PersistentMenus.Remove(i, 1);
|
2021-05-16 09:40:02 +00:00
|
|
|
i = GetFreeIndex(M.bAlwaysTop);
|
|
|
|
ActiveMenus[i] = M;
|
|
|
|
M.ShowMenu();
|
|
|
|
return M;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
M = New(None)MenuClass;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (M == None ) // Probably abstract class.
|
2021-05-16 09:40:02 +00:00
|
|
|
return None;
|
|
|
|
|
|
|
|
i = GetFreeIndex(M.bAlwaysTop);
|
|
|
|
ActiveMenus[i] = M;
|
|
|
|
M.Owner = Self;
|
|
|
|
M.InitMenu();
|
|
|
|
M.ShowMenu();
|
|
|
|
return M;
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
2021-06-13 07:29:12 +00:00
|
|
|
simulated function CloseMenu(class<KFGUI_Page> MenuClass, optional bool bCloseAll)
|
2020-01-10 13:14:11 +00:00
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local int i, j;
|
|
|
|
local KFGUI_Page M;
|
|
|
|
|
2022-09-03 17:26:40 +00:00
|
|
|
if (!bCloseAll && Menuclass == None)
|
2021-05-16 09:40:02 +00:00
|
|
|
return;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (KeyboardFocus != None)
|
2021-05-16 09:40:02 +00:00
|
|
|
GrabInputFocus(None);
|
2021-06-13 02:53:33 +00:00
|
|
|
if (InputFocus != None)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
InputFocus.LostInputFocus();
|
|
|
|
InputFocus = None;
|
|
|
|
}
|
2021-06-13 02:53:33 +00:00
|
|
|
for (i=(ActiveMenus.Length-1); i >= 0; --i)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
2022-09-03 17:26:40 +00:00
|
|
|
if (bCloseAll || ActiveMenus[i].class == MenuClass)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
M = ActiveMenus[i];
|
2021-06-13 02:54:35 +00:00
|
|
|
ActiveMenus.Remove(i, 1);
|
2021-05-16 09:40:02 +00:00
|
|
|
M.CloseMenu();
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
for (j=0; j < M.TimerNames.Length; j++)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
M.ClearTimer(M.TimerNames[j]);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Cache menu.
|
2021-06-13 02:53:33 +00:00
|
|
|
if (M.bPersistant && M.bUnique)
|
2021-05-16 09:40:02 +00:00
|
|
|
PersistentMenus[PersistentMenus.Length] = M;
|
|
|
|
}
|
|
|
|
}
|
2021-06-13 02:53:33 +00:00
|
|
|
if (ActiveMenus.Length == 0)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
SetMenuState(false);
|
|
|
|
}
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
2021-06-13 03:00:19 +00:00
|
|
|
simulated function PopCloseMenu(KFGUI_Base Item)
|
2020-01-10 13:14:11 +00:00
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local int i;
|
|
|
|
local KFGUI_Page M;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (Item == None)
|
2021-05-16 09:40:02 +00:00
|
|
|
return;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (Item.bIsHUDWidget)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
HUDOwner.HUDWidgets.RemoveItem(Item);
|
|
|
|
Item.CloseMenu();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (KeyboardFocus != None)
|
2021-05-16 09:40:02 +00:00
|
|
|
GrabInputFocus(None);
|
2021-06-13 02:53:33 +00:00
|
|
|
if (InputFocus != None)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
InputFocus.LostInputFocus();
|
|
|
|
InputFocus = None;
|
|
|
|
}
|
2021-06-13 02:53:33 +00:00
|
|
|
for (i=(ActiveMenus.Length-1); i >= 0; --i)
|
|
|
|
if (ActiveMenus[i] == Item)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
M = ActiveMenus[i];
|
2021-06-13 02:54:35 +00:00
|
|
|
ActiveMenus.Remove(i, 1);
|
2021-05-16 09:40:02 +00:00
|
|
|
M.CloseMenu();
|
|
|
|
|
|
|
|
// Cache menu.
|
2021-06-13 02:53:33 +00:00
|
|
|
if (M.bPersistant && M.bUnique)
|
2021-05-16 09:40:02 +00:00
|
|
|
PersistentMenus[PersistentMenus.Length] = M;
|
|
|
|
break;
|
|
|
|
}
|
2021-06-13 02:53:33 +00:00
|
|
|
if (ActiveMenus.Length == 0)
|
2021-05-16 09:40:02 +00:00
|
|
|
SetMenuState(false);
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
2021-06-13 03:00:19 +00:00
|
|
|
simulated function BringMenuToFront(KFGUI_Page Page)
|
2020-01-10 13:14:11 +00:00
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local int i;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (ActiveMenus[0].bAlwaysTop && !Page.bAlwaysTop)
|
2021-05-16 09:40:02 +00:00
|
|
|
return; // Can't override this menu.
|
|
|
|
|
|
|
|
// Try to remove from current position at stack.
|
2021-06-13 02:53:33 +00:00
|
|
|
for (i=(ActiveMenus.Length-1); i >= 0; --i)
|
|
|
|
if (ActiveMenus[i] == Page)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
2021-06-13 02:54:35 +00:00
|
|
|
ActiveMenus.Remove(i, 1);
|
2021-05-16 09:40:02 +00:00
|
|
|
break;
|
|
|
|
}
|
2021-06-13 02:53:33 +00:00
|
|
|
if (i == -1)
|
2021-05-16 09:40:02 +00:00
|
|
|
return; // Page isn't open.
|
|
|
|
|
|
|
|
// Put on front of stack.
|
2021-06-13 02:54:35 +00:00
|
|
|
ActiveMenus.Insert(0, 1);
|
2021-05-16 09:40:02 +00:00
|
|
|
ActiveMenus[0] = Page;
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
2021-06-13 07:29:12 +00:00
|
|
|
simulated final function bool MenuIsOpen(optional class<KFGUI_Page> MenuClass)
|
2020-01-10 13:14:11 +00:00
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local int i;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
for (i=(ActiveMenus.Length-1); i >= 0; --i)
|
2022-09-03 17:26:40 +00:00
|
|
|
if (Menuclass == None || ActiveMenus[i].class == MenuClass)
|
2021-05-16 09:40:02 +00:00
|
|
|
return true;
|
|
|
|
return false;
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
2021-06-13 03:00:19 +00:00
|
|
|
simulated final function GrabInputFocus(KFGUI_Base Comp, optional bool bForce)
|
2020-01-10 13:14:11 +00:00
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
if (Comp == KeyboardFocus && !bForce)
|
2021-05-16 09:40:02 +00:00
|
|
|
return;
|
2020-01-10 13:14:11 +00:00
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (KeyboardFocus != None)
|
2021-05-16 09:40:02 +00:00
|
|
|
KeyboardFocus.LostKeyFocus();
|
2020-01-10 13:14:11 +00:00
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (Comp == None)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
OnInputKey = InternalInputKey;
|
|
|
|
OnReceivedInputChar = InternalReceivedInputChar;
|
|
|
|
}
|
2021-06-13 02:53:33 +00:00
|
|
|
else if (KeyboardFocus == None)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
OnInputKey = Comp.NotifyInputKey;
|
|
|
|
OnReceivedInputChar = Comp.NotifyInputChar;
|
|
|
|
OnReceivedInputAxis = Comp.NotifyInputAxis;
|
|
|
|
}
|
|
|
|
KeyboardFocus = Comp;
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
|
2021-06-13 03:00:19 +00:00
|
|
|
simulated final function GUI_InputMouse(bool bPressed, bool bRight)
|
2020-01-10 13:14:11 +00:00
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local byte i;
|
|
|
|
|
|
|
|
MousePauseTime = 0;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (bPressed)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
if (KeyboardFocus != None && KeyboardFocus != MouseFocus)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
GrabInputFocus(None);
|
|
|
|
LastClickTimes[0] = 0;
|
|
|
|
LastClickTimes[1] = 0;
|
|
|
|
}
|
2021-06-13 02:53:33 +00:00
|
|
|
if (MouseFocus != None)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
if (MouseFocus != InputFocus && !MouseFocus.bClickable && !MouseFocus.IsTopMenu() && MouseFocus.BringPageToFront())
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
BringMenuToFront(MouseFocus.GetPageTop());
|
|
|
|
LastClickTimes[0] = 0;
|
|
|
|
LastClickTimes[1] = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
i = byte(bRight);
|
2021-06-13 02:53:33 +00:00
|
|
|
if ((MenuTime-LastClickTimes[i]) < 0.2 && Abs(LastClickPos[i].X-MousePosition.X) < 5 && Abs(LastClickPos[i].Y-MousePosition.Y) < 5)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
LastClickTimes[i] = 0;
|
|
|
|
MouseFocus.DoubleMouseClick(bRight);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
MouseFocus.MouseClick(bRight);
|
|
|
|
LastClickTimes[i] = MenuTime;
|
|
|
|
LastClickPos[i] = MousePosition;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-06-13 02:53:33 +00:00
|
|
|
else if (InputFocus != None)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
InputFocus.LostInputFocus();
|
|
|
|
InputFocus = None;
|
|
|
|
LastClickTimes[0] = 0;
|
|
|
|
LastClickTimes[1] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
if (InputFocus != None)
|
2021-05-16 09:40:02 +00:00
|
|
|
InputFocus.MouseRelease(bRight);
|
2021-06-13 02:53:33 +00:00
|
|
|
else if (MouseFocus != None)
|
2021-05-16 09:40:02 +00:00
|
|
|
MouseFocus.MouseRelease(bRight);
|
|
|
|
}
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
2021-06-13 03:00:19 +00:00
|
|
|
simulated final function bool CheckMouse(name Key, EInputEvent Event)
|
2020-01-10 13:14:11 +00:00
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
if (Event == IE_Pressed)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
2021-06-13 03:00:19 +00:00
|
|
|
switch (Key)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
case 'XboxTypeS_A':
|
|
|
|
case 'LeftMouseButton':
|
2021-06-13 02:54:35 +00:00
|
|
|
GUI_InputMouse(true, false);
|
2021-05-16 09:40:02 +00:00
|
|
|
return true;
|
|
|
|
case 'XboxTypeS_B':
|
|
|
|
case 'RightMouseButton':
|
2021-06-13 02:54:35 +00:00
|
|
|
GUI_InputMouse(true, true);
|
2021-05-16 09:40:02 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2021-06-13 02:53:33 +00:00
|
|
|
else if (Event == IE_Released)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
2021-06-13 03:00:19 +00:00
|
|
|
switch (Key)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
case 'XboxTypeS_A':
|
|
|
|
case 'LeftMouseButton':
|
2021-06-13 02:54:35 +00:00
|
|
|
GUI_InputMouse(false, false);
|
2021-05-16 09:40:02 +00:00
|
|
|
return true;
|
|
|
|
case 'XboxTypeS_B':
|
|
|
|
case 'RightMouseButton':
|
2021-06-13 02:54:35 +00:00
|
|
|
GUI_InputMouse(false, true);
|
2021-05-16 09:40:02 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
2021-06-13 03:00:19 +00:00
|
|
|
simulated function bool ReceivedInputKey(int ControllerId, name Key, EInputEvent Event, optional float AmountDepressed=1.f, optional bool bGamepad)
|
2020-01-10 13:14:11 +00:00
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local KFPlayerInput KFInput;
|
|
|
|
local KeyBind BoundKey;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (!bIsInMenuState)
|
2021-05-16 09:40:02 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
bUsingGamepad = bGamepad;
|
|
|
|
|
|
|
|
KFInput = KFPlayerInput(BackupInput);
|
2021-06-13 02:53:33 +00:00
|
|
|
if (KFInput == None)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
KFInput = KFPlayerInput(PlayerOwner.PlayerInput);
|
|
|
|
}
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (KeyboardFocus == None)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
if (KFInput != None)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
KFInput.GetKeyBindFromCommand(BoundKey, "GBA_VoiceChat", false);
|
2021-06-13 02:53:33 +00:00
|
|
|
if (string(Key) ~= KFInput.GetBindDisplayName(BoundKey))
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
if (Event == IE_Pressed)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
KFInput.StartVoiceChat(true);
|
|
|
|
}
|
2021-06-13 02:53:33 +00:00
|
|
|
else if (Event == IE_Released)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
KFInput.StopVoiceChat();
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-13 02:54:35 +00:00
|
|
|
if (!CheckMouse(Key, Event) && !OnInputKey(ControllerId, Key, Event, AmountDepressed, bGamepad))
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
if (bGamepad)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
if (ActiveMenus[0].ReceievedControllerInput(ControllerId, Key, Event))
|
2021-05-16 09:40:02 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-06-13 03:00:19 +00:00
|
|
|
switch (Key)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
case 'XboxTypeS_Start':
|
|
|
|
case 'Escape':
|
2021-06-13 02:53:33 +00:00
|
|
|
if (Event == IE_Pressed)
|
2021-05-16 09:40:02 +00:00
|
|
|
ActiveMenus[0].UserPressedEsc(); // Pop top menu if possible. // IE_Released
|
|
|
|
return true;
|
|
|
|
case 'XboxTypeS_DPad_Up':
|
|
|
|
case 'XboxTypeS_DPad_Down':
|
|
|
|
case 'XboxTypeS_DPad_Left':
|
|
|
|
case 'XboxTypeS_DPad_Right':
|
|
|
|
case 'MouseScrollDown':
|
|
|
|
case 'MouseScrollUp':
|
2021-06-13 02:53:33 +00:00
|
|
|
if (Event == IE_Pressed && MouseFocus != None)
|
|
|
|
MouseFocus.ScrollMouseWheel(Key == 'MouseScrollUp' || Key == 'XboxTypeS_DPad_Up' || Key == 'XboxTypeS_DPad_Left');
|
2021-05-16 09:40:02 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return bAbsorbInput;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
2021-06-13 03:00:19 +00:00
|
|
|
simulated function bool ReceivedInputAxis(int ControllerId, name Key, float Delta, float DeltaTime, bool bGamepad)
|
2020-01-10 13:14:11 +00:00
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local Vector2D V;
|
|
|
|
local KFPlayerInput KFInput;
|
2021-06-13 02:54:35 +00:00
|
|
|
local float GamepadSensitivity, OldMouseX, OldMouseY, MoveDelta, MoveDeltaInvert;
|
2021-05-16 09:40:02 +00:00
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (!bIsInMenuState)
|
2021-05-16 09:40:02 +00:00
|
|
|
return false;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (bGamepad )
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
if (Abs(Delta) > 0.2f)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
bUsingGamepad = true;
|
|
|
|
|
|
|
|
V = ClientViewport.GetMousePosition();
|
|
|
|
OldMouseX = V.X;
|
|
|
|
OldMouseY = V.Y;
|
|
|
|
|
|
|
|
KFInput = KFPlayerInput(BackupInput);
|
|
|
|
GamepadSensitivity = KFInput.GamepadSensitivityScale * 10;
|
|
|
|
MoveDelta = Delta * (KFInput.bInvertController ? -GamepadSensitivity : GamepadSensitivity);
|
|
|
|
MoveDeltaInvert = Delta * (KFInput.bInvertController ? GamepadSensitivity : -GamepadSensitivity);
|
|
|
|
|
2021-06-13 03:00:19 +00:00
|
|
|
switch (Key)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
case 'XboxTypeS_LeftX':
|
|
|
|
case 'XboxTypeS_RightX':
|
2021-06-13 02:53:33 +00:00
|
|
|
if (Delta < 0)
|
2021-05-16 09:40:02 +00:00
|
|
|
V.X = Clamp(V.X - MoveDeltaInvert, 0, ScreenSize.X);
|
|
|
|
else V.X = Clamp(V.X + MoveDelta, 0, ScreenSize.X);
|
|
|
|
break;
|
|
|
|
case 'XboxTypeS_LeftY':
|
2021-06-13 02:53:33 +00:00
|
|
|
if (Delta < 0)
|
2021-05-16 09:40:02 +00:00
|
|
|
V.Y = Clamp(V.Y + MoveDeltaInvert, 0, ScreenSize.Y);
|
|
|
|
else V.Y = Clamp(V.Y - MoveDelta, 0, ScreenSize.Y);
|
|
|
|
break;
|
|
|
|
case 'XboxTypeS_RightY':
|
2021-06-13 02:53:33 +00:00
|
|
|
if (Delta < 0)
|
2021-05-16 09:40:02 +00:00
|
|
|
V.Y = Clamp(V.Y - MoveDeltaInvert, 0, ScreenSize.Y);
|
|
|
|
else V.Y = Clamp(V.Y + MoveDelta, 0, ScreenSize.Y);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (OldMouseX != V.X || OldMouseY != V.Y)
|
2021-05-16 09:40:02 +00:00
|
|
|
ClientViewport.SetMouse(V.X, V.Y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return OnReceivedInputAxis(ControllerId, Key, Delta, DeltaTime, bGamepad);
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
2021-06-13 03:00:19 +00:00
|
|
|
simulated function bool ReceivedInputChar(int ControllerId, string Unicode)
|
2020-01-10 13:14:11 +00:00
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
if (!bIsInMenuState)
|
2021-05-16 09:40:02 +00:00
|
|
|
return false;
|
2021-06-13 02:54:35 +00:00
|
|
|
return OnReceivedInputChar(ControllerId, Unicode);
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
|
2021-06-13 03:00:19 +00:00
|
|
|
simulated Delegate bool OnInputKey(int ControllerId, name Key, EInputEvent Event, optional float AmountDepressed=1.f, optional bool bGamepad)
|
2020-01-10 13:14:11 +00:00
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
return false;
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
2021-06-13 03:00:19 +00:00
|
|
|
simulated Delegate bool OnReceivedInputAxis(int ControllerId, name Key, float Delta, float DeltaTime, bool bGamepad)
|
2020-01-10 13:14:11 +00:00
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
return false;
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
2021-06-13 03:00:19 +00:00
|
|
|
simulated Delegate bool OnReceivedInputChar(int ControllerId, string Unicode)
|
2020-01-10 13:14:11 +00:00
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
return false;
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
2021-06-13 03:00:19 +00:00
|
|
|
simulated Delegate bool InternalInputKey(int ControllerId, name Key, EInputEvent Event, optional float AmountDepressed=1.f, optional bool bGamepad)
|
2020-01-10 13:14:11 +00:00
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
return false;
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
2021-06-13 03:00:19 +00:00
|
|
|
simulated Delegate bool InternalReceivedInputChar(int ControllerId, string Unicode)
|
2020-01-10 13:14:11 +00:00
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
return false;
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
defaultproperties
|
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
CursorSize=24
|
2021-06-13 02:54:35 +00:00
|
|
|
CursorColor=(R=255, G=255, B=255, A=255)
|
2021-05-16 09:40:02 +00:00
|
|
|
CursorTextures[`CURSOR_DEFAULT]=Texture2D'UI_Managers.LoaderManager_SWF_I13'
|
|
|
|
CurrentCursorIndex=`CURSOR_DEFAULT
|
|
|
|
|
|
|
|
DefaultStyle=class'ClassicStyle'
|
|
|
|
bAbsorbInput=true
|
|
|
|
bAlwaysTick=true
|
|
|
|
bHideCursor=true
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|