Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Template for new versions:
## Documentation

## API

- ``DFSDL``: added ``obtain_library_handle`` and ``obtain_image_library_handle`` so that a plugin can obtain DFHack's already-open handle to these libs instead of having to do it itself.
- ``Screen``: new functions ``paintMapPortTile`` and ``readMapPortTile`` to write and read world and region map tiles.
- ``Materials``: ``MaterialInfo`` constants ``NUM_BUILTIN``, ``GROUP_SIZE``, ``CREATURE_BASE``, ``FIGURE_BASE``, ``PLANT_BASE``, and ``END_BASE`` removed. New plugins should use appropriate members of the ``df::builtin_mats`` enum.

Expand Down
8 changes: 8 additions & 0 deletions library/include/modules/DFSDL.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "ColorText.h"
#include "Export.h"
#include "PluginManager.h"

#include <cstdint>
#include <functional>
Expand Down Expand Up @@ -35,6 +36,13 @@ namespace DFHack::DFSDL
*/
void cleanup();

/**
* Obtain DFHack's handle to the SDL or IMG libraries, in case a plugin needs
* to map a SDL API not mapped here
*/
DFHACK_EXPORT DFLibrary* obtain_library_handle();
DFHACK_EXPORT DFLibrary* obtain_image_library_handle();

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);
Expand Down
11 changes: 11 additions & 0 deletions library/modules/DFSDL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ using std::vector;

static DFLibrary *g_sdl_handle = nullptr;
static DFLibrary *g_sdl_image_handle = nullptr;

DFLibrary* obtain_library_handle()
{
return g_sdl_handle;
}

DFLibrary* obtain_image_library_handle()
{
return g_sdl_image_handle;
}

static const vector<string> SDL_LIBS {
#ifdef WIN32
"SDL2.dll"
Expand Down
Loading