KF2-Server-Extension/ServerExt/Classes/KFGUI_SwitchComponent.uc

86 lines
1.8 KiB
Ucode
Raw Normal View History

2017-10-20 02:00:49 +00:00
// A component to have multiple "pages" of different components.
Class KFGUI_SwitchComponent extends KFGUI_MultiComponent;
var protected int CurrentComponent;
function PreDraw()
{
local byte j;
ComputeCoords();
2020-11-28 20:12:58 +00:00
if (CurrentComponent<0 || CurrentComponent>=Components.Length)
2017-10-20 02:00:49 +00:00
return;
Components[CurrentComponent].Canvas = Canvas;
2020-11-28 20:12:58 +00:00
for (j=0; j<4; ++j)
2017-10-20 02:00:49 +00:00
Components[CurrentComponent].InputPos[j] = CompPos[j];
Components[CurrentComponent].PreDraw();
}
function bool CaptureMouse()
{
2020-11-28 20:12:58 +00:00
if ((CurrentComponent>=0 || CurrentComponent<Components.Length) && Components[CurrentComponent].CaptureMouse())
2017-10-20 02:00:49 +00:00
{
MouseArea = Components[CurrentComponent];
return true;
}
MouseArea = None;
return Super(KFGUI_Base).CaptureMouse(); // check with frame itself.
}
final function int GetSelectedPage()
{
return CurrentComponent;
}
2020-11-28 21:54:57 +00:00
2017-10-20 02:00:49 +00:00
final function name GetSelectedPageID()
{
2020-11-28 20:12:58 +00:00
if (CurrentComponent<Components.Length)
2017-10-20 02:00:49 +00:00
return Components[CurrentComponent].ID;
return '';
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
final function bool SelectPageID(name PageID)
2017-10-20 02:00:49 +00:00
{
local int i;
2023-05-14 02:49:12 +00:00
2020-11-28 20:12:58 +00:00
if (Components[CurrentComponent].ID==PageID)
2017-10-20 02:00:49 +00:00
return false;
2020-11-28 20:12:58 +00:00
for (i=0; i<Components.Length; ++i)
if (Components[i].ID==PageID)
2017-10-20 02:00:49 +00:00
{
Components[CurrentComponent].CloseMenu();
CurrentComponent = i;
Components[CurrentComponent].ShowMenu();
return true;
}
return false;
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
final function bool SelectPageIndex(int Num)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
if (CurrentComponent==Num)
2017-10-20 02:00:49 +00:00
return false;
2020-11-28 20:12:58 +00:00
if (Num>=0 && Num<Components.Length)
2017-10-20 02:00:49 +00:00
{
Components[CurrentComponent].CloseMenu();
CurrentComponent = Num;
Components[CurrentComponent].ShowMenu();
return true;
}
return false;
}
function ShowMenu()
{
2020-11-28 20:12:58 +00:00
if (CurrentComponent<Components.Length)
2017-10-20 02:00:49 +00:00
Components[CurrentComponent].ShowMenu();
}
2020-11-28 21:54:57 +00:00
2017-10-20 02:00:49 +00:00
function CloseMenu()
{
2020-11-28 20:12:58 +00:00
if (CurrentComponent<Components.Length)
2017-10-20 02:00:49 +00:00
Components[CurrentComponent].CloseMenu();
}