CLevelPlay.cpp 1.71 KB
Newer Older
1 2 3 4 5 6 7 8
/*
 * CLevelPlay.cpp
 *
 *  Created on: 06.08.2010
 *      Author: gerstrong
 */

#include "CLevelPlay.h"
9
#include "ep4/CMapLoaderGalaxyEp4.h"
Gerhard Stein's avatar
Gerhard Stein committed
10
#include "ep5/CMapLoaderGalaxyEp5.h"
11
#include "sdl/input/CInput.h"
12
#include "sdl/CVideoDriver.h"
13
#include "sdl/music/CMusic.h"
14
#include "dialog/CMessageBoxBitmapGalaxy.h"
15
#include "CLogFile.h"
16

17 18
#include "CMapPlayGalaxy.h"

19 20
namespace galaxy {

21
CLevelPlay::CLevelPlay(CExeFile &ExeFile,
Gerstrong's avatar
Gerstrong committed
22 23 24
		CInventory &Inventory,
		stCheat &Cheatmode) :
CMapPlayGalaxy(ExeFile, Inventory, Cheatmode)
25 26 27
{ }


28
void CLevelPlay::loadMap(const int level)
29 30
{
	// Load the World map level.
31
	SmartPointer<CMapLoaderGalaxy> MapLoader;
32

33 34
	if(g_pBehaviorEngine->getEpisode() == 4)
		MapLoader = new CMapLoaderGalaxyEp4(mExeFile, mObjectPtr, mInventory, mCheatmode);
Gerhard Stein's avatar
Gerhard Stein committed
35 36
	else if(g_pBehaviorEngine->getEpisode() == 5)
		MapLoader = new CMapLoaderGalaxyEp5(mExeFile, mObjectPtr, mInventory, mCheatmode);
37 38

	MapLoader->loadMap( mMap, level );
39

40 41 42
    // Load the Background Music
	g_pMusicPlayer->stop();

Gerhard Stein's avatar
Gerhard Stein committed
43
    if( !g_pMusicPlayer->load(mExeFile, level) )
44 45 46
    	g_pLogFile->textOut("Warning: The music cannot be played. Check that all the files have been correctly copied!");
    else
    	g_pMusicPlayer->play();
47 48 49 50 51
}


void CLevelPlay::reloadLevel()
{
Gerhard Stein's avatar
Gerhard Stein committed
52
	loadMap( mMap.getLevel() );
53 54 55 56 57
}

bool CLevelPlay::loadLevel(const Uint16 level)
{
	loadMap( level );
58

59
    // Add the load message
60 61
    const std::string level_text = "LEVEL" + itoa(level) + "_LOAD_TEXT";
    const std::string loading_text = g_pBehaviorEngine->getString(level_text);
Gerstrong's avatar
Gerstrong committed
62 63

	CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
Gerhard Stein's avatar
Gerhard Stein committed
64

65
	EventContainer.add( new EventSendBitmapDialogMsg(*g_pGfxEngine->getBitmap("KEENTHUMBSUP"), loading_text, LEFT) );
66

Gerhard Stein's avatar
Gerhard Stein committed
67
	mMap.drawAll();
68 69 70 71
	return true;
}

}