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: ExManagerParticuleSystem.cpp,v 1.17 2002/11/24 11:58:58 data Exp $ 00021 * 00022 */ 00023 #include "ExManagerParticuleSystem.h" 00024 00025 bool ExManagerParticuleSystem::m_flag = false; 00026 ExManagerParticuleSystem* ExManagerParticuleSystem::m_instance = NULL; 00027 00028 ExManagerParticuleSystem* ExManagerParticuleSystem::CreateSingleton(void){ 00029 Guard(ExManagerParticuleSystem* ExManagerParticuleSystem::CreateSingleton(void)) 00030 if(!m_flag) 00031 { 00032 m_flag = true; // We are creating the error log now, so set flag to true 00033 m_instance = new ExManagerParticuleSystem; // Create the error log 00034 }else 00035 { 00036 std::cout<<"Error singleton already created"<<std::endl; 00037 } 00038 return m_instance; 00039 UnGuard 00040 } 00041 00042 ExManagerParticuleSystem::ExManagerParticuleSystem(void) 00043 { 00044 Guard(ExManagerParticuleSystem::ExManagerParticuleSystem(void)) 00045 00046 UnGuard 00047 } 00048 00049 00050 ExManagerParticuleSystem::~ExManagerParticuleSystem(void) 00051 { 00052 Guard(ExManagerParticuleSystem::~ExManagerParticuleSystem(void)) 00053 UnGuard 00054 } 00055 00056 void ExManagerParticuleSystem::Init(void) 00057 { 00058 Guard(void ExManagerModel::Init(void)) 00059 ExManagerObject<ExCSystemeParticule>::Init(); 00060 UnGuard 00061 } 00062 00063 void ExManagerParticuleSystem::Reset(void) 00064 { 00065 ExManagerObject<ExCSystemeParticule>::Reset(); 00066 } 00067 00068 bool ExManagerParticuleSystem::Load(std::string FileName) 00069 { 00070 Guard(bool ExManagerParticuleSystem::Load(std::string FileName)) 00071 FileName="../Data/ParticuleSystem/"+FileName; 00072 try 00073 { 00074 ExCSystemeParticule systeme; 00075 systeme.Consol=Consol; 00076 systeme.SetManagerTexture(ManagerTexture); 00077 systeme.Load(FileName); 00078 return ExManagerObject<ExCSystemeParticule>::Add(systeme); 00079 } 00080 catch(ExCExpFileNotFound) 00081 { 00082 *Consol<<"ExManagerParticuleSystem::ExCeption =>"<<FileName<<" File not found"<<std::endl; 00083 return false; 00084 } 00085 catch(ExCExpFileReadError) 00086 { 00087 *Consol<<"ExManagerParticuleSystem::ExCeption =>"<<FileName<<" Read file error"<<std::endl; 00088 return false; 00089 } 00090 catch(...) 00091 { 00092 *Consol<<"ExManagerParticuleSystem::ExCeption =>"<<FileName<<" Unknow exception"<<std::endl; 00093 return false; 00094 } 00095 UnGuard 00096 } 00097 00098 int ExManagerParticuleSystem::Start(std::string Name) 00099 { 00100 Guard(int ExManagerParticuleSystem::Start(std::string Name)) 00101 /*for(m_ItMap=m_Map->begin();m_ItMap!=m_Map->end();m_ItMap++) 00102 { 00103 if(strcmp(m_ItMap->GetParticuleSystemeName(),param.data())==0) 00104 { 00105 m_ItMap->Start(); 00106 } 00107 } 00108 */ 00109 return GetNumberEnableParticuleSysteme(); 00110 UnGuard 00111 } 00112 00113 int ExManagerParticuleSystem::Stop(std::string Name) 00114 { 00115 Guard(int ExManagerParticuleSystem::Stop(std::string Name)) 00116 /*for(m_ItMap=m_Map->begin();m_ItMap!=m_Map->end();m_ItMap++) 00117 { 00118 if(strcmp(m_ItMap->GetParticuleSystemeName(),param.data())==0) 00119 { 00120 m_ItMap->Stop(); 00121 } 00122 }*/ 00123 return GetNumberEnableParticuleSysteme(); 00124 UnGuard 00125 } 00126 00127 int ExManagerParticuleSystem::Pause(std::string Name) 00128 { 00129 Guard(int ExManagerParticuleSystem::Pause(std::string Name)) 00130 /*for(m_ItMap=m_Map->begin();m_ItMap!=m_Map->end();m_ItMap++) 00131 { 00132 if(strcmp(m_ItMap->GetParticuleSystemeName(),param.data())==0) 00133 { 00134 m_ItMap->Pause(); 00135 } 00136 }*/ 00137 return GetNumberEnableParticuleSysteme(); 00138 UnGuard 00139 } 00140 00141 int ExManagerParticuleSystem::StartAll(void) 00142 { 00143 Guard(int ExManagerParticuleSystem::StartAll(void)) 00144 for(m_ItMap=m_Map->begin();m_ItMap!=m_Map->end();m_ItMap++) 00145 { 00146 m_ItMap->second.Start(); 00147 } 00148 return GetNumberEnableParticuleSysteme(); 00149 UnGuard 00150 } 00151 00152 void ExManagerParticuleSystem::Draw(void) 00153 { 00154 Guard(void ExManagerParticuleSystem::Draw(void)) 00155 for(m_ItMap=m_Map->begin();m_ItMap!=m_Map->end();m_ItMap++) 00156 { 00157 m_ItMap->second.Draw(); 00158 } 00159 UnGuard 00160 } 00161 00162 int ExManagerParticuleSystem::StopAll(void) 00163 { 00164 Guard(int ExManagerParticuleSystem::StopAll(void)) 00165 for(m_ItMap=m_Map->begin();m_ItMap!=m_Map->end();m_ItMap++) 00166 { 00167 m_ItMap->second.Stop(); 00168 } 00169 return GetNumberEnableParticuleSysteme(); 00170 UnGuard 00171 } 00172 00173 int ExManagerParticuleSystem::PauseAll(void) 00174 { 00175 Guard(int ExManagerParticuleSystem::PauseAll(void)) 00176 for(m_ItMap=m_Map->begin();m_ItMap!=m_Map->end();m_ItMap++) 00177 { 00178 m_ItMap->second.Pause(); 00179 } 00180 return GetNumberEnableParticuleSysteme(); 00181 UnGuard 00182 } 00183 00184 00185 00186 ExCAction ExManagerParticuleSystem::InputCommand(ExCCommand Command) 00187 { 00188 Guard(ExCAction ExManagerParticuleSystem::InputCommand(ExCCommand Command)) 00189 return NOTHING; 00190 UnGuard 00191 } 00192 00193 ExCAction ExManagerParticuleSystem::InputAction(ExCAction Action) 00194 { 00195 Guard(ExCAction ExManagerParticuleSystem::InputAction(ExCAction Action)) 00196 switch(Action.m_Action) 00197 { 00198 case LOAD_PARTICULESYSTEME:Load(Action.m_Param);break; 00199 case STAR_PARTICULESYSTEME:GetObject(Action.m_Param)->Start();break; 00200 case STOP_PARTICULESYSTEME:GetObject(Action.m_Param)->Stop();break; 00201 case PAUSE_PARTICULESYSTEME:GetObject(Action.m_Param)->Pause();break; 00202 case STAR_ALL_PARTICULESYSTEME:StartAll();break; 00203 case STOP_ALL_PARTICULESYSTEME:StopAll();break; 00204 case PAUSE_ALL_PARTICULESYSTEME:PauseAll();break; 00205 case LIST_PARTICULESYSTEME:List();break; 00206 00207 default: 00208 *Consol<<"Can not file action in PARTICULESYSTEME_ACTION_MAP"<<std::endl; 00209 break; 00210 } 00211 if(Action.m_NextAction){return *Action.m_NextAction;} 00212 else{return NOTHING;} 00213 UnGuard 00214 } 00215