Commit 40661ab5 authored by Gerhard Stein's avatar Gerhard Stein

SINGLEPLAYER will force builds to use only one playero

parent 52bcf76e
......@@ -19,6 +19,7 @@
#include <vector>
#include <string>
#include <map>
#include "hardware/Configurator.h"
#include "fileio/CExeFile.h"
#include "CTileProperties.h"
#include "CPhysicsSettings.h"
......@@ -28,7 +29,11 @@
#include "CSingleton.h"
#define MAX_PLAYERS 4
#if defined (SINGLEPLAYER)
const unsigned int MAX_PLAYERS = 1;
#else
const unsigned int MAX_PLAYERS = 4;
#endif
#define g_pBehaviorEngine CBehaviorEngine::Get()
......
......@@ -56,7 +56,6 @@ protected:
SmartPointer<CGUIDialog> mpMenuDialog;
CGUIButton *mpReturnButton;
std::list< SmartPointer<CEvent> > mEventList;
};
#endif /* CBASEMENU_H_ */
......@@ -21,8 +21,17 @@
void CMainMenu::createVorticonMenu( const bool openedGamePlay )
{
#if defined (EMBEDDED)
g_pBehaviorEngine->mPlayers = 1;
CGUIButton *button = new CGUIButton( "New Game",
new OpenMenuEvent(new CDifficultySelection) );
#else
CGUIButton *button = new CGUIButton( "New Game",
new OpenMenuEvent( new CPlayersSelection<NewGamePlayersEvent>(true) ) );
#endif
mpMenuDialog->addControl( button );
......@@ -62,8 +71,10 @@ void CMainMenu::createVorticonMenu( const bool openedGamePlay )
void CMainMenu::createGalaxyMenu( const bool openedGamePlay )
{
g_pBehaviorEngine->mPlayers = 1;
CGUIButton *button = new CGUIButton( "New Game",
new OpenMenuEvent( new CPlayersSelection<NewGamePlayersEvent>(true) ) );
new OpenMenuEvent(new CDifficultySelection) );
mpMenuDialog->addControl( button );
......
......@@ -11,6 +11,7 @@
#ifndef CSELECTIONMENU_H_
#define CSELECTIONMENU_H_
#include "hardware/Configurator.h"
#include "common/CBehaviorEngine.h"
#include "CBaseMenu.h"
#include "StringUtils.h"
......@@ -48,19 +49,23 @@ public:
CPlayersSelection(bool numFirst = false) :
CBaseMenu( CRect<float>(0.25f, 0.35f, 0.5f, 0.3f) )
{
std::string playerStr;
for( int i = 1 ; i <= MAX_PLAYERS ; i++ )
{
if(numFirst)
playerStr = itoa(i) + " Player";
else
playerStr = "Player " + itoa(i);
mpButtonList.push_back( new CGUIButton( playerStr,
new _T(i) ) );
mpMenuDialog->addControl( mpButtonList.back() );
}
std::string playerStr;
for( int i = 1 ; i <= MAX_PLAYERS ; i++ )
{
if(numFirst)
playerStr = itoa(i) + " Player";
else
playerStr = "Player " + itoa(i);
CGUIButton *button = new CGUIButton( playerStr, new _T(i) );
#if defined (SINGLEPLAYER)
button->setAutoActivation();
#endif
mpButtonList.push_back( button );
mpMenuDialog->addControl( mpButtonList.back() );
}
}
std::list<CGUIButton*> mpButtonList;
......
......@@ -21,7 +21,8 @@ CGUIButton::CGUIButton( const std::string& text,
const Style style ) :
mText(text),
mEvent(ev),
drawButton(&CGUIButton::drawNoStyle)
drawButton(&CGUIButton::drawNoStyle),
mAutoActivation(false)
{
mMapping[UNSET] = g_pBehaviorEngine->getEngine();
mMapping[NONE] = ENGINE_LAUNCHER;
......@@ -84,6 +85,11 @@ void CGUIButton::sendEvent(const InputCommands command)
void CGUIButton::processLogic()
{
if(mAutoActivation)
{
g_pBehaviorEngine->m_EventList.add(mEvent);
}
// Here we check if the mouse-cursor/Touch entry clicked on our Button
if( MouseMoveEvent *mouseevent = g_pInput->m_EventList.occurredEvent<MouseMoveEvent>() )
......@@ -103,6 +109,7 @@ void CGUIButton::processLogic()
return;
}
if(!mEnabled)
return;
......
......@@ -48,6 +48,9 @@ public:
std::string getText()
{ return mText; }
void setAutoActivation()
{ mAutoActivation = true; }
private:
void setupButtonSurface();
......@@ -60,6 +63,9 @@ private:
std::map< Style, EngineType > mMapping;
void (CGUIButton::*drawButton)(SDL_Rect&);
// Auto activation means that as soon it's enabled and process the event will be triggered immediately
bool mAutoActivation;
};
#endif /* CGUIBUTTON_H_ */
......@@ -12,6 +12,7 @@
#ifndef CONFIGURATOR_H_
#define CONFIGURATOR_H_
#define EMBEDDED
#if defined(ANDROID)
#define EMBEDDED
......
......@@ -175,14 +175,10 @@ bool CIMFPlayer::unpackAudioAt( const CExeFile& ExeFile,
if( audio_start < audio_end )
{
/*#if defined(ANDROID)
assert( AudioCompFileData + audio_start % 4 == 0 ); // Make sure the pointer is aligned, or we'll get segfault on Android
#endif*/
const uint32_t audio_comp_data_start = audio_start+sizeof(uint32_t);
//const uint32_t *AudioCompFileData32 = (uint32_t*) (void*) (AudioCompFileData + audio_start);
const uint32_t *AudioCompFileData32 = reinterpret_cast<uint32_t*>(AudioCompFileData + audio_start);
const uint32_t emb_file_data_size = *AudioCompFileData32;
uint32_t emb_file_data_size;
memcpy( &emb_file_data_size, AudioCompFileData + audio_start, sizeof(uint32_t) );
byte imf_data[emb_file_data_size];
byte *imf_data_ptr = imf_data;
......
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