Commit aa1f3b11 authored by Gerhard Stein's avatar Gerhard Stein

Crash fixes

parent 836a80ff
......@@ -102,10 +102,10 @@ bool CGameLauncher::loadResources()
mLauncherDialog.addControl(new CGUIText("Pick a Game"), GsRect<float>(0.0f, 0.0f, 1.0f, 0.05f));
mLauncherDialog.addControl(new CGUIButton( "x", new GMQuit() ), GsRect<float>(0.0f, 0.0f, 0.07f, 0.07f) );
mLauncherDialog.addControl(new GsButton( "x", new GMQuit() ), GsRect<float>(0.0f, 0.0f, 0.07f, 0.07f) );
mLauncherDialog.addControl(mpSelList, GsRect<float>(0.01f, 0.07f, 0.49f, 0.87f));
mLauncherDialog.addControl(new CGUIButton( "Start >", new GMStart() ), GsRect<float>(0.65f, 0.865f, 0.3f, 0.07f) );
mLauncherDialog.addControl(new GsButton( "Start >", new GMStart() ), GsRect<float>(0.65f, 0.865f, 0.3f, 0.07f) );
mpEpisodeText = new CGUIText("Game");
mpVersionText = new CGUIText("Version");
......
......@@ -29,7 +29,7 @@ public:
mpButton(NULL)
{}
void setButtonPtr(CGUIButton* button)
void setButtonPtr(GsButton* button)
{
mpButton = button;
}
......@@ -45,7 +45,7 @@ public:
int mSelPlayer;
InputCommands mCommand;
const std::string mCommandName;
CGUIButton* mpButton;
GsButton* mpButton;
};
......@@ -74,12 +74,12 @@ CControlsettings::CControlsettings( const int selectedPlayer ) :
CBaseMenu( GsRect<float>(0.1f, 0.25f, 0.8f, 0.5f) ),
mSelectedPlayer(selectedPlayer)
{
CGUIButton *button;
GsButton *button;
button = new CGUIButton( "Movement", new OpenMovementControlMenuEvent(mSelectedPlayer) );
button = new GsButton( "Movement", new OpenMovementControlMenuEvent(mSelectedPlayer) );
mpMenuDialog->addControl( button );
button = new CGUIButton( "Buttons", new OpenButtonsControlMenuEvent(mSelectedPlayer) );
button = new GsButton( "Buttons", new OpenButtonsControlMenuEvent(mSelectedPlayer) );
mpMenuDialog->addControl( button );
mpTwoButtonSwitch = new CGUISwitch( "Two Button Fire" );
......@@ -102,7 +102,7 @@ mSelectedPlayer(selectedPlayer)
mpMenuDialog->addControl( mpSuperPogoSwitch );
mpMenuDialog->addControl( mpImpPogoSwitch );
mpMenuDialog->addControl( mpAutoGunSwitch );
mpMenuDialog->addControl( new CGUIButton( "Reset Controls", new ResetInputEvent(mSelectedPlayer-1) ) );
mpMenuDialog->addControl( new GsButton( "Reset Controls", new ResetInputEvent(mSelectedPlayer-1) ) );
setMenuLabel("KEYBMENULABEL");
......@@ -153,7 +153,7 @@ void CControlSettingsMovement::init()
const std::string buf2 = gInput.getEventShortName( it->first, mSelectedPlayer-1 );
ReadInputEvent *rie = new ReadInputEvent(mSelectedPlayer, it->first, it->second);
CGUIButton *guiButton = new CGUIButton( buf+buf2, rie );
GsButton *guiButton = new GsButton( buf+buf2, rie );
rie->setButtonPtr(guiButton);
mpButtonList.push_back( guiButton );
......@@ -177,7 +177,7 @@ void CControlSettingsMovement::ponder()
// mapping changed!
mapping = false;
CGUIButton *button = dynamic_cast<CGUIButton*>(mpMenuDialog->CurrentControl());
GsButton *button = dynamic_cast<GsButton*>(mpMenuDialog->CurrentControl());
if(button)
{
int pos; unsigned char input;
......@@ -228,7 +228,7 @@ void CControlSettingsButtons::init()
const std::string buf2 = gInput.getEventShortName( it->first, mSelectedPlayer-1 );
ReadInputEvent *rie = new ReadInputEvent(mSelectedPlayer, it->first, it->second);
CGUIButton *guiButton = new CGUIButton( buf+buf2, rie );
GsButton *guiButton = new GsButton( buf+buf2, rie );
rie->setButtonPtr(guiButton);
......@@ -254,7 +254,7 @@ void CControlSettingsButtons::ponder()
// mapping changed!
mapping = false;
CGUIButton *button = dynamic_cast<CGUIButton*>(mpMenuDialog->CurrentControl());
GsButton *button = dynamic_cast<GsButton*>(mpMenuDialog->CurrentControl());
if(button)
{
int pos; unsigned char input;
......
......@@ -57,7 +57,7 @@ private:
int mSelectedPlayer;
std::vector<CGUIButton*> mpButtonList;
std::vector<GsButton*> mpButtonList;
std::map<InputCommands, std::string> mCommandName;
bool mapping;
......@@ -79,7 +79,7 @@ private:
int mSelectedPlayer;
std::vector<CGUIButton*> mpButtonList;
std::vector<GsButton*> mpButtonList;
std::map<InputCommands, std::string> mCommandName;
bool mapping;
......
......@@ -22,22 +22,22 @@ CBaseMenu( GsRect<float>(0.25f, 0.24f, 0.5f, 0.5f) )
// Create the Menu Dialog and entries
mpMenuDialog->addControl(new CGUIButton( "The Game",
mpMenuDialog->addControl(new GsButton( "The Game",
new StartInfoSceneEvent( new CHelp("Game") ) ) );
mpMenuDialog->addControl(new CGUIButton( "The Story",
mpMenuDialog->addControl(new GsButton( "The Story",
new StartInfoSceneEvent( new CStory ) ) );
mpMenuDialog->addControl(new CGUIButton( "Ordering Info",
mpMenuDialog->addControl(new GsButton( "Ordering Info",
new StartInfoSceneEvent( new COrderingInfo ) ) );
mpMenuDialog->addControl(new CGUIButton( "About ID",
mpMenuDialog->addControl(new GsButton( "About ID",
new StartInfoSceneEvent( new CAbout("ID") ) ) );
mpMenuDialog->addControl(new CGUIButton( "About CG",
mpMenuDialog->addControl(new GsButton( "About CG",
new StartInfoSceneEvent( new CAbout("CG") ) ) );
mpMenuDialog->addControl(new CGUIButton( "Credits",
mpMenuDialog->addControl(new GsButton( "Credits",
new StartInfoSceneEvent( new CCredits() ) ) );
std::string filename = "previews.ck";
......@@ -46,7 +46,7 @@ CBaseMenu( GsRect<float>(0.25f, 0.24f, 0.5f, 0.5f) )
if( filename != "" )
{
mpMenuDialog->addControl(new CGUIButton( "Previews!",
mpMenuDialog->addControl(new GsButton( "Previews!",
new StartInfoSceneEvent( new CPreviews() ) ) );
}
......
......@@ -36,12 +36,12 @@ CBaseMenu( GsRect<float>(0.1f, 0.0f, 0.8f, 1.0f) )
// Load the state-file list
const CGUIControl::Style style =
( g_pBehaviorEngine->getEngine() == ENGINE_GALAXY ) ?
CGUIButton::GALAXY_BORDERED : CGUIButton::VORTICON;
GsButton::GALAXY_BORDERED : GsButton::VORTICON;
std::vector<std::string> StateFileList = gpSaveGameController->getSlotList();
std::vector<std::string>::iterator it = StateFileList.begin();
Uint32 i=1;
CGUIButton *button;
GsButton *button;
std::string text;
for( ; it != StateFileList.end() && i<8 ; i++,it++ )
......@@ -50,7 +50,7 @@ CBaseMenu( GsRect<float>(0.1f, 0.0f, 0.8f, 1.0f) )
if( !text.empty() )
{
button = new CGUIButton( text,
button = new GsButton( text,
new LoadGameSlotFunctorEvent(i),
style );
mpMenuDialog->addControl( button );
......@@ -62,7 +62,7 @@ CBaseMenu( GsRect<float>(0.1f, 0.0f, 0.8f, 1.0f) )
for( int j = i ; j<8 ; j++ )
{
text = "Empty";
button = new CGUIButton( text,
button = new GsButton( text,
new LoadGameSlotFunctorEvent(j),
style );
mpMenuDialog->addControl( button );
......
......@@ -8,7 +8,7 @@
#include "CMainMenu.h"
#include <base/GsApp.h>
#include <widgets/GsMenuController.h>
#include <widgets/GsButton.h>
#include "common/Menu/CSettingsMenu.h"
#include "common/Menu/CSelectionMenu.h"
......@@ -19,8 +19,8 @@
#include "common/CBehaviorEngine.h"
#include "core/mode/CGameMode.h"
//#include "core/CGameLauncherMenu.h"
#include "engine/galaxy/menu/GalaxyButton.h"
void CMainMenu::createVorticonMenu( const bool openedGamePlay )
......@@ -28,10 +28,10 @@ void CMainMenu::createVorticonMenu( const bool openedGamePlay )
#if defined (SINGLEPLAYER)
g_pBehaviorEngine->mPlayers = 1;
CGUIButton *button = new CGUIButton( "New Game",
GsButton *button = new GsButton( "New Game",
new OpenMenuEvent(new CDifficultySelection) );
#else
CGUIButton *button = new CGUIButton( "New Game",
GsButton *button = new GsButton( "New Game",
new OpenMenuEvent( new CPlayersSelection<NewGamePlayersEvent>(true) ) );
#endif
......@@ -40,32 +40,32 @@ void CMainMenu::createVorticonMenu( const bool openedGamePlay )
// TODO: Some items are still disabled, because those are not yet implemented in Galaxy
CGUIButton *loadButton = new CGUIButton( "Load",
GsButton *loadButton = new GsButton( "Load",
new OpenMenuEvent( new CLoadMenu() ) );
mpMenuDialog->addControl( loadButton );
loadButton->mEnabled = true;
CGUIButton *saveButton = new CGUIButton( "Save",
GsButton *saveButton = new GsButton( "Save",
new OpenMenuEvent( new CSaveMenu() ) );
mpMenuDialog->addControl( saveButton );
saveButton->mEnabled = openedGamePlay;
mpMenuDialog->addControl(new CGUIButton( "Configure",
mpMenuDialog->addControl(new GsButton( "Configure",
new OpenMenuEvent( new CSettingsMenu() ) ) );
CGUIButton *highscoreButton = new CGUIButton( "High Scores",
GsButton *highscoreButton = new GsButton( "High Scores",
new StartInfoSceneEvent( new CHighScores ) );
mpMenuDialog->addControl( highscoreButton );
highscoreButton->mEnabled = true;
CGUIButton *infoButton = new CGUIButton( "Info",
GsButton *infoButton = new GsButton( "Info",
new OpenMenuEvent( new CHelpMenu() ) );
mpMenuDialog->addControl( infoButton );
infoButton->mEnabled = true;
mpMenuDialog->addControl(new CGUIButton( "End Game", new EventEndGamePlay() ) );
mpMenuDialog->addControl(new GsButton( "End Game", new EventEndGamePlay() ) );
mpMenuDialog->addControl(new CGUIButton( "Quit", new GMQuit() ) );
mpMenuDialog->addControl(new GsButton( "Quit", new GMQuit() ) );
setMenuLabel("MAINMENULABEL");
......@@ -76,10 +76,10 @@ void CMainMenu::createGalaxyMenu( const bool openedGamePlay )
{
#if defined (SINGLEPLAYER)
g_pBehaviorEngine->mPlayers = 1;
CGUIButton *button = new CGUIButton( "New Game",
GsButton *button = new GalaxyButton( "New Game",
new OpenMenuEvent(new CDifficultySelection) );
#else
CGUIButton *button = new CGUIButton( "New Game",
GsButton *button = new GalaxyButton( "New Game",
new OpenMenuEvent( new CPlayersSelection<NewGamePlayersEvent>(true) ) );
#endif
......@@ -87,32 +87,32 @@ void CMainMenu::createGalaxyMenu( const bool openedGamePlay )
// TODO: Some items are still disabled, because those are not yet implemented in Galaxy
CGUIButton *loadButton = new CGUIButton( "Load",
GsButton *loadButton = new GsButton( "Load",
new OpenMenuEvent( new CLoadMenu() ) );
mpMenuDialog->addControl( loadButton );
loadButton->mEnabled = true;
CGUIButton *saveButton = new CGUIButton( "Save",
GsButton *saveButton = new GsButton( "Save",
new OpenMenuEvent( new CSaveMenu() ) );
mpMenuDialog->addControl( saveButton );
saveButton->mEnabled = openedGamePlay;
mpMenuDialog->addControl(new CGUIButton( "Configure",
mpMenuDialog->addControl(new GsButton( "Configure",
new OpenMenuEvent( new CSettingsMenu() ) ) );
CGUIButton *highscoreButton = new CGUIButton( "High Scores",
GsButton *highscoreButton = new GsButton( "High Scores",
new StartInfoSceneEvent( new CHighScores ) );
mpMenuDialog->addControl( highscoreButton );
highscoreButton->mEnabled = false;
CGUIButton *infoButton = new CGUIButton( "Info",
GsButton *infoButton = new GsButton( "Info",
new OpenMenuEvent( new CHelpMenu() ) );
mpMenuDialog->addControl( infoButton );
infoButton->mEnabled = false;
mpMenuDialog->addControl(new CGUIButton( "End Game", new EventEndGamePlay() ) );
mpMenuDialog->addControl(new GsButton( "End Game", new EventEndGamePlay() ) );
mpMenuDialog->addControl(new CGUIButton( "Quit", new GMQuit() ) );
mpMenuDialog->addControl(new GsButton( "Quit", new GMQuit() ) );
setMenuLabel("MAINMENULABEL");
......
......@@ -7,7 +7,7 @@
#include <widgets/GsBaseMenu.h>
#include "engine/CEvent.h"
#include <base/GsEvent.h>
#ifndef CMAINMENU_H_
#define CMAINMENU_H_
......@@ -21,5 +21,6 @@ public:
void createGalaxyMenu( const bool openedGamePlay );
};
struct OpenMainMenuEvent : public CEvent {};
#endif /* CMAINMENU_H_ */
......@@ -74,10 +74,10 @@ public:
CProfilesMenu::CProfilesMenu() :
CBaseMenu( GsRect<float>(0.25f, 0.4f, 0.5f, 0.2f) )
{
mpMenuDialog->addControl(new CGUIButton( "Classic mode",
mpMenuDialog->addControl(new GsButton( "Classic mode",
new SetDefaultClassic() ) );
mpMenuDialog->addControl(new CGUIButton( "Enhanced mode",
mpMenuDialog->addControl(new GsButton( "Enhanced mode",
new SetDefaultEnhanced() ) );
setMenuLabel("OPTIONSMENULABEL");
......
......@@ -57,14 +57,14 @@ public:
else
playerStr = "Player " + itoa(i);
CGUIButton *button = new CGUIButton( playerStr, new _T(i) );
GsButton *button = new GsButton( playerStr, new _T(i) );
mpButtonList.push_back( button );
mpMenuDialog->addControl( mpButtonList.back() );
}
}
std::list<CGUIButton*> mpButtonList;
std::list<GsButton*> mpButtonList;
};
......@@ -76,12 +76,12 @@ public:
CBaseMenu( GsRect<float>(0.25f, 0.2f, 0.5f, 0.5f) )
{
mpMenuDialog->addControl( new CGUIButton( "Easy", new StartNewGameEvent(EASY) ) );
mpMenuDialog->addControl( new CGUIButton( "Normal", new StartNewGameEvent(NORMAL) ) );
mpMenuDialog->addControl( new CGUIButton( "Hard", new StartNewGameEvent(HARD) ) );
mpMenuDialog->addControl( new CGUIButton( "Expert", new StartNewGameEvent(EXPERT) ) );
mpMenuDialog->addControl( new CGUIButton( "Ninja", new StartNewGameEvent(NINJA) ) );
mpMenuDialog->addControl( new CGUIButton( "Elite", new StartNewGameEvent(ELITE) ) );
mpMenuDialog->addControl( new GsButton( "Easy", new StartNewGameEvent(EASY) ) );
mpMenuDialog->addControl( new GsButton( "Normal", new StartNewGameEvent(NORMAL) ) );
mpMenuDialog->addControl( new GsButton( "Hard", new StartNewGameEvent(HARD) ) );
mpMenuDialog->addControl( new GsButton( "Expert", new StartNewGameEvent(EXPERT) ) );
mpMenuDialog->addControl( new GsButton( "Ninja", new StartNewGameEvent(NINJA) ) );
mpMenuDialog->addControl( new GsButton( "Elite", new StartNewGameEvent(ELITE) ) );
setMenuLabel("NEWGAMELABEL");
}
......
......@@ -26,13 +26,13 @@
CSettingsMenu::CSettingsMenu() :
CBaseMenu( GsRect<float>(0.25f, 0.24f, 0.5f, 0.32f) )
{
mpMenuDialog->addControl(new CGUIButton( "Video",
mpMenuDialog->addControl(new GsButton( "Video",
new OpenMenuEvent( new CVideoSettings() ) ) );
mpMenuDialog->addControl(new CGUIButton( "Audio",
mpMenuDialog->addControl(new GsButton( "Audio",
new OpenMenuEvent( new CAudioSettings() ) ) );
mpMenuDialog->addControl(new CGUIButton( "Options",
mpMenuDialog->addControl(new GsButton( "Options",
new OpenMenuEvent( new COptions() ) ) );
......@@ -46,20 +46,20 @@ CBaseMenu( GsRect<float>(0.25f, 0.24f, 0.5f, 0.32f) )
* */
#if defined (SINGLEPLAYER)
mpMenuDialog->addControl( new CGUIButton( "Controls",
mpMenuDialog->addControl( new GsButton( "Controls",
new OpenMenuEvent( new CControlsettings(1) ) ) );
#else
mpMenuDialog->addControl(new CGUIButton( "Controls",
mpMenuDialog->addControl(new GsButton( "Controls",
new OpenMenuEvent( new CPlayersSelection<OpenControlMenuEvent>() ) ) );
#endif
#if !defined(EMBEDDED)
mpMenuDialog->addControl( new CGUIButton( "Camera",
mpMenuDialog->addControl( new GsButton( "Camera",
new OpenMenuEvent( new CCameraSettings() ) ) );
#endif
mpMenuDialog->addControl(new CGUIButton( "Profile",
mpMenuDialog->addControl(new GsButton( "Profile",
new OpenMenuEvent( new CProfilesMenu() ) ) );
setMenuLabel("CONFIGMENULABEL");
......
......@@ -95,7 +95,7 @@ CBaseMenu(GsRect<float>(0.15f, 0.24f, 0.65f, 0.55f) )
filledStrList(1, "?x?") );
mpMenuDialog->addControl( mpResolutionSelection );
mpFullScreenSwitch = new CGUIButton( "Unknown mode",
mpFullScreenSwitch = new GsButton( "Unknown mode",
new toggleFullscreenFunctor(*this) );
mpMenuDialog->addControl( mpFullScreenSwitch );
#endif
......
......@@ -44,7 +44,7 @@ private:
CGUIComboSelection *mpAspectSelection;
CGUISwitch *mpVSyncSwitch;
CGUISwitch *mpSFXSwitch;
CGUIButton *mpFullScreenSwitch;
GsButton *mpFullScreenSwitch;
CGUIComboSelection *mpResolutionSelection;
CGUIComboSelection *mpGameResSelection;
......
......@@ -29,7 +29,7 @@ m_mustclose(false)
const char closeChar = 0x1F;
std::string closeString;
closeString = closeChar;
CGUIButton* pButton = new CGUIButton( closeString, new CloseDialog(m_mustclose), CGUIButton::NONE );
GsButton* pButton = new GsButton( closeString, new CloseDialog(m_mustclose), GsButton::NONE );
addControl( pButton, GsRect<float>(0.0f, 0.0f, 0.06f/0.8f, 0.06f/0.8f) );
......
......@@ -46,7 +46,7 @@ public:
protected:
bool m_mustclose;
CGUIButton *mpReturnButton;
GsButton *mpReturnButton;
CGUIText *mpTextCtrl;
};
......
......@@ -16,6 +16,8 @@
#include <widgets/GsMenuController.h>
#include <base/CInput.h>
#include "common/Menu/CMainMenu.h"
////
// Creation Routine
////
......@@ -86,7 +88,7 @@ void CTitle::ponder()
{
if( gInput.getPressedAnyCommand() )
{
gMenuController.openMainMenu();
gEventManager.add(new OpenMainMenuEvent());
}
}
......
......@@ -15,7 +15,7 @@
#include "graphics/GsGraphics.h"
#include "graphics/effects/CPixelate.h"
#include "sdl/extensions.h"
//#include "core/CGameLauncherMenu.h"
#include "common/Menu/CMainMenu.h"
namespace galaxy
......@@ -320,7 +320,7 @@ void CPassiveGalaxy::processTitle()
if( gInput.getPressedAnyCommand() )
{
gInput.flushAll();
gMenuController.openMainMenu();
gEventManager.add(new OpenMainMenuEvent);
}
}
}
......
#include <graphics/GsGraphics.h>
#include <base/video/CVideoDriver.h>
#include "GalaxyButton.h"
GalaxyButton::GalaxyButton(const std::string& text,
CEvent *ev,
const bool bordered) :
GsButton(text, ev),
mBordered(bordered)
{
mFontID = 1;
/* if(style == GALAXY_BORDERED)
drawButton = &GsButton::drawGalaxyBorderedStyle;
else
drawButton = &GsButton::drawGalaxyStyle;*/
setupButtonSurface();
}
void GalaxyButton::setupButtonSurface()
{
GsFont &Font = gGraphics.getFont(mFontID);
SDL_PixelFormat *format = gVideoDriver.getBlitSurface()->format;
mTextDarkSfc = Font.fetchColoredTextSfc( " " + mText, SDL_MapRGB( format, 38, 134, 38));
mTextLightSfc = Font.fetchColoredTextSfc( " " + mText, SDL_MapRGB( format, 84, 234, 84));
mTextDisabledSfc = Font.fetchColoredTextSfc( " " + mText, SDL_MapRGB( format, 123, 150, 123));
}
void GalaxyButton::drawGalaxyBorderedStyle(SDL_Rect& lRect)
{
SDL_Surface *blitsfc = gVideoDriver.getBlitSurface();
// Now lets draw the text of the list control
GsFont &Font = gGraphics.getFont(mFontID);
SDL_PixelFormat *format = gVideoDriver.getBlitSurface()->format;
const Uint32 oldcolor = Font.getFGColor();
Uint32 newcolor;
if(!mEnabled)
newcolor = SDL_MapRGB( format, 123, 150, 123);
else if(mHovered || mPressed)
newcolor = SDL_MapRGB( format, 84, 234, 84);
else
newcolor = SDL_MapRGB( format, 38, 134, 38);
Font.setupColor( newcolor );
drawEmptyRect( blitsfc, &lRect, newcolor);
Font.drawFont( blitsfc, mText, lRect.x+24, lRect.y+2, false );
Font.setupColor( oldcolor );
}
void GalaxyButton::drawGalaxyStyle(SDL_Rect& lRect)
{
GsSurface blitsfc( gVideoDriver.getBlitSurface() );
blitsfc.disownSfc();
if(!mEnabled)
{
mTextDisabledSfc.blitTo(blitsfc, lRect);
}
else
{
if(mHovered)
{
mTextLightSfc.blitTo(blitsfc, lRect);
}
else // Button is not hovered
{
mTextDarkSfc.blitTo(blitsfc, lRect);
}
}
drawBlinker(lRect);
}
void GalaxyButton::processRender(const GsRect<float> &RectDispCoordFloat)
{
// Transform to the display coordinates
GsRect<float> displayRect = mRect;
displayRect.transform(RectDispCoordFloat);
SDL_Rect lRect = displayRect.SDLRect();
drawGalaxyStyle(lRect);
}
#ifndef __GALAXYBUTTON_H__
#define __GALAXYBUTTON_H__
#include <widgets/GsButton.h>
class GalaxyButton : public GsButton
{
public:
GalaxyButton(const std::string& text,
CEvent *ev,
const bool bordered = false);
void processRender(const GsRect<float> &RectDispCoordFloat);
private:
void setupButtonSurface();
void drawGalaxyStyle(SDL_Rect& lRect);
void drawGalaxyBorderedStyle(SDL_Rect& lRect);
const bool mBordered;
};
#endif /* __GALAXYBUTTON_H__ */
......@@ -8,6 +8,47 @@
#include "fileio/ResourceMgmt.h"
#include "fileio/CSaveGameController.h"
#include "sdl/music/CMusic.h"
#include "common/Menu/CMainMenu.h"
void KeenEngine::openMainMenu()
{
if(gMenuController.isLocked())
return;
gEventManager.add( new OpenMenuEvent( new CMainMenu(mOpenedGamePlay) ) );
g_pBehaviorEngine->setPause(true);
g_pMusicPlayer->pause();
/*
// Control Menu Events
if( const OpenMovementControlMenuEvent* ctrlMenu = dynamic_cast<const OpenMovementControlMenuEvent*>(evPtr) )
{
const int players = ctrlMenu->mSelection;
EventContainer.add( new OpenMenuEvent(
new CControlSettingsMovement(players) ) );
}
if( const OpenButtonsControlMenuEvent* ctrlMenu = dynamic_cast<const OpenButtonsControlMenuEvent*>(evPtr) )
{
const int players = ctrlMenu->mSelection;
EventContainer.add( new OpenMenuEvent(
new CControlSettingsButtons(players) ) );
}
if( const OpenControlMenuEvent* ctrlMenu = dynamic_cast<const OpenControlMenuEvent*>(evPtr) )
{
const int players = ctrlMenu->mSelection;
EventContainer.add( new OpenMenuEvent(
new CControlsettings(players) ) );
}*/
// When menu is opened show the cursor
SDL_ShowCursor(SDL_ENABLE);
}
void KeenEngine::start()
{
......@@ -59,6 +100,30 @@ void KeenEngine::pumpEvent(const CEvent *evPtr)
DataDirectory,
m_start_level) );*/
}
else if( dynamic_cast<const OpenMainMenuEvent*>(evPtr) )
{
openMainMenu();
}
}
void KeenEngine::ponder(const float deltaT)
{
GameEngine::ponder(deltaT);
CEventContainer &EventContainer = gEventManager;
// Did the player press the quit/back button
if( gInput.getPressedCommand(IC_BACK) )
{
if( gMenuController.empty() ) // If no menu is open, open the main menu
{
openMainMenu();
}
else // Close the menu which is open. Might go back if it is a submenu
{
EventContainer.add( new CloseMenuEvent() );
}
}
}
......
......@@ -11,16 +11,22 @@ public:
const int ep,
const std::string &dataPath) :
GameEngine(openedGamePlay, dataPath),
mEp(ep) {}
mEp(ep),
mLockedMenu(true) {}
void openMainMenu();
void start();
virtual void pumpEvent(const CEvent *evPtr);