previous functionality of the view restored with a few new benefits ("non-linear" menus)
This commit is contained in:
+39
-11
@@ -71,7 +71,9 @@ int View::OnInit (int argc, char* argv[]) {
|
||||
Engine::RegisterListener (this, EventAccelerateStart);
|
||||
Engine::RegisterListener (this, EventAccelerateStop);
|
||||
Engine::RegisterListener (this, EventShipExplode);
|
||||
Engine::RegisterListener (this, EventPlayerDied);
|
||||
Engine::RegisterListener (this, EventGameOver);
|
||||
Engine::RegisterListener (this, EventLevelComplete);
|
||||
|
||||
PushViewState (ViewStateMainMenu);
|
||||
|
||||
@@ -96,19 +98,32 @@ bool View::OnReceiveEvent (const Engine::EventBasePtr &event) {
|
||||
return true;
|
||||
|
||||
break;
|
||||
case EventLevelComplete:
|
||||
PushViewState(ViewStateLevelComplete);
|
||||
GetModel()->SetPlayerEntityId(Engine::NullEntityId);
|
||||
break;
|
||||
|
||||
case EventGameOver:
|
||||
mFadeTimerSecValue = 2.;
|
||||
|
||||
PopViewState();
|
||||
PushViewState(ViewStateGameOver);
|
||||
GetModel()->SetGameState(GameStatePaused);
|
||||
|
||||
GetModel()->SetPlayerEntityId(Engine::NullEntityId);
|
||||
|
||||
break;
|
||||
case EventPlayerDied:
|
||||
mFadeTimerSecValue = 2.;
|
||||
PushViewState(ViewStatePlayerDied);
|
||||
|
||||
GetModel()->SetPlayerEntityId(Engine::NullEntityId);
|
||||
|
||||
break;
|
||||
case EventShipExplode: {
|
||||
Engine::LogDebug ("Received Ship Explode Event: %d", event->mEventType);
|
||||
// This event is fired when the ship explodes. Note: this event is not
|
||||
// sufficient for EventPlayerDied!
|
||||
Engine::LogDebug ("Received PlayerDied Event: %d", event->mEventType);
|
||||
|
||||
PopViewState();
|
||||
PushViewState(ViewStatePlayerDied);
|
||||
GetModel()->SetGameState(GameStatePaused);
|
||||
|
||||
// insert sprits that contains parts of the ship
|
||||
Engine::EntityBase *ship_entity = Engine::GetEntity (event->mEventUnsignedInt);
|
||||
vector3d position = ship_entity->mPhysicState->mPosition;
|
||||
@@ -206,6 +221,8 @@ void View::DrawStars() {
|
||||
void View::Draw() {
|
||||
PreDraw();
|
||||
|
||||
mFadeTimerSecValue -= GetModel()->GetFrameDuration();
|
||||
|
||||
// Actual Drawing
|
||||
UpdateCamera ();
|
||||
|
||||
@@ -215,12 +232,11 @@ void View::Draw() {
|
||||
/*
|
||||
if (mDrawAxis)
|
||||
DrawAxis ();
|
||||
*/
|
||||
*/
|
||||
|
||||
DrawWorld ();
|
||||
|
||||
DrawUi ();
|
||||
// mOverlayManager.Draw();
|
||||
|
||||
// Perform post-Draw actions
|
||||
PostDraw();
|
||||
@@ -499,9 +515,15 @@ void View::DrawUiGameOver() {
|
||||
screen_bottom * 0.5 + 32);
|
||||
}
|
||||
|
||||
if (mFadeTimerSecValue > 0.)
|
||||
return;
|
||||
|
||||
if (Engine::GUI::Button (2, "Continue...",
|
||||
(screen_right - button_width) * 0.5,
|
||||
screen_bottom * 0.5 + 80, button_width, button_height)) {
|
||||
// We do not want the background to show the remaining bits of the game
|
||||
GetModel()->SetGameState(GameStatePaused);
|
||||
|
||||
PopViewState();
|
||||
PushViewState(ViewStateShowHighscore);
|
||||
}
|
||||
@@ -514,6 +536,7 @@ void View::DrawUiLevelComplete() {
|
||||
|
||||
if(Engine::GUI::Button (1, "Next level ...", (screen_right - button_width) * 0.5, screen_bottom * 0.5 + 60, button_width, button_height)) {
|
||||
PopViewState();
|
||||
GetModel()->ProceedToNextLevel();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -531,8 +554,7 @@ void View::DrawUiGamePaused() {
|
||||
}
|
||||
|
||||
if (Engine::GUI::Button (3, "Abort Game", screen_right * 0.5 - 100, 300, button_width, button_height)) {
|
||||
while (mViewStateStack.size())
|
||||
PopViewState();
|
||||
ResetViewState();
|
||||
|
||||
PushViewState(ViewStateMainMenu);
|
||||
GetModel()->SetGameState(GameStatePaused);
|
||||
@@ -547,8 +569,13 @@ void View::DrawUiPlayerDied() {
|
||||
DrawPageTitle ("You died!");
|
||||
SelectFont ("console.ttf size=23");
|
||||
|
||||
if (Engine::GUI::Button (1, "Continue", screen_right * 0.5 - 100, 200, button_width, button_height)) {
|
||||
if (mFadeTimerSecValue > 0.)
|
||||
return;
|
||||
|
||||
if (Engine::GUI::Button (1, "Continue", screen_right * 0.5 - 100, 380, button_width, button_height)) {
|
||||
PopViewState();
|
||||
GetModel()->ReloadLevel();
|
||||
GetModel()->SetGameState(GameStateRunning);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -593,6 +620,7 @@ void View::DrawUiHighscore() {
|
||||
DrawPageTitle ("Highscores");
|
||||
SelectFont ("console.ttf size=23");
|
||||
|
||||
|
||||
unsigned int entry_length = 32;
|
||||
float char_width, height;
|
||||
DrawGLStringMeasure ("M", &char_width, &height);
|
||||
|
||||
Reference in New Issue
Block a user