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 GetIterator(param)->second.EnableInterface(); 00124 return GetNumberEnableInterface(); 00125 UnGuard 00126 } 00127 00128 int ExManagerInterface::DisableInterface(std::string param) 00129 { 00130 Guard(int ExManagerInterface::DisableInterface(std::string param)) 00131 GetIterator(param)->second.DisableInterface(); 00132 return GetNumberEnableInterface(); 00133 UnGuard 00134 } 00135 00136 int ExManagerInterface::EnableAllInterface(void) 00137 { 00138 Guard(int ExManagerInterface::EnableAllInterface(void)) 00139 for(m_ItMap=m_Map->begin();m_ItMap!=m_Map->end();m_ItMap++) 00140 { 00141 m_ItMap->second.EnableInterface(); 00142 } 00143 m_AllDisable=false; 00144 return GetNumberEnableInterface(); 00145 UnGuard 00146 } 00147 00148 int ExManagerInterface::DisableAllInterface(void) 00149 { 00150 Guard(int ExManagerInterface::DisableAllInterface(void)) 00151 for(m_ItMap=m_Map->begin();m_ItMap!=m_Map->end();m_ItMap++) 00152 { 00153 m_ItMap->second.DisableInterface(); 00154 } 00155 m_AllDisable=true; 00156 return GetNumberEnableInterface(); 00157 UnGuard 00158 } 00159 00160 int ExManagerInterface::GetNumberEnableInterface(void) 00161 { 00162 Guard(int ExManagerInterface::GetNumberEnableInterface(void)) 00163 int ret=0; 00164 for(m_ItMap=m_Map->begin();m_ItMap!=m_Map->end();m_ItMap++) 00165 { 00166 if(m_ItMap->second.GetInterfaceState())ret++; 00167 } 00168 return ret; 00169 UnGuard 00170 } 00171 00172 ExCAction ExManagerInterface::InputCommand(ExCCommand Command) 00173 { 00174 Guard(ExCAction ExManagerInterface::InputCommand(ExCCommand Command)) 00175 return NOTHING; 00176 UnGuard 00177 } 00178 ExCAction ExManagerInterface::InputAction(ExCAction Action) 00179 { 00180 Guard(ExCAction ExManagerInterface::InputAction(ExCAction Action)) 00181 switch(Action.m_Action) 00182 { 00183 case ENABLE_INTERFACE:EnableInterface(Action.m_Param);break; 00184 case DISABLE_INTERFACE:DisableInterface(Action.m_Param);break; 00185 case ENABLE_ALL_INTERFACE:EnableAllInterface();break; 00186 case DISABLE_ALL_INTERFACE:DisableAllInterface();break; 00187 case LIST_INTERFACE:List(); break; 00188 case ADD_INTERFACE:Load(Action.m_Param);break; 00189 case SHOW_INTERFACE_REGION:ShowRegion();break; 00190 case HIDE_INTERFACE_REGION:HideRegion();break; 00191 default: 00192 *Consol<<"Can not file action in INTERFACE_ACTION_MAP"<<std::endl; 00193 break; 00194 } 00195 if(Action.m_NextAction){return *Action.m_NextAction;} 00196 else{return NOTHING;} 00197 UnGuard 00198 } 00199