KF2-YetAnotherScoreboard/YAS/Classes/YAS_HUD.uc

110 lines
2.5 KiB
Ucode
Raw Normal View History

2022-09-03 17:26:40 +00:00
class YAS_HUD extends KFGFxHudWrapper;
2021-06-12 20:11:37 +00:00
2020-01-10 13:14:11 +00:00
const HUDBorderSize = 3;
var float ScaledBorderSize;
2021-06-13 03:17:40 +00:00
var array<KFGUI_Base> HUDWidgets;
2020-01-10 13:14:11 +00:00
2022-09-03 17:26:40 +00:00
var class<YAS_ScoreBoard> ScoreboardClass;
var YAS_ScoreBoard Scoreboard;
2020-01-10 13:14:11 +00:00
2021-05-16 06:16:12 +00:00
var transient KF2GUIController GUIController;
var transient GUIStyleBase GUIStyle;
2020-01-10 13:14:11 +00:00
simulated function PostBeginPlay()
{
Super.PostBeginPlay();
PlayerOwner.PlayerInput.OnReceivedNativeInputKey = NotifyInputKey;
PlayerOwner.PlayerInput.OnReceivedNativeInputAxis = NotifyInputAxis;
PlayerOwner.PlayerInput.OnReceivedNativeInputChar = NotifyInputChar;
RemoveMovies();
CreateHUDMovie();
2020-01-10 13:14:11 +00:00
}
function PostRender()
{
2021-06-13 02:53:33 +00:00
if (KFGRI == None)
KFGRI = KFGameReplicationInfo(WorldInfo.GRI);
2021-06-13 02:53:33 +00:00
if (GUIController != None && PlayerOwner.PlayerInput == None)
GUIController.NotifyLevelChange();
2021-06-13 02:53:33 +00:00
if (GUIController == None || GUIController.bIsInvalid)
{
2021-06-20 05:04:22 +00:00
GUIController = Class'YAS.KF2GUIController'.Static.GetGUIController(PlayerOwner);
2021-06-13 02:53:33 +00:00
if (GUIController != None)
{
GUIStyle = GUIController.CurrentStyle;
GUIStyle.HUDOwner = self;
LaunchHUDMenus();
}
}
GUIStyle.Canvas = Canvas;
GUIStyle.PickDefaultFontSize(Canvas.ClipY);
2021-06-13 02:53:33 +00:00
if (!GUIController.bIsInMenuState)
GUIController.HandleDrawMenu();
2021-05-16 06:16:12 +00:00
ScaledBorderSize = FMax(GUIStyle.ScreenScale(HUDBorderSize), 1.f);
Super.PostRender();
2020-01-10 13:14:11 +00:00
}
function LaunchHUDMenus()
{
2022-09-03 17:26:40 +00:00
Scoreboard = YAS_ScoreBoard(GUIController.InitializeHUDWidget(ScoreboardClass));
Scoreboard.SetVisibility(false);
2020-01-10 13:14:11 +00:00
}
function bool NotifyInputKey(int ControllerId, Name Key, EInputEvent Event, float AmountDepressed, bool bGamepad)
{
local int i;
2021-06-13 02:53:33 +00:00
for (i=(HUDWidgets.Length-1); i >= 0; --i)
{
2021-06-13 02:53:33 +00:00
if (HUDWidgets[i].bVisible && HUDWidgets[i].NotifyInputKey(ControllerId, Key, Event, AmountDepressed, bGamepad))
return true;
}
return false;
2020-01-10 13:14:11 +00:00
}
function bool NotifyInputAxis(int ControllerId, name Key, float Delta, float DeltaTime, optional bool bGamepad)
{
local int i;
2021-06-13 02:53:33 +00:00
for (i=(HUDWidgets.Length-1); i >= 0; --i)
{
2021-06-13 02:53:33 +00:00
if (HUDWidgets[i].bVisible && HUDWidgets[i].NotifyInputAxis(ControllerId, Key, Delta, DeltaTime, bGamepad))
return true;
}
return false;
2020-01-10 13:14:11 +00:00
}
function bool NotifyInputChar(int ControllerId, string Unicode)
{
local int i;
2021-06-13 02:53:33 +00:00
for (i=(HUDWidgets.Length-1); i >= 0; --i)
{
2021-06-13 02:53:33 +00:00
if (HUDWidgets[i].bVisible && HUDWidgets[i].NotifyInputChar(ControllerId, Unicode))
return true;
}
return false;
2020-01-10 13:14:11 +00:00
}
2021-05-16 06:16:12 +00:00
exec function SetShowScores(bool bNewValue)
2021-05-16 04:40:47 +00:00
{
if (Scoreboard != None)
Scoreboard.SetVisibility(bNewValue);
2021-05-16 06:16:12 +00:00
else Super.SetShowScores(bNewValue);
2021-05-16 04:40:47 +00:00
}
2021-05-16 06:16:12 +00:00
defaultproperties
2021-05-16 04:40:47 +00:00
{
2022-09-03 17:26:40 +00:00
ScoreboardClass=class'YAS_ScoreBoard'
2020-01-10 13:14:11 +00:00
}