Page principale | Liste des namespaces | Hiérarchie des classes | Liste par ordre alphabétique | Liste des composants | Liste des fichiers | Membres des namespaces | Composants | Déclarations

# ExManagerMap.cpp

Aller à la documentation de ce fichier.

    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: ExManagerMap.cpp,v 1.9 2002/09/22 15:54:04 data Exp $
    00021  *
    00022  */
    00023
    00024 #include "ExManagerMap.h"
    00025
    00026 bool ExManagerMap::m_flag = false;
    00027 ExManagerMap* ExManagerMap::m_instance = NULL;
    00028
    00029 ExManagerMap* ExManagerMap::CreateSingleton(void){
    00030 Guard(ExManagerMap* ExManagerMap::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 ExManagerMap; // 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 ExManagerMap::ExManagerMap(void)
    00044 {
    00045         MapLoaded=false;
    00046         SkyLoaded=false;
    00047 }
    00048
    00049 ExManagerMap::~ExManagerMap(void)
    00050 {
    00051 }
    00052
    00053 void ExManagerMap::Init(void)
    00054 {
    00055
    00056 }
    00057
    00058 void ExManagerMap::Reset(void)
    00059 {
    00060         MapLoaded=false;
    00061         SkyLoaded=false;
    00062 }
    00063
    00064 void ExManagerMap::Load(std::string FileName)
    00065 {
    00066 Guard(ExManagerMap::Load(std::string FileName))
    00067
    00068         //find extension type of map
    00069         if(FileName.find("."))
    00070         {
    00071                 //skybox
    00072                 if(FileName.find(".skyb")==(FileName.length()-5))
    00073                 {
    00074                         Skybox=new ExCSkyBox();
    00075                         Skybox->SetManagerTexture(ManagerTexture);
    00076                         Skybox->SetFileName(FileName);
    00077                         Skybox->Load(FileName);
    00078                         SkyLoaded=true;
    00079                         return;
    00080                 }
    00081                 //bsp map
    00082                 if(FileName.find(".bsp")==(FileName.length()-4))
    00083                 {
    00084                         return;
    00085                 }
    00086                 //height map
    00087                 if(FileName.find(".hgmp")==(FileName.length()-5))
    00088                 {
    00089                         HeightMap=new ExCHeightMap();
    00090                         HeightMap->SetManagerTexture(ManagerTexture);
    00091                         HeightMap->SetManagerFog(ManagerFog);
    00092                         HeightMap->SetFileName(FileName);
    00093                         HeightMap->Load(FileName);
    00094                         MapLoaded=true;
    00095                         return;
    00096                 }
    00097         }
    00098
    00099 UnGuard
    00100 }
    00101
    00102 void ExManagerMap::Draw(void)
    00103 {
    00104 Guard(void ExManagerMap::Draw(void))
    00105         if(MapLoaded)
    00106         {
    00107                 HeightMap->Draw();
    00108         }
    00109         if(SkyLoaded)
    00110         {
    00111                 Skybox->Draw();
    00112         }
    00113 UnGuard
    00114 }
    00115
    00116 ExCAction ExManagerMap::InputCommand(ExCCommand Command)
    00117 {
    00118 Guard(ExCAction ExManagerMap::InputCommand(ExCCommand Command))
    00119         return NOTHING;
    00120 UnGuard
    00121 }
    00122
    00123 ExCAction ExManagerMap::InputAction(ExCAction Action)
    00124 {
    00125 Guard(ExCAction ExManagerMap::InputAction(ExCAction Action))
    00126         switch(Action.m_Action)
    00127         {
    00128
    00129         case HEIGHTMAP_INCREASE_DETAIL_LEVEL:HeightMap->IncreaseDetailLevel();break;
    00130         case HEIGHTMAP_DECREASE_DETAIL_LEVEL:HeightMap->DereaseDetailLevel();break;
    00131         case HEIGHTMAP_ENABLE_FOG:HeightMap->SetFogState(true);break;
    00132         case HEIGHTMAP_DISABLE_FOG:HeightMap->SetFogState(false);break;
    00133         case HEIGHTMAP_SWITCH_FOG:HeightMap->GetFogState()? HeightMap->SetFogState(false):HeightMap->SetFogState(true);
    00134
    00135         case HEIGHTMAP_INCREASE_FOG_DEPHT_LEVEL:HeightMap->IncreaseFogDepthLevel();break;
    00136         case HEIGHTMAP_DECREASE_FOG_DEPHT_LEVEL:HeightMap->DereaseFogDepthLevel();break;
    00137
    00138         case HEIGHTMAP_INCREASE_TEXTURE_2_REPETITION:HeightMap->IncreaseTexture2Repetition();break;
    00139         case HEIGHTMAP_DECREASE_TEXTURE_2_REPETITION:HeightMap->DereaseTexture2Repetition();break;
    00140         case RELOAD_MANAGER_MAP:
    00141                 if(SkyLoaded)Skybox->Load(Skybox->GetFileName());
    00142                 if(MapLoaded)HeightMap->Load(HeightMap->GetFileName());
    00143                 break;
    00144         default:
    00145                 *Consol<<"Can not file action in MAP_ACTION_MAP"<<std::endl;
    00146                 break;
    00147         }
    00148         if(Action.m_NextAction){return *Action.m_NextAction;}
    00149         else{return NOTHING;}
    00150 UnGuard
    00151 }
    00152