Commit 2ea47021 authored by Gerhard Stein's avatar Gerhard Stein

Statusscreen fixes with the use of GsSurface

parent eecac10f
Subproject commit 72ddd7f220e5e11abf8c5a845ac6deb0b636056d
Subproject commit d958c0a0b6b29002c7c2963145ee8a20d129b91b
......@@ -31,7 +31,7 @@ void CHUD::createHUDBlit()
{
mHUDBlit.createRGBSurface(mRenderRect);
mHUDBlit.setAlpha(220);
mHUDBlit.makeBlitCompatible();
mHUDBlit.makeBlitCompatible();
}
void CHUD::setup(const int id)
......@@ -196,18 +196,18 @@ void CHUD::renderGalaxy()
charges = (mOldCharges<99) ? mOldCharges : 99;
// Draw the HUD with all the digits
auto blitsfc = mHUDBlit.getSDLSurface();
auto hudBlitsfc = mHUDBlit.getSDLSurface();
const int w = mHUDBox.getWidth();
const int h = mHUDBox.getHeight();
mHUDBox.drawSprite( blitsfc, -4, 0, w, h);
mHUDBox.drawSprite( hudBlitsfc, -4, 0, w, h);
if(lives >= 0)
{
gGraphics.drawDigits(getRightAlignedString(itoa(score),9), 4, 4, blitsfc );
gGraphics.drawDigits(getRightAlignedString(itoa(charges),2),60, 20, blitsfc );
gGraphics.drawDigits(getRightAlignedString(itoa(lives),2), 20, 20, blitsfc );
gGraphics.drawDigits(getRightAlignedString(itoa(score),9), 4, 4, hudBlitsfc );
gGraphics.drawDigits(getRightAlignedString(itoa(charges),2),60, 20, hudBlitsfc );
gGraphics.drawDigits(getRightAlignedString(itoa(lives),2), 20, 20, hudBlitsfc );
if(gBehaviorEngine.mPlayers > 1 && mId == CCamera::getLead())
{
......@@ -215,7 +215,7 @@ void CHUD::renderGalaxy()
rect.x = 7; rect.y = 29;
rect.h = 1; rect.w = 10;
SDL_FillRect(blitsfc, &rect, 0xffff0000);
SDL_FillRect(hudBlitsfc, &rect, 0xffff0000);
}
}
......
......@@ -81,15 +81,19 @@ void CInventory::toggleStatusScreen()
mp_StatusScreen->scaleToResolution();
gVideoDriver.collectSurfaces();
mp_StatusBgrnd = gVideoDriver.convertThroughBlitSfc(gVideoDriver.mpVideoEngine->getBlitSurface());
CScrollEffect* ScrollEffect = dynamic_cast<CScrollEffect*>(gEffectController.Effect());
if( ScrollEffect )
{
scroll_pos = ScrollEffect->getScrollPosition();
}
gEffectController.setupEffect(
new CScrollEffect(mp_StatusScreen->getStatusSfc(), scroll_pos, scaleFac*scaleFac, CENTER, DOWN));
new CScrollEffect(mp_StatusScreen->mStatusSfcTransformed,
scroll_pos,
scaleFac*scaleFac,
CENTER, DOWN));
}
else
{
......@@ -99,17 +103,15 @@ void CInventory::toggleStatusScreen()
// Check if it's already scrolling and get the position
if( ScrollEffect )
{
scroll_pos = ScrollEffect->getScrollPosition();
}
gEffectController.setupEffect(
new CScrollEffect(mp_StatusScreen->getStatusSfc(), scroll_pos, -scaleFac*scaleFac, CENTER, DOWN));
if(mp_StatusBgrnd)
{
SDL_FreeSurface(mp_StatusBgrnd);
}
new CScrollEffect(mp_StatusScreen->mStatusSfcTransformed,
scroll_pos, -scaleFac*scaleFac,
CENTER, DOWN));
mp_StatusBgrnd = nullptr;
}
gInput.flushAll();
......
......@@ -61,7 +61,6 @@ public:
CHUD m_HUD;
std::shared_ptr<CStatusScreenGalaxy> mp_StatusScreen;
SDL_Surface *mp_StatusBgrnd = nullptr;
};
......
......@@ -46,11 +46,12 @@ std::string CStatusScreenGalaxy::getDifficultyText()
void CStatusScreenGalaxy::drawBase(SDL_Rect &EditRect)
{
SDL_Rect DestRect;
DestRect.w = 320; DestRect.h = 200;
SDL_Rect DestRect = {0, 0, 320, 200};
mStatusSurface.createRGBSurface(DestRect);
mStatusSurface.makeBlitCompatible();
/// Draw the required bitmaps and backgrounds for Statusscreen
// Draw the support Bitmap and see where the gray rectangle starts...
// Prepare the drawrect for positions
......@@ -73,7 +74,7 @@ void CStatusScreenGalaxy::drawBase(SDL_Rect &EditRect)
BackRect.x = (DestRect.w-BackRect.w)/2;
BackRect.y = SupportRect.h;
mStatusSurface.fillRGBA(BackRect, 0xFF, 0xAA, 0xAA, 0xAA);
mStatusSurface.fillRGB(BackRect, 0xAA, 0xAA, 0xAA);
// Draw the cables Bitmap
GsBitmap &Cables_Bitmap = gGraphics.getMaskedBitmap(1);
......@@ -123,15 +124,15 @@ void CStatusScreenGalaxy::drawBase(SDL_Rect &EditRect)
void CStatusScreenGalaxy::scaleToResolution()
{
SDL_Rect gameres = gVideoDriver.getGameResolution().SDLRect();
/*SDL_Rect gameres = gVideoDriver.getGameResolution().SDLRect();
const int scaleFac = gameres.h/200;
GsWeakSurface blit(gVideoDriver.getBlitSurface());
SDL_PixelFormat *format = mStatusSurface.getSDLSurface()->format;
mStatusSfcTransformed.create(0,
blit.width(),
blit.height(),
blit.width()*scaleFac,
blit.height()*scaleFac,
32,
format->Rmask,
format->Gmask,
......@@ -141,11 +142,9 @@ void CStatusScreenGalaxy::scaleToResolution()
mStatusSurface.setBlendMode(0);
mStatusSurface.setAlpha(0);
SDL_Rect srcRect = mStatusSurface.getSDLSurface()->clip_rect;
srcRect.w *= scaleFac;
srcRect.h *= scaleFac;
mStatusSurface.blitScaledTo(mStatusSfcTransformed);*/
mStatusSurface.blitScaledTo(mStatusSfcTransformed);
mStatusSfcTransformed.createCopy(mStatusSurface);
}
void CStatusScreenGalaxy::GenerateStatusEp4()
......@@ -158,7 +157,8 @@ void CStatusScreenGalaxy::GenerateStatusEp4()
Font.drawFontCentered(mStatusSurface.getSDLSurface(), "LOCATION", EditRect.x, EditRect.w, EditRect.y, false);
// Temporary Rect for drawing some stuff like background for scores and so...
// drawing Rect for stuff like background for scores and items
SDL_Rect TempRect;
// Location Rect
......@@ -168,7 +168,8 @@ void CStatusScreenGalaxy::GenerateStatusEp4()
TempRect.h = 20;
Font.setupColor(0x0);
mStatusSurface.fillRGBA(0xFF, 0xFF, 0xFF, 0xFF);
mStatusSurface.fillRGBA(TempRect, 0xFF, 0xFF, 0xFF, 0xFF);
Font.drawFontCentered(mStatusSurface.getSDLSurface(),
m_Item.mLevelName,
TempRect.x,
......@@ -177,6 +178,7 @@ void CStatusScreenGalaxy::GenerateStatusEp4()
false);
Font.setupColor(mStatusSurface.mapRGB(0x44, 0x44, 0x44));
/// SCORE and EXTRA Rect
TempRect.x = EditRect.x;
TempRect.y = EditRect.y+32;
......@@ -187,13 +189,13 @@ void CStatusScreenGalaxy::GenerateStatusEp4()
// Score Box
TempRect.w = 8*8;
mStatusSurface.fillRGBA(TempRect, 0xFF, 0x0, 0x0, 0x0);
mStatusSurface.fillRGBA(TempRect, 0x0, 0x0, 0x0, 0xFF);
gGraphics.drawDigits(getRightAlignedString(itoa(m_Item.m_points), 8), TempRect.x, TempRect.y+2,
mStatusSurface.getSDLSurface());
// Extra Box
TempRect.x = EditRect.x+96;
mStatusSurface.fillRGBA(0xFF, 0x0, 0x0, 0x0);
mStatusSurface.fillRGBA(TempRect, 0x0, 0x0, 0x0, 0xFF);
gGraphics.drawDigits(getRightAlignedString(itoa(m_Item.m_lifeAt), 8),
TempRect.x, TempRect.y+2,
mStatusSurface.getSDLSurface());
......@@ -226,7 +228,7 @@ void CStatusScreenGalaxy::GenerateStatusEp4()
// Rescued Box
TempRect.w = 8*8;
mStatusSurface.fillRGBA(0xFF, 0x0, 0x0, 0x0);
mStatusSurface.fillRGBA(TempRect, 0x0, 0x0, 0x0, 0xFF);
for( int count=0 ; count<m_Item.m_special.ep4.elders ; count++ )
{
gGraphics.drawDigit(40,
......@@ -253,7 +255,7 @@ void CStatusScreenGalaxy::GenerateStatusEp4()
TempRect.x = TempRect.x+8*5;
mStatusSurface.fillRGBA(TempRect, 0xFF, 0x0, 0x0, 0x0);
mStatusSurface.fillRGBA(TempRect, 0x0, 0x0, 0x0, 0xFF);
if(m_Item.m_gem.red)
{
......@@ -279,7 +281,7 @@ void CStatusScreenGalaxy::GenerateStatusEp4()
TempRect.w = 8*3; TempRect.h = 10;
TempRect.x = TempRect.x+8*5;
mStatusSurface.fillRGBA(TempRect, 0xFF, 0x0, 0x0, 0x0);
mStatusSurface.fillRGBA(TempRect, 0x0, 0x0, 0x0, 0xFF);
gGraphics.drawDigits(getRightAlignedString(itoa(m_Item.m_bullets), 3),
TempRect.x, TempRect.y+1,
mStatusSurface.getSDLSurface());
......@@ -290,7 +292,7 @@ void CStatusScreenGalaxy::GenerateStatusEp4()
Font.drawFont(mStatusSurface, "KEENS", TempRect.x, TempRect.y, false);
TempRect.w = 8*2; TempRect.h = 10;
TempRect.x = TempRect.x+8*5+8;
mStatusSurface.fillRGBA(TempRect, 0xFF, 0x0, 0x0, 0x0);
mStatusSurface.fillRGBA(TempRect, 0x0, 0x0, 0x0, 0xFF);
gGraphics.drawDigits(getRightAlignedString(itoa(m_Item.m_lifes), 2),
TempRect.x,
TempRect.y+1,
......@@ -303,7 +305,7 @@ void CStatusScreenGalaxy::GenerateStatusEp4()
TempRect.w = 8*2; TempRect.h = 10;
TempRect.x = TempRect.x+8*5+8;
mStatusSurface.fillRGBA(TempRect, 0xFF, 0x0, 0x0, 0x0);
mStatusSurface.fillRGBA(TempRect, 0x0, 0x0, 0x0, 0xFF);
gGraphics.drawDigits(getRightAlignedString(itoa(m_Item.m_drops), 2),
TempRect.x,
TempRect.y+1,
......@@ -611,6 +613,6 @@ void CStatusScreenGalaxy::GenerateStatusEp6()
void CStatusScreenGalaxy::draw()
{
GsWeakSurface blit(gVideoDriver.getBlitSurface());
mStatusSfcTransformed.blitTo(blit);
auto weakBlit = GsWeakSurface(gVideoDriver.getBlitSurface());
mStatusSfcTransformed.blitTo(weakBlit);
}
......@@ -36,11 +36,11 @@ public:
// Generate the base for the Status screen. This function is common for all Keen4-6 galaxy games
// and start_x and start_y will return the start offset pixel where particular stuff can be drawn
void drawBase(SDL_Rect &EditRect);
void drawBase(SDL_Rect &EditRect);
// return the pointer to the allocated status screen surface
SDL_Surface *getStatusSfc()
{ return mStatusSfcTransformed.getSDLSurface(); }
/*SDL_Surface *getStatusSfc()
{ return mStatusSfcTransformed.getSDLSurface(); }*/
// Draw the status
void draw();
......
......@@ -11,20 +11,6 @@
#include <cassert>
CScrollEffect::CScrollEffect(SDL_Surface *pScrollSurface,
const int initialPos,
const int speed,
const direction_t hDir,
const direction_t vDir) :
mInitSpeed(speed),
mSpeed(2*speed),
mInitialSpeed(speed),
mScrollPos(initialPos),
mHDir(hDir),
mVDir(vDir)
{
mScrollSurface.createFromSDLSfc(pScrollSurface);
}
CScrollEffect::CScrollEffect(GsWeakSurface &scrollSurface,
const int initialPos,
......
......@@ -21,12 +21,6 @@ class CScrollEffect : public CEffects
{
public:
CScrollEffect(SDL_Surface *pScrollSurface,
const int initialPos,
const int speed,
const direction_t hDir,
const direction_t vDir);
CScrollEffect(GsWeakSurface &scrollSurface,
const int initialPos,
const int speed,
......
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