FTEQW
Documentation of the FTE engine source tree.
api_menu.h
Go to the documentation of this file.
1 /*
2 * Copyright (c) 2015-2018
3 * Marco Cawthorne All rights reserved.
4 *
5 * This is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9
10 * This is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14
15 * You should have received a copy of the GNU General Public License
16 * along with this. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#define NATIVEMENU_API_VERSION_MIN 0 //will be updated any time a symbol is renamed.
20#define NATIVEMENU_API_VERSION_MAX 0 //bumped for any change.
21#ifndef NATIVEMENU_API_VERSION //so you can hold back the reported version in order to work with older engines.
22#define NATIVEMENU_API_VERSION NATIVEMENU_API_VERSION_MAX //version reported to the other side.
23#endif
24
25struct vfsfile_s;
26struct serverinfo_s;
28struct model_s;
29struct font_s;
30struct shader_s;
31
32#ifndef __QUAKEDEF_H__
33 #ifdef __cplusplus
34 typedef enum {qfalse, qtrue} qboolean;//false and true are forcivly defined.
35 #else
36 typedef enum {false, true} qboolean;
37 #endif
38 typedef float vec_t;
39 typedef vec_t vec2_t[2];
40 typedef vec_t vec3_t[3];
41 typedef vec_t vec4_t[4];
42 #ifdef _MSC_VER
43 #define QDECL __cdecl
44 #else
45 #define QDECL
46 #endif
47
48 #include <stdint.h>
50#endif
51
52#if 1 //c++ or standard C
53 #include "cl_master.h"
54#endif
55enum slist_test_e;
56enum hostcachekey_e; //obtained via calls to gethostcacheindexforkey
57enum fs_relative;
59
61{
62 enum {
69 unsigned int devid;
70 union
71 {
72 struct
73 {
74 unsigned int scancode;
75 unsigned int charcode;
76 } key;
77 struct
78 {
79 float delta[2];
80 float screen[2]; //virtual coords
82 struct
83 {
84 unsigned int axis;
85 float val;
87 };
88};
89
90typedef enum
91{
92 MI_INIT, //initial startup
93 MI_RENDERER, //renderer restarted, any models/shaders/textures handles are no longer valid
94 MI_RESOLUTION, //video mode changed (scale or physical size) but without any gpu resources getting destroyed. you'll want to reload fonts.
96
97typedef struct
98{
99 struct model_s *model;
100 int frame[2];
101 float frametime[2];
102 float frameweight[2];
103 vec4_t matrix[3]; //axis/angles+origin
105typedef struct
106{
107 //these are in virtual coords, thus they need to be floats so that they can be rounded to ints more cleanly... yeah, scaling sucks.
110
111 float time; //affects shader effects
112 vec_t fov[2];
113 vec4_t viewmatrix[3];
114
119
120typedef struct {
121 int api_version; //this may be higher than you expect.
122 const char *engine_version;
123
124 int (*checkextension) (const char *ext);
125 void (QDECL *error) (const char *err, ...);
126 void (*printf) (const char *text, ...);
127 void (*dprintf) (const char *text, ...);
128 void (*localcmd) (const char *cmd);
129 float (*cvar_float) (const char *name);
130 const char *(*cvar_string) (const char *name, qboolean effective); //NULL if it doesn't exist. return value lasts until cvar_set is called, etc, so don't cache. effective=true reports its active value, not the value that the user wanted.
131 const char *(*cvar_default) (const char *name);
132 void (*cvar_set) (const char *name, const char *value);
133 void (*registercvar) (const char *name, const char *defaultvalue, unsigned int flags, const char *description);
134 void (*registercommand) (const char *name, const char *description);
135
136 char *(*parsetoken) (const char *data, char *out, int outlen, enum com_tokentype_e *toktype);
137
138 int (*isserver) (void);
139 int (*getclientstate) (char const**disconnectionreason);
140 void (*localsound) (const char *sample, int channel, float volume);
141
142 // file input / search crap
143 struct vfsfile_s *(*fopen) (const char *filename, const char *modestring, enum fs_relative fsroot); //modestring should be one of rb,r+b,wb,w+b,ab,wbp. Mostly use a root of FS_GAMEONLY for writes, otherwise FS_GAME for reads.
144 void (*fclose) (struct vfsfile_s *fhandle);
145 char *(*fgets) (struct vfsfile_s *fhandle, char *out, size_t outsize); //returns output buffer, or NULL
146 void (*fprintf) (struct vfsfile_s *fhandle, const char *s, ...);
147 void (*enumeratefiles) (const char *match, int (QDECL *callback)(const char *fname, qofs_t fsize, time_t mtime, void *ctx, struct searchpathfuncs_s *package), void *ctx);
148 qboolean (QDECL *nativepath)(const char *fname, enum fs_relative relativeto, char *out, int outlen); //Converts a relative path to a printable system path. All paths are considered to be utf-8. WARNING: This means that windows users will need to use _wfopen etc if they use the resulting path of this function in any system calls. WARNING: this function can and WILL fail for dodgy paths (eg blocking writes to "../engine.dll")
149
150 // Drawing stuff
151 void (*drawsetcliparea) (float x, float y, float width, float height);
152 void (*drawresetcliparea) (void);
153 struct shader_s *(*cachepic)(const char *name);
154 qboolean (*drawgetimagesize)(struct shader_s *pic, int *x, int *y);
155 void (*drawquad) (const vec2_t position[4], const vec2_t texcoords[4], struct shader_s *pic, const vec4_t rgba, unsigned int be_flags);
156
157 float (*drawstring) (const vec2_t position, const char *text, struct font_s *font, float height, const vec4_t rgba, unsigned int be_flags);
158 float (*stringwidth) (const char *text, struct font_s *font, float height);
159 struct font_s *(*loadfont) (const char *facename, float intendedheight); //with ttf fonts, you'll probably want one for each size.
160 void (*destroyfont) (struct font_s *font);
161
162 // 3D scene stuff
163 struct model_s *(*cachemodel)(const char *name);
164 qboolean (*getmodelsize) (struct model_s *model, vec3_t out_mins, vec3_t out_maxs);
165 void (*renderscene) (menuscene_t *scene);
166
167 // Menu specific stuff
168 void (*pushmenu) (void *ctx); //will have key focus.
169 qboolean (*ismenupushed) (void *ctx); //reports if its still pushed (but not necessarily the active one!).
170 void (*killmenu) (void *ctx); //force-removes a menu.
171 int (*setmousecursor) (const char *cursorname, float hot_x, float hot_y, float scale); //forces absolute mouse coords whenever cursorname isn't NULL
172 const char *(*keynumtostring) (int keynum, int modifier);
173 int (*stringtokeynum) (const char *key, int *modifier);
174 int (*findkeysforcommand) (int bindmap, const char *command, int *out_scancodes, int *out_modifiers, int keycount);
175
176 // Server browser stuff
177 enum hostcachekey_e (*gethostcacheindexforkey) (const char *key);
178 struct serverinfo_s *(*getsortedhost) (int idx);
179 char *(*gethostcachestring) (struct serverinfo_s *host, enum hostcachekey_e fld);
180 float (*gethostcachenumber) (struct serverinfo_s *host, enum hostcachekey_e fld);
181 void (*resethostcachemasks) (void);
182 void (*sethostcachemaskstring) (qboolean or_, enum hostcachekey_e fld, const char *str, enum slist_test_e op);
183 void (*sethostcachemasknumber) (qboolean or_, enum hostcachekey_e fld, int num, enum slist_test_e op);
184 void (*sethostcachesort) (enum hostcachekey_e fld, qboolean descending);
185 int (*resorthostcache) (void);
186 void (*refreshhostcache) (qboolean fullreset);
187 qboolean (*sendhostcachequeries) (void); //returns true while there are still waiting for servers. should be called each frame while you still care about the servers.
189
190typedef struct {
192
193 void (*Init) (mintreason_t reason, float vwidth, float vheight, int pwidth, int pheight);
194 void (*Shutdown) (mintreason_t reason);
195 void (*DrawLoading) (double frametime); //pure loading screen.
196 void (*Toggle) (int wantmode);
197 qboolean(*ConsoleCommand) (const char *cmdline, int argc, char const*const*argv);
198
199 void (*Draw) (void *ctx, double frametime); //draws a menu.
200 qboolean(*InputEvent) (void *ctx, struct menu_inputevent_args_s ev); //return true to prevent the engine handling it (ie: because you already did).
201 void (*Closed) (void *ctx); //a pushed menu was closed.
203
204#ifndef NATIVEEXPORT
205 #ifdef _WIN32
206 #define NATIVEEXPORTPROTO __declspec(dllexport)
207 #define NATIVEEXPORT NATIVEEXPORTPROTO
208 #else
209 #define NATIVEEXPORTPROTO
210 #define NATIVEEXPORT __attribute__((visibility("default")))
211 #endif
212#endif
213
214NATIVEEXPORTPROTO menu_export_t *QDECL GetMenuAPI (menu_import_t *import);
qboolean
Definition: api_menu.h:34
@ qtrue
Definition: api_menu.h:34
@ qfalse
Definition: api_menu.h:34
float vec_t
Definition: api_menu.h:38
NATIVEEXPORTPROTO menu_export_t *QDECL GetMenuAPI(menu_import_t *import)
vec_t vec3_t[3]
Definition: api_menu.h:40
mintreason_t
Definition: api_menu.h:91
@ MI_INIT
Definition: api_menu.h:92
@ MI_RESOLUTION
Definition: api_menu.h:94
@ MI_RENDERER
Definition: api_menu.h:93
vec_t vec4_t[4]
Definition: api_menu.h:41
uint64_t qofs_t
Definition: api_menu.h:49
vec_t vec2_t[2]
Definition: api_menu.h:39
struct @13::@38 ext
cvar_t model
Definition: cl_main.c:153
slist_test_e
Definition: cl_master.h:91
hostcachekey_e
Definition: cl_master.h:56
void(QDECL *vgui_frame)(void)
int op
Definition: cmd.c:3416
void dNearCallback * callback
Definition: com_phys_ode.c:655
int num
Definition: com_phys_ode.c:314
com_tokentype_e
Definition: common.h:446
fs_relative
Definition: common.h:661
char * text
Definition: decomp.c:375
s
Definition: execloop.h:53
char filename[64]
Definition: generatebuiltin.c:8
static EGLSurface EGLSurface EGLContext ctx
Definition: gl_videgl.c:47
int error
Definition: gl_vidlinuxglx.c:447
static CONST PIXELFORMATDESCRIPTOR *static int
Definition: gl_vidnt.c:222
GLfloat GLfloat y
Definition: glquake.h:158
GLfloat x
Definition: glquake.h:158
GLsizei GLboolean const GLfloat * value
Definition: glquake.h:164
char * package
Definition: m_download.c:202
char fname[MAX_QPATH]
Definition: m_mp3.c:160
char ** data
Definition: p_script.c:63
float frametime
Definition: pmove.c:31
int idx
Definition: pr_lua.c:221
float scale
Definition: pr_menu.c:106
char facename[MAX_OSPATH]
Definition: pr_menu.c:105
struct font_s * font[FONT_SIZES]
Definition: pr_menu.c:111
int outlen
Definition: qccgui.c:6543
static SpeexBits spx_int16_t * out
Definition: snd_dma.c:492
cvar_t volume
Definition: snd_dma.c:85
Definition: api_menu.h:190
int api_version
Definition: api_menu.h:191
Definition: api_menu.h:120
const char * engine_version
Definition: api_menu.h:122
enum fs_relative relativeto char * out
Definition: api_menu.h:148
int api_version
Definition: api_menu.h:121
void(QDECL *error)(const char *err
Definition: api_menu.h:61
float delta[2]
Definition: api_menu.h:79
float screen[2]
Definition: api_menu.h:80
unsigned int charcode
Definition: api_menu.h:75
struct menu_inputevent_args_s::@3::@6 mouse
struct menu_inputevent_args_s::@3::@5 key
float val
Definition: api_menu.h:85
enum menu_inputevent_args_s::@2 eventtype
unsigned int devid
Definition: api_menu.h:69
@ MIE_KEYUP
Definition: api_menu.h:64
@ MIE_MOUSEABS
Definition: api_menu.h:66
@ MIE_MOUSEDELTA
Definition: api_menu.h:65
@ MIE_KEYDOWN
Definition: api_menu.h:63
@ MIE_JOYAXIS
Definition: api_menu.h:67
unsigned int axis
Definition: api_menu.h:84
unsigned int scancode
Definition: api_menu.h:74
Definition: api_menu.h:98
struct model_s * model
Definition: api_menu.h:99
Definition: api_menu.h:106
menuentity_t * entlist
Definition: api_menu.h:117
float time
Definition: api_menu.h:111
vec2_t pos
Definition: api_menu.h:108
struct model_s * worldmodel
Definition: api_menu.h:115
vec2_t size
Definition: api_menu.h:109
int numentities
Definition: api_menu.h:116
Definition: gl_model.h:972
int width
Definition: gl_model.h:1100
time_t mtime
Definition: gl_model.h:980
char name[MAX_QPATH]
Definition: gl_model.h:973
int height
Definition: gl_model.h:1101
int flags
Definition: gl_model.h:990
Definition: fs.h:34
Definition: cl_master.h:129
Definition: shader.h:602
Definition: common.h:620
static char ** argv
Definition: sv_sql.c:11
unsigned __int64 uint64_t
Definition: vk_platform.h:82