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: ExManagerInterface.cpp,v 1.14 2002/12/08 17:57:06 data Exp $ 00021 * 00022 */ 00023 00024 #include "ExManagerInterface.h" 00025 00026 bool ExManagerInterface::m_flag = false; 00027 ExManagerInterface* ExManagerInterface::m_instance = NULL; 00028 00029 ExManagerInterface* ExManagerInterface::CreateSingleton(void){ 00030 Guard(ExManagerInterface* ExManagerInterface::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 ExManagerInterface; // 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 ExManagerInterface::ExManagerInterface(void) 00044 { 00045 m_AllDisable=false; 00046 } 00047 00048 ExManagerInterface::~ExManagerInterface(void) 00049 { 00050 } 00051 00052 void ExManagerInterface::Reset(void) 00053 { 00054 Guard(void ExManagerInterface::Reset(void)) 00055 ExManagerObject<ExCInterface>::Reset(); 00056 UnGuard 00057 } 00058 00059 void ExManagerInterface::Init(void) 00060 { 00061 Guard(void ExManagerInterface::Init(void)) 00062 ExManagerObject<ExCInterface>::Init(); 00063 SetStatus(true); 00064 UnGuard 00065 } 00066 00067 bool ExManagerInterface::Load(std::string FileName) 00068 { 00069 Guard(bool ExManagerInterface::Load(std::string FileName)) 00070 ExCInterface Inter; 00071 Inter.SetManagerTexture(ManagerTexture); 00072 Inter.Consol=Consol; 00073 if(Inter.LoadFile(FileName)) 00074 { 00075 SetCurrentObject(Inter.GetName()); 00076 Add(Inter); 00077 return true; 00078 } 00079 return false; 00080 UnGuard 00081 } 00082 00083 void ExManagerInterface::Draw(void) 00084 { 00085 Guard(void ExManagerInterface::Draw(void)) 00086 if(!GetStatus())return; 00087 if(m_AllDisable)return; 00088 for(m_ItMap=m_Map->begin();m_ItMap!=m_Map->end();m_ItMap++) 00089 { 00090 m_ItMap->second.Draw(); 00091 } 00092 UnGuard 00093 } 00094 00095 void ExManagerInterface::ShowRegion(void) 00096 { 00097 Guard(void ExManagerInterface::ShowRegion(void)) 00098 GetCurrentObject()->ShowRegion(); 00099 UnGuard 00100 } 00101 00102 void ExManagerInterface::HideRegion(void) 00103 { 00104 Guard(void ExManagerInterface::HideRegion(void)) 00105 GetCurrentObject()->HideRegion(); 00106 UnGuard 00107 } 00108 00109 ExCAction ExManagerInterface::InputCommand(int command,int mousex,int mousey) 00110 { 00111 Guard(int ExManagerInterface::InputCommand(int command,int mousex,int mousey)) 00112 /* if(GetCurrentObject()->GetInterfaceState()) 00113 { 00114 return GetCurrentObject()->InputCommand(command,mousex,mousey); 00115 }*/ 00116 return NOTHING; 00117 UnGuard 00118 } 00119 00120 int ExManagerInterface::EnableInterface(std::string param) 00121 { 00122 Guard(int ExManagerInterface::EnableInterface(std::string param)) 00123 SetCurrentObject(param); 00124 GetCurrentObject()->EnableInterface(); 00125 return GetNumberEnableInterface(); 00126 UnGuard 00127 } 00128 00129 int ExManagerInterface::DisableInterface(std::string param) 00130 { 00131 Guard(int ExManagerInterface::DisableInterface(std::string param)) 00132 SetCurrentObject(param); 00133 GetCurrentObject()->EnableInterface(); 00134 return GetNumberEnableInterface(); 00135 UnGuard 00136 } 00137 00138 int ExManagerInterface::EnableAllInterface(void) 00139 { 00140 Guard(int ExManagerInterface::EnableAllInterface(void)) 00141 for(m_ItMap=m_Map->begin();m_ItMap!=m_Map->end();m_ItMap++) 00142 { 00143 m_ItMap->second.EnableInterface(); 00144 } 00145 m_AllDisable=false; 00146 return GetNumberEnableInterface(); 00147 UnGuard 00148 } 00149 00150 int ExManagerInterface::DisableAllInterface(void) 00151 { 00152 Guard(int ExManagerInterface::DisableAllInterface(void)) 00153 for(m_ItMap=m_Map->begin();m_ItMap!=m_Map->end();m_ItMap++) 00154 { 00155 m_ItMap->second.DisableInterface(); 00156 } 00157 m_AllDisable=true; 00158 return GetNumberEnableInterface(); 00159 UnGuard 00160 } 00161 00162 int ExManagerInterface::GetNumberEnableInterface(void) 00163 { 00164 Guard(int ExManagerInterface::GetNumberEnableInterface(void)) 00165 int ret=0; 00166 for(m_ItMap=m_Map->begin();m_ItMap!=m_Map->end();m_ItMap++) 00167 { 00168 if(m_ItMap->second.GetInterfaceState())ret++; 00169 } 00170 return ret; 00171 UnGuard 00172 } 00173 00174 ExCAction ExManagerInterface::InputCommand(ExCCommand Command) 00175 { 00176 Guard(ExCAction ExManagerInterface::InputCommand(ExCCommand Command)) 00177 return NOTHING; 00178 UnGuard 00179 } 00180 ExCAction ExManagerInterface::InputAction(ExCAction Action) 00181 { 00182 Guard(ExCAction ExManagerInterface::InputAction(ExCAction Action)) 00183 switch(Action.m_Action) 00184 { 00185 case ENABLE_INTERFACE:EnableInterface(Action.m_Param);break; 00186 case DISABLE_INTERFACE:DisableInterface(Action.m_Param);break; 00187 case ENABLE_ALL_INTERFACE:EnableAllInterface();break; 00188 case DISABLE_ALL_INTERFACE:DisableAllInterface();break; 00189 case LIST_INTERFACE:List(); break; 00190 case ADD_INTERFACE:Load(Action.m_Param);break; 00191 case SHOW_INTERFACE_REGION:ShowRegion();break; 00192 case HIDE_INTERFACE_REGION:HideRegion();break; 00193 default: 00194 *Consol<<"Can not file action in INTERFACE_ACTION_MAP"<<std::endl; 00195 break; 00196 } 00197 if(Action.m_NextAction){return *Action.m_NextAction;} 00198 else{return NOTHING;} 00199 UnGuard 00200 } 00201