From 220875d2de1069777a04ecace23359ed78c6032b Mon Sep 17 00:00:00 2001 From: zcaliptium Date: Mon, 14 Mar 2016 02:46:30 +0300 Subject: [PATCH] GameExecutable: Move some stuff from Menu.cpp into files PART TWO Menu.cpp is so large(>6000 lines). I'll separate it! --- Sources/SeriousSam/MDisabled.cpp | 18 + Sources/SeriousSam/MDisabled.h | 5 + Sources/SeriousSam/MLevels.cpp | 101 +++++ Sources/SeriousSam/MLevels.h | 9 +- Sources/SeriousSam/MSinglePlayerNew.cpp | 87 +++++ Sources/SeriousSam/MSinglePlayerNew.h | 10 + Sources/SeriousSam/MVar.cpp | 121 ++++++ Sources/SeriousSam/MVar.h | 11 + Sources/SeriousSam/Menu.cpp | 344 ++---------------- Sources/SeriousSam/SeriousSam.vcxproj | 4 + Sources/SeriousSam/SeriousSam.vcxproj.filters | 12 + 11 files changed, 407 insertions(+), 315 deletions(-) create mode 100644 Sources/SeriousSam/MDisabled.cpp create mode 100644 Sources/SeriousSam/MLevels.cpp create mode 100644 Sources/SeriousSam/MSinglePlayerNew.cpp create mode 100644 Sources/SeriousSam/MVar.cpp diff --git a/Sources/SeriousSam/MDisabled.cpp b/Sources/SeriousSam/MDisabled.cpp new file mode 100644 index 0000000..828d321 --- /dev/null +++ b/Sources/SeriousSam/MDisabled.cpp @@ -0,0 +1,18 @@ +/* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ + +#include "StdH.h" +#include +#include "MenuPrinting.h" +#include "MDisabled.h" + + +void CDisabledMenu::Initialize_t(void) +{ + gm_mgTitle.mg_boxOnScreen = BoxTitle(); + gm_lhGadgets.AddTail(gm_mgTitle.mg_lnNode); + + gm_mgButton.mg_bfsFontSize = BFS_MEDIUM; + gm_mgButton.mg_boxOnScreen = BoxBigRow(0.0f); + gm_lhGadgets.AddTail(gm_mgButton.mg_lnNode); + gm_mgButton.mg_pActivatedFunction = NULL; +} \ No newline at end of file diff --git a/Sources/SeriousSam/MDisabled.h b/Sources/SeriousSam/MDisabled.h index 7d372f5..90de7ec 100644 --- a/Sources/SeriousSam/MDisabled.h +++ b/Sources/SeriousSam/MDisabled.h @@ -7,10 +7,15 @@ #endif #include "GameMenu.h" +#include "MGButton.h" +#include "MGTitle.h" class CDisabledMenu : public CGameMenu { public: + CMGTitle gm_mgTitle; + CMGButton gm_mgButton; + void Initialize_t(void); }; diff --git a/Sources/SeriousSam/MLevels.cpp b/Sources/SeriousSam/MLevels.cpp new file mode 100644 index 0000000..5fe5c6e --- /dev/null +++ b/Sources/SeriousSam/MLevels.cpp @@ -0,0 +1,101 @@ +/* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ + +#include "StdH.h" +#include +#include "MenuPrinting.h" +#include "LevelInfo.h" +#include "MLevels.h" + + +void CLevelsMenu::Initialize_t(void) +{ + gm_mgTitle.mg_boxOnScreen = BoxTitle(); + gm_mgTitle.mg_strText = TRANS("CHOOSE LEVEL"); + gm_lhGadgets.AddTail(gm_mgTitle.mg_lnNode); + + for (INDEX iLabel = 0; iLabel"); + gm_mgManualLevel[i].mg_iInList = -2; + } + + BOOL bHasFirst = FALSE; + BOOL bHasLast = FALSE; + INDEX ctLabels = _lhFilteredLevels.Count(); + INDEX iLabel = 0; + FOREACHINLIST(CLevelInfo, li_lnNode, _lhFilteredLevels, itli) { + CLevelInfo &li = *itli; + INDEX iInMenu = iLabel - gm_iListOffset; + if ((iLabel >= gm_iListOffset) && + (iLabel<(gm_iListOffset + LEVELS_ON_SCREEN))) + { + bHasFirst |= (iLabel == 0); + bHasLast |= (iLabel == ctLabels - 1); + gm_mgManualLevel[iInMenu].mg_strText = li.li_strName; + gm_mgManualLevel[iInMenu].mg_fnmLevel = li.li_fnLevel; + gm_mgManualLevel[iInMenu].mg_bEnabled = TRUE; + gm_mgManualLevel[iInMenu].mg_iInList = iLabel; + } + iLabel++; + } + + // enable/disable up/down arrows + gm_mgArrowUp.mg_bEnabled = !bHasFirst && ctLabels>0; + gm_mgArrowDn.mg_bEnabled = !bHasLast && ctLabels>0; +} + + + +void CLevelsMenu::StartMenu(void) +{ + // set default parameters for the list + gm_iListOffset = 0; + gm_ctListTotal = _lhFilteredLevels.Count(); + gm_iListWantedItem = 0; + // for each level + INDEX i = 0; + FOREACHINLIST(CLevelInfo, li_lnNode, _lhFilteredLevels, itlid) { + CLevelInfo &lid = *itlid; + // if it is the chosen one + if (lid.li_fnLevel == _pGame->gam_strCustomLevel) { + // demand focus on it + gm_iListWantedItem = i; + break; + } + i++; + } + CGameMenu::StartMenu(); +} \ No newline at end of file diff --git a/Sources/SeriousSam/MLevels.h b/Sources/SeriousSam/MLevels.h index 174a86a..61b8d0c 100644 --- a/Sources/SeriousSam/MLevels.h +++ b/Sources/SeriousSam/MLevels.h @@ -7,10 +7,17 @@ #endif #include "GameMenu.h" - +#include "MGArrow.h" +#include "MGLevelButton.h" +#include "MGTitle.h" class CLevelsMenu : public CGameMenu { public: + CMGTitle gm_mgTitle; + CMGLevelButton gm_mgManualLevel[LEVELS_ON_SCREEN]; + CMGArrow gm_mgArrowUp; + CMGArrow gm_mgArrowDn; + void Initialize_t(void); void FillListItems(void); void StartMenu(void); diff --git a/Sources/SeriousSam/MSinglePlayerNew.cpp b/Sources/SeriousSam/MSinglePlayerNew.cpp new file mode 100644 index 0000000..41a0d47 --- /dev/null +++ b/Sources/SeriousSam/MSinglePlayerNew.cpp @@ -0,0 +1,87 @@ +/* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ + +#include "StdH.h" +#include +#include "MenuPrinting.h" +#include "MenuStuff.h" +#include "MSinglePlayerNew.h" + + +void CSinglePlayerNewMenu::Initialize_t(void) +{ + // intialize single player new menu + gm_mgTitle.mg_strText = TRANS("NEW GAME"); + gm_mgTitle.mg_boxOnScreen = BoxTitle(); + gm_lhGadgets.AddTail(gm_mgTitle.mg_lnNode); + + gm_mgTourist.mg_strText = TRANS("TOURIST"); + gm_mgTourist.mg_bfsFontSize = BFS_LARGE; + gm_mgTourist.mg_boxOnScreen = BoxBigRow(0.0f); + gm_mgTourist.mg_strTip = TRANS("for non-FPS players"); + gm_lhGadgets.AddTail(gm_mgTourist.mg_lnNode); + gm_mgTourist.mg_pmgUp = &gm_mgSerious; + gm_mgTourist.mg_pmgDown = &gm_mgEasy; + gm_mgTourist.mg_pActivatedFunction = NULL; + + gm_mgEasy.mg_strText = TRANS("EASY"); + gm_mgEasy.mg_bfsFontSize = BFS_LARGE; + gm_mgEasy.mg_boxOnScreen = BoxBigRow(1.0f); + gm_mgEasy.mg_strTip = TRANS("for unexperienced FPS players"); + gm_lhGadgets.AddTail(gm_mgEasy.mg_lnNode); + gm_mgEasy.mg_pmgUp = &gm_mgTourist; + gm_mgEasy.mg_pmgDown = &gm_mgMedium; + gm_mgEasy.mg_pActivatedFunction = NULL; + + gm_mgMedium.mg_strText = TRANS("NORMAL"); + gm_mgMedium.mg_bfsFontSize = BFS_LARGE; + gm_mgMedium.mg_boxOnScreen = BoxBigRow(2.0f); + gm_mgMedium.mg_strTip = TRANS("for experienced FPS players"); + gm_lhGadgets.AddTail(gm_mgMedium.mg_lnNode); + gm_mgMedium.mg_pmgUp = &gm_mgEasy; + gm_mgMedium.mg_pmgDown = &gm_mgHard; + gm_mgMedium.mg_pActivatedFunction = NULL; + + gm_mgHard.mg_strText = TRANS("HARD"); + gm_mgHard.mg_bfsFontSize = BFS_LARGE; + gm_mgHard.mg_boxOnScreen = BoxBigRow(3.0f); + gm_mgHard.mg_strTip = TRANS("for experienced Serious Sam players"); + gm_lhGadgets.AddTail(gm_mgHard.mg_lnNode); + gm_mgHard.mg_pmgUp = &gm_mgMedium; + gm_mgHard.mg_pmgDown = &gm_mgSerious; + gm_mgHard.mg_pActivatedFunction = NULL; + + gm_mgSerious.mg_strText = TRANS("SERIOUS"); + gm_mgSerious.mg_bfsFontSize = BFS_LARGE; + gm_mgSerious.mg_boxOnScreen = BoxBigRow(4.0f); + gm_mgSerious.mg_strTip = TRANS("are you serious?"); + gm_lhGadgets.AddTail(gm_mgSerious.mg_lnNode); + gm_mgSerious.mg_pmgUp = &gm_mgHard; + gm_mgSerious.mg_pmgDown = &gm_mgTourist; + gm_mgSerious.mg_pActivatedFunction = NULL; + + gm_mgMental.mg_strText = TRANS("MENTAL"); + gm_mgMental.mg_bfsFontSize = BFS_LARGE; + gm_mgMental.mg_boxOnScreen = BoxBigRow(5.0f); + gm_mgMental.mg_strTip = TRANS("you are not serious!"); + gm_lhGadgets.AddTail(gm_mgMental.mg_lnNode); + gm_mgMental.mg_pmgUp = &gm_mgSerious; + gm_mgMental.mg_pmgDown = &gm_mgTourist; + gm_mgMental.mg_pActivatedFunction = NULL; + gm_mgMental.mg_bMental = TRUE; + + +} +void CSinglePlayerNewMenu::StartMenu(void) +{ + CGameMenu::StartMenu(); + extern INDEX sam_bMentalActivated; + if (sam_bMentalActivated) { + gm_mgMental.Appear(); + gm_mgSerious.mg_pmgDown = &gm_mgMental; + gm_mgTourist.mg_pmgUp = &gm_mgMental; + } else { + gm_mgMental.Disappear(); + gm_mgSerious.mg_pmgDown = &gm_mgTourist; + gm_mgTourist.mg_pmgUp = &gm_mgSerious; + } +} diff --git a/Sources/SeriousSam/MSinglePlayerNew.h b/Sources/SeriousSam/MSinglePlayerNew.h index 090a439..e0689da 100644 --- a/Sources/SeriousSam/MSinglePlayerNew.h +++ b/Sources/SeriousSam/MSinglePlayerNew.h @@ -7,10 +7,20 @@ #endif #include "GameMenu.h" +#include "MGButton.h" +#include "MGTitle.h" class CSinglePlayerNewMenu : public CGameMenu { public: + CMGTitle gm_mgTitle; + CMGButton gm_mgTourist; + CMGButton gm_mgEasy; + CMGButton gm_mgMedium; + CMGButton gm_mgHard; + CMGButton gm_mgSerious; + CMGButton gm_mgMental; + void Initialize_t(void); void StartMenu(void); }; diff --git a/Sources/SeriousSam/MVar.cpp b/Sources/SeriousSam/MVar.cpp new file mode 100644 index 0000000..373b5de --- /dev/null +++ b/Sources/SeriousSam/MVar.cpp @@ -0,0 +1,121 @@ +/* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ + +#include "StdH.h" +#include +#include "MenuPrinting.h" +#include "VarList.h" +#include "MVar.h" + +extern BOOL _bVarChanged; + + +void CVarMenu::Initialize_t(void) +{ + gm_mgTitle.mg_boxOnScreen = BoxTitle(); + gm_mgTitle.mg_strText = ""; + gm_lhGadgets.AddTail(gm_mgTitle.mg_lnNode); + + for (INDEX iLabel = 0; iLabel= gm_iListOffset) && + (iLabel<(gm_iListOffset + VARS_ON_SCREEN))) + { + bHasFirst |= (iLabel == 0); + bHasLast |= (iLabel == ctLabels - 1); + gm_mgVar[iInMenu].mg_pvsVar = &vs; + gm_mgVar[iInMenu].mg_strTip = vs.vs_strTip; + gm_mgVar[iInMenu].mg_bEnabled = gm_mgVar[iInMenu].IsEnabled(); + gm_mgVar[iInMenu].mg_iInList = iLabel; + } + iLabel++; + } + // enable/disable up/down arrows + gm_mgArrowUp.mg_bEnabled = !bHasFirst && ctLabels>0; + gm_mgArrowDn.mg_bEnabled = !bHasLast && ctLabels>0; +} + +void CVarMenu::StartMenu(void) +{ + LoadVarSettings(gm_fnmMenuCFG); + // set default parameters for the list + gm_iListOffset = 0; + gm_ctListTotal = _lhVarSettings.Count(); + gm_iListWantedItem = 0; + CGameMenu::StartMenu(); +} + +void CVarMenu::EndMenu(void) +{ + // disable all items first + for (INDEX i = 0; i"); - mgManualLevel[i].mg_iInList = -2; - } - - BOOL bHasFirst = FALSE; - BOOL bHasLast = FALSE; - INDEX ctLabels = _lhFilteredLevels.Count(); - INDEX iLabel=0; - FOREACHINLIST(CLevelInfo, li_lnNode, _lhFilteredLevels, itli) { - CLevelInfo &li = *itli; - INDEX iInMenu = iLabel-gm_iListOffset; - if( (iLabel>=gm_iListOffset) && - (iLabel<(gm_iListOffset+LEVELS_ON_SCREEN)) ) - { - bHasFirst|=(iLabel==0); - bHasLast |=(iLabel==ctLabels-1); - mgManualLevel[iInMenu].mg_strText = li.li_strName; - mgManualLevel[iInMenu].mg_fnmLevel = li.li_fnLevel; - mgManualLevel[iInMenu].mg_bEnabled = TRUE; - mgManualLevel[iInMenu].mg_iInList = iLabel; - } - iLabel++; - } - - // enable/disable up/down arrows - mgLevelsArrowUp.mg_bEnabled = !bHasFirst && ctLabels>0; - mgLevelsArrowDn.mg_bEnabled = !bHasLast && ctLabels>0; -} - -void CLevelsMenu::Initialize_t(void) -{ - mgLevelsTitle.mg_boxOnScreen = BoxTitle(); - mgLevelsTitle.mg_strText = TRANS("CHOOSE LEVEL"); - gm_lhGadgets.AddTail( mgLevelsTitle.mg_lnNode); - - for( INDEX iLabel=0; iLabelgam_strCustomLevel) { - // demand focus on it - gm_iListWantedItem = i; - break; - } - i++; - } - CGameMenu::StartMenu(); -} - +// ------------------------ CVarMenu implementation void VarApply(void) { FlushVarSettings(TRUE); @@ -4816,114 +4638,8 @@ void VarApply(void) gmVarMenu.StartMenu(); } -void CVarMenu::Initialize_t(void) -{ - mgVarTitle.mg_boxOnScreen = BoxTitle(); - mgVarTitle.mg_strText = ""; - gm_lhGadgets.AddTail( mgVarTitle.mg_lnNode); - - for( INDEX iLabel=0; iLabel=gm_iListOffset) && - (iLabel<(gm_iListOffset+VARS_ON_SCREEN)) ) - { - bHasFirst|=(iLabel==0); - bHasLast |=(iLabel==ctLabels-1); - mgVar[iInMenu].mg_pvsVar = &vs; - mgVar[iInMenu].mg_strTip = vs.vs_strTip; - mgVar[iInMenu].mg_bEnabled = mgVar[iInMenu].IsEnabled(); - mgVar[iInMenu].mg_iInList = iLabel; - } - iLabel++; - } - // enable/disable up/down arrows - mgVarArrowUp.mg_bEnabled = !bHasFirst && ctLabels>0; - mgVarArrowDn.mg_bEnabled = !bHasLast && ctLabels>0; -} - -void CVarMenu::StartMenu(void) -{ - LoadVarSettings(gm_fnmMenuCFG); - // set default parameters for the list - gm_iListOffset = 0; - gm_ctListTotal = _lhVarSettings.Count(); - gm_iListWantedItem = 0; - CGameMenu::StartMenu(); -} - -void CVarMenu::EndMenu(void) -{ - // disable all items first - for(INDEX i=0; i + Use StdH.h @@ -210,8 +211,11 @@ copy Release\$(TargetName).map $(SolutionDir)..\Bin\ >nul + + + Use StdH.h diff --git a/Sources/SeriousSam/SeriousSam.vcxproj.filters b/Sources/SeriousSam/SeriousSam.vcxproj.filters index 987e89e..378cb3c 100644 --- a/Sources/SeriousSam/SeriousSam.vcxproj.filters +++ b/Sources/SeriousSam/SeriousSam.vcxproj.filters @@ -132,6 +132,18 @@ Source Files\Menus + + Source Files\Menus + + + Source Files\Menus + + + Source Files\Menus + + + Source Files\Menus +