2018-05-21 13:47:53 +00:00
/*
* Copyright ( c ) 2015 - 2018
* Marco Hladik All rights reserved .
*
* This is free software : you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation , either version 3 of the License , or
* ( at your option ) any later version .
* This is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
* You should have received a copy of the GNU General Public License
* along with this . If not , see < http : //www.gnu.org/licenses/>.
*/
# define NATIVEMENU_API_VERSION_MIN 0 //will be updated any time a symbol is renamed.
# define NATIVEMENU_API_VERSION_MAX 0 //bumped for any change.
# ifndef NATIVEMENU_API_VERSION //so you can hold back the reported version in order to work with older engines.
# define NATIVEMENU_API_VERSION NATIVEMENU_API_VERSION_MAX //version reported to the other side.
# endif
struct vfsfile_s ;
struct serverinfo_s ;
struct searchpathfuncs_s ;
2018-06-02 08:55:57 +00:00
struct model_s ;
struct font_s ;
struct shader_s ;
2018-08-04 19:00:19 +00:00
2018-05-21 13:47:53 +00:00
# ifndef __QUAKEDEF_H__
# ifdef __cplusplus
typedef enum { qfalse , qtrue } qboolean ; //false and true are forcivly defined.
# else
typedef enum { false , true } qboolean ;
# endif
typedef float vec_t ;
typedef vec_t vec2_t [ 2 ] ;
typedef vec_t vec3_t [ 3 ] ;
typedef vec_t vec4_t [ 4 ] ;
# ifdef _MSC_VER
# define QDECL __cdecl
# else
# define QDECL
# endif
# include <stdint.h>
typedef uint64_t qofs_t ;
# endif
2018-08-04 19:00:19 +00:00
# if 1 //c++ or standard C
# include "cl_master.h"
# endif
2018-11-19 08:06:07 +00:00
enum slist_test_e ;
enum hostcachekey_e ; //obtained via calls to gethostcacheindexforkey
2018-08-04 19:00:19 +00:00
enum fs_relative ;
enum com_tokentype_e ;
2018-05-21 13:47:53 +00:00
struct menu_inputevent_args_s
{
enum {
MIE_KEYDOWN = 0 ,
MIE_KEYUP = 1 ,
MIE_MOUSEDELTA = 2 ,
MIE_MOUSEABS = 3 ,
} eventtype ;
unsigned int devid ;
union
{
struct
{
unsigned int scancode ;
unsigned int charcode ;
} key ;
struct
{
float delta [ 2 ] ;
float screen [ 2 ] ; //virtual coords
} mouse ;
} ;
} ;
2018-06-02 08:55:57 +00:00
typedef enum
{
MI_INIT , //initial startup
MI_RENDERER , //renderer restarted, any models/shaders/textures handles are no longer valid
MI_RESOLUTION , //video mode changed (scale or physical size) but without any gpu resources getting destroyed. you'll want to reload fonts.
} mintreason_t ;
typedef struct
{
struct model_s * model ;
int frame [ 2 ] ;
float frametime [ 2 ] ;
float frameweight [ 2 ] ;
vec4_t matrix [ 3 ] ; //axis/angles+origin
} menuentity_t ;
typedef struct
{
//these are in virtual coords, thus they need to be floats so that they can be rounded to ints more cleanly... yeah, scaling sucks.
vec2_t pos ;
vec2_t size ;
float time ; //affects shader effects
vec_t fov [ 2 ] ;
vec4_t viewmatrix [ 3 ] ;
struct model_s * worldmodel ;
int numentities ;
menuentity_t * entlist ;
} menuscene_t ;
2018-05-21 13:47:53 +00:00
typedef struct {
int api_version ; //this may be higher than you expect.
2018-06-02 08:55:57 +00:00
const char * engine_version ;
2018-05-21 13:47:53 +00:00
int ( * checkextension ) ( const char * ext ) ;
2018-07-05 16:21:44 +00:00
void ( QDECL * error ) ( const char * err , . . . ) ;
2018-05-21 13:47:53 +00:00
void ( * printf ) ( const char * text , . . . ) ;
void ( * dprintf ) ( const char * text , . . . ) ;
void ( * localcmd ) ( const char * cmd ) ;
float ( * cvar_float ) ( const char * name ) ;
2018-06-02 08:55:57 +00:00
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.
const char * ( * cvar_default ) ( const char * name ) ;
2018-05-21 13:47:53 +00:00
void ( * cvar_set ) ( const char * name , const char * value ) ;
void ( * registercvar ) ( const char * name , const char * defaultvalue , unsigned int flags , const char * description ) ;
2018-06-02 08:55:57 +00:00
void ( * registercommand ) ( const char * name , const char * description ) ;
char * ( * parsetoken ) ( const char * data , char * out , int outlen , enum com_tokentype_e * toktype ) ;
2018-05-21 13:47:53 +00:00
int ( * isserver ) ( void ) ;
2018-12-06 04:55:35 +00:00
int ( * getclientstate ) ( char const * * disconnectionreason ) ;
2018-05-21 13:47:53 +00:00
void ( * localsound ) ( const char * sample , int channel , float volume ) ;
// file input / search crap
2018-07-05 16:21:44 +00:00
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.
2018-05-21 13:47:53 +00:00
void ( * fclose ) ( struct vfsfile_s * fhandle ) ;
char * ( * fgets ) ( struct vfsfile_s * fhandle , char * out , size_t outsize ) ; //returns output buffer, or NULL
void ( * fprintf ) ( struct vfsfile_s * fhandle , const char * s , . . . ) ;
2018-06-02 08:55:57 +00:00
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 ) ;
2018-12-06 04:55:35 +00:00
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")
2018-05-21 13:47:53 +00:00
// Drawing stuff
void ( * drawsetcliparea ) ( float x , float y , float width , float height ) ;
void ( * drawresetcliparea ) ( void ) ;
2018-06-02 08:55:57 +00:00
struct shader_s * ( * cachepic ) ( const char * name ) ;
qboolean ( * drawgetimagesize ) ( struct shader_s * pic , int * x , int * y ) ;
void ( * drawquad ) ( const vec2_t position [ 4 ] , const vec2_t texcoords [ 4 ] , struct shader_s * pic , const vec4_t rgba , unsigned int be_flags ) ;
2018-07-05 16:21:44 +00:00
float ( * drawstring ) ( const vec2_t position , const char * text , struct font_s * font , float height , const vec4_t rgba , unsigned int be_flags ) ;
2018-06-02 08:55:57 +00:00
float ( * stringwidth ) ( const char * text , struct font_s * font , float height ) ;
struct font_s * ( * loadfont ) ( const char * facename , float intendedheight ) ; //with ttf fonts, you'll probably want one for each size.
void ( * destroyfont ) ( struct font_s * font ) ;
// 3D scene stuff
struct model_s * ( * cachemodel ) ( const char * name ) ;
2018-07-05 16:21:44 +00:00
qboolean ( * getmodelsize ) ( struct model_s * model , vec3_t out_mins , vec3_t out_maxs ) ;
2018-06-02 08:55:57 +00:00
void ( * renderscene ) ( menuscene_t * scene ) ;
2018-05-21 13:47:53 +00:00
// Menu specific stuff
qboolean ( * setkeydest ) ( qboolean focused ) ; //returns whether it changed.
int ( * getkeydest ) ( void ) ; //returns 0 if unfocused, -1 if active-but-unfocused, 1 if focused-and-active.
int ( * setmousetarget ) ( const char * cursorname , float hot_x , float hot_y , float scale ) ; //forces absolute mouse coords whenever cursorname isn't NULL
const char * ( * keynumtostring ) ( int keynum , int modifier ) ;
int ( * stringtokeynum ) ( const char * key , int * modifier ) ;
int ( * findkeysforcommand ) ( int bindmap , const char * command , int * out_scancodes , int * out_modifiers , int keycount ) ;
// Server browser stuff
2018-06-02 08:55:57 +00:00
enum hostcachekey_e ( * gethostcacheindexforkey ) ( const char * key ) ;
struct serverinfo_s * ( * getsortedhost ) ( int idx ) ;
2018-05-21 13:47:53 +00:00
char * ( * gethostcachestring ) ( struct serverinfo_s * host , enum hostcachekey_e fld ) ;
float ( * gethostcachenumber ) ( struct serverinfo_s * host , enum hostcachekey_e fld ) ;
void ( * resethostcachemasks ) ( void ) ;
2018-08-04 19:00:19 +00:00
void ( * sethostcachemaskstring ) ( qboolean or_ , enum hostcachekey_e fld , const char * str , enum slist_test_e op ) ;
void ( * sethostcachemasknumber ) ( qboolean or_ , enum hostcachekey_e fld , int num , enum slist_test_e op ) ;
2018-05-21 13:47:53 +00:00
void ( * sethostcachesort ) ( enum hostcachekey_e fld , qboolean descending ) ;
2018-06-02 08:55:57 +00:00
int ( * resorthostcache ) ( void ) ;
2018-05-21 13:47:53 +00:00
void ( * refreshhostcache ) ( qboolean fullreset ) ;
2018-06-02 08:55:57 +00:00
qboolean ( * sendhostcachequeries ) ( void ) ; //returns true while there are still waiting for servers. should be called each frame while you still care about the servers.
2018-05-21 13:47:53 +00:00
} menu_import_t ;
typedef struct {
int api_version ;
2018-06-02 08:55:57 +00:00
void ( * Init ) ( mintreason_t reason , float vwidth , float vheight , int pwidth , int pheight ) ;
void ( * Shutdown ) ( mintreason_t reason ) ;
void ( * Draw ) ( double frametime ) ;
void ( * DrawLoading ) ( double frametime ) ;
2018-05-21 13:47:53 +00:00
void ( * Toggle ) ( int wantmode ) ;
int ( * InputEvent ) ( struct menu_inputevent_args_s ev ) ;
2018-06-02 08:55:57 +00:00
qboolean ( * ConsoleCommand ) ( const char * cmdline , int argc , char const * const * argv ) ;
2018-05-21 13:47:53 +00:00
} menu_export_t ;
# ifndef NATIVEEXPORT
# ifdef _WIN32
2018-06-02 08:55:57 +00:00
# define NATIVEEXPORTPROTO __declspec(dllexport)
# define NATIVEEXPORT NATIVEEXPORTPROTO
2018-05-21 13:47:53 +00:00
# else
# define NATIVEEXPORTPROTO
# define NATIVEEXPORT __attribute__((visibility("default")))
# endif
# endif
2018-06-02 08:55:57 +00:00
NATIVEEXPORTPROTO menu_export_t * QDECL GetMenuAPI ( menu_import_t * import ) ;