Commit 2d4eb007 authored by Gerhard Stein's avatar Gerhard Stein

Now New Game within a Game will properly start

parent 6f4c33c3
......@@ -12,12 +12,27 @@
#include "engine/infoscenes/CHighScores.h"
#include "core/mode/CGameMode.h"
#include "common/Menu/CMenuController.h"
#include "common/Menu/CSelectionMenu.h"
#include "sdl/CVideoDriver.h"
void CGameMain::switchToGamePlayMode()
{
const int episode = g_pBehaviorEngine->getEpisode();
//const int Numplayers = mp_Passive->getNumPlayers();
const int Numplayers = 1;
std::string DataDirectory = g_pBehaviorEngine->m_ExeFile.getDataDirectory();
g_pBehaviorEngine->m_EventList.add( new GMSwitchToPlayGameMode( episode, Numplayers, DataDirectory ) );
}
void CGameMain::init()
{}
void CGameMain::process()
{
// process any triggered Game Main related event
......@@ -26,7 +41,7 @@ void CGameMain::process()
if( !EventContainer.empty() )
{
if( GMSwitchToPassiveMode* p_Passive = EventContainer.occurredEvent<GMSwitchToPassiveMode>() )
if( EventContainer.occurredEvent<GMSwitchToPassiveMode>() )
{
mpGameMode = new CGamePassiveMode();
mpGameMode->init();
......@@ -51,6 +66,34 @@ void CGameMain::process()
EventContainer.add( new CloseAllMenusEvent() );
return;
}
else if( NewGamePlayersEvent* pLauncher = EventContainer.occurredEvent<NewGamePlayersEvent>() )
{
EventContainer.pop_Event();
g_pBehaviorEngine->mPlayers = pLauncher->mSelection;
EventContainer.add( new OpenMenuEvent(new CDifficultySelection) );
return;
}
else if( StartNewGameEvent* pStart = EventContainer.occurredEvent<StartNewGameEvent>() )
{
EventContainer.pop_Event();
g_pBehaviorEngine->mDifficulty = pStart->mDifficulty;
switchToGamePlayMode();
return;
}
else if( EventContainer.occurredEvent<LoadGameEvent>() &&
(dynamic_cast<CGamePlayMode*>(mpGameMode.get()) == NULL) ) // If GamePlayMode is not running but loading is requested...
{
// In this case let's pop this event and add the same one, the way the loading is finished within the playgame object
EventContainer.pop_Event();
switchToGamePlayMode();
// The same caught event is pushed again but this time it will be polled by the GamePlay object which in the next cycles will be running!
EventContainer.add( new LoadGameEvent() );
}
}
......
......@@ -18,6 +18,8 @@ public:
protected:
void switchToGamePlayMode();
void init();
void process();
......
......@@ -68,4 +68,5 @@ public:
virtual void init() = 0;
};
#endif /* CGAMEMODE_H_ */
......@@ -46,14 +46,6 @@ void CGamePassiveMode::init()
}
void CGamePassiveMode::switchToGamePlayMode()
{
const int episode = g_pBehaviorEngine->getEpisode();
//const int Numplayers = mp_Passive->getNumPlayers();
const int Numplayers = 1;
std::string DataDirectory = mpPassive->getGamePath();
g_pBehaviorEngine->m_EventList.add( new GMSwitchToPlayGameMode( episode, Numplayers, DataDirectory ) );
}
void CGamePassiveMode::process()
{
......@@ -64,37 +56,11 @@ void CGamePassiveMode::process()
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
if(!EventContainer.empty())
/*if(!EventContainer.empty())
{
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
EventContainer.pop_Event();
switchToGamePlayMode();
// The same caught event is pushed again but this time it will be polled by the GamePlay object which in the next cycles will be running!
EventContainer.add( new LoadGameEvent() );
}
}
}*/
// check here what the player chose from the menu over the passive mode.
// NOTE: Demo is not part of playgame anymore!!
......
......@@ -20,7 +20,6 @@ public:
CGamePassiveMode();
void init();
void switchToGamePlayMode();
void process();
private:
......
......@@ -203,7 +203,7 @@ void CEndingEp1::ShipFlyEarthToMShip()
m_Player[0].hideplayer = false;
x = 48<<CSF;
y = 23<<CSF;
m_Player[0].moveTo(VectorD2<int>(x,y));
m_Player[0].moveTo( VectorD2<int>(x,y) );
mpMap->gotoPos((x>>STC)-100, (y>>STC)-160);
......
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