added level_assemble_mode for easier switching between levels ingame

main
Martin Felis (berta) 2011-03-23 08:13:27 +01:00
parent 27843ac067
commit 69c6e1aaef
3 changed files with 30 additions and 0 deletions

View File

@ -604,6 +604,13 @@ int Model::DoSaveLevel (const char* filename) {
return 0;
}
void Model::LoadLevelFromIndex (unsigned int level_index) {
if (level_index < mLevelList.size()) {
mCurrentLevelIndex = level_index;
DoLoadLevel(mLevelList[mCurrentLevelIndex].c_str());
}
}
void Model::ReloadLevel () {
Engine::LogDebug ("Reloading level %d", mCurrentLevelIndex + 1);

View File

@ -23,6 +23,7 @@ class Model : public Engine::ModelBase {
/* Level loading etc. */
int DoLoadLevel (const char* filename);
int DoSaveLevel (const char* filename);
void LoadLevelFromIndex (unsigned int level_index);
void ResetLevel ();
void ReloadLevel();

View File

@ -31,6 +31,8 @@ using namespace std;
namespace asteroids {
bool level_assemble_mode = true;
int View::OnInit (int argc, char* argv[]) {
ViewBase::OnInit (argc, argv);
@ -542,6 +544,26 @@ void View::DrawUiGameRunning() {
// revert the font justification
SetFontJustification (Engine::FontJustificationLeft);
if (level_assemble_mode) {
if (Engine::GUI::CheckKeyPress(SDLK_PAGEDOWN)) {
Engine::EventBasePtr level_complete_event (new Engine::EventBase());
level_complete_event->mEventType = EventLevelComplete;
QueueEvent (level_complete_event);
} else if (Engine::GUI::CheckKeyPress(SDLK_PAGEUP)) {
unsigned int current_level = GetModel()->GetCurrentLevelIndex();
if (current_level > 0) {
GetModel()->SetGameState(GameStatePaused);
GetModel()->LoadLevelFromIndex(current_level - 1);
PushViewState(ViewStateLevelIntro);
Engine::StartTimer ("LevelIntroLevelNumber", 0.4);
Engine::StartTimer ("LevelIntroLevelTitle", 0.6);
Engine::StartTimer ("LevelIntroLevelAuthor", 0.8);
Engine::StartTimer ("LevelIntroLevelStart", 1.0);
}
}
}
if (Engine::GUI::CheckKeyPress(SDLK_ESCAPE)) {
PushViewState(ViewStatePaused);
GetModel()->SetGameState(GameStatePaused);