00001
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #include "K3dMenu.h"
00040 #include "../System/K3dScene.h"
00041
00042 K3dMenu::K3dMenu(K3dGameData *_pGameData):
00043 K3dDir(_pGameData),
00044 K3dGui(_pGameData)
00045 {
00046 m_pGameData = _pGameData;
00047 }
00048
00049 K3dMenu::~K3dMenu()
00050 {
00051 }
00052
00053
00055
00056
00057
00058
00059
00060
00061
00062
00063
00067 bool K3dMenu::ButtonIsPressed(const int _iButtonId)
00068 {
00069 if(_iButtonId < 0)
00070 {
00071 cerr << "Error:: bool K3dMenu::ButtonIsPressed() -- ButtonId is negative !!! " << endl;
00072 return false;
00073 }
00074 K3dGuiButton *pButton = GetGuiButton(_iButtonId);
00075
00076
00077
00078 if(pButton)
00079 {
00080 return pButton->isPressed();
00081 }
00082 else
00083 {
00084 cerr << "Error:: bool K3dMenu::ButtonIsPressed() -- Pointer to pButton doesn`t allocated !!! " << endl;
00085 }
00086 return false;
00087 }
00088
00092 void K3dMenu::ShowFileListBox(const int _iListModelId, const char *_strPath)
00093 {
00094 if(_iListModelId < 0)
00095 {
00096 cerr << "Error:: void K3dMenu::ShowFileListBox() -- _iListBoxId is negative !!! " << endl;
00097 return;
00098 }
00099 K3dGuiListModel *pListModel = GetGuiListModel(_iListModelId);
00100 if(pListModel)
00101 {
00102
00103 pListModel->DeleteElements();
00104 K3dString strFilename = m_pGameData->GetPath(K_PATH_APP) + _strPath;
00105
00106 if(OpenDirectory(strFilename.GetString().c_str()))
00107 {
00108 TStringArray tStrArray = GetDirFileArray();
00109 for(unsigned int i=0; i<tStrArray.size(); i++)
00110 {
00111 K3dString strFile = tStrArray[i];
00112
00113 K3dString strName;
00114 strName.GetStrTok(strFile, ".");
00115 if(strName != "")
00116 {
00117
00118 pListModel->AddElement(strName.GetString());
00119 }
00120 }
00121 }
00122 else
00123 {
00124 cerr << "Error:: void K3dMenu::ShowFileListBox() -- Path " << _strPath << " doesn`t exists.." << endl;
00125 }
00126 }
00127 else
00128 {
00129 cerr << "Error:: bool K3dMenu::ButtonIsPressed() -- Pointer to pButton doesn`t allocated !!! " << endl;
00130 }
00131 }
00132
00134 bool K3dMenu::LoadMapFromListBox(const int _iListBoxId, const char * _strPath)
00135 {
00136 K3dGuiListBox *pListBox = GetGuiListBox(_iListBoxId);
00137
00138 int iSlctd = pListBox->getSelected();
00139
00140 if(iSlctd >= 0)
00141 {
00142
00143 string strFileName = pListBox->getListModel()->getElementAt(iSlctd);
00144
00145 strFileName += K_STR_DOT_LUA;
00146
00147 string strPath = _strPath;
00148 strPath += "/";
00149 strPath += strFileName;
00150 K3dString strLoad = strPath;
00151 K3dScene *pScene = m_pGameData->GetScene();
00152 if(pScene)
00153 {
00154 pScene->LoadNewScript( strLoad.GetString( ).c_str());
00155 }
00156 return true;
00157 }
00158
00159 return false;
00160
00161 }
00162
00163