//-------------------------------------------------------------------
//
//  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.
//
//-------------------------------------------------------------------

//
//  Game Menu
//


class CGameMenu extends CBaseMenu
{
  // methods

  void CGameMenu()
  {
  }

  string GetMenuType()
  {
    return "GameMenu";
  }

  //
  //  Menu construction happens here
  //

  void InitMenu()
  {
    //
    //  Background
    //

    CreateBitmapControl(
      "Resources/Splash.tex",
      "ID_BITMAP",
      0.0,
      0.0,
      1.0,
      1.0
    );

    // current build sign

    string CurrentBuild   = str_VersionNumber;
    float  fMessageWidth  = GetTextWidth(CurrentBuild);
    float  fMessageHeight = GetTextHeight(CurrentBuild);

    CreateTextControl(
      CurrentBuild,
      "ID_CURRENT_BUILD",
      (1.0 - fMessageWidth) / 2,
      0.05,
      fMessageWidth,
      fMessageHeight,
      color(0.7, 0.7, 0.7)
    );

    // menu

    CreateMenuButtonGroup(MenuWidth, MenuSpacing);

    float fButtonX      = 0.1375;
    float fButtonY      = 0.66;
    float fButtonWidth  = 0.35;

    //
    //  Start new game button
    //

    CreateBitmapSubMenu(
      "ID_START_GAME",
      nStartButtonNormMat,
      nStartButtonHiMat,
      0.253,
      0.914,
      fStdButtonWidth,
      fStdButtonHeight,
      true,
      "GameMenu_InitMissionsMenu"
    );

    //
    //  Settings button
    //

    CreateBitmapSubMenu(
      "ID_SETTINGS",
      nSettingsButtonNormMat,
      nSettingsButtonHiMat,
      0.378,
      0.914,
      fStdButtonWidth,
      fStdButtonHeight,
      true,
      "BaseMenu_InitSettingsMenu"
    );

    //
    //  Credits button
    //

    CreateBitmapSubMenu(
      "ID_CREDITS",
      nCreditsButtonNormMat,
      nCreditsButtonHiMat,
      0.503,
      0.914,
      fStdButtonWidth,
      fStdButtonHeight,
      true,
      "ShowCredits"
    );

    //
    //  Quit button
    //

    CreateBitmapSubMenu(
      "ID_QUIT_MENU",
      nQuitButtonNormMat,
      nQuitButtonHiMat,
      0.628,
      0.914,
      fStdButtonWidth,
      fStdButtonHeight,
      true,
      "GameMenu_InitQuitMenu"
    );
  }

  //
  //  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);

    //
    //  All briefings ids
    //

    if ("ID_PAGEUP" == _id)
      SendCommandToControl("ID_MISSION_DESCRIPTION", "PageUp");
    else
    if ("ID_PAGEDN" == _id)
      SendCommandToControl("ID_MISSION_DESCRIPTION", "PageDown");
    else


    if ("ID_QUIT" == _id)
    {
      Core_SendEventTo(SOID_GameController, "OnQuitGame");
    }
    else
    if ("ID_RESTART_MISSION" == _id)
    {
      Core_SendEventTo(
        SOID_GameController,
        "OnRestartMission");
    }
    else
    if ("ID_START_MISSION_1" == _id)
    {
      // go to the loading screen
      GoToSubMenu("GameMenu_LoadScreen");

      // load mission
      Core_SendEventTo(SOID_GameController, "OnLoadMission", "CDestroyMission", 0);
    }
    else
    if ("ID_START_MISSION_2" == _id)
    {
      // go to the loading screen
      GoToSubMenu("GameMenu_LoadScreen");

      // load mission
      Core_SendEventTo(SOID_GameController, "OnLoadMission", "CConvoyMission", 1);
    }
    else
    if ("ID_START_MISSION_3" == _id)
    {
      // go to the loading screen
      GoToSubMenu("GameMenu_LoadScreen");

      // load mission
      Core_SendEventTo(SOID_GameController, "OnLoadMission", "CFireworksMission", 2);
    }
    else
    if ("ID_START_MISSION_4" == _id)
    {
      // go to the loading screen
      GoToSubMenu("GameMenu_LoadScreen");

      // load mission
      Core_SendEventTo(SOID_GameController, "OnLoadMission", "CDestroyGuardedTarget", 3);
    }
    else
    if ("ID_START_MISSION_5" == _id)
    {
      // go to the loading screen
      GoToSubMenu("GameMenu_LoadScreen");

      // load mission
      Core_SendEventTo(SOID_GameController, "OnLoadMission", "CClearVillageMission", 4);
    }
    else
    if ("ID_START_MISSION_6" == _id)
    {
      // go to the loading screen
      GoToSubMenu("GameMenu_LoadScreen");

      // load mission
      Core_SendEventTo(SOID_GameController, "OnLoadMission", "CPreventVillageDestructionMission", 5);
    }
    else
    if ("ID_START_MISSION_7" == _id)
    {
      // go to the loading screen
      GoToSubMenu("GameMenu_LoadScreen");

      // load mission
      Core_SendEventTo(SOID_GameController, "OnLoadMission", "CBreakRingAndConvoyMission", 6);
    }
    else
    if ("ID_START_MISSION_8" == _id)
    {
      // go to the loading screen
      GoToSubMenu("GameMenu_LoadScreen");

      // load mission
      Core_SendEventTo(SOID_GameController, "OnLoadMission", "CInterceptJeepMission", 7);
    }
    else
    if ("ID_START_MISSION_9" == _id)
    {
      // go to the loading screen
      GoToSubMenu("GameMenu_LoadScreen");

      // load mission
      Core_SendEventTo(SOID_GameController, "OnLoadMission", "CTankBattleMission", 8);
    }
    else
    if ("ID_START_MISSION_10" == _id)
    {
      // go to the loading screen
      GoToSubMenu("GameMenu_LoadScreen");

      // load mission
      Core_SendEventTo(SOID_GameController, "OnLoadMission", "CInterceptConvoyMission", 9);
    }
    else
    if ("ID_START_MISSION_11" == _id)
    {
      // go to the loading screen
      GoToSubMenu("GameMenu_LoadScreen");

      // load mission
      Core_SendEventTo(SOID_GameController, "OnLoadMission", "CDrawAttentionMission", 10);
    }
    else
    if ("ID_START_MISSION_12" == _id)
    {
      // go to the loading screen
      GoToSubMenu("GameMenu_LoadScreen");

      // load mission
      Core_SendEventTo(SOID_GameController, "OnLoadMission", "CEliminatePartisansMission", 11);
    }
    else
    if ("ID_START_MISSION_13" == _id)
    {
      // go to the loading screen
      GoToSubMenu("GameMenu_LoadScreen");

      // load mission
      Core_SendEventTo(SOID_GameController, "OnLoadMission", "CSupportAerialAttackMission", 12);
    }
    else
    if ("ID_START_MISSION_14" == _id)
    {
      // go to the loading screen
      GoToSubMenu("GameMenu_LoadScreen");

      // load mission
      Core_SendEventTo(SOID_GameController, "OnLoadMission", "CEliminateDescentMission", 13);
    }
    else
    if ("ID_START_MISSION_15" == _id)
    {
      // go to the loading screen
      GoToSubMenu("GameMenu_LoadScreen");

      // load mission
      Core_SendEventTo(SOID_GameController, "OnLoadMission", "CSurvivalMission", 14);
    }
    else
    if ("ID_CREDITS_SCREEN" == _id)
    {
      m_nCreditsScreenNumber = (m_nCreditsScreenNumber + 1) % str_CreditsScreens.size();
      if (0 == m_nCreditsScreenNumber)
        GoToRootMenu();
      else
        GoToSubMenu("ShowCredits");
    }
  }

  //
  //  Submenus construction
  //

  //
  //  Quit confirmation screen
  //

  void GameMenu_InitQuitMenu()
  {
    //
    //  Background
    //

    CreateBitmapControl(
      "Resources/Splash.tex",
      "ID_BITMAP",
      0.0,
      0.0,
      1.0,
      1.0
    );

    //
    //  Text control with objectives
    //

    float fMessageWidth  = GetTextWidth(str_QuitGameQuestion);
    float fMessageHeight = GetTextHeight(str_QuitGameQuestion);
    float fBasePosition  = 0.7f;

    CreateTextControl(
      str_QuitGameQuestion,
      "ID_QUESTION",
      (1.0 - fMessageWidth) / 2,
      fBasePosition,
      fMessageWidth,
      fMessageHeight
    );

    CreateMenuButtonGroup(MenuWidth, MenuSpacing);

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

    //
    //  Back button
    //

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

    fButtonY = fButtonY + fButtonHeight + fVertSpacing;

    //
    //  Test mission button
    //

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

    fButtonY = fButtonY + fButtonHeight + fVertSpacing;
  }


  //
  //  Loading screen
  //

  void GameMenu_LoadScreen()
  {
    //
    //  Background
    //

    CreateBitmapControl(
      "Resources/Menu_Mission_Loading.tex",
      "ID_BITMAP",
      0.0,
      0.0,
      1.0,
      1.0
    );

    float fProgressWidth  = 0.39;
    float fProgressHeight = fButtonHeight;

    float fProgressX = (1.0 - fProgressWidth) / 2;
    float fProgressY = 0.9;

    CreateProgressBar(
      "ID_LOAD_PROGRESS_BAR",
      color(1.0, 1.0, 1.0),
      fProgressX,
      fProgressY,
      fProgressWidth,
      fProgressHeight);
  }

  //
  //  Missions menu
  //

  // array of mission button positions on screen

  array m_MissionButtonX =
    array(
      402.0, 610.0, 177.0, 417.0, 67.0, 738.0, 387.0, 738.0, 417.0, 738.0, 67.0, 387.0, 387.0, 67.0, 417.0
    );

  array m_MissionButtonY =
    array(
      353.0, 290.0, 417.0, 226.0, 482.0, 226.0, 482.0, 160.0, 160.0, 97.0, 546.0, 546.0, 610.0, 610.0, 97.0
    );

  float GetMissionButtonX(int i)
  {
    return (m_MissionButtonX[i] - 10.0) / 1024.0;
  }

  float GetMissionButtonY(int i)
  {
    return (m_MissionButtonY[i] - 3.0) / 768.0;
  }

  void DrawMedal(int _mission)
  {
    int state = Core_CallFunction(
                 SOID_GameController,
                 "GetMissionState",
                 _mission
               );

    if (state == 0 || state == 1)
      return;

    int material = 4 + (state - 2);

    CreateMaterialControl(
      "Common/Medals.skin",
      material,
      "ID_MEDAL" + _mission,
      GetMissionButtonX(_mission) - 0.023,
      GetMissionButtonY(_mission) + 0.005,
      0.027,
      0.035
    );
  }

  void DrawOrders()
  {

    float MedalWidth  = 0.07;
    float MedalHeight = 0.15;

    bool  bHeliMedal  = true;
    bool  bBronzeStar = true;
    bool  bSilverStar = true;
    bool  bGoldStar   = true;

    for (int i = 0; i < 15; i = i + 1)
    {
      int state = Core_CallFunction(
                    SOID_GameController,
                    "GetMissionState",
                    i
                  );

      if (state < 2)
      {
        bHeliMedal  = false;
        bBronzeStar = false;
        bSilverStar = false;
        bGoldStar   = false;
      }

      if (state < 3)
      {
        bBronzeStar = false;
        bSilverStar = false;
        bGoldStar   = false;
      }

      if (state < 4)
      {
        bSilverStar = false;
        bGoldStar   = false;
      }

      if (state < 5)
      {
        bGoldStar   = false;
      }
    }

    if (!bHeliMedal)
      return;

    CreateMaterialControl(
      "Common/Medals.skin",
      0,
      "ID_BIG_MEDAL_0",
      0.043,
      0.127,
      MedalWidth,
      MedalHeight
    );

    float MedalsX    = 0.043 + 0.079;
    float MedalsY    = 0.127;
    float MedalsDist = 0.073;

    if (!bBronzeStar)
      return;

    CreateMaterialControl(
      "Common/Medals.skin",
      1,
      "ID_BIG_MEDAL_1",
      MedalsX,
      MedalsY,
      MedalWidth,
      MedalHeight
    );

    MedalsX = MedalsX + MedalsDist;

    if (!bSilverStar)
      return;

    CreateMaterialControl(
      "Common/Medals.skin",
      2,
      "ID_BIG_MEDAL_2",
      MedalsX,
      MedalsY,
      MedalWidth,
      MedalHeight
    );

    MedalsX = MedalsX + MedalsDist;

    if (!bGoldStar)
      return;

    CreateMaterialControl(
      "Common/Medals.skin",
      3,
      "ID_BIG_MEDAL_3",
      MedalsX,
      MedalsY,
      MedalWidth,
      MedalHeight
    );
  }

  void GameMenu_InitMissionsMenu()
  {
    //
    //  Background
    //

    CreateBitmapControl(
      "Resources/SelectMission.tex",
      "ID_BITMAP",
      0.0,
      0.0,
      1.0,
      1.0
    );

    string CurrentDifficulty;
    int diff_level = GetDifficultyLevel();
    if (diff_level == 0)
      CurrentDifficulty = str_Difficulty + str_Easy;
    else
    if (diff_level == 1)
      CurrentDifficulty = str_Difficulty + str_Medium;
    else
    if (diff_level == 2)
      CurrentDifficulty = str_Difficulty + str_Hard;
    else
    if (diff_level == 3)
      CurrentDifficulty = str_Difficulty + str_Nightmare;

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

    CreateTextControl(
      CurrentDifficulty,
      "ID_CURRENT_DIFFICULTY",
      0.05,
      0.3,
      fMessageWidth,
      fMessageHeight,
      color(0.89, 0.5, 0.41)
    );

    CreateMenuButtonGroup(MenuWidth, MenuSpacing);

    bool  bEnabled;

    float fMissionButtonWidth  = 0.25;
    float fMissionButtonHeight = 0.03125 / 0.75;

    DrawOrders();

    //
    //  Mission 1 button
    //

    int nMissMat = 16;

    bEnabled = Core_CallFunction(
                 SOID_GameController,
                 "GetMissionState",
                 0
               );

    CreateBitmapSubMenu(
      "ID_MISSION_1",
      nMissMat,
      nMissMat + 1,
      GetMissionButtonX(0),
      GetMissionButtonY(0),
      fMissionButtonWidth,
      fMissionButtonHeight,
      bEnabled,
      "GameMenu_InitMission1Briefing"
    );

    DrawMedal(0);

    nMissMat = nMissMat + 2;

    //
    //  Mission 2 button
    //

    bEnabled = Core_CallFunction(
                 SOID_GameController,
                 "GetMissionState",
                 1
               );

    CreateBitmapSubMenu(
      "ID_MISSION_2",
      nMissMat,
      nMissMat + 1,
      GetMissionButtonX(1),
      GetMissionButtonY(1),
      fMissionButtonWidth,
      fMissionButtonHeight,
      bEnabled,
      "GameMenu_InitMission2Briefing"
    );

    DrawMedal(1);

    nMissMat = nMissMat + 2;

    //
    //  Mission 3 button
    //

    bEnabled = Core_CallFunction(
                 SOID_GameController,
                 "GetMissionState",
                 2
               );

    CreateBitmapSubMenu(
      "ID_MISSION_3",
      nMissMat,
      nMissMat + 1,
      GetMissionButtonX(2),
      GetMissionButtonY(2),
      fMissionButtonWidth,
      fMissionButtonHeight,
      bEnabled,
      "GameMenu_InitMission3Briefing"
    );

    DrawMedal(2);

    nMissMat = nMissMat + 2;

    //
    //  Mission 4 button
    //

    bEnabled = Core_CallFunction(
                 SOID_GameController,
                 "GetMissionState",
                 3
               );

    CreateBitmapSubMenu(
      "ID_MISSION_4",
      nMissMat,
      nMissMat + 1,
      GetMissionButtonX(3),
      GetMissionButtonY(3),
      fMissionButtonWidth,
      fMissionButtonHeight,
      bEnabled,
      "GameMenu_InitMission4Briefing"
    );

    DrawMedal(3);

    nMissMat = nMissMat + 2;

    //
    //  Mission 5 button
    //

    bEnabled = Core_CallFunction(
                 SOID_GameController,
                 "GetMissionState",
                 4
               );

    CreateBitmapSubMenu(
      "ID_MISSION_5",
      nMissMat,
      nMissMat + 1,
      GetMissionButtonX(4),
      GetMissionButtonY(4),
      fMissionButtonWidth,
      fMissionButtonHeight,
      bEnabled,
      "GameMenu_InitMission5Briefing"
    );

    DrawMedal(4);

    nMissMat = nMissMat + 2;

    //
    //  Mission 6 button
    //

    bEnabled = Core_CallFunction(
                 SOID_GameController,
                 "GetMissionState",
                 5
               );

    CreateBitmapSubMenu(
      "ID_MISSION_6",
      nMissMat,
      nMissMat + 1,
      GetMissionButtonX(5),
      GetMissionButtonY(5),
      fMissionButtonWidth,
      fMissionButtonHeight,
      bEnabled,
      "GameMenu_InitMission6Briefing"
    );

    DrawMedal(5);

    nMissMat = nMissMat + 2;

    //
    //  Mission 7 button
    //

    bEnabled = Core_CallFunction(
                 SOID_GameController,
                 "GetMissionState",
                 6
               );

    CreateBitmapSubMenu(
      "ID_MISSION_7",
      nMissMat,
      nMissMat + 1,
      GetMissionButtonX(6),
      GetMissionButtonY(6),
      fMissionButtonWidth,
      fMissionButtonHeight,
      bEnabled,
      "GameMenu_InitMission7Briefing"
    );

    DrawMedal(6);

    nMissMat = nMissMat + 2;

    //
    //  Mission 8 button
    //

    bEnabled = Core_CallFunction(
                 SOID_GameController,
                 "GetMissionState",
                 7
               );

    CreateBitmapSubMenu(
      "ID_MISSION_8",
      nMissMat,
      nMissMat + 1,
      GetMissionButtonX(7),
      GetMissionButtonY(7),
      fMissionButtonWidth,
      fMissionButtonHeight,
      bEnabled,
      "GameMenu_InitMission8Briefing"
    );

    DrawMedal(7);

    nMissMat = nMissMat + 2;

    //
    //  Mission 9 button
    //

    bEnabled = Core_CallFunction(
                 SOID_GameController,
                 "GetMissionState",
                 8
               );

    CreateBitmapSubMenu(
      "ID_MISSION_9",
      nMissMat,
      nMissMat + 1,
      GetMissionButtonX(8),
      GetMissionButtonY(8),
      fMissionButtonWidth,
      fMissionButtonHeight,
      bEnabled,
      "GameMenu_InitMission9Briefing"
    );

    DrawMedal(8);

    nMissMat = nMissMat + 2;

    //
    //  Mission 10 button
    //

    bEnabled = Core_CallFunction(
                 SOID_GameController,
                 "GetMissionState",
                 9
               );

    CreateBitmapSubMenu(
      "ID_MISSION_10",
      nMissMat,
      nMissMat + 1,
      GetMissionButtonX(9),
      GetMissionButtonY(9),
      fMissionButtonWidth,
      fMissionButtonHeight,
      bEnabled,
      "GameMenu_InitMission10Briefing"
    );

    DrawMedal(9);

    nMissMat = nMissMat + 2;

    //
    //  Back button
    //

    CreateBitmapButton(
      "ID_BACK",
      nBackButtonNormMat,
      nBackButtonHiMat,
      0.471,
      0.914,
      fStdButtonWidth,
      fStdButtonHeight
    );

    //
    //  Mission 11 button
    //

    bEnabled = Core_CallFunction(
                 SOID_GameController,
                 "GetMissionState",
                 10
               );

    CreateBitmapSubMenu(
      "ID_MISSION_11",
      nMissMat,
      nMissMat + 1,
      GetMissionButtonX(10),
      GetMissionButtonY(10),
      fMissionButtonWidth,
      fMissionButtonHeight,
      bEnabled,
      "GameMenu_InitMission11Briefing"
    );

    DrawMedal(10);

    nMissMat = nMissMat + 2;

    //
    //  Mission 12 button
    //

    bEnabled = Core_CallFunction(
                 SOID_GameController,
                 "GetMissionState",
                 11
               );

    CreateBitmapSubMenu(
      "ID_MISSION_12",
      nMissMat,
      nMissMat + 1,
      GetMissionButtonX(11),
      GetMissionButtonY(11),
      fMissionButtonWidth,
      fMissionButtonHeight,
      bEnabled,
      "GameMenu_InitMission12Briefing"
    );

    DrawMedal(11);

    nMissMat = nMissMat + 2;

    //
    //  Mission 13 button
    //

    bEnabled = Core_CallFunction(
                 SOID_GameController,
                 "GetMissionState",
                 12
               );

    CreateBitmapSubMenu(
      "ID_MISSION_13",
      nMissMat,
      nMissMat + 1,
      GetMissionButtonX(12),
      GetMissionButtonY(12),
      fMissionButtonWidth,
      fMissionButtonHeight,
      bEnabled,
      "GameMenu_InitMission13Briefing"
    );

    DrawMedal(12);

    nMissMat = nMissMat + 2;

    //
    //  Mission 14 button
    //

    bEnabled = Core_CallFunction(
                 SOID_GameController,
                 "GetMissionState",
                 13
               );

    CreateBitmapSubMenu(
      "ID_MISSION_14",
      nMissMat,
      nMissMat + 1,
      GetMissionButtonX(13),
      GetMissionButtonY(13),
      fMissionButtonWidth,
      fMissionButtonHeight,
      bEnabled,
      "GameMenu_InitMission14Briefing"
    );

    DrawMedal(13);

    nMissMat = nMissMat + 2;

    //
    //  Mission 15 button
    //

    bEnabled = Core_CallFunction(
                 SOID_GameController,
                 "GetMissionState",
                 14
               );

    CreateBitmapSubMenu(
      "ID_MISSION_15",
      nMissMat,
      nMissMat + 1,
      GetMissionButtonX(14),
      GetMissionButtonY(14),
      fMissionButtonWidth,
      fMissionButtonHeight,
      bEnabled,
      "GameMenu_InitMission15Briefing"
    );

    DrawMedal(14);

    nMissMat = nMissMat + 2;
  }

  //
  //  Briefings
  //

  //
  //  Mission 1
  //

  void GameMenu_InitMission1Briefing()
  {
    GameMenu_InitBriefing(
      "Resources/Mission1Briefing.tex",
      "Resources/Mission1Description.txt",
      "Resources/Mission1Objectives.txt",
      "Resources/Mission1BonusObjectives.txt",
      "ID_START_MISSION_1"
    );
  }

  //
  //  Mission 2
  //

  void GameMenu_InitMission2Briefing()
  {
    GameMenu_InitBriefing(
      "Resources/Mission2Briefing.tex",
      "Resources/Mission2Description.txt",
      "Resources/Mission2Objectives.txt",
      "Resources/Mission2BonusObjectives.txt",
      "ID_START_MISSION_2"
    );
  }

  //
  //  Mission 3
  //

  void GameMenu_InitMission3Briefing()
  {
    GameMenu_InitBriefing(
      "Resources/Mission3Briefing.tex",
      "Resources/Mission3Description.txt",
      "Resources/Mission3Objectives.txt",
      "Resources/Mission3BonusObjectives.txt",
      "ID_START_MISSION_3"
    );
  }

  //
  //  Mission 4
  //

  void GameMenu_InitMission4Briefing()
  {
    GameMenu_InitBriefing(
      "Resources/Mission4Briefing.tex",
      "Resources/Mission4Description.txt",
      "Resources/Mission4Objectives.txt",
      "Resources/Mission4BonusObjectives.txt",
      "ID_START_MISSION_4"
    );
  }

  //
  //  Mission 5
  //

  void GameMenu_InitMission5Briefing()
  {
    GameMenu_InitBriefing(
      "Resources/Mission5Briefing.tex",
      "Resources/Mission5Description.txt",
      "Resources/Mission5Objectives.txt",
      "Resources/Mission5BonusObjectives.txt",
      "ID_START_MISSION_5"
    );
  }

  //
  //  Mission 6
  //

  void GameMenu_InitMission6Briefing()
  {
    GameMenu_InitBriefing(
      "Resources/Mission6Briefing.tex",
      "Resources/Mission6Description.txt",
      "Resources/Mission6Objectives.txt",
      "Resources/Mission6BonusObjectives.txt",
      "ID_START_MISSION_6"
    );
  }

  //
  //  Mission 7
  //

  void GameMenu_InitMission7Briefing()
  {
    GameMenu_InitBriefing(
      "Resources/Mission7Briefing.tex",
      "Resources/Mission7Description.txt",
      "Resources/Mission7Objectives.txt",
      "Resources/Mission7BonusObjectives.txt",
      "ID_START_MISSION_7"
    );
  }

  //
  //  Mission 8
  //

  void GameMenu_InitMission8Briefing()
  {
    GameMenu_InitBriefing(
      "Resources/Mission8Briefing.tex",
      "Resources/Mission8Description.txt",
      "Resources/Mission8Objectives.txt",
      "Resources/Mission8BonusObjectives.txt",
      "ID_START_MISSION_8"
    );
  }

  //
  //  Mission 9
  //

  void GameMenu_InitMission9Briefing()
  {
    GameMenu_InitBriefing(
      "Resources/Mission9Briefing.tex",
      "Resources/Mission9Description.txt",
      "Resources/Mission9Objectives.txt",
      "Resources/Mission9BonusObjectives.txt",
      "ID_START_MISSION_9"
    );
  }

  //
  //  Mission 10
  //

  void GameMenu_InitMission10Briefing()
  {
    GameMenu_InitBriefing(
      "Resources/Mission10Briefing.tex",
      "Resources/Mission10Description.txt",
      "Resources/Mission10Objectives.txt",
      "Resources/Mission10BonusObjectives.txt",
      "ID_START_MISSION_10"
    );
  }

  //
  //  Mission 11
  //

  void GameMenu_InitMission11Briefing()
  {
    GameMenu_InitBriefing(
      "Resources/Mission11Briefing.tex",
      "Resources/Mission11Description.txt",
      "Resources/Mission11Objectives.txt",
      "Resources/Mission11BonusObjectives.txt",
      "ID_START_MISSION_11"
    );
  }

  //
  //  Mission 12
  //

  void GameMenu_InitMission12Briefing()
  {
    GameMenu_InitBriefing(
      "Resources/Mission12Briefing.tex",
      "Resources/Mission12Description.txt",
      "Resources/Mission12Objectives.txt",
      "Resources/Mission12BonusObjectives.txt",
      "ID_START_MISSION_12"
    );
  }

  //
  //  Mission 13
  //

  void GameMenu_InitMission13Briefing()
  {
    GameMenu_InitBriefing(
      "Resources/Mission13Briefing.tex",
      "Resources/Mission13Description.txt",
      "Resources/Mission13Objectives.txt",
      "Resources/Mission13BonusObjectives.txt",
      "ID_START_MISSION_13"
    );
  }

  //
  //  Mission 14
  //

  void GameMenu_InitMission14Briefing()
  {
    GameMenu_InitBriefing(
      "Resources/Mission14Briefing.tex",
      "Resources/Mission14Description.txt",
      "Resources/Mission14Objectives.txt",
      "Resources/Mission14BonusObjectives.txt",
      "ID_START_MISSION_14"
    );
  }

  //
  //  Mission 15
  //

  void GameMenu_InitMission15Briefing()
  {
    GameMenu_InitBriefing(
      "Resources/Mission15Briefing.tex",
      "Resources/Mission15Description.txt",
      "Resources/Mission15Objectives.txt",
      "Resources/Mission15BonusObjectives.txt",
      "ID_START_MISSION_15"
    );
  }

  void GameMenu_InitBriefing(
         string MapPictureFile,
         string DescriptionFile,
         string ObjectivesFile,
         string BonusObjectivesFile,
         string StartMissionButtonID
        )
  {
    //
    //  Background
    //

    CreateBitmapControl(
      "Resources/Menu_Briefing.tex",
      "ID_BITMAP",
      0.0,
      0.0,
      1.0,
      1.0
    );

    float fSpacing = 0.025;

    //
    //  Map
    //

    CreateBitmapControl(
      MapPictureFile,
      "ID_BITMAP",
      0.508,
      0.339,
      0.420,
      0.560
    );

    //
    //  Text control with mission description
    //

    color BriefingTextColor = color(0.835, 0.415, 0.313);

    CreateTextControl(
      LoadTextFromFile(DescriptionFile),
      "ID_MISSION_DESCRIPTION",
      0.095,
      0.165,
      0.830,
      0.140,
      BriefingTextColor
    );

    //
    //  Text control with primary objectives
    //

    CreateTextControl(
      LoadTextFromFile(ObjectivesFile),
      "ID_MISSION_OBJECTIVES",
      0.095,
      0.442,
      0.405,
      0.182,
      BriefingTextColor
    );

    //
    //  Text control with bonus objectives
    //

    CreateTextControl(
      LoadTextFromFile(BonusObjectivesFile),
      "ID_BONUS_MISSION_OBJECTIVES",
      0.095,
      0.684,
      0.405,
      0.200,
      BriefingTextColor
    );

    //
    //  Page Down button
    //

    CreateBitmapButton(
      "ID_PAGEDN",
      nDownButtonNormMat,
      nDownButtonHiMat,
      0.855,
      0.302,
      fScrollButtonWidth,
      fScrollButtonHeight
    );

    //
    //  Page Up button
    //

    CreateBitmapButton(
      "ID_PAGEUP",
      nUpButtonNormMat,
      nUpButtonHiMat,
      0.855 + fScrollButtonWidth,
      0.302,
      fScrollButtonWidth,
      fScrollButtonHeight
    );

    //
    //  Accept mission button
    //

    CreateBitmapButton(
      StartMissionButtonID,
      nAcceptButtonNormMat,
      nAcceptButtonHiMat,
      0.375,
      0.914,
      fStdButtonWidth,
      fStdButtonHeight
    );

    //
    //  Back button
    //

    CreateBitmapButton(
      "ID_BACK",
      nBackButtonNormMat,
      nBackButtonHiMat,
      0.500,
      0.914,
      fStdButtonWidth,
      fStdButtonHeight
    );
  }

  int m_nCreditsScreenNumber = 0;

  void ShowCredits()
  {
    //
    //  Background
    //

    CreateBitmapControl(
      "Resources/" + str_CreditsScreens[m_nCreditsScreenNumber],
      "ID_BITMAP",
      0.0,
      0.0,
      1.0,
      1.0
    );

    CreateMenuButtonGroup(MenuWidth, MenuSpacing);

    //
    //  Next button
    //

    CreateBitmapButton(
      "ID_CREDITS_SCREEN",
      nCreditsButtonNormMat,
      nCreditsButtonHiMat,
      0.435,
      0.914,
      fStdButtonWidth,
      fStdButtonHeight
    );
  }
};
