Commit d59e310a authored by Gerhard Stein's avatar Gerhard Stein

Cleanups

parent d178b9d1
Subproject commit 645a857c73a1a80d1d248aa5d0d65fc600a9c3f0
Subproject commit 6e4923af4f76550504356e4ad31709633459ed06
......@@ -25,11 +25,10 @@ m_timer(0)
m_8x8tilewidth = m_8x8tileheight = 8;
m_mustclose = false;
SDL_Surface *temp = CG_CreateRGBSurface( gVideoDriver.getGameResolution().SDLRect() );
GsSurface temp;
temp.createRGBSurface(gVideoDriver.getGameResolution().SDLRect());
mpTextVSfc.reset(gVideoDriver.convertThroughBlitSfc(temp), &SDL_FreeSurface);
SDL_FreeSurface(temp);
mpTextVSfc.reset(gVideoDriver.convertThroughBlitSfc(temp.getSDLSurface()), &SDL_FreeSurface);
}
void CTextViewer::scrollDown()
......
......@@ -29,7 +29,7 @@ timer(0)
}
void CHUD::createHUDBlit()
{
{
mpHUDBlit.reset( CG_CreateRGBSurface( mRenderRect ), &SDL_FreeSurface );
mpHUDBlit.reset(gVideoDriver.convertThroughBlitSfc(mpHUDBlit.get()), &SDL_FreeSurface);
......
......@@ -328,8 +328,8 @@ m_style(PROGRESS_STYLE_TEXT)
rect.x = 0; rect.y = 0;
rect.w = gameRes.w; rect.h = gameRes.h;
mpProgressSfc.reset( CG_CreateRGBSurface( rect ), &SDL_FreeSurface );
mpProgressSfc.reset( gVideoDriver.convertThroughBlitSfc(mpProgressSfc.get()), &SDL_FreeSurface );
mProgressSfc.createRGBSurface(rect);
mProgressSfc.makeBlitCompatible();
}
......@@ -416,8 +416,7 @@ void CResourceLoaderBackground::run(const float deltaT)
*/
void CResourceLoaderBackground::render()
{
SDL_Surface *sfc = mpProgressSfc.get();
SDL_FillRect(sfc, nullptr, 0x0);
mProgressSfc.fillRGB(0, 0, 0);
GsRect<Uint16> gameRes = gVideoDriver.getGameResolution();
......@@ -433,14 +432,15 @@ void CResourceLoaderBackground::render()
int rest = m_permil%10;
std::string text = "Loading ... " + itoa(percent)+"."+ itoa(rest)+" \%";
SDL_Rect textRect;
GsRect<Uint16> textRect;
GsRect<Uint16> gameRes = gVideoDriver.getGameResolution();
const float scaleUpW = float(gameRes.w)/320.0f;
const float scaleUpH = float(gameRes.h)/200.0f;
textRect.x = (int)(80.0*scaleUpW); textRect.y = (int)(100.0*scaleUpH);
textRect.w = 200; textRect.h = 10;
SDL_FillRect(sfc, &textRect, SDL_MapRGB(sfc->format, 0, 0, 0));
Font.drawFont(sfc, text , textRect.x, textRect.y, true);
mProgressSfc.fillRGB(textRect, 0, 0, 0);
Font.drawFont(mProgressSfc.getSDLSurface(), text , textRect.x, textRect.y, true);
}
else if(m_style == PROGRESS_STYLE_BITMAP)
{
......@@ -448,7 +448,7 @@ void CResourceLoaderBackground::render()
SDL_Rect rect;
int width = Bitmap.width();
int height = Bitmap.height();
Bitmap._draw( (gameWidth-width)/2, (gameHeight-height)/2, sfc);
Bitmap._draw( (gameWidth-width)/2, (gameHeight-height)/2, mProgressSfc.getSDLSurface());
rect.x = (gameWidth-width)/2;
rect.y = (gameHeight+height)/2;
......@@ -457,9 +457,7 @@ void CResourceLoaderBackground::render()
rect.h = 4;
// Fade from yellow to green with this formula
Uint32 color = SDL_MapRGB(sfc->format, 200-(200*m_permil)/1000, 200, 0 );
SDL_FillRect(sfc, &rect, color);
mProgressSfc.fillRGB(rect, 200-(200*m_permil)/1000, 200, 0);
}
else if(m_style == PROGRESS_STYLE_BAR)
{
......@@ -482,18 +480,13 @@ void CResourceLoaderBackground::render()
const Uint8 b = 0;
// Fade from yellow to green with this formula
Uint32 color = SDL_MapRGB(sfc->format, r, g, b );
SDL_FillRect(sfc, &bgRect, SDL_MapRGB(sfc->format, 128, 128, 128));
SDL_FillRect(sfc, &rect, color);
mProgressSfc.fillRGB(bgRect, 128, 128, 128);
mProgressSfc.fillRGB(rect, r, g, b);
}
// In there is garbage of other drawn stuff clean it up.
auto blit = gVideoDriver.getBlitSurface();
SDL_FillRect( blit, nullptr, SDL_MapRGB(blit->format, 0,0,0) );
BlitSurface( mpProgressSfc.get(), nullptr, blit, nullptr );
BlitSurface( mProgressSfc.getSDLSurface(), nullptr, blit, nullptr );
}
......
......@@ -14,6 +14,7 @@
#include <base/Singleton.h>
#include <base/utils/ThreadPool.h>
#include <graphics/GsSurface.h>
#include <base/GsGear.h>
#include <memory>
......@@ -97,7 +98,7 @@ private:
ProgressStyle m_style;
ThreadPoolItem *mpThread;
std::shared_ptr<SDL_Surface> mpProgressSfc;
GsSurface mProgressSfc;
};
......
......@@ -190,8 +190,12 @@ void CGameLauncher::setupDownloadDialog()
GsRect<float>(0.100f, 0.865f, 0.25f, 0.07f) ) );
mpDloadCancel = std::dynamic_pointer_cast<GsButton>(
mpGameStoreDialog->addControl( new GsButton( "Cancel", new CancelDownloadEvent() ),
mpGameStoreDialog->addControl( new GsButton( "Cancel", new CancelDownloadEvent(),
GsControl::Style::UNSET,
1.0f, 0.675f, 0.675f) ,
GsRect<float>(0.375f, 0.865f, 0.25f, 0.07f) ) );
mpDloadCancel->enable(false);
mpDloadDownload = std::dynamic_pointer_cast<GsButton>(
......
......@@ -277,7 +277,7 @@ bool GameDownloader::checkForMissingGames( std::vector< std::string > &missingLi
if(!mCataFound)
{
gLogging.ftextOut("Sorry, catalogue file was not found: %s<br>", mCatalogFName.c_str() );
gLogging.ftextOut("Sorry, the catalogue file \"%s\" was not found <br>", mCatalogFName.c_str() );
return -1;
}
......
......@@ -24,3 +24,4 @@ set(HSRC
add_library(engine_keen_dreams ${CXXSRC} ${HSRC})
target_link_libraries(engine_keen_dreams refkeen)
......@@ -187,3 +187,4 @@ set(HSRC
add_library(engine_keen_vorticon ${CXXSRC} ${HSRC})
target_link_libraries(engine_keen_vorticon GsKit)
......@@ -65,16 +65,14 @@ void CMessageBoxVort::addTileAt(Uint16 tile, Uint16 x, Uint16 y)
rect.x = rect.y = 0;
rect.w = rect.h = tileDim;
#if SDL_VERSION_ATLEAST(2, 0, 0)
std::shared_ptr<SDL_Surface> bmpSfc( CG_CreateRGBSurface( rect ), &SDL_FreeSurface );
bmpSfc.reset(gVideoDriver.convertThroughBlitSfc(bmpSfc.get()), &SDL_FreeSurface);
#else
std::shared_ptr<SDL_Surface> bmpSfc( CG_CreateRGBSurface(rect), &SDL_FreeSurface );
#endif
GsSurface bmpSfc;
bmpSfc.createRGBSurface(rect);
bmpSfc.makeBlitCompatible();
SDL_FillRect(bmpSfc.get(), NULL, 0xFF00FFFF);
tilemap.drawTile(bmpSfc.get(), 0, 0, tile);
bmpSfc.fillRGBA(0xFF, 0x00, 0xFF, 0xFF);
tilemap.drawTile(bmpSfc.getSDLSurface(), 0, 0, tile);
rect.x = x; rect.y = y;
......
......@@ -18,6 +18,11 @@
#if SDL_VERSION_ATLEAST(2, 0, 0)
#endif
/*
GsSurface sfc;
sfc.createRGBSurface(rect);
*/
SDL_Surface *CG_CreateRGBSurface( const SDL_Rect rect )
{
......
......@@ -10,19 +10,19 @@
#define SDL_EXTENSIONS_H_
#include <SDL.h>
/*
struct Colormask
{
Uint32 r,g,b,a;
};
*/
//Uint32 getPixel(SDL_Surface *surface, int x, int y);
Uint32 getPixel(SDL_Surface *surface, int x, int y);
inline Colormask getColourMask32bit();
//inline Colormask getColourMask32bit();
SDL_Surface *CG_CreateRGBSurface( const SDL_Rect rect );
void drawEmptyRect(SDL_Surface *sfc, SDL_Rect *pRect, Uint32 color);
//void drawEmptyRect(SDL_Surface *sfc, SDL_Rect *pRect, Uint32 color);
......
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