UFO: Alien Invasion
Toggle main menu visibility
Loading...
Searching...
No Matches
ui_components.cpp
Go to the documentation of this file.
1
4
5
/*
6
Copyright (C) 2002-2025 UFO: Alien Invasion.
7
8
This program is free software; you can redistribute it and/or
9
modify it under the terms of the GNU General Public License
10
as published by the Free Software Foundation; either version 2
11
of the License, or (at your option) any later version.
12
13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
17
See the GNU General Public License for more details.
18
19
You should have received a copy of the GNU General Public License
20
along with this program; if not, write to the Free Software
21
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
23
*/
24
25
#include "
ui_internal.h
"
26
#include "
ui_components.h
"
27
34
uiNode_t
*
UI_GetComponent
(
const
char
*
name
)
35
{
36
unsigned
char
min = 0;
37
unsigned
char
max =
ui_global
.numComponents;
38
39
while
(min != max) {
40
const
int
mid = (min + max) >> 1;
41
const
int
diff = strcmp(
ui_global
.components[mid]->name,
name
);
42
assert(mid < max);
43
assert(mid >= min);
44
45
if
(diff == 0)
46
return
ui_global
.components[mid];
47
48
if
(diff > 0)
49
max = mid;
50
else
51
min = mid + 1;
52
}
53
54
return
nullptr
;
55
}
56
61
void
UI_InsertComponent
(
uiNode_t
* component)
62
{
63
if
(
ui_global
.numComponents >=
UI_MAX_COMPONENTS
)
64
Com_Error
(
ERR_FATAL
,
"UI_InsertComponent: hit MAX_COMPONENTS"
);
65
66
/* search the insertion position */
67
int
pos = 0;
68
for
(; pos <
ui_global
.numComponents; pos++) {
69
const
uiNode_t
* node =
ui_global
.components[pos];
70
if
(strcmp(component->
name
, node->
name
) < 0)
71
break
;
72
}
73
74
/* create the space */
75
for
(
int
i
=
ui_global
.numComponents - 1;
i
>= pos;
i
--)
76
ui_global
.components[
i
+ 1] =
ui_global
.components[
i
];
77
78
/* insert */
79
ui_global
.components[pos] = component;
80
ui_global
.numComponents++;
81
}
Com_Error
void Com_Error(int code, const char *fmt,...)
Definition
common.cpp:459
ERR_FATAL
#define ERR_FATAL
Definition
common.h:210
i
QGL_EXTERN GLint i
Definition
r_gl.h:113
name
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition
r_gl.h:110
uiNode_t
Atomic structure used to define most of the UI.
Definition
ui_nodes.h:80
uiNode_t::name
char name[MAX_VAR]
Definition
ui_nodes.h:82
UI_GetComponent
uiNode_t * UI_GetComponent(const char *name)
Searches all components for the specified one.
Definition
ui_components.cpp:34
UI_InsertComponent
void UI_InsertComponent(uiNode_t *component)
Add a new component to the list of all components.
Definition
ui_components.cpp:61
ui_components.h
ui_internal.h
Internal data use by the UI package.
UI_MAX_COMPONENTS
#define UI_MAX_COMPONENTS
Definition
ui_internal.h:30
ui_global
uiGlobal_t ui_global
Definition
ui_main.cpp:38
src
client
ui
ui_components.cpp
Generated on __DATE__ __TIME__ for UFO: Alien Invasion by
1.17.0