2010-07-18 22:00:00 +02:00
|
|
|
|
//=======================================================================
|
|
|
|
|
// Copyright XashXT Group 2010 <20>
|
2010-11-15 22:00:00 +01:00
|
|
|
|
// cl_menu.c - menu dlls interaction
|
2010-07-18 22:00:00 +02:00
|
|
|
|
//=======================================================================
|
|
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
|
#include "client.h"
|
|
|
|
|
#include "const.h"
|
2010-12-14 22:00:00 +01:00
|
|
|
|
#include "gl_local.h"
|
2010-07-18 22:00:00 +02:00
|
|
|
|
|
2011-01-03 22:00:00 +01:00
|
|
|
|
static void UI_UpdateUserinfo( void );
|
2010-11-15 22:00:00 +01:00
|
|
|
|
menu_static_t menu;
|
2010-07-18 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
void UI_UpdateMenu( float realtime )
|
|
|
|
|
{
|
2010-11-15 22:00:00 +01:00
|
|
|
|
if( !menu.hInstance ) return;
|
|
|
|
|
menu.dllFuncs.pfnRedraw( realtime );
|
2011-01-03 22:00:00 +01:00
|
|
|
|
UI_UpdateUserinfo();
|
2010-12-28 22:00:00 +01:00
|
|
|
|
Con_DrawVersion();
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-26 22:00:00 +02:00
|
|
|
|
void UI_KeyEvent( int key, qboolean down )
|
2010-07-18 22:00:00 +02:00
|
|
|
|
{
|
2010-11-15 22:00:00 +01:00
|
|
|
|
if( !menu.hInstance ) return;
|
|
|
|
|
menu.dllFuncs.pfnKeyEvent( key, down );
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UI_MouseMove( int x, int y )
|
|
|
|
|
{
|
2010-11-15 22:00:00 +01:00
|
|
|
|
if( !menu.hInstance ) return;
|
|
|
|
|
menu.dllFuncs.pfnMouseMove( x, y );
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-26 22:00:00 +02:00
|
|
|
|
void UI_SetActiveMenu( qboolean fActive )
|
2010-07-18 22:00:00 +02:00
|
|
|
|
{
|
2010-09-30 22:00:00 +02:00
|
|
|
|
movie_state_t *cin_state;
|
|
|
|
|
|
2010-12-21 22:00:00 +01:00
|
|
|
|
// don't touch menu state when video is restarted
|
|
|
|
|
if( !menu.hInstance )//|| host.state == HOST_RESTART )
|
|
|
|
|
return;
|
|
|
|
|
|
2010-11-15 22:00:00 +01:00
|
|
|
|
menu.drawLogo = fActive;
|
|
|
|
|
menu.dllFuncs.pfnSetActiveMenu( fActive );
|
2010-09-30 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
if( !fActive )
|
|
|
|
|
{
|
|
|
|
|
// close logo when menu is shutdown
|
|
|
|
|
cin_state = AVI_GetState( CIN_LOGO );
|
|
|
|
|
AVI_CloseVideo( cin_state );
|
|
|
|
|
}
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UI_AddServerToList( netadr_t adr, const char *info )
|
|
|
|
|
{
|
2010-11-15 22:00:00 +01:00
|
|
|
|
if( !menu.hInstance ) return;
|
|
|
|
|
menu.dllFuncs.pfnAddServerToList( adr, info );
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UI_GetCursorPos( int *pos_x, int *pos_y )
|
|
|
|
|
{
|
2010-11-15 22:00:00 +01:00
|
|
|
|
if( !menu.hInstance ) return;
|
|
|
|
|
menu.dllFuncs.pfnGetCursorPos( pos_x, pos_y );
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UI_SetCursorPos( int pos_x, int pos_y )
|
|
|
|
|
{
|
2010-11-15 22:00:00 +01:00
|
|
|
|
if( !menu.hInstance ) return;
|
|
|
|
|
menu.dllFuncs.pfnSetCursorPos( pos_x, pos_y );
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-26 22:00:00 +02:00
|
|
|
|
void UI_ShowCursor( qboolean show )
|
2010-07-18 22:00:00 +02:00
|
|
|
|
{
|
2010-11-15 22:00:00 +01:00
|
|
|
|
if( !menu.hInstance ) return;
|
|
|
|
|
menu.dllFuncs.pfnShowCursor( show );
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-26 22:00:00 +02:00
|
|
|
|
qboolean UI_CreditsActive( void )
|
2010-07-18 22:00:00 +02:00
|
|
|
|
{
|
2010-11-15 22:00:00 +01:00
|
|
|
|
if( !menu.hInstance ) return 0;
|
|
|
|
|
return menu.dllFuncs.pfnCreditsActive();
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UI_CharEvent( int key )
|
|
|
|
|
{
|
2010-11-15 22:00:00 +01:00
|
|
|
|
if( !menu.hInstance ) return;
|
|
|
|
|
menu.dllFuncs.pfnCharEvent( key );
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-26 22:00:00 +02:00
|
|
|
|
qboolean UI_MouseInRect( void )
|
2010-07-18 22:00:00 +02:00
|
|
|
|
{
|
2010-11-15 22:00:00 +01:00
|
|
|
|
if( !menu.hInstance ) return 1;
|
|
|
|
|
return menu.dllFuncs.pfnMouseInRect();
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-26 22:00:00 +02:00
|
|
|
|
qboolean UI_IsVisible( void )
|
2010-07-18 22:00:00 +02:00
|
|
|
|
{
|
2010-11-15 22:00:00 +01:00
|
|
|
|
if( !menu.hInstance ) return 0;
|
|
|
|
|
return menu.dllFuncs.pfnIsVisible();
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-09-30 22:00:00 +02:00
|
|
|
|
static void UI_DrawLogo( const char *filename, float x, float y, float width, float height )
|
|
|
|
|
{
|
|
|
|
|
static float cin_time;
|
|
|
|
|
static int last_frame = -1;
|
2010-10-01 22:00:00 +02:00
|
|
|
|
byte *cin_data = NULL;
|
2010-09-30 22:00:00 +02:00
|
|
|
|
movie_state_t *cin_state;
|
|
|
|
|
int cin_frame;
|
2010-10-26 22:00:00 +02:00
|
|
|
|
qboolean redraw = false;
|
2010-09-30 22:00:00 +02:00
|
|
|
|
|
2010-11-15 22:00:00 +01:00
|
|
|
|
if( !menu.drawLogo ) return;
|
2010-09-30 22:00:00 +02:00
|
|
|
|
cin_state = AVI_GetState( CIN_LOGO );
|
|
|
|
|
|
|
|
|
|
if( !AVI_IsActive( cin_state ))
|
|
|
|
|
{
|
|
|
|
|
string path;
|
|
|
|
|
const char *fullpath;
|
|
|
|
|
|
|
|
|
|
// run cinematic if not
|
|
|
|
|
com.snprintf( path, sizeof( path ), "media/%s", filename );
|
|
|
|
|
FS_DefaultExtension( path, ".avi" );
|
|
|
|
|
fullpath = FS_GetDiskPath( path );
|
|
|
|
|
|
|
|
|
|
if( FS_FileExists( path ) && !fullpath )
|
|
|
|
|
{
|
|
|
|
|
MsgDev( D_ERROR, "couldn't load %s from packfile. Please extract it\n", path );
|
2010-11-15 22:00:00 +01:00
|
|
|
|
menu.drawLogo = false;
|
2010-09-30 22:00:00 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-01 22:00:00 +02:00
|
|
|
|
AVI_OpenVideo( cin_state, fullpath, false, false, true );
|
2011-02-05 22:00:00 +01:00
|
|
|
|
if( !( AVI_GetVideoInfo( cin_state, &menu.logo_xres, &menu.logo_yres, &menu.logo_length )))
|
2010-09-30 22:00:00 +02:00
|
|
|
|
{
|
|
|
|
|
AVI_CloseVideo( cin_state );
|
2010-11-15 22:00:00 +01:00
|
|
|
|
menu.drawLogo = false;
|
2010-09-30 22:00:00 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cin_time = 0.0f;
|
|
|
|
|
last_frame = -1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-01 22:00:00 +02:00
|
|
|
|
if( width <= 0 || height <= 0 )
|
|
|
|
|
{
|
|
|
|
|
// precache call, don't draw
|
|
|
|
|
cin_time = 0.0f;
|
|
|
|
|
last_frame = -1;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-09 22:00:00 +02:00
|
|
|
|
// advances cinematic time (ignores maxfps and host_framerate settings)
|
|
|
|
|
cin_time += host.realframetime;
|
2010-09-30 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
// restarts the cinematic
|
2011-02-05 22:00:00 +01:00
|
|
|
|
if( cin_time > menu.logo_length )
|
2010-09-30 22:00:00 +02:00
|
|
|
|
cin_time = 0.0f;
|
|
|
|
|
|
|
|
|
|
// read the next frame
|
|
|
|
|
cin_frame = AVI_GetVideoFrameNumber( cin_state, cin_time );
|
|
|
|
|
|
|
|
|
|
if( cin_frame != last_frame )
|
|
|
|
|
{
|
2010-10-01 22:00:00 +02:00
|
|
|
|
cin_data = AVI_GetVideoFrame( cin_state, cin_frame );
|
2010-09-30 22:00:00 +02:00
|
|
|
|
last_frame = cin_frame;
|
|
|
|
|
redraw = true;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-25 22:00:00 +01:00
|
|
|
|
pglDisable( GL_BLEND );
|
|
|
|
|
pglDepthMask( GL_FALSE );
|
|
|
|
|
pglDisable( GL_ALPHA_TEST );
|
|
|
|
|
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
|
|
|
|
|
|
2010-12-02 22:00:00 +01:00
|
|
|
|
R_DrawStretchRaw( x, y, width, height, menu.logo_xres, menu.logo_yres, cin_data, redraw );
|
2010-09-30 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int UI_GetLogoWidth( void )
|
|
|
|
|
{
|
2010-11-15 22:00:00 +01:00
|
|
|
|
return menu.logo_xres;
|
2010-09-30 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int UI_GetLogoHeight( void )
|
|
|
|
|
{
|
2010-11-15 22:00:00 +01:00
|
|
|
|
return menu.logo_yres;
|
2010-09-30 22:00:00 +02:00
|
|
|
|
}
|
2011-01-03 22:00:00 +01:00
|
|
|
|
|
2011-02-05 22:00:00 +01:00
|
|
|
|
static float UI_GetLogoLength( void )
|
|
|
|
|
{
|
|
|
|
|
return menu.logo_length;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-03 22:00:00 +01:00
|
|
|
|
static void UI_UpdateUserinfo( void )
|
|
|
|
|
{
|
|
|
|
|
player_info_t *player;
|
|
|
|
|
|
|
|
|
|
if( !userinfo->modified ) return;
|
|
|
|
|
player = &menu.playerinfo;
|
|
|
|
|
|
|
|
|
|
com.strncpy( player->userinfo, Cvar_Userinfo(), sizeof( player->userinfo ));
|
|
|
|
|
com.strncpy( player->name, Info_ValueForKey( player->userinfo, "name" ), sizeof( player->name ));
|
|
|
|
|
com.strncpy( player->model, Info_ValueForKey( player->userinfo, "model" ), sizeof( player->model ));
|
|
|
|
|
}
|
2010-09-30 22:00:00 +02:00
|
|
|
|
|
2010-07-18 22:00:00 +02:00
|
|
|
|
void Host_Credits( void )
|
|
|
|
|
{
|
2010-11-15 22:00:00 +01:00
|
|
|
|
if( !menu.hInstance ) return;
|
|
|
|
|
menu.dllFuncs.pfnFinalCredits();
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void UI_ConvertGameInfo( GAMEINFO *out, gameinfo_t *in )
|
|
|
|
|
{
|
|
|
|
|
com.strncpy( out->gamefolder, in->gamefolder, sizeof( out->gamefolder ));
|
|
|
|
|
com.strncpy( out->startmap, in->startmap, sizeof( out->startmap ));
|
|
|
|
|
com.strncpy( out->trainmap, in->trainmap, sizeof( out->trainmap ));
|
|
|
|
|
com.strncpy( out->title, in->title, sizeof( out->title ));
|
|
|
|
|
com.strncpy( out->version, va( "%g", in->version ), sizeof( out->version ));
|
|
|
|
|
|
|
|
|
|
com.strncpy( out->game_url, in->game_url, sizeof( out->game_url ));
|
|
|
|
|
com.strncpy( out->update_url, in->update_url, sizeof( out->update_url ));
|
|
|
|
|
com.strncpy( out->size, com.pretifymem( in->size, 0 ), sizeof( out->size ));
|
|
|
|
|
com.strncpy( out->type, in->type, sizeof( out->type ));
|
|
|
|
|
com.strncpy( out->date, in->date, sizeof( out->date ));
|
|
|
|
|
|
|
|
|
|
out->gamemode = in->gamemode;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-26 22:00:00 +02:00
|
|
|
|
static qboolean PIC_Scissor( float *x, float *y, float *width, float *height, float *u0, float *v0, float *u1, float *v1 )
|
2010-07-18 22:00:00 +02:00
|
|
|
|
{
|
|
|
|
|
float dudx, dvdy;
|
|
|
|
|
|
|
|
|
|
// clip sub rect to sprite
|
|
|
|
|
if(( width == 0 ) || ( height == 0 ))
|
|
|
|
|
return false;
|
|
|
|
|
|
2010-11-15 22:00:00 +01:00
|
|
|
|
if( *x + *width <= menu.ds.scissor_x )
|
2010-07-18 22:00:00 +02:00
|
|
|
|
return false;
|
2010-11-15 22:00:00 +01:00
|
|
|
|
if( *x >= menu.ds.scissor_x + menu.ds.scissor_width )
|
2010-07-18 22:00:00 +02:00
|
|
|
|
return false;
|
2010-11-15 22:00:00 +01:00
|
|
|
|
if( *y + *height <= menu.ds.scissor_y )
|
2010-07-18 22:00:00 +02:00
|
|
|
|
return false;
|
2010-11-15 22:00:00 +01:00
|
|
|
|
if( *y >= menu.ds.scissor_y + menu.ds.scissor_height )
|
2010-07-18 22:00:00 +02:00
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
dudx = (*u1 - *u0) / *width;
|
|
|
|
|
dvdy = (*v1 - *v0) / *height;
|
|
|
|
|
|
2010-11-15 22:00:00 +01:00
|
|
|
|
if( *x < menu.ds.scissor_x )
|
2010-07-18 22:00:00 +02:00
|
|
|
|
{
|
2010-11-15 22:00:00 +01:00
|
|
|
|
*u0 += (menu.ds.scissor_x - *x) * dudx;
|
|
|
|
|
*width -= menu.ds.scissor_x - *x;
|
|
|
|
|
*x = menu.ds.scissor_x;
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-11-15 22:00:00 +01:00
|
|
|
|
if( *x + *width > menu.ds.scissor_x + menu.ds.scissor_width )
|
2010-07-18 22:00:00 +02:00
|
|
|
|
{
|
2010-11-15 22:00:00 +01:00
|
|
|
|
*u1 -= (*x + *width - (menu.ds.scissor_x + menu.ds.scissor_width)) * dudx;
|
|
|
|
|
*width = menu.ds.scissor_x + menu.ds.scissor_width - *x;
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-11-15 22:00:00 +01:00
|
|
|
|
if( *y < menu.ds.scissor_y )
|
2010-07-18 22:00:00 +02:00
|
|
|
|
{
|
2010-11-15 22:00:00 +01:00
|
|
|
|
*v0 += (menu.ds.scissor_y - *y) * dvdy;
|
|
|
|
|
*height -= menu.ds.scissor_y - *y;
|
|
|
|
|
*y = menu.ds.scissor_y;
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-11-15 22:00:00 +01:00
|
|
|
|
if( *y + *height > menu.ds.scissor_y + menu.ds.scissor_height )
|
2010-07-18 22:00:00 +02:00
|
|
|
|
{
|
2010-11-15 22:00:00 +01:00
|
|
|
|
*v1 -= (*y + *height - (menu.ds.scissor_y + menu.ds.scissor_height)) * dvdy;
|
|
|
|
|
*height = menu.ds.scissor_y + menu.ds.scissor_height - *y;
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
====================
|
|
|
|
|
PIC_DrawGeneric
|
|
|
|
|
|
|
|
|
|
draw hudsprite routine
|
|
|
|
|
====================
|
|
|
|
|
*/
|
2010-12-02 22:00:00 +01:00
|
|
|
|
static void PIC_DrawGeneric( float x, float y, float width, float height, const wrect_t *prc )
|
2010-07-18 22:00:00 +02:00
|
|
|
|
{
|
|
|
|
|
float s1, s2, t1, t2;
|
|
|
|
|
|
|
|
|
|
if( width == -1 && height == -1 )
|
|
|
|
|
{
|
|
|
|
|
int w, h;
|
|
|
|
|
|
|
|
|
|
// assume we get sizes from image
|
2010-12-02 22:00:00 +01:00
|
|
|
|
R_GetTextureParms( &w, &h, menu.ds.gl_texturenum );
|
2010-07-18 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
width = w;
|
|
|
|
|
height = h;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( prc )
|
|
|
|
|
{
|
2010-07-20 22:00:00 +02:00
|
|
|
|
// calc user-defined rectangle
|
|
|
|
|
s1 = (float)prc->left / width;
|
|
|
|
|
t1 = (float)prc->top / height;
|
|
|
|
|
s2 = (float)prc->right / width;
|
|
|
|
|
t2 = (float)prc->bottom / height;
|
|
|
|
|
width = prc->right - prc->left;
|
|
|
|
|
height = prc->bottom - prc->top;
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
s1 = t1 = 0.0f;
|
|
|
|
|
s2 = t2 = 1.0f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// pass scissor test if supposed
|
2010-11-15 22:00:00 +01:00
|
|
|
|
if( menu.ds.scissor_test && !PIC_Scissor( &x, &y, &width, &height, &s1, &t1, &s2, &t2 ))
|
2010-07-18 22:00:00 +02:00
|
|
|
|
return;
|
|
|
|
|
|
2010-12-02 22:00:00 +01:00
|
|
|
|
R_DrawStretchPic( x, y, width, height, s1, t1, s2, t2, menu.ds.gl_texturenum );
|
2010-12-14 22:00:00 +01:00
|
|
|
|
pglColor4ub( 255, 255, 255, 255 );
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
===============================================================================
|
2010-11-15 22:00:00 +01:00
|
|
|
|
MainUI Builtin Functions
|
2010-07-18 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
===============================================================================
|
|
|
|
|
*/
|
|
|
|
|
/*
|
|
|
|
|
=========
|
|
|
|
|
pfnPIC_Load
|
|
|
|
|
|
|
|
|
|
=========
|
|
|
|
|
*/
|
2010-10-06 22:00:00 +02:00
|
|
|
|
static HIMAGE pfnPIC_Load( const char *szPicName, const byte *image_buf, long image_size )
|
2010-07-18 22:00:00 +02:00
|
|
|
|
{
|
|
|
|
|
if( !szPicName || !*szPicName )
|
|
|
|
|
{
|
|
|
|
|
MsgDev( D_ERROR, "CL_LoadImage: bad name!\n" );
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2010-12-02 22:00:00 +01:00
|
|
|
|
return GL_LoadTexture( szPicName, image_buf, image_size, TF_IMAGE );
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
=========
|
|
|
|
|
pfnPIC_Free
|
|
|
|
|
|
|
|
|
|
=========
|
|
|
|
|
*/
|
|
|
|
|
static void pfnPIC_Free( const char *szPicName )
|
|
|
|
|
{
|
2010-12-02 22:00:00 +01:00
|
|
|
|
GL_FreeImage( szPicName );
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
=========
|
2010-12-02 22:00:00 +01:00
|
|
|
|
pfnPIC_Width
|
2010-07-18 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
=========
|
|
|
|
|
*/
|
2010-12-02 22:00:00 +01:00
|
|
|
|
static int pfnPIC_Width( HIMAGE hPic )
|
2010-07-18 22:00:00 +02:00
|
|
|
|
{
|
2010-12-02 22:00:00 +01:00
|
|
|
|
int picWidth;
|
2010-07-18 22:00:00 +02:00
|
|
|
|
|
2010-12-02 22:00:00 +01:00
|
|
|
|
R_GetTextureParms( &picWidth, NULL, hPic );
|
2010-07-18 22:00:00 +02:00
|
|
|
|
|
2010-12-02 22:00:00 +01:00
|
|
|
|
return picWidth;
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
=========
|
|
|
|
|
pfnPIC_Height
|
|
|
|
|
|
|
|
|
|
=========
|
|
|
|
|
*/
|
2010-12-02 22:00:00 +01:00
|
|
|
|
static int pfnPIC_Height( HIMAGE hPic )
|
2010-07-18 22:00:00 +02:00
|
|
|
|
{
|
|
|
|
|
int picHeight;
|
|
|
|
|
|
2010-12-02 22:00:00 +01:00
|
|
|
|
R_GetTextureParms( NULL, &picHeight, hPic );
|
2010-07-18 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
return picHeight;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
=========
|
|
|
|
|
pfnPIC_Set
|
|
|
|
|
|
|
|
|
|
=========
|
|
|
|
|
*/
|
2010-12-02 22:00:00 +01:00
|
|
|
|
void pfnPIC_Set( HIMAGE hPic, int r, int g, int b, int a )
|
2010-07-18 22:00:00 +02:00
|
|
|
|
{
|
2010-12-02 22:00:00 +01:00
|
|
|
|
menu.ds.gl_texturenum = hPic;
|
2010-12-14 22:00:00 +01:00
|
|
|
|
r = bound( 0, r, 255 );
|
|
|
|
|
g = bound( 0, g, 255 );
|
|
|
|
|
b = bound( 0, b, 255 );
|
|
|
|
|
a = bound( 0, a, 255 );
|
|
|
|
|
pglColor4ub( r, g, b, a );
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
=========
|
|
|
|
|
pfnPIC_Draw
|
|
|
|
|
|
|
|
|
|
=========
|
|
|
|
|
*/
|
2010-12-02 22:00:00 +01:00
|
|
|
|
void pfnPIC_Draw( int x, int y, int width, int height, const wrect_t *prc )
|
2010-07-18 22:00:00 +02:00
|
|
|
|
{
|
2010-12-02 22:00:00 +01:00
|
|
|
|
GL_SetRenderMode( kRenderNormal );
|
|
|
|
|
PIC_DrawGeneric( x, y, width, height, prc );
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
=========
|
|
|
|
|
pfnPIC_DrawTrans
|
|
|
|
|
|
|
|
|
|
=========
|
|
|
|
|
*/
|
2010-12-02 22:00:00 +01:00
|
|
|
|
void pfnPIC_DrawTrans( int x, int y, int width, int height, const wrect_t *prc )
|
2010-07-18 22:00:00 +02:00
|
|
|
|
{
|
2010-12-02 22:00:00 +01:00
|
|
|
|
GL_SetRenderMode( kRenderTransTexture );
|
|
|
|
|
PIC_DrawGeneric( x, y, width, height, prc );
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
=========
|
|
|
|
|
pfnPIC_DrawHoles
|
|
|
|
|
|
|
|
|
|
=========
|
|
|
|
|
*/
|
2010-12-02 22:00:00 +01:00
|
|
|
|
void pfnPIC_DrawHoles( int x, int y, int width, int height, const wrect_t *prc )
|
2010-07-18 22:00:00 +02:00
|
|
|
|
{
|
2010-12-02 22:00:00 +01:00
|
|
|
|
GL_SetRenderMode( kRenderTransAlpha );
|
|
|
|
|
PIC_DrawGeneric( x, y, width, height, prc );
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
=========
|
|
|
|
|
pfnPIC_DrawAdditive
|
|
|
|
|
|
|
|
|
|
=========
|
|
|
|
|
*/
|
2010-12-02 22:00:00 +01:00
|
|
|
|
void pfnPIC_DrawAdditive( int x, int y, int width, int height, const wrect_t *prc )
|
2010-07-18 22:00:00 +02:00
|
|
|
|
{
|
2010-12-02 22:00:00 +01:00
|
|
|
|
GL_SetRenderMode( kRenderTransAdd );
|
|
|
|
|
PIC_DrawGeneric( x, y, width, height, prc );
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
=========
|
|
|
|
|
pfnPIC_EnableScissor
|
|
|
|
|
|
|
|
|
|
=========
|
|
|
|
|
*/
|
|
|
|
|
static void pfnPIC_EnableScissor( int x, int y, int width, int height )
|
|
|
|
|
{
|
|
|
|
|
// check bounds
|
2010-11-15 22:00:00 +01:00
|
|
|
|
x = bound( 0, x, menu.globals->scrWidth );
|
|
|
|
|
y = bound( 0, y, menu.globals->scrHeight );
|
|
|
|
|
width = bound( 0, width, menu.globals->scrWidth - x );
|
|
|
|
|
height = bound( 0, height, menu.globals->scrHeight - y );
|
|
|
|
|
|
|
|
|
|
menu.ds.scissor_x = x;
|
|
|
|
|
menu.ds.scissor_width = width;
|
|
|
|
|
menu.ds.scissor_y = y;
|
|
|
|
|
menu.ds.scissor_height = height;
|
|
|
|
|
menu.ds.scissor_test = true;
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
=========
|
|
|
|
|
pfnPIC_DisableScissor
|
|
|
|
|
|
|
|
|
|
=========
|
|
|
|
|
*/
|
|
|
|
|
static void pfnPIC_DisableScissor( void )
|
|
|
|
|
{
|
2010-11-15 22:00:00 +01:00
|
|
|
|
menu.ds.scissor_x = 0;
|
|
|
|
|
menu.ds.scissor_width = 0;
|
|
|
|
|
menu.ds.scissor_y = 0;
|
|
|
|
|
menu.ds.scissor_height = 0;
|
|
|
|
|
menu.ds.scissor_test = false;
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
=============
|
|
|
|
|
pfnFillRGBA
|
|
|
|
|
|
|
|
|
|
=============
|
|
|
|
|
*/
|
|
|
|
|
static void pfnFillRGBA( int x, int y, int width, int height, int r, int g, int b, int a )
|
|
|
|
|
{
|
2010-12-14 22:00:00 +01:00
|
|
|
|
r = bound( 0, r, 255 );
|
|
|
|
|
g = bound( 0, g, 255 );
|
|
|
|
|
b = bound( 0, b, 255 );
|
|
|
|
|
a = bound( 0, a, 255 );
|
|
|
|
|
pglColor4ub( r, g, b, a );
|
2010-12-02 22:00:00 +01:00
|
|
|
|
GL_SetRenderMode( kRenderTransTexture );
|
|
|
|
|
R_DrawStretchPic( x, y, width, height, 0, 0, 1, 1, cls.fillImage );
|
2010-12-14 22:00:00 +01:00
|
|
|
|
pglColor4ub( 255, 255, 255, 255 );
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
=============
|
|
|
|
|
pfnClientCmd
|
|
|
|
|
|
|
|
|
|
=============
|
|
|
|
|
*/
|
|
|
|
|
static void pfnClientCmd( int execute_now, const char *szCmdString )
|
|
|
|
|
{
|
|
|
|
|
int when;
|
|
|
|
|
|
|
|
|
|
if( execute_now )
|
|
|
|
|
when = EXEC_NOW;
|
|
|
|
|
else when = EXEC_APPEND;
|
|
|
|
|
|
|
|
|
|
// client command executes immediately
|
|
|
|
|
Cbuf_ExecuteText( when, szCmdString );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
=============
|
|
|
|
|
pfnPlaySound
|
|
|
|
|
|
|
|
|
|
=============
|
|
|
|
|
*/
|
|
|
|
|
static void pfnPlaySound( const char *szSound )
|
|
|
|
|
{
|
2010-07-21 22:00:00 +02:00
|
|
|
|
if( !szSound || !*szSound ) return;
|
2010-07-18 22:00:00 +02:00
|
|
|
|
S_StartLocalSound( szSound );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
=============
|
|
|
|
|
pfnDrawCharacter
|
|
|
|
|
|
2010-07-20 22:00:00 +02:00
|
|
|
|
quakefont draw character
|
2010-07-18 22:00:00 +02:00
|
|
|
|
=============
|
|
|
|
|
*/
|
2010-07-20 22:00:00 +02:00
|
|
|
|
static void pfnDrawCharacter( int x, int y, int width, int height, int ch, int ulRGBA, HIMAGE hFont )
|
2010-07-18 22:00:00 +02:00
|
|
|
|
{
|
2010-07-20 22:00:00 +02:00
|
|
|
|
rgba_t color;
|
|
|
|
|
float row, col, size;
|
2010-07-18 22:00:00 +02:00
|
|
|
|
|
2010-07-20 22:00:00 +02:00
|
|
|
|
ch &= 255;
|
2010-07-18 22:00:00 +02:00
|
|
|
|
|
2010-12-02 22:00:00 +01:00
|
|
|
|
if( ch == ' ' ) return;
|
2010-07-20 22:00:00 +02:00
|
|
|
|
if( y < -height ) return;
|
|
|
|
|
|
|
|
|
|
color[3] = (ulRGBA & 0xFF000000) >> 24;
|
|
|
|
|
color[0] = (ulRGBA & 0xFF0000) >> 16;
|
|
|
|
|
color[1] = (ulRGBA & 0xFF00) >> 8;
|
|
|
|
|
color[2] = (ulRGBA & 0xFF) >> 0;
|
2010-12-14 22:00:00 +01:00
|
|
|
|
pglColor4ubv( color );
|
2010-07-20 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
col = (ch & 15) * 0.0625 + (0.5f / 256.0f);
|
|
|
|
|
row = (ch >> 4) * 0.0625 + (0.5f / 256.0f);
|
|
|
|
|
size = 0.0625f - (1.0f / 256.0f);
|
2010-07-18 22:00:00 +02:00
|
|
|
|
|
2010-12-02 22:00:00 +01:00
|
|
|
|
GL_SetRenderMode( kRenderTransTexture );
|
|
|
|
|
R_DrawStretchPic( x, y, width, height, col, row, col + size, row + size, hFont );
|
2010-12-14 22:00:00 +01:00
|
|
|
|
pglColor4ub( 255, 255, 255, 255 );
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
=============
|
|
|
|
|
pfnDrawConsoleString
|
|
|
|
|
|
|
|
|
|
drawing string like a console string
|
|
|
|
|
=============
|
|
|
|
|
*/
|
2010-07-20 22:00:00 +02:00
|
|
|
|
static int pfnDrawConsoleString( int x, int y, const char *string )
|
2010-07-18 22:00:00 +02:00
|
|
|
|
{
|
2010-07-20 22:00:00 +02:00
|
|
|
|
int drawLen;
|
|
|
|
|
|
2010-07-18 22:00:00 +02:00
|
|
|
|
if( !string || !*string ) return 0; // silent ignore
|
2010-11-15 22:00:00 +01:00
|
|
|
|
drawLen = Con_DrawString( x, y, string, menu.ds.textColor );
|
|
|
|
|
MakeRGBA( menu.ds.textColor, 255, 255, 255, 255 );
|
2010-07-20 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
return drawLen; // exclude color prexfixes
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
=============
|
|
|
|
|
pfnDrawSetTextColor
|
|
|
|
|
|
|
|
|
|
set color for anything
|
|
|
|
|
=============
|
|
|
|
|
*/
|
2010-07-20 22:00:00 +02:00
|
|
|
|
static void pfnDrawSetTextColor( int r, int g, int b, int alpha )
|
2010-07-18 22:00:00 +02:00
|
|
|
|
{
|
|
|
|
|
// bound color and convert to byte
|
2010-11-15 22:00:00 +01:00
|
|
|
|
menu.ds.textColor[0] = r;
|
|
|
|
|
menu.ds.textColor[1] = g;
|
|
|
|
|
menu.ds.textColor[2] = b;
|
|
|
|
|
menu.ds.textColor[3] = alpha;
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
====================
|
|
|
|
|
pfnGetPlayerModel
|
|
|
|
|
|
|
|
|
|
for drawing playermodel previews
|
|
|
|
|
====================
|
|
|
|
|
*/
|
2010-08-07 22:00:00 +02:00
|
|
|
|
static cl_entity_t* pfnGetPlayerModel( void )
|
2010-07-18 22:00:00 +02:00
|
|
|
|
{
|
2010-11-15 22:00:00 +01:00
|
|
|
|
return &menu.playermodel;
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
====================
|
|
|
|
|
pfnSetPlayerModel
|
|
|
|
|
|
|
|
|
|
for drawing playermodel previews
|
|
|
|
|
====================
|
|
|
|
|
*/
|
2010-08-07 22:00:00 +02:00
|
|
|
|
static void pfnSetPlayerModel( cl_entity_t *ent, const char *path )
|
2010-07-18 22:00:00 +02:00
|
|
|
|
{
|
2010-12-08 22:00:00 +01:00
|
|
|
|
Mod_RegisterModel( path, MAX_MODELS - 1 );
|
2010-08-07 22:00:00 +02:00
|
|
|
|
ent->curstate.modelindex = MAX_MODELS - 1;
|
2011-02-20 22:00:00 +01:00
|
|
|
|
ent->model = Mod_Handle( MAX_MODELS - 1 );
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
====================
|
|
|
|
|
pfnRenderScene
|
|
|
|
|
|
|
|
|
|
for drawing playermodel previews
|
|
|
|
|
====================
|
|
|
|
|
*/
|
|
|
|
|
static void pfnRenderScene( const ref_params_t *fd )
|
|
|
|
|
{
|
2010-12-02 22:00:00 +01:00
|
|
|
|
if( !fd || fd->fov_x <= 0.0f || fd->fov_y <= 0.0f )
|
|
|
|
|
return;
|
|
|
|
|
R_RenderFrame( fd, false );
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
====================
|
|
|
|
|
pfnClientJoin
|
|
|
|
|
|
|
|
|
|
send client connect
|
|
|
|
|
====================
|
|
|
|
|
*/
|
|
|
|
|
static void pfnClientJoin( const netadr_t adr )
|
|
|
|
|
{
|
|
|
|
|
Cbuf_ExecuteText( EXEC_APPEND, va( "connect %s\n", NET_AdrToString( adr )));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
====================
|
|
|
|
|
pfnKeyGetOverstrikeMode
|
|
|
|
|
|
|
|
|
|
get global key overstrike state
|
|
|
|
|
====================
|
|
|
|
|
*/
|
|
|
|
|
static int pfnKeyGetOverstrikeMode( void )
|
|
|
|
|
{
|
|
|
|
|
return host.key_overstrike;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
====================
|
|
|
|
|
pfnKeySetOverstrikeMode
|
|
|
|
|
|
|
|
|
|
set global key overstrike mode
|
|
|
|
|
====================
|
|
|
|
|
*/
|
|
|
|
|
static void pfnKeySetOverstrikeMode( int fActive )
|
|
|
|
|
{
|
|
|
|
|
host.key_overstrike = fActive;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-09 22:00:00 +01:00
|
|
|
|
/*
|
|
|
|
|
====================
|
|
|
|
|
pfnKeyGetState
|
|
|
|
|
|
|
|
|
|
returns kbutton struct if found
|
|
|
|
|
====================
|
|
|
|
|
*/
|
|
|
|
|
static void *pfnKeyGetState( const char *name )
|
|
|
|
|
{
|
|
|
|
|
if( clgame.dllFuncs.KB_Find )
|
|
|
|
|
return clgame.dllFuncs.KB_Find( name );
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-18 22:00:00 +02:00
|
|
|
|
/*
|
|
|
|
|
=========
|
|
|
|
|
pfnMemAlloc
|
|
|
|
|
|
|
|
|
|
=========
|
|
|
|
|
*/
|
|
|
|
|
static void *pfnMemAlloc( size_t cb, const char *filename, const int fileline )
|
|
|
|
|
{
|
2010-11-15 22:00:00 +01:00
|
|
|
|
return com.malloc( menu.mempool, cb, filename, fileline );
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
=========
|
|
|
|
|
pfnMemFree
|
|
|
|
|
|
|
|
|
|
=========
|
|
|
|
|
*/
|
|
|
|
|
static void pfnMemFree( void *mem, const char *filename, const int fileline )
|
|
|
|
|
{
|
|
|
|
|
com.free( mem, filename, fileline );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
=========
|
|
|
|
|
pfnGetGameInfo
|
|
|
|
|
|
|
|
|
|
=========
|
|
|
|
|
*/
|
|
|
|
|
static int pfnGetGameInfo( GAMEINFO *pgameinfo )
|
|
|
|
|
{
|
|
|
|
|
if( !pgameinfo ) return 0;
|
|
|
|
|
|
2010-11-15 22:00:00 +01:00
|
|
|
|
*pgameinfo = menu.gameInfo;
|
2010-07-18 22:00:00 +02:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
=========
|
|
|
|
|
pfnGetGamesList
|
|
|
|
|
|
|
|
|
|
=========
|
|
|
|
|
*/
|
|
|
|
|
static GAMEINFO **pfnGetGamesList( int *numGames )
|
|
|
|
|
{
|
|
|
|
|
if( numGames ) *numGames = SI->numgames;
|
2010-11-15 22:00:00 +01:00
|
|
|
|
return menu.modsInfo;
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
=========
|
|
|
|
|
pfnGetFilesList
|
|
|
|
|
|
|
|
|
|
release prev search on a next call
|
|
|
|
|
=========
|
|
|
|
|
*/
|
2010-09-10 22:00:00 +02:00
|
|
|
|
static char **pfnGetFilesList( const char *pattern, int *numFiles, int gamedironly )
|
2010-07-18 22:00:00 +02:00
|
|
|
|
{
|
|
|
|
|
static search_t *t = NULL;
|
|
|
|
|
|
|
|
|
|
if( t ) Mem_Free( t ); // release prev search
|
|
|
|
|
|
2010-09-10 22:00:00 +02:00
|
|
|
|
t = FS_SearchExt( pattern, true, gamedironly );
|
2010-07-18 22:00:00 +02:00
|
|
|
|
if( !t )
|
|
|
|
|
{
|
|
|
|
|
if( numFiles ) *numFiles = 0;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( numFiles ) *numFiles = t->numfilenames;
|
|
|
|
|
return t->filenames;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
=========
|
|
|
|
|
pfnGetClipboardData
|
|
|
|
|
|
|
|
|
|
pointer must be released in call place
|
|
|
|
|
=========
|
|
|
|
|
*/
|
|
|
|
|
static char *pfnGetClipboardData( void )
|
|
|
|
|
{
|
|
|
|
|
return Sys_GetClipboardData();
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-22 22:00:00 +02:00
|
|
|
|
/*
|
|
|
|
|
=========
|
|
|
|
|
pfnCheckGameDll
|
|
|
|
|
|
|
|
|
|
=========
|
|
|
|
|
*/
|
|
|
|
|
int pfnCheckGameDll( void )
|
|
|
|
|
{
|
|
|
|
|
void *hInst;
|
|
|
|
|
|
|
|
|
|
if( SV_Active( )) return true;
|
|
|
|
|
|
|
|
|
|
if(( hInst = FS_LoadLibrary( GI->game_dll, true )) != NULL )
|
|
|
|
|
{
|
|
|
|
|
FS_FreeLibrary( hInst );
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-18 22:00:00 +02:00
|
|
|
|
/*
|
|
|
|
|
=========
|
|
|
|
|
pfnShellExecute
|
|
|
|
|
|
|
|
|
|
=========
|
|
|
|
|
*/
|
2010-10-26 22:00:00 +02:00
|
|
|
|
static void pfnShellExecute( const char *name, const char *args, qboolean closeEngine )
|
2010-07-18 22:00:00 +02:00
|
|
|
|
{
|
|
|
|
|
Sys_ShellExecute( name, args, closeEngine );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
=========
|
|
|
|
|
pfnChangeInstance
|
|
|
|
|
|
|
|
|
|
=========
|
|
|
|
|
*/
|
|
|
|
|
static void pfnChangeInstance( const char *newInstance, const char *szFinalMessage )
|
|
|
|
|
{
|
|
|
|
|
if( !szFinalMessage ) szFinalMessage = "";
|
|
|
|
|
if( !newInstance || !*newInstance ) return;
|
|
|
|
|
|
|
|
|
|
Sys_NewInstance( newInstance, szFinalMessage );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
=========
|
|
|
|
|
pfnHostNewGame
|
|
|
|
|
|
|
|
|
|
=========
|
|
|
|
|
*/
|
|
|
|
|
static void pfnHostNewGame( const char *mapName )
|
|
|
|
|
{
|
|
|
|
|
if( !mapName || !*mapName ) return;
|
|
|
|
|
Host_NewGame( mapName, false );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
=========
|
|
|
|
|
pfnHostEndGame
|
|
|
|
|
|
|
|
|
|
=========
|
|
|
|
|
*/
|
|
|
|
|
static void pfnHostEndGame( const char *szFinalMessage )
|
|
|
|
|
{
|
|
|
|
|
if( !szFinalMessage ) szFinalMessage = "";
|
|
|
|
|
Host_EndGame( szFinalMessage );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// engine callbacks
|
|
|
|
|
static ui_enginefuncs_t gEngfuncs =
|
|
|
|
|
{
|
|
|
|
|
pfnPIC_Load,
|
|
|
|
|
pfnPIC_Free,
|
|
|
|
|
pfnPIC_Width,
|
2010-12-02 22:00:00 +01:00
|
|
|
|
pfnPIC_Height,
|
2010-07-18 22:00:00 +02:00
|
|
|
|
pfnPIC_Set,
|
|
|
|
|
pfnPIC_Draw,
|
|
|
|
|
pfnPIC_DrawHoles,
|
|
|
|
|
pfnPIC_DrawTrans,
|
|
|
|
|
pfnPIC_DrawAdditive,
|
|
|
|
|
pfnPIC_EnableScissor,
|
|
|
|
|
pfnPIC_DisableScissor,
|
|
|
|
|
pfnFillRGBA,
|
2010-10-20 22:00:00 +02:00
|
|
|
|
pfnCvar_RegisterVariable,
|
2010-07-18 22:00:00 +02:00
|
|
|
|
pfnCVarGetValue,
|
|
|
|
|
pfnCVarGetString,
|
|
|
|
|
pfnCVarSetString,
|
|
|
|
|
pfnCVarSetValue,
|
|
|
|
|
pfnAddCommand,
|
|
|
|
|
pfnClientCmd,
|
|
|
|
|
pfnDelCommand,
|
|
|
|
|
pfnCmd_Argc,
|
|
|
|
|
pfnCmd_Argv,
|
|
|
|
|
pfnCmd_Args,
|
2010-08-20 22:00:00 +02:00
|
|
|
|
Con_Printf,
|
|
|
|
|
Con_DPrintf,
|
2010-07-18 22:00:00 +02:00
|
|
|
|
pfnPlaySound,
|
2010-09-30 22:00:00 +02:00
|
|
|
|
UI_DrawLogo,
|
|
|
|
|
UI_GetLogoWidth,
|
|
|
|
|
UI_GetLogoHeight,
|
2011-02-05 22:00:00 +01:00
|
|
|
|
UI_GetLogoLength,
|
2010-07-18 22:00:00 +02:00
|
|
|
|
pfnDrawCharacter,
|
|
|
|
|
pfnDrawConsoleString,
|
|
|
|
|
pfnDrawSetTextColor,
|
2010-07-20 22:00:00 +02:00
|
|
|
|
Con_DrawStringLen,
|
|
|
|
|
Con_DefaultColor,
|
2010-07-18 22:00:00 +02:00
|
|
|
|
pfnGetPlayerModel,
|
|
|
|
|
pfnSetPlayerModel,
|
|
|
|
|
V_ClearScene,
|
|
|
|
|
pfnRenderScene,
|
|
|
|
|
CL_AddEntity,
|
|
|
|
|
pfnLoadLibrary,
|
|
|
|
|
pfnGetProcAddress,
|
|
|
|
|
pfnFreeLibrary,
|
|
|
|
|
Host_Error,
|
|
|
|
|
pfnFileExists,
|
|
|
|
|
pfnGetGameDir,
|
|
|
|
|
VGui_GetPanel,
|
|
|
|
|
VGui_ViewportPaintBackground,
|
|
|
|
|
Cmd_CheckMapsList,
|
|
|
|
|
CL_Active,
|
|
|
|
|
pfnClientJoin,
|
|
|
|
|
pfnLoadFile,
|
2010-08-20 22:00:00 +02:00
|
|
|
|
COM_ParseFile,
|
2010-07-18 22:00:00 +02:00
|
|
|
|
pfnFreeFile,
|
|
|
|
|
Key_ClearStates,
|
|
|
|
|
Key_SetKeyDest,
|
|
|
|
|
Key_KeynumToString,
|
|
|
|
|
Key_GetBinding,
|
|
|
|
|
Key_SetBinding,
|
|
|
|
|
Key_IsDown,
|
|
|
|
|
pfnKeyGetOverstrikeMode,
|
|
|
|
|
pfnKeySetOverstrikeMode,
|
2011-01-09 22:00:00 +01:00
|
|
|
|
pfnKeyGetState,
|
2010-07-18 22:00:00 +02:00
|
|
|
|
pfnMemAlloc,
|
|
|
|
|
pfnMemFree,
|
|
|
|
|
pfnGetGameInfo,
|
|
|
|
|
pfnGetGamesList,
|
|
|
|
|
pfnGetFilesList,
|
|
|
|
|
SV_GetComment,
|
|
|
|
|
CL_GetComment,
|
2010-10-22 22:00:00 +02:00
|
|
|
|
pfnCheckGameDll,
|
2010-07-18 22:00:00 +02:00
|
|
|
|
pfnGetClipboardData,
|
|
|
|
|
pfnShellExecute,
|
|
|
|
|
Host_WriteServerConfig,
|
|
|
|
|
pfnChangeInstance,
|
2010-11-22 22:00:00 +01:00
|
|
|
|
S_StartBackgroundTrack,
|
2010-07-18 22:00:00 +02:00
|
|
|
|
pfnHostEndGame,
|
2011-02-22 22:00:00 +01:00
|
|
|
|
pfnRandomFloat,
|
|
|
|
|
pfnRandomLong,
|
2010-07-18 22:00:00 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void UI_UnloadProgs( void )
|
|
|
|
|
{
|
2010-11-15 22:00:00 +01:00
|
|
|
|
if( !menu.hInstance ) return;
|
2010-07-18 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
// deinitialize game
|
2010-11-15 22:00:00 +01:00
|
|
|
|
menu.dllFuncs.pfnShutdown();
|
2010-07-18 22:00:00 +02:00
|
|
|
|
|
2010-11-15 22:00:00 +01:00
|
|
|
|
FS_FreeLibrary( menu.hInstance );
|
|
|
|
|
Mem_FreePool( &menu.mempool );
|
|
|
|
|
Mem_Set( &menu, 0, sizeof( menu ));
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-26 22:00:00 +02:00
|
|
|
|
qboolean UI_LoadProgs( const char *name )
|
2010-07-18 22:00:00 +02:00
|
|
|
|
{
|
2010-11-15 22:00:00 +01:00
|
|
|
|
static MENUAPI GetMenuAPI;
|
2011-01-09 22:00:00 +01:00
|
|
|
|
static ui_enginefuncs_t gpEngfuncs;
|
2010-07-18 22:00:00 +02:00
|
|
|
|
static ui_globalvars_t gpGlobals;
|
|
|
|
|
int i;
|
|
|
|
|
|
2010-11-15 22:00:00 +01:00
|
|
|
|
if( menu.hInstance ) UI_UnloadProgs();
|
2010-07-18 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
// setup globals
|
2010-11-15 22:00:00 +01:00
|
|
|
|
menu.globals = &gpGlobals;
|
2010-07-18 22:00:00 +02:00
|
|
|
|
|
2010-11-15 22:00:00 +01:00
|
|
|
|
menu.mempool = Mem_AllocPool( "Menu Pool" );
|
|
|
|
|
menu.hInstance = FS_LoadLibrary( name, false );
|
|
|
|
|
if( !menu.hInstance ) return false;
|
2010-07-18 22:00:00 +02:00
|
|
|
|
|
2010-11-15 22:00:00 +01:00
|
|
|
|
GetMenuAPI = (MENUAPI)FS_GetProcAddress( menu.hInstance, "GetMenuAPI" );
|
2010-07-18 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
if( !GetMenuAPI )
|
|
|
|
|
{
|
2010-11-15 22:00:00 +01:00
|
|
|
|
FS_FreeLibrary( menu.hInstance );
|
|
|
|
|
MsgDev( D_NOTE, "UI_LoadProgs: failed to get address of GetMenuAPI proc\n" );
|
|
|
|
|
menu.hInstance = NULL;
|
2010-07-18 22:00:00 +02:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-09 22:00:00 +01:00
|
|
|
|
// make local copy of engfuncs to prevent overwrite it with user dll
|
|
|
|
|
Mem_Copy( &gpEngfuncs, &gEngfuncs, sizeof( gpEngfuncs ));
|
|
|
|
|
|
|
|
|
|
if( !GetMenuAPI( &menu.dllFuncs, &gpEngfuncs, menu.globals ))
|
2010-07-18 22:00:00 +02:00
|
|
|
|
{
|
2010-11-15 22:00:00 +01:00
|
|
|
|
FS_FreeLibrary( menu.hInstance );
|
2010-07-18 22:00:00 +02:00
|
|
|
|
MsgDev( D_NOTE, "UI_LoadProgs: can't init client API\n" );
|
2010-11-15 22:00:00 +01:00
|
|
|
|
menu.hInstance = NULL;
|
2010-07-18 22:00:00 +02:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// setup gameinfo
|
|
|
|
|
for( i = 0; i < SI->numgames; i++ )
|
|
|
|
|
{
|
2010-11-15 22:00:00 +01:00
|
|
|
|
menu.modsInfo[i] = Mem_Alloc( menu.mempool, sizeof( GAMEINFO ));
|
|
|
|
|
UI_ConvertGameInfo( menu.modsInfo[i], SI->games[i] );
|
2010-07-18 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-11-15 22:00:00 +01:00
|
|
|
|
UI_ConvertGameInfo( &menu.gameInfo, SI->GameInfo ); // current gameinfo
|
2010-07-18 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
// setup globals
|
2010-11-15 22:00:00 +01:00
|
|
|
|
menu.globals->developer = host.developer;
|
2010-07-18 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
// initialize game
|
2010-11-15 22:00:00 +01:00
|
|
|
|
menu.dllFuncs.pfnInit();
|
2010-07-18 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|