Skip to content

Commit

Permalink
no more need to use Escape key twice
Browse files Browse the repository at this point in the history
after going Video, Choose set of graphics
to get back working main menu after exiting Video menu

the point is
   -        while ( true )
   +        while ( ! screen->getEscapeAction()->hasBegun() )

and for ShowAuthors too

bins one of gotchas from problem #7
  • Loading branch information
dougmencken committed Oct 7, 2017
1 parent 8c9b5bc commit 2d6942b
Show file tree
Hide file tree
Showing 37 changed files with 150 additions and 92 deletions.
6 changes: 6 additions & 0 deletions src/gui/Screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ Screen::~Screen( )
delete pictureOfHeels ;
}

void Screen::setEscapeAction ( Action * action )
{
delete escapeAction ;
escapeAction = action ;
}

void Screen::refreshBackground ()
{
if ( backgroundPicture != 0 )
Expand Down
2 changes: 1 addition & 1 deletion src/gui/Screen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class Screen : public Widget

Action * getActionOfScreen () const { return actionOfScreen ; }

void setEscapeAction ( Action * action ) { escapeAction = action ; }
void setEscapeAction ( Action * action ) ;

Action * getEscapeAction () const { return escapeAction ; }

Expand Down
24 changes: 20 additions & 4 deletions src/guiactions/Action.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,41 @@ class Action

public:

Action( ) { }
Action( ) : begin( false ), done( false ) { }

virtual ~Action( ) { }

virtual void doIt () = 0 ;
void doIt () { begin = true ; doAction() ; done = true ; }

virtual std::string getNameOfAction () const = 0 ;

bool hasBegun() { return begin ; }

bool isDone() { return done ; }

protected:

virtual void doAction () = 0 ;

private:

bool begin ;

bool done ;

};

class DoNothing : public Action
{

public:

void doIt () { }

std::string getNameOfAction () const { return "DoNothing" ; }

protected:

virtual void doAction () { }

};

}
Expand Down
2 changes: 1 addition & 1 deletion src/guiactions/ContinueGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ContinueGame::ContinueGame( BITMAP* picture, bool gameInProgress )

}

void ContinueGame::doIt ()
void ContinueGame::doAction ()
{
SoundManager::getInstance()->stopAnyOgg (); // or hear music of planets screen when playing after restore

Expand Down
8 changes: 5 additions & 3 deletions src/guiactions/ContinueGame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ class ContinueGame : public Action
*/
ContinueGame( BITMAP* picture, bool gameInProgress ) ;

std::string getNameOfAction () const { return "ContinueGame" ; }

protected:

/**
* Begin the game
*/
void doIt () ;

std::string getNameOfAction () const { return "ContinueGame" ; }
virtual void doAction () ;

private:

Expand Down
2 changes: 1 addition & 1 deletion src/guiactions/CreateAudioMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ CreateAudioMenu::CreateAudioMenu( BITMAP* picture ) :

}

void CreateAudioMenu::doIt ()
void CreateAudioMenu::doAction ()
{
const size_t positionOfValue = 20;

Expand Down
8 changes: 5 additions & 3 deletions src/guiactions/CreateAudioMenu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ class CreateAudioMenu : public Action
*/
CreateAudioMenu( BITMAP* picture ) ;

std::string getNameOfAction () const { return "CreateAudioMenu" ; }

protected:

/**
* Show the audio menu
*/
void doIt () ;

std::string getNameOfAction () const { return "CreateAudioMenu" ; }
virtual void doAction () ;

private:

Expand Down
2 changes: 1 addition & 1 deletion src/guiactions/CreateCongratulationsScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ CreateCongratulationsScreen::~CreateCongratulationsScreen( )

}

void CreateCongratulationsScreen::doIt ()
void CreateCongratulationsScreen::doAction ()
{
LanguageManager* languageManager = GuiManager::getInstance()->getLanguageManager();
LanguageText* langString = 0;
Expand Down
8 changes: 5 additions & 3 deletions src/guiactions/CreateCongratulationsScreen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ class CreateCongratulationsScreen : public Action

virtual ~CreateCongratulationsScreen( ) ;

std::string getNameOfAction () const { return "CreateCongratulationsScreen" ; }

protected:

/**
* Crea la pantalla con el texto
*/
void doIt () ;

std::string getNameOfAction () const { return "CreateCongratulationsScreen" ; }
virtual void doAction () ;

private:

Expand Down
2 changes: 1 addition & 1 deletion src/guiactions/CreateEndScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ CreateEndScreen::CreateEndScreen( BITMAP* picture, unsigned int rooms, unsigned
{
}

void CreateEndScreen::doIt ()
void CreateEndScreen::doAction ()
{
SoundManager::getInstance()->playOgg( "music/MainTheme.ogg", /* loop */ true );

Expand Down
8 changes: 5 additions & 3 deletions src/guiactions/CreateEndScreen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ class CreateEndScreen : public gui::Action
*/
CreateEndScreen( BITMAP* picture, unsigned int rooms, unsigned short planets ) ;

std::string getNameOfAction () const { return "CreateEndScreen" ; }

protected:

/**
* Show summary screen
*/
void doIt () ;

std::string getNameOfAction () const { return "CreateEndScreen" ; }
virtual void doAction () ;

private:

Expand Down
2 changes: 1 addition & 1 deletion src/guiactions/CreateKeyboardMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ CreateKeyboardMenu::CreateKeyboardMenu( BITMAP* picture ) :

}

void CreateKeyboardMenu::doIt ()
void CreateKeyboardMenu::doAction ()
{
const size_t positionOfKey = 21;

Expand Down
8 changes: 5 additions & 3 deletions src/guiactions/CreateKeyboardMenu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ class CreateKeyboardMenu : public Action
*/
CreateKeyboardMenu( BITMAP* picture ) ;

std::string getNameOfAction () const { return "CreateKeyboardMenu" ; }

protected:

/**
* Show the keys menu
*/
void doIt () ;

std::string getNameOfAction () const { return "CreateKeyboardMenu" ; }
virtual void doAction () ;

private:

Expand Down
2 changes: 1 addition & 1 deletion src/guiactions/CreateLanguageMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ CreateLanguageMenu::~CreateLanguageMenu( )
this->texts.clear();
}

void CreateLanguageMenu::doIt ()
void CreateLanguageMenu::doAction ()
{
Screen* screen = GuiManager::getInstance()->findOrCreateScreenForAction( this, this->where );
if ( screen->countWidgets() == 0 )
Expand Down
10 changes: 5 additions & 5 deletions src/guiactions/CreateLanguageMenu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ class CreateLanguageMenu : public Action

~CreateLanguageMenu( ) ;

std::string getNameOfAction () const { return "CreateLanguageMenu" ; }

protected:

/**
* Show the language menu
*/
void doIt () ;

std::string getNameOfAction () const { return "CreateLanguageMenu" ; }
virtual void doAction () ;

private:

Expand All @@ -54,8 +56,6 @@ class CreateLanguageMenu : public Action
*/
void parse ( const std::string& fileName ) ;

private:

/**
* Imagen donde se dibujará la interfaz gráfica
*/
Expand Down
2 changes: 1 addition & 1 deletion src/guiactions/CreateListOfSavedGames.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ CreateListOfSavedGames::CreateListOfSavedGames( BITMAP* picture, bool isLoadMenu

}

void CreateListOfSavedGames::doIt ()
void CreateListOfSavedGames::doAction ()
{
Screen* screen = GuiManager::getInstance()->findOrCreateScreenForAction( this, this->where );
if ( screen->countWidgets() > 0 )
Expand Down
14 changes: 7 additions & 7 deletions src/guiactions/CreateListOfSavedGames.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,17 @@ class CreateListOfSavedGames : public gui::Action
*/
CreateListOfSavedGames( BITMAP* picture, bool isLoadMenu ) ;

/**
* Show the saved games
*/
void doIt () ;

std::string getNameOfAction () const { return "CreateListOfSavedGames" ; }

bool isLoadMenu () { return this->isMenuForLoad ; }

protected:

/**
* Show the saved games
*/
virtual void doAction () ;

private:

/**
Expand All @@ -55,8 +57,6 @@ class CreateListOfSavedGames : public gui::Action
*/
void readSomeInfoFromGamefile( const std::string& fileName, short* rooms, short* planets ) ;

private:

BITMAP* where ;

bool isMenuForLoad ;
Expand Down
2 changes: 1 addition & 1 deletion src/guiactions/CreateMainMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ CreateMainMenu::CreateMainMenu( BITMAP* picture ) :

}

void CreateMainMenu::doIt ()
void CreateMainMenu::doAction ()
{
if ( ! SoundManager::getInstance()->isPlayingOgg( "music/MainTheme.ogg" ) )
{
Expand Down
8 changes: 5 additions & 3 deletions src/guiactions/CreateMainMenu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ class CreateMainMenu : public Action
*/
CreateMainMenu( BITMAP* picture ) ;

std::string getNameOfAction () const { return "CreateMainMenu" ; }

protected:

/**
* Show the main menu of the game
*/
void doIt () ;

std::string getNameOfAction () const { return "CreateMainMenu" ; }
virtual void doAction () ;

private:

Expand Down
2 changes: 1 addition & 1 deletion src/guiactions/CreateMenuOfGraphicSets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ CreateMenuOfGraphicSets::CreateMenuOfGraphicSets( BITMAP* picture, Action* previ
menuOfGraphicSets->setVerticalOffset( 50 );
}

void CreateMenuOfGraphicSets::doIt ()
void CreateMenuOfGraphicSets::doAction ()
{
const size_t positionOfSecondColumn = 18;

Expand Down
8 changes: 5 additions & 3 deletions src/guiactions/CreateMenuOfGraphicSets.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ class CreateMenuOfGraphicSets : public Action
*/
CreateMenuOfGraphicSets( BITMAP * picture, Action * previous ) ;

std::string getNameOfAction () const { return "CreateMenuOfGraphicSets" ; }

protected:

/**
* Show this menu
*/
void doIt () ;

std::string getNameOfAction () const { return "CreateMenuOfGraphicSets" ; }
virtual void doAction () ;

private:

Expand Down
2 changes: 1 addition & 1 deletion src/guiactions/CreatePlanetsScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ CreatePlanetsScreen::~CreatePlanetsScreen( )

}

void CreatePlanetsScreen::doIt ()
void CreatePlanetsScreen::doAction ()
{
SoundManager::getInstance()->playOgg( "music/HeadOverHeels.ogg", /* loop */ false );

Expand Down
12 changes: 7 additions & 5 deletions src/guiactions/CreatePlanetsScreen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ class CreatePlanetsScreen : public Action

virtual ~CreatePlanetsScreen( ) ;

/**
* Crea la pantalla de los planetas
*/
void doIt () ;

std::string getNameOfAction () const { return "CreatePlanetsScreen" ; }

void liberateBlacktooth() { blacktoothFree = true ; }
Expand All @@ -52,6 +47,13 @@ class CreatePlanetsScreen : public Action

void liberateSafari() { safariFree = true ; }

protected:

/**
* Crea la pantalla de los planetas
*/
virtual void doAction () ;

private:

/**
Expand Down
Loading

0 comments on commit 2d6942b

Please sign in to comment.