#include <ExCMenu.h>
Inheritance diagram for ExCMenu:
Public Methods | |
ExCMenu (void) | |
~ExCMenu (void) | |
bool | LoadFile (std::string FileName) |
void | Draw (void) |
void | NextItem (void) |
void | PreviousItem (void) |
MenuItem | GetItem (int item) |
MenuItem | GetCurrentItem (void) |
ExCAction | GetCurrentItemAction (void) |
Private Attributes | |
std::vector< MenuItem > | m_VecMenuItem |
int | m_CurrentItem |
std::string | m_MenuTitle |
std::string | m_MenuType |
|
Definition at line 26 of file ExCMenu.cpp. References ExCMenu(), Guard, m_CurrentItem, ExCObject::SetName(), and ExCObject::SetType(). Referenced by ExCMenu(), and ~ExCMenu().
00027 { 00028 Guard(ExCMenu::ExCMenu(void)) 00029 SetName("ExCMenu"); 00030 SetType(typeid(this).name()); 00031 m_CurrentItem=-1; 00032 UnGuard 00033 } |
|
Definition at line 35 of file ExCMenu.cpp. References ExCMenu(), and Guard.
|
|
Reimplemented from ExCObject. Definition at line 41 of file ExCMenu.cpp. References Draw(), ExNihilo::DrawCadre(), Guard, m_CurrentItem, m_MenuTitle, m_VecMenuItem, and ExNihilo::WriteToScreen24(). Referenced by ExManagerMenu::Draw(), and Draw().
00042 { 00043 Guard(void ExCMenu::Draw(void)) 00044 ExNihilo::DrawCadre(350,10,300,60+30*m_VecMenuItem.size(),0.2f,0.0f,0.6f,0.9f); 00045 ExNihilo::WriteToScreen24(400,50,1,1,1,m_MenuTitle); 00046 for(unsigned int i=0;i<m_VecMenuItem.size();i++) 00047 { 00048 if(i==m_CurrentItem) 00049 { 00050 ExNihilo::WriteToScreen24(400,100+(i*25),1,0,0,m_VecMenuItem.at(i).m_string); 00051 }else 00052 { 00053 ExNihilo::WriteToScreen24(400,100+(i*25),1,1,1,m_VecMenuItem.at(i).m_string); 00054 } 00055 } 00056 00057 UnGuard 00058 } |
|
Definition at line 132 of file ExCMenu.cpp. References GetCurrentItem(), GetItem(), Guard, and m_CurrentItem. Referenced by GetCurrentItem(), and GetCurrentItemAction().
00133 { 00134 Guard(MenuItem ExCMenu::GetCurrentItem(void)) 00135 return GetItem(m_CurrentItem); 00136 UnGuard 00137 } |
|
Definition at line 139 of file ExCMenu.cpp. References GetCurrentItem(), GetCurrentItemAction(), Guard, and MenuItem::m_Action. Referenced by GetCurrentItemAction(), and ExManagerMenu::InputCommand().
00140 { 00141 Guard(ExCAction ExCMenu::GetCurrentItemAction(void)) 00142 return GetCurrentItem().m_Action; 00143 UnGuard 00144 } |
|
Definition at line 125 of file ExCMenu.cpp. References GetItem(), Guard, and m_VecMenuItem. Referenced by GetCurrentItem(), and GetItem().
00126 { 00127 Guard(MenuItem ExCMenu::GetItem(int item)) 00128 return m_VecMenuItem.at(item); 00129 UnGuard 00130 } |
|
Reimplemented from ExCObject. Definition at line 60 of file ExCMenu.cpp. References ExNihilo::ExtractIntValueFromSring(), ExNihilo::ExtracValueFromSring(), Guard, LoadFile(), ExCAction::m_Action, MenuItem::m_Action, m_CurrentItem, m_MenuTitle, m_MenuType, ExCAction::m_Param, MenuItem::m_string, m_VecMenuItem, and PREFIX. Referenced by ExManagerMenu::Add(), ExManagerMenu::Init(), and LoadFile().
00061 { 00062 Guard(ExCMenu::LoadFile(std::string FileName)) 00063 char buffer[255],b[255]; 00064 std::string buffstring; 00065 std::ifstream fin; 00066 #ifdef UNIX_SRC 00067 sprintf(buffer, PREFIX "/ExNihilo/Data/Menu/%s", FileName.data()); 00068 #else 00069 sprintf(buffer, "../Data/Menu/%s", FileName.data()); 00070 #endif 00071 MenuItem Menuitem; 00072 fin.open(buffer,std::ios::in); 00073 if(fin.is_open()) 00074 { 00075 try 00076 { 00077 //read header 00078 memset(b,0,255); 00079 fin.getline(b,256,'\n'); 00080 try 00081 { 00082 buffstring=ExNihilo::ExtracValueFromSring(b,"<MenuHeader>","<#MenuHeader>"); 00083 m_MenuTitle=ExNihilo::ExtracValueFromSring(b,"<title>","<#title>"); 00084 m_MenuType=ExNihilo::ExtracValueFromSring(b,"<type>","<#type>"); 00085 }catch(ExCExpStringNotFound){} 00086 //read items 00087 do 00088 { 00089 memset(b,0,255); 00090 fin.getline(b,256,'\n'); 00091 try 00092 { 00093 buffstring=ExNihilo::ExtracValueFromSring(b,"<MenuItem>","<#MenuItem>"); 00094 Menuitem.m_string=ExNihilo::ExtracValueFromSring(buffstring,"<string>","<#string>"); 00095 Menuitem.m_Action.m_Action=ExNihilo::ExtractIntValueFromSring(buffstring,"<action>","<#action>"); 00096 Menuitem.m_Action.m_Param=ExNihilo::ExtracValueFromSring(buffstring,"<param>","<#param>"); 00097 m_VecMenuItem.push_back(Menuitem); 00098 }catch(ExCExpStringNotFound){} 00099 00100 }while(!fin.eof()); 00101 fin.close(); 00102 }catch(...){throw ExCExpFileReadError();} 00103 }else throw ExCExpFileNotFound(); 00104 m_CurrentItem=0; 00105 return true; 00106 UnGuard 00107 } |
|
Definition at line 109 of file ExCMenu.cpp. References Guard, m_CurrentItem, m_VecMenuItem, and NextItem(). Referenced by ExManagerMenu::InputCommand(), and NextItem().
00110 { 00111 Guard(void ExCMenu::NextItem(void)) 00112 m_CurrentItem++; 00113 if(m_CurrentItem>=m_VecMenuItem.size())m_CurrentItem=0; 00114 UnGuard 00115 } |
|
Definition at line 117 of file ExCMenu.cpp. References Guard, m_CurrentItem, m_VecMenuItem, and PreviousItem(). Referenced by ExManagerMenu::InputCommand(), and PreviousItem().
00118 { 00119 Guard(void ExCMenu::PreviousItem(void)) 00120 m_CurrentItem--; 00121 if(m_CurrentItem<0)m_CurrentItem=m_VecMenuItem.size()-1; 00122 UnGuard 00123 } |
|
Definition at line 79 of file ExCMenu.h. Referenced by Draw(), ExCMenu(), GetCurrentItem(), LoadFile(), NextItem(), and PreviousItem(). |
|
Definition at line 80 of file ExCMenu.h. Referenced by Draw(), and LoadFile(). |
|
Definition at line 81 of file ExCMenu.h. Referenced by LoadFile(). |
|
Definition at line 78 of file ExCMenu.h. Referenced by Draw(), GetItem(), LoadFile(), NextItem(), and PreviousItem(). |