Commit 19b01736 authored by Gerhard Stein's avatar Gerhard Stein

More improvements for saved games. Now it's getting worth :-)

parent cc515196
......@@ -22,7 +22,7 @@ mpMenuDialog( new CGUIDialog(rect) )
{
CRect<float> rect(0.30f, 0.28f, 0.5f, 0.5f);
mpMenuDialog->setRect(rect);
closeString = "<<";
closeString = "x";
pButton = new CGUIButton( closeString, new CloseMenuEvent(), CGUIButton::GALAXY );
mpMenuDialog->addControl( pButton, CRect<float>(-0.1f, 0.1f, 0.03f/rect.w, 0.03f/rect.h) );
}
......
......@@ -39,19 +39,31 @@ CBaseMenu( CRect<float>(0.1f, 0.0f, 0.8f, 1.0f) )
CGUIButton *button;
std::string text;
for( ; it != StateFileList.end() ; i++,it++ )
for( ; it != StateFileList.end() && i<8 ; i++,it++ )
{
text = *it;
if( !text.empty() )
{
button = new CGUIButton( text,
new LoadGameSlotFunctorEvent(i) );
new LoadGameSlotFunctorEvent(i),
CGUIButton::GALAXY_BORDERED );
mpMenuDialog->addControl( button );
button->enable( true );
}
}
for( int j = i ; j<8 ; j++ )
{
text = "Empty";
button = new CGUIButton( text,
new LoadGameSlotFunctorEvent(j),
CGUIButton::GALAXY_BORDERED );
mpMenuDialog->addControl( button );
button->enable( false );
}
setMenuLabel("LOADMENULABEL");
}
......@@ -24,7 +24,7 @@ m_overwrite(false)
for(Uint32 i=1;i<=8;i++)
{
std::string text = "Slot " + itoa(i);
std::string text = "EMPTY";
if(i <= StateFileList.size())
text = StateFileList.at(i-1);
......
......@@ -277,6 +277,8 @@ bool CMapPlayGalaxy::operator<<(CSaveGameController &savedGame)
savedGame.readDataBlock( reinterpret_cast<byte*>(mMap.getBackgroundData()) );
savedGame.readDataBlock( reinterpret_cast<byte*>(mMap.getForegroundData()) );
if( mMap.m_width * mMap.m_height > 0 )
mMap.drawAll();
return true;
}
......@@ -266,12 +266,15 @@ void CPlayGameGalaxy::process()
if(ev->data > 0xC000)
{
const Uint16 NewLevel = ev->data - 0xC000;
g_pMusicPlayer->stop();
m_WorldMap.setActive(false);
m_LevelPlay.loadLevel(NewLevel);
m_LevelName = m_LevelPlay.getLevelName();
g_pSound->playSound( SOUND_ENTER_LEVEL );
m_LevelPlay.setActive(true);
if(NewLevel < 50)
{
g_pMusicPlayer->stop();
m_WorldMap.setActive(false);
m_LevelPlay.loadLevel(NewLevel);
m_LevelName = m_LevelPlay.getLevelName();
g_pSound->playSound( SOUND_ENTER_LEVEL );
m_LevelPlay.setActive(true);
}
}
eventContainer.pop_Event();
}
......
......@@ -12,6 +12,7 @@
#include "sdl/CVideoDriver.h"
#include "core/mode/CGameMode.h"
#include "sdl/CTimer.h"
#include "sdl/extensions.h"
#include "StringUtils.h"
......@@ -28,7 +29,7 @@ mAutoActivation(false)
mMapping[NONE] = ENGINE_LAUNCHER;
mMapping[VORTICON] = ENGINE_VORTICON;
mMapping[GALAXY] = ENGINE_GALAXY;
mMapping[GALAXY_BORDERED] = ENGINE_GALAXY;
switch( mMapping[style] )
{
......@@ -43,7 +44,10 @@ mAutoActivation(false)
case ENGINE_GALAXY:
{
mFontID = 1;
drawButton = &CGUIButton::drawGalaxyStyle;
if(style == GALAXY_BORDERED)
drawButton = &CGUIButton::drawGalaxyBorderedStyle;
else
drawButton = &CGUIButton::drawGalaxyStyle;
setupButtonSurface();
break;
}
......@@ -160,6 +164,37 @@ void CGUIButton::drawVorticonStyle(SDL_Rect& lRect)
}
void CGUIButton::drawGalaxyBorderedStyle(SDL_Rect& lRect)
{
SDL_Surface *blitsfc = g_pVideoDriver->getBlitSurface();
// Now lets draw the text of the list control
CFont &Font = g_pGfxEngine->getFont(mFontID);
SDL_PixelFormat *format = g_pVideoDriver->getBlitSurface()->format;
const Uint32 oldcolor = Font.getFGColor();
Uint32 newcolor;
if(!mEnabled)
newcolor = SDL_MapRGB( format, 123, 150, 123);
else if(mHovered || mButtonDown)
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 CGUIButton::drawGalaxyStyle(SDL_Rect& lRect)
{
SDL_Surface *blitsfc = g_pVideoDriver->getBlitSurface();
......
......@@ -34,6 +34,8 @@ public:
void drawVorticonStyle(SDL_Rect& lRect);
void drawGalaxyBorderedStyle(SDL_Rect& lRect);
void drawGalaxyStyle(SDL_Rect& lRect);
......
......@@ -21,7 +21,8 @@ public:
UNSET,
NONE,
VORTICON,
GALAXY
GALAXY,
GALAXY_BORDERED
};
......
......@@ -13,6 +13,7 @@
#include "common/CBehaviorEngine.h"
#include "core/mode/CGameMode.h"
#include "sdl/CTimer.h"
#include "sdl/extensions.h"
const int MAX_TICK = 8; // Units in a logical loop
......@@ -35,7 +36,7 @@ drawButton(&CGUIInputText::drawNoStyle)
else if(g_pBehaviorEngine->getEngine() == ENGINE_GALAXY)
{
mFontID = 1;
drawButton = &CGUIInputText::drawVorticonStyle;
drawButton = &CGUIInputText::drawGalaxyStyle;
}
}
......@@ -116,6 +117,38 @@ void CGUIInputText::processLogic()
}
void CGUIInputText::drawGalaxyStyle(SDL_Rect& lRect)
{
if(!mEnabled)
return;
SDL_Surface *blitsfc = g_pVideoDriver->getBlitSurface();
// Now lets draw the text of the list control
CFont &Font = g_pGfxEngine->getFont(mFontID);
SDL_PixelFormat *format = g_pVideoDriver->getBlitSurface()->format;
const Uint32 oldcolor = Font.getFGColor();
Uint32 newcolor;
if(mHovered || mButtonDown)
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, getInputString(), lRect.x+24, lRect.y+2, false );
Font.setupColor( oldcolor );
}
void CGUIInputText::drawVorticonStyle(SDL_Rect& lRect)
{
......@@ -131,11 +164,8 @@ void CGUIInputText::drawVorticonStyle(SDL_Rect& lRect)
Font.drawFont( blitsfc, getInputString(), lRect.x+24, lRect.y, false );
drawTwirl(lRect);
}
void CGUIInputText::drawNoStyle(SDL_Rect& lRect)
{
if(!mEnabled)
......
......@@ -28,6 +28,8 @@ public:
void drawVorticonStyle(SDL_Rect& lRect);
void drawGalaxyStyle(SDL_Rect& lRect);
void processRender(const CRect<float> &RectDispCoordFloat);
......@@ -53,6 +55,8 @@ private:
int mTypeTick;
bool mTick;
SmartPointer<SDL_Surface> mpTextSfc;
void (CGUIInputText::*drawButton)(SDL_Rect&);
};
......
......@@ -49,6 +49,29 @@ Uint32 getPixel(SDL_Surface *surface, int x, int y)
}
void drawEmptyRect(SDL_Surface *sfc, SDL_Rect *pRect, Uint32 color)
{
SDL_Rect tempRect = *pRect;
tempRect.h = 1;
SDL_FillRect(sfc, &tempRect, color);
tempRect.y = pRect->y + pRect->h - 1;
SDL_FillRect(sfc, &tempRect, color);
tempRect.w = 1;
tempRect.h = pRect->h;
tempRect.y = pRect->y;
SDL_FillRect(sfc, &tempRect, color);
tempRect.x = pRect->x + pRect->w - 1;
SDL_FillRect(sfc, &tempRect, color);
}
inline Colormask getColourMask32bit()
......
......@@ -22,5 +22,7 @@ inline Colormask getColourMask32bit();
SDL_Surface *CG_CreateRGBSurface( const SDL_Rect rect );
void drawEmptyRect(SDL_Surface *sfc, SDL_Rect *pRect, Uint32 color);
#endif /* SDL_EXTENSIONS_H_ */
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