41 unsigned profiles() {
return _nProfiles; }
44 void onCommand(
unsigned long uID,
unsigned long nCmd);
46 void loadProfile(
char*strProfile);
47 char* profileName(
unsigned i)
50 pb->getText(_title_buf);
55 uiLoadProfile_JR::uiLoadProfile_JR():
uiContainer(
"ui\\dialogs\\mm-profile-list.cui")
57 WIN32_FIND_DATA FindFileData;
61 hFind = FindFirstFile(
"save\\*.profile", &FindFileData);
62 if(hFind != INVALID_HANDLE_VALUE) bOK = TRUE;
66 #define M_BUT_HEIGHT 45
71 but->
create( laPoint3(0, (_nProfiles++)*M_BUT_HEIGHT*1.1 + 10), laPoint3(150, M_BUT_HEIGHT) );
72 *strstr(FindFileData.cFileName,
".profile") =
'\0';
73 but->setText(FindFileData.cFileName);
74 but->setID( insert(but) );
77 bOK = FindNextFile(hFind, &FindFileData);
81 but->
create( laPoint3(0, (_nProfiles)*M_BUT_HEIGHT*1.1 + 10 + M_BUT_HEIGHT*0.3), laPoint3(150, M_BUT_HEIGHT) );
82 but->setText(
"Cancel" );
83 but->setID( insert(but) );
85 _ptSize[1] = (_nProfiles+2)*M_BUT_HEIGHT*1.1 + 30;
90 void uiLoadProfile_JR::onCommand(
unsigned long uID,
unsigned long nCmd)
92 if(!isEnabled())
return;
99 if( !strstr(title,
"Cancel") ) {
106 void uiLoadProfile_JR::loadProfile(
char*strProfile)
109 sprintf(strfile,
"save\\%s.profile", strProfile);
113 if( fp.fileOpen(strfile) )
117 fp.readObj(&pl, M_FALSE);
120 strcpy( laSystemIntegrator::getSettings()->load_level, pl.getText(
"load-level"));
121 strcpy( laSystemIntegrator::getSettings()->load_player_name, strProfile);
124 laSystemIntegrator::getGame()->setStage(M_STAGE_LOAD);
131 ASSERT(M_FALSE,
"Corrupted player profile '%s'", strProfile);
137 uiLoadProfile_JR **_ppListProf;
143 uiNewProfile_JR::uiNewProfile_JR():
uiChoiceDialog(
"ui\\dialogs\\mm-profile-new.cui"){
146 void uiNewProfile_JR::onOK()
149 ((
uiEdit*)
get(3))->getText(str);
154 sprintf(strfile,
"save\\%s.profile", str);
155 FILE* f = fopen(strfile,
"r");
163 static uiWarningDialog* pWarn = NULL;
164 if(pWarn) pWarn->show();
166 pWarn =
new uiWarningDialog(
"ui\\dialogs\\mm-profile-w-duplicate.cui",
this);
175 f = fopen(strfile,
"w+");
176 fprintf(f,
"[profile]\n [text] load-level: '%s' \n[/profile]", M_NEWGAME_FIRST_LEVEL);
179 strcpy( laSystemIntegrator::getSettings()->load_player_name, str);
180 strcpy( laSystemIntegrator::getSettings()->load_level, M_NEWGAME_FIRST_LEVEL);
181 laSystemIntegrator::getGame()->setStage(M_STAGE_LOAD);
189 uiMenu_JR::uiMenu_JR(
unsigned nMenuType)
191 _nMenuType = nMenuType;
196 load(
"ui\\dialogs\\mmenu.cui");
198 case M_JRMENU_INGAME:
199 load(
"ui\\dialogs\\mmenu-ingame.cui");
202 load(
"ui\\dialogs\\mmenu-edit.cui");
205 throw laError(
"uiMenu_JR::uiMenu_JR(): Unimplemented menu type");
212 uiMenu_JR::~uiMenu_JR(
void)
214 if(_pListProf)
delete _pListProf;
215 if(_pNewProf)
delete _pNewProf;
218 void uiMenu_JR::_create_profile_dialogs()
220 ASSERT(
_pParent,
"Paremnt must be set to create dialogs");
224 _pListProf =
new uiLoadProfile_JR();
231 _pNewProf =
new uiNewProfile_JR();
237 _pNewProf->_ppListProf = &_pListProf;
243 _create_profile_dialogs();
244 if( _pListProf->profiles() == 0 )
get(2)->disable();
245 else get(2)->enable();
252 if(!isEnabled())
return;
259 if(strstr(title,
"New Game"))
264 else if(strstr(title,
"Continue"))
267 if(_pListProf->profiles() == 1)
269 _pListProf->loadProfile( _pListProf->profileName(0) );
277 else if(strstr(title,
"New Level"))
279 ((
stageEdit*)(laSystemIntegrator::getGame()->getStage(M_STAGE_EDIT)))
280 ->pNewLevelDlg->show();
282 else if(strstr(title,
"Save As"))
284 ((
stageEdit*)(laSystemIntegrator::getGame()->getStage(M_STAGE_EDIT)))
287 else if(strstr(title,
"Open"))
289 ((
stageEdit*)(laSystemIntegrator::getGame()->getStage(M_STAGE_EDIT)))
292 else if(strstr(title,
"Editor"))
297 else if(strstr(title,
"About"))
302 else if(strstr(title,
"Exit"))
304 ::laSystemIntegrator::getEnvironment()->terminate();
306 else if(strstr(title,
"Resume"))
310 else if(strstr(title,
"Return"))
312 laSystemIntegrator::getGame()->setStage(M_STAGE_MENU);
315 else if(strstr(title,
"hide"))
319 else if(strstr(title,
"show"))
325 void uiMenu_JR::collapse()
328 ((
uiEdit*)
get(2))->setText(
"show menu");
331 void uiMenu_JR::expand()
334 ((
uiEdit*)
get(2))->setText(
"hide menu");
337 void uiMenu_JR::toggle()
340 ((
uiEdit*)
get(2))->getText(caption);
342 if(strstr( caption,
"show" )) expand();
#define M_AB
Text align bottom.
virtual void move(laPoint3 ptNewPos, unsigned nHReference=M_AL, unsigned nVReference=M_AT)
Change window position.
#define M_AR
Text align right.
laPoint3 _ptSize
Window size.
uiWindow * _pParent
Pointer to parent window, if any.
virtual void reply()
Handle input message.
virtual void onCommand(unsigned long uID, unsigned long nCmd)
Command event handler.