This repository has been archived on 2022-06-27. You can view files and clone it, but cannot push or open issues or pull requests.
Xash3DArchive/engine/menu_int.h

191 lines
7.7 KiB
C
Raw Permalink Normal View History

2011-05-09 22:00:00 +02:00
/*
menu_int.h - interface between engine and menu
Copyright (C) 2010 Uncle Mike
This program 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 program 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.
*/
2010-11-15 22:00:00 +01:00
#ifndef MENU_INT_H
#define MENU_INT_H
2010-07-17 22:00:00 +02:00
2010-10-22 22:00:00 +02:00
#include "cvardef.h"
2010-07-17 22:00:00 +02:00
#include "gameinfo.h"
2010-07-20 22:00:00 +02:00
#include "wrect.h"
2010-07-17 22:00:00 +02:00
2010-11-15 22:00:00 +01:00
typedef int HIMAGE; // handle to a graphic
2010-07-17 22:00:00 +02:00
2011-10-09 22:00:00 +02:00
// flags for PIC_Load
#define PIC_NEAREST (1<<0) // disable texfilter
2017-03-23 22:00:00 +01:00
#define PIC_KEEP_SOURCE (1<<1) // some images keep source
2011-10-09 22:00:00 +02:00
#define PIC_NOFLIP_TGA (1<<2) // Steam background completely ignore tga attribute 0x20
2010-07-17 22:00:00 +02:00
typedef struct ui_globalvars_s
{
float time; // unclamped host.realtime
float frametime;
2010-07-20 22:00:00 +02:00
int scrWidth; // actual values
int scrHeight;
2010-07-17 22:00:00 +02:00
int maxClients;
2018-03-03 22:00:00 +01:00
int allow_console;
2010-07-17 22:00:00 +02:00
int demoplayback;
int demorecording;
char demoname[64]; // name of currently playing demo
char maptitle[64]; // title of active map
} ui_globalvars_t;
typedef struct ui_enginefuncs_s
{
// image handlers
2011-10-09 22:00:00 +02:00
HIMAGE (*pfnPIC_Load)( const char *szPicName, const byte *ucRawImage, long ulRawImageSize, long flags );
2010-07-17 22:00:00 +02:00
void (*pfnPIC_Free)( const char *szPicName );
2010-12-02 22:00:00 +01:00
int (*pfnPIC_Width)( HIMAGE hPic );
int (*pfnPIC_Height)( HIMAGE hPic );
2010-07-17 22:00:00 +02:00
void (*pfnPIC_Set)( HIMAGE hPic, int r, int g, int b, int a );
2010-12-02 22:00:00 +01:00
void (*pfnPIC_Draw)( int x, int y, int width, int height, const wrect_t *prc );
void (*pfnPIC_DrawHoles)( int x, int y, int width, int height, const wrect_t *prc );
void (*pfnPIC_DrawTrans)( int x, int y, int width, int height, const wrect_t *prc );
void (*pfnPIC_DrawAdditive)( int x, int y, int width, int height, const wrect_t *prc );
2010-07-17 22:00:00 +02:00
void (*pfnPIC_EnableScissor)( int x, int y, int width, int height );
void (*pfnPIC_DisableScissor)( void );
// screen handlers
void (*pfnFillRGBA)( int x, int y, int width, int height, int r, int g, int b, int a );
// cvar handlers
2010-10-22 22:00:00 +02:00
cvar_t* (*pfnRegisterVariable)( const char *szName, const char *szValue, int flags );
2010-07-17 22:00:00 +02:00
float (*pfnGetCvarFloat)( const char *szName );
char* (*pfnGetCvarString)( const char *szName );
void (*pfnCvarSetString)( const char *szName, const char *szValue );
void (*pfnCvarSetValue)( const char *szName, float flValue );
// command handlers
2010-10-31 22:00:00 +01:00
int (*pfnAddCommand)( const char *cmd_name, void (*function)(void) );
2010-07-17 22:00:00 +02:00
void (*pfnClientCmd)( int execute_now, const char *szCmdString );
void (*pfnDelCommand)( const char *cmd_name );
int (*pfnCmdArgc)( void );
2010-10-31 22:00:00 +01:00
char* (*pfnCmdArgv)( int argc );
char* (*pfnCmd_Args)( void );
2010-07-17 22:00:00 +02:00
2011-04-06 22:00:00 +02:00
// debug messages (in-menu shows only notify)
2010-08-15 22:00:00 +02:00
void (*Con_Printf)( char *fmt, ... );
void (*Con_DPrintf)( char *fmt, ... );
2011-04-06 22:00:00 +02:00
void (*Con_NPrintf)( int pos, char *fmt, ... );
void (*Con_NXPrintf)( struct con_nprint_s *info, char *fmt, ... );
2010-07-17 22:00:00 +02:00
// sound handlers
void (*pfnPlayLocalSound)( const char *szSound );
2010-09-30 22:00:00 +02:00
// cinematic handlers
void (*pfnDrawLogo)( const char *filename, float x, float y, float width, float height );
int (*pfnGetLogoWidth)( void );
int (*pfnGetLogoHeight)( void );
2012-12-16 21:00:00 +01:00
float (*pfnGetLogoLength)( void ); // cinematic duration in seconds
2010-09-30 22:00:00 +02:00
2010-07-17 22:00:00 +02:00
// text message system
2010-07-20 22:00:00 +02:00
void (*pfnDrawCharacter)( int x, int y, int width, int height, int ch, int ulRGBA, HIMAGE hFont );
int (*pfnDrawConsoleString)( int x, int y, const char *string );
void (*pfnDrawSetTextColor)( int r, int g, int b, int alpha );
2010-07-17 22:00:00 +02:00
void (*pfnDrawConsoleStringLen)( const char *string, int *length, int *height );
2010-07-20 22:00:00 +02:00
void (*pfnSetConsoleDefaultColor)( int r, int g, int b ); // color must came from colors.lst
2010-07-17 22:00:00 +02:00
// custom rendering (for playermodel preview)
2010-08-07 22:00:00 +02:00
struct cl_entity_s* (*pfnGetPlayerModel)( void ); // for drawing playermodel previews
void (*pfnSetModel)( struct cl_entity_s *ed, const char *path );
2010-07-17 22:00:00 +02:00
void (*pfnClearScene)( void );
2017-02-21 22:00:00 +01:00
void (*pfnRenderScene)( const struct ref_viewpass_s *rvp );
2010-10-31 22:00:00 +01:00
int (*CL_CreateVisibleEntity)( int type, struct cl_entity_s *ent );
2010-07-17 22:00:00 +02:00
2011-04-06 22:00:00 +02:00
// misc handlers
2010-07-17 22:00:00 +02:00
void (*pfnHostError)( const char *szFmt, ... );
2011-02-26 22:00:00 +01:00
int (*pfnFileExists)( const char *filename, int gamedironly );
2010-07-17 22:00:00 +02:00
void (*pfnGetGameDir)( char *szGetGameDir );
// gameinfo handlers
int (*pfnCreateMapsList)( int fRefresh );
int (*pfnClientInGame)( void );
2010-08-15 22:00:00 +02:00
void (*pfnClientJoin)( const struct netadr_s adr );
2010-07-17 22:00:00 +02:00
// parse txt files
2010-08-20 22:00:00 +02:00
byte* (*COM_LoadFile)( const char *filename, int *pLength );
char* (*COM_ParseFile)( char *data, char *token );
void (*COM_FreeFile)( void *buffer );
2010-07-17 22:00:00 +02:00
// keyfuncs
void (*pfnKeyClearStates)( void ); // call when menu open or close
void (*pfnSetKeyDest)( int dest );
const char *(*pfnKeynumToString)( int keynum );
const char *(*pfnKeyGetBinding)( int keynum );
void (*pfnKeySetBinding)( int keynum, const char *binding );
int (*pfnKeyIsDown)( int keynum );
int (*pfnKeyGetOverstrikeMode)( void );
void (*pfnKeySetOverstrikeMode)( int fActive );
2011-01-09 22:00:00 +01:00
void *(*pfnKeyGetState)( const char *name ); // for mlook, klook etc
2010-07-17 22:00:00 +02:00
// engine memory manager
void* (*pfnMemAlloc)( size_t cb, const char *filename, const int fileline );
void (*pfnMemFree)( void *mem, const char *filename, const int fileline );
// collect info from engine
int (*pfnGetGameInfo)( GAMEINFO *pgameinfo );
GAMEINFO **(*pfnGetGamesList)( int *numGames ); // collect info about all mods
2010-09-10 22:00:00 +02:00
char **(*pfnGetFilesList)( const char *pattern, int *numFiles, int gamedironly ); // find in files
2010-07-17 22:00:00 +02:00
int (*pfnGetSaveComment)( const char *savename, char *comment );
int (*pfnGetDemoComment)( const char *demoname, char *comment );
2012-12-16 21:00:00 +01:00
int (*pfnCheckGameDll)( void ); // returns false if hl.dll is missed or invalid
2010-07-17 22:00:00 +02:00
char *(*pfnGetClipboardData)( void );
// engine launcher
2010-09-10 22:00:00 +02:00
void (*pfnShellExecute)( const char *name, const char *args, int closeEngine );
2010-07-30 22:00:00 +02:00
void (*pfnWriteServerConfig)( const char *name );
2010-07-17 22:00:00 +02:00
void (*pfnChangeInstance)( const char *newInstance, const char *szFinalMessage );
2010-11-22 22:00:00 +01:00
void (*pfnPlayBackgroundTrack)( const char *introName, const char *loopName );
2010-07-17 22:00:00 +02:00
void (*pfnHostEndGame)( const char *szFinalMessage );
2011-02-22 22:00:00 +01:00
// menu interface is freezed at version 0.75
// new functions starts here
float (*pfnRandomFloat)( float flLow, float flHigh );
long (*pfnRandomLong)( long lLow, long lHigh );
2011-04-01 22:00:00 +02:00
void (*pfnSetCursor)( void *hCursor ); // change cursor
int (*pfnIsMapValid)( char *filename );
2011-10-06 22:00:00 +02:00
void (*pfnProcessImage)( int texnum, float gamma, int topColor, int bottomColor );
2011-10-14 22:00:00 +02:00
int (*pfnCompareFileTime)( char *filename1, char *filename2, int *iCompare );
2017-03-22 22:00:00 +01:00
const char *(*pfnGetModeString)( int vid_mode );
2018-04-25 23:00:00 +02:00
int (*COM_SaveFile)( const char *filename, const void *data, long len );
int (*COM_RemoveFile)( const char *filepath );
2010-07-17 22:00:00 +02:00
} ui_enginefuncs_t;
typedef struct
{
int (*pfnVidInit)( void );
void (*pfnInit)( void );
void (*pfnShutdown)( void );
void (*pfnRedraw)( float flTime );
void (*pfnKeyEvent)( int key, int down );
void (*pfnMouseMove)( int x, int y );
void (*pfnSetActiveMenu)( int active );
2010-08-15 22:00:00 +02:00
void (*pfnAddServerToList)( struct netadr_s adr, const char *info );
2010-07-17 22:00:00 +02:00
void (*pfnGetCursorPos)( int *pos_x, int *pos_y );
void (*pfnSetCursorPos)( int pos_x, int pos_y );
void (*pfnShowCursor)( int show );
void (*pfnCharEvent)( int key );
int (*pfnMouseInRect)( void ); // mouse entering\leave game window
int (*pfnIsVisible)( void );
int (*pfnCreditsActive)( void ); // unused
void (*pfnFinalCredits)( void ); // show credits + game end
} UI_FUNCTIONS;
2010-11-15 22:00:00 +01:00
typedef int (*MENUAPI)( UI_FUNCTIONS *pFunctionTable, ui_enginefuncs_t* engfuncs, ui_globalvars_t *pGlobals );
2010-07-17 22:00:00 +02:00
2010-11-15 22:00:00 +01:00
#endif//MENU_INT_H