home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 June / PCFJune.iso / Xenon / XenonSource.exe / xenon / source / optionsmenustate.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-10  |  2.8 KB  |  123 lines

  1. //-------------------------------------------------------------
  2. //
  3. // Class:    COptionsMenuState
  4. //
  5. // Author:    John M Phillips
  6. //
  7. // Started:    06/05/00
  8. //
  9. // Base:    CGameState
  10. //
  11. // Derived:    None
  12. //
  13. //-------------------------------------------------------------
  14.  
  15. #include "game.h"
  16.  
  17. //-------------------------------------------------------------
  18.  
  19. COptionsMenuState *COptionsMenuState::m_instance = 0;
  20.  
  21. //-------------------------------------------------------------
  22.  
  23. COptionsMenuState::COptionsMenuState()
  24. {
  25. }
  26.  
  27. //-------------------------------------------------------------
  28.  
  29. COptionsMenuState::~COptionsMenuState()
  30. {
  31. }
  32.  
  33. //-------------------------------------------------------------
  34.  
  35. CGameState *COptionsMenuState::instance()
  36. {
  37.     if (!m_instance)
  38.         m_instance = new COptionsMenuState;
  39.  
  40.     return m_instance;
  41. }
  42.  
  43. //-------------------------------------------------------------
  44.  
  45. bool COptionsMenuState::create()
  46. {
  47.     m_menu.clear();
  48.  
  49.     m_menu.addSelection("Control Options");
  50.     m_menu.addSelection("Video Options");
  51.     m_menu.addSelection("Audio Options");
  52.  
  53.     m_menu.addSeperator();
  54.     m_menu.addSelection("Back To Main Menu");
  55.  
  56.     m_menu.setWrap(true);
  57.     m_menu.setPosition(gsCPoint(0,150));
  58.     m_menu.setSpacing(gsCPoint(0,30));
  59.     m_menu.setCurrentItem(OM_BACK);
  60.     m_menu.setFont(&m_medium_font);
  61.  
  62.     return true;
  63. }
  64.  
  65. //-------------------------------------------------------------
  66.  
  67. bool COptionsMenuState::update()
  68. {
  69.     if (!CGameState::update())
  70.         return false;
  71.  
  72.     if (Options.getOption(OPTION_BACKDROP))
  73.         m_backdrop.draw(gsCPoint(0,0));
  74.     else
  75.         m_screen.clear(gsCColour(gsBLACK));
  76.  
  77.     m_starfield.move(4);
  78.     m_starfield.draw();
  79.  
  80.     m_medium_font.setTextCursor(gsCPoint(0,50));
  81.     m_medium_font.justifyString("Options Menu");
  82.  
  83.     m_menu.draw();
  84.     
  85.     m_screen.flip();
  86.  
  87.     OptionsMenuItem item = (OptionsMenuItem) m_menu.getCurrentItem();
  88.  
  89.     switch (getKey()) {
  90.         case gsKEY_RETURN:
  91.         case gsKEY_ENTER:
  92.         case gsKEY_LCONTROL:
  93.             switch (item) {
  94.                 case OM_CONTROL:
  95.                     CGameState::playSample(SAMPLE_MENU_SELECTION);
  96.                     return changeState(CControlMenuState::instance());
  97.                 case OM_VIDEO:
  98.                     CGameState::playSample(SAMPLE_MENU_SELECTION);
  99.                     return changeState(CVideoMenuState::instance());
  100.                 case OM_AUDIO:
  101.                     CGameState::playSample(SAMPLE_MENU_SELECTION);
  102.                     return changeState(CAudioMenuState::instance());
  103.                 case OM_BACK:
  104.                     CGameState::playSample(SAMPLE_MENU_BACK);
  105.                     return changeState(CMainMenuState::instance());
  106.                 }
  107.             break;
  108.         case gsKEY_UP:
  109.             CGameState::playSample(SAMPLE_MENU_SELECTION);
  110.             m_menu.scroll(-1);
  111.             break;
  112.         case gsKEY_DOWN:
  113.             CGameState::playSample(SAMPLE_MENU_SELECTION);
  114.             m_menu.scroll(1);
  115.             break;
  116.         }
  117.  
  118.     return true;
  119. }
  120.  
  121. //-------------------------------------------------------------
  122.  
  123.