Commit 22ade2ee authored by Gerstrong's avatar Gerstrong

Now the Status Screen in Keen 4 completely works. Only scroll-effect is missing

parent f7ca4029
......@@ -43,6 +43,15 @@ void CMap::setLevel(Uint16 Level)
Uint16 CMap::getLevel()
{ return m_Level; }
void CMap::setLevelName( const std::string& name )
{
m_LevelName = name;
}
std::string CMap::getLevelName()
{ return m_LevelName; }
/**
* \brief Create an empty data plane used for the map data
* \param blocksize size in bytes of the datablock that has to be created
......
......@@ -34,6 +34,9 @@ public:
void setLevel(Uint16 Level);
Uint16 getLevel();
void setLevelName( const std::string& name );
std::string getLevelName();
bool createEmptyDataPlane(size_t plane, Uint32 width, Uint32 height);
bool gotoPos( int x, int y );
......@@ -113,6 +116,7 @@ private:
CPlane m_Plane[3];
bool m_Background; // This variable holds, whether we have a background to draw or not.
Uint16 m_Level;
std::string m_LevelName;
};
#endif /* CMAP_H_ */
......@@ -12,22 +12,22 @@
//#include "CStatusScreenGalaxyEp6.h"
CInventory::CInventory(Uint8& difficulty) :
CInventory::CInventory(Uint8& difficulty, const std::string& levelname) :
Item(difficulty),
m_HUD(Item.m_points, Item.m_lifes, Item.m_bullets),
mp_StatusScreen(NULL)
mp_StatusScreen(NULL),
m_LevelName(levelname)
{
reset();
int Episode = g_pBehaviorEngine->getEpisode();
if(Episode == 4)
mp_StatusScreen = new CStatusScreenGalaxyEp4(Item);
mp_StatusScreen = new CStatusScreenGalaxyEp4(Item, m_LevelName);
// else if(Episode == 5)
// mp_StatusScreen = new CStatusScreenGalaxyEp5(Item);
// mp_StatusScreen = new CStatusScreenGalaxyEp5(Item, m_LevelName);
// else if(Episode == 6)
// mp_StatusScreen = new CStatusScreenGalaxyEp6(Item);
mp_StatusScreen->GenerateStatus();
// mp_StatusScreen = new CStatusScreenGalaxyEp6(Item, m_LevelName);
}
void CInventory::reset()
......
......@@ -16,10 +16,11 @@
#include "ItemsGalaxy.h"
#include "CStatusScreenGalaxy.h"
#include "SmartPointer.h"
#include <string>
class CInventory {
public:
CInventory(Uint8& difficulty);
CInventory(Uint8& difficulty, const std::string& levelname);
void reset();
// This function draws the HUD on the Screen
......@@ -39,6 +40,7 @@ public:
CHUD m_HUD;
SmartPointer<CStatusScreenGalaxy> mp_StatusScreen;
const std::string &m_LevelName;
};
......
......@@ -47,6 +47,15 @@ bool CLevelPlay::loadLevel(const Uint16 level)
return true;
}
/**
* return the name of the opened level
*/
std::string CLevelPlay::getLevelName()
{
return m_Map.getLevelName();
}
void CLevelPlay::process()
{
// Animate the tiles of the map
......
......@@ -26,6 +26,7 @@ public:
bool loadLevel(const Uint16 level);
std::string getLevelName();
void process();
private:
......
......@@ -210,6 +210,7 @@ bool CMapLoaderGalaxy::loadMap(CMap &Map, Uint8 level)
// Get and check the signature
g_pLogFile->textOut("Loading the Level \"" + static_cast<std::string>(name) + "\"<br>" );
Map.setLevelName(name);
// Then decompress the level data using rlew and carmack
g_pLogFile->textOut("Decompressing the Map...<br>" );
......
......@@ -21,7 +21,7 @@ CPlayGameGalaxy::CPlayGameGalaxy(CExeFile &ExeFile, char level,
char numplayers, Uint8& difficulty,
CSavedGame &SavedGame) :
CPlayGame(ExeFile, level, numplayers, difficulty ),
m_Inventory(difficulty),
m_Inventory(difficulty, m_LevelName),
m_WorldMap(ExeFile, m_Inventory),
m_LevelPlay(ExeFile, m_Inventory),
mp_Menu(NULL),
......@@ -40,6 +40,7 @@ bool CPlayGameGalaxy::init()
{
m_WorldMap.setActive(true);
m_WorldMap.loadAndPlayMusic();
m_LevelName = m_WorldMap.getLevelName();
return false;
}
else
......@@ -47,6 +48,7 @@ bool CPlayGameGalaxy::init()
// manually a level has been loaded
m_LevelPlay.loadLevel(m_Level);
m_LevelPlay.setActive(true);
m_LevelName = m_LevelPlay.getLevelName();
return true;
}
}
......@@ -78,6 +80,19 @@ void CPlayGameGalaxy::process()
{
processInput();
// Trigger the Status screen here
if(m_Inventory.showStatus())
{
if(g_pInput->getPressedAnyCommand())
m_Inventory.toggleStatusScreen();
}
else
{
if(g_pInput->getPressedCommand(IC_STATUS))
m_Inventory.toggleStatusScreen();
}
if(g_pInput->getPressedCommand(IC_STATUS))
{
m_Inventory.toggleStatusScreen();
......@@ -118,6 +133,7 @@ void CPlayGameGalaxy::process()
g_pMusicPlayer->stop();
m_WorldMap.setActive(false);
m_LevelPlay.loadLevel(ev->data - 0xC000);
m_LevelName = m_LevelPlay.getLevelName();
m_LevelPlay.setActive(true);
}
EventContainer.pop_Event();
......@@ -127,6 +143,7 @@ void CPlayGameGalaxy::process()
g_pMusicPlayer->stop();
m_LevelPlay.setActive(false);
m_WorldMap.setActive(true);
m_LevelName = m_WorldMap.getLevelName();
m_WorldMap.loadAndPlayMusic();
}
......
......@@ -15,6 +15,7 @@
#include "CLevelPlay.h"
#include "CMenuGalaxy.h"
#include <vector>
#include <string>
namespace galaxy
{
......@@ -39,6 +40,7 @@ public:
virtual ~CPlayGameGalaxy();
private:
std::string m_LevelName;
CInventory m_Inventory;
CWorldMap m_WorldMap;
CLevelPlay m_LevelPlay;
......
......@@ -11,10 +11,11 @@
#include "sdl/video/colourconvert.h"
#include "common/CBehaviorEngine.h"
CStatusScreenGalaxy::CStatusScreenGalaxy(const stItemGalaxy& Item) :
CStatusScreenGalaxy::CStatusScreenGalaxy(const stItemGalaxy& Item, const std::string &LevelName) :
m_showstatus(false),
mp_StatusSurface(NULL),
m_Item(Item)
m_Item(Item),
m_LevelName(LevelName)
{}
void CStatusScreenGalaxy::drawBase(SDL_Rect &EditRect)
......
......@@ -12,11 +12,11 @@
#include <SDL.h>
#include "ItemsGalaxy.h"
#include <string>
class CStatusScreenGalaxy {
public:
CStatusScreenGalaxy(const stItemGalaxy& Item);
CStatusScreenGalaxy(const stItemGalaxy& Item, const std::string &LevelName);
~CStatusScreenGalaxy();
// This will generate the status screen. It must be derived by other classes, depending on the Episode
......@@ -32,6 +32,7 @@ public:
bool m_showstatus;
SDL_Surface *mp_StatusSurface;
const stItemGalaxy& m_Item;
const std::string &m_LevelName;
};
......
......@@ -10,8 +10,8 @@
#include "common/CBehaviorEngine.h"
#include "StringUtils.h"
CStatusScreenGalaxyEp4::CStatusScreenGalaxyEp4(const stItemGalaxy& Item) :
CStatusScreenGalaxy(Item)
CStatusScreenGalaxyEp4::CStatusScreenGalaxyEp4(const stItemGalaxy& Item, const std::string &LevelName) :
CStatusScreenGalaxy(Item, LevelName)
{}
......@@ -37,7 +37,13 @@ void CStatusScreenGalaxyEp4::GenerateStatus()
TempRect.w = EditRect.w;
TempRect.h = 20;
Font.setBGColour(pixelformat, 0xFFFFFF);
Font.setFGColour(pixelformat, 0x0);
SDL_FillRect(mp_StatusSurface, &TempRect, 0xFFFFFFFF);
Font.drawFontCentered(mp_StatusSurface, m_LevelName, TempRect.x, TempRect.w, TempRect.y+6, false);
Font.setBGColour(pixelformat, 0xAAAAAA);
Font.setFGColour(pixelformat, 0x555555);
/// SCORE and EXTRA Rect
TempRect.x = EditRect.x;
......@@ -83,7 +89,7 @@ void CStatusScreenGalaxyEp4::GenerateStatus()
difftext = "Hard";
else
difftext = "???";
Font.drawFontCentered(mp_StatusSurface, difftext, TempRect.x+4, TempRect.w, TempRect.y+1, false);
Font.drawFontCentered(mp_StatusSurface, difftext, TempRect.x, TempRect.w, TempRect.y+1, false);
Font.setBGColour(pixelformat, 0xAAAAAA);
Font.setFGColour(pixelformat, 0x555555);
......
......@@ -14,7 +14,7 @@
class CStatusScreenGalaxyEp4 : public CStatusScreenGalaxy {
public:
CStatusScreenGalaxyEp4(const stItemGalaxy& Item);
CStatusScreenGalaxyEp4(const stItemGalaxy& Item, const std::string &LevelName);
void GenerateStatus();
};
......
......@@ -46,6 +46,14 @@ void CWorldMap::init()
m_Map.drawAll();
}
/**
* return the name of the opened level
*/
std::string CWorldMap::getLevelName()
{
return m_Map.getLevelName();
}
/**
* The map is not loaded again after the game started. But we have to reload its song.
*/
......
......@@ -25,6 +25,7 @@ public:
void setActive(bool value);
void init();
std::string getLevelName();
void loadAndPlayMusic();
void process();
......
......@@ -233,7 +233,13 @@ void CFont::drawFontCentered(SDL_Surface* dst, const std::string& text, Uint16 w
void CFont::drawFontCentered(SDL_Surface* dst, const std::string& text, Uint16 x, Uint16 width, Uint16 yoff, bool highlight)
{
const Uint16 xmidpos = (width-(text.size()*8))/2+x;
Uint16 xmidpos = 0;
for( unsigned int i=0 ; i<text.size() ; i++)
xmidpos += m_widthtable[text[i]];
xmidpos = (width-xmidpos)/2+x;
drawFont(dst, text, xmidpos, yoff, highlight);
}
......
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