UFO: Alien Invasion
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
cl_tutorials.cpp
Go to the documentation of this file.
1
5
/*
6
Copyright (C) 2002-2020 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 "
cl_tutorials.h
"
26
#include "
client.h
"
27
#include "
ui/ui_main.h
"
28
#include "../shared/parse.h"
29
30
typedef
struct
tutorial_s
{
31
char
name
[
MAX_VAR
];
32
char
sequence
[
MAX_VAR
];
33
}
tutorial_t
;
34
35
#define MAX_TUTORIALS 16
36
static
tutorial_t
tutorials
[
MAX_TUTORIALS
];
37
static
int
numTutorials
;
38
39
static
void
TUT_GetTutorials_f
(
void
)
40
{
41
UI_ExecuteConfunc
(
"tutorialsListClear"
);
42
43
for
(
int
i
= 0;
i
<
numTutorials
;
i
++) {
44
const
tutorial_t
* t = &tutorials[
i
];
45
UI_ExecuteConfunc
(
"tutorialsListAdd %i \"%s\""
,
i
,
_
(t->
name
));
46
}
47
}
48
49
static
void
TUT_List_f
(
void
)
50
{
51
Com_Printf
(
"Tutorials: %i\n"
,
numTutorials
);
52
for
(
int
i
= 0;
i
<
numTutorials
;
i
++) {
53
Com_Printf
(
"tutorial: %s\n"
, tutorials[
i
].
name
);
54
Com_Printf
(
"..sequence: %s\n"
, tutorials[
i
].sequence);
55
}
56
}
57
61
static
void
TUT_ListClick_f
(
void
)
62
{
63
if
(
Cmd_Argc
() < 2) {
64
Com_Printf
(
"Usage: %s <num>\n"
,
Cmd_Argv
(0));
65
return
;
66
}
67
68
const
int
num = atoi(
Cmd_Argv
(1));
69
if
(num < 0 || num >=
numTutorials
)
70
return
;
71
72
Cmd_ExecuteString
(
"seq_start %s"
, tutorials[num].sequence);
73
}
74
75
void
TUT_InitStartup
(
void
)
76
{
77
/* tutorial stuff */
78
Cmd_AddCommand
(
"listtutorials"
,
TUT_List_f
,
"Show all tutorials"
);
79
Cmd_AddCommand
(
"gettutorials"
,
TUT_GetTutorials_f
);
80
Cmd_AddCommand
(
"tutoriallist_click"
,
TUT_ListClick_f
);
81
82
numTutorials
= 0;
83
}
84
85
static
const
value_t
tutValues
[] = {
86
{
"name"
,
V_TRANSLATION_STRING
, offsetof(
tutorial_t
,
name
), 0},
87
{
"sequence"
,
V_STRING
, offsetof(
tutorial_t
, sequence), 0},
88
{
nullptr
,
V_NULL
, 0, 0}
89
};
90
94
void
TUT_ParseTutorials
(
const
char
*
name
,
const
char
** text)
95
{
96
/* parse tutorials */
97
if
(
numTutorials
>=
MAX_TUTORIALS
) {
98
Com_Printf
(
"Too many tutorials, '%s' ignored.\n"
, name);
99
return
;
100
}
101
tutorial_t
* t = &tutorials[
numTutorials
++];
102
OBJZERO
(*t);
103
104
Com_ParseBlock
(name, text, t, tutValues,
nullptr
);
105
}
V_STRING
Definition:
scripts.h:58
Com_ParseBlock
bool Com_ParseBlock(const char *name, const char **text, void *base, const value_t *values, memPool_t *mempool)
Definition:
scripts.cpp:1415
Cmd_Argv
const char * Cmd_Argv(int arg)
Returns a given argument.
Definition:
cmd.cpp:516
Cmd_AddCommand
void Cmd_AddCommand(const char *cmdName, xcommand_t function, const char *desc)
Add a new command to the script interface.
Definition:
cmd.cpp:744
TUT_ParseTutorials
void TUT_ParseTutorials(const char *name, const char **text)
Definition:
cl_tutorials.cpp:94
_
#define _(String)
Definition:
cl_shared.h:43
tutorials
static tutorial_t tutorials[MAX_TUTORIALS]
Definition:
cl_tutorials.cpp:36
TUT_List_f
static void TUT_List_f(void)
Definition:
cl_tutorials.cpp:49
ui_main.h
MAX_TUTORIALS
#define MAX_TUTORIALS
Definition:
cl_tutorials.cpp:35
Com_Printf
void Com_Printf(const char *const fmt,...)
Definition:
common.cpp:386
TUT_InitStartup
void TUT_InitStartup(void)
Definition:
cl_tutorials.cpp:75
Cmd_ExecuteString
void Cmd_ExecuteString(const char *text,...)
A complete command line has been parsed, so try to execute it.
Definition:
cmd.cpp:1007
TUT_ListClick_f
static void TUT_ListClick_f(void)
click function for text tutoriallist in menu_tutorials.ufo
Definition:
cl_tutorials.cpp:61
value_s
Definition:
scripts.h:168
OBJZERO
#define OBJZERO(obj)
Definition:
shared.h:178
cl_tutorials.h
MAX_VAR
#define MAX_VAR
Definition:
shared.h:36
Cmd_Argc
int Cmd_Argc(void)
Return the number of arguments of the current command. "command parameter" will result in a argc of 2...
Definition:
cmd.cpp:505
tutorial_s::name
char name[MAX_VAR]
Definition:
cl_tutorials.cpp:31
tutorial_s
Definition:
cl_tutorials.cpp:30
tutValues
static const value_t tutValues[]
Definition:
cl_tutorials.cpp:85
tutorial_t
struct tutorial_s tutorial_t
V_NULL
Definition:
scripts.h:49
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
TUT_GetTutorials_f
static void TUT_GetTutorials_f(void)
Definition:
cl_tutorials.cpp:39
V_TRANSLATION_STRING
Definition:
scripts.h:59
numTutorials
static int numTutorials
Definition:
cl_tutorials.cpp:37
tutorial_s::sequence
char sequence[MAX_VAR]
Definition:
cl_tutorials.cpp:32
client.h
Primary header for client.
UI_ExecuteConfunc
void UI_ExecuteConfunc(const char *fmt,...)
Executes confunc - just to identify those confuncs in the code - in this frame.
Definition:
ui_main.cpp:110
src
client
cl_tutorials.cpp
Generated on Mon Feb 24 2020 05:28:04 for UFO: Alien Invasion by
1.8.8