diff --git a/dfhack/CMakeLists.txt b/dfhack/CMakeLists.txt index c00d3218e..42965c3f4 100644 --- a/dfhack/CMakeLists.txt +++ b/dfhack/CMakeLists.txt @@ -45,6 +45,7 @@ modules/Buildings.cpp modules/Constructions.cpp modules/Position_C.cpp +modules/Gui_C.cpp ) SET(PROJECT_HDRS_LINUX diff --git a/dfhack/DFHackAPI_C.cpp b/dfhack/DFHackAPI_C.cpp index e7bf624b0..fb6f7c932 100644 --- a/dfhack/DFHackAPI_C.cpp +++ b/dfhack/DFHackAPI_C.cpp @@ -140,6 +140,128 @@ int API_AsyncSuspend(DFHackObject* api) return -1; } +//module getters + +DFHackObject* API_getMemoryInfo(DFHackObject* api) +{ + if(api != NULL) + { + return (DFHackObject*)((DFHack::API*)api)->getMemoryInfo(); + } + + return NULL; +} + +DFHackObject* API_getProcess(DFHackObject* api) +{ + if(api != NULL) + { + return (DFHackObject*)((DFHack::API*)api)->getProcess(); + } + + return NULL; +} + +DFHackObject* API_getWindow(DFHackObject* api) +{ + if(api != NULL) + { + return (DFHackObject*)((DFHack::API*)api)->getWindow(); + } + + return NULL; +} + +DFHackObject* API_getCreatures(DFHackObject* api) +{ + if(api != NULL) + { + return (DFHackObject*)((DFHack::API*)api)->getCreatures(); + } + + return NULL; +} + +DFHackObject* API_getMaps(DFHackObject* api) +{ + if(api != NULL) + { + return (DFHackObject*)((DFHack::API*)api)->getMaps(); + } + + return NULL; +} + +DFHackObject* API_getGui(DFHackObject* api) +{ + if(api != NULL) + { + return (DFHackObject*)((DFHack::API*)api)->getGui(); + } + + return NULL; +} + +DFHackObject* API_getPosition(DFHackObject* api) +{ + if(api != NULL) + { + return (DFHackObject*)((DFHack::API*)api)->getPosition(); + } + + return NULL; +} + +DFHackObject* API_getMaterials(DFHackObject* api) +{ + if(api != NULL) + { + return (DFHackObject*)((DFHack::API*)api)->getMaterials(); + } + + return NULL; +} + +DFHackObject* API_getTranslation(DFHackObject* api) +{ + if(api != NULL) + { + return (DFHackObject*)((DFHack::API*)api)->getTranslation(); + } + + return NULL; +} + +DFHackObject* API_getVegetation(DFHackObject* api) +{ + if(api != NULL) + { + return (DFHackObject*)((DFHack::API*)api)->getVegetation(); + } + + return NULL; +} + +DFHackObject* API_getBuildings(DFHackObject* api) +{ + if(api != NULL) + { + return (DFHackObject*)((DFHack::API*)api)->getBuildings(); + } + + return NULL; +} + +DFHackObject* API_getConstructions(DFHackObject* api) +{ + if(api != NULL) + { + return (DFHackObject*)((DFHack::API*)api)->getConstructions(); + } + + return NULL; +} + void API_ReadRaw(DFHackObject* api, const uint32_t offset, const uint32_t size, uint8_t* target) { if(api != NULL) diff --git a/dfhack/include/DFHackAPI_C.h b/dfhack/include/DFHackAPI_C.h index 88e7a3f2e..6c49aa35a 100644 --- a/dfhack/include/DFHackAPI_C.h +++ b/dfhack/include/DFHackAPI_C.h @@ -47,6 +47,21 @@ DFHACK_EXPORT int API_isSuspended(DFHackObject* api); DFHACK_EXPORT int API_ForceResume(DFHackObject* api); DFHACK_EXPORT int API_AsyncSuspend(DFHackObject* api); +DFHACK_EXPORT DFHackObject* API_getMemoryInfo(DFHackObject* api); +DFHACK_EXPORT DFHackObject* API_getProcess(DFHackObject* api); +DFHACK_EXPORT DFHackObject* API_getWindow(DFHackObject* api); + +DFHACK_EXPORT DFHackObject* API_getCreatures(DFHackObject* api); +DFHACK_EXPORT DFHackObject* API_getMaps(DFHackObject* api); +DFHACK_EXPORT DFHackObject* API_getGui(DFHackObject* api); +DFHACK_EXPORT DFHackObject* API_getPosition(DFHackObject* api); +DFHACK_EXPORT DFHackObject* API_getMaterials(DFHackObject* api); +DFHACK_EXPORT DFHackObject* API_getTranslation(DFHackObject* api); +DFHACK_EXPORT DFHackObject* API_getVegetation(DFHackObject* api); +DFHACK_EXPORT DFHackObject* API_getBuildings(DFHackObject* api); +DFHACK_EXPORT DFHackObject* API_getConstructions(DFHackObject* api); + +//these are DANGEROUS...can crash/segfault DF, turn the seas to blood, call up the Antichrist, etc DFHACK_EXPORT void API_ReadRaw(DFHackObject* api, const uint32_t offset, const uint32_t size, uint8_t* target); DFHACK_EXPORT void API_WriteRaw(DFHackObject* api, const uint32_t offset, const uint32_t size, uint8_t* source); diff --git a/dfhack/include/modules/Gui_C.h b/dfhack/include/modules/Gui_C.h new file mode 100644 index 000000000..cccde45fe --- /dev/null +++ b/dfhack/include/modules/Gui_C.h @@ -0,0 +1,49 @@ +/* +www.sourceforge.net/projects/dfhack +Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any +damages arising from the use of this software. + +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must +not claim that you wrote the original software. If you use this +software in a product, an acknowledgment in the product documentation +would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and +must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source +distribution. +*/ + +#ifndef GUI_C_API +#define GUI_C_API + +#include "Export.h" +#include "integers.h" +#include "DFTypes.h" +#include "DFHackAPI_C.h" + +using namespace DFHack; + +#ifdef __cplusplus +extern "C" { +#endif + +DFHACK_EXPORT int Gui_Start(DFHackObject* gui); +DFHACK_EXPORT int Gui_Finish(DFHackObject* gui); + +DFHACK_EXPORT int Gui_ReadPauseState(DFHackObject* gui); +DFHACK_EXPORT int Gui_ReadViewScreen(DFHackObject* gui, t_viewscreen* viewscreen); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dfhack/modules/Gui_C.cpp b/dfhack/modules/Gui_C.cpp new file mode 100644 index 000000000..8a8dc185d --- /dev/null +++ b/dfhack/modules/Gui_C.cpp @@ -0,0 +1,81 @@ +/* +www.sourceforge.net/projects/dfhack +Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any +damages arising from the use of this software. + +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must +not claim that you wrote the original software. If you use this +software in a product, an acknowledgment in the product documentation +would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and +must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source +distribution. +*/ + +#include "modules/Gui_C.h" +#include "integers.h" + +#include "DFCommonInternal.h" +#include "modules/Gui.h" + +using namespace DFHack; + +#ifdef __cplusplus +extern "C" { +#endif + +int Gui_Start(DFHackObject* gui) +{ + if(gui != NULL) + { + return ((DFHack::Gui*)gui)->Start(); + } + + return -1; +} + +int Gui_Finish(DFHackObject* gui) +{ + if(gui != NULL) + { + return ((DFHack::Gui*)gui)->Finish(); + } + + return -1; +} + +int Gui_ReadPauseState(DFHackObject* gui) +{ + if(gui != NULL) + { + return ((DFHack::Gui*)gui)->ReadPauseState(); + } + + return -1; +} + +int Gui_ReadViewScreen(DFHackObject* gui, t_viewscreen* viewscreen) +{ + int result; + + if(gui != NULL) + { + return ((DFHack::Gui*)gui)->ReadViewScreen(*viewscreen); + } + + return -1; +} + +#ifdef __cplusplus +} +#endif