Definition at line 30 of file Level.h.
Public Member Functions | |
Level (const std::string &codename, const Path &datafile, int depth) | |
Create new level. | |
virtual | ~Level () |
virtual const char * | getName () const |
void | fillDesc (const DescFinder *desc) |
void | fillStatus (LevelStatus *status) |
void | saveGame (const std::string &models) |
Write save to the file. | |
void | loadGame (const std::string &moves) |
Start loading mode. | |
void | loadReplay (const std::string &moves) |
Start replay mode. | |
bool | action_restart () |
(re)start room. | |
bool | action_move (char symbol) |
Move a fish. | |
bool | action_save () |
Save position. | |
bool | action_load () |
Load position. | |
void | switchFish () |
void | controlEvent (const KeyStroke &stroke) |
void | controlMouse (const MouseStroke &button) |
std::string | getLevelName () const |
int | getRestartCounter () const |
int | getDepth () const |
bool | isNewRound () const |
void | createRoom (int w, int h, const Path &picture) |
Create new room and change screen resolution. | |
void | newDemo (const Path &demofile) |
bool | isLoading () const |
void | togglePause () |
bool | isShowing () const |
void | interruptShow () |
void | planShow (Command *new_command) |
virtual int | getCountForSolved () const |
virtual int | getCountForWrong () const |
Protected Member Functions | |
virtual void | own_initState () |
Start gameplay. | |
virtual void | own_updateState () |
Update level. | |
virtual void | own_pauseState () |
virtual void | own_resumeState () |
virtual void | own_cleanState () |
Clean room after visit. | |
virtual void | own_noteBg () |
Loading is paused on background. | |
virtual void | own_noteFg () |
|
Create new level.
Definition at line 44 of file Level.cpp. 00045 : m_codename(codename), m_datafile(datafile) 00046 { 00047 m_desc = NULL; 00048 m_restartCounter = 1; 00049 m_depth = depth; 00050 m_newRound = false; 00051 m_locker = new PhaseLocker(); 00052 m_levelScript = new LevelScript(this); 00053 m_loading = new LevelLoading(m_levelScript); 00054 m_countdown = new LevelCountDown(m_levelScript); 00055 m_show = new CommandQueue(); 00056 m_background = new MultiDrawer(); 00057 m_statusDisplay = new StatusDisplay(); 00058 takeHandler(new LevelInput(this)); 00059 registerDrawable(m_background); 00060 registerDrawable(SubTitleAgent::agent()); 00061 registerDrawable(m_statusDisplay); 00062 }
|
|
Definition at line 64 of file Level.cpp. 00065 { 00066 own_cleanState(); 00067 delete m_locker; 00068 //NOTE: m_show must be removed before levelScript 00069 // because uses the same script 00070 delete m_show; 00071 delete m_countdown; 00072 delete m_loading; 00073 delete m_levelScript; 00074 delete m_background; 00075 delete m_statusDisplay; 00076 }
|
|
Load position.
Definition at line 383 of file Level.cpp. 00384 { 00385 Path file = Path::dataReadPath("saves/" + m_codename + ".lua"); 00386 if (file.exists()) { 00387 m_restartCounter--; 00388 action_restart(); 00389 m_levelScript->scriptInclude(file); 00390 m_levelScript->scriptDo("script_load()"); 00391 } 00392 else { 00393 LOG_INFO(ExInfo("there is no file to load") 00394 .addInfo("file", file.getNative())); 00395 } 00396 return true; 00397 }
|
|
Move a fish.
Definition at line 356 of file Level.cpp. 00357 { 00358 return m_levelScript->room()->makeMove(symbol); 00359 }
|
|
(re)start room.
Definition at line 340 of file Level.cpp. 00341 { 00342 own_cleanState(); 00343 m_restartCounter++; 00344 //TODO: is ok to run the script on second time? 00345 //NOTE: planned show remains after restart 00346 own_initState(); 00347 return true; 00348 }
|
|
Save position.
Definition at line 366 of file Level.cpp. 00367 { 00368 if (m_levelScript->room()->isSolvable()) { 00369 m_levelScript->scriptDo("script_save()"); 00370 } 00371 else { 00372 LOG_INFO(ExInfo("bad level condition, level cannot be finished, " 00373 "no save is made")); 00374 } 00375 return true; 00376 }
|
|
Definition at line 409 of file Level.cpp. 00410 { 00411 if (m_levelScript->isRoom()) { 00412 m_levelScript->room()->controlEvent(stroke); 00413 } 00414 }
|
|
Definition at line 417 of file Level.cpp. 00418 { 00419 if (m_levelScript->isRoom()) { 00420 m_levelScript->room()->controlMouse(button); 00421 } 00422 }
|
|
Create new room and change screen resolution.
Definition at line 429 of file Level.cpp. 00430 { 00431 Room *room = new Room(w, h, picture, m_locker, m_levelScript); 00432 room->addDecor(new StepDecor(room->stepCounter())); 00433 m_levelScript->takeRoom(room); 00434 m_background->removeAll(); 00435 m_background->acceptDrawer(room); 00436 00437 initScreen(); 00438 }
|
|
Definition at line 69 of file Level.h. 00069 { m_desc = desc; }
|
|
Definition at line 79 of file Level.cpp. 00080 { 00081 m_countdown->fillStatus(status); 00082 }
|
|
Implements CountAdvisor. Definition at line 491 of file Level.cpp. 00492 { 00493 int countdown = 10; 00494 if (isLoading()) { 00495 countdown = 0; 00496 } 00497 else if (m_levelScript->dialogs()->areRunning()) { 00498 countdown = 30; 00499 } 00500 return countdown; 00501 }
|
|
Implements CountAdvisor. Definition at line 504 of file Level.cpp. 00505 { 00506 //NOTE: don't forget to change briefcase_help_demo too 00507 return 70; 00508 }
|
|
Definition at line 87 of file Level.h. 00087 { return m_depth; }
|
|
Definition at line 485 of file Level.cpp. 00486 { 00487 return m_desc->findLevelName(m_codename); 00488 }
|
|
Implements INamed. Definition at line 68 of file Level.h. 00068 { return "state_level"; };
|
|
Definition at line 86 of file Level.h. 00086 { return m_restartCounter; }
|
|
Definition at line 473 of file Level.cpp. 00474 { 00475 m_show->removeAll(); 00476 }
|
|
Definition at line 172 of file Level.cpp. 00173 { 00174 return m_loading->isLoading(); 00175 }
|
|
Definition at line 88 of file Level.h. 00088 { return m_newRound; }
|
|
Definition at line 467 of file Level.cpp. 00468 { 00469 return !m_show->empty(); 00470 }
|
|
Start loading mode.
Definition at line 294 of file Level.cpp. 00295 { 00296 m_loading->loadGame(moves); 00297 }
|
|
Start replay mode.
Definition at line 304 of file Level.cpp. 00305 { 00306 m_loading->loadReplay(moves); 00307 }
|
|
Definition at line 458 of file Level.cpp. 00459 { 00460 m_levelScript->interruptPlan(); 00461 DemoMode *demo = new DemoMode(demofile); 00462 pushState(demo); 00463 }
|
|
Clean room after visit.
Implements GameState. Definition at line 143 of file Level.cpp. 00144 { 00145 m_levelScript->cleanRoom(); 00146 }
|
|
Start gameplay. fillDesc() and fillStatus() must be called before. Implements GameState. Definition at line 89 of file Level.cpp. 00090 { 00091 if (NULL == m_desc) { 00092 throw LogicException(ExInfo("level description is NULL") 00093 .addInfo("codename", m_codename)); 00094 } 00095 m_countdown->reset(); 00096 m_loading->reset(); 00097 //NOTE: let level first to draw and then play 00098 m_locker->reset(); 00099 m_locker->ensurePhases(1); 00100 SoundAgent::agent()->stopMusic(); 00101 //TODO: escape "codename" 00102 m_levelScript->scriptDo("CODENAME = [[" + m_codename + "]]"); 00103 m_levelScript->scriptInclude(m_datafile); 00104 }
|
|
Loading is paused on background.
Reimplemented from GameState. Definition at line 152 of file Level.cpp. 00153 { 00154 if (m_loading->isLoading() && !m_loading->isPaused()) { 00155 m_loading->togglePause(); 00156 } 00157 }
|
|
Reimplemented from GameState. Definition at line 160 of file Level.cpp. 00161 { 00162 initScreen(); 00163 if (m_loading->isLoading() && m_loading->isPaused()) { 00164 m_loading->togglePause(); 00165 } 00166 //NOTE: ensure that unwanted mouse press will not move a fish 00167 m_locker->ensurePhases(3); 00168 }
|
|
Implements GameState. Definition at line 126 of file Level.cpp. 00127 { 00128 m_levelScript->killPlan(); 00129 }
|
|
Implements GameState. Definition at line 132 of file Level.cpp. 00133 { 00134 if (m_levelScript->isRoom()) { 00135 initScreen(); 00136 } 00137 }
|
|
Update level.
Implements GameState. Definition at line 110 of file Level.cpp. 00111 { 00112 m_newRound = false; 00113 if (m_locker->getLocked() == 0) { 00114 m_newRound = true; 00115 nextAction(); 00116 } 00117 updateLevel(); 00118 m_locker->decLock(); 00119 00120 if (m_countdown->countDown(this)) { 00121 finishLevel(); 00122 } 00123 }
|
|
Definition at line 479 of file Level.cpp. 00480 { 00481 m_show->planCommand(new_command); 00482 }
|
|
Write save to the file. Save moves and models state.
Definition at line 254 of file Level.cpp. 00255 { 00256 if (m_levelScript->isRoom()) { 00257 Path file = Path::dataWritePath("saves/" + m_codename + ".lua"); 00258 FILE *saveFile = fopen(file.getNative().c_str(), "w"); 00259 if (saveFile) { 00260 std::string moves = 00261 m_levelScript->room()->stepCounter()->getMoves(); 00262 fputs("\nsaved_moves = '", saveFile); 00263 fputs(moves.c_str(), saveFile); 00264 fputs("'\n", saveFile); 00265 00266 fputs("\nsaved_models = ", saveFile); 00267 fputs(models.c_str(), saveFile); 00268 fclose(saveFile); 00269 displaySaveStatus(); 00270 } 00271 else { 00272 LOG_WARNING(ExInfo("cannot save game") 00273 .addInfo("file", file.getNative())); 00274 } 00275 } 00276 }
|
|
Definition at line 401 of file Level.cpp. 00402 { 00403 if (m_levelScript->isRoom()) { 00404 m_levelScript->room()->switchFish(); 00405 } 00406 }
|
|
Definition at line 178 of file Level.cpp. 00179 { 00180 return m_loading->togglePause(); 00181 }
|