2020-01-10 13:14:11 +00:00
|
|
|
Class KFGUI_MultiComponent extends KFGUI_Base;
|
|
|
|
|
2021-06-12 20:11:37 +00:00
|
|
|
`include(Build.uci)
|
|
|
|
`include(Logger.uci)
|
|
|
|
|
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()
|
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local int i;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
for (i=0; i < Components.Length; ++i)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
Components[i].Owner = Owner;
|
|
|
|
Components[i].ParentComponent = Self;
|
|
|
|
Components[i].InitMenu();
|
|
|
|
}
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
function ShowMenu()
|
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local int i;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
for (i=0; i < Components.Length; ++i)
|
2021-05-16 09:40:02 +00:00
|
|
|
Components[i].ShowMenu();
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
function PreDraw()
|
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local int i;
|
|
|
|
local byte j;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (!bVisible)
|
2021-05-16 09:40:02 +00:00
|
|
|
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]);
|
2021-05-16 09:40:02 +00:00
|
|
|
DrawMenu();
|
2021-06-13 02:53:33 +00:00
|
|
|
for (i=0; i < Components.Length; ++i)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
Components[i].Canvas = Canvas;
|
2021-06-13 02:53:33 +00:00
|
|
|
for (j=0; j < 4; ++j)
|
2021-05-16 09:40:02 +00:00
|
|
|
Components[i].InputPos[j] = CompPos[j];
|
|
|
|
Components[i].PreDraw();
|
|
|
|
}
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
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=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
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local int i;
|
2020-01-10 13:14:11 +00:00
|
|
|
|
2021-05-16 09:40:02 +00:00
|
|
|
Super.MenuTick(DeltaTime);
|
2021-06-13 02:53:33 +00:00
|
|
|
for (i=0; i < Components.Length; ++i)
|
2021-05-16 09:40:02 +00:00
|
|
|
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
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
Components[Components.Length] = C;
|
|
|
|
C.Owner = Owner;
|
|
|
|
C.ParentComponent = Self;
|
|
|
|
C.InitMenu();
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function CloseMenu()
|
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local int i;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
for (i=0; i < Components.Length; ++i)
|
2021-05-16 09:40:02 +00:00
|
|
|
Components[i].CloseMenu();
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
function bool CaptureMouse()
|
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local int i;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
for (i=Components.Length - 1; i >= 0; i--)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
if (Components[i].CaptureMouse())
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
MouseArea = Components[i];
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MouseArea = None;
|
|
|
|
return Super.CaptureMouse(); // check with frame itself.
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
function bool ReceievedControllerInput(int ControllerId, name Key, EInputEvent Event)
|
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local int i;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
for (i=Components.Length - 1; i >= 0; i--)
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
if (Components[i].ReceievedControllerInput(ControllerId, Key, Event))
|
2021-05-16 09:40:02 +00:00
|
|
|
{
|
|
|
|
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
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local int i;
|
|
|
|
local KFGUI_Base Result;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
if (ID == InID)
|
2021-05-16 09:40:02 +00:00
|
|
|
Result = Self;
|
|
|
|
else
|
|
|
|
{
|
2021-06-13 02:53:33 +00:00
|
|
|
for (i=0; i < Components.Length && Result == None; ++i)
|
2021-05-16 09:40:02 +00:00
|
|
|
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
|
|
|
{
|
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 (ID == InID)
|
2021-05-16 09:40:02 +00:00
|
|
|
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
|
|
|
{
|
2021-05-16 09:40:02 +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-05-16 09:40:02 +00:00
|
|
|
{
|
2021-06-13 02:54:35 +00:00
|
|
|
Components.Remove(i, 1);
|
2021-05-16 09:40:02 +00:00
|
|
|
B.CloseMenu();
|
|
|
|
return;
|
|
|
|
}
|
2021-06-13 02:53:33 +00:00
|
|
|
for (i=0; i < Components.Length; ++i)
|
2021-05-16 09:40:02 +00:00
|
|
|
Components[i].RemoveComponent(B);
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
function NotifyLevelChange()
|
|
|
|
{
|
2021-05-16 09:40:02 +00:00
|
|
|
local int i;
|
|
|
|
|
2021-06-13 02:53:33 +00:00
|
|
|
for (i=0; i < Components.Length; ++i)
|
2021-05-16 09:40:02 +00:00
|
|
|
Components[i].NotifyLevelChange();
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|