diff --git a/docs/changelog.txt b/docs/changelog.txt index 3f1340168f..300ae435f2 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -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. diff --git a/library/include/modules/DFSDL.h b/library/include/modules/DFSDL.h index 7d53242ad0..95837b6889 100644 --- a/library/include/modules/DFSDL.h +++ b/library/include/modules/DFSDL.h @@ -2,6 +2,7 @@ #include "ColorText.h" #include "Export.h" +#include "PluginManager.h" #include #include @@ -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); diff --git a/library/modules/DFSDL.cpp b/library/modules/DFSDL.cpp index f23cde5511..ae0e6abbd6 100644 --- a/library/modules/DFSDL.cpp +++ b/library/modules/DFSDL.cpp @@ -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 SDL_LIBS { #ifdef WIN32 "SDL2.dll"