Atrinik Client  4.0
Enumerations | Functions | Variables
spells.c File Reference
#include <global.h>

Go to the source code of this file.

Enumerations

enum  {
  BUTTON_PATH_LEFT, BUTTON_PATH_RIGHT, BUTTON_CLOSE, BUTTON_HELP,
  BUTTON_NUM
}
 

Functions

void spells_init (void)
 
void spells_deinit (void)
 
static void list_handle_enter (list_struct *list, SDL_Event *event)
 
static void spell_list_reload (void)
 
static void button_repeat_func (button_struct *button)
 
int spell_find (const char *name, size_t *spell_path, size_t *spell_id)
 
int spell_find_object (object *op, size_t *spell_path, size_t *spell_id)
 
static spell_entry_structspell_find_path_selected (const char *name)
 
spell_entry_structspell_get (size_t spell_path, size_t spell_id)
 
void spells_update (object *op, uint16_t cost, uint32_t path, uint32_t flags, const char *msg)
 
void spells_remove (object *op)
 
static void widget_draw (widgetdata *widget)
 
static void widget_background (widgetdata *widget, int draw)
 
static int widget_event (widgetdata *widget, SDL_Event *event)
 
static void widget_deinit (widgetdata *widget)
 
void widget_spells_init (widgetdata *widget)
 

Variables

static spell_entry_struct ** spell_list [SPELL_PATH_NUM-1]
 
static size_t spell_list_num [SPELL_PATH_NUM]
 
static size_t spell_list_path = 0
 
static button_struct buttons [BUTTON_NUM]
 
static list_structlist_spells = NULL
 

Detailed Description

Implements spells type widgets.

Author
Alex Tokar

Definition in file spells.c.

Function Documentation

static void button_repeat_func ( button_struct button)
static

Handle button repeating (and actual pressing).

Parameters
buttonThe button.

Definition at line 167 of file spells.c.

static void list_handle_enter ( list_struct list,
SDL_Event *  event 
)
static

Handle double click inside the spells list.

Parameters
listThe spells list.

Definition at line 104 of file spells.c.

int spell_find ( const char *  name,
size_t *  spell_path,
size_t *  spell_id 
)

Find a spell in the spell_list based on its name.

Partial spell names will be matched.

Parameters
nameSpell name to find.
[out]spell_pathWill contain the spell's path.
[out]spell_idWill contain the spell's ID.
Returns
1 if the spell was found, 0 otherwise.

Definition at line 198 of file spells.c.

int spell_find_object ( object op,
size_t *  spell_path,
size_t *  spell_id 
)

Find a spell in the spell_list, based on a matching object.

Parameters
opObject to find.
[out]spell_pathWill contain the spell's path.
[out]spell_idWill contain the spell's ID.
Returns
1 if the spell was found, 0 otherwise.

Definition at line 230 of file spells.c.

static spell_entry_struct* spell_find_path_selected ( const char *  name)
static

Find a spell in the spell_list based on its name, but only look inside the currently selected spell path list.

Partial spell names will be matched.

Parameters
nameSpell name to find.
Returns
The spell if found, NULL otherwise.

Definition at line 254 of file spells.c.

spell_entry_struct* spell_get ( size_t  spell_path,
size_t  spell_id 
)

Get spell from the spell_list structure.

Parameters
spell_pathSpell path.
spell_idSpell ID.
Returns
The spell.

Definition at line 294 of file spells.c.

static void spell_list_reload ( void  )
static

Reload the spells list, due to a change of the spell path, filtering options, etc.

Definition at line 123 of file spells.c.

void spells_deinit ( void  )

Deinitialize the spells system.

Definition at line 85 of file spells.c.

void spells_init ( void  )

Initialize the spells system.

Definition at line 74 of file spells.c.

static void widget_background ( widgetdata widget,
int  draw 
)
static

Definition at line 499 of file spells.c.

static void widget_deinit ( widgetdata widget)
static

Definition at line 583 of file spells.c.

static void widget_draw ( widgetdata widget)
static

Definition at line 371 of file spells.c.

static int widget_event ( widgetdata widget,
SDL_Event *  event 
)
static

Definition at line 518 of file spells.c.

void widget_spells_init ( widgetdata widget)

Initialize one spells widget.

Definition at line 598 of file spells.c.

Variable Documentation

button_struct buttons[BUTTON_NUM]
static

Button buffer.

Definition at line 65 of file spells.c.

list_struct* list_spells = NULL
static

The spells list.

Definition at line 69 of file spells.c.

spell_entry_struct** spell_list[SPELL_PATH_NUM-1]
static

The spell list. This is a multi-dimensional array, containing dynamically resized spell path arrays, which actually hold the spells for each spell path. For example (pseudo array structure):

  • spell_list:
    • fire
      • firestorm, firebolt

Definition at line 43 of file spells.c.

size_t spell_list_num[SPELL_PATH_NUM]
static

Number of spells contained in each spell path array in spell_list

Definition at line 47 of file spells.c.

size_t spell_list_path = 0
static

Currently selected spell path ID.

Definition at line 51 of file spells.c.