dfhack/library/include/modules/DFSDL.h

64 lines
2.1 KiB
C

2023-01-04 18:15:32 -07:00
#pragma once
#include "Export.h"
#include "ColorText.h"
2023-05-22 16:07:19 -06:00
struct SDL_Surface;
struct SDL_Rect;
struct SDL_PixelFormat;
union SDL_Event;
2023-01-04 18:15:32 -07:00
namespace DFHack
{
struct DFTileSurface
{
bool paintOver; // draw over original tile?
2023-05-22 16:07:19 -06:00
SDL_Surface* surface; // from where it should be drawn
SDL_Rect* rect; // from which coords (NULL to draw whole surface)
SDL_Rect* dstResize; // if not NULL dst rect will be resized (x/y/w/h will be added to original dst)
2023-01-04 18:15:32 -07:00
};
/**
* The DFSDL module - provides access to SDL functions without actually
* requiring build-time linkage to SDL
* \ingroup grp_modules
* \ingroup grp_dfsdl
*/
namespace DFSDL
{
/**
* Call this on DFHack init so we can load the SDL functions. Returns false on
* failure.
*/
bool init(DFHack::color_ostream &out);
/**
* Call this when DFHack is being unloaded.
*/
void cleanup();
2023-05-22 16:07:19 -06:00
DFHACK_EXPORT SDL_Surface * DFIMG_Load(const char *file);
DFHACK_EXPORT SDL_Surface * DFSDL_CreateRGBSurface(uint32_t flags, int width, int height, int depth, uint32_t Rmask, uint32_t Gmask, uint32_t Bmask, uint32_t Amask);
DFHACK_EXPORT SDL_Surface * DFSDL_CreateRGBSurfaceFrom(void *pixels, int width, int height, int depth, int pitch, uint32_t Rmask, uint32_t Gmask, uint32_t Bmask, uint32_t Amask);
DFHACK_EXPORT int DFSDL_UpperBlit(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect);
DFHACK_EXPORT SDL_Surface * DFSDL_ConvertSurface(SDL_Surface *src, const SDL_PixelFormat *fmt, uint32_t flags);
DFHACK_EXPORT void DFSDL_FreeSurface(SDL_Surface *surface);
// DFHACK_EXPORT int DFSDL_SemWait(SDL_sem *sem);
// DFHACK_EXPORT int DFSDL_SemPost(SDL_sem *sem);
DFHACK_EXPORT int DFSDL_PushEvent(SDL_Event *event);
DFHACK_EXPORT void DFSDL_free(void *ptr);
2023-01-04 18:15:32 -07:00
// submitted and returned text is UTF-8
// see wrapper functions below for cp-437 variants
DFHACK_EXPORT char * DFSDL_GetClipboardText();
DFHACK_EXPORT int DFSDL_SetClipboardText(const char *text);
2023-01-04 18:15:32 -07:00
}
// System clipboard -- submitted and returned text must be in CP437
DFHACK_EXPORT std::string getClipboardTextCp437();
DFHACK_EXPORT bool setClipboardTextCp437(std::string text);
2023-01-04 18:15:32 -07:00
}