added getters/setters for cursor/view coords, window size, and screen tiles added ReadHotkeys

develop
doomchild 2011-03-29 09:46:59 -05:00
parent cee5d176b9
commit e34831a354
2 changed files with 118 additions and 108 deletions

@ -36,6 +36,18 @@ extern "C" {
DFHACK_EXPORT int Gui_Start(DFHackObject* gui); DFHACK_EXPORT int Gui_Start(DFHackObject* gui);
DFHACK_EXPORT int Gui_Finish(DFHackObject* gui); DFHACK_EXPORT int Gui_Finish(DFHackObject* gui);
DFHACK_EXPORT int Gui_getViewCoords(DFHackObject* gui, int32_t* x, int32_t* y, int32_t* z);
DFHACK_EXPORT int Gui_setViewCoords(DFHackObject* gui, int32_t x, int32_t y, int32_t z);
DFHACK_EXPORT int Gui_getCursorCoords(DFHackObject* gui, int32_t* x, int32_t* y, int32_t* z);
DFHACK_EXPORT int Gui_setCursorCoords(DFHackObject* gui, int32_t x, int32_t y, int32_t z);
DFHACK_EXPORT t_hotkey* Gui_ReadHotkeys(DFHackObject* gui);
DFHACK_EXPORT int Gui_getWindowSize(DFHackObject* gui, int32_t* width, int32_t* height);
DFHACK_EXPORT t_screen* Gui_getScreenTiles(DFHackObject* gui, int32_t width, int32_t height);
DFHACK_EXPORT int Gui_ReadViewScreen(DFHackObject* gui, t_viewscreen* viewscreen); DFHACK_EXPORT int Gui_ReadViewScreen(DFHackObject* gui, t_viewscreen* viewscreen);
DFHACK_EXPORT int Gui_ReadMenuState(DFHackObject* gui, uint32_t* menuState); DFHACK_EXPORT int Gui_ReadMenuState(DFHackObject* gui, uint32_t* menuState);

@ -48,126 +48,103 @@ int Gui_Finish(DFHackObject* gui)
return -1; return -1;
} }
int Gui_ReadViewScreen(DFHackObject* gui, t_viewscreen* viewscreen) int Gui_getViewCoords(DFHackObject* gui, int32_t* x, int32_t* y, int32_t* z)
{ {
if(gui != NULL) if(gui != NULL)
{ {
return ((DFHack::Gui*)gui)->ReadViewScreen(*viewscreen); int32_t tx, ty, tz;
if(((DFHack::Gui*)gui)->getViewCoords(tx, ty, tz))
{
*x = tx;
*y = ty;
*z = tz;
return 1;
}
else
return 0;
} }
return -1; return -1;
} }
int Gui_ReadMenuState(DFHackObject* gui, uint32_t* menuState) int Gui_setViewCoords(DFHackObject* gui, int32_t x, int32_t y, int32_t z)
{ {
if(gui != NULL) if(gui != NULL)
{ {
*menuState = ((DFHack::Gui*)gui)->ReadMenuState(); if(((DFHack::Gui*)gui)->setViewCoords(x, y, z))
return 1;
return 1; else
return 0;
} }
return -1; return -1;
} }
int Gui_getViewCoords(DFHackObject* pos, int32_t* x, int32_t* y, int32_t* z) int Gui_getCursorCoords(DFHackObject* gui, int32_t* x, int32_t* y, int32_t* z)
{
if(pos != NULL)
{
int32_t tx, ty, tz;
if(((DFHack::Gui*)pos)->getViewCoords(tx, ty, tz))
{
*x = tx;
*y = ty;
*z = tz;
return 1;
}
else
return 0;
}
return -1;
}
int Gui_setViewCoords(DFHackObject* pos, int32_t x, int32_t y, int32_t z)
{
if(pos != NULL)
{
if(((DFHack::Gui*)pos)->setViewCoords(x, y, z))
return 1;
else
return 0;
}
return -1;
}
int Gui_getCursorCoords(DFHackObject* pos, int32_t* x, int32_t* y, int32_t* z)
{ {
if(pos != NULL) if(gui != NULL)
{ {
int32_t tx, ty, tz; int32_t tx, ty, tz;
if(((DFHack::Gui*)pos)->getCursorCoords(tx, ty, tz)) if(((DFHack::Gui*)gui)->getCursorCoords(tx, ty, tz))
{ {
*x = tx; *x = tx;
*y = ty; *y = ty;
*z = tz; *z = tz;
return 1; return 1;
} }
else else
return 0; return 0;
} }
return -1; return -1;
} }
int Gui_setCursorCoords(DFHackObject* pos, int32_t x, int32_t y, int32_t z) int Gui_setCursorCoords(DFHackObject* gui, int32_t x, int32_t y, int32_t z)
{ {
if(pos != NULL) if(gui != NULL)
{ {
if(((DFHack::Gui*)pos)->setCursorCoords(x, y, z)) if(((DFHack::Gui*)gui)->setCursorCoords(x, y, z))
return 1; return 1;
else else
return 0; return 0;
} }
return -1; return -1;
} }
t_hotkey* Gui_ReadHotkeys(DFHackObject* pos) t_hotkey* Gui_ReadHotkeys(DFHackObject* gui)
{ {
if(pos != NULL) if(gui != NULL)
{ {
t_hotkey* buf = NULL; t_hotkey* buf;
(*alloc_hotkey_buffer_callback)(&buf, NUM_HOTKEYS); (*alloc_t_hotkey_buffer_callback)(&buf, NUM_HOTKEYS);
if(buf != NULL) if(buf != NULL)
{ {
if(((DFHack::Gui*)pos)->ReadHotkeys(buf)) if(((DFHack::Gui*)gui)->ReadHotkeys(buf))
return buf; return buf;
else else
return NULL; return NULL;
} }
else else
return NULL; return NULL;
} }
return NULL; return NULL;
} }
int Gui_getWindowSize(DFHackObject* pos, int32_t* width, int32_t* height) int Gui_getWindowSize(DFHackObject* gui, int32_t* width, int32_t* height)
{ {
if(pos != NULL) if(gui != NULL)
{ {
int32_t tw, th; int32_t tw, th;
if(((DFHack::Gui*)pos)->getWindowSize(tw, th)) if(((DFHack::Gui*)gui)->getWindowSize(tw, th))
{ {
*width = tw; *width = tw;
*height = th; *height = th;
@ -181,26 +158,47 @@ int Gui_getWindowSize(DFHackObject* pos, int32_t* width, int32_t* height)
return -1; return -1;
} }
t_screen* Gui_getScreenTiles(DFHackObject* pos, int32_t width, int32_t height) t_screen* Gui_getScreenTiles(DFHackObject* gui, int32_t width, int32_t height)
{ {
if(pos != NULL) if(gui != NULL)
{ {
t_screen* buf = NULL; t_screen* buf;
(*alloc_screen_buffer_callback)(&buf, width * height); (*alloc_t_screen_buffer_callback)(&buf, width * height);
if(buf == NULL) if(buf == NULL)
return NULL; return NULL;
if(((DFHack::Gui*)pos)->getScreenTiles(width, height, buf)) if(((DFHack::Gui*)gui)->getScreenTiles(width, height, buf))
return buf; return buf;
else else
return NULL; return NULL;
} }
return NULL; return NULL;
} }
int Gui_ReadViewScreen(DFHackObject* gui, t_viewscreen* viewscreen)
{
if(gui != NULL)
{
return ((DFHack::Gui*)gui)->ReadViewScreen(*viewscreen);
}
return -1;
}
int Gui_ReadMenuState(DFHackObject* gui, uint32_t* menuState)
{
if(gui != NULL)
{
*menuState = ((DFHack::Gui*)gui)->ReadMenuState();
return 1;
}
return -1;
}
#ifdef __cplusplus #ifdef __cplusplus
} }