KF2-YetAnotherScoreboard/YAS/Classes/KFGUI_MultiComponent.uc

157 lines
2.8 KiB
Ucode
Raw Normal View History

2022-09-03 17:26:40 +00:00
class KFGUI_MultiComponent extends KFGUI_Base;
2021-06-12 20:11:37 +00:00
2021-06-13 03:17:40 +00:00
var() export editinline array<KFGUI_Base> Components;
2020-01-10 13:14:11 +00:00
function InitMenu()
{
local int i;
2021-06-13 02:53:33 +00:00
for (i=0; i < Components.Length; ++i)
{
Components[i].Owner = Owner;
Components[i].ParentComponent = Self;
Components[i].InitMenu();
}
2020-01-10 13:14:11 +00:00
}
2020-01-10 13:14:11 +00:00
function ShowMenu()
{
local int i;
2021-06-13 02:53:33 +00:00
for (i=0; i < Components.Length; ++i)
Components[i].ShowMenu();
2020-01-10 13:14:11 +00:00
}
2020-01-10 13:14:11 +00:00
function PreDraw()
{
local int i;
local byte j;
2021-06-13 02:53:33 +00:00
if (!bVisible)
return;
ComputeCoords();
2021-06-13 02:54:35 +00:00
Canvas.SetDrawColor(255, 255, 255);
Canvas.SetOrigin(CompPos[0], CompPos[1]);
Canvas.SetClip(CompPos[0]+CompPos[2], CompPos[1]+CompPos[3]);
DrawMenu();
2021-06-13 02:53:33 +00:00
for (i=0; i < Components.Length; ++i)
{
Components[i].Canvas = Canvas;
2021-06-13 02:53:33 +00:00
for (j=0; j < 4; ++j)
Components[i].InputPos[j] = CompPos[j];
Components[i].PreDraw();
}
2020-01-10 13:14:11 +00:00
}
2020-01-10 13:14:11 +00:00
function InventoryChanged(optional KFWeapon Wep, optional bool bRemove)
{
local int i;
2021-06-13 02:53:33 +00:00
for (i=0; i < Components.Length; ++i)
2021-06-13 02:54:35 +00:00
Components[i].InventoryChanged(Wep, bRemove);
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
function MenuTick(float DeltaTime)
2020-01-10 13:14:11 +00:00
{
local int i;
2020-01-10 13:14:11 +00:00
Super.MenuTick(DeltaTime);
2021-06-13 02:53:33 +00:00
for (i=0; i < Components.Length; ++i)
Components[i].MenuTick(DeltaTime);
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
function AddComponent(KFGUI_Base C)
2020-01-10 13:14:11 +00:00
{
Components[Components.Length] = C;
C.Owner = Owner;
C.ParentComponent = Self;
C.InitMenu();
2020-01-10 13:14:11 +00:00
}
function CloseMenu()
{
local int i;
2021-06-13 02:53:33 +00:00
for (i=0; i < Components.Length; ++i)
Components[i].CloseMenu();
2020-01-10 13:14:11 +00:00
}
2020-01-10 13:14:11 +00:00
function bool CaptureMouse()
{
local int i;
2021-06-13 02:53:33 +00:00
for (i=Components.Length - 1; i >= 0; i--)
{
2021-06-13 02:53:33 +00:00
if (Components[i].CaptureMouse())
{
MouseArea = Components[i];
return true;
}
}
MouseArea = None;
return Super.CaptureMouse(); // check with frame itself.
2020-01-10 13:14:11 +00:00
}
2020-01-10 13:14:11 +00:00
function bool ReceievedControllerInput(int ControllerId, name Key, EInputEvent Event)
{
local int i;
2021-06-13 02:53:33 +00:00
for (i=Components.Length - 1; i >= 0; i--)
{
2021-06-13 02:53:33 +00:00
if (Components[i].ReceievedControllerInput(ControllerId, Key, Event))
{
return true;
}
}
return Super.ReceievedControllerInput(ControllerId, Key, Event);
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
function KFGUI_Base FindComponentID(name InID)
2020-01-10 13:14:11 +00:00
{
local int i;
local KFGUI_Base Result;
2021-06-13 02:53:33 +00:00
if (ID == InID)
Result = Self;
else
{
2021-06-13 02:53:33 +00:00
for (i=0; i < Components.Length && Result == None; ++i)
Result = Components[i].FindComponentID(InID);
}
return Result;
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
function FindAllComponentID(name InID, out array < KFGUI_Base> Res)
2020-01-10 13:14:11 +00:00
{
local int i;
2020-01-10 13:14:11 +00:00
2021-06-13 02:53:33 +00:00
if (ID == InID)
Res[Res.Length] = Self;
2021-06-13 02:53:33 +00:00
for (i=0; i < Components.Length; ++i)
2021-06-13 02:54:35 +00:00
Components[i].FindAllComponentID(InID, Res);
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
function RemoveComponent(KFGUI_Base B)
2020-01-10 13:14:11 +00:00
{
local int i;
2021-06-13 02:53:33 +00:00
for (i=0; i < Components.Length; ++i)
if (Components[i] == B)
{
2021-06-13 02:54:35 +00:00
Components.Remove(i, 1);
B.CloseMenu();
return;
}
2021-06-13 02:53:33 +00:00
for (i=0; i < Components.Length; ++i)
Components[i].RemoveComponent(B);
2020-01-10 13:14:11 +00:00
}
2020-01-10 13:14:11 +00:00
function NotifyLevelChange()
{
local int i;
2021-06-13 02:53:33 +00:00
for (i=0; i < Components.Length; ++i)
Components[i].NotifyLevelChange();
}