// This is the main file for the Havoc GUI which includes an interface for
// controling client and server settings, admin options, voting controls,
// teleportation destination control, and deployable controls.

// -----------------------------------------------------------
// Generic GUI Functions
// -----------------------------------------------------------

function ClientCmdPopupMessageBox(%Title, %Message)
{
   MessageBoxOK(%Title, %Message);
}

function clientCmdCloseAllHuds()
{
   EngineerMenu.close();
   RenameMenu.close();
   TurretMenu.close();
   FFMenu.close();
   TeleportMenu.close();
   inventoryHud.close();
}

// -----------------------------------------------------------
// Main Havoc GUI
// -----------------------------------------------------------

function ClientCmdOpenHavocMenu()
{
   ClientCmdPopupMessageBox("Should work!", "Should open the main Havoc GUI");
}

function OpenHavocGUI(%Val)
{
   if (%Val == true)
      ClientCmdOpenHavocMenu();
}

$RemapName[108] = "Open Havoc GUI";
$RemapCmd[108] = "OpenHavocGUI";
$RemapCount = 109;

$ObsRemapName[5] = "Open Havoc GUI";
$ObsRemapCmd[5] = "OpenHavocGUI";
$ObsRemapCount = 6;

// -----------------------------------------------------------
// Engineering GUI
// -----------------------------------------------------------
// This GUI helps control deployables more easily and gives players the
// ability to order a repack, rename, small turret mode controls, and forcefield
// orientation controls.

function ClientCmdOpenEngineerMenu(%ObjectName, %Owner, %Type)
{
   if (isObject(EngineerMenu) == false)
   {
      %HUD = new GuiControl(EngineerMenu)
      {
         profile = "GuiDefaultProfile";
         horizSizing = "center";
         vertSizing = "center";
         position = "0 -200";
         extent = "240 200";
         minExtent = "8 8";
         visible = "1";
         setFirstResponder = "0";
         modal = "1";

        new GuiTextCtrl(UplinkText)
        {
           profile = "GuiDashTextProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "275 -235";
           extent = "250 15";
           minExtent = "8 8";
           visible = "1";
           text = "Message that says what is uplinked with";
        };

        new GuiTextCtrl(OwnerText) {
           profile = "GuiDashTextProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "275 -220";
           extent = "250 15";
           minExtent = "8 8";
           visible = "1";
           text = "Message that says who owns it";
        };
 
        new ShellBitmapButton(RenameButton)
        {
           profile = "ShellButtonProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "325 -190";
           extent = "140 20";
           minExtent = "26 27";
           visible = "1";
           hideCursor = "0";
           bypassHideCursor = "0";
           command = "RequestRenameMenu();";
           helpTag = "0";
           text = "Rename Deployable";
           maxLength = "255";
        };

        new ShellBitmapButton(RepackButton)
        {
           profile = "ShellButtonProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "325 -160";
           extent = "140 20";
           minExtent = "26 27";
           visible = "1";
           hideCursor = "0";
           bypassHideCursor = "0";
           command = "RequestRepack();";
           helpTag = "0";
           text = "Repack Deployable";
           maxLength = "255";
        };

        new ShellBitmapButton(AlternateButton)
        {
           profile = "ShellButtonProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "325 -130";
           extent = "140 20";
           minExtent = "26 27";
           visible = "1";
           hideCursor = "0";
           bypassHideCursor = "0";
           command = "Nothing();";
           helpTag = "0";
           text = "FF Generator Controls";
           maxLength = "255";
        };

        new ShellBitmapButton(Back)
        {
           profile = "ShellButtonProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "325 -100";
           extent = "140 20";
           minExtent = "26 27";
           visible = "1";
           hideCursor = "0";
           bypassHideCursor = "0";
           command = "EngineerMenu.close();";
           helpTag = "0";
           text = "Back";
           maxLength = "255";
        };

      };

      GuiGroup.add(%HUD);
   }
   UplinkText.setText("Uplinked with: " @ %ObjectName);
   OwnerText.setText("Owned by: " @ %Owner);

   if (%Type $= "SmallTurret" || %Type $= "FFGenerator")
   {
      AlternateButton.setVisible(true);

      switch$ (%Type)
      {
         case "SmallTurret" :
            AlternateButton.Text = "Small Turret Modes";
            AlternateButton.Command = "RequestTurretMenu();";

         case "FFGenerator" :
            AlternateButton.Text = "FF Generator Controls";
            AlternateButton.Command = "RequestFFMenu();";

         default :
            AlternateButton.setText("HUH?");
            AlternateButton.Command = "";
      }
   } else {
      AlternateButton.setVisible(false);
   }

   ShowHUD('EngineerMenu');
}

function EngineerMenu::setUpHud(%this, %tag)
{

}

function EngineerMenu::loadHud(%this, %tag)
{
   $Hud[%tag] = EngineerMenu;
   $Hud[%tag].childGui = ENG_Root;
   $Hud[%tag].parent = ENG_Root;
}

function EngineerMenu::open(%this)
{
   parent::open(%this);
}

function EngineerMenu::close(%this, %DontReOpen)
{
   HideHud('EngineerMenu');
   EngineerMenu.delete();
   CursorOff();

   if (%DontReOpen != true)
      commandToServer('OpenHavocMenu');      
}

function ClientCmdOpenTurretMenu(%ObjectName, %Owner, %Mode)
{
   if (isObject(TurretMenu) == false)
   {
      %HUD = new GuiControl(TurretMenu)
      {
         profile = "GuiDefaultProfile";
         horizSizing = "center";
         vertSizing = "center";
         position = "0 -200";
         extent = "240 200";
         minExtent = "8 8";
         visible = "1";
         setFirstResponder = "0";
         modal = "1";

        new GuiTextCtrl(UplinkText)
        {
           profile = "GuiDashTextProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "275 -295";
           extent = "250 15";
           minExtent = "8 8";
           visible = "1";
           text = "Message that says what is uplinked with";
        };

        new GuiTextCtrl(OwnerText) {
           profile = "GuiDashTextProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "275 -280";
           extent = "250 15";
           minExtent = "8 8";
           visible = "1";
           text = "Message that says who owns it";
        };
 
        new GuiTextCtrl(ModeText) {
           profile = "GuiDashTextProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "275 -265";
           extent = "250 15";
           minExtent = "8 8";
           visible = "1";
           text = "Message that says what mode it is in now";
        };

        new ShellBitmapButton(EMPButton)
        {
           profile = "ShellButtonProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "325 -245";
           extent = "140 20";
           minExtent = "26 27";
           visible = "1";
           hideCursor = "0";
           bypassHideCursor = "0";
           command = "RequestModeChange(1);";
           helpTag = "0";
           text = "EMP Mode";
           maxLength = "255";
        };

        new ShellBitmapButton(FlameButton)
        {
           profile = "ShellButtonProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "325 -215";
           extent = "140 20";
           minExtent = "26 27";
           visible = "1";
           hideCursor = "0";
           bypassHideCursor = "0";
           command = "RequestModeChange(2);";
           helpTag = "0";
           text = "Flame Mode";
           maxLength = "255";
        };

        new ShellBitmapButton(FusionButton)
        {
           profile = "ShellButtonProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "325 -185";
           extent = "140 20";
           minExtent = "26 27";
           visible = "1";
           hideCursor = "0";
           bypassHideCursor = "0";
           command = "RequestModeChange(3);";
           helpTag = "0";
           text = "Fusion Mode";
           maxLength = "255";
        };

        new ShellBitmapButton(ImpulseButton)
        {
           profile = "ShellButtonProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "325 -155";
           extent = "140 20";
           minExtent = "26 27";
           visible = "1";
           hideCursor = "0";
           bypassHideCursor = "0";
           command = "RequestModeChange(4);";
           helpTag = "0";
           text = "Impulse Mode";
           maxLength = "255";
        };

        new ShellBitmapButton(IonButton)
        {
           profile = "ShellButtonProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "325 -125";
           extent = "140 20";
           minExtent = "26 27";
           visible = "1";
           hideCursor = "0";
           bypassHideCursor = "0";
           command = "RequestModeChange(5);";
           helpTag = "0";
           text = "Ion Mode";
           maxLength = "255";
        };

        new ShellBitmapButton(LaserButton)
        {
           profile = "ShellButtonProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "325 -95";
           extent = "140 20";
           minExtent = "26 27";
           visible = "1";
           hideCursor = "0";
           bypassHideCursor = "0";
           command = "RequestModeChange(6);";
           helpTag = "0";
           text = "Laser Mode";
           maxLength = "255";
        };

        new ShellBitmapButton(TractorButton)
        {
           profile = "ShellButtonProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "325 -65";
           extent = "140 20";
           minExtent = "26 27";
           visible = "1";
           hideCursor = "0";
           bypassHideCursor = "0";
           command = "RequestModeChange(7);";
           helpTag = "0";
           text = "Tractor Mode";
           maxLength = "255";
        };

        new ShellBitmapButton(BackButton)
        {
           profile = "ShellButtonProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "325 -35";
           extent = "140 20";
           minExtent = "26 27";
           visible = "1";
           hideCursor = "0";
           bypassHideCursor = "0";
           command = "TurretMenu.close();";
           helpTag = "0";
           text = "Back";
           maxLength = "255";
        };
      };

      GuiGroup.add(%HUD);
   }
   UplinkText.setText("Uplinked with: " @ %ObjectName);
   OwnerText.setText("Owned by: " @ %Owner);
   ModeText.setText("Current Mode: " @ %Mode);

   ShowHUD('TurretMenu');
}

function TurretMenu::setUpHud(%this, %tag)
{

}

function TurretMenu::loadHud(%this, %tag)
{
   $Hud[%tag] = TurretMenu;
   $Hud[%tag].childGui = ENG_Root;
   $Hud[%tag].parent = ENG_Root;
}

function TurretMenu::open(%this)
{
   parent::open(%this);
}

function TurretMenu::close(%this, %DontReOpen)
{
   HideHud('TurretMenu');
   TurretMenu.delete();
   CursorOff();
   
   if (%DontReOpen != true)
      commandToServer('OpenEngineerMenu');
}

function ClientCmdOpenRenameMenu(%ObjectName, %Owner)
{
   if (isObject(RenameMenu) == false)
   {
      %HUD = new GuiControl(RenameMenu)
      {
         profile = "GuiDefaultProfile";
         horizSizing = "center";
         vertSizing = "center";
         position = "0 -200";
         extent = "240 200";
         minExtent = "8 8";
         visible = "1";
         setFirstResponder = "0";
         modal = "1";

        new GuiTextCtrl(UplinkText)
        {
           profile = "GuiDashTextProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "275 -235";
           extent = "250 15";
           minExtent = "8 8";
           visible = "1";
           text = "Message that says what is uplinked with";
        };

        new GuiTextCtrl(OwnerText)
        {
           profile = "GuiDashTextProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "275 -220";
           extent = "250 15";
           minExtent = "8 8";
           visible = "1";
           text = "Message that says who owns it";
        };
 
        new GuiTextCtrl(RenameLabel)
        {
           profile = "GuiDashTextProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "200 -180";
           extent = "285 15";
           minExtent = "8 8";
           visible = "1";
           text = "New Name for Deployable:";
        };

        new ShellBitmapButton(RenameButton)
        {
           profile = "ShellButtonProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "320 -135";
           extent = "60 20";
           minExtent = "8 8";
           visible = "1";
           setFirstResponder = "0";
           modal = "1";
           helpTag = "0";
           command = "renameDeployable();";
           text = "Ok";
        };      

        new ShellTextEditCtrl(RenameText)
        {
           profile = "NewTextEditProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "280 -165";
           extent = "240 38";
           minExtent = "8 8";
           visible = "1";
           altCommand = "renameDeployable()";
           setFirstResponder = "1";
           modal = "1";
           helpTag = "0";
           historySize = "0";
           maxLength = "50";
        };

        new ShellBitmapButton(BackButton)
        {
           profile = "ShellButtonProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "420 -135";
           extent = "60 20";
           minExtent = "26 27";
           visible = "1";
           hideCursor = "0";
           bypassHideCursor = "0";
           command = "RenameMenu.close(0);";
           helpTag = "0";
           text = "Cancel";
           maxLength = "255";
        };
      };

      GuiGroup.add(%HUD);
   }
   UplinkText.setText("Uplinked with: " @ %ObjectName);
   OwnerText.setText("Owned by: " @ %Owner);

   RenameText.setValue(%ObjectName);

   ShowHUD('RenameMenu');
}

function RenameMenu::setUpHud(%this, %tag)
{

}

function RenameMenu::loadHud(%this, %tag)
{
   $Hud[%tag] = RenameMenu;
   $Hud[%tag].childGui = ENG_Root;
   $Hud[%tag].parent = ENG_Root;
}

function RenameMenu::open(%this)
{
   parent::open(%this);
}

function RenameMenu::close(%this, %DontReOpen)
{
   HideHud('RenameMenu');
   CursorOff();

   if (%DontReOpen != true)
      commandToServer('OpenEngineerMenu');
}

// Supporting Functions for Buttons
function RenameDeployable()
{
   %NewName = RenameText.getValue();
   commandToServer('RenameDeployable', %NewName);

   RenameMenu.close('RenameMenu', true);
}

function RequestRepack()
{
   commandToServer('Repack');
   EngineerMenu.close('EngineerMenu', true);
}

function RequestRenameMenu()
{
   commandToServer('OpenRenameMenu');
   EngineerMenu.close('EngineerMenu', true);
}

function RequestFFMenu()
{
   commandToServer('OpenFFMenu');
   EngineerMenu.close('EngineerMenu', true);
}

function RequestTurretMenu()
{
   commandToServer('OpenTurretMenu');
   EngineerMenu.close('EngineerMenu', true);
}

function RequestModeChange(%ModeNo)
{
   switch (%ModeNo)
   {
      case 1 :
         %Mode = "EMP";

      case 2 :
         %Mode = "Flame";

      case 3 :
         %Mode = "Fusion";

      case 4 :
         %Mode = "Impulse";

      case 5 :
         %Mode = "Ion";

      case 6 :
         %Mode = "Laser";

      case 7 :
         %Mode = "Tractor";

      default :
         %Mode = "";
   }

   commandToServer('ChangeTurretMode', %Mode);
   TurretMenu.close('TurretMenu', true); 
}

function ClientCmdOpenFFMenu(%ObjectName, %Owner, %Orientation, %RightLeft, %UpDown)
{
   if (isObject(FFMenu) == false)
   {
      %HUD = new GuiControl(FFMenu)
      {
         profile = "GuiDefaultProfile";
         horizSizing = "center";
         vertSizing = "center";
         position = "0 -200";
         extent = "240 400";
         minExtent = "8 8";
         visible = "1";
         setFirstResponder = "0";
         modal = "1";

        new GuiTextCtrl(UplinkText)
        {
           profile = "GuiDashTextProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "275 -235";
           extent = "250 15";
           minExtent = "8 8";
           visible = "1";
           text = "Message that says what is uplinked with";
        };

        new GuiTextCtrl(OwnerText) {
           profile = "GuiDashTextProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "275 -220";
           extent = "250 15";
           minExtent = "8 8";
           visible = "1";
           text = "Message that says who owns it";
        };
 
        new ShellBitmapButton(LargeUpButton)
        {
           profile = "ShellButtonProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "150 -190";
           extent = "140 20";
           minExtent = "26 27";
           visible = "1";
           hideCursor = "0";
           bypassHideCursor = "0";
           command = "RequestUpDown(1);";
           helpTag = "0";
           text = "";
           bitmap = "gui/LargeUpButton.png";
        };

        new ShellBitmapButton(SmallUpButton)
        {
           profile = "ShellButtonProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "125 -190";
           extent = "140 20";
           minExtent = "26 27";
           visible = "1";
           hideCursor = "0";
           bypassHideCursor = "0";
           command = "RequestUpDown(0.1);";
           helpTag = "0";
           text = "";
           bitmap = "gui/SmallUpButton.png";
        };

        new ShellBitmapButton(LargeDownButton)
        {
           profile = "ShellButtonProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "150 -160";
           extent = "140 20";
           minExtent = "26 27";
           visible = "1";
           hideCursor = "0";
           bypassHideCursor = "0";
           command = "RequestUpDown(-1);";
           helpTag = "0";
           text = "";
           bitmap = "gui/LargeDownButton.png";
        };

        new ShellBitmapButton(SmallDownButton)
        {
           profile = "ShellButtonProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "125 -160";
           extent = "140 20";
           minExtent = "26 27";
           visible = "1";
           hideCursor = "0";
           bypassHideCursor = "0";
           command = "RequestUpDown(-0.1);";
           helpTag = "0";
           text = "";
           bitmap = "gui/SmallDownButton.png";
        };

        new HudBitmapCtrl(UpDownScale)
        {
           profile = "GuiDashBoxProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "256 0";
           extent = "128 128";
           minExtent = "8 8";
           visible = "1";
           bitmap = "gui/upDownScale.png";
           opacity = "1.0";
        };

        new HudBitmapCtrl(UpDownMarker)
        {
           profile = "GuiDashBoxProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "256 0";
           extent = "128 128";
           minExtent = "8 8";
           visible = "1";
           bitmap = "gui/upDownMarker.png";
           opacity = "1.0";
        };

        new ShellBitmapButton(LargeLeftButton)
        {
           profile = "ShellButtonProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "150 -190";
           extent = "140 20";
           minExtent = "26 27";
           visible = "1";
           hideCursor = "0";
           bypassHideCursor = "0";
           command = "RequestRightLeft(1);";
           helpTag = "0";
           text = "";
           bitmap = "gui/LargeLeftButton.png";
        };

        new ShellBitmapButton(SmallLeftButton)
        {
           profile = "ShellButtonProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "125 -190";
           extent = "140 20";
           minExtent = "26 27";
           visible = "1";
           hideCursor = "0";
           bypassHideCursor = "0";
           command = "RequestRightLeft(0.1);";
           helpTag = "0";
           text = "";
           bitmap = "gui/SmallLeftButton.png";
        };

        new ShellBitmapButton(LargeRightButton)
        {
           profile = "ShellButtonProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "150 -160";
           extent = "140 20";
           minExtent = "26 27";
           visible = "1";
           hideCursor = "0";
           bypassHideCursor = "0";
           command = "RequestRightLeft(-1);";
           helpTag = "0";
           text = "";
           bitmap = "gui/LargeRightButton.png";
        };

        new ShellBitmapButton(SmallRightButton)
        {
           profile = "ShellButtonProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "125 -160";
           extent = "140 20";
           minExtent = "26 27";
           visible = "1";
           hideCursor = "0";
           bypassHideCursor = "0";
           command = "RequestRightLeft(-0.1);";
           helpTag = "0";
           text = "";
           bitmap = "gui/SmallRightButton.png";
        };

        new HudBitmapCtrl(RightLeftScale)
        {
           profile = "GuiDashBoxProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "256 0";
           extent = "128 128";
           minExtent = "8 8";
           visible = "1";
           bitmap = "gui/RightLeftScale.png";
           opacity = "1.0";
        };

        new HudBitmapCtrl(RightLeftMarker)
        {
           profile = "GuiDashBoxProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "256 0";
           extent = "128 128";
           minExtent = "8 8";
           visible = "1";
           bitmap = "gui/RightLeftMarker.png";
           opacity = "1.0";
        };

        new HudBitmapCtrl(Orientation1Highlight)
        {
           profile = "GuiDashBoxProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "256 0";
           extent = "128 128";
           minExtent = "8 8";
           visible = "1";
           bitmap = "gui/buttonhighlight.png";
           opacity = "1.0";
        };

        new ShellBitmapButton(Orientation1Button)
        {
           profile = "ShellButtonProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "125 -160";
           extent = "140 20";
           minExtent = "26 27";
           visible = "1";
           hideCursor = "0";
           bypassHideCursor = "0";
           command = "RequestOrientation(1);";
           helpTag = "0";
           text = "";
           bitmap = "gui/FFOrientation1Button.png";
        };

        new HudBitmapCtrl(Orientation2Highlight)
        {
           profile = "GuiDashBoxProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "256 0";
           extent = "128 128";
           minExtent = "8 8";
           visible = "1";
           bitmap = "gui/buttonhighlight.png";
           opacity = "1.0";
        };

        new ShellBitmapButton(Orientation2Button)
        {
           profile = "ShellButtonProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "125 -160";
           extent = "140 20";
           minExtent = "26 27";
           visible = "1";
           hideCursor = "0";
           bypassHideCursor = "0";
           command = "RequestOrientation(2);";
           helpTag = "0";
           text = "";
           bitmap = "gui/FFOrientation2Button.png";
        };

        new HudBitmapCtrl(Orientation3Highlight)
        {
           profile = "GuiDashBoxProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "256 0";
           extent = "128 128";
           minExtent = "8 8";
           visible = "1";
           bitmap = "gui/buttonhighlight.png";
           opacity = "1.0";
        };

        new ShellBitmapButton(Orientation3Button)
        {
           profile = "ShellButtonProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "125 -160";
           extent = "140 20";
           minExtent = "26 27";
           visible = "1";
           hideCursor = "0";
           bypassHideCursor = "0";
           command = "RequestOrientation(3);";
           helpTag = "0";
           text = "";
           bitmap = "gui/FFOrientation3Button.png";
        };

        new HudBitmapCtrl(Orientation4Highlight)
        {
           profile = "GuiDashBoxProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "256 0";
           extent = "128 128";
           minExtent = "8 8";
           visible = "1";
           bitmap = "gui/buttonhighlight.png";
           opacity = "1.0";
        };

        new ShellBitmapButton(Orientation4Button)
        {
           profile = "ShellButtonProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "125 -160";
           extent = "140 20";
           minExtent = "26 27";
           visible = "1";
           hideCursor = "0";
           bypassHideCursor = "0";
           command = "RequestOrientation(4);";
           helpTag = "0";
           text = "";
           bitmap = "gui/FFOrientation4Button.png";
        };

        new HudBitmapCtrl(Orientation5Highlight)
        {
           profile = "GuiDashBoxProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "256 0";
           extent = "128 128";
           minExtent = "8 8";
           visible = "1";
           bitmap = "gui/buttonhighlight.png";
           opacity = "1.0";
        };

        new ShellBitmapButton(Orientation5Button)
        {
           profile = "ShellButtonProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "125 -160";
           extent = "140 20";
           minExtent = "26 27";
           visible = "1";
           hideCursor = "0";
           bypassHideCursor = "0";
           command = "RequestOrientation(5);";
           helpTag = "0";
           text = "";
           bitmap = "gui/FFOrientation5Button.png";
        };

        new ShellBitmapButton(BackButton)
        {
           profile = "ShellButtonProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "325 -100";
           extent = "140 20";
           minExtent = "26 27";
           visible = "1";
           hideCursor = "0";
           bypassHideCursor = "0";
           command = "FFMenu.close();";
           helpTag = "0";
           text = "Back";
           maxLength = "255";
        };

      };

      GuiGroup.add(%HUD);
   }
   UplinkText.setText("Uplinked with: " @ %ObjectName);
   OwnerText.setText("Owned by: " @ %Owner);

   ShowHUD('FFMenu');

   clientCmdUpdateFFMenu(%Orientation, %RightLeft, %UpDown);
}

function clientCmdUpdateFFMenu(%Orientation, %RightLeft, %UpDown)
{
   // If the Menu is not open, then ignore the player
   if (isObject(FFMenu) == false)
      return;

   // Update the Orientation Highlights for the Current Orientation
   switch (%Orientation)
   {
      case 1:
         Orientation1Hightlight.setVisible(true);
         Orientation2Hightlight.setVisible(false);
         Orientation3Hightlight.setVisible(false);
         Orientation4Hightlight.setVisible(false);
         Orientation5Hightlight.setVisible(false);

      case 2:
         Orientation1Hightlight.setVisible(false);
         Orientation2Hightlight.setVisible(true);
         Orientation3Hightlight.setVisible(false);
         Orientation4Hightlight.setVisible(false);
         Orientation5Hightlight.setVisible(false);

      case 3:
         Orientation1Hightlight.setVisible(false);
         Orientation2Hightlight.setVisible(false);
         Orientation3Hightlight.setVisible(true);
         Orientation4Hightlight.setVisible(false);
         Orientation5Hightlight.setVisible(false);

      case 4:
         Orientation1Hightlight.setVisible(false);
         Orientation2Hightlight.setVisible(false);
         Orientation3Hightlight.setVisible(false);
         Orientation4Hightlight.setVisible(true);
         Orientation5Hightlight.setVisible(false);

      case 5:
         Orientation1Hightlight.setVisible(false);
         Orientation2Hightlight.setVisible(false);
         Orientation3Hightlight.setVisible(false);
         Orientation4Hightlight.setVisible(false);
         Orientation5Hightlight.setVisible(true);
         
      default :
   }

   // Change the RightLeft Marker
   %RightLeftPositionX = %RightLeft * 10 + 325;
   UpDownMarker.setPosition(%RightLeftPositionX @ " 250");

   // Change the UpDown Marker
   %UpDownPositionY = %UpDown * 10 - 200;
   UpDownMarker.setPosition("250 " @ %UpDownPositionY);
}

function FFMenu::loadHud(%this, %tag)
{
   $Hud[%tag] = FFMenu;
   $Hud[%tag].childGui = ENG_Root;
   $Hud[%tag].parent = ENG_Root;
}

function FFMenu::open(%this)
{
   parent::open(%this);
}

function FFMenu::close(%this, %DontReOpen)
{
   HideHud('FFMenu');
   FFMenu.delete();
   CursorOff();

   if (%DontReOpen != true)
      commandToServer('OpenHavocMenu');      
}

function RequestUpDown(%Amount)
{
   commandToServer('ChangeFFUpDown', %Amount, "");
}

function RequestRightLeft(%Amount)
{
   commandToServer('ChangeFFRightLeft', %Amount, "");
}

function RequestOrientation(%Orientation)
{
   commandToServer('ChangeFFOrientation', %Orientation);
}

// -----------------------------------------------------------
// Teleportation GUI
// -----------------------------------------------------------
// This GUI gives the player the option to choose the teleport 
// destination.  A listing of the teleporters available is
// provided to the player and other important information.

// This sets up global array for the status and name of each of 
// the 6 teleporters for the team.
function clientCmdSetTeleporterStatus(%TeleportNo, %Name, %Owner, %Status, %PowerLevel)
{
   $TeleporterName[%TeleportNo] = %Name;
   $TeleporterOwner[%TeleportNo] = %Owner;
   $TeleporterStatus[%TeleportNo] = %Status;
   $TeleporterPowerLevel[%TeleportNo] = %PowerLevel @ "%";
}

function clientCmdSetCurrentTeleporter(%Name, %Owner, %PowerLevel)
{
   $CurrentTeleporterName = %Name;
   $CurrentTeleporterOwner = %Owner;
   $CurrentTeleporterPowerLevel = %PowerLevel;
}

function ClientCmdOpenTeleporterMenu()
{
   if (isObject(TeleportMenu) == false)
   {
      %HUD = new GuiControl(TeleportMenu)
      {
         profile = "GuiDefaultProfile";
         horizSizing = "center";
         vertSizing = "center";
         position = "0 -200";
         extent = "240 200";
         minExtent = "8 8";
         visible = "1";
         setFirstResponder = "0";
         modal = "1";

        new GuiTextCtrl(CurrentTeleporterName)
        {
           profile = "GuiDashTextProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "275 -295";
           extent = "250 15";
           minExtent = "8 8";
           visible = "1";
           text = "Message that is the teleporter name";
        };

        new GuiTextCtrl(CurrentTeleporterOwner)
        {
           profile = "GuiDashTextProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "275 -280";
           extent = "250 15";
           minExtent = "8 8";
           visible = "1";
           text = "Message that says who owns it";
        };
 
        new GuiTextCtrl(CurrentTeleporterPowerLevel)
        {
           profile = "GuiDashTextProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "275 -265";
           extent = "250 15";
           minExtent = "8 8";
           visible = "1";
           text = "Message that says the power level";
        };

        new GuiTextCtrl(Teleporter1Name)
        {
           profile = "GuiDashTextProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "150 -245";
           extent = "250 15";
           minExtent = "8 8";
           visible = "1";
           text = "Name of Teleporter 1";
        };

        new GuiTextCtrl(Teleporter1Owner)
        {
           profile = "GuiDashTextProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "150 -230";
           extent = "250 15";
           minExtent = "8 8";
           visible = "1";
           text = "Owner of Teleporter 1";
        };

        new GuiTextCtrl(Teleporter1Status)
        {
           profile = "GuiDashTextProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "150 -215";
           extent = "250 15";
           minExtent = "8 8";
           visible = "1";
           text = "Status: ";
        };

        new GuiTextCtrl(Teleporter1PowerLevel)
        {
           profile = "GuiDashTextProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "150 -200";
           extent = "250 15";
           minExtent = "8 8";
           visible = "1";
           text = "Power Level: ";
        };

        new ShellBitmapButton(Teleporter1Button)
        {
           profile = "ShellButtonProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "205 -185";
           extent = "140 20";
           minExtent = "26 27";
           visible = "1";
           hideCursor = "0";
           bypassHideCursor = "0";
           command = "RequestTeleport(1);";
           helpTag = "0";
           text = "Select as Destination";
           maxLength = "255";
        };

        new GuiTextCtrl(Teleporter2Name)
        {
           profile = "GuiDashTextProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "400 -245";
           extent = "250 15";
           minExtent = "8 8";
           visible = "1";
           text = "Name of Teleporter 2";
        };

        new GuiTextCtrl(Teleporter2Owner)
        {
           profile = "GuiDashTextProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "400 -230";
           extent = "250 15";
           minExtent = "8 8";
           visible = "1";
           text = "Owner of Teleporter 1";
        };

        new GuiTextCtrl(Teleporter2Status)
        {
           profile = "GuiDashTextProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "400 -215";
           extent = "250 15";
           minExtent = "8 8";
           visible = "1";
           text = "Status: ";
        };

        new GuiTextCtrl(Teleporter2PowerLevel)
        {
           profile = "GuiDashTextProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "400 -200";
           extent = "250 15";
           minExtent = "8 8";
           visible = "1";
           text = "Power Level: ";
        };

        new ShellBitmapButton(Teleporter2Button)
        {
           profile = "ShellButtonProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "450 -185";
           extent = "140 20";
           minExtent = "26 27";
           visible = "1";
           hideCursor = "0";
           bypassHideCursor = "0";
           command = "RequestTeleport(2);";
           helpTag = "0";
           text = "Select as Destination";
           maxLength = "255";
        };

        new GuiTextCtrl(Teleporter3Name)
        {
           profile = "GuiDashTextProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "150 -145";
           extent = "250 15";
           minExtent = "8 8";
           visible = "1";
           text = "Name of Teleporter 2";
        };

        new GuiTextCtrl(Teleporter3Owner)
        {
           profile = "GuiDashTextProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "150 -130";
           extent = "250 15";
           minExtent = "8 8";
           visible = "1";
           text = "Owner of Teleporter 1";
        };

        new GuiTextCtrl(Teleporter3Status)
        {
           profile = "GuiDashTextProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "150 -115";
           extent = "250 15";
           minExtent = "8 8";
           visible = "1";
           text = "Status: ";
        };

        new GuiTextCtrl(Teleporter3PowerLevel)
        {
           profile = "GuiDashTextProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "150 -100";
           extent = "250 15";
           minExtent = "8 8";
           visible = "1";
           text = "Power Level: ";
        };

        new ShellBitmapButton(Teleporter3Button)
        {
           profile = "ShellButtonProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "205 -85";
           extent = "140 20";
           minExtent = "26 27";
           visible = "1";
           hideCursor = "0";
           bypassHideCursor = "0";
           command = "RequestTeleport(3);";
           helpTag = "0";
           text = "Select as Destination";
           maxLength = "255";
        };

        new GuiTextCtrl(Teleporter4Name)
        {
           profile = "GuiDashTextProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "400 -145";
           extent = "250 15";
           minExtent = "8 8";
           visible = "1";
           text = "Name of Teleporter 2";
        };

        new GuiTextCtrl(Teleporter4Owner)
        {
           profile = "GuiDashTextProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "400 -130";
           extent = "250 15";
           minExtent = "8 8";
           visible = "1";
           text = "Owner of Teleporter 1";
        };

        new GuiTextCtrl(Teleporter4Status)
        {
           profile = "GuiDashTextProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "400 -115";
           extent = "250 15";
           minExtent = "8 8";
           visible = "1";
           text = "Status: ";
        };

        new GuiTextCtrl(Teleporter4PowerLevel)
        {
           profile = "GuiDashTextProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "400 -100";
           extent = "250 15";
           minExtent = "8 8";
           visible = "1";
           text = "Power Level: ";
        };

        new ShellBitmapButton(Teleporter4Button)
        {
           profile = "ShellButtonProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "450 -85";
           extent = "140 20";
           minExtent = "26 27";
           visible = "1";
           hideCursor = "0";
           bypassHideCursor = "0";
           command = "RequestTeleport(4);";
           helpTag = "0";
           text = "Select as Destination";
           maxLength = "255";
        };

        new GuiTextCtrl(Teleporter5Name)
        {
           profile = "GuiDashTextProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "150 -45";
           extent = "250 15";
           minExtent = "8 8";
           visible = "1";
           text = "Name of Teleporter 2";
        };

        new GuiTextCtrl(Teleporter5Owner)
        {
           profile = "GuiDashTextProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "150 -30";
           extent = "250 15";
           minExtent = "8 8";
           visible = "1";
           text = "Owner of Teleporter 1";
        };

        new GuiTextCtrl(Teleporter5Status)
        {
           profile = "GuiDashTextProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "150 -15";
           extent = "250 15";
           minExtent = "8 8";
           visible = "1";
           text = "Status: ";
        };

        new GuiTextCtrl(Teleporter5PowerLevel)
        {
           profile = "GuiDashTextProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "150 0";
           extent = "250 15";
           minExtent = "8 8";
           visible = "1";
           text = "Power Level: ";
        };

        new ShellBitmapButton(Teleporter5Button)
        {
           profile = "ShellButtonProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "205 15";
           extent = "140 20";
           minExtent = "26 27";
           visible = "1";
           hideCursor = "0";
           bypassHideCursor = "0";
           command = "RequestTeleport(5);";
           helpTag = "0";
           text = "Select as Destination";
           maxLength = "255";
        };

        new GuiTextCtrl(Teleporter6Name)
        {
           profile = "GuiDashTextProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "400 -45";
           extent = "250 15";
           minExtent = "8 8";
           visible = "1";
           text = "Name of Teleporter 2";
        };

        new GuiTextCtrl(Teleporter6Owner)
        {
           profile = "GuiDashTextProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "400 -30";
           extent = "250 15";
           minExtent = "8 8";
           visible = "1";
           text = "Owner of Teleporter 1";
        };

        new GuiTextCtrl(Teleporter6Status)
        {
           profile = "GuiDashTextProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "400 -15";
           extent = "250 15";
           minExtent = "8 8";
           visible = "1";
           text = "Status: ";
        };

        new GuiTextCtrl(Teleporter6PowerLevel)
        {
           profile = "GuiDashTextProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "400 0";
           extent = "250 15";
           minExtent = "8 8";
           visible = "1";
           text = "Power Level: ";
        };

        new ShellBitmapButton(Teleporter6Button)
        {
           profile = "ShellButtonProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "450 15";
           extent = "140 20";
           minExtent = "26 27";
           visible = "1";
           hideCursor = "0";
           bypassHideCursor = "0";
           command = "RequestTeleport(6);";
           helpTag = "0";
           text = "Select as Destination";
           maxLength = "255";
        };

        new ShellBitmapButton(BackButton)
        {
           profile = "ShellButtonProfile";
           horizSizing = "right";
           vertSizing = "top";
           position = "325 65";
           extent = "140 20";
           minExtent = "26 27";
           visible = "1";
           hideCursor = "0";
           bypassHideCursor = "0";
           command = "TeleportMenu.close(true);";
           helpTag = "0";
           text = "Close";
           maxLength = "255";
        };
      };

      GuiGroup.add(%HUD);
   }
   CurrentTeleporterName.setText("Currently at Teleporter: " @ $CurrentTeleporterName);
   CurrentTeleporterowner.setText("Owned by: " @ $CurrentTeleporterOwner);

   ShowHUD('TeleportMenu');
   schedule(1125, 0, clientCmdUpdateTeleportMenu);
}

function clientCmdUpdateTeleportMenu()
{
   // If the Menu is not open, then ignore the player
   if (isObject(TeleportMenu) == false)
      return;

   CurrentTeleporterPowerLevel.setText("Power Level: " @ $CurrentTeleporterPowerLevel @ "%");

   %i = 1;

   while (%i <= 6)
   {   
      %Name = $TeleporterName[%i];
      %Owner = $TeleporterOwner[%i];
      %Status = $TeleporterStatus[%i];
      %PowerLevel = $TeleporterPowerLevel[%i];

      switch(%i)
      {
         case 1:
            if (%Status $= "Destroyed" || %Status $= "")
            {
               Teleporter1Name.setVisible(false);
               Teleporter1Owner.setVisible(false);
               Teleporter1Status.setVisible(false);
               Teleporter1PowerLevel.setVisible(false);
               Teleporter1Button.setVisible(false);

               %i++;
               continue;
            } else {
               Teleporter1Name.setVisible(true);
               Teleporter1Owner.setVisible(true);
               Teleporter1Status.setVisible(true);
               Teleporter1PowerLevel.setVisible(true);
            }

            if (%Status $= "Ready")
               Teleporter1Button.setVisible(true);
            else               
               Teleporter1Button.setVisible(false);

            Teleporter1Name.setText(%Name);
            Teleporter1Owner.setText("Owned by: " @ %Owner);
            Teleporter1Status.setText("Status: " @ %Status);
            Teleporter1PowerLevel.setText("Power Level: " @ %PowerLevel);

         case 2:
            if (%Status $= "Destroyed" || %Status $= "")
            {
               Teleporter2Name.setVisible(false);
               Teleporter2Owner.setVisible(false);
               Teleporter2Status.setVisible(false);
               Teleporter2PowerLevel.setVisible(false);
               Teleporter2Button.setVisible(false);

               %i++;
               continue;
            } else {
               Teleporter2Name.setVisible(true);
               Teleporter2Owner.setVisible(true);
               Teleporter2Status.setVisible(true);
               Teleporter2PowerLevel.setVisible(true);
            }

            if (%Status $= "Ready")
               Teleporter2Button.setVisible(true);
            else               
               Teleporter2Button.setVisible(false);

            Teleporter2Name.setText(%Name);
            Teleporter2Owner.setText("Owned by: " @ %Owner);
            Teleporter2Status.setText("Status: " @ %Status);
            Teleporter2PowerLevel.setText("Power Level: " @ %PowerLevel);

         case 3:
            if (%Status $= "Destroyed" || %Status $= "")
            {
               Teleporter3Name.setVisible(false);
               Teleporter3Owner.setVisible(false);
               Teleporter3Status.setVisible(false);
               Teleporter3PowerLevel.setVisible(false);
               Teleporter3Button.setVisible(false);

               %i++;
               continue;
            } else {
               Teleporter3Name.setVisible(true);
               Teleporter3Owner.setVisible(true);
               Teleporter3Status.setVisible(true);
               Teleporter3PowerLevel.setVisible(true);
            }

            if (%Status $= "Ready")
               Teleporter3Button.setVisible(true);
            else               
               Teleporter3Button.setVisible(false);

            Teleporter3Name.setText(%Name);
            Teleporter3Owner.setText("Owned by: " @ %Owner);
            Teleporter3Status.setText("Status: " @ %Status);
            Teleporter3PowerLevel.setText("Power Level: " @ %PowerLevel);

         case 4:
            if (%Status $= "Destroyed" || %Status $= "")
            {
               Teleporter4Name.setVisible(false);
               Teleporter4Owner.setVisible(false);
               Teleporter4Status.setVisible(false);
               Teleporter4PowerLevel.setVisible(false);
               Teleporter4Button.setVisible(false);

               %i++;
               continue;
            } else {
               Teleporter4Name.setVisible(true);
               Teleporter4Owner.setVisible(true);
               Teleporter4Status.setVisible(true);
               Teleporter4PowerLevel.setVisible(true);
            }

            if (%Status $= "Ready")
               Teleporter4Button.setVisible(true);
            else               
               Teleporter4Button.setVisible(false);

            Teleporter4Name.setText(%Name);
            Teleporter4Owner.setText("Owned by: " @ %Owner);
            Teleporter4Status.setText("Status: " @ %Status);
            Teleporter4PowerLevel.setText("Power Level: " @ %PowerLevel);

         case 5:
            if (%Status $= "Destroyed" || %Status $= "")
            {
               Teleporter5Name.setVisible(false);
               Teleporter5Owner.setVisible(false);
               Teleporter5Status.setVisible(false);
               Teleporter5PowerLevel.setVisible(false);
               Teleporter5Button.setVisible(false);

               %i++;
               continue;
            } else {
               Teleporter5Name.setVisible(true);
               Teleporter5Owner.setVisible(true);
               Teleporter5Status.setVisible(true);
               Teleporter5PowerLevel.setVisible(true);
            }

            if (%Status $= "Ready")
               Teleporter5Button.setVisible(true);
            else               
               Teleporter5Button.setVisible(false);

            Teleporter5Name.setText(%Name);
            Teleporter5Owner.setText("Owned by: " @ %Owner);
            Teleporter5Status.setText("Status: " @ %Status);
            Teleporter5PowerLevel.setText("Power Level: " @ %PowerLevel);

         case 6:
            if (%Status $= "Destroyed" || %Status $= "")
            {
               Teleporter6Name.setVisible(false);
               Teleporter6Owner.setVisible(false);
               Teleporter6Status.setVisible(false);
               Teleporter6PowerLevel.setVisible(false);
               Teleporter6Button.setVisible(false);

               %i++;
               continue;
            } else {
               Teleporter6Name.setVisible(true);
               Teleporter6Owner.setVisible(true);
               Teleporter6Status.setVisible(true);
               Teleporter6PowerLevel.setVisible(true);
            }

            if (%Status $= "Ready")
               Teleporter6Button.setVisible(true);
            else               
               Teleporter6Button.setVisible(false);

            Teleporter6Name.setText(%Name);
            Teleporter6Owner.setText("Owned by: " @ %Owner);
            Teleporter6Status.setText("Status: " @ %Status);
            Teleporter6PowerLevel.setText("Power Level: " @ %PowerLevel);

         default :
      }

      %i++;
   }
}

function TeleportMenu::setUpHud(%this, %tag)
{

}

function TeleportMenu::loadHud(%this, %tag)
{
   $Hud[%tag] = TeleportMenu;
   $Hud[%tag].childGui = ENG_Root;
   $Hud[%tag].parent = ENG_Root;
}

function TeleportMenu::open(%this)
{
   parent::open(%this);
}

function TeleportMenu::close(%this, %Unlock)
{
   HideHud('TeleportMenu');
   TeleportMenu.delete();
   CursorOff();

   if (%UnLock == true)
      commandToServer('UnLockPlayer');
}

function RequestTeleport(%TeleporterNo)
{
   commandToServer('SelectTeleporter', %TeleporterNo);
   TeleportMenu.close('TeleportMenu', true);
}
