UFO: Alien Invasion
Loading...
Searching...
No Matches
ui_sprite.cpp File Reference
#include "ui_main.h"
#include "ui_internal.h"
#include "ui_parse.h"
#include "ui_sprite.h"
#include "ui_render.h"
Include dependency graph for ui_sprite.cpp:

Go to the source code of this file.

Functions

static uiSprite_tUI_AutoGenerateSprite (const char *name)
 Search a file name inside pics/ according to the sprite name If it exists, generate a "single" sprite using the size of the image.
static bool UI_SpriteExists (const char *name)
 Check if an sprite name exists.
uiSprite_tUI_GetSpriteByName (const char *name)
 Return an sprite by is name.
uiSprite_tUI_AllocStaticSprite (const char *name)
 Allocate an sprite to the UI static memory.
void UI_DrawSpriteInBox (bool flip, const uiSprite_t *sprite, uiSpriteStatus_t status, int posX, int posY, int sizeX, int sizeY)

Variables

const value_t ui_spriteProperties []
static const int tile_template_17_1_3 []
static const int tile_template_25_1_3 []
static const int tile_template_popup []

Function Documentation

◆ UI_AllocStaticSprite()

uiSprite_t * UI_AllocStaticSprite ( const char * name)

Allocate an sprite to the UI static memory.

Note
Its not a dynamic memory allocation. Please only use it at the loading time
Parameters
[in]nameName of the sprite
Todo
Assert out when we are not in parsing/loading stage

Definition at line 130 of file ui_sprite.cpp.

References Com_Error(), ERR_FATAL, name, uiSprite_t::name, OBJZERO, Q_strncpyz(), ui_global, UI_MAX_SPRITES, and UI_SpriteExists().

Referenced by UI_AutoGenerateSprite(), and UI_ParseSprite().

◆ UI_AutoGenerateSprite()

uiSprite_t * UI_AutoGenerateSprite ( const char * name)
static

Search a file name inside pics/ according to the sprite name If it exists, generate a "single" sprite using the size of the image.

Parameters
nameName of the sprite
Returns
A sprite, else nullptr

Definition at line 65 of file ui_sprite.cpp.

References Com_sprintf(), image_t::height, i, uiSprite_t::image, MAX_QPATH, name, Q_strncpyz(), uiSprite_t::size, SPRITE_STATUS_MAX, SPRITE_STATUS_NORMAL, UI_AllocStaticSprite(), UI_AllocStaticString(), UI_LoadImage(), and image_t::width.

Referenced by UI_GetSpriteByName().

◆ UI_DrawSpriteInBox()

void UI_DrawSpriteInBox ( bool flip,
const uiSprite_t * sprite,
uiSpriteStatus_t status,
int posX,
int posY,
int sizeX,
int sizeY )

◆ UI_GetSpriteByName()

◆ UI_SpriteExists()

bool UI_SpriteExists ( const char * name)
static

Check if an sprite name exists.

Parameters
[in]nameName of the sprite
Returns
True if the sprite exists
Note
not very fast; if we use it often we should improve the search

Definition at line 99 of file ui_sprite.cpp.

References i, MEMBER_SIZEOF, name, and ui_global.

Referenced by UI_AllocStaticSprite().

Variable Documentation

◆ tile_template_17_1_3

const int tile_template_17_1_3[]
static
Initial value:
= {
17, 1, 17,
17, 1, 17,
3
}

Template to draw a tiled texture with corner size of 17 pixels, middle size of 1 pixel, margin between tiles of 3 pixels

Definition at line 153 of file ui_sprite.cpp.

Referenced by UI_DrawSpriteInBox().

◆ tile_template_25_1_3

const int tile_template_25_1_3[]
static
Initial value:
= {
25, 1, 25,
25, 1, 25,
3
}

Template to draw a tiled texture with corner size of 17 pixels, middle size of 1 pixel, margin between tiles of 3 pixels

Definition at line 164 of file ui_sprite.cpp.

Referenced by UI_DrawSpriteInBox().

◆ tile_template_popup

const int tile_template_popup[]
static
Initial value:
= {
20, 1, 19,
46, 1, 19,
3
}

Template to draw a tiled texture with used for popup windows

Definition at line 174 of file ui_sprite.cpp.

Referenced by UI_DrawSpriteInBox().

◆ ui_spriteProperties

const value_t ui_spriteProperties[]
Initial value:
= {
{"size", V_POS, offsetof(uiSprite_t, size), MEMBER_SIZEOF(uiSprite_t, size)},
{"single", V_BOOL, offsetof(uiSprite_t, single), 0},
{"blend", V_BOOL, offsetof(uiSprite_t, blend), 0},
{"pack64", V_BOOL, offsetof(uiSprite_t, pack64), 0},
{"tiled_17_1_3", V_BOOL, offsetof(uiSprite_t, tiled_17_1_3), 0},
{"tiled_25_1_3", V_BOOL, offsetof(uiSprite_t, tiled_25_1_3), 0},
{"tiled_popup", V_BOOL, offsetof(uiSprite_t, tiled_popup), 0},
{"border", V_INT, offsetof(uiSprite_t, border), MEMBER_SIZEOF(uiSprite_t, border)},
{"texl", V_POS, offsetof(uiSprite_t, pos[SPRITE_STATUS_NORMAL]), MEMBER_SIZEOF(uiSprite_t, pos[SPRITE_STATUS_NORMAL])},
{"hoveredtexl", V_POS, offsetof(uiSprite_t, pos[SPRITE_STATUS_HOVER]), MEMBER_SIZEOF(uiSprite_t, pos[SPRITE_STATUS_HOVER])},
{"disabledtexl", V_POS, offsetof(uiSprite_t, pos[SPRITE_STATUS_DISABLED]), MEMBER_SIZEOF(uiSprite_t, pos[SPRITE_STATUS_DISABLED])},
{"clickedtexl", V_POS, offsetof(uiSprite_t, pos[SPRITE_STATUS_CLICKED]), MEMBER_SIZEOF(uiSprite_t, pos[SPRITE_STATUS_CLICKED])},
{"image", (valueTypes_t)V_REF_OF_STRING, offsetof(uiSprite_t, image[SPRITE_STATUS_NORMAL]), 0},
{"hoveredimage", (valueTypes_t)V_REF_OF_STRING, offsetof(uiSprite_t, image[SPRITE_STATUS_HOVER]), 0},
{"disabledimage", (valueTypes_t)V_REF_OF_STRING, offsetof(uiSprite_t, image[SPRITE_STATUS_DISABLED]), 0},
{"clickedimage", (valueTypes_t)V_REF_OF_STRING, offsetof(uiSprite_t, image[SPRITE_STATUS_CLICKED]), 0},
{"color", V_COLOR, offsetof(uiSprite_t, color[SPRITE_STATUS_NORMAL]), MEMBER_SIZEOF(uiSprite_t, color[SPRITE_STATUS_NORMAL])},
{"hoveredcolor", V_COLOR, offsetof(uiSprite_t, color[SPRITE_STATUS_HOVER]), MEMBER_SIZEOF(uiSprite_t, color[SPRITE_STATUS_HOVER])},
{"disabledcolor", V_COLOR, offsetof(uiSprite_t, color[SPRITE_STATUS_DISABLED]), MEMBER_SIZEOF(uiSprite_t, color[SPRITE_STATUS_DISABLED])},
{"clickedcolor", V_COLOR, offsetof(uiSprite_t, color[SPRITE_STATUS_CLICKED]), MEMBER_SIZEOF(uiSprite_t, color[SPRITE_STATUS_CLICKED])},
{nullptr, V_NULL, 0, 0}
}
voidpf void uLong size
Definition ioapi.h:42
valueTypes_t
possible values for parsing functions
Definition scripts.h:48
@ V_BOOL
Definition scripts.h:50
@ V_NULL
Definition scripts.h:49
@ V_INT
Definition scripts.h:52
@ V_COLOR
Definition scripts.h:57
@ V_POS
Definition scripts.h:55
#define MEMBER_SIZEOF(TYPE, MEMBER)
Definition scripts.h:34
#define V_REF_OF_STRING
Definition ui_parse.h:71
@ SPRITE_STATUS_DISABLED
Definition ui_sprite.h:35
@ SPRITE_STATUS_HOVER
Definition ui_sprite.h:34
@ SPRITE_STATUS_CLICKED
Definition ui_sprite.h:36
@ SPRITE_STATUS_NORMAL
Definition ui_sprite.h:33

Definition at line 31 of file ui_sprite.cpp.

Referenced by UI_ParseSprite().