|
|
@ -2,17 +2,6 @@ from ctypes import *
|
|
|
|
from dftypes import libdfhack
|
|
|
|
from dftypes import libdfhack
|
|
|
|
from util import *
|
|
|
|
from util import *
|
|
|
|
|
|
|
|
|
|
|
|
_get_arg_types = [ c_void_p, _arr_create_func ]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
libdfhack.Materials_getInorganic.argtypes = _get_arg_types
|
|
|
|
|
|
|
|
libdfhack.Materials_getOrganic.argtypes = _get_arg_types
|
|
|
|
|
|
|
|
libdfhack.Materials_getTree.argtypes = _get_arg_types
|
|
|
|
|
|
|
|
libdfhack.Materials_getPlant.argtypes = _get_arg_types
|
|
|
|
|
|
|
|
libdfhack.Materials_getRace.argtypes = _get_arg_types
|
|
|
|
|
|
|
|
#libdfhack.Materials_getRaceEx.argtypes = _get_arg_types
|
|
|
|
|
|
|
|
libdfhack.Materials_getColor.argtypes = _get_arg_types
|
|
|
|
|
|
|
|
libdfhack.Materials_getOther.argtypes = _get_arg_types
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Materials(object):
|
|
|
|
class Materials(object):
|
|
|
|
def __init__(self, ptr):
|
|
|
|
def __init__(self, ptr):
|
|
|
|
self._mat_ptr = ptr
|
|
|
|
self._mat_ptr = ptr
|
|
|
@ -26,116 +15,134 @@ class Materials(object):
|
|
|
|
self.color = None
|
|
|
|
self.color = None
|
|
|
|
self.other = None
|
|
|
|
self.other = None
|
|
|
|
|
|
|
|
|
|
|
|
def read_inorganic(self):
|
|
|
|
def _get_inorganic(self):
|
|
|
|
return libdfhack.Materials_ReadInorganicMaterials(self._mat_ptr)
|
|
|
|
self.inorganic = libdfhack.Materials_getInorganic(self._mat_ptr)
|
|
|
|
|
|
|
|
def _get_organic(self):
|
|
|
|
def read_organic(self):
|
|
|
|
self.organic = libdfhack.Materials_getOrganic(self._mat_ptr)
|
|
|
|
return libdfhack.Materials_ReadOrganicMaterials(self._mat_ptr)
|
|
|
|
def _get_tree(self):
|
|
|
|
|
|
|
|
self.tree = libdfhack.Materials_getTree(self._mat_ptr)
|
|
|
|
def read_wood(self):
|
|
|
|
def _get_plant(self):
|
|
|
|
return libdfhack.Materials_ReadWoodMaterials(self._mat_ptr)
|
|
|
|
self.plant = libdfhack.Materials_getPlant(self._mat_ptr)
|
|
|
|
|
|
|
|
def _get_race(self):
|
|
|
|
def read_plant(self):
|
|
|
|
self.race = libdfhack.Materials_getRace(self._mat_ptr)
|
|
|
|
return libdfhack.Materials_ReadPlantMaterials(self._mat_ptr)
|
|
|
|
def _get_race_ex(self):
|
|
|
|
|
|
|
|
self.race_ex = libdfhack.Materials_getRaceEx(self._mat_ptr)
|
|
|
|
def read_creature_types(self):
|
|
|
|
def _get_color(self):
|
|
|
|
return libdfhack.Materials_ReadCreatureTypes(self._mat_ptr)
|
|
|
|
self.color = libdfhack.Materials_getColor(self._mat_ptr)
|
|
|
|
|
|
|
|
def _get_other(self):
|
|
|
|
def read_creature_types_ex(self):
|
|
|
|
self.other = libdfhack.Materials_getOther(self._mat_ptr)
|
|
|
|
return libdfhack.Materials_ReadCreatureTypesEx(self._mat_ptr)
|
|
|
|
|
|
|
|
|
|
|
|
def _get_all(self):
|
|
|
|
def read_descriptor_colors(self):
|
|
|
|
self._get_inorganic()
|
|
|
|
return libdfhack.Materials_ReadDescriptorColors(self._mat_ptr)
|
|
|
|
self._get_organic()
|
|
|
|
|
|
|
|
self._get_tree()
|
|
|
|
def read_others(self):
|
|
|
|
self._get_plant()
|
|
|
|
return libdfhack.Materials_ReadOthers(self._mat_ptr)
|
|
|
|
self._get_race()
|
|
|
|
|
|
|
|
self._get_race_ex()
|
|
|
|
def read_all(self):
|
|
|
|
self._get_color()
|
|
|
|
libdfhack.Materials_ReadAllMaterials(self._mat_ptr)
|
|
|
|
self._get_other()
|
|
|
|
|
|
|
|
def _clear_all(self):
|
|
|
|
def get_description(self, material):
|
|
|
|
self.inorganic = None
|
|
|
|
return libdfhack.Materials_getDescription(self._mat_ptr, byref(material))
|
|
|
|
self.organic = None
|
|
|
|
|
|
|
|
self.tree = None
|
|
|
|
def update_inorganic_cache(self):
|
|
|
|
self.plant = None
|
|
|
|
def update_callback(count):
|
|
|
|
self.race = None
|
|
|
|
allocated = _allocate_array(Matgloss, count)
|
|
|
|
self.race_ex = None
|
|
|
|
|
|
|
|
self.color = None
|
|
|
|
self.inorganic = allocated[0]
|
|
|
|
self.other = None
|
|
|
|
|
|
|
|
|
|
|
|
return allocated[1]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
callback = _arr_create_func(update_callback)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return libdfhack.Materials_getInorganic(self._mat_ptr, callback)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def update_organic_cache(self):
|
|
|
|
|
|
|
|
def update_callback(count):
|
|
|
|
|
|
|
|
allocated = _allocate_array(Matgloss, count)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.organic = allocated[0]
|
|
|
|
def read_inorganic(self):
|
|
|
|
|
|
|
|
result = libdfhack.Materials_ReadInorganicMaterials(self._mat_ptr) > 0
|
|
|
|
|
|
|
|
|
|
|
|
return allocated[1]
|
|
|
|
if result == True:
|
|
|
|
|
|
|
|
self._get_inorganic()
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
self.inorganic = None
|
|
|
|
|
|
|
|
|
|
|
|
callback = _arr_create_func(update_callback)
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
return libdfhack.Materials_getOrganic(self._mat_ptr, callback)
|
|
|
|
def read_organic(self):
|
|
|
|
|
|
|
|
result = libdfhack.Materials_ReadOrganicMaterials(self._mat_ptr) > 0
|
|
|
|
|
|
|
|
|
|
|
|
def update_tree_cache(self):
|
|
|
|
if result == True:
|
|
|
|
def update_callback(count):
|
|
|
|
self._get_organic()
|
|
|
|
allocated = _allocate_array(Matgloss, count)
|
|
|
|
else:
|
|
|
|
|
|
|
|
self.organic = None
|
|
|
|
|
|
|
|
|
|
|
|
self.tree = allocated[0]
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
return allocated[1]
|
|
|
|
def read_tree(self):
|
|
|
|
|
|
|
|
result = libdfhack.Materials_ReadWoodMaterials(self._mat_ptr) > 0
|
|
|
|
|
|
|
|
|
|
|
|
callback = _arr_create_func(update_callback)
|
|
|
|
if result == True:
|
|
|
|
|
|
|
|
self._get_tree()
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
self.tree = None
|
|
|
|
|
|
|
|
|
|
|
|
return libdfhack.Materials_getTree(self._mat_ptr, callback)
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
def update_plant_cache(self):
|
|
|
|
def read_plant(self):
|
|
|
|
def update_callback(count):
|
|
|
|
result = libdfhack.Materials_ReadPlantMaterials(self._mat_ptr) > 0
|
|
|
|
allocated = _allocate_array(Matgloss, count)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.plant = allocated[0]
|
|
|
|
if result == True:
|
|
|
|
|
|
|
|
self._get_plant()
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
self.plant = None
|
|
|
|
|
|
|
|
|
|
|
|
return allocated[1]
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
callback = _arr_create_func(update_callback)
|
|
|
|
def read_creature_types(self):
|
|
|
|
|
|
|
|
result = libdfhack.Materials_ReadCreatureTypes(self._mat_ptr) > 0
|
|
|
|
|
|
|
|
|
|
|
|
return libdfhack.Materials_getPlant(self._mat_ptr, callback)
|
|
|
|
if result == True:
|
|
|
|
|
|
|
|
self._get_race()
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
self.race = None
|
|
|
|
|
|
|
|
|
|
|
|
def update_race_cache(self):
|
|
|
|
return result
|
|
|
|
def update_callback(count):
|
|
|
|
|
|
|
|
allocated = _allocate_array(Matgloss, count)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.race = allocated[0]
|
|
|
|
def read_creature_types_ex(self):
|
|
|
|
|
|
|
|
result = libdfhack.Materials_ReadCreatureTypesEx(self._mat_ptr) > 0
|
|
|
|
|
|
|
|
|
|
|
|
return allocated[1]
|
|
|
|
if result == True:
|
|
|
|
|
|
|
|
self._get_race_ex()
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
self.race_ex = None
|
|
|
|
|
|
|
|
|
|
|
|
callback = _arr_create_func(update_callback)
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
return libdfhack.Materials_getRace(self._mat_ptr, callback)
|
|
|
|
def read_descriptor_colors(self):
|
|
|
|
|
|
|
|
result = libdfhack.Materials_ReadDescriptorColors(self._mat_ptr) > 0
|
|
|
|
|
|
|
|
|
|
|
|
def update_color_cache(self):
|
|
|
|
if result == True:
|
|
|
|
def update_callback(count):
|
|
|
|
self._get_color()
|
|
|
|
allocated = _allocate_array(DescriptorColor, count)
|
|
|
|
else:
|
|
|
|
|
|
|
|
self.color = None
|
|
|
|
|
|
|
|
|
|
|
|
self.color = allocated[0]
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
return allocated[1]
|
|
|
|
def read_others(self):
|
|
|
|
|
|
|
|
result = libdfhack.Materials_ReadOthers(self._mat_ptr) > 0
|
|
|
|
|
|
|
|
|
|
|
|
callback = _arr_create_func(update_callback)
|
|
|
|
if result == True:
|
|
|
|
|
|
|
|
self._get_other()
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
self.other = None
|
|
|
|
|
|
|
|
|
|
|
|
return libdfhack.Materials_getColor(self._mat_ptr, callback)
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
def update_other_cache(self):
|
|
|
|
def read_all(self):
|
|
|
|
def update_callback(count):
|
|
|
|
result = libdfhack.Materials_ReadAllMaterials(self._mat_ptr) > 0
|
|
|
|
allocated = _allocate_array(MatglossOther, count)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.other = allocated[0]
|
|
|
|
if result == True:
|
|
|
|
|
|
|
|
self._get_all()
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
self._clear_all()
|
|
|
|
|
|
|
|
|
|
|
|
return allocated[1]
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
callback = _arr_create_func(update_callback)
|
|
|
|
def get_type(self, material):
|
|
|
|
|
|
|
|
return libdfhack.Materials_getType(self._mat_ptr, byref(material))
|
|
|
|
|
|
|
|
|
|
|
|
return libdfhack.Materials_getOther(self._mat_ptr, callback)
|
|
|
|
def get_description(self, material):
|
|
|
|
|
|
|
|
return libdfhack.Materials_getDescription(self._mat_ptr, byref(material))
|