00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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;
00034 m_instance = new ExManagerCommand;
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",ios::out);
00048 #else
00049 logfilecommand.open("logCommand.txt",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 UnGuard
00098 }
00099
00100
00101 void ExManagerCommand::InputCommand(int command)
00102 {
00103 Guard(void ExManagerCommand::InputCommand(int command))
00104 std::cout<<"ManagerCommand::InputCommand : plokiiiiiii"<<std::endl;
00105 UnGuard
00106 }
00107
00108
00109 ExCAction ExManagerCommand::InputCommand(ExCCommand Command)
00110 {
00111 Guard(ExCAction ExManagerCommand::InputCommand(ExCCommand Command))
00112
00113 if(ManagerConsole->AskForCommand())
00114 {
00115 AddAction(ManagerConsole->InputCommand(Command));
00116 if(ManagerConsole->AskForExclusifCommand())return NOTHING;
00117 }
00118 if(ManagerMenu->AskForCommand())
00119 {
00120 AddAction(ManagerMenu->InputCommand(Command));
00121 if(ManagerMenu->AskForExclusifCommand())return NOTHING;
00122 }
00123
00124
00125
00126
00127
00128 ProcessCommand(Command);
00129 return NOTHING;
00130 UnGuard
00131 }
00132
00133
00134 void ExManagerCommand::ProcessCommand(ExCCommand command)
00135 {
00136 Guard(void ExManagerCommand::ProcessCommand(ExCCommand command))
00137
00138 for(m_ItVecCommand=m_VecCommand.begin();m_ItVecCommand!=m_VecCommand.end();m_ItVecCommand++)
00139 {
00140 if(m_ItVecCommand->first.m_Command==command.m_Command)
00141 {
00142 AddAction(m_ItVecCommand->second);
00143 }
00144 }
00145 UnGuard
00146 }
00147
00148 void ExManagerCommand::AddAction(ExCAction action)
00149 {
00150 Guard(void ExManagerCommand::AddAction(ExCAction action))
00151
00152 if(action.m_Action!=NOTHING)
00153 {
00154 m_VecAction.push_back(action);
00155 }
00156 UnGuard
00157 }
00158
00159 void ExManagerCommand::AddNewAction(ExCAction action)
00160 {
00161 Guard(void ExManagerCommand::AddNewAction(ExCAction action))
00162
00163 if(action.m_Action!=NOTHING)
00164 {
00165 m_VecTempAction.push_back(action);
00166 }
00167 UnGuard
00168 }
00169
00170 void ExManagerCommand::RemoveRepAction(ExCAction action)
00171 {
00172 Guard(void ExManagerCommand::RemoveRepAction(ExCAction action))
00173 int i=0;
00174 for(m_ItVecRepAction=m_VecRepAction.begin();m_ItVecRepAction!=m_VecRepAction.end();m_ItVecRepAction++,i++)
00175 {
00176 if(m_VecRepAction.at(i).m_Action==action.m_Action)
00177 {
00178 m_VecRepAction.erase(m_ItVecRepAction); break;
00179 }
00180 }
00181 UnGuard
00182 }
00183
00184 void ExManagerCommand::AddRepAction(ExCAction action)
00185 {
00186 Guard(void ExManagerCommand::AddRepAction(ExCAction action))
00187 bool already=false;
00188 int i=0;
00189 for(m_ItVecRepAction=m_VecRepAction.begin();m_ItVecRepAction!=m_VecRepAction.end();m_ItVecRepAction++,i++)
00190 {
00191 if(m_VecRepAction.at(i).m_Action==action.m_Action)
00192 {
00193 already=true;
00194 }
00195 }
00196 if(!already)
00197 {
00198 m_VecRepAction.push_back(action);
00199 }
00200 UnGuard
00201 }
00202
00203 void ExManagerCommand::ApplyAction(void)
00204 {
00205 Guard(void ExManagerCommand::ApplyAction(void))
00206 int i;
00207 std::vector<ExCAction> TmpVecAction;
00208 for(m_ItVecAction=m_VecAction.begin();m_ItVecAction!=m_VecAction.end();m_ItVecAction++,i++)
00209 {
00210
00211 if(!ProcesExCAction(*m_ItVecAction))
00212 {
00213 AddNewAction(*m_ItVecAction);
00214 }
00215 }
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229 m_VecAction.clear();
00230
00231 for(i=0; (unsigned)i<m_VecTempAction.size();i++)
00232 {
00233 AddAction(m_VecTempAction.at(i));
00234 }
00235 m_VecTempAction.clear();
00236 i=0;
00237 for(m_ItVecRepAction=m_VecRepAction.begin();m_ItVecRepAction!=m_VecRepAction.end();m_ItVecRepAction++,i++)
00238 {
00239 ProcesExCAction(m_VecRepAction.at(i));
00240 }
00241
00242 UnGuard
00243 }
00244
00245 void ExManagerCommand::AddCommandAction (ExCFileDataAction e)
00246 {
00247 Guard(void ExManagerCommand::AddCommandAction(ExCFileDataAction e))
00248 CommandAction ComAct;
00249 ComAct.first = atoi (e.getAction ().data());
00250 ComAct.second.m_Action = e.getCommand ();
00251 ComAct.second.m_Param = e.getParam ();
00252 m_VecCommand.push_back (ComAct);
00253 UnGuard
00254 }
00255
00256 void ExManagerCommand::AddCommandAction(int command,ExCAction action)
00257 {
00258 Guard(void ExManagerCommand::AddCommandAction(int command,ExCAction action))
00259 CommandAction ComAct;
00260 ComAct.first=command;
00261 ComAct.second=action;
00262
00263
00264
00265 m_VecCommand.push_back(ComAct);
00266 UnGuard
00267 }
00268
00269 void ExManagerCommand::AddCommandAction(CommandAction ComAct)
00270 {
00271 Guard(void ExManagerCommand::AddCommandAction(CommandAction ComAct))
00272 m_VecCommand.push_back(ComAct);
00273 UnGuard
00274 }
00275
00276 void ExManagerCommand::AddCommandAction(int command,int action,std::string param)
00277 {
00278 Guard(void ExManagerCommand::AddCommandAction(int command,int action,std::string param))
00279 CommandAction ComAct;
00280 ComAct.first=command;
00281 ComAct.second.m_Action=action;
00282 ComAct.second.m_Param= param;
00283 m_VecCommand.push_back(ComAct);
00284 UnGuard
00285 }
00286
00287 void ExManagerCommand::Init(void)
00288 {
00289 Guard(void ExManagerCommand::Init(void))
00290 AddCommandAction(KEYBOARD_DOWN_ESC, ExCAction(ENABLE_DISABLE_MENU));
00291 AddCommandAction(KEYBOARD_DOWN_EXP, ExCAction(CONSOL_NEXT_AVIABLE_STATE));
00292 AddCommandAction(KEYBOARD_UP_PAGE_UP, ExCAction(CONSOL_LINE_UP));
00293 AddCommandAction(KEYBOARD_UP_PAGE_DOWN, ExCAction(CONSOL_LINE_DOWN));
00294 AddCommandAction(KEYBOARD_DOWN_4, ExCAction(CAMERA_CURRENT_START_ROTATEY_DOWN));
00295 AddCommandAction(KEYBOARD_UP_4, ExCAction(CAMERA_CURRENT_STOP_ROTATEY_DOWN));
00296 AddCommandAction(KEYBOARD_UP_5, ExCAction(CAMERA_CURRENT_INCREASE_SPEED));
00297 AddCommandAction(KEYBOARD_UP_0, ExCAction(CAMERA_CURRENT_DECREASE_SPEED));
00298 AddCommandAction(KEYBOARD_UP_S, ExCAction(CAMERA_CURRENT_FULL_STOP));
00299 AddCommandAction(KEYBOARD_DOWN_6, ExCAction(CAMERA_CURRENT_START_ROTATEY_UP));
00300 AddCommandAction(KEYBOARD_UP_6, ExCAction(CAMERA_CURRENT_STOP_ROTATEY_UP));
00301 AddCommandAction(KEYBOARD_DOWN_2, ExCAction(CAMERA_CURRENT_START_ROTATEX_UP));
00302 AddCommandAction(KEYBOARD_UP_2, ExCAction(CAMERA_CURRENT_STOP_ROTATEX_UP));
00303 AddCommandAction(KEYBOARD_DOWN_8, ExCAction(CAMERA_CURRENT_START_ROTATEX_DOWN));
00304 AddCommandAction(KEYBOARD_UP_8, ExCAction(CAMERA_CURRENT_STOP_ROTATEX_DOWN));
00305 AddCommandAction(KEYBOARD_DOWN_1, ExCAction(CAMERA_CURRENT_START_ROTATEZ_UP));
00306 AddCommandAction(KEYBOARD_UP_1, ExCAction(CAMERA_CURRENT_STOP_ROTATEZ_UP));
00307 AddCommandAction(KEYBOARD_DOWN_3, ExCAction(CAMERA_CURRENT_START_ROTATEZ_DOWN));
00308 AddCommandAction(KEYBOARD_UP_3, ExCAction(CAMERA_CURRENT_STOP_ROTATEZ_DOWN));
00309 AddCommandAction(KEYBOARD_UP_A, ExCAction(CAMERA_CURRENT_STOP_INCREASE_ZOOM));
00310 AddCommandAction(KEYBOARD_UP_Q, ExCAction(CAMERA_CURRENT_STOP_DECREASE_ZOOM));
00311 AddCommandAction(KEYBOARD_DOWN_A, ExCAction(CAMERA_CURRENT_START_INCREASE_ZOOM));
00312 AddCommandAction(KEYBOARD_DOWN_Q, ExCAction(CAMERA_CURRENT_START_DECREASE_ZOOM));
00313 AddCommandAction(KEYBOARD_UP_9, ExCAction(CAMERA_NEXT_CAM));
00314 AddCommandAction(KEYBOARD_UP_7, ExCAction(CAMERA_PREV_CAM));
00315 AddCommandAction(KEYBOARD_UP_F1, ExCAction(STAR_ALL_PARTICULESYSTEME));
00316 AddCommandAction(KEYBOARD_UP_F2, ExCAction(PAUSE_ALL_PARTICULESYSTEME));
00317
00318
00319 AddCommandAction(KEYBOARD_UP_G, ExCAction(SWITCH_GRIDE));
00320
00321
00322 AddCommandAction(KEYBOARD_UP_F3, ExCAction(PLAY_SOUND," idiot.wav"));
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343 UnGuard
00344 }
00345
00346 void ExManagerCommand::LoadSetOfFile(const char *FileName)
00347 {
00348 Guard(void ExManagerCommand::LoadSetOfFile(const char *FileName))
00349 char ch;
00350 int RetVal;
00351 int FileSize;
00352 FILE *MyFile;
00353 bool endfile=false;
00354
00355 std::string StBuffer;
00356 std::string StType;
00357 char buffer[255];
00358
00359 #ifdef UNIX_SRC
00360 sprintf(buffer, PREFIX "/ExNihilo/Data/%s",FileName);
00361 #else
00362 sprintf(buffer, "../Data/%s",FileName);
00363 #endif
00364
00365 MyFile=fopen (buffer,"r");
00366 if(!MyFile)
00367 {
00368 *Consol<<"File not found:"<<buffer<<std::endl;
00369 }else
00370 {
00371 *Consol<<"Loading set File :"<<FileName<<std::endl;
00372
00373 fseek(MyFile,0,SEEK_END);
00374 FileSize=ftell(MyFile);
00375
00376 fseek(MyFile,0,SEEK_SET);
00377 do
00378 {
00379 RetVal=fread(&ch,sizeof(char),1,MyFile);
00380 }while(ch!='#');
00381
00382 do
00383 {
00384 RetVal=fread(&ch,sizeof(char),1,MyFile);
00385 StBuffer=StBuffer+ch;
00386 }while(ch!='#');
00387 if(strcmp(StBuffer.data(),"set#")==0)
00388 {
00389
00390 do
00391 {
00392
00393 StBuffer.erase(StBuffer.begin(),StBuffer.end());
00394 do
00395 {
00396 RetVal=fread(&ch,sizeof(char),1,MyFile);
00397 StBuffer=StBuffer+ch;
00398 }while(ch!='#');
00399 StBuffer.erase(StBuffer.end()-1,StBuffer.end());
00400 StBuffer.erase(StBuffer.begin(),StBuffer.begin()+1);
00401 if(StBuffer.find("end of set file") != (unsigned)-1)
00402 {
00403 endfile=true;
00404 }else
00405 {
00406 StType=StBuffer;
00407 StBuffer.erase(StBuffer.begin(),StBuffer.end());
00408 do
00409 {
00410 RetVal=fread(&ch,sizeof(char),1,MyFile);
00411 StBuffer=StBuffer+ch;
00412 }while(ch!='#');
00413 StBuffer.erase(StBuffer.end()-1,StBuffer.end());
00414
00415 if(strcmp(StType.data(),"command")==0)
00416 {
00417 std::cout<<"Load command file :"<<StBuffer.data()<<std::endl;
00418 LoadCommandFile(StBuffer.data());
00419 }
00420 if(strcmp(StType.data(),"console")==0)
00421 {
00422 std::cout<<"Load console file :"<<StBuffer.data()<<std::endl;
00423 ManagerConsole->LoadStringActionFile(StBuffer.data());
00424 }
00425 if(strcmp(StType.data(),"interface")==0)
00426 {
00427 std::cout<<"Load interface file :"<<StBuffer.data()<<std::endl;
00428 ManagerInterface->Load(StBuffer.data());
00429 }
00430 if(strcmp(StType.data(),"modele")==0)
00431 {
00432 std::cout<<"Load asc file :"<<StBuffer.data()<<std::endl;
00433 ManagerModel->Load(StBuffer);
00434 }
00435 if(strcmp(StType.data(),"sound")==0)
00436 {
00437 std::cout<<"Load sound file :"<<StBuffer.data()<<std::endl;
00438 ManagerSound->LoadSound(StBuffer.data());
00439 }
00440 if(strcmp(StType.data(),"set")==0)
00441 {
00442 std::cout<<"Load set file :"<<StBuffer.data()<<std::endl;
00443 LoadSetOfFile(StBuffer.data());
00444 }
00445 if(strcmp(StType.data(),"exec")==0)
00446 {
00447 std::cout<<"Load set file :"<<StBuffer.data()<<std::endl;
00448
00449 ExCAction action;
00450 action.SetParam(StBuffer.data());
00451
00452 }
00453 if(strcmp(StType.data(),"map")==0)
00454 {
00455 std::cout<<"Load map file :"<<StBuffer.data()<<std::endl;
00456 ManagerMap->LoadMap(StBuffer.data());
00457 }
00458
00459 }
00460 }while(!endfile);
00461 fclose(MyFile);
00462 }else
00463 {
00464 *Consol<<FileName<<" is not a valide console file"<<std::endl;
00465 }
00466 }
00467 UnGuard
00468 }
00469
00470 void ExManagerCommand::LoadExecFile(std::string FileName)
00471 {
00472 Guard(void ExManagerCommand::LoadExecFile(std::string FileName))
00473 ExCAction NewActionA;
00474 char buffer[255];
00475 #ifdef UNIX_SRC
00476 sprintf(buffer, PREFIX "/ExNihilo/Data/Command/%s", FileName.data());
00477 #else
00478 sprintf(buffer, "../Data/Command/%s", FileName.data());
00479 #endif
00480 std::ifstream fin;
00481 std::string buffstring;
00482 char b[256];
00483 fin.open(buffer,std::ios::in);
00484 if(fin.is_open())
00485 {
00486 try
00487 {
00488 do
00489 {
00490 memset(b,0,255);
00491 fin.getline(b,256,'\n');
00492 try
00493 {
00494 buffstring=ExNihilo::ExtracValueFromSring(b,"<Exec_Action>","<#Exec_Action>");
00495 NewActionA.m_Action=ExNihilo::ExtractIntValueFromSring(buffstring,"<Action>","<#Action>");
00496 NewActionA.m_Param=ExNihilo::ExtracValueFromSring(buffstring,"<Param>","<#Param>");
00497 NewActionA.m_Param1=ExNihilo::ExtracValueFromSring(buffstring,"<Param1>","<#Param1>");
00498 NewActionA.m_Param2=ExNihilo::ExtracValueFromSring(buffstring,"<Param2>","<#Param2>");
00499 NewActionA.m_ExecutingLife=ExNihilo::ExtractIntValueFromSring(buffstring,"<Timer>","<#Timer>");
00500 NewActionA.m_StartingLife=(double)((double)glutGet(GLUT_ELAPSED_TIME)/1000);
00501
00502 AddNewAction(NewActionA);
00503 }catch(ExCExpStringNotFound){}
00504 }while(!fin.eof());
00505 fin.close();
00506 }catch(...){throw ExCExpFileReadError();}
00507 }else throw ExCExpFileNotFound();
00508 UnGuard
00509 }
00510
00511
00512 bool ExManagerCommand::LoadFile(std::string FileName)
00513 {
00514 ExCAction action;
00515 action.SetParam(FileName);
00516 action.m_Action=30038;
00517 AddNewAction(action);
00518 return true;
00519 }
00520
00521
00522
00523 bool ExManagerCommand::ProcesExCAction(ExCAction action)
00524 {
00525 Guard(bool ExManagerCommand::ProcesExCAction(ExCAction action))
00526 if(action.m_executed==false)
00527 {
00528
00529 std::string Param;
00530 Param=action.m_Param;
00531 Param.erase(Param.begin(),Param.begin()+1);
00532
00533 ExCAction NAction(action);
00534
00535 NAction.m_Param=Param;
00536
00537
00538 double ctime;
00539 ctime=(double)((double)glutGet(GLUT_ELAPSED_TIME)/1000);
00540 if(action.m_ExecutingLife<0||(double)ctime-action.m_ExecutingLife>=(action.m_StartingLife))
00541 {
00542 if(LogCommand)
00543 {
00544 logfilecommand<<"Process Action :"<<action.m_Action<<" Param :"<<action.m_Param<<std::endl;
00545 }
00546
00547
00548
00549
00550
00551
00552 if(action.m_Action>=START_BASIC_ACTION_MAP && action.m_Action<END_BASIC_ACTION_MAP)
00553 {
00554 switch(action.m_Action)
00555 {
00556 case NOTHING:
00557 break;
00558 case QUIT:
00559 exit(0);
00560 break;
00561 case RESET:
00562 ManagerId->Reset();
00563 ManagerMenu->Reset();
00564 ManagerCollision->Reset();
00565 ManagerAnim->Reset();
00566 ManagerMap->Reset();
00567 ManagerFog->Reset();
00568 ManagerModel->Reset();
00569 ManagerGizmo->Reset();
00570 ManagerLight->Reset();
00571 ManagerCamera->Reset();
00572 ManagerParticuleSystem->Reset();
00573 ManagerTexture->Reset();
00574 ManagerInterface->Reset();
00575 ManagerConsole->Reset();
00576 ManagerSpirit->Reset();
00577 ManagerSound->Reset();
00578 ManagerConsole->ClearConsol();
00579 *Consol<<"Engine reseted"<<std::endl;
00580 break;
00581 default:
00582 *Consol<<"Can not file action in BASIC_ACTION_MAP Action:"<<action.m_Action<<" Param:"<<Param<<std::endl;
00583 break;
00584 }
00585
00586 }
00587
00588
00589
00590 if(action.m_Action>START_CONSOL_ACTION_MAP && action.m_Action<END_CONSOL_ACTION_MAP)
00591 {
00592 AddNewAction(ManagerConsole->InputAction(NAction));
00593 }
00594
00595
00596
00597 if(action.m_Action>START_CAMERA_ACTION_MAP && action.m_Action<END_CAMERA_ACTION_MAP)
00598 {
00599 AddNewAction(ManagerCamera->InputAction(NAction));
00600 }
00601
00602
00603
00604 if(action.m_Action>START_CONSOL_ACTION_MAP && action.m_Action<END_CONSOL_ACTION_MAP)
00605 {
00606 AddNewAction(ManagerConsole->InputAction(NAction));
00607 }
00608
00609
00610
00611 if(action.m_Action>START_FOG_ACTION_MAP && action.m_Action<END_FOG_ACTION_MAP)
00612 {
00613 AddNewAction(ManagerFog->InputAction(NAction));
00614 }
00615
00616
00617
00618 if(action.m_Action>START_INTERFACE_ACTION_MAP && action.m_Action<END_INTERFACE_ACTION_MAP)
00619 {
00620 AddNewAction(ManagerInterface->InputAction(NAction));
00621 }
00622
00623
00624
00625 if(action.m_Action>START_SOUND_ACTION_MAP && action.m_Action<END_SOUND_ACTION_MAP)
00626 {
00627 AddNewAction(ManagerSound->InputAction(NAction));
00628 }
00629
00630
00631
00632 if(action.m_Action>START_MAP_ACTION_MAP && action.m_Action<END_MAP_ACTION_MAP)
00633 {
00634 AddNewAction(ManagerMap->InputAction(NAction));
00635 }
00636
00637
00638
00639 if(action.m_Action>START_PARTICULESYSTEME_ACTION_MAP && action.m_Action<END_PARTICULESYSTEME_ACTION_MAP)
00640 {
00641 AddNewAction(ManagerParticuleSystem->InputAction(NAction));
00642 }
00643
00644
00645
00646 if(action.m_Action>START_MODEL_ACTION_MAP && action.m_Action<END_MODEL_ACTION_MAP)
00647 {
00648 AddNewAction(ManagerModel->InputAction(NAction));
00649 }
00650
00651
00652
00653 if(action.m_Action>START_MENU_ACTION_MAP && action.m_Action<END_MENU_ACTION_MAP)
00654 {
00655 AddNewAction(ManagerMenu->InputAction(NAction));
00656 }
00657
00658
00659
00660 if(action.m_Action>START_NETWORK_ACTION_MAP && action.m_Action<END_NETWORK_ACTION_MAP)
00661 {
00662 AddNewAction(ManagerNetwork->InputAction(NAction));
00663 }
00664
00665
00666
00667 if(action.m_Action>START_ID_ACTION_MAP && action.m_Action<END_ID_ACTION_MAP)
00668 {
00669 AddNewAction(ManagerId->InputAction(NAction));
00670 }
00671
00672
00673
00674 if(action.m_Action>START_WINDOW_ACTION_MAP && action.m_Action<END_WINDOW_ACTION_MAP)
00675 {
00676 AddNewAction(ManagerWindow->InputAction(NAction));
00677 }
00678
00679
00680
00681 if(action.m_Action>START_COMMAND_ACTION_MAP && action.m_Action<END_COMMAND_ACTION_MAP)
00682 {
00683 AddNewAction(InputAction(NAction));
00684 }
00685 }
00686 }
00687
00688
00689 if(action.m_NextAction!=NULL)
00690 {
00691 ProcesExCAction(*action.m_NextAction);
00692 }
00693 if(action.m_ActionNumber==0)
00694 {
00695 if(action.AllActionDone())
00696 {
00697 return true;
00698 }
00699 }
00700 return false;
00701 UnGuard
00702 }
00703
00704 void ExManagerCommand::DisplayFileType(void)
00705 {
00706 Guard(void ExManagerCommand::DisplayFileType(void))
00707 *Consol<<"*------------------------------------------------------------------------------------------------*"<<std::endl;
00708 *Consol<<"| Extension file supported by Exnihilo |"<<std::endl;
00709 *Consol<<"|------------------------------------------------------------------------------------------------|"<<std::endl;
00710 *Consol<<"|Description | Extension | Status | Comment |"<<std::endl;
00711 *Consol<<"|------------------------------------------------------------------------------------------------|"<<std::endl;
00712 *Consol<<"|Console configuration file | .csl | Aviable | Asign consol command to action |"<<std::endl;
00713 *Consol<<"|Command configuration file | .comd | Aviable | Asign input (keyboard,mouse,...)to action |"<<std::endl;
00714 *Consol<<"|------------------------------------------------------|-----------------------------------------|"<<std::endl;
00715 *Consol<<"|ExNihilo map file | .map | Aviable | Create map file with AscToMap converter |"<<std::endl;
00716 *Consol<<"|Quake map file | .bsp | | |"<<std::endl;
00717 *Consol<<"|------------------------------------------------------------------------------------------------|"<<std::endl;
00718 *Consol<<"|ASC model file | .asc | Aviable | Create a 3d model and export him to *.asc |"<<std::endl;
00719 *Consol<<"|MD2 (quake 2) model file | .md2 | Aviable | |"<<std::endl;
00720 *Consol<<"|MD3 (quake 3) model file | .md3 | | |"<<std::endl;
00721 *Consol<<"|ASE model file | .ase | | |"<<std::endl;
00722 *Consol<<"|3d studio max model file | .3ds | Aviable | |"<<std::endl;
00723 *Consol<<"|OBJ model file | .obj | | |"<<std::endl;
00724 *Consol<<"|------------------------------------------------------------------------------------------------|"<<std::endl;
00725 *Consol<<"|Wave sound file | .wav | | |"<<std::endl;
00726 *Consol<<"|Midi sound file | .mid | | |"<<std::endl;
00727 *Consol<<"|Mp3 sound file | .mp3 | | |"<<std::endl;
00728 *Consol<<"|------------------------------------------------------------------------------------------------|"<<std::endl;
00729 *Consol<<"|Particule system file | .part | Aviable | Use SDK partiucle to create *.part file |"<<std::endl;
00730 *Consol<<"|Interface file | .int | Aviable | Use SDK partiucle to create *.int file |"<<std::endl;
00731 *Consol<<"|------------------------------------------------------------------------------------------------|"<<std::endl;
00732 *Consol<<"|Groupe of file | .set | Aviable | |"<<std::endl;
00733 *Consol<<"|Groupe of action | .exec | Aviable | |"<<std::endl;
00734 *Consol<<"*------------------------------------------------------------------------------------------------*"<<std::endl;
00735 UnGuard
00736 }
00737
00738
00739 ExCAction ExManagerCommand::InputAction(ExCAction Action)
00740 {
00741 Guard(ExCAction ExManagerCommand::InputAction(ExCAction Action))
00742 switch(Action.m_Action)
00743 {
00744 case LOAD_PART_CONFIG_FILE:
00745 ManagerParticuleSystem->Load(Action.m_Param);
00746 break;
00747 case LOAD_EXEC_CONFIG_FILE:
00748 LoadExecFile(Action.m_Param.data());
00749 break;
00750 case LOAD_FILE:
00751 try
00752 {
00753 char Buffext[255];
00754 memset(Buffext,0,255);
00755
00756 if(Action.m_Param.find_first_of(".",0) != (unsigned)-1)
00757 {
00758 Action.m_Param.copy(Buffext,Action.m_Param.size()-Action.m_Param.find_first_of(".",0)-1,Action.m_Param.find_first_of(".",0)+1);
00759 if(strcmp(Buffext,"csl")==0)
00760 {
00761 ManagerConsole->LoadStringActionFile(Action.m_Param.data());
00762 break;
00763 }else
00764 if(strcmp(Buffext,"comd")==0)
00765 {
00766 LoadCommandFile(Action.m_Param);
00767 break;
00768 }else
00769 if(strcmp(Buffext,"wav")==0||strcmp(Buffext,"mid")==0)
00770 {
00771 ManagerSound->LoadSound(Action.m_Param);
00772 break;
00773 }else
00774 if(strcmp(Buffext,"asc")==0
00775 ||strcmp(Buffext,"ase")==0
00776 ||strcmp(Buffext,"3ds")==0
00777 ||strcmp(Buffext,"md2")==0
00778 ||strcmp(Buffext,"md3")==0
00779 ||strcmp(Buffext,"obj")==0)
00780 {
00781 ManagerModel->Load(Action.m_Param);
00782 break;
00783 }else
00784 if(strcmp(Buffext,"map")==0
00785 ||strcmp(Buffext,"bsp")==0)
00786 {
00787 ManagerMap->LoadMap(Action.m_Param.data());
00788 break;
00789 }else
00790 if(strcmp(Buffext,"int")==0)
00791 {
00792 ManagerInterface->Load(Action.m_Param);
00793 break;
00794 }else
00795 if(strcmp(Buffext,"set")==0)
00796 {
00797 LoadSetOfFile(Action.m_Param.data());
00798 break;
00799 }else
00800 if(strcmp(Buffext,"exec")==0)
00801 {
00802 LoadExecFile(Action.m_Param);
00803 break;
00804 }
00805 else
00806 if(strcmp(Buffext,"part")==0)
00807 {
00808 ManagerParticuleSystem->Load(Action.m_Param);
00809 break;
00810 }
00811 }else
00812 {
00813 *Consol<<"ExManagerCommand::ExCeption =>"<<Action.m_Param<<" Bad file extension"<<std::endl;
00814 }DisplayFileType();
00815
00816 }
00817 catch(ExCExpFileNotFound)
00818 {
00819 *Consol<<"ExManagerCommand::ExCeption =>"<<Action.m_Param<<" File not found"<<std::endl;
00820 return false;
00821 }
00822 catch(ExCExpFileReadError)
00823 {
00824 *Consol<<"ExManagerCommand::ExCeption =>"<<Action.m_Param<<" Read file error"<<std::endl;
00825 return false;
00826 }
00827 catch(...)
00828 {
00829 *Consol<<"ExManagerCommand::ExCeption =>"<<Action.m_Param<<" Unknow exception"<<std::endl;
00830 return false;
00831 }
00832 break;
00833
00834 case LOAD_SET_OF_FILE:
00835 LoadSetOfFile(Action.m_Param.data());
00836 break;
00837
00838 default:
00839 *Consol<<"Can not file action in COMMAND_ACTION_MAP Action:"<<Action.m_Action<<" Param:"<<Action.m_Param<<std::endl;
00840 break;
00841 }
00842 if(Action.m_NextAction){return *Action.m_NextAction;}
00843 else{return NOTHING;}
00844 UnGuard
00845 }
00846