UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ui_data.h
Go to the documentation of this file.
1 
7 /*
8 Copyright (C) 2002-2020 UFO: Alien Invasion.
9 
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License
12 as published by the Free Software Foundation; either version 2
13 of the License, or (at your option) any later version.
14 
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 
19 See the GNU General Public License for more details.
20 
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 
25 */
26 
27 #pragma once
28 
29 #include "../../shared/ufotypes.h"
30 #include "../../shared/shared.h"
31 #include "ui_nodes.h"
32 #include "node/ui_node_option.h"
33 #include "ui_dataids.h"
34 
35 struct linkedList_t;
36 
37 typedef enum {
43 
44 typedef struct uiSharedData_s {
46  union {
48  const char* text;
53  } data;
54  int versionId;
56 
57 #define MAX_DEPTH_OPTIONITERATORCACHE 8
58 
59 typedef struct {
62  int depthPos;
66 
67 /* common */
68 int UI_GetDataVersion(int textId) __attribute__ ((warn_unused_result));
69 void UI_ResetData(int dataId);
70 int UI_GetDataIDByName(const char* name) __attribute__ ((warn_unused_result));
71 void UI_InitData(void);
72 
73 /* text */
74 void UI_RegisterText(int textId, const char* text);
75 const char* UI_GetText(int textId) __attribute__ ((warn_unused_result));
76 const char* UI_GetTextFromList(int textId, int line) __attribute__ ((warn_unused_result));
77 
78 /* linked list */
79 void UI_RegisterLinkedListText(int textId, linkedList_t* text);
80 
81 /* option */
82 void UI_RegisterOption(int dataId, uiNode_t* option);
83 uiNode_t* UI_GetOption(int dataId) __attribute__ ((warn_unused_result));
84 void UI_SortOptions(uiNode_t** option);
86 uiNode_t* UI_InitOptionIteratorAtIndex(int index, uiNode_t* option, uiOptionIterator_t* iterator, bool skipCollapsed, bool skipInvisible);
88 void UI_UpdateInvisOptions(uiNode_t* option, const linkedList_t* stringList);
89 uiNode_t* UI_FindOptionByValue(uiOptionIterator_t* iterator, const char* value);
90 int UI_FindOptionPosition(uiOptionIterator_t* iterator, uiNode_t const* option);
91 uiNode_t* UI_AddOption(uiNode_t** tree, const char* name, const char* label, const char* value);
void UI_RegisterText(int textId, const char *text)
share a text with a data id
Definition: ui_data.cpp:115
bool skipCollapsed
Definition: ui_data.h:64
void UI_ResetData(int dataId)
Reset a shared data. Type became NONE and value became nullptr.
Definition: ui_data.cpp:212
struct uiSharedData_s uiSharedData_t
int UI_FindOptionPosition(uiOptionIterator_t *iterator, uiNode_t const *option)
Find an option position from an option iterator.
Definition: ui_data.cpp:485
bool skipInvisible
Definition: ui_data.h:63
#define MAX_DEPTH_OPTIONITERATORCACHE
Definition: ui_data.h:57
void UI_RegisterOption(int dataId, uiNode_t *option)
Definition: ui_data.cpp:311
uiNode_t * option
Holds a linked list for option (label, action, icon...)
Definition: ui_data.h:52
const char * UI_GetTextFromList(int textId, int line) __attribute__((warn_unused_result))
Definition: ui_data.cpp:151
#define __attribute__(x)
Definition: cxx.h:37
void UI_UpdateInvisOptions(uiNode_t *option, const linkedList_t *stringList)
Unhide those options that are stored in the linked list and hide the others.
Definition: ui_data.cpp:297
uiSharedType_t type
Definition: ui_data.h:45
linkedList_t * linkedListText
Holds a linked list for displaying in the UI.
Definition: ui_data.h:50
uiNode_t * UI_InitOptionIteratorAtIndex(int index, uiNode_t *option, uiOptionIterator_t *iterator)
Init an option iterator at an index.
Definition: ui_data.cpp:394
uiNode_t * UI_AddOption(uiNode_t **tree, const char *name, const char *label, const char *value)
Append an option to an option list.
Definition: ui_data.cpp:172
const char * UI_GetText(int textId) __attribute__((warn_unused_result))
Definition: ui_data.cpp:144
int UI_GetDataIDByName(const char *name) __attribute__((warn_unused_result))
Return a dataId by name.
Definition: ui_data.cpp:102
void UI_RegisterLinkedListText(int textId, linkedList_t *text)
share a linked list of text with a data id
Definition: ui_data.cpp:131
Atomic structure used to define most of the UI.
Definition: ui_nodes.h:80
QGL_EXTERN GLuint index
Definition: r_gl.h:110
int versionId
Definition: ui_data.h:54
uiNode_t * UI_OptionIteratorNextOption(uiOptionIterator_t *iterator)
Find the next element from the iterator Iterator skipCollapsed and skipInvisible attribute can contro...
Definition: ui_data.cpp:430
uiSharedType_t
Definition: ui_data.h:37
union uiSharedData_s::@18 data
void UI_InitData(void)
Initialize console command about UI shared data.
Definition: ui_data.cpp:521
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition: r_gl.h:110
int UI_GetDataVersion(int textId) __attribute__((warn_unused_result))
Definition: ui_data.cpp:159
void UI_SortOptions(uiNode_t **option)
Sort options by alphabet.
Definition: ui_data.cpp:273
uiNode_t * UI_GetOption(int dataId) __attribute__((warn_unused_result))
Definition: ui_data.cpp:324
uiNode_t * option
Definition: ui_data.h:60
uiNode_t * UI_FindOptionByValue(uiOptionIterator_t *iterator, const char *value)
Find an option (and all his parents) by is value.
Definition: ui_data.cpp:468
const char * text
Holds static array of characters to display.
Definition: ui_data.h:48