Commit 7e53e66b authored by Gerhard Stein's avatar Gerhard Stein

"End Game" now works

parent 2d4eb007
......@@ -23,6 +23,7 @@
CGameLauncher::CGameLauncher()
{
g_pBehaviorEngine->setEpisode(0);
m_mustquit = false;
m_chosenGame = -1;
m_ep1slot = -1;
......
......@@ -16,6 +16,7 @@
#include "common/CBehaviorEngine.h"
#include "gui/CGUIButton.h"
#include "core/mode/CGameMode.h"
#include "core/CGameLauncherMenu.h"
CMainMenu::CMainMenu( const bool openedGamePlay ) :
......@@ -45,6 +46,8 @@ CBaseMenu( CRect<float>(0.25f, 0.23f, 0.5f, 0.5f) )
mpMenuDialog->addControl(new CGUIButton( "Info",
new OpenMenuEvent( new CHelpMenu() ) ) );
mpMenuDialog->addControl(new CGUIButton( "End Game", new GMSwitchToGameLauncher() ) );
mpMenuDialog->addControl(new CGUIButton( "Quit", new GMQuit() ) );
setMenuLabel("MAINMENULABEL");
......
......@@ -13,6 +13,12 @@
#include "sdl/music/CMusic.h"
void CMenuController::emptyMenuStack()
{
while(!mMenuStack.empty())
popBackMenu();
}
void CMenuController::process()
{
......@@ -66,8 +72,7 @@ void CMenuController::process()
if( EventContainer.occurredEvent<CloseAllMenusEvent>() )
{
while(!mMenuStack.empty())
popBackMenu();
emptyMenuStack();
EventContainer.pop_Event();
g_pMusicPlayer->play();
......
......@@ -41,6 +41,8 @@ class CMenuController
public:
CMenuController() : mOpenedGamePlay(false) {}
void emptyMenuStack();
void process();
bool active()
......
......@@ -12,6 +12,7 @@
#include "mode/CGameMode.h"
class CBaseEngine
{
......
......@@ -21,6 +21,8 @@
#include "mode/CGamePlayMode.h"
#include "mode/CGamePassiveMode.h"
#include "sdl/CVideoDriver.h"
#include "arguments.h"
......@@ -89,6 +91,7 @@ void CGameControl::process()
if( GMSwitchToGameLauncher* p_Launcher = EventContainer.occurredEvent<GMSwitchToGameLauncher>() )
{
mMenuController.emptyMenuStack();
mpEngine = new CGameLauncherMenu( m_firsttime, p_Launcher->m_ChosenGame, p_Launcher->m_StartLevel );
mpEngine->init();
EventContainer.pop_Event();
......
......@@ -44,7 +44,8 @@ private:
// Events
// This event switches to the GameLauncher
struct GMSwitchToGameLauncher : CEvent {
struct GMSwitchToGameLauncher : CEvent
{
const int m_ChosenGame;
const int m_StartLevel;
GMSwitchToGameLauncher( const int ChosenGame=-1, const int StartLevel=-1 ) :
......
......@@ -19,7 +19,8 @@
// Events Structure //
///////////////////////
// This event switches to the PassiveMode
struct GMSwitchToPassiveMode : CEvent {
struct GMSwitchToPassiveMode : CEvent
{
const std::string m_DataDirectory;
const int m_Episode;
GMSwitchToPassiveMode( const std::string& DataDirectory, const int& Episode ) :
......@@ -46,7 +47,7 @@ struct GMSwitchToPlayGameMode : CEvent
// It's a simple quit event which will force CG to close the App
struct GMQuit : CEvent {};
// It's a simple quit event which will force CG to close the App
// It's a simple start event which will force CG launch a game from a specified slot
struct GMStart : CEvent
{
GMStart(int &Slot) :
......
......@@ -17,6 +17,8 @@
class CEventContainer {
public:
size_t size() { return m_EventList.size(); }
bool empty() { return m_EventList.empty(); }
void clear() { m_EventList.clear(); }
void add(const SmartPointer<CEvent>& ev) { m_EventList.push_back(ev); }
......
......@@ -29,7 +29,7 @@ CGUIDialog::~CGUIDialog()
{
CVideoDriver *pVideoDriver = CVideoDriver::GetNoPtrChk();
if( pVideoDriver ) // This checks if the video object still exists, because if
{ // deleting drawing routine, it is not needed anymore
{ // deleting drawing routine, it is not needed anymore
pVideoDriver->clearDrawingTasks();
}
}
......
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