Skip to content

Commit

Permalink
Finally, added options to the pause menu mode.
Browse files Browse the repository at this point in the history
Part of #155.

What's left is to add game options:
- Dialogues speed
- Difficulty setting
- Battle target cursor memory
  • Loading branch information
Yohann Ferreira committed Apr 8, 2014
1 parent 7d623e5 commit 2733161
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 48 deletions.
121 changes: 75 additions & 46 deletions src/modes/pause.cpp
Expand Up @@ -43,9 +43,10 @@ bool PAUSE_DEBUG = false;
*** presented to the player while the _quit_state member is active.
**/
//@{
const uint8 QUIT_GAME = 0;
const uint8 QUIT_TO_BOOT = 1;
const uint8 QUIT_CANCEL = 2;
const uint8 QUIT_CANCEL = 0;
const uint8 QUIT_OPTIONS = 1;
const uint8 QUIT_TO_BOOT = 2;
const uint8 QUIT_GAME = 3;
//@}

PauseMode::PauseMode(bool quit_state, bool pause_audio) :
Expand All @@ -54,7 +55,8 @@ PauseMode::PauseMode(bool quit_state, bool pause_audio) :
_audio_paused(pause_audio),
_music_volume(1.0f),
_dim_color(0.35f, 0.35f, 0.35f, 1.0f), // A grayish opaque color
_option_selected(false)
_option_selected(false),
_options_handler(this)
{
mode_type = MODE_MANAGER_PAUSE_MODE;

Expand All @@ -64,20 +66,32 @@ PauseMode::PauseMode(bool quit_state, bool pause_audio) :

// Initialize the quit options box
_quit_options.SetPosition(512.0f, 384.0f);
_quit_options.SetDimensions(750.0f, 50.0f, 3, 1, 3, 1);
_quit_options.SetDimensions(150.0f, 300.0f, 1, 4, 1, 4);
_quit_options.SetTextStyle(TextStyle("title24", Color::white, VIDEO_TEXT_SHADOW_BLACK));

_quit_options.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
_quit_options.SetOptionAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
_quit_options.SetSelectMode(VIDEO_SELECT_SINGLE);
_quit_options.SetCursorOffset(-58.0f, -18.0f);

_quit_options.AddOption(UTranslate("Quit Game"));
_quit_options.AddOption(UTranslate("Quit to Main Menu"));
_SetupOptions();
}

void PauseMode::_SetupOptions()
{
_quit_options.ClearOptions();
_quit_options.AddOption(UTranslate("Cancel"));
_quit_options.AddOption(UTranslate("Options"));
_quit_options.AddOption(UTranslate("Quit to Main Menu"));
_quit_options.AddOption(UTranslate("Quit Game"));
_quit_options.SetSelection(QUIT_CANCEL);
}

void PauseMode::ReloadTranslatedTexts()
{
_SetupOptions();
}

PauseMode::~PauseMode()
{
if(_audio_paused)
Expand Down Expand Up @@ -130,52 +144,64 @@ void PauseMode::Update()
if(!_quit_state) {
if(InputManager->QuitPress()) {
_quit_state = true;
return;
} else if(InputManager->PausePress()) {
_option_selected = true;
ModeManager->Pop();
return;
}
} else { // (_quit_state == true)
_quit_options.Update();

if(InputManager->QuitPress()) {
_option_selected = true;
ModeManager->Pop();
return;
} else if(InputManager->ConfirmPress()) {
_option_selected = true;
switch(_quit_options.GetSelection()) {
case QUIT_CANCEL:
ModeManager->Pop();
break;
case QUIT_TO_BOOT:
// Disable potential previous effects
VideoManager->DisableFadeEffect();
ModeManager->PopAll();

// This will permit the fade system to start updating again.
mode_type = MODE_MANAGER_DUMMY_MODE;

ModeManager->Push(new BootMode(), true, true);
break;
case QUIT_GAME:
SystemManager->ExitGame();
break;
default:
IF_PRINT_WARNING(PAUSE_DEBUG) << "unknown quit option selected: " << _quit_options.GetSelection() << std::endl;
break;
}
return;
} else if(InputManager->CancelPress()) {
_option_selected = true;
return;
}

// (_quit_state == true)

// Handles the options menu
if (_options_handler.IsActive()) {
_options_handler.Update();
return;
}

_quit_options.Update();

if(InputManager->QuitPress()) {
_option_selected = true;
ModeManager->Pop();
return;
} else if(InputManager->ConfirmPress()) {
_option_selected = true;
switch(_quit_options.GetSelection()) {
case QUIT_CANCEL:
ModeManager->Pop();
return;
} else if(InputManager->LeftPress()) {
_quit_options.InputLeft();
} else if(InputManager->RightPress()) {
_quit_options.InputRight();
break;
case QUIT_TO_BOOT:
// Disable potential previous effects
VideoManager->DisableFadeEffect();
ModeManager->PopAll();

// This will permit the fade system to start updating again.
mode_type = MODE_MANAGER_DUMMY_MODE;

ModeManager->Push(new BootMode(), true, true);
break;
case QUIT_OPTIONS:
_option_selected = false;
_options_handler.Activate();
break;
case QUIT_GAME:
SystemManager->ExitGame();
break;
default:
IF_PRINT_WARNING(PAUSE_DEBUG) << "unknown quit option selected: " << _quit_options.GetSelection() << std::endl;
break;
}
return;
} else if(InputManager->CancelPress()) {
_option_selected = true;
ModeManager->Pop();
return;
} else if(InputManager->UpPress()) {
_quit_options.InputUp();
} else if(InputManager->DownPress()) {
_quit_options.InputDown();
}
} // void PauseMode::Update()

Expand All @@ -193,6 +219,9 @@ void PauseMode::DrawPostEffects()
_paused_text.Draw();
} else {
_quit_options.Draw();

if (_options_handler.IsActive())
_options_handler.Draw();
}
}

Expand Down
15 changes: 13 additions & 2 deletions src/modes/pause.h
Expand Up @@ -18,10 +18,11 @@
#ifndef __PAUSE_HEADER__
#define __PAUSE_HEADER__

#include "common/gui/option.h"

#include "engine/mode_manager.h"

#include "common/options_handler.h"
#include "common/gui/option.h"

//! \brief All calls to pause mode are wrapped in this namespace.
namespace vt_pause
{
Expand Down Expand Up @@ -74,6 +75,9 @@ class PauseMode : public vt_mode_manager::GameMode
//! \brief Draws the next frame to be displayed on the screen, bunt unaffected but ambient effects
void DrawPostEffects();

//! \brief Reload the different translated texts
void ReloadTranslatedTexts();

private:
//! \brief When true, the player is presented with quit options. When false, "Paused" is displayed on the screen
bool _quit_state;
Expand All @@ -98,6 +102,13 @@ class PauseMode : public vt_mode_manager::GameMode

//! \brief Tells whether an option has been selected, thus preventing the quick triggering of another one.
bool _option_selected;

//! \brief The options permitting to change different settings.
vt_gui::private_gui::GameOptionsMenuHandler _options_handler;

//! \brief Load or reload the menu options
void _SetupOptions();

}; // class PauseMode : public vt_mode_manager::GameMode

} // namespace vt_pause
Expand Down

0 comments on commit 2733161

Please sign in to comment.