1
0
mirror of https://github.com/blupi-games/planetblupi synced 2024-12-30 10:15:36 +01:00

WIP: add an expanded mode for the backgrounds

It's just partially working.
This commit is contained in:
Mathieu Schroeter 2017-10-15 11:23:02 +02:00
parent 3e5768510e
commit f7640e92ce
5 changed files with 100 additions and 22 deletions

View File

@ -192,8 +192,8 @@ UpdateFrame (void)
rcRect.left = 0; rcRect.left = 0;
rcRect.top = 0; rcRect.top = 0;
rcRect.right = LXLOGIC; rcRect.right = LXIMAGE;
rcRect.bottom = LYLOGIC; rcRect.bottom = LYIMAGE;
g_pPixmap->DrawImage (-1, CHBACK, rcRect); // draw the background g_pPixmap->DrawImage (-1, CHBACK, rcRect); // draw the background
if (phase == EV_PHASE_INTRO1) if (phase == EV_PHASE_INTRO1)

View File

@ -97,6 +97,7 @@ static Phase table[] =
{ {
EV_PHASE_TESTCD, EV_PHASE_TESTCD,
"image/init.png", "image/init.png",
CPixmap::Mode::FIX,
false, false,
{ {
{ {
@ -108,6 +109,7 @@ static Phase table[] =
{ {
EV_PHASE_INTRO1, EV_PHASE_INTRO1,
"image/intro1.png", "image/intro1.png",
CPixmap::Mode::FIX,
false, false,
{ {
{ {
@ -119,6 +121,7 @@ static Phase table[] =
{ {
EV_PHASE_INIT, EV_PHASE_INIT,
"image/init.png", "image/init.png",
CPixmap::Mode::FIX,
false, false,
{ {
{ {
@ -166,6 +169,7 @@ static Phase table[] =
{ {
EV_PHASE_HISTORY0, EV_PHASE_HISTORY0,
"image/history0.png", "image/history0.png",
CPixmap::Mode::FIX,
true, true,
{ {
{ {
@ -189,6 +193,7 @@ static Phase table[] =
{ {
EV_PHASE_HISTORY1, EV_PHASE_HISTORY1,
"image/history1.png", "image/history1.png",
CPixmap::Mode::FIX,
true, true,
{ {
{ {
@ -212,6 +217,7 @@ static Phase table[] =
{ {
EV_PHASE_INFO, EV_PHASE_INFO,
"image/info%.3d.png", "image/info%.3d.png",
CPixmap::Mode::FIX,
false, false,
{ {
{ {
@ -277,6 +283,7 @@ static Phase table[] =
{ {
EV_PHASE_PLAY, EV_PHASE_PLAY,
"image/play.png", "image/play.png",
CPixmap::Mode::EXPAND,
false, false,
{ {
{ {
@ -306,6 +313,7 @@ static Phase table[] =
{ {
EV_PHASE_STOP, EV_PHASE_STOP,
"image/stop%.3d.png", "image/stop%.3d.png",
CPixmap::Mode::FIX,
false, false,
{ {
{ {
@ -353,6 +361,7 @@ static Phase table[] =
{ {
EV_PHASE_HELP, EV_PHASE_HELP,
"image/help.png", "image/help.png",
CPixmap::Mode::FIX,
true, true,
{ {
{ {
@ -394,6 +403,7 @@ static Phase table[] =
{ {
EV_PHASE_SETUP, EV_PHASE_SETUP,
"image/setup01.png", "image/setup01.png",
CPixmap::Mode::FIX,
false, false,
{ {
{ {
@ -471,6 +481,7 @@ static Phase table[] =
{ {
EV_PHASE_SETUPp, EV_PHASE_SETUPp,
"image/setup01.png", "image/setup01.png",
CPixmap::Mode::FIX,
false, false,
{ {
{ {
@ -548,6 +559,7 @@ static Phase table[] =
{ {
EV_PHASE_READ, EV_PHASE_READ,
"image/read.png", "image/read.png",
CPixmap::Mode::FIX,
false, false,
{ {
{ {
@ -625,6 +637,7 @@ static Phase table[] =
{ {
EV_PHASE_WRITE, EV_PHASE_WRITE,
"image/write.png", "image/write.png",
CPixmap::Mode::FIX,
false, false,
{ {
{ {
@ -702,6 +715,7 @@ static Phase table[] =
{ {
EV_PHASE_WRITEp, EV_PHASE_WRITEp,
"image/write.png", "image/write.png",
CPixmap::Mode::FIX,
false, false,
{ {
{ {
@ -779,6 +793,7 @@ static Phase table[] =
{ {
EV_PHASE_LOST, EV_PHASE_LOST,
"image/lost.png", "image/lost.png",
CPixmap::Mode::FIX,
true, true,
{ {
{ {
@ -796,6 +811,7 @@ static Phase table[] =
{ {
EV_PHASE_WIN, EV_PHASE_WIN,
"image/win.png", "image/win.png",
CPixmap::Mode::FIX,
true, true,
{ {
{ {
@ -813,6 +829,7 @@ static Phase table[] =
{ {
EV_PHASE_LASTWIN, EV_PHASE_LASTWIN,
"image/last%.3d.png", "image/last%.3d.png",
CPixmap::Mode::FIX,
true, true,
{ {
{ {
@ -830,6 +847,7 @@ static Phase table[] =
{ {
EV_PHASE_BUILD, EV_PHASE_BUILD,
"image/build.png", "image/build.png",
CPixmap::Mode::FIX,
true, true,
{ {
{ {
@ -945,6 +963,7 @@ static Phase table[] =
{ {
EV_PHASE_BUTTON, EV_PHASE_BUTTON,
"image/button.png", "image/button.png",
CPixmap::Mode::FIX,
true, true,
{ {
{ {
@ -1165,6 +1184,7 @@ static Phase table[] =
{ {
EV_PHASE_TERM, EV_PHASE_TERM,
"image/term.png", "image/term.png",
CPixmap::Mode::FIX,
true, true,
{ {
{ {
@ -1254,6 +1274,7 @@ static Phase table[] =
{ {
EV_PHASE_MUSIC, EV_PHASE_MUSIC,
"image/music.png", "image/music.png",
CPixmap::Mode::FIX,
true, true,
{ {
{ {
@ -1337,6 +1358,7 @@ static Phase table[] =
{ {
EV_PHASE_REGION, EV_PHASE_REGION,
"image/region.png", "image/region.png",
CPixmap::Mode::FIX,
true, true,
{ {
{ {
@ -1378,6 +1400,7 @@ static Phase table[] =
{ {
EV_PHASE_PLAYMOVIE, EV_PHASE_PLAYMOVIE,
"image/movie.png", "image/movie.png",
CPixmap::Mode::FIX,
false, false,
{ {
{ {
@ -1389,6 +1412,7 @@ static Phase table[] =
{ {
EV_PHASE_WINMOVIE, EV_PHASE_WINMOVIE,
"image/movie.png", "image/movie.png",
CPixmap::Mode::FIX,
false, false,
{ {
{ {
@ -1400,6 +1424,7 @@ static Phase table[] =
{ {
EV_PHASE_H0MOVIE, EV_PHASE_H0MOVIE,
"image/movie.png", "image/movie.png",
CPixmap::Mode::FIX,
false, false,
{ {
{ {
@ -1411,6 +1436,7 @@ static Phase table[] =
{ {
EV_PHASE_H1MOVIE, EV_PHASE_H1MOVIE,
"image/movie.png", "image/movie.png",
CPixmap::Mode::FIX,
false, false,
{ {
{ {
@ -1422,6 +1448,7 @@ static Phase table[] =
{ {
EV_PHASE_H2MOVIE, EV_PHASE_H2MOVIE,
"image/movie.png", "image/movie.png",
CPixmap::Mode::FIX,
false, false,
{ {
{ {
@ -1433,6 +1460,7 @@ static Phase table[] =
{ {
EV_PHASE_BYE, EV_PHASE_BYE,
"image/bye.png", "image/bye.png",
CPixmap::Mode::FIX,
false, false,
{ {
{ {
@ -1444,6 +1472,7 @@ static Phase table[] =
{ {
EV_PHASE_INSERT, EV_PHASE_INSERT,
"image/insert.png", "image/insert.png",
CPixmap::Mode::FIX,
false, false,
{ {
{ {
@ -1461,6 +1490,7 @@ static Phase table[] =
{ {
EV_PHASE_SETTINGS, EV_PHASE_SETTINGS,
"image/setup00.png", "image/setup00.png",
CPixmap::Mode::FIX,
false, false,
{ {
{ {
@ -3099,7 +3129,8 @@ CEvent::ChangePhase (Uint32 phase)
totalDim.y = LYLOGIC; totalDim.y = LYLOGIC;
iconDim.x = 0; iconDim.x = 0;
iconDim.y = 0; iconDim.y = 0;
if (!m_pPixmap->Cache (CHBACK, filename, totalDim, iconDim)) if (!m_pPixmap->Cache (
CHBACK, filename, totalDim, iconDim, table[m_index].mode))
{ {
WaitMouse (false); // enlève le sablier WaitMouse (false); // enlève le sablier
m_tryInsertCount = 40; m_tryInsertCount = 40;

View File

@ -26,6 +26,7 @@
#include "button.h" #include "button.h"
#include "menu.h" #include "menu.h"
#include "pixmap.h"
#include "progress.h" #include "progress.h"
class CMovie; class CMovie;
@ -41,10 +42,11 @@ typedef struct {
} Button; } Button;
typedef struct { typedef struct {
Uint32 phase; Uint32 phase;
char backName[20]; char backName[20];
Sint32 bCDrom; CPixmap::Mode mode;
Button buttons[MAXBUTTON]; Sint32 bCDrom;
Button buttons[MAXBUTTON];
} Phase; } Phase;
typedef struct { typedef struct {

View File

@ -267,7 +267,8 @@ CPixmap::Cache (size_t channel, Point totalDim)
bool bool
CPixmap::Cache ( CPixmap::Cache (
size_t channel, const std::string & pFilename, Point totalDim, Point iconDim) size_t channel, const std::string & pFilename, Point totalDim, Point iconDim,
Mode mode)
{ {
std::string file = GetBaseDir () + pFilename; std::string file = GetBaseDir () + pFilename;
SDL_Surface * surface = IMG_Load (file.c_str ()); SDL_Surface * surface = IMG_Load (file.c_str ());
@ -277,8 +278,19 @@ CPixmap::Cache (
SDL_Texture * texture = SDL_CreateTextureFromSurface (g_renderer, surface); SDL_Texture * texture = SDL_CreateTextureFromSurface (g_renderer, surface);
Uint32 format; Uint32 format;
Sint32 access, w, h; Sint32 access, ow, w, oh, h;
SDL_QueryTexture (texture, &format, &access, &w, &h); SDL_QueryTexture (texture, &format, &access, &ow, &oh);
if (mode == EXPAND || channel == CHBACK)
{
w = LXIMAGE;
h = LYIMAGE;
}
else
{
w = ow;
h = oh;
}
if (m_SDLTextureInfo.find (channel) == m_SDLTextureInfo.end ()) if (m_SDLTextureInfo.find (channel) == m_SDLTextureInfo.end ())
{ {
@ -311,7 +323,43 @@ CPixmap::Cache (
m_SDLTextureInfo[channel].file = pFilename; m_SDLTextureInfo[channel].file = pFilename;
SDL_SetRenderTarget (g_renderer, m_SDLTextureInfo[channel].texture); SDL_SetRenderTarget (g_renderer, m_SDLTextureInfo[channel].texture);
SDL_RenderCopy (g_renderer, texture, nullptr, nullptr);
switch (mode)
{
case FIX:
{
if (channel == CHBACK)
{
SDL_Rect dst;
dst.x = (LXIMAGE - ow) / 2;
dst.y = 0;
dst.w = ow;
dst.h = oh;
SDL_RenderCopy (g_renderer, texture, nullptr, &dst);
}
else
SDL_RenderCopy (g_renderer, texture, nullptr, nullptr);
break;
}
case EXPAND:
{
SDL_Rect src, dst;
src.x = 0;
src.y = 0;
src.w = POSDRAWX - 1;
src.h = LYIMAGE;
dst = src;
SDL_RenderCopy (g_renderer, texture, &src, &dst);
src.x = ow - 15;
src.w = 15;
dst.x = LXIMAGE - 15;
dst.w = src.w;
SDL_RenderCopy (g_renderer, texture, &src, &dst);
break;
}
}
SDL_SetRenderTarget (g_renderer, nullptr); SDL_SetRenderTarget (g_renderer, nullptr);
if (!m_SDLTextureInfo[channel].texMask) if (!m_SDLTextureInfo[channel].texMask)
@ -540,16 +588,8 @@ CPixmap::DrawImage (Sint32 chDst, size_t channel, Rect rect)
if (m_SDLTextureInfo.find (channel) == m_SDLTextureInfo.end ()) if (m_SDLTextureInfo.find (channel) == m_SDLTextureInfo.end ())
return false; return false;
if (channel == CHBACK) dst.x = rect.left;
{ dst.y = rect.top;
dst.x = (LXIMAGE - LXLOGIC) / 2;
dst.y = (LYIMAGE - LYLOGIC) / 2;
}
else
{
dst.x = rect.left;
dst.y = rect.top;
}
res = BltFast (chDst, channel, dst, rect); res = BltFast (chDst, channel, dst, rect);

View File

@ -50,6 +50,11 @@ struct TextureInfo {
class CPixmap class CPixmap
{ {
public: public:
enum Mode {
FIX = 0,
EXPAND,
};
CPixmap (); CPixmap ();
~CPixmap (); ~CPixmap ();
@ -59,7 +64,7 @@ public:
bool Cache (size_t channel, Point totalDim); bool Cache (size_t channel, Point totalDim);
bool Cache ( bool Cache (
size_t channel, const std::string & pFilename, Point totalDim, size_t channel, const std::string & pFilename, Point totalDim,
Point iconDim); Point iconDim, Mode mode = FIX);
bool Cache (size_t channel, const std::string & pFilename, Point totalDim); bool Cache (size_t channel, const std::string & pFilename, Point totalDim);
bool Cache (size_t channel, SDL_Surface * surface, Point totalDim); bool Cache (size_t channel, SDL_Surface * surface, Point totalDim);
void SetClipping (Rect clip); void SetClipping (Rect clip);