|
|
@ -1,22 +1,31 @@
|
|
|
|
from ctypes import *
|
|
|
|
from ctypes import c_void_p, c_int, c_uint, byref
|
|
|
|
from pydfhack import libdfhack, ViewScreen
|
|
|
|
from dftypes import libdfhack, ViewScreen, Hotkey
|
|
|
|
|
|
|
|
from util import check_pointer_cache
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
libdfhack.Gui_getViewCoords.argtypes = [ c_void_p, POINTER(c_int), POINTER(c_int), POINTER(c_int) ]
|
|
|
|
|
|
|
|
libdfhack.Gui_setViewCoords.argtypes = [ c_void_p, c_int, c_int, c_int ]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
libdfhack.Gui_getCursorCoords.argtypes = [ c_void_p, POINTER(c_int), POINTER(c_int), POINTER(c_int) ]
|
|
|
|
|
|
|
|
libdfhack.Gui_setCursorCoords.argtypes = [ c_void_p, c_int, c_int, c_int ]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
libdfhack.Gui_getWindowSize.argtypes = [ c_void_p, POINTER(c_int), POINTER(c_int) ]
|
|
|
|
|
|
|
|
|
|
|
|
libdfhack.Gui_ReadHotkeys.restype = c_void_p
|
|
|
|
|
|
|
|
libdfhack.Gui_ReadViewScreen.argtypes = [ c_void_p, c_void_p ]
|
|
|
|
libdfhack.Gui_ReadViewScreen.argtypes = [ c_void_p, c_void_p ]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
libdfhack.Gui_ReadHotkeys.restype = c_void_p
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
libdfhack.Gui_getScreenTiles.argtypes = [ c_void_p, c_int, c_int ]
|
|
|
|
|
|
|
|
libdfhack.Gui_getScreenTiles.restype = c_void_p
|
|
|
|
|
|
|
|
|
|
|
|
class Gui(object):
|
|
|
|
class Gui(object):
|
|
|
|
def __init__(self, ptr):
|
|
|
|
def __init__(self, ptr):
|
|
|
|
self._gui_ptr = ptr
|
|
|
|
self._gui_ptr = ptr
|
|
|
|
|
|
|
|
|
|
|
|
self._vx, self._vy, self._vz = c_int(), c_int(), c_int()
|
|
|
|
|
|
|
|
self._cx, self._cy, self._cz = c_int(), c_int(), c_int()
|
|
|
|
|
|
|
|
self._ww, self._wh = c_int(), c_int()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def start(self):
|
|
|
|
def start(self):
|
|
|
|
return libdfhack.Gui_Start(self._gui_ptr)
|
|
|
|
return libdfhack.Gui_Start(self._gui_ptr) > 0
|
|
|
|
|
|
|
|
|
|
|
|
def finish(self):
|
|
|
|
def finish(self):
|
|
|
|
return libdfhack.Gui_Finish(self._gui_ptr)
|
|
|
|
return libdfhack.Gui_Finish(self._gui_ptr) > 0
|
|
|
|
|
|
|
|
|
|
|
|
def read_view_screen(self):
|
|
|
|
def read_view_screen(self):
|
|
|
|
s = ViewScreen()
|
|
|
|
s = ViewScreen()
|
|
|
@ -27,37 +36,38 @@ class Gui(object):
|
|
|
|
return None
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
def get_view_coords(self):
|
|
|
|
def get_view_coords(self):
|
|
|
|
if libdfhack.Gui_getViewCoords(self._gui_ptr, byref(self._vx), byref(self._vy), byref(self._vz)) > 0:
|
|
|
|
x, y, z = (0, 0, 0)
|
|
|
|
return (self._vx.value, self._vy.value, self._vz.value)
|
|
|
|
|
|
|
|
|
|
|
|
if libdfhack.Gui_getViewCoords(self._gui_ptr, byref(x), byref(y), byref(z)) > 0:
|
|
|
|
|
|
|
|
return (x, y, z)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return (-1, -1, -1)
|
|
|
|
return (-1, -1, -1)
|
|
|
|
|
|
|
|
|
|
|
|
def set_view_coords(self, v_coords):
|
|
|
|
def set_view_coords(self, x, y, z):
|
|
|
|
self._vx.value, self._vy.value, self._vz.value = v_coords
|
|
|
|
libdfhack.Gui_setViewCoords(self._gui_ptr, x, y, z)
|
|
|
|
|
|
|
|
|
|
|
|
libdfhack.Gui_setViewCoords(self._gui_ptr, self._vx, self._vy, self._vz)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
view_coords = property(get_view_coords, set_view_coords)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_cursor_coords(self):
|
|
|
|
def get_cursor_coords(self):
|
|
|
|
if libdfhack.Gui_getCursorCoords(self._gui_ptr, byref(self._cx), byref(self._cy), byref(self._cz)) > 0:
|
|
|
|
x, y, z = (0, 0, 0)
|
|
|
|
return (self._cx.value, self._cy.value, self._cz.value)
|
|
|
|
|
|
|
|
|
|
|
|
if libdfhack.Gui_getCursorCoords(self._gui_ptr, byref(x), byref(y), byref(z)) > 0:
|
|
|
|
|
|
|
|
return (x, y, z)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return (-1, -1, -1)
|
|
|
|
return (-1, -1, -1)
|
|
|
|
|
|
|
|
|
|
|
|
def set_cursor_coords(self, c_coords):
|
|
|
|
def set_cursor_coords(self, x, y, z):
|
|
|
|
self._cx.value, self._cy.value, self_cz.value = c_coords
|
|
|
|
libdfhack.Gui_setCursorCoords(self._gui_ptr, x, y, z)
|
|
|
|
|
|
|
|
|
|
|
|
libdfhack.Gui_setCursorCoords(self._gui_ptr, self._cx, self._cy, self._cz)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cursor_coords = property(get_cursor_coords, set_cursor_coords)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def read_hotkeys(self):
|
|
|
|
def read_hotkeys(self):
|
|
|
|
return check_pointer_cache(libdfhack.Gui_ReadHotkeys(self._gui_ptr))
|
|
|
|
return check_pointer_cache(libdfhack.Gui_ReadHotkeys(self._gui_ptr))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_screen_tiles(self, width, height):
|
|
|
|
|
|
|
|
return check_pointer_cache(libdfhack.Gui_getScreenTiles(self._gui_ptr, width, height))
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
@property
|
|
|
|
def window_size(self):
|
|
|
|
def window_size(self):
|
|
|
|
if libdfhack.Gui_getWindowSize(self._gui_ptr, byref(self._ww), byref(self._wh)) > 0:
|
|
|
|
width, height = (0, 0)
|
|
|
|
return (self._ww.value, self._wh.value)
|
|
|
|
|
|
|
|
|
|
|
|
if libdfhack.Gui_getWindowSize(self._gui_ptr, byref(width), byref(height)) > 0:
|
|
|
|
|
|
|
|
return (width, height)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return (-1, -1)
|
|
|
|
return (-1, -1)
|
|
|
|