ui_data.c File Reference

#include "../client.h"
#include "ui_main.h"
#include "ui_internal.h"
#include "ui_nodes.h"
#include "node/ui_node_linechart.h"
#include "node/ui_node_option.h"
Include dependency graph for ui_data.c:

Go to the source code of this file.

Functions

 CASSERT (lengthof(ui_sharedDataIDNames)==UI_MAX_DATAID)
int UI_GetDataIDByName (const char *name)
 Return a dataId by name.
void UI_RegisterText (int dataId, const char *text)
 share a text with a data id
void UI_RegisterLinkedListText (int dataId, linkedList_t *text)
 share a linked list of text with a data id
const char * UI_GetText (int textId)
int UI_GetDataVersion (int textId)
static void UI_InitOption (uiNode_t *option, const char *label, const char *value)
 Initializes an option with a very little set of values.
uiNode_tUI_AddOption (uiNode_t **tree, const char *name, const char *label, const char *value)
 Append an option to an option list.
static void UI_DeleteOption (uiNode_t *tree)
void UI_ResetData (int dataId)
 Reset a shared data. Type became NONE and value became NULL.
static uiNode_tUI_OptionNodeRemoveHigherOption (uiNode_t **option)
 Remove the higher element (in alphabet) from a list.
void UI_SortOptions (uiNode_t **first)
 Sort options by alphabet.
void UI_UpdateInvisOptions (uiNode_t *option, const linkedList_t *stringList)
 Unhide those options that are stored in the linked list and hide the others.
void UI_RegisterOption (int dataId, uiNode_t *option)
void UI_RegisterLineStrip (int dataId, lineStrip_t *lineStrip)
uiNode_tUI_GetOption (int dataId)
static uiNode_tUI_FindOptionAtIndex (int index, uiNode_t *option, uiOptionIterator_t *iterator)
 find an option why index (0 is the first option)
uiNode_tUI_InitOptionIteratorAtIndex (int index, uiNode_t *option, uiOptionIterator_t *iterator)
 Init an option iterator at an index.
uiNode_tUI_OptionIteratorNextOption (uiOptionIterator_t *iterator)
 Find the next element from the iterator Iterator skipCollapsed and skipInvisible attribute can control the option flow.
uiNode_tUI_FindOptionByValue (uiOptionIterator_t *iterator, const char *value)
 Find an option (and all his parents) by is value.
int UI_FindOptionPosition (uiOptionIterator_t *iterator, const uiNode_t *option)
 Find an option position from an option iterator.
static void UI_ResetData_f (void)
 Resets the ui_global.sharedData pointers from a func node.
void UI_InitData (void)
 Initialize console command about UI shared data.

Variables

static const char *const ui_sharedDataIDNames []

Detailed Description

Definition in file ui_data.c.


Function Documentation

CASSERT ( lengthof(ui_sharedDataIDNames = =UI_MAX_DATAID  ) 
uiNode_t* UI_AddOption ( uiNode_t **  tree,
const char *  name,
const char *  label,
const char *  value 
) [read]

Append an option to an option list.

Parameters:
[in,out] tree first option of the list/tree of options
[in] name name of the option (should be unique in the option list)
[in] label label displayed
[in] value value used when this option is selected
Returns:
The new option

Definition at line 197 of file ui_data.c.

References uiNode_s::next, qtrue, UI_AllocNode(), and UI_InitOption().

Referenced by AIM_UpdateAircraftItemList(), CL_InitSkin_f(), CL_LanguageInit(), CL_TeamDefInitMenu(), CL_VideoInitMenu(), GAME_InitMenuOptions(), IN_JoystickInitMenu(), MSO_InitList(), TR_InitBaseList(), TR_TransferAliensFromMission_f(), UP_GenerateArticlesSummary(), and UP_GenerateSummary().

static void UI_DeleteOption ( uiNode_t tree  )  [static]
Warning:
If we use it with real option node, i will crash the code cause relation with parent node are not updated
Parameters:
tree 

Definition at line 226 of file ui_data.c.

References uiNode_s::next, and UI_DeleteNode().

Referenced by UI_ResetData().

static uiNode_t* UI_FindOptionAtIndex ( int  index,
uiNode_t option,
uiOptionIterator_t iterator 
) [static]

find an option why index (0 is the first option)

Parameters:
[in] index Requested index (0 is the first option)
[in] option First element of options (it can be a tree)
[in,out] iterator need an initialised iterator, and update it into the write index

Definition at line 379 of file ui_data.c.

References uiNode_s::behaviour, uiOptionIterator_t::depthCache, uiOptionIterator_t::depthPos, uiNode_s::firstChild, uiNode_s::invis, MAX_DEPTH_OPTIONITERATORCACHE, uiNode_s::next, uiOptionIterator_t::option, OPTIONEXTRADATA, qfalse, and ui_optionBehaviour.

Referenced by UI_InitOptionIteratorAtIndex().

uiNode_t* UI_FindOptionByValue ( uiOptionIterator_t iterator,
const char *  value 
) [read]

Find an option (and all his parents) by is value.

Parameters:
[in,out] iterator If it found an option, the iterator contain all option parent
[in] value The value we search
Returns:
The right option, else NULL

Definition at line 486 of file ui_data.c.

References uiNode_s::behaviour, uiOptionIterator_t::option, OPTIONEXTRADATA, ui_optionBehaviour, and UI_OptionIteratorNextOption().

Referenced by UI_OptionTreeSetSelectedValue().

int UI_FindOptionPosition ( uiOptionIterator_t iterator,
const uiNode_t option 
)

Find an option position from an option iterator.

Parameters:
[in,out] iterator Context of the iteration. If it found an option, the iterator contain all option parent
[in] option The value we search
Returns:
The option index, else -1

Definition at line 503 of file ui_data.c.

References i, uiOptionIterator_t::option, and UI_OptionIteratorNextOption().

Referenced by UI_OptionTreeSetSelectedValue().

int UI_GetDataIDByName ( const char *  name  ) 

Return a dataId by name.

Returns:
A dataId if data found, else -1

Definition at line 120 of file ui_data.c.

References uiNode_s::num, UI_MAX_DATAID, and ui_sharedDataIDNames.

Referenced by UI_ParseProperty(), and UI_ResetData_f().

int UI_GetDataVersion ( int  textId  ) 
uiNode_t* UI_GetOption ( int  dataId  )  [read]
const char* UI_GetText ( int  textId  ) 
void UI_InitData ( void   ) 

Initialize console command about UI shared data.

Note:
called by UI_Init

Definition at line 540 of file ui_data.c.

References Cmd_AddCommand(), and UI_ResetData_f().

Referenced by UI_Init().

static void UI_InitOption ( uiNode_t option,
const char *  label,
const char *  value 
) [static]

Initializes an option with a very little set of values.

Parameters:
[in] option Context option
[in] label label displayed
[in] value value used when this option is selected

Definition at line 181 of file ui_data.c.

References uiNode_s::behaviour, OPTIONEXTRADATA, Q_strncpyz(), and ui_optionBehaviour.

Referenced by UI_AddOption().

uiNode_t* UI_InitOptionIteratorAtIndex ( int  index,
uiNode_t option,
uiOptionIterator_t iterator 
) [read]

Init an option iterator at an index.

Note:
invis option are skipped, and child are counted
Parameters:
[in] index Requested index (0 is the first option)
[in] option First element of options (it can be a tree)
[out] iterator Initialised iterator
Returns:
the first option element found (current position of the iterator)
 uiOptionIterator_t iterator;
 UI_InitOptionIteratorAtIndex(index, firstOption, &iterator);   // also return the option
 while (iterator.option) {
     ...
     UI_OptionIteratorNextOption(&iterator);    // also return the option
 }
Todo:
Rework that code, we should split "Init" and "AtIndex"

Definition at line 435 of file ui_data.c.

References uiNode_s::behaviour, qtrue, uiOptionIterator_t::skipCollapsed, uiOptionIterator_t::skipInvisible, UI_FindOptionAtIndex(), and ui_optionBehaviour.

Referenced by MSO_Toggle_f(), MSO_UpdateVisibleButtons(), UI_OptionTreeNodeDraw(), UI_OptionTreeNodeGetOptionAtPosition(), and UI_OptionTreeSetSelectedValue().

uiNode_t* UI_OptionIteratorNextOption ( uiOptionIterator_t iterator  )  [read]
static uiNode_t* UI_OptionNodeRemoveHigherOption ( uiNode_t **  option  )  [static]

Remove the higher element (in alphabet) from a list.

Todo:
option should start with '_' if we need to translate it
Warning:
update parent

Definition at line 266 of file ui_data.c.

References _, uiNode_s::next, and OPTIONEXTRADATA.

Referenced by UI_SortOptions().

void UI_RegisterLineStrip ( int  dataId,
lineStrip_t lineStrip 
)
void UI_RegisterLinkedListText ( int  dataId,
linkedList_t text 
)
void UI_RegisterOption ( int  dataId,
uiNode_t option 
)
void UI_RegisterText ( int  dataId,
const char *  text 
)
void UI_ResetData ( int  dataId  ) 
static void UI_ResetData_f ( void   )  [static]

Resets the ui_global.sharedData pointers from a func node.

Note:
You can give this function a parameter to only delete a specific data
See also:
ui_sharedDataIDNames

Definition at line 520 of file ui_data.c.

References Cmd_Argc(), Cmd_Argv(), Com_Printf(), i, UI_GetDataIDByName(), UI_MAX_DATAID, and UI_ResetData().

Referenced by UI_InitData().

void UI_SortOptions ( uiNode_t **  first  ) 

Sort options by alphabet.

Definition at line 306 of file ui_data.c.

References uiNode_s::next, and UI_OptionNodeRemoveHigherOption().

Referenced by CL_LanguageInit(), UI_OptionNodeSortOptions(), and UP_GenerateArticlesSummary().

void UI_UpdateInvisOptions ( uiNode_t option,
const linkedList_t stringList 
)

Unhide those options that are stored in the linked list and hide the others.

Parameters:
[in,out] option Option list we want to update
[in] stringList List of option name (ID) we want to display

Definition at line 330 of file ui_data.c.

References uiNode_s::invis, LIST_ContainsString(), uiNode_s::name, uiNode_s::next, qfalse, and qtrue.

Referenced by GAME_SK_HideDropships(), and GAME_SK_HideUFOs().


Variable Documentation

const char* const ui_sharedDataIDNames[] [static]

Definition at line 35 of file ui_data.c.

Referenced by UI_GetDataIDByName().


Generated by  doxygen 1.6.2