Commit 1c5024a8 authored by Gerhard Stein's avatar Gerhard Stein

Difficulty and Players shown when Game is started

parent 8a22dd76
......@@ -43,6 +43,15 @@ enum EngineType
ENGINE_GALAXY
};
enum Difficulty
{
EASY,
NORMAL,
HARD
};
typedef struct{
Uint8 objectnumber1; // Andy (Adurdin) calls that sprite, not all his numbers seem to be right
Uint8 objectnumber2; // Alternate number
......@@ -52,7 +61,9 @@ typedef struct{
class CBehaviorEngine : public CSingleton<CBehaviorEngine>
{
public:
CBehaviorEngine() : mPausedGamePlay(false) {}
CBehaviorEngine() : mPlayers(0),
mDifficulty(EASY),
mPausedGamePlay(false) {}
void addMessage(const std::string &name,
const std::string &message);
......@@ -88,6 +99,10 @@ public:
bool m_is_a_mod;
stOption m_option[NUM_OPTIONS];
unsigned int mPlayers;
Difficulty mDifficulty;
private:
std::vector<CTileProperties> m_TileProperties[2];
CPhysicsSettings m_PhysicsSettings;
......
......@@ -13,6 +13,7 @@
#include "gui/CGUIButton.h"
#include "gui/CGUISwitch.h"
#include "engine/CEvent.h"
#include "CSelectionMenu.h"
#include <vector>
#include <map>
......@@ -73,14 +74,15 @@ private:
// Create the Control-Menu for the indicated Player
struct OpenControlMenuEvent : CEvent
{
OpenControlMenuEvent(const int option) :
mNumPlayers(option) {};
int mNumPlayers;
struct OpenControlMenuEvent : SelectionEvent
{
OpenControlMenuEvent(const int players) :
SelectionEvent(players) {};
};
struct OpenButtonsControlMenuEvent : OpenControlMenuEvent
{
OpenButtonsControlMenuEvent(const int option) :
......@@ -95,27 +97,4 @@ struct OpenMovementControlMenuEvent : OpenControlMenuEvent
};
class CPlayerControl : public CBaseMenu
{
public:
CPlayerControl() :
CBaseMenu( CRect<float>(0.25f, 0.35f, 0.5f, 0.3f) )
{
for( int i = 1 ; i <= MAX_PLAYERS ; i++ )
{
const std::string playerStr = "Player " + itoa(i);
mpButtonList.push_back( new CGUIButton( playerStr,
new OpenControlMenuEvent(i) ) );
mpMenuDialog->addControl( mpButtonList.back() );
}
}
std::list<CGUIButton*> mpButtonList;
};
#endif /* CCONTROLSETTINGS_H_ */
......@@ -8,6 +8,7 @@
#include "CMainMenu.h"
#include "common/Menu/CMenuController.h"
#include "common/Menu/CSettingsMenu.h"
#include "common/Menu/CSelectionMenu.h"
#include "common/Menu/CLoadMenu.h"
#include "common/Menu/CSaveMenu.h"
#include "common/Menu/CHelpMenu.h"
......@@ -21,7 +22,8 @@ CMainMenu::CMainMenu( const bool openedGamePlay ) :
CBaseMenu( CRect<float>(0.25f, 0.23f, 0.5f, 0.5f) )
{
CGUIButton *button = new CGUIButton( "New Game", new StartGameplayEvent() );
CGUIButton *button = new CGUIButton( "New Game",
new OpenMenuEvent( new CPlayersSelection<NewGamePlayersEvent>() ) );
mpMenuDialog->addControl( button );
......
......@@ -76,7 +76,7 @@ void CMenuController::process()
// Control Menu Events
if( OpenMovementControlMenuEvent* ctrlMenu = EventContainer.occurredEvent<OpenMovementControlMenuEvent>() )
{
const int players = ctrlMenu->mNumPlayers;
const int players = ctrlMenu->mSelection;
EventContainer.pop_Event();
EventContainer.add( new OpenMenuEvent(
new CControlSettingsMovement(players) ) );
......@@ -84,7 +84,7 @@ void CMenuController::process()
if( OpenButtonsControlMenuEvent* ctrlMenu = EventContainer.occurredEvent<OpenButtonsControlMenuEvent>() )
{
const int players = ctrlMenu->mNumPlayers;
const int players = ctrlMenu->mSelection;
EventContainer.pop_Event();
EventContainer.add( new OpenMenuEvent(
new CControlSettingsButtons(players) ) );
......@@ -92,7 +92,7 @@ void CMenuController::process()
if( OpenControlMenuEvent* ctrlMenu = EventContainer.occurredEvent<OpenControlMenuEvent>() )
{
const int players = ctrlMenu->mNumPlayers;
const int players = ctrlMenu->mSelection;
EventContainer.pop_Event();
EventContainer.add( new OpenMenuEvent(
new CControlsettings(players) ) );
......
......@@ -11,11 +11,71 @@
#ifndef CSELECTIONMENU_H_
#define CSELECTIONMENU_H_
#include <string>
#include <list>
#include "CBaseMenu.h"
#include "common/Menu/CMenuController.h"
#include "common/CBehaviorEngine.h"
#include "CBaseMenu.h"
struct SelectionEvent : CEvent
{
SelectionEvent(const int option) :
mSelection(option) {};
int mSelection;
};
// Invoked when New Game -> Players selected
struct NewGamePlayersEvent : SelectionEvent
{
NewGamePlayersEvent(const int players) :
SelectionEvent(players) {};
};
// Invoked when New Game -> Players selected -> Difficulty selected
struct StartNewGameEvent : CEvent
{
StartNewGameEvent(const Difficulty difficulty) :
mDifficulty(difficulty) {};
const Difficulty mDifficulty;
};
template <class _T>
class CPlayersSelection : public CBaseMenu
{
public:
CPlayersSelection() :
CBaseMenu( CRect<float>(0.25f, 0.35f, 0.5f, 0.3f) )
{
for( int i = 1 ; i <= MAX_PLAYERS ; i++ )
{
const std::string playerStr = "Player " + itoa(i);
mpButtonList.push_back( new CGUIButton( playerStr,
new _T(i) ) );
mpMenuDialog->addControl( mpButtonList.back() );
}
}
std::list<CGUIButton*> mpButtonList;
};
class CDifficultySelection : public CBaseMenu
{
public:
CDifficultySelection() :
CBaseMenu( CRect<float>(0.25f, 0.35f, 0.5f, 0.3f) )
{
mpMenuDialog->addControl( new CGUIButton( "Easy", new StartNewGameEvent(EASY) ) );
mpMenuDialog->addControl( new CGUIButton( "Normal", new StartNewGameEvent(NORMAL) ) );
mpMenuDialog->addControl( new CGUIButton( "Hard", new StartNewGameEvent(HARD) ) );
}
};
/*class CSelectionMenu : public CBaseMenu
......
......@@ -11,6 +11,7 @@
#include "COptions.h"
#include "CControlsettings.h"
#include "CProfilesMenu.h"
#include "CSelectionMenu.h"
#include "sdl/CTimer.h"
#include "sdl/CVideoDriver.h"
#include "gui/CGUIButton.h"
......@@ -33,7 +34,7 @@ CBaseMenu( CRect<float>(0.25f, 0.24f, 0.5f, 0.32f) )
new OpenMenuEvent( new COptions() ) ) );
mpMenuDialog->addControl(new CGUIButton( "Controls",
new OpenMenuEvent( new CPlayerControl() ) ) );
new OpenMenuEvent( new CPlayersSelection<OpenControlMenuEvent>() ) ) );
mpMenuDialog->addControl(new CGUIButton( "Profile",
new OpenMenuEvent( new CProfilesMenu() ) ) );
......
......@@ -58,10 +58,6 @@ struct GMStart : CEvent
int &mSlot;
};
// Start the Gameplay
struct StartGameplayEvent : CEvent {};
///////
// Base Class for the modes
//////
......
......@@ -12,6 +12,8 @@
#include "engine/infoscenes/CHighScores.h"
#include "common/Menu/CMenuController.h"
#include "core/CGameLauncherMenu.h"
#include "common/Menu/CSelectionMenu.h"
CGamePassiveMode::CGamePassiveMode() :
......@@ -66,13 +68,25 @@ void CGamePassiveMode::process()
if(!EventContainer.empty())
{
if( StartGameplayEvent* pLauncher = EventContainer.occurredEvent<StartGameplayEvent>() )
if( NewGamePlayersEvent* pLauncher = EventContainer.occurredEvent<NewGamePlayersEvent>() )
{
EventContainer.pop_Event();
g_pBehaviorEngine->mPlayers = pLauncher->mSelection;
EventContainer.add( new OpenMenuEvent(new CDifficultySelection) );
return;
}
if( StartNewGameEvent* pStart = EventContainer.occurredEvent<StartNewGameEvent>() )
{
EventContainer.pop_Event();
g_pBehaviorEngine->mDifficulty = pStart->mDifficulty;
switchToGamePlayMode();
return;
}
if( EventContainer.occurredEvent<LoadGameEvent>() )
{
// In this case let's pop this event and add the same one, the way the loading is finished within the playgame object
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment