//-------------------------------------------------------------------
//
//  This code is copyright 2001 by G5 Software.
//  Any unauthorized usage, either in part or in whole of this code
//  is strictly prohibited. Violators WILL be prosecuted to the
//  maximum extent allowed by law.
//
//-------------------------------------------------------------------

//
//  Mission Menu
//

class CMissionMenu extends CBaseMenu
{
  // methods

  void CMissionMenu()
  {
  }

  string GetMenuType()
  {
    return "MissionMenu";
  }

  //
  //  Menu construction happens here
  //

  void InitMenu()
  {
    CreateMenuButtonGroup(MenuWidth, MenuSpacing);

    float fButtonX      = (1.0 - fButtonWidth) / 2;
    float fButtonY      = 0.2;

    //
    //  'Quit to main menu' button
    //

    CreateSubMenu(
      str_QuitToMainMenuButton,
      "ID_QUIT_TO_MAIN_MENU",
      fButtonX,
      fButtonY,
      fButtonWidth,
      fButtonHeight,
      "MissionMenu_InitQuitMenu");

    fButtonY = fButtonY + fButtonHeight + fVertSpacing;

    //
    //  'Resume game' button
    //

    CreateTextButton(
      str_BackToTheGameButton,
      "ID_RESUME_GAME",
      fButtonX,
      fButtonY,
      fButtonWidth,
      fButtonHeight);

    fButtonY = fButtonY + fButtonHeight + fVertSpacing;

    //
    //  'Restart mission' button
    //

    CreateSubMenu(
      str_RestartMissionButton,
      "ID_RESTART_MISSION_MENU",
      fButtonX,
      fButtonY,
      fButtonWidth,
      fButtonHeight,
      "MissionMenu_InitRestartMissionMenu");

    fButtonY = fButtonY + fButtonHeight + fVertSpacing;

    //
    //  Settings button
    //

    CreateSubMenu(
      str_SettingsButton,
      "ID_SETTINGS",
      fButtonX,
      fButtonY,
      fButtonWidth,
      fButtonHeight,
      "BaseMenu_InitSettingsMenu");

    fButtonY = fButtonY + fButtonHeight + fVertSpacing;
  }

  //
  //  Called on user move of menu button
  //

  void MenuButtonMoved(string _id)
  {
    BaseMenu_MenuButtonMoved(_id);
  }

  //
  //  Called on user click on menu button
  //

  void MenuButtonClicked(string _id)
  {
    BaseMenu_MenuButtonClicked(_id);

    if ("ID_FINISH_MISSION" == _id)
    {
      Core_SendEventTo(
        SOID_MissionController,
        "OnHideMissionStatus");

      Core_SendEventTo(
        SOID_MissionController,
        "OnQuitMission");

      Core_SendEventTo(
        SOID_GameController,
        "OnQuitMission");
    }
    else
    if ("ID_SURE_QUIT_TO_MAIN_MENU" == _id)
    {
      Core_SendEventTo(
        SOID_MissionController,
        "OnHideMissionMenu");

      Core_SendEventTo(
        SOID_MissionController,
        "OnQuitMission");

      Core_SendEventTo(
        SOID_GameController,
        "OnQuitMission");
    }
    else
    if ("ID_RESTART_MISSION" == _id)
    {
      // can be called from mission menu or mission status screen
      Core_SendEventTo(
        SOID_MissionController,
        "OnHideMissionMenu");

      // can be called from mission menu or mission status screen
      Core_SendEventTo(
        SOID_MissionController,
        "OnHideMissionStatus");

      Core_SendEventTo(
        SOID_MissionController,
        "OnQuitMission");

      Core_SendEventTo(
        SOID_GameController,
        "OnRestartMission");
    }
    else
    if ("ID_RESUME_GAME" == _id)
    {
      Core_SendEventTo(SOID_MissionController, "OnHideMissionMenu");
    }
  }

  //
  //  Submenus construction
  //

  //
  //  Missions menu
  //

  void MissionMenu_InitQuitMenu()
  {
    //
    //  Text control with objectives
    //

    float fMessageWidth  = GetTextWidth(str_QuitQuestion);
    float fMessageHeight = GetTextHeight(str_QuitQuestion);

    CreateTextControl(
      str_QuitQuestion,
      "ID_QUESTION",
      (1.0 - fMessageWidth) / 2,
      0.2,
      fMessageWidth,
      fMessageHeight
    );

    CreateMenuButtonGroup(MenuWidth, MenuSpacing);

    float fButtonX      = (1.0 - fButtonWidth) / 2;
    float fButtonY      = 0.2 + fMessageHeight + fVertSpacing;

    //
    //  Back button
    //

    CreateTextButton(
      str_NoButton,
      "ID_BACK",
      fButtonX,
      fButtonY,
      fButtonWidth,
      fButtonHeight);

    fButtonY = fButtonY + fButtonHeight + fVertSpacing;

    //
    //  Test mission button
    //

    CreateTextButton(
      str_YesButton,
      "ID_SURE_QUIT_TO_MAIN_MENU",
      fButtonX,
      fButtonY,
      fButtonWidth,
      fButtonHeight);

    fButtonY = fButtonY + fButtonHeight + fVertSpacing;
  }

  void MissionMenu_InitRestartMissionMenu()
  {
    //
    //  Text control with objectives
    //

    float fMessageWidth  = GetTextWidth(str_QuitQuestion);
    float fMessageHeight = GetTextHeight(str_QuitQuestion);

    CreateTextControl(
      str_QuitQuestion,
      "ID_QUESTION",
      (1.0 - fMessageWidth) / 2,
      0.2,
      fMessageWidth,
      fMessageHeight
    );

    CreateMenuButtonGroup(MenuWidth, MenuSpacing);

    float fButtonX      = (1.0 - fButtonWidth) / 2;
    float fButtonY      = 0.2 + fMessageHeight + fVertSpacing;

    //
    //  Back button
    //

    CreateTextButton(
      str_NoButton,
      "ID_BACK",
      fButtonX,
      fButtonY,
      fButtonWidth,
      fButtonHeight);

    fButtonY = fButtonY + fButtonHeight + fVertSpacing;

    //
    //  Test mission button
    //

    CreateTextButton(
      str_YesButton,
      "ID_RESTART_MISSION",
      fButtonX,
      fButtonY,
      fButtonWidth,
      fButtonHeight);

    fButtonY = fButtonY + fButtonHeight + fVertSpacing;
  }
};
