home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 80 / XENIATGM80.iso / Goodies / Blood 2 / Source / data.z / MenuLoadGame.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-04-02  |  2.5 KB  |  95 lines

  1. // MenuLoadGame.cpp: implementation of the CMenuLoadGame class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4.  
  5. #include "LTGUIMgr.h"
  6. #include "MenuLoadGame.h"
  7. #include "MenuCommands.h"
  8. #include "BloodClientShell.h"
  9. #include "ClientRes.h"
  10.  
  11. //////////////////////////////////////////////////////////////////////
  12. // Construction/Destruction
  13. //////////////////////////////////////////////////////////////////////
  14.  
  15. CMenuLoadGame::CMenuLoadGame()
  16. {
  17.  
  18. }
  19.  
  20. CMenuLoadGame::~CMenuLoadGame()
  21. {
  22.  
  23. }
  24.  
  25. // Build the menu
  26. void CMenuLoadGame::Build()
  27. {
  28.     // Make sure to call the base class
  29.     CMenuBase::Build();
  30.  
  31.     CreateTitle("interface\\mainmenus\\loadgame.pcx", IDS_MENU_TITLE_LOADGAME, m_pMainMenus->GetTitlePos());        
  32.     SetOptionPos(m_pMainMenus->GetOptionsPos());
  33.     SetItemSpacing(0);        
  34. }
  35.  
  36. // Add the menu items
  37. void CMenuLoadGame::InitSavedGameSlots()
  38. {        
  39.     // Remove all of the menu options
  40.     RemoveAllOptions();
  41.  
  42.     // Save game info
  43.     CSavedGameInfo *pSGInfo = DNULL;
  44.     pSGInfo = g_pBloodClientShell->GetSavedGameInfo();
  45.     
  46.     // This is "RESTART: %s" in English
  47.     HSTRING hRestartFormat=m_pClientDE->FormatString(IDS_MENU_LOADGAME_RESTART, pSGInfo->gCurrentSaveInfo.szName);            
  48.     AddTextItemOption(hRestartFormat, MENU_CMD_LOAD_SAVE_GAME, m_pMainMenus->GetSmallFont());        
  49.     m_pClientDE->FreeString(hRestartFormat);
  50.  
  51.     // This is "QUICKLOAD: %s" in English
  52.     HSTRING hQuickLoadFormat=m_pClientDE->FormatString(IDS_MENU_LOADGAME_QUICKLOAD, pSGInfo->gQuickSaveInfo.szName);        
  53.     AddTextItemOption(hQuickLoadFormat, MENU_CMD_LOAD_SAVE_GAME, m_pMainMenus->GetSmallFont());    
  54.     m_pClientDE->FreeString(hQuickLoadFormat);
  55.  
  56.     // Add the save game slots
  57.     if ( pSGInfo )
  58.     {
  59.         int i;
  60.         for (i=0; i < MAX_SAVESLOTS; i++)
  61.         {            
  62.             HSTRING hString=m_pClientDE->CreateString(pSGInfo->gSaveSlotInfo[i].szName);
  63.             AddTextItemOption(hString, MENU_CMD_LOAD_SAVE_GAME, m_pMainMenus->GetSmallFont());    
  64.             m_pClientDE->FreeString(hString);
  65.         }
  66.     }    
  67. }
  68.  
  69. DDWORD CMenuLoadGame::OnCommand(DDWORD dwCommand, DDWORD dwParam1, DDWORD dwParam2)
  70. {
  71.     switch (dwCommand)
  72.     {
  73.     case MENU_CMD_LOAD_SAVE_GAME:
  74.         {
  75.             int nIndex=m_listOption.GetSelectedItem();
  76.  
  77.             // Special case quickload and restart last level
  78.             if ( nIndex == 0 )
  79.             {
  80.                 g_pBloodClientShell->MenuLoadGame(SLOT_CURRENT);
  81.             }
  82.             else if ( nIndex == 1 )
  83.             {
  84.                 g_pBloodClientShell->MenuLoadGame(SLOT_QUICK);
  85.             }
  86.             else
  87.             {
  88.                 // Load the saved game
  89.                 g_pBloodClientShell->MenuLoadGame(nIndex-2);
  90.             }
  91.             break;
  92.         }
  93.     }
  94.     return 0;
  95. }