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

ExManagerCommand.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: ExManagerCommand.cpp,v 1.51 2002/12/13 11:45:00 data Exp $
00021  *
00022  */
00023 
00024 #include "ExManagerCommand.h"
00025 
00026 bool ExManagerCommand::m_flag = false; 
00027 ExManagerCommand* ExManagerCommand::m_instance = NULL; 
00028 
00029 ExManagerCommand* ExManagerCommand::CreateSingleton(void){
00030 Guard(ExManagerCommand* ExManagerCommand::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 ExManagerCommand; // 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 ExManagerCommand::ExManagerCommand(void)
00044 {
00045         LogCommand = true;
00046         #ifdef UNIX_SRC
00047         logfilecommand.open("/tmp/logCommand.txt",std::ios::out);
00048         #else
00049         logfilecommand.open("logCommand.txt",std::ios::out);
00050         #endif
00051         plok=true;
00052 }
00053 
00054 ExManagerCommand::~ExManagerCommand(void)
00055 {
00056 }
00057 
00058 bool ExManagerCommand::LoadCommandFile(std::string FileName)
00059 {
00060 Guard(bool ExManagerCommand::LoadCommandFile(std::string FileName))
00061         char buffer[255];
00062         
00063 #ifdef UNIX_SRC
00064         sprintf(buffer, PREFIX "/ExNihilo/Data/Command/%s", FileName.data());
00065 #else
00066         sprintf(buffer, "../Data/Command/%s",FileName.data());
00067 #endif
00068     
00069 /*      ExCFileReader my_file (buffer);
00070         if (! my_file.exist()) 
00071         {
00072                 *Consol<<"File not found: "<<buffer<<std::endl;
00073                 return false;
00074         } else 
00075         {
00076                 *Consol<<"Loading Command File: "<<FileName<<std::endl; 
00077                 ExCFileData _data = my_file.getContent();
00078                 
00079                 if (_data.getType() != FILE_COMMAND) 
00080                 {
00081                         *Consol<<FileName<<" is not a valide command file"<<std::endl;
00082                         return false;
00083                 } else 
00084                 {
00085                         vector<ExCFileDataAction> dd = _data.getContent();
00086                         vector<ExCFileDataAction>::iterator i = dd.begin ();
00087                         ExCFileDataAction f;
00088                         while (i != dd.end ()) 
00089                         {
00090                                 f = *i++;
00091                                 AddCommandAction (f);
00092                         }
00093                 }
00094                 return true;
00095         }
00096         */
00097         return false;
00098 UnGuard
00099 }
00100 
00101 
00102 void ExManagerCommand::InputCommand(int command)
00103 {
00104 Guard(void ExManagerCommand::InputCommand(int command))
00105         std::cout<<"ManagerCommand::InputCommand : plokiiiiiii"<<std::endl;
00106 UnGuard
00107 }
00108 
00109 
00110 ExCAction ExManagerCommand::InputCommand(ExCCommand Command)
00111 {
00112 Guard(ExCAction ExManagerCommand::InputCommand(ExCCommand Command))
00113         //std::cout<<"ManagerCommand::InputCommand :"<<Command.m_Command<<std::endl;
00114         if(ManagerConsole->AskForCommand())
00115         {
00116                 AddAction(ManagerConsole->InputCommand(Command));
00117                 if(ManagerConsole->AskForExclusifCommand())return NOTHING;
00118         }
00119         if(ManagerNetwork->AskForCommand())
00120         {
00121                 AddAction(ManagerNetwork->InputCommand(Command));
00122                 if(ManagerNetwork->AskForExclusifCommand())return NOTHING;
00123         }
00124         if(ManagerObjectWindow->AskForCommand())
00125         {
00126                 AddAction(ManagerObjectWindow->InputCommand(Command));
00127                 if(ManagerObjectWindow->AskForExclusifCommand())return NOTHING;
00128         }
00129         if(ManagerLoad->AskForCommand())
00130         {
00131                 AddAction(ManagerLoad->InputCommand(Command));
00132         //      if(ManagerLoad->AskForExclusifCommand())return NOTHING;
00133         }
00134         /*
00135         if(ManagerInterface->AskForCommand())
00136         {
00137                 AddAction(ManagerMenu->InputCommand(Command));
00138                 if(ManagerMenu->AskForExclusifCommand())return NOTHING;
00139         }*/
00140         ProcessCommand(Command);
00141         return NOTHING;
00142 UnGuard
00143 }
00144 
00145 
00146 void ExManagerCommand::ProcessCommand(ExCCommand command)
00147 {
00148 Guard(void ExManagerCommand::ProcessCommand(ExCCommand command))
00149         //std::cout<<"ManagerCommand::Process command :"<<command.m_Command<<std::endl;
00150         for(m_ItVecCommand=m_VecCommand.begin();m_ItVecCommand!=m_VecCommand.end();m_ItVecCommand++)
00151         {
00152                 if(m_ItVecCommand->first.m_Command==command.m_Command)
00153                 {
00154                         AddAction(m_ItVecCommand->second);
00155                 }
00156         }
00157 UnGuard
00158 }
00159 
00160 void ExManagerCommand::AddAction(ExCAction action)
00161 {
00162 Guard(void ExManagerCommand::AddAction(ExCAction action))       
00163         //std::cout<<"ManagerCommand::Add Action"<<action.m_Action<<std::endl;
00164         if(action.m_Action!=NOTHING)
00165         {
00166                 m_VecAction.push_back(action);
00167         }
00168 UnGuard
00169 }
00170 
00171 void ExManagerCommand::AddNewAction(ExCAction action)
00172 {
00173 Guard(void ExManagerCommand::AddNewAction(ExCAction action))    
00174         //std::cout<<"ManagerCommand::ADD NEW ACTION:"<<action;
00175         if(action.m_Action!=NOTHING)
00176         {
00177                 
00178                 m_VecTempAction.push_back(action);
00179         }
00180 UnGuard
00181 }
00182 
00183 void ExManagerCommand::RemoveRepAction(ExCAction action)
00184 {
00185 Guard(void ExManagerCommand::RemoveRepAction(ExCAction action)) 
00186         int i=0;
00187         for(m_ItVecRepAction=m_VecRepAction.begin();m_ItVecRepAction!=m_VecRepAction.end();m_ItVecRepAction++,i++)
00188         {
00189                 if(m_VecRepAction.at(i).m_Action==action.m_Action)
00190                 {
00191                         m_VecRepAction.erase(m_ItVecRepAction); break;
00192                 }
00193         }
00194 UnGuard
00195 }
00196 
00197 void ExManagerCommand::AddRepAction(ExCAction action)
00198 {
00199 Guard(void ExManagerCommand::AddRepAction(ExCAction action))    
00200         bool already=false;
00201         int i=0;
00202         for(m_ItVecRepAction=m_VecRepAction.begin();m_ItVecRepAction!=m_VecRepAction.end();m_ItVecRepAction++,i++)
00203         {
00204                 if(m_VecRepAction.at(i).m_Action==action.m_Action)
00205                 {
00206                         already=true;
00207                 }
00208         }  
00209         if(!already)
00210         {  
00211                 m_VecRepAction.push_back(action);
00212         }
00213 UnGuard
00214 }
00215 
00216 void ExManagerCommand::ApplyAction(void)
00217 {
00218 Guard(void ExManagerCommand::ApplyAction(void))
00219 //Read action on flux to apply;
00220 
00221 
00222 
00223 
00224         int i;
00225         std::vector<ExCAction>                  TmpVecAction;
00226         for(m_ItVecAction=m_VecAction.begin();m_ItVecAction!=m_VecAction.end();m_ItVecAction++,i++)
00227         {
00228                 //std::cout<<"ManagerCommand::Aplly Action :"<<m_VecAction.at(i)<<endl;
00229                 if(!ProcesExCAction(*m_ItVecAction))
00230                 {
00231                         AddNewAction(*m_ItVecAction);
00232                 }
00233         }
00234         
00235         //Remove executed action
00236         /*for(m_ItVecAction=m_VecAction.begin();m_ItVecAction!=m_VecAction.end();m_ItVecAction++)
00237         {
00238                 
00239                 if(!m_ItVecAction->AllActionDone())
00240                 {
00241                         TmpVecAction.push_back(*m_ItVecAction);
00242                 }else
00243                 {
00244                         std::cout<<"action not done :"<<m_ItVecAction->m_Action<<std::endl;
00245                 }
00246         }*/
00247         m_VecAction.clear();
00248         //m_VecAction=TmpVecAction;
00249         for(i=0; (unsigned)i<m_VecTempAction.size();i++)
00250         {
00251                 AddAction(m_VecTempAction.at(i));
00252         }
00253         m_VecTempAction.clear();
00254         i=0;
00255         for(m_ItVecRepAction=m_VecRepAction.begin();m_ItVecRepAction!=m_VecRepAction.end();m_ItVecRepAction++,i++)
00256         {
00257                 ProcesExCAction(m_VecRepAction.at(i));
00258         }
00259         while(FluxAction->GetSize()>0)
00260         {
00261                 AddAction(FluxAction->Pop());
00262         }       
00263 UnGuard
00264 }
00265 
00266 /*void ExManagerCommand::AddCommandAction (ExCFileDataAction e)
00267 {
00268 Guard(void ExManagerCommand::AddCommandAction(ExCFileDataAction e))
00269         CommandAction ComAct;
00270         ComAct.first = atoi (e.getAction ().data());
00271         ComAct.second.m_Action = e.getCommand ();
00272         ComAc t.second.m_Param  = e.getParam ();
00273         m_VecCommand.push_back (ComAct);
00274 UnGuard
00275 }*/
00276 
00277 void ExManagerCommand::AddCommandAction(int command,ExCAction action)
00278 {
00279 Guard(void ExManagerCommand::AddCommandAction(int command,ExCAction action))
00280         CommandAction ComAct;   
00281         ComAct.first=command;
00282         ComAct.second=action;
00283         /*
00284         ComAct.second.m_Action=action.m_Action;
00285         ComAct.second.m_Param= action.m_Param;*/
00286         m_VecCommand.push_back(ComAct);
00287 UnGuard
00288 }
00289 
00290 void ExManagerCommand::AddCommandAction(CommandAction ComAct)
00291 {
00292 Guard(void ExManagerCommand::AddCommandAction(CommandAction ComAct))
00293         m_VecCommand.push_back(ComAct);
00294 UnGuard
00295 }
00296 
00297 void ExManagerCommand::AddCommandAction(int command,int action,std::string param)
00298 {
00299 Guard(void ExManagerCommand::AddCommandAction(int command,int action,std::string param))
00300         CommandAction ComAct;
00301         ComAct.first=command;
00302         ComAct.second.m_Action=action;
00303         ComAct.second.m_Param= param;
00304         m_VecCommand.push_back(ComAct); 
00305 UnGuard
00306 }
00307 
00308 void ExManagerCommand::Init(void)
00309 {
00310 Guard(void ExManagerCommand::Init(void))
00311         AddCommandAction(KEYBOARD_DOWN_EXP,             ExCAction(CONSOL_NEXT_AVIABLE_STATE));
00312         AddCommandAction(MOUSE_RIGHT_BUTTON_DOWN,               ExCAction(TOGGLE_WINDOW));
00313         AddCommandAction(KEYBOARD_UP_PAGE_UP,   ExCAction(CONSOL_LINE_UP));
00314         AddCommandAction(KEYBOARD_UP_PAGE_DOWN, ExCAction(CONSOL_LINE_DOWN));
00315 
00316 
00317         AddCommandAction(KEYBOARD_DOWN_4,               ExCAction(CAMERA_CURRENT_START_ROTATEY_DOWN));
00318         AddCommandAction(KEYBOARD_UP_4,                 ExCAction(CAMERA_CURRENT_STOP_ROTATEY_DOWN));
00319         AddCommandAction(KEYBOARD_UP_5,                 ExCAction(CAMERA_CURRENT_INCREASE_SPEED));
00320         AddCommandAction(KEYBOARD_UP_0,                 ExCAction(CAMERA_CURRENT_DECREASE_SPEED));
00321         AddCommandAction(KEYBOARD_UP_S,                 ExCAction(CAMERA_CURRENT_FULL_STOP));
00322         AddCommandAction(KEYBOARD_DOWN_6,               ExCAction(CAMERA_CURRENT_START_ROTATEY_UP));
00323         AddCommandAction(KEYBOARD_UP_6,                 ExCAction(CAMERA_CURRENT_STOP_ROTATEY_UP));
00324         AddCommandAction(KEYBOARD_DOWN_2,               ExCAction(CAMERA_CURRENT_START_ROTATEX_UP));
00325         AddCommandAction(KEYBOARD_UP_2,                 ExCAction(CAMERA_CURRENT_STOP_ROTATEX_UP));
00326         AddCommandAction(KEYBOARD_DOWN_8,               ExCAction(CAMERA_CURRENT_START_ROTATEX_DOWN));
00327         AddCommandAction(KEYBOARD_UP_8,                 ExCAction(CAMERA_CURRENT_STOP_ROTATEX_DOWN));
00328         AddCommandAction(KEYBOARD_DOWN_1,               ExCAction(CAMERA_CURRENT_START_ROTATEZ_UP));
00329         AddCommandAction(KEYBOARD_UP_1,                 ExCAction(CAMERA_CURRENT_STOP_ROTATEZ_UP));
00330         AddCommandAction(KEYBOARD_DOWN_3,               ExCAction(CAMERA_CURRENT_START_ROTATEZ_DOWN));
00331         AddCommandAction(KEYBOARD_UP_3,                 ExCAction(CAMERA_CURRENT_STOP_ROTATEZ_DOWN));
00332         AddCommandAction(KEYBOARD_UP_A,                 ExCAction(CAMERA_CURRENT_STOP_INCREASE_ZOOM));
00333         AddCommandAction(KEYBOARD_UP_Q,                 ExCAction(CAMERA_CURRENT_STOP_DECREASE_ZOOM));
00334 
00335         //AddCommandAction(KEYBOARD_UP_ESC,                     ExCAction(QUIT));
00336 
00337         AddCommandAction(KEYBOARD_DOWN_A,               ExCAction(CAMERA_CURRENT_START_INCREASE_ZOOM));
00338         AddCommandAction(KEYBOARD_DOWN_Q,               ExCAction(CAMERA_CURRENT_START_DECREASE_ZOOM));
00339         AddCommandAction(KEYBOARD_UP_9,                 ExCAction(CAMERA_NEXT_CAM));
00340         AddCommandAction(KEYBOARD_UP_7,                 ExCAction(CAMERA_PREV_CAM));
00341         AddCommandAction(KEYBOARD_UP_F1,                ExCAction(STAR_ALL_PARTICULESYSTEME));
00342         AddCommandAction(KEYBOARD_UP_F2,                ExCAction(PAUSE_ALL_PARTICULESYSTEME));
00343 
00344 
00345         AddCommandAction(KEYBOARD_UP_G,                 ExCAction(SWITCH_GRIDE));
00346         
00347         //AddCommandAction(KEYBOARD_DOWN_T,             ExCAction(SAY));
00348 
00349         AddCommandAction(KEYBOARD_DOWN_SPACE,           ExCAction(MODEL_START_MOVE_FORWARD));
00350         AddCommandAction(KEYBOARD_UP_SPACE,                     ExCAction(MODEL_STOP_MOVE_FORWARD));
00351         
00352         AddCommandAction(KEYBOARD_DOWN_ARROW_RIGHT,             ExCAction(MODEL_START_ROTATE_Y_DOWN));
00353         AddCommandAction(KEYBOARD_UP_ARROW_RIGHT,                       ExCAction(MODEL_STOP_ROTATE_Y_DOWN));
00354         AddCommandAction(KEYBOARD_DOWN_ARROW_LEFT,              ExCAction(MODEL_START_ROTATE_Y_UP));
00355         AddCommandAction(KEYBOARD_UP_ARROW_LEFT,                        ExCAction(MODEL_STOP_ROTATE_Y_UP));
00356         //AddCommandAction(KEYBOARD_DOWN_ARROW_UP,              ExCAction(MODEL_JUMP));
00357         
00358 
00359 /*      AddCommandAction(KEYBOARD_DOWN_X,               ExCAction(MODEL_START_STRAFE_LEFT));
00360         AddCommandAction(KEYBOARD_UP_X,                 ExCAction(MODEL_STOP_STRAFE_LEFT));
00361         AddCommandAction(KEYBOARD_DOWN_W,               ExCAction(MODEL_START_STRAFE_RIGHT));
00362         AddCommandAction(KEYBOARD_UP_W,                 ExCAction(MODEL_STOP_STREFA_RIGHT));
00363 */      
00364         AddCommandAction(KEYBOARD_DOWN_ARROW_UP,                ExCAction(MODEL_START_ROTATE_Z_DOWN));
00365         AddCommandAction(KEYBOARD_UP_ARROW_UP,                  ExCAction(MODEL_STOP_ROTATE_Z_DOWN));
00366         AddCommandAction(KEYBOARD_DOWN_ARROW_DOWN,              ExCAction(MODEL_START_ROTATE_Z_UP));
00367         AddCommandAction(KEYBOARD_UP_ARROW_DOWN,                        ExCAction(MODEL_STOP_ROTATE_Z_UP));
00368 /*
00369         AddCommandAction(KEYBOARD_DOWN_U,               ExCAction(MODEL_START_ROTATE_X_DOWN));
00370         AddCommandAction(KEYBOARD_UP_U,                 ExCAction(MODEL_STOP_ROTATE_X_DOWN));
00371         AddCommandAction(KEYBOARD_DOWN_J,               ExCAction(MODEL_START_ROTATE_X_UP));
00372         AddCommandAction(KEYBOARD_UP_J,                 ExCAction(MODEL_STOP_ROTATE_X_UP));      
00373 */      
00374 //      AddCommandAction(KEYBOARD_DOWN_V,               ExCAction(START_ACTION," RUN"));
00375 //      AddCommandAction(KEYBOARD_DOWN_B,               ExCAction(START_ACTION," JUMP"));
00376         AddCommandAction(KEYBOARD_DOWN_N,               ExCAction(STOP_ACTION));
00377 
00378         AddCommandAction(KEYBOARD_DOWN_O,               ExCAction(CAMERA_CURRENT_START_INCREASE_AROUND));
00379         AddCommandAction(KEYBOARD_UP_O,                 ExCAction(CAMERA_CURRENT_STOP_INCREASE_AROUND));
00380         AddCommandAction(KEYBOARD_DOWN_P,               ExCAction(CAMERA_CURRENT_START_DECREASE_AROUND));
00381         AddCommandAction(KEYBOARD_UP_P,                 ExCAction(CAMERA_CURRENT_STOP_DECREASE_AROUND));        
00382 
00383         AddCommandAction(KEYBOARD_DOWN_L,               ExCAction(CAMERA_CURRENT_START_INCREASE_DISTANCE));
00384         AddCommandAction(KEYBOARD_UP_L,                 ExCAction(CAMERA_CURRENT_STOP_INCREASE_DISTANCE));
00385         AddCommandAction(KEYBOARD_DOWN_M,               ExCAction(CAMERA_CURRENT_START_DECREASE_DISTANCE));
00386         AddCommandAction(KEYBOARD_UP_M,                 ExCAction(CAMERA_CURRENT_STOP_DECREASE_DISTANCE));      
00387 
00388         AddCommandAction(KEYBOARD_DOWN_I,               ExCAction(CAMERA_CURRENT_START_INCREASE_HEIGHT));
00389         AddCommandAction(KEYBOARD_UP_I,                 ExCAction(CAMERA_CURRENT_STOP_INCREASE_HEIGHT));
00390         AddCommandAction(KEYBOARD_DOWN_K,               ExCAction(CAMERA_CURRENT_START_DECREASE_HEIGHT));
00391         AddCommandAction(KEYBOARD_UP_K,                 ExCAction(CAMERA_CURRENT_STOP_DECREASE_HEIGHT));
00392 
00393         //AddCommandAction(KEYBOARD_DOWN_F3,            ExCAction(MODEL_NEXT_MODEL));
00394         //AddCommandAction(KEYBOARD_DOWN_F4,            ExCAction(MODEL_PREV_MODEL));
00395         //AddCommandAction(KEYBOARD_DOWN_F5,            ExCAction(MODEL_STOP_ALL));
00396         //AddCommandAction(KEYBOARD_DOWN_F6,            ExCAction(MODEL_SHOW_COLLISION_SPHERE));
00397         
00398         //AddCommandAction(KEYBOARD_UP_F6,              ExCAction(HEIGHTMAP_INCREASE_TEXTURE_2_REPETITION));
00399         AddCommandAction(KEYBOARD_UP_F7,                ExCAction(HEIGHTMAP_DECREASE_TEXTURE_2_REPETITION));
00400         AddCommandAction(KEYBOARD_UP_F8,                ExCAction(HEIGHTMAP_INCREASE_FOG_DEPHT_LEVEL));
00401         AddCommandAction(KEYBOARD_UP_F9,                ExCAction(HEIGHTMAP_DECREASE_FOG_DEPHT_LEVEL));
00402         AddCommandAction(KEYBOARD_UP_F10,               ExCAction(HEIGHTMAP_SWITCH_FOG));
00403         AddCommandAction(KEYBOARD_UP_F11,               ExCAction(HEIGHTMAP_INCREASE_DETAIL_LEVEL));
00404         AddCommandAction(KEYBOARD_UP_F12,               ExCAction(HEIGHTMAP_DECREASE_DETAIL_LEVEL));
00405         
00406         AddCommandAction(KEYBOARD_UP_E,         ExCAction(SAVE_TEXTURE," screen.tga"));
00407 
00408         AddCommandAction(KEYBOARD_DOWN_W,               ExCAction(START_FADE_TO_WHITE));
00409         AddCommandAction(KEYBOARD_DOWN_X,               ExCAction(START_WITHE_TO_FADE));
00410         AddCommandAction(KEYBOARD_DOWN_C,               ExCAction(START_FADE_TO_BLACK));
00411         AddCommandAction(KEYBOARD_DOWN_V,               ExCAction(START_BLACK_TO_FADE));
00412         AddCommandAction(KEYBOARD_DOWN_B,               ExCAction(START_MOTION_BLUR));
00413         AddCommandAction(KEYBOARD_DOWN_N,               ExCAction(STOP_MOTION_BLUR));
00414         AddCommandAction(KEYBOARD_DOWN_T,               ExCAction(MANAGER_ANIMATION_TOGGLE_PAUSE_ALL_ANIMATION));
00415 UnGuard
00416 }
00417 
00418 
00419 void ExManagerCommand::LoadExecFile(std::string FileName)
00420 {
00421 Guard(void ExManagerCommand::LoadExecFile(std::string FileName))
00422         std::cout<<"Loading Programme :"<<FileName<<std::endl;
00423         ExCAction                       NewActionA;
00424         char                    buffer[255];
00425 #ifdef UNIX_SRC
00426         sprintf(buffer, PREFIX "/ExNihilo/Data/Program/%s", FileName.data());
00427 #else
00428         sprintf(buffer, "../Data/Program/%s", FileName.data());
00429 #endif
00430         std::ifstream fin;
00431         std::string buffstring;
00432         char b[256];
00433         fin.open(buffer,std::ios::in);
00434         if(fin.is_open())
00435         {
00436                 try
00437                 {
00438                         do
00439                         {
00440                                 memset(b,0,255);
00441                                 fin.getline(b,256,'\n');
00442                                 try
00443                                 {
00444                                         buffstring=ExNihilo::ExtracValueFromSring(b,"<Exec_Action>","<#Exec_Action>");
00445                                         NewActionA.m_Action=ExNihilo::ExtractIntValueFromSring(buffstring,"<Action>","<#Action>");
00446                                         NewActionA.m_Param=ExNihilo::ExtracValueFromSring(buffstring,"<Param>","<#Param>");
00447                                         NewActionA.m_Param1=ExNihilo::ExtracValueFromSring(buffstring,"<Param1>","<#Param1>");
00448                                         NewActionA.m_Param2=ExNihilo::ExtracValueFromSring(buffstring,"<Param2>","<#Param2>");
00449                                         NewActionA.m_ExecutingLife=ExNihilo::ExtractIntValueFromSring(buffstring,"<Timer>","<#Timer>");
00450                                         NewActionA.m_StartingLife=(double)((double)glutGet(GLUT_ELAPSED_TIME)/1000);
00451                                         //std::cout<<"READNEW ACTION:"<<NewActionA<<std::endl;;
00452                                         //AddNewAction(NewActionA);
00453                                         FluxAction->Push(NewActionA);
00454                                 }catch(ExCExpStringNotFound){}
00455                         }while(!fin.eof());
00456                         fin.close();
00457                 }catch(...)
00458                 {
00459                         std::cout<<"ExCExpFileReadError"<<std::endl; 
00460                         throw ExCExpFileReadError();
00461                 }
00462         }else
00463         {
00464                 std::cout<<"ExCExpFileNotFound:"<<buffer<<std::endl; 
00465                 throw   ExCExpFileNotFound();
00466         }
00467         //std::cout<<"FIN"<<std::endl;;
00468 UnGuard
00469 }
00470 
00471 
00472 bool ExManagerCommand::LoadFile(std::string FileName)
00473 {
00474         ExCAction action;
00475         action.SetParam(FileName);
00476         action.m_Action=30038;
00477     AddNewAction(action);
00478         return true;
00479 }
00480 //-----------------------------------------------------------
00481 // ici taper ce que fait l action
00482 //-----------------------------------------------------------
00483 bool ExManagerCommand::ProcesExCAction(ExCAction action)
00484 {
00485 Guard(bool ExManagerCommand::ProcesExCAction(ExCAction action))
00486         if(action.m_executed==false)//check if action already executed
00487         {
00488         
00489                 std::string Param;
00490                 Param=action.m_Param;
00491                 Param.erase(Param.begin(),Param.begin()+1);
00492                 
00493                 ExCAction NAction(action);
00494                 //NAction.m_Action=action.m_Action;
00495                 NAction.m_Param=Param;
00496 
00497                 //check if is time to execute action
00498                 double ctime;
00499                 ctime=(double)((double)glutGet(GLUT_ELAPSED_TIME)/1000);
00500                 //std::cout<<"ManagerCommand::"<<action<<std::endl;
00501                 if(action.m_ExecutingLife<0||(double)ctime-action.m_ExecutingLife>=(action.m_StartingLife))
00502                 {
00503                         if(LogCommand)
00504                         {
00505                                 logfilecommand<<"Process Action :"<<action.m_Action<<" Param :"<<action.m_Param<<std::endl;
00506                         }
00507                         //*Consol<<action;
00508                         //std::cout<<"ManagerCommand::Process Action :"<<action.m_Action<<" Param :"<<action.m_Param<<std::endl;
00509                         //time to execute action
00510                         //-------------------------------------------------
00511                         //BASIC ACTION
00512                         //-------------------------------------------------
00513                         if(action.m_Action>=START_BASIC_ACTION_MAP && action.m_Action<END_BASIC_ACTION_MAP) 
00514                         {
00515                                 switch(action.m_Action)
00516                                 {
00517                                 case NOTHING:
00518                                         break;
00519                                 case QUIT:
00520                                         exit(0);
00521                                         break;
00522                                 case RESET:
00523                                         ManagerId->Reset();
00524                                         ManagerCollision->Reset();
00525                                         ManagerAnim->Reset();
00526                                         ManagerMap->Reset();    
00527                                         ManagerFog->Reset();
00528                                         ManagerModel->Reset();
00529                                         ManagerGizmo->Reset();
00530                                         ManagerLight->Reset();
00531                                         ManagerCamera->Reset();
00532                                         ManagerParticuleSystem->Reset();
00533                                         ManagerTexture->Reset();
00534                                         ManagerInterface->Reset();
00535                                         ManagerConsole->Reset();
00536                                         ManagerSpirit->Reset();
00537                                         ManagerSound->Reset();
00538                                         ManagerObjectWindow->Reset();
00539                                         ManagerMesh->Reset();
00540                                         ManagerLoad->Reset();
00541                                         ManagerConsole->ClearConsol();
00542                                         ManagerEntity->Reset();
00543                                         
00544                                         *Consol<<"Engine reseted"<<std::endl;
00545                                         break;
00546                                 case RELOAD:
00547                                         Reload();
00548                                         ManagerAnim->Reload();
00549                                         ManagerCollision->Reload();
00550                                         ManagerGizmo->Reload();
00551                                         ManagerInterface->Reload();
00552                                         ManagerLight->Reload();
00553                                         ManagerMesh->Reload();
00554                                         ManagerModel->Reload();
00555                                         ManagerObjectWindow->Reload();
00556                                         ManagerParticuleSystem->Reload();
00557                                         ManagerSound->Reload();
00558                                         ManagerSpirit->Reload();
00559                                         ManagerTexture->Reload();
00560                                         ManagerConsole->Reload();
00561                                         ManagerMap->Reload();
00562                                         ManagerPVS->Reload();
00563                                         ManagerSpecialEffect->Reload();
00564                                         
00565                                 default:
00566                                         *Consol<<"Can not file action in BASIC_ACTION_MAP Action:"<<action.m_Action<<" Param:"<<Param<<std::endl;
00567                                         break;
00568                                 }
00569 
00570                         }
00571                         //-------------------------------------------------
00572                         //CONSOLE ACTION
00573                         //-------------------------------------------------
00574                         if(action.m_Action>START_CONSOL_ACTION_MAP && action.m_Action<END_CONSOL_ACTION_MAP) 
00575                         {
00576                                 AddNewAction(ManagerConsole->InputAction(NAction));
00577                         }
00578                         //-------------------------------------------------
00579                         //CAMERA ACTION
00580                         //-------------------------------------------------
00581                         if(action.m_Action>START_CAMERA_ACTION_MAP && action.m_Action<END_CAMERA_ACTION_MAP) 
00582                         {
00583                                 AddNewAction(ManagerCamera->InputAction(NAction));
00584                         }
00585                         //-------------------------------------------------
00586                         //CONSOL ACTION
00587                         //-------------------------------------------------
00588                         if(action.m_Action>START_CONSOL_ACTION_MAP && action.m_Action<END_CONSOL_ACTION_MAP) 
00589                         {
00590                                 AddNewAction(ManagerConsole->InputAction(NAction));
00591                         }
00592                         //-------------------------------------------------
00593                         //FOG ACTION
00594                         //-------------------------------------------------
00595                         if(action.m_Action>START_FOG_ACTION_MAP && action.m_Action<END_FOG_ACTION_MAP) 
00596                         {
00597                                 AddNewAction(ManagerFog->InputAction(NAction));
00598                         }
00599                         //-------------------------------------------------
00600                         //INTERFACE ACTION
00601                         //-------------------------------------------------
00602                         if(action.m_Action>START_INTERFACE_ACTION_MAP && action.m_Action<END_INTERFACE_ACTION_MAP) 
00603                         {
00604                                 AddNewAction(ManagerInterface->InputAction(NAction));
00605                         }
00606                         //-------------------------------------------------
00607                         //SOUND ACTION
00608                         //-------------------------------------------------
00609                         if(action.m_Action>START_SOUND_ACTION_MAP && action.m_Action<END_SOUND_ACTION_MAP) 
00610                         {
00611                                 AddNewAction(ManagerSound->InputAction(NAction));
00612                         }
00613                         //-------------------------------------------------
00614                         //MAP ACTION
00615                         //-------------------------------------------------
00616                         if(action.m_Action>START_MAP_ACTION_MAP && action.m_Action<END_MAP_ACTION_MAP) 
00617                         {
00618                                 AddNewAction(ManagerMap->InputAction(NAction));
00619                         }
00620                         //-------------------------------------------------
00621                         //PARTICULESYSTEME ACTION
00622                         //-------------------------------------------------
00623                         if(action.m_Action>START_PARTICULESYSTEME_ACTION_MAP && action.m_Action<END_PARTICULESYSTEME_ACTION_MAP) 
00624                         {
00625                                 AddNewAction(ManagerParticuleSystem->InputAction(NAction));
00626                         }
00627                         //-------------------------------------------------
00628                         //MODEL ACTION
00629                         //-------------------------------------------------
00630                         if(action.m_Action>START_MODEL_ACTION_MAP && action.m_Action<END_MODEL_ACTION_MAP) 
00631                         {
00632                                 AddNewAction(ManagerModel->InputAction(NAction));
00633                         }
00634                         //-------------------------------------------------
00635                         //NETWORK ACTION
00636                         //-------------------------------------------------
00637                         if(action.m_Action>START_NETWORK_ACTION_MAP && action.m_Action<END_NETWORK_ACTION_MAP) 
00638                         {
00639                                 AddNewAction(ManagerNetwork->InputAction(NAction));
00640                         }
00641                         //-------------------------------------------------
00642                         //ID ACTION
00643                         //-------------------------------------------------
00644                         if(action.m_Action>START_ID_ACTION_MAP && action.m_Action<END_ID_ACTION_MAP) 
00645                         {
00646                                 AddNewAction(ManagerId->InputAction(NAction));
00647                         }
00648                         //-------------------------------------------------
00649                         //MAIN WINDOW ACTION
00650                         //-------------------------------------------------
00651                         if(action.m_Action>START_WINDOW_ACTION_MAP && action.m_Action<END_WINDOW_ACTION_MAP) 
00652                         {
00653                                 AddNewAction(ManagerWindow->InputAction(NAction));
00654                         }
00655                         //-------------------------------------------------
00656                         //OBJECT WINDOW ACTION
00657                         //-------------------------------------------------
00658                         if(action.m_Action>START_OBJECT_WINDOW_ACTION_MAP && action.m_Action<END_OBJECT_WINDOW_ACTION_MAP) 
00659                         {
00660                                 AddNewAction(ManagerObjectWindow->InputAction(NAction));
00661                         }
00662                         //-------------------------------------------------
00663                         //TEXTURE ACTION
00664                         //-------------------------------------------------
00665                         if(action.m_Action>START_TEXTURE_ACTION_MAP && action.m_Action<END_TEXTURE_ACTION_MAP) 
00666                         {
00667                                 AddNewAction(ManagerTexture->InputAction(NAction));
00668                         }
00669                         //-------------------------------------------------
00670                         //SPECIALEFFECT ACTION
00671                         //-------------------------------------------------
00672                         if(action.m_Action>START_SPECIALEFFECT_ACTION_MAP && action.m_Action<END_SPECIALEFFECT_ACTION_MAP) 
00673                         {
00674                                 AddNewAction(ManagerSpecialEffect->InputAction(NAction));
00675                         }
00676                         //-------------------------------------------------
00677                         //MESH ACTION
00678                         //-------------------------------------------------
00679                         if(action.m_Action>START_MESH_ACTION_MAP && action.m_Action<END_MESH_ACTION_MAP) 
00680                         {
00681                                 AddNewAction(ManagerMesh->InputAction(NAction));
00682                         }
00683                         //-------------------------------------------------
00684                         //LOAD ACTION
00685                         //-------------------------------------------------
00686                         if(action.m_Action>START_LOAD_ACTION_MAP && action.m_Action<END_LOAD_ACTION_MAP) 
00687                         {
00688                                 AddNewAction(ManagerLoad->InputAction(NAction));
00689                         }
00690                         //-------------------------------------------------
00691                         //PVS ACTION
00692                         //-------------------------------------------------
00693                         if(action.m_Action>START_PVS_ACTION_MAP && action.m_Action<END_PVS_ACTION_MAP) 
00694                         {
00695                                 AddNewAction(ManagerPVS->InputAction(NAction));
00696                         }
00697                         //-------------------------------------------------
00698                         //ENTITY ACTION
00699                         //-------------------------------------------------
00700                         if(action.m_Action>START_ENTITY_ACTION_MAP && action.m_Action<END_ENTITY_ACTION_MAP) 
00701                         {
00702                                 AddNewAction(ManagerEntity->InputAction(NAction));
00703                         }
00704                         //-------------------------------------------------
00705                         //ANIMATION ACTION
00706                         //-------------------------------------------------
00707                         if(action.m_Action>START_ANIMATION_ACTION_MAP && action.m_Action<END_ANIMATION_ACTION_MAP) 
00708                         {
00709                                 AddNewAction(ManagerAnim->InputAction(NAction));
00710                         }
00711                         //-------------------------------------------------
00712                         //COMMAND ACTION
00713                         //-------------------------------------------------
00714                         if(action.m_Action>START_COMMAND_ACTION_MAP && action.m_Action<END_COMMAND_ACTION_MAP) 
00715                         {
00716                                 AddNewAction(InputAction(NAction));
00717                         }
00718                 }else   AddNewAction(action);
00719         }
00720     //action.m_executed=false;
00721         //to call all acton in the stack
00722         if(action.m_NextAction!=NULL)
00723         {
00724                 ProcesExCAction(*action.m_NextAction);
00725         }
00726         if(action.m_ActionNumber==0)//this is the first action of the stack
00727         {
00728                 if(action.AllActionDone())//all action in the stack was done
00729                 {
00730                         return true;
00731                 }
00732         }
00733         return false;
00734 UnGuard
00735 }
00736 
00737 
00738 
00739 
00740 ExCAction ExManagerCommand::InputAction(ExCAction Action)
00741 {
00742 Guard(ExCAction ExManagerCommand::InputAction(ExCAction Action))
00743         //std::cout<<"ExManagerCommand::InputAction::"<<Action<<std::endl;
00744         switch(Action.m_Action)
00745         {               
00746         case LOAD_EXEC_CONFIG_FILE:
00747                 LoadExecFile(Action.m_Param.data());
00748                 break;
00749 
00750         default:
00751                 *Consol<<"Can not file action in COMMAND_ACTION_MAP Action:"<<Action.m_Action<<" Param:"<<Action.m_Param<<std::endl;
00752                 break;
00753         }
00754         if(Action.m_NextAction){return *Action.m_NextAction;}
00755         else{return NOTHING;}
00756 UnGuard
00757 }
00758 

Généré le Tue Oct 28 12:43:35 2003 pour ExNihilo par doxygen 1.3.4