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

ExCInterface Class Reference

#include <ExCInterface.h>

Inheritance diagram for ExCInterface:

ExCObject2D ExCObject

Public Methods

 ExCInterface (void)
 ExCInterface (std::string FileName)
 ~ExCInterface (void)
bool LoadFile (std::string FileName)
void SetManagerWindow (ExManagerWindow *Window)
void SetManagerTexture (ExManagerTexture *Texture)
void SetNumInterface (int num)
int GetNumInterface (void)
void ShowRegion (void)
void HideRegion (void)
void DisableInterface (void)
void EnableInterface (void)
bool GetInterfaceState (void)
void Draw (void)
ExCAction InputCommand (int command, int mousex, int mousey)

Data Fields

std::ostrstream * Consol

Private Attributes

ExManagerWindowManagerWindow
ExManagerTextureManagerTexture
std::string m_Texture
std::string m_TextureMask
int m_NumInterface
int m_DefaultResolutionX
int m_DefaultResolutionY
bool m_ShowRegion
bool m_State
std::vector< ActionCommandm_VecActionCommand
std::vector< ActionCommand
>::iterator 
m_ItVecActionCommand

Constructor & Destructor Documentation

ExCInterface void   
 

Definition at line 26 of file ExCInterface.cpp.

References ExCInterface(), Guard, m_ShowRegion, m_State, ExCObject::SetName(), and ExCObject::SetType().

Referenced by ExCInterface(), and ~ExCInterface().

00027 {
00028 Guard(ExCInterface::ExCInterface(void))
00029         m_ShowRegion=true;
00030         m_State=true;
00031         SetName("ExCInterface");
00032         SetType(typeid(this).name());
00033 UnGuard
00034 }

ExCInterface std::string    FileName
 

Definition at line 36 of file ExCInterface.cpp.

References ExCInterface(), Guard, LoadFile(), m_ShowRegion, and m_State.

00037 {
00038 Guard(ExCInterface::ExCInterface(std::string FileName))
00039         m_ShowRegion=true;
00040         m_State=true;
00041         LoadFile(FileName);
00042 UnGuard
00043 }

~ExCInterface void   
 

Definition at line 45 of file ExCInterface.cpp.

References ExCInterface(), and Guard.

00046 {
00047 Guard(ExCInterface::~ExCInterface(void))
00048 UnGuard
00049 }


Member Function Documentation

void DisableInterface void    [inline]
 

Definition at line 85 of file ExCInterface.h.

References m_ShowRegion.

00085 {m_ShowRegion=false;}

void Draw void    [virtual]
 

Reimplemented from ExCObject.

Definition at line 110 of file ExCInterface.cpp.

References Draw(), ExNihilo::EnterOrthoMode(), Guard, ExNihilo::LeaveOrthoMode(), m_Texture, m_TextureMask, ManagerTexture, and ExManagerTexture::SetCurrentObject().

Referenced by Draw().

00111 {
00112 Guard(void ExCInterface::Draw(void))
00113     glPushMatrix();
00114         ExNihilo::EnterOrthoMode();
00115         
00116         glEnable(GL_TEXTURE_2D);
00117         glDisable(GL_LIGHTING);
00118         glColor4f(1, 1, 1, 1);
00119         glDisable(GL_DEPTH_TEST);
00120         glBlendFunc(GL_DST_COLOR,GL_ZERO);
00121         glEnable(GL_BLEND);                                                                                     
00122         
00123         ManagerTexture->SetCurrentObject(m_TextureMask);
00124         
00125         glBegin(GL_QUADS);
00126                 glTexCoord2f(0.0f, 1.0f);       glVertex2f(0, 0);
00127                 glTexCoord2f(0.0f, 0.0f);       glVertex2f(0,glutGet(GLUT_WINDOW_HEIGHT));
00128                 glTexCoord2f(1.0f, 0.0f);       glVertex2f(glutGet(GLUT_WINDOW_WIDTH),glutGet(GLUT_WINDOW_HEIGHT));
00129                 glTexCoord2f(1.0f, 1.0f);       glVertex2f(glutGet(GLUT_WINDOW_WIDTH), 0);
00130         glEnd();        
00131 
00132         glBlendFunc(GL_ONE,GL_ONE);
00133         ManagerTexture->SetCurrentObject(m_Texture);
00134         
00135         glBegin(GL_QUADS);
00136                 glTexCoord2f(0.0f, 1.0f);       glVertex2f(0, 0);
00137                 glTexCoord2f(0.0f, 0.0f);       glVertex2f(0,glutGet(GLUT_WINDOW_HEIGHT));
00138                 glTexCoord2f(1.0f, 0.0f);       glVertex2f(glutGet(GLUT_WINDOW_WIDTH),glutGet(GLUT_WINDOW_HEIGHT));
00139                 glTexCoord2f(1.0f, 1.0f);       glVertex2f(glutGet(GLUT_WINDOW_WIDTH), 0);
00140     glEnd();    
00141         
00142         glDisable(GL_BLEND);
00143         glDisable(GL_TEXTURE_2D);
00144         glEnable(GL_DEPTH_TEST);
00145         
00146         /*
00147         if(m_ShowRegion)
00148         {
00149                 int i=0;
00150                 for(m_ItVecActionCommand=m_VecActionCommand.begin();m_ItVecActionCommand!=m_VecActionCommand.end();m_ItVecActionCommand++,i++)
00151                 {
00152                         
00153                         double Xup,Yup,Xdo,Ydo,cofx=1,cofy=1;
00154                         //Xup=((double)m_ItVecActionCommand->m_MouseXup/m_DefaultResolutionX)*ManagerWindow->GetResolutionX();
00155                         //Yup=((double)m_ItVecActionCommand->m_MouseYup/m_DefaultResolutionY)*ManagerWindow->GetResolutionY();
00156                         //Xdo=((double)m_ItVecActionCommand->m_MouseXdown/m_DefaultResolutionX)*ManagerWindow->GetResolutionX();
00157                         //Ydo=((double)m_ItVecActionCommand->m_MouseYdown/m_DefaultResolutionY)*ManagerWindow->GetResolutionY();
00158                         
00159                         
00160                         
00161                         //cout<<"Current resolution X:"<<ManagerWindow->GetResolutionX()<<endl;
00162                         //cout<<"Current resolution Y:"<<ManagerWindow->GetResolutionY()<<endl;
00163                         //cout<<"Default X:"<<m_DefaultResolutionX<<endl;
00164                         //cout<<"Default Y:"<<m_DefaultResolutionY<<endl;
00165                         if(cofx==0)cofx=1;
00166                         if(cofy==0)cofy=1;
00167                         cofx=(ManagerWindow->GetResolutionX()/m_DefaultResolutionX);            
00168                         cofy=(ManagerWindow->GetResolutionY()/m_DefaultResolutionY);
00169                         //cout<<"cofx :"<<cofx<<endl;
00170                         //cout<<"cofy :"<<cofy<<endl;
00171                         
00172 
00173                         
00174                         
00175                         Xup=(m_ItVecActionCommand->m_MouseXup)*cofx;
00176                         Yup=(m_ItVecActionCommand->m_MouseYup)*cofy;
00177                         Xdo=(m_ItVecActionCommand->m_MouseXdown)*cofx;
00178                         Ydo=(m_ItVecActionCommand->m_MouseYdown)*cofy;
00179                         
00180                         if(i%1==0){glColor3f((float)i/10,1.0f-((float)i/10),1.0f);}
00181                         if(i%2==0){glColor3f(1.0f,1.0f-((float)i/10),(float)1/10);}
00182                         if(i%3==0){glColor3f(1.0f-((float)i/10),1.0f,(float)1/10);}
00183                         glBegin(GL_LINE_LOOP);
00184                                 glVertex2f(Xdo,Ydo);
00185                                 glVertex2f(Xdo,Yup);
00186                                 glVertex2f(Xup,Yup);
00187                                 glVertex2f(Xup,Ydo);
00188                         glEnd();
00189                 }
00190         }
00191         glEnable(GL_LIGHTING);*/
00192         ExNihilo::LeaveOrthoMode();
00193         glPopMatrix();
00194 UnGuard
00195 }

void EnableInterface void    [inline]
 

Definition at line 86 of file ExCInterface.h.

References m_State.

00086 {m_State=false;}

bool GetInterfaceState void    [inline]
 

Definition at line 87 of file ExCInterface.h.

References m_State.

00087 {m_State=true;}

int GetNumInterface void    [inline]
 

Definition at line 81 of file ExCInterface.h.

References m_NumInterface.

00081 {m_NumInterface=num;}

void HideRegion void    [inline]
 

Definition at line 84 of file ExCInterface.h.

References m_ShowRegion.

Referenced by ExManagerInterface::HideRegion().

00084 {m_ShowRegion=true;}

ExCAction InputCommand int    command,
int    mousex,
int    mousey
 

Definition at line 197 of file ExCInterface.cpp.

References ExManagerWindow::GetResolutionX(), ExManagerWindow::GetResolutionY(), Guard, InputCommand(), ExCAction::m_Action, m_ItVecActionCommand, ExCAction::m_NextAction, m_VecActionCommand, ManagerWindow, and ExCAction::SetParam().

Referenced by InputCommand().

00198 {
00199 Guard(ExCAction ExCInterface::InputCommand(int command,int mousex,int mousey))
00200         int CntAct=0;
00201         ExCAction RetAct;
00202         
00203         for(m_ItVecActionCommand=m_VecActionCommand.begin();m_ItVecActionCommand!=m_VecActionCommand.end();m_ItVecActionCommand++)
00204         {
00205                 if(m_ItVecActionCommand->m_Command==command)
00206                 {
00207                         if(m_ItVecActionCommand->m_MouseXup<0)
00208                         {
00209                                 if(CntAct>0)
00210                                 {
00211                                         ExCAction       *RecursifActA;
00212                                         ExCAction       *RecursifActB;
00213                                         RecursifActA=&RetAct;
00214                                         for(int i=0;i<CntAct;i++)
00215                                         {
00216                                                 if(RecursifActA->m_NextAction==NULL)
00217                                                 {
00218                                                         RecursifActA->m_NextAction=new ExCAction;
00219                                                         RecursifActB=RecursifActA->m_NextAction;
00220                                                         RecursifActB->m_Action=m_ItVecActionCommand->m_Action;
00221                                                         RecursifActB->SetParam(m_ItVecActionCommand->m_Param);
00222                                                 }
00223                                                 RecursifActA=RecursifActA->m_NextAction;
00224                                         }
00225                                         CntAct++;
00226                                 }else
00227                                 {
00228                                         RetAct.m_Action=m_ItVecActionCommand->m_Action;
00229                                         RetAct.SetParam(m_ItVecActionCommand->m_Param);
00230                                         CntAct++;
00231                                 }
00232                         }else
00233                         {
00234                                 double Xup,Yup,Xdo,Ydo,Mx,My;
00235                                 Xup=((double)m_ItVecActionCommand->m_MouseXup/ManagerWindow->GetResolutionX());
00236                                 Yup=((double)m_ItVecActionCommand->m_MouseYup/ManagerWindow->GetResolutionY());
00237                                 Xdo=((double)m_ItVecActionCommand->m_MouseXdown/ManagerWindow->GetResolutionX());
00238                                 Ydo=((double)m_ItVecActionCommand->m_MouseYdown/ManagerWindow->GetResolutionY());
00239                                 Mx=((double)mousex/ManagerWindow->GetResolutionX());
00240                                 My=((double)mousey/ManagerWindow->GetResolutionY());
00241 
00242                                 /*cout<<"Resolution "<<ManagerWindow->GetResolutionX()<<" "<<ManagerWindow->GetResolutionY()<<endl;
00243                                 cout<<"Xup :"<<Xup<<endl;
00244                                 cout<<"Yup :"<<Yup<<endl;
00245                                 cout<<"Xdo :"<<Xdo<<endl;
00246                                 cout<<"Ydo :"<<Ydo<<endl;
00247                                 cout<<"Mx  :"<<Mx<<endl;
00248                                 cout<<"My  :"<<My<<endl;
00249                                 */
00250                                 
00251                                 if((Xup>Mx)&&(Xdo<Mx)&&(Ydo<My)&&(Yup>My))
00252                                 {
00253                                         std::cout<<"clik dedans"<<std::endl;
00254                                         if(CntAct>0)
00255                                         {
00256                                                 ExCAction       *RecursifActA;
00257                                                 ExCAction       *RecursifActB;
00258                                                 RecursifActA=&RetAct;
00259                                                 for(int i=0;i<CntAct;i++)
00260                                                 {
00261                                                         if(RecursifActA->m_NextAction==NULL)
00262                                                         {
00263                                                                 RecursifActA->m_NextAction=new ExCAction;
00264                                                                 RecursifActB=RecursifActA->m_NextAction;
00265                                                                 RecursifActB->m_Action=m_ItVecActionCommand->m_Action;
00266                                                                 RecursifActB->SetParam(m_ItVecActionCommand->m_Param);
00267                                                         }
00268                                                         RecursifActA=RecursifActA->m_NextAction;
00269                                                 }
00270                                                 CntAct++;
00271                                         }else
00272                                         {
00273                                                 RetAct.m_Action=m_ItVecActionCommand->m_Action;
00274                                                 RetAct.SetParam(m_ItVecActionCommand->m_Param);
00275                                                 CntAct++;
00276                                         }
00277                                 }else
00278                                 {
00279                                         std::cout<<"click hors coordonée"<<std::endl;
00280                                 }
00281                         }
00282                 }
00283         }
00284         if(CntAct==0)
00285         {
00286                 RetAct.m_Action=NOTHING;
00287                 RetAct.SetParam("NULL");
00288         }
00289 
00290         return RetAct;
00291 UnGuard
00292 }

bool LoadFile std::string    FileName [virtual]
 

Reimplemented from ExCObject.

Definition at line 51 of file ExCInterface.cpp.

References ExManagerTexture::Add(), ExNihilo::ExtractIntValueFromSring(), ExNihilo::ExtracValueFromSring(), Guard, LoadFile(), ActionCommand::m_Action, ActionCommand::m_Command, m_DefaultResolutionX, m_DefaultResolutionY, ActionCommand::m_MouseXdown, ActionCommand::m_MouseXup, ActionCommand::m_MouseYdown, ActionCommand::m_MouseYup, ActionCommand::m_Param, m_Texture, m_TextureMask, m_VecActionCommand, ManagerTexture, and PREFIX.

Referenced by ExCInterface(), ExManagerInterface::Load(), and LoadFile().

00052 {
00053 Guard(bool ExCInterface::LoadFile(std::string FileName))
00054         char                    buffer[255];
00055 #ifdef UNIX_SRC
00056         sprintf(buffer, PREFIX "/ExNihilo/Data/Interface/%s", FileName.data());
00057 #else
00058         sprintf(buffer, "../Data/Interface/%s", FileName.data());
00059 #endif
00060         std::ifstream fin;
00061         std::string buffstring;
00062         char b[256];
00063         fin.open(buffer,std::ios::in);
00064         if(fin.is_open())
00065         {
00066                 try
00067                 {
00068                         //----Read image
00069                         memset(b,0,255);
00070                         fin.getline(b,256,'\n');
00071                         m_Texture=ExNihilo::ExtracValueFromSring(b,"<Image>","<#Image>");
00072                         //----Read mask
00073             memset(b,0,255);
00074                         fin.getline(b,256,'\n');                        
00075                         m_TextureMask=ExNihilo::ExtracValueFromSring(b,"<Mask>","<#Mask>");
00076                         //----Read resolution
00077             memset(b,0,255);
00078                         fin.getline(b,256,'\n');                        
00079                         buffstring=ExNihilo::ExtracValueFromSring(b,"<Mask>","<#Mask>");
00080                         m_DefaultResolutionX=ExNihilo::ExtractIntValueFromSring(buffstring,"<X>","<#X>");
00081                         m_DefaultResolutionY=ExNihilo::ExtractIntValueFromSring(buffstring,"<Y>","<#Y>");
00082                         //----Read all command
00083                         do
00084                         {
00085                                 memset(b,0,255);
00086                                 fin.getline(b,256,'\n');
00087                                 try
00088                                 {
00089                                         ActionCommand actcmd;
00090                                         buffstring=ExNihilo::ExtracValueFromSring(b,"<Interface_Action>","<#Interface_Action>");
00091                                         actcmd.m_Action=ExNihilo::ExtractIntValueFromSring(buffstring,"<Action>","<#Action>");
00092                                         actcmd.m_Command=ExNihilo::ExtractIntValueFromSring(buffstring,"<Command>","<#Command>");
00093                                         actcmd.m_Param=ExNihilo::ExtracValueFromSring(buffstring,"<Param>","<#Param>");
00094                                         actcmd.m_MouseXup=ExNihilo::ExtractIntValueFromSring(buffstring,"<TopX>","<#TopX>");
00095                                         actcmd.m_MouseYup=ExNihilo::ExtractIntValueFromSring(buffstring,"<TopY>","<#TopY>");
00096                                         actcmd.m_MouseXdown=ExNihilo::ExtractIntValueFromSring(buffstring,"<BottomX>","<#BottomX>");
00097                                         actcmd.m_MouseYdown=ExNihilo::ExtractIntValueFromSring(buffstring,"<BottomY>","<#BottomY>");
00098                                         m_VecActionCommand.push_back(actcmd);
00099                                 }catch(ExCExpStringNotFound){}
00100                         }while(!fin.eof());
00101                         fin.close();
00102                 }catch(...){throw ExCExpFileReadError();}
00103         }else throw   ExCExpFileNotFound();
00104         ManagerTexture->Add(m_Texture);
00105         ManagerTexture->Add(m_TextureMask);
00106         return true;
00107 UnGuard
00108 }

void SetManagerTexture ExManagerTexture   Texture [inline]
 

Definition at line 78 of file ExCInterface.h.

References ManagerWindow.

Referenced by ExManagerInterface::Load().

00078 {ManagerWindow = Window;}

void SetManagerWindow ExManagerWindow   Window [inline]
 

Definition at line 77 of file ExCInterface.h.

00078 {ManagerWindow = Window;}

void SetNumInterface int    num [inline]
 

Definition at line 80 of file ExCInterface.h.

00081 {m_NumInterface=num;}

void ShowRegion void    [inline]
 

Definition at line 83 of file ExCInterface.h.

Referenced by ExManagerInterface::ShowRegion().

00084 {m_ShowRegion=true;}


Field Documentation

std::ostrstream* Consol
 

Definition at line 68 of file ExCInterface.h.

Referenced by ExManagerInterface::Load().

int m_DefaultResolutionX [private]
 

Definition at line 49 of file ExCInterface.h.

Referenced by LoadFile().

int m_DefaultResolutionY [private]
 

Definition at line 50 of file ExCInterface.h.

Referenced by LoadFile().

std::vector<ActionCommand>::iterator m_ItVecActionCommand [private]
 

Definition at line 65 of file ExCInterface.h.

Referenced by InputCommand().

int m_NumInterface [private]
 

Definition at line 48 of file ExCInterface.h.

Referenced by GetNumInterface().

bool m_ShowRegion [private]
 

Definition at line 51 of file ExCInterface.h.

Referenced by DisableInterface(), ExCInterface(), and HideRegion().

bool m_State [private]
 

Definition at line 52 of file ExCInterface.h.

Referenced by EnableInterface(), ExCInterface(), and GetInterfaceState().

std::string m_Texture [private]
 

Definition at line 46 of file ExCInterface.h.

Referenced by Draw(), and LoadFile().

std::string m_TextureMask [private]
 

Definition at line 47 of file ExCInterface.h.

Referenced by Draw(), and LoadFile().

std::vector<ActionCommand> m_VecActionCommand [private]
 

Definition at line 64 of file ExCInterface.h.

Referenced by InputCommand(), and LoadFile().

ExManagerTexture* ManagerTexture [private]
 

Definition at line 45 of file ExCInterface.h.

Referenced by Draw(), and LoadFile().

ExManagerWindow* ManagerWindow [private]
 

Definition at line 44 of file ExCInterface.h.

Referenced by InputCommand().


The documentation for this class was generated from the following files:
Generated on Tue Dec 10 18:20:21 2002 for ExNihilo by doxygen1.3-rc1