20#define SP_XML_ID "slot"
25typedef struct SlotProperty_s {
41static int sp_check(
unsigned int spid );
52 for (
int i = 0; i <
array_size( sp_files ); i++ ) {
63 node = doc->xmlChildrenNode;
65 WARN( _(
"Malformed '%s' file: missing root element '%s'" ),
72 xmlr_attr_strd( node,
"name", sp->
name );
73 cur = node->xmlChildrenNode;
78 xmlr_strd( cur,
"display", sp->
display );
80 if ( xml_isNode( cur,
"required" ) ) {
84 if ( xml_isNode( cur,
"exclusive" ) ) {
88 if ( xml_isNode( cur,
"locked" ) ) {
92 if ( xml_isNode( cur,
"visible" ) ) {
96 if ( xml_isNode( cur,
"icon" ) ) {
97 char path[STRMAX_SHORT];
98 snprintf( path,
sizeof( path ),
"gfx/slots/%s", xml_get( cur ) );
103 WARN( _(
"Slot Property '%s' has unknown node '%s'." ), node->name,
105 }
while ( xml_nextNode( cur ) );
111 for (
int i = 0; i <
array_size( sp_files ); i++ )
145 if ( strcmp( sp->
name, name ) == 0 )
148 WARN( _(
"Slot property '%s' not found in array." ), name );
179 return sp_array[spid - 1].description;
199 return sp_array[spid - 1].exclusive;
Provides macros to work with dynamic arrays.
#define array_free(ptr_array)
Frees memory allocated and sets array to NULL.
static ALWAYS_INLINE int array_size(const void *array)
Returns number of elements in the array.
#define array_grow(ptr_array)
Increases the number of elements by one and returns the last element.
#define array_create(basic_type)
Creates a new dynamic array of ‘basic_type’.
Header file with generic functions and naev-specifics.
char ** ndata_listRecursive(const char *path)
Lists all the visible files in a directory, at any depth.
glTexture * xml_parseTexture(xmlNodePtr node, const char *path, int defsx, int defsy, const unsigned int flags)
Parses a texture handling the sx and sy elements.
xmlDocPtr xml_parsePhysFS(const char *filename)
Analogous to xmlParseMemory/xmlParseFile.
void gl_freeTexture(glTexture *texture)
Frees a texture.
int sp_locked(unsigned int spid)
Gets whether or not a slot property is locked.
unsigned int sp_get(const char *name)
Gets the id of a slot property.
const char * sp_description(unsigned int spid)
Gets the description of a slot property (in English).
void sp_cleanup(void)
Cleans up after the slot properties.
static int sp_check(unsigned int spid)
Checks to see if in bound of array.
int sp_load(void)
Initializes the slot properties.
const glTexture * sp_icon(unsigned int spid)
Gets the icon associated with the slot.
const char * sp_display(unsigned int spid)
Gets the display name of a slot property (in English).
int sp_required(unsigned int spid)
Gets whether or not a slot property is required.
int sp_exclusive(unsigned int spid)
Gets whether or not a slot property is exclusive.
int sp_visible(unsigned int spid)
Whether or not the slot should be visible even if locked.
static SlotProperty_t * sp_array
Representation of a slot property.
Abstraction for rendering sprite sheets.