Main Page   Namespace List   Class Hierarchy   Alphabetical List   Data Structures   File List   Namespace Members   Data Fields   Globals  

ExManagerMenu.cpp

Go to the documentation of this file.
00001 /*
00002  * ExNihilo 3D Engine
00003  * 
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU Library General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  *
00018  * Please read AUTHORS file !!!
00019  * 
00020  * $Id: ExManagerMenu.cpp,v 1.13 2002/12/08 17:57:06 data Exp $
00021  *
00022  */
00023 
00024 #include "ExManagerMenu.h"
00025 
00026 bool ExManagerMenu::m_flag = false; 
00027 ExManagerMenu* ExManagerMenu::m_instance = NULL; 
00028 
00029 ExManagerMenu* ExManagerMenu::CreateSingleton(void){
00030 Guard(ExManagerMenu* ExManagerMenu::CreateSingleton(void))
00031         if(!m_flag)
00032         {
00033                 m_flag = true; // We are creating the error log now, so set flag to true
00034                 m_instance = new ExManagerMenu; // Create the error log
00035         }else
00036         {
00037                 std::cout<<"Error singleton already created"<<std::endl;
00038         }
00039         return m_instance; 
00040 UnGuard
00041 }
00042 
00043 ExManagerMenu::ExManagerMenu(void)
00044 {
00045 }
00046 
00047 ExManagerMenu::~ExManagerMenu(void)
00048 {
00049 }
00050 
00051 void ExManagerMenu::Init(void)
00052 {
00053 Guard(void ExManagerMenu::Init(void))
00054         ExManagerObject<ExCMenu>::Init();
00055 
00056         SetStatus(true);
00057         SetAskForCommand(true);
00058         SetAskForExclusifCommand(true);
00059                 
00060         ExCMenu object;
00061         object.LoadFile("start.men");
00062         object.SetName("StartMenu");
00063         ExManagerMenu::Add(object);
00064         SetCurrentObject("StartMenu");
00065         
00066         ExCMenu object2;
00067         object2.LoadFile("credit.men");
00068         object2.SetName("CreditMenu");
00069         ExManagerMenu::Add(object2);
00070 
00071         ExCMenu object3;
00072         object3.LoadFile("option.men");
00073         object3.SetName("OptionMenu");
00074         ExManagerMenu::Add(object3);
00075 
00076         ExCMenu object4;
00077         object4.LoadFile("commandmenu.men");
00078         object4.SetName("CommandMenu");
00079         ExManagerMenu::Add(object4);
00080         
00081 UnGuard
00082 }
00083 
00084 void ExManagerMenu::Reset(void)
00085 {
00086 Guard(void ExManagerMenu::Reset(void))
00087         ExManagerObject<ExCMenu>::Reset();
00088         Init();
00089         SetCurrentObject("StartMenu0");
00090 UnGuard
00091 }
00092 
00093 void ExManagerMenu::Draw(void)
00094 {
00095 Guard(void ExManagerMenu::Draw(void))
00096         if(!GetStatus())return;
00097         glDisable(GL_LIGHTING);
00098         if(GetCurrentObject()!=NULL)GetCurrentObject()->Draw();
00099         glEnable(GL_LIGHTING);
00100 UnGuard
00101 }
00102 
00103 bool ExManagerMenu::Load(std::string FileName)
00104 {
00105 Guard(ExManagerMenu::Load(std::string FileName))
00106         return  Add(FileName);
00107 UnGuard
00108 }
00109 
00110 bool ExManagerMenu::Add(ExCMenu object)
00111 {
00112 Guard(ExManagerMenu::Add(ExCMenu object))
00113         return ExManagerObject<ExCMenu>::Add(object);
00114 UnGuard
00115 }
00116 
00117 
00118 bool ExManagerMenu::Add(std::string FileName)
00119 {
00120 Guard(ExManagerMenu::Add(std::string FileName))
00121         try
00122         {
00123                 ExCMenu object;
00124                 object.LoadFile(FileName);
00125                 Add(object);
00126         }
00127         catch(ExCExpFileNotFound)
00128         {
00129                 *Consol<<"ExManagerObject::ExCeption =>"<<FileName<<" File not found"<<std::endl;
00130         }
00131         catch(ExCExpFileReadError)
00132         {
00133                 *Consol<<"ExManagerObject::ExCeption =>"<<FileName<<" Read file error"<<std::endl;
00134         }
00135         catch(...)
00136         {
00137                 *Consol<<"ExManagerObject::ExCeption =>"<<FileName<<" Unknow exception"<<std::endl;
00138         }
00139         return false;
00140 UnGuard
00141 }
00142 
00143 ExCAction ExManagerMenu::InputCommand(ExCCommand Command)
00144 {
00145 Guard(ExManagerMenu::InputCommand(ExCCommand Command))
00146         if(GetCurrentObject()==NULL)return NOTHING;
00147         switch(Command.m_Command)
00148         {
00149         case KEYBOARD_DOWN_ARROW_UP:
00150                 GetCurrentObject()->PreviousItem();
00151                 break;
00152         case KEYBOARD_DOWN_ARROW_DOWN:
00153                 GetCurrentObject()->NextItem();
00154                 break;
00155         case KEYBOARD_DOWN_ENTER:
00156                 return GetCurrentObject()->GetCurrentItemAction();
00157                 break;
00158         case KEYBOARD_DOWN_ESC:
00159                 return DISABLE_MENU;
00160                 break;
00161         }
00162         return  NOTHING;
00163 UnGuard
00164 }
00165 
00166 ExCAction ExManagerMenu::InputAction(ExCAction Action)
00167 {
00168 Guard(ExManagerMenu::InputAction(ExCAction Action))
00169         switch(Action.m_Action)
00170         {
00171         case ENABLE_MENU:
00172                 SetStatus(true);
00173                 SetAskForCommand(true);
00174                 SetAskForExclusifCommand(true);
00175                 break;
00176         case DISABLE_MENU:
00177                 SetStatus(false);
00178                 SetAskForCommand(false);
00179                 SetAskForExclusifCommand(false);
00180                 break;
00181         case ENABLE_DISABLE_MENU:
00182                 if(GetStatus())InputAction(DISABLE_MENU);
00183                 else InputAction(ENABLE_MENU); 
00184                 break;
00185         case SET_CURRENT_MENU:
00186                 std::cout<<Action.m_Param<<std::endl;
00187                 SetCurrentObject(Action.m_Param);
00188                 break;
00189         }
00190         return  NOTHING;
00191 UnGuard
00192 }

Generated on Tue Dec 10 18:20:07 2002 for ExNihilo by doxygen1.3-rc1