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

90 lines
2.9 KiB
C
Raw Normal View History

2017-01-21 17:27:46 +01:00
#pragma once
#include <unordered_map>
2017-02-10 23:03:33 +01:00
#include <SDL2/SDL.h>
2017-01-21 17:27:46 +01:00
2017-02-10 00:14:28 +01:00
#include "blupi.h"
2017-01-21 17:27:46 +01:00
#define MAXIMAGE 100
#define MAXCURSORS 14
2017-01-21 17:27:46 +01:00
struct TextureInfo
{
SDL_Texture *texture;
bool target; // can be used as a render target
std::string file;
POINT dimTotal;
POINT dimIcon;
TextureInfo () : texture (nullptr), target (false) {}
};
2017-01-21 17:27:46 +01:00
class CPixmap
{
public:
CPixmap();
~CPixmap();
2017-02-26 17:57:40 +01:00
bool Create (POINT dim, Sint32 mouseType);
void Fill (RECT rect, COLORREF color);
bool Cache (Sint32 channel, const char *pFilename, POINT totalDim,
POINT iconDim);
bool Cache (Sint32 channel, const char *pFilename, POINT totalDim);
bool Cache (Sint32 channel, SDL_Surface *surface, POINT totalDim);
void SetClipping (RECT clip);
RECT GetClipping();
bool IsIconPixel (Sint32 channel, Sint32 rank, POINT pos);
bool DrawIcon (Sint32 chDst, Sint32 channel, Sint32 rank, POINT pos,
bool bMask = false);
bool DrawIconDemi (Sint32 chDst, Sint32 channel, Sint32 rank, POINT pos,
bool bMask = false);
bool DrawIconPart (Sint32 chDst, Sint32 channel, Sint32 rank, POINT pos,
Sint32 startY, Sint32 endY, bool bMask = false);
bool DrawPart (Sint32 chDst, Sint32 channel, POINT dest, RECT rect,
bool bMask = false);
bool DrawImage (Sint32 chDst, Sint32 channel, RECT rect);
bool BuildIconMask (Sint32 channelMask, Sint32 rankMask,
Sint32 channel, Sint32 rankSrc, Sint32 rankDst);
bool Display();
void SetMouseSprite (Sint32 sprite, bool bDemoPlay);
void MouseShow (bool bShow);
void LoadCursors();
void ChangeSprite (MouseSprites sprite);
2017-01-21 17:27:46 +01:00
protected:
Sint32 BltFast (Sint32 chDst, Sint32 channel, POINT dst, RECT rcRect);
Sint32 BltFast (SDL_Texture *lpSDL, Sint32 channel, POINT dst, RECT rcRect);
2017-01-21 17:27:46 +01:00
RECT MouseRectSprite();
SDL_Point GetCursorHotSpot (Sint32 sprite);
SDL_Rect GetCursorRect (Sint32 sprite);
2017-01-21 17:27:46 +01:00
protected:
Sint32 m_mouseType;
bool m_bDebug;
bool m_bPalette;
POINT m_dim; // dimensions totales
RECT m_clipRect; // rectangle de clipping
Sint32 m_mouseSprite;
bool m_bBackDisplayed;
SDL_Cursor *m_lpCurrentCursor;
SDL_Cursor *m_lpSDLCursors[MAXCURSORS];
SDL_Surface *m_lpSDLBlupi;
std::unordered_map<size_t, TextureInfo> m_SDLTextureInfo;
char m_filename[MAXIMAGE][20];
POINT m_totalDim[MAXIMAGE]; // dimensions totale image
POINT m_iconDim[MAXIMAGE]; // dimensions d'une ic�ne
2017-01-21 17:27:46 +01:00
};
/////////////////////////////////////////////////////////////////////////////