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.top = 0;
rcRect.right = LXLOGIC;
rcRect.bottom = LYLOGIC;
rcRect.right = LXIMAGE;
rcRect.bottom = LYIMAGE;
g_pPixmap->DrawImage (-1, CHBACK, rcRect); // draw the background
if (phase == EV_PHASE_INTRO1)

View File

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

View File

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

View File

@ -267,7 +267,8 @@ CPixmap::Cache (size_t channel, Point totalDim)
bool
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;
SDL_Surface * surface = IMG_Load (file.c_str ());
@ -277,8 +278,19 @@ CPixmap::Cache (
SDL_Texture * texture = SDL_CreateTextureFromSurface (g_renderer, surface);
Uint32 format;
Sint32 access, w, h;
SDL_QueryTexture (texture, &format, &access, &w, &h);
Sint32 access, ow, w, oh, 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 ())
{
@ -311,7 +323,43 @@ CPixmap::Cache (
m_SDLTextureInfo[channel].file = pFilename;
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);
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 ())
return false;
if (channel == CHBACK)
{
dst.x = (LXIMAGE - LXLOGIC) / 2;
dst.y = (LYIMAGE - LYLOGIC) / 2;
}
else
{
dst.x = rect.left;
dst.y = rect.top;
}
dst.x = rect.left;
dst.y = rect.top;
res = BltFast (chDst, channel, dst, rect);

View File

@ -50,6 +50,11 @@ struct TextureInfo {
class CPixmap
{
public:
enum Mode {
FIX = 0,
EXPAND,
};
CPixmap ();
~CPixmap ();
@ -59,7 +64,7 @@ public:
bool Cache (size_t channel, Point totalDim);
bool Cache (
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, SDL_Surface * surface, Point totalDim);
void SetClipping (Rect clip);