2002-02-21 20:10:16 +00:00
//-----------------------------------------------------------------------------
//
// $Id$
//
//-----------------------------------------------------------------------------
//
// $Log$
2005-09-07 20:24:33 +00:00
// Revision 1.22 2005/09/07 20:24:33 makro
// Vector support for most item types
//
2005-02-15 16:33:39 +00:00
// Revision 1.21 2005/02/15 16:33:39 makro
// Tons of updates (entity tree attachment system, UI vectors)
//
2003-03-31 00:23:18 +00:00
// Revision 1.20 2003/03/31 00:23:18 makro
// Replacements and stuff
//
2002-12-09 00:58:49 +00:00
// Revision 1.19 2002/12/09 00:58:49 makro
// Items are now disabled from the weapon/item menus in teamplay
// games if they are banned from the server
//
2002-11-09 14:17:51 +00:00
// Revision 1.18 2002/11/09 14:17:51 makro
// Cleaned up about menu code
// Made the weapon menu unavailable in TDM if g_RQ3_tdmMode is not 0
//
2002-10-29 01:34:52 +00:00
// Revision 1.17 2002/10/29 01:34:52 jbravo
// Added g_RQ3_tdmMode (0 = TP style, 1 = DM style) including UI support.
//
2002-09-01 21:15:47 +00:00
// Revision 1.16 2002/09/01 21:15:47 makro
// no message
//
2002-08-26 00:41:53 +00:00
// Revision 1.15 2002/08/26 00:41:52 makro
// Presets menu + editor
//
2002-07-02 09:51:29 +00:00
// Revision 1.14 2002/07/02 09:51:29 makro
// In-game server info code
//
2002-06-24 12:29:43 +00:00
// Revision 1.13 2002/06/24 12:29:43 makro
// Enabled weapon/item menus in CTF
//
2002-06-16 20:06:15 +00:00
// Revision 1.12 2002/06/16 20:06:14 jbravo
// Reindented all the source files with "indent -kr -ut -i8 -l120 -lc120 -sob -bad -bap"
//
2002-05-29 13:30:19 +00:00
// Revision 1.11 2002/05/29 13:30:19 makro
// Weapon/join menu tweaks
//
2002-04-30 11:56:54 +00:00
// Revision 1.10 2002/04/30 11:56:54 makro
// Stuff
//
2002-04-07 17:51:49 +00:00
// Revision 1.9 2002/04/07 17:51:49 makro
// Abbey
//
2002-03-31 13:23:26 +00:00
// Revision 1.8 2002/03/31 13:23:26 makro
// Cleaned things up a little
//
2002-03-24 21:26:43 +00:00
// Revision 1.7 2002/03/24 21:26:15 makro
// no message
//
2002-03-14 21:52:09 +00:00
// Revision 1.6 2002/03/14 21:52:08 makro
// no message
//
2002-03-10 22:13:34 +00:00
// Revision 1.5 2002/03/10 22:10:10 makro
// no message
//
2002-03-03 21:22:58 +00:00
// Revision 1.4 2002/03/03 21:22:58 makro
// no message
//
2002-02-21 20:10:16 +00:00
// Revision 1.3 2002/02/21 20:10:16 jbravo
// Converted files back from M$ format and added cvs headers again.
//
//
//-----------------------------------------------------------------------------
2002-02-10 02:36:52 +00:00
// Copyright (C) 1999-2000 Id Software, Inc.
//
/**********************************************************************
UI_ATOMS . C
User interface building blocks and support functions .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# include "ui_local.h"
2002-06-16 20:06:15 +00:00
qboolean m_entersound ; // after a frame, so caching won't disrupt the sound
2002-02-10 02:36:52 +00:00
// these are here so the functions in q_shared.c can link
# ifndef UI_HARD_LINKED
2002-06-16 20:06:15 +00:00
void QDECL Com_Error ( int level , const char * error , . . . )
{
va_list argptr ;
char text [ 1024 ] ;
2002-02-10 02:36:52 +00:00
2002-06-16 20:06:15 +00:00
va_start ( argptr , error ) ;
2009-07-04 02:29:42 +00:00
Q_vsnprintf ( text , sizeof ( text ) , error , argptr ) ;
2002-06-16 20:06:15 +00:00
va_end ( argptr ) ;
2002-02-10 02:36:52 +00:00
2002-06-16 20:06:15 +00:00
trap_Error ( va ( " %s " , text ) ) ;
2002-02-10 02:36:52 +00:00
}
2002-06-16 20:06:15 +00:00
void QDECL Com_Printf ( const char * msg , . . . )
{
va_list argptr ;
char text [ 1024 ] ;
2002-02-10 02:36:52 +00:00
2002-06-16 20:06:15 +00:00
va_start ( argptr , msg ) ;
2009-07-04 02:29:42 +00:00
Q_vsnprintf ( text , sizeof ( text ) , msg , argptr ) ;
2002-06-16 20:06:15 +00:00
va_end ( argptr ) ;
2002-02-10 02:36:52 +00:00
2002-06-16 20:06:15 +00:00
trap_Print ( va ( " %s " , text ) ) ;
2002-02-10 02:36:52 +00:00
}
# endif
qboolean newUI = qfalse ;
/*
= = = = = = = = = = = = = = = = =
UI_ClampCvar
= = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
float UI_ClampCvar ( float min , float max , float value )
2002-02-10 02:36:52 +00:00
{
2002-06-16 20:06:15 +00:00
if ( value < min )
return min ;
if ( value > max )
return max ;
2002-02-10 02:36:52 +00:00
return value ;
}
/*
= = = = = = = = = = = = = = = = =
UI_StartDemoLoop
= = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
void UI_StartDemoLoop ( void )
{
trap_Cmd_ExecuteText ( EXEC_APPEND , " d1 \n " ) ;
2002-02-10 02:36:52 +00:00
}
2002-03-31 13:23:26 +00:00
//Makro - not used anywhere
/*
2002-02-21 18:40:25 +00:00
# ifndef MISSIONPACK // bk001206
2002-02-10 02:36:52 +00:00
static void NeedCDAction ( qboolean result ) {
if ( ! result ) {
trap_Cmd_ExecuteText ( EXEC_APPEND , " quit \n " ) ;
}
}
2002-02-21 18:40:25 +00:00
# endif // MISSIONPACK
2002-02-10 02:36:52 +00:00
2002-02-21 18:40:25 +00:00
# ifndef MISSIONPACK // bk001206
2002-02-10 02:36:52 +00:00
static void NeedCDKeyAction ( qboolean result ) {
if ( ! result ) {
trap_Cmd_ExecuteText ( EXEC_APPEND , " quit \n " ) ;
}
}
2002-02-21 18:40:25 +00:00
# endif // MISSIONPACK
2002-03-31 13:23:26 +00:00
*/
2002-02-10 02:36:52 +00:00
2002-06-16 20:06:15 +00:00
char * UI_Argv ( int arg )
{
static char buffer [ MAX_STRING_CHARS ] ;
2002-02-10 02:36:52 +00:00
2002-06-16 20:06:15 +00:00
trap_Argv ( arg , buffer , sizeof ( buffer ) ) ;
2002-02-10 02:36:52 +00:00
return buffer ;
}
2002-06-16 20:06:15 +00:00
char * UI_Cvar_VariableString ( const char * var_name )
{
static char buffer [ MAX_STRING_CHARS ] ;
2002-02-10 02:36:52 +00:00
2002-06-16 20:06:15 +00:00
trap_Cvar_VariableStringBuffer ( var_name , buffer , sizeof ( buffer ) ) ;
2002-02-10 02:36:52 +00:00
return buffer ;
}
2002-06-16 20:06:15 +00:00
void UI_SetBestScores ( postGameInfo_t * newInfo , qboolean postGame )
{
trap_Cvar_Set ( " ui_scoreAccuracy " , va ( " %i%% " , newInfo - > accuracy ) ) ;
trap_Cvar_Set ( " ui_scoreImpressives " , va ( " %i " , newInfo - > impressives ) ) ;
trap_Cvar_Set ( " ui_scoreExcellents " , va ( " %i " , newInfo - > excellents ) ) ;
trap_Cvar_Set ( " ui_scoreDefends " , va ( " %i " , newInfo - > defends ) ) ;
trap_Cvar_Set ( " ui_scoreAssists " , va ( " %i " , newInfo - > assists ) ) ;
trap_Cvar_Set ( " ui_scoreGauntlets " , va ( " %i " , newInfo - > gauntlets ) ) ;
trap_Cvar_Set ( " ui_scoreScore " , va ( " %i " , newInfo - > score ) ) ;
trap_Cvar_Set ( " ui_scorePerfect " , va ( " %i " , newInfo - > perfects ) ) ;
trap_Cvar_Set ( " ui_scoreTeam " , va ( " %i to %i " , newInfo - > redScore , newInfo - > blueScore ) ) ;
trap_Cvar_Set ( " ui_scoreBase " , va ( " %i " , newInfo - > baseScore ) ) ;
trap_Cvar_Set ( " ui_scoreTimeBonus " , va ( " %i " , newInfo - > timeBonus ) ) ;
trap_Cvar_Set ( " ui_scoreSkillBonus " , va ( " %i " , newInfo - > skillBonus ) ) ;
trap_Cvar_Set ( " ui_scoreShutoutBonus " , va ( " %i " , newInfo - > shutoutBonus ) ) ;
trap_Cvar_Set ( " ui_scoreTime " , va ( " %02i:%02i " , newInfo - > time / 60 , newInfo - > time % 60 ) ) ;
trap_Cvar_Set ( " ui_scoreCaptures " , va ( " %i " , newInfo - > captures ) ) ;
if ( postGame ) {
trap_Cvar_Set ( " ui_scoreAccuracy2 " , va ( " %i%% " , newInfo - > accuracy ) ) ;
trap_Cvar_Set ( " ui_scoreImpressives2 " , va ( " %i " , newInfo - > impressives ) ) ;
trap_Cvar_Set ( " ui_scoreExcellents2 " , va ( " %i " , newInfo - > excellents ) ) ;
trap_Cvar_Set ( " ui_scoreDefends2 " , va ( " %i " , newInfo - > defends ) ) ;
trap_Cvar_Set ( " ui_scoreAssists2 " , va ( " %i " , newInfo - > assists ) ) ;
trap_Cvar_Set ( " ui_scoreGauntlets2 " , va ( " %i " , newInfo - > gauntlets ) ) ;
trap_Cvar_Set ( " ui_scoreScore2 " , va ( " %i " , newInfo - > score ) ) ;
trap_Cvar_Set ( " ui_scorePerfect2 " , va ( " %i " , newInfo - > perfects ) ) ;
trap_Cvar_Set ( " ui_scoreTeam2 " , va ( " %i to %i " , newInfo - > redScore , newInfo - > blueScore ) ) ;
trap_Cvar_Set ( " ui_scoreBase2 " , va ( " %i " , newInfo - > baseScore ) ) ;
trap_Cvar_Set ( " ui_scoreTimeBonus2 " , va ( " %i " , newInfo - > timeBonus ) ) ;
trap_Cvar_Set ( " ui_scoreSkillBonus2 " , va ( " %i " , newInfo - > skillBonus ) ) ;
trap_Cvar_Set ( " ui_scoreShutoutBonus2 " , va ( " %i " , newInfo - > shutoutBonus ) ) ;
trap_Cvar_Set ( " ui_scoreTime2 " , va ( " %02i:%02i " , newInfo - > time / 60 , newInfo - > time % 60 ) ) ;
trap_Cvar_Set ( " ui_scoreCaptures2 " , va ( " %i " , newInfo - > captures ) ) ;
2002-02-10 02:36:52 +00:00
}
}
2002-06-16 20:06:15 +00:00
void UI_LoadBestScores ( const char * map , int game )
{
char fileName [ MAX_QPATH ] ;
2002-02-10 02:36:52 +00:00
fileHandle_t f ;
postGameInfo_t newInfo ;
2011-07-18 16:27:47 +00:00
int protocol , protocolLegacy ;
2002-06-16 20:06:15 +00:00
2002-02-10 02:36:52 +00:00
memset ( & newInfo , 0 , sizeof ( postGameInfo_t ) ) ;
Com_sprintf ( fileName , MAX_QPATH , " games/%s_%i.game " , map , game ) ;
if ( trap_FS_FOpenFile ( fileName , & f , FS_READ ) > = 0 ) {
int size = 0 ;
trap_FS_Read ( & size , sizeof ( int ) , f ) ;
if ( size = = sizeof ( postGameInfo_t ) ) {
trap_FS_Read ( & newInfo , sizeof ( postGameInfo_t ) , f ) ;
}
trap_FS_FCloseFile ( f ) ;
}
UI_SetBestScores ( & newInfo , qfalse ) ;
uiInfo . demoAvailable = qfalse ;
2011-07-18 16:27:47 +00:00
protocolLegacy = trap_Cvar_VariableValue ( " com_legacyprotocol " ) ;
protocol = trap_Cvar_VariableValue ( " com_protocol " ) ;
if ( ! protocol )
protocol = trap_Cvar_VariableValue ( " protocol " ) ;
if ( protocolLegacy = = protocol )
protocolLegacy = 0 ;
Com_sprintf ( fileName , MAX_QPATH , " demos/%s_%d.%s%d " , map , game , DEMOEXT , protocol ) ;
if ( trap_FS_FOpenFile ( fileName , & f , FS_READ ) > = 0 )
{
2002-02-10 02:36:52 +00:00
uiInfo . demoAvailable = qtrue ;
trap_FS_FCloseFile ( f ) ;
2002-06-16 20:06:15 +00:00
}
2011-07-18 16:27:47 +00:00
else if ( protocolLegacy > 0 )
{
Com_sprintf ( fileName , MAX_QPATH , " demos/%s_%d.%s%d " , map , game , DEMOEXT , protocolLegacy ) ;
if ( trap_FS_FOpenFile ( fileName , & f , FS_READ ) > = 0 )
{
uiInfo . demoAvailable = qtrue ;
trap_FS_FCloseFile ( f ) ;
}
}
2002-02-10 02:36:52 +00:00
}
/*
= = = = = = = = = = = = = = =
UI_ClearScores
= = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
void UI_ClearScores ( )
{
char gameList [ 4096 ] ;
2002-02-10 02:36:52 +00:00
char * gameFile ;
2002-06-16 20:06:15 +00:00
int i , len , count , size ;
2002-02-10 02:36:52 +00:00
fileHandle_t f ;
postGameInfo_t newInfo ;
2002-06-16 20:06:15 +00:00
count = trap_FS_GetFileList ( " games " , " game " , gameList , sizeof ( gameList ) ) ;
2002-02-10 02:36:52 +00:00
size = sizeof ( postGameInfo_t ) ;
memset ( & newInfo , 0 , size ) ;
if ( count > 0 ) {
gameFile = gameList ;
2002-06-16 20:06:15 +00:00
for ( i = 0 ; i < count ; i + + ) {
2002-02-10 02:36:52 +00:00
len = strlen ( gameFile ) ;
2002-06-16 20:06:15 +00:00
if ( trap_FS_FOpenFile ( va ( " games/%s " , gameFile ) , & f , FS_WRITE ) > = 0 ) {
2002-02-10 02:36:52 +00:00
trap_FS_Write ( & size , sizeof ( int ) , f ) ;
trap_FS_Write ( & newInfo , size , f ) ;
trap_FS_FCloseFile ( f ) ;
}
gameFile + = len + 1 ;
}
}
2002-06-16 20:06:15 +00:00
2002-02-10 02:36:52 +00:00
UI_SetBestScores ( & newInfo , qfalse ) ;
}
2009-07-04 03:37:46 +00:00
static void UI_Cache_f ( void )
2002-06-16 20:06:15 +00:00
{
2002-02-10 02:36:52 +00:00
Display_CacheAll ( ) ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = =
UI_CalcPostGameStats
= = = = = = = = = = = = = = = = = = = = = = =
*/
2009-07-04 03:37:46 +00:00
static void UI_CalcPostGameStats ( void )
2002-06-16 20:06:15 +00:00
{
char map [ MAX_QPATH ] ;
char fileName [ MAX_QPATH ] ;
char info [ MAX_INFO_STRING ] ;
2002-02-10 02:36:52 +00:00
fileHandle_t f ;
int size , game , time , adjustedTime ;
postGameInfo_t oldInfo ;
postGameInfo_t newInfo ;
qboolean newHigh = qfalse ;
2002-06-16 20:06:15 +00:00
trap_GetConfigString ( CS_SERVERINFO , info , sizeof ( info ) ) ;
Q_strncpyz ( map , Info_ValueForKey ( info , " mapname " ) , sizeof ( map ) ) ;
2002-02-10 02:36:52 +00:00
game = atoi ( Info_ValueForKey ( info , " g_gametype " ) ) ;
// compose file name
Com_sprintf ( fileName , MAX_QPATH , " games/%s_%i.game " , map , game ) ;
// see if we have one already
memset ( & oldInfo , 0 , sizeof ( postGameInfo_t ) ) ;
if ( trap_FS_FOpenFile ( fileName , & f , FS_READ ) > = 0 ) {
2002-06-16 20:06:15 +00:00
// if so load it
2002-02-10 02:36:52 +00:00
size = 0 ;
trap_FS_Read ( & size , sizeof ( int ) , f ) ;
if ( size = = sizeof ( postGameInfo_t ) ) {
trap_FS_Read ( & oldInfo , sizeof ( postGameInfo_t ) , f ) ;
}
trap_FS_FCloseFile ( f ) ;
2002-06-16 20:06:15 +00:00
}
2002-02-10 02:36:52 +00:00
newInfo . accuracy = atoi ( UI_Argv ( 3 ) ) ;
newInfo . impressives = atoi ( UI_Argv ( 4 ) ) ;
newInfo . excellents = atoi ( UI_Argv ( 5 ) ) ;
newInfo . defends = atoi ( UI_Argv ( 6 ) ) ;
newInfo . assists = atoi ( UI_Argv ( 7 ) ) ;
newInfo . gauntlets = atoi ( UI_Argv ( 8 ) ) ;
newInfo . baseScore = atoi ( UI_Argv ( 9 ) ) ;
newInfo . perfects = atoi ( UI_Argv ( 10 ) ) ;
newInfo . redScore = atoi ( UI_Argv ( 11 ) ) ;
newInfo . blueScore = atoi ( UI_Argv ( 12 ) ) ;
time = atoi ( UI_Argv ( 13 ) ) ;
newInfo . captures = atoi ( UI_Argv ( 14 ) ) ;
newInfo . time = ( time - trap_Cvar_VariableValue ( " ui_matchStartTime " ) ) / 1000 ;
adjustedTime = uiInfo . mapList [ ui_currentMap . integer ] . timeToBeat [ game ] ;
2002-06-16 20:06:15 +00:00
if ( newInfo . time < adjustedTime ) {
2002-02-10 02:36:52 +00:00
newInfo . timeBonus = ( adjustedTime - newInfo . time ) * 10 ;
} else {
newInfo . timeBonus = 0 ;
}
if ( newInfo . redScore > newInfo . blueScore & & newInfo . blueScore < = 0 ) {
newInfo . shutoutBonus = 100 ;
} else {
newInfo . shutoutBonus = 0 ;
}
newInfo . skillBonus = trap_Cvar_VariableValue ( " g_spSkill " ) ;
if ( newInfo . skillBonus < = 0 ) {
newInfo . skillBonus = 1 ;
}
newInfo . score = newInfo . baseScore + newInfo . shutoutBonus + newInfo . timeBonus ;
newInfo . score * = newInfo . skillBonus ;
// see if the score is higher for this one
newHigh = ( newInfo . redScore > newInfo . blueScore & & newInfo . score > oldInfo . score ) ;
2002-06-16 20:06:15 +00:00
if ( newHigh ) {
2002-02-10 02:36:52 +00:00
// if so write out the new one
uiInfo . newHighScoreTime = uiInfo . uiDC . realTime + 20000 ;
if ( trap_FS_FOpenFile ( fileName , & f , FS_WRITE ) > = 0 ) {
size = sizeof ( postGameInfo_t ) ;
trap_FS_Write ( & size , sizeof ( int ) , f ) ;
trap_FS_Write ( & newInfo , sizeof ( postGameInfo_t ) , f ) ;
trap_FS_FCloseFile ( f ) ;
}
}
if ( newInfo . time < oldInfo . time ) {
uiInfo . newBestTime = uiInfo . uiDC . realTime + 20000 ;
}
// put back all the ui overrides
trap_Cvar_Set ( " capturelimit " , UI_Cvar_VariableString ( " ui_saveCaptureLimit " ) ) ;
trap_Cvar_Set ( " fraglimit " , UI_Cvar_VariableString ( " ui_saveFragLimit " ) ) ;
trap_Cvar_Set ( " cg_drawTimer " , UI_Cvar_VariableString ( " ui_drawTimer " ) ) ;
trap_Cvar_Set ( " g_doWarmup " , UI_Cvar_VariableString ( " ui_doWarmup " ) ) ;
trap_Cvar_Set ( " g_Warmup " , UI_Cvar_VariableString ( " ui_Warmup " ) ) ;
trap_Cvar_Set ( " sv_pure " , UI_Cvar_VariableString ( " ui_pure " ) ) ;
trap_Cvar_Set ( " g_friendlyFire " , UI_Cvar_VariableString ( " ui_friendlyFire " ) ) ;
UI_SetBestScores ( & newInfo , qtrue ) ;
UI_ShowPostGame ( newHigh ) ;
}
2002-12-09 00:58:49 +00:00
//Makro - returns qtrue if the player can access the weapon/item menus
2002-11-09 14:17:51 +00:00
qboolean UI_RQ3_WeaponMenuAccess ( )
{
char info [ MAX_INFO_STRING ] ;
int game , tdmMode ;
trap_GetConfigString ( CS_SERVERINFO , info , sizeof ( info ) ) ;
game = atoi ( Info_ValueForKey ( info , " g_gametype " ) ) ;
tdmMode = atoi ( Info_ValueForKey ( info , " g_RQ3_tdmMode " ) ) ;
if ( game = = GT_TEAMPLAY | | game = = GT_CTF | | ( game = = GT_TEAM & & ! tdmMode ) )
return qtrue ;
else
return qfalse ;
}
2002-02-10 02:36:52 +00:00
/*
= = = = = = = = = = = = = = = = =
UI_ConsoleCommand
= = = = = = = = = = = = = = = = =
*/
2003-03-31 00:23:18 +00:00
2002-06-16 20:06:15 +00:00
qboolean UI_ConsoleCommand ( int realTime )
{
char * cmd ;
2002-02-10 02:36:52 +00:00
uiInfo . uiDC . frameTime = realTime - uiInfo . uiDC . realTime ;
uiInfo . uiDC . realTime = realTime ;
2002-06-16 20:06:15 +00:00
cmd = UI_Argv ( 0 ) ;
2002-02-10 02:36:52 +00:00
// ensure minimum menu data is available
//Menu_Cache();
2002-06-16 20:06:15 +00:00
if ( Q_stricmp ( cmd , " ui_test " ) = = 0 ) {
2002-02-10 02:36:52 +00:00
UI_ShowPostGame ( qtrue ) ;
}
2002-06-16 20:06:15 +00:00
if ( Q_stricmp ( cmd , " ui_report " ) = = 0 ) {
2002-02-10 02:36:52 +00:00
UI_Report ( ) ;
return qtrue ;
}
2002-06-16 20:06:15 +00:00
if ( Q_stricmp ( cmd , " ui_load " ) = = 0 ) {
2002-02-10 02:36:52 +00:00
UI_Load ( ) ;
return qtrue ;
}
2002-06-16 20:06:15 +00:00
if ( Q_stricmp ( cmd , " remapShader " ) = = 0 ) {
2002-02-21 18:40:25 +00:00
//Makro - disabling shader remapping when cheats are off
2002-06-16 20:06:15 +00:00
if ( trap_Cvar_VariableValue ( " sv_cheats " ) = = 1 ) {
2002-02-21 18:40:25 +00:00
if ( trap_Argc ( ) > = 4 ) {
char shader1 [ MAX_QPATH ] ;
char shader2 [ MAX_QPATH ] ;
2002-06-16 20:06:15 +00:00
2002-02-21 18:40:25 +00:00
Q_strncpyz ( shader1 , UI_Argv ( 1 ) , sizeof ( shader1 ) ) ;
Q_strncpyz ( shader2 , UI_Argv ( 2 ) , sizeof ( shader2 ) ) ;
trap_R_RemapShader ( shader1 , shader2 , UI_Argv ( 3 ) ) ;
2002-06-16 20:06:15 +00:00
} else
//Makro - if no offset is specified, use 0
2002-02-21 18:40:25 +00:00
if ( trap_Argc ( ) = = 3 ) {
char shader1 [ MAX_QPATH ] ;
char shader2 [ MAX_QPATH ] ;
2002-06-16 20:06:15 +00:00
2002-02-21 18:40:25 +00:00
Q_strncpyz ( shader1 , UI_Argv ( 1 ) , sizeof ( shader1 ) ) ;
Q_strncpyz ( shader2 , UI_Argv ( 2 ) , sizeof ( shader2 ) ) ;
trap_R_RemapShader ( shader1 , shader2 , 0 ) ;
2002-06-16 20:06:15 +00:00
} else
Com_Printf ( " Usage: remapShader <oldShader> <newShader> [timeOffset] \n " ) ;
} else
2002-02-21 18:40:25 +00:00
Com_Printf ( " Shader remapping is cheat-protected \n " ) ;
return qtrue ;
2002-02-10 02:36:52 +00:00
}
2002-06-16 20:06:15 +00:00
if ( Q_stricmp ( cmd , " postgame " ) = = 0 ) {
2002-02-10 02:36:52 +00:00
UI_CalcPostGameStats ( ) ;
return qtrue ;
}
2002-06-16 20:06:15 +00:00
if ( Q_stricmp ( cmd , " ui_cache " ) = = 0 ) {
2002-02-10 02:36:52 +00:00
UI_Cache_f ( ) ;
return qtrue ;
}
2002-06-16 20:06:15 +00:00
if ( Q_stricmp ( cmd , " ui_teamOrders " ) = = 0 ) {
2002-02-10 02:36:52 +00:00
//UI_TeamOrdersMenu_f();
return qtrue ;
}
2002-06-16 20:06:15 +00:00
if ( Q_stricmp ( cmd , " ui_cdkey " ) = = 0 ) {
2002-02-10 02:36:52 +00:00
//UI_CDKeyMenu_f();
return qtrue ;
}
2002-02-21 18:40:25 +00:00
//Makro - adding popup for choose commands
2002-06-16 20:06:15 +00:00
if ( Q_stricmp ( cmd , " ui_RQ3_loadout " ) = = 0 ) {
2002-11-09 14:17:51 +00:00
if ( UI_RQ3_WeaponMenuAccess ( ) )
2002-02-21 18:40:25 +00:00
_UI_SetActiveMenu ( UIMENU_RQ3_WEAPON ) ;
else
2002-11-09 14:17:51 +00:00
Com_Printf ( " Weapon/item menus are not available in this gametype. \n " ) ;
2002-03-03 21:22:58 +00:00
return qtrue ;
}
//Makro - join menu
2002-06-16 20:06:15 +00:00
if ( Q_stricmp ( cmd , " ui_RQ3_joinTeam " ) = = 0 ) {
2002-05-29 13:30:19 +00:00
_UI_SetActiveMenu ( UIMENU_RQ3_JOIN ) ;
2002-03-03 21:22:58 +00:00
return qtrue ;
}
2002-04-30 11:56:54 +00:00
//Makro - tkok menu
2002-06-16 20:06:15 +00:00
if ( Q_stricmp ( cmd , " ui_RQ3_tkok " ) = = 0 ) {
if ( trap_Cvar_VariableValue ( " g_gametype " ) > = GT_TEAM )
2002-04-30 11:56:54 +00:00
_UI_SetActiveMenu ( UIMENU_RQ3_TKOK ) ;
else
Com_Printf ( " Not playing a team-based game. \n " ) ;
return qtrue ;
}
2002-08-26 00:41:53 +00:00
//Makro - presets menu
if ( Q_stricmp ( cmd , " ui_RQ3_presets " ) = = 0 ) {
_UI_SetActiveMenu ( UIMENU_RQ3_PRESETS ) ;
return qtrue ;
}
2002-03-03 21:22:58 +00:00
//Makro - I've always wanted a command to inc/dec a cvar :)
2002-06-16 20:06:15 +00:00
if ( Q_stricmp ( cmd , " inc " ) = = 0 ) {
2002-03-03 21:22:58 +00:00
if ( trap_Argc ( ) > = 2 ) {
char cvar [ MAX_CVAR_VALUE_STRING ] ;
2002-03-10 22:13:34 +00:00
float amount = 1 ;
float val ;
2002-03-03 21:22:58 +00:00
int max = 0 ;
Q_strncpyz ( cvar , UI_Argv ( 1 ) , sizeof ( cvar ) ) ;
2002-03-10 22:13:34 +00:00
val = trap_Cvar_VariableValue ( cvar ) ;
2002-03-03 21:22:58 +00:00
if ( trap_Argc ( ) > = 3 ) {
2002-03-10 22:13:34 +00:00
amount = atof ( UI_Argv ( 2 ) ) ;
2002-03-03 21:22:58 +00:00
if ( trap_Argc ( ) > = 4 ) {
max = atoi ( UI_Argv ( 3 ) ) ;
}
}
if ( max ! = 0 ) {
2002-06-16 20:06:15 +00:00
trap_Cvar_SetValue ( cvar , ( float ) ( ( ( int ) ( val + amount ) ) % max ) ) ;
2002-03-03 21:22:58 +00:00
} else {
2002-06-16 20:06:15 +00:00
trap_Cvar_SetValue ( cvar , val + amount ) ;
2002-03-03 21:22:58 +00:00
}
} else {
2002-03-10 22:13:34 +00:00
Com_Printf ( " Usage: inc <cvarName> [amount] [max] \n " ) ;
2002-03-03 21:22:58 +00:00
}
2002-02-21 18:40:25 +00:00
return qtrue ;
}
2002-03-14 21:52:09 +00:00
/*
if ( Q_stricmp ( cmd , " ifCvars " ) = = 0 ) {
if ( trap_Argc ( ) > = 4 ) {
char cvar [ MAX_CVAR_VALUE_STRING ] , cvarValue [ MAX_CVAR_VALUE_STRING ] ;
char * val = " " ;
char command [ 256 ] ;
char script [ 1024 ] ;
qboolean doScript = qfalse ;
int i ;
Q_strncpyz ( cvar , UI_Argv ( 1 ) , sizeof ( cvar ) ) ;
Q_strncpyz ( cvarValue , UI_Argv ( 2 ) , sizeof ( cvarValue ) ) ;
memset ( script , 0 , sizeof ( script ) ) ;
for ( i = 3 ; i < trap_Argc ( ) ; i + + ) {
Q_strncpyz ( command , UI_Argv ( i ) , sizeof ( command ) ) ;
Q_strcat ( script , sizeof ( script ) , command ) ;
if ( trap_Argc ( ) - i > 1 ) {
Q_strcat ( script , sizeof ( script ) , " " ) ;
}
}
val = UI_Cvar_VariableString ( cvar ) ;
if ( Q_stricmp ( val , cvarValue ) = = 0 ) {
doScript = qtrue ;
Com_Printf ( va ( " ^3%s = %s^7 \n " , val , cvarValue ) ) ;
}
if ( doScript ) {
trap_Cmd_ExecuteText ( EXEC_APPEND , va ( " %s \n " , script ) ) ;
}
} else {
Com_Printf ( va ( " Usage: %s <cvarName> <cvarValue> <script> \n " , cmd ) ) ;
}
return qtrue ;
}
*/
2002-02-21 18:40:25 +00:00
2002-09-01 21:15:47 +00:00
/*
2002-06-16 20:06:15 +00:00
if ( Q_stricmp ( cmd , " error " ) = = 0 ) {
if ( trap_Cvar_VariableValue ( " developer " ) = = 1 ) {
2002-03-24 21:26:43 +00:00
char text [ MAX_CVAR_VALUE_STRING ] ;
memset ( text , 0 , sizeof ( text ) ) ;
if ( trap_Argc ( ) = = 1 ) {
2002-09-01 21:15:47 +00:00
//Q_strcat(text, sizeof(text), "INFO: Testing error menu. Type 'error [msg]' in the console to see this screen. This command is only available when developer is set to 1");
2002-06-16 20:06:15 +00:00
Q_strcat ( text , sizeof ( text ) ,
2002-09-01 21:15:47 +00:00
" Could not download \" maps/longmapname.pk3 \" because autodownloading is disabled on the server \n \n The server you are connecting to is not a pure server, set autodownload to No in your settings and you might be able to join the game anyway. \n " ) ;
2002-03-24 21:26:43 +00:00
} else {
2002-09-01 21:15:47 +00:00
Q_strncpyz ( text , ConcatArgs ( 1 ) , sizeof ( text ) ) ;
2002-03-24 21:26:43 +00:00
}
Com_Error ( ERR_DROP , text ) ;
return qtrue ;
2002-03-03 21:22:58 +00:00
}
}
2002-09-01 21:15:47 +00:00
*/
2002-07-02 09:51:29 +00:00
2011-03-07 15:55:01 +00:00
if ( Q_stricmp ( cmd , " ui_RQ3_postVidRestart " ) = = 0 ) {
_UI_SetActiveMenu ( UIMENU_RQ3_POST_VID_RESTART ) ;
return qtrue ;
}
2002-02-10 02:36:52 +00:00
return qfalse ;
}
/*
= = = = = = = = = = = = = = = = =
UI_Shutdown
= = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
void UI_Shutdown ( void )
{
2002-02-10 02:36:52 +00:00
}
/*
= = = = = = = = = = = = = = = =
UI_AdjustFrom640
Adjusted for resolution and screen aspect ratio
2005-09-07 20:24:33 +00:00
Makro - converted to macro , see ui_local . h
2002-02-10 02:36:52 +00:00
= = = = = = = = = = = = = = = =
*/
2005-09-07 20:24:33 +00:00
void _UI_AdjustFrom640 ( float * x , float * y , float * w , float * h )
2002-06-16 20:06:15 +00:00
{
2002-02-10 02:36:52 +00:00
// expect valid pointers
#if 0
* x = * x * uiInfo . uiDC . scale + uiInfo . uiDC . bias ;
* y * = uiInfo . uiDC . scale ;
* w * = uiInfo . uiDC . scale ;
* h * = uiInfo . uiDC . scale ;
# endif
* x * = uiInfo . uiDC . xscale ;
* y * = uiInfo . uiDC . yscale ;
* w * = uiInfo . uiDC . xscale ;
* h * = uiInfo . uiDC . yscale ;
}
2002-06-16 20:06:15 +00:00
void UI_DrawNamedPic ( float x , float y , float width , float height , const char * picname )
{
qhandle_t hShader ;
2002-02-10 02:36:52 +00:00
2002-06-16 20:06:15 +00:00
hShader = trap_R_RegisterShaderNoMip ( picname ) ;
UI_AdjustFrom640 ( & x , & y , & width , & height ) ;
2005-02-15 16:33:39 +00:00
//trap_R_DrawStretchPic(x, y, width, height, 0, 0, 1, 1, hShader);
2005-09-07 20:24:33 +00:00
uiInfo . uiDC . drawStretchPic ( x , y , width , height , 0 , 0 , 1 , 1 , hShader , qfalse ) ;
2002-02-10 02:36:52 +00:00
}
2002-06-16 20:06:15 +00:00
void UI_DrawHandlePic ( float x , float y , float w , float h , qhandle_t hShader )
{
float s0 ;
float s1 ;
float t0 ;
float t1 ;
2002-02-10 02:36:52 +00:00
2002-06-16 20:06:15 +00:00
if ( w < 0 ) { // flip about vertical
w = - w ;
2002-02-10 02:36:52 +00:00
s0 = 1 ;
s1 = 0 ;
2002-06-16 20:06:15 +00:00
} else {
2002-02-10 02:36:52 +00:00
s0 = 0 ;
s1 = 1 ;
}
2002-06-16 20:06:15 +00:00
if ( h < 0 ) { // flip about horizontal
h = - h ;
2002-02-10 02:36:52 +00:00
t0 = 1 ;
t1 = 0 ;
2002-06-16 20:06:15 +00:00
} else {
2002-02-10 02:36:52 +00:00
t0 = 0 ;
t1 = 1 ;
}
2002-06-16 20:06:15 +00:00
UI_AdjustFrom640 ( & x , & y , & w , & h ) ;
2005-02-15 16:33:39 +00:00
//trap_R_DrawStretchPic(x, y, w, h, s0, t0, s1, t1, hShader);
2005-09-07 20:24:33 +00:00
uiInfo . uiDC . drawStretchPic ( x , y , w , h , s0 , t0 , s1 , t1 , hShader , qfalse ) ;
2002-02-10 02:36:52 +00:00
}
/*
= = = = = = = = = = = = = = = =
UI_FillRect
Coordinates are 640 * 480 virtual values
= = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
void UI_FillRect ( float x , float y , float width , float height , const float * color )
{
trap_R_SetColor ( color ) ;
2002-02-10 02:36:52 +00:00
2002-06-16 20:06:15 +00:00
UI_AdjustFrom640 ( & x , & y , & width , & height ) ;
2005-02-15 16:33:39 +00:00
//trap_R_DrawStretchPic(x, y, width, height, 0, 0, 0, 0, uiInfo.uiDC.whiteShader);
2005-09-07 20:24:33 +00:00
uiInfo . uiDC . drawStretchPic ( x , y , width , height , 0 , 0 , 0 , 0 , uiInfo . uiDC . whiteShader , qfalse ) ;
2002-02-10 02:36:52 +00:00
2002-06-16 20:06:15 +00:00
trap_R_SetColor ( NULL ) ;
2002-02-10 02:36:52 +00:00
}
2005-09-07 20:24:33 +00:00
//Makro - added shader parm
void UI_DrawSides ( float x , float y , float w , float h , qhandle_t shader )
2002-06-16 20:06:15 +00:00
{
UI_AdjustFrom640 ( & x , & y , & w , & h ) ;
2005-02-15 16:33:39 +00:00
//trap_R_DrawStretchPic(x, y, 1, h, 0, 0, 0, 0, uiInfo.uiDC.whiteShader);
//trap_R_DrawStretchPic(x + w - 1, y, 1, h, 0, 0, 0, 0, uiInfo.uiDC.whiteShader);
2005-09-07 20:24:33 +00:00
uiInfo . uiDC . drawStretchPic ( x , y , 1 , h , 0 , 0 , 0 , 0 , shader , qfalse ) ;
uiInfo . uiDC . drawStretchPic ( x + w - 1 , y , 1 , h , 0 , 0 , 0 , 0 , shader , qfalse ) ;
2002-02-10 02:36:52 +00:00
}
2005-09-07 20:24:33 +00:00
//Makro - added shader parm
void UI_DrawTopBottom ( float x , float y , float w , float h , qhandle_t shader )
2002-06-16 20:06:15 +00:00
{
UI_AdjustFrom640 ( & x , & y , & w , & h ) ;
2005-02-15 16:33:39 +00:00
//trap_R_DrawStretchPic(x, y, w, 1, 0, 0, 0, 0, uiInfo.uiDC.whiteShader);
//trap_R_DrawStretchPic(x, y + h - 1, w, 1, 0, 0, 0, 0, uiInfo.uiDC.whiteShader);
2005-09-07 20:24:33 +00:00
uiInfo . uiDC . drawStretchPic ( x , y , w , 1 , 0 , 0 , 0 , 0 , shader , qfalse ) ;
uiInfo . uiDC . drawStretchPic ( x , y + h - 1 , w , 1 , 0 , 0 , 0 , 0 , shader , qfalse ) ;
2002-02-10 02:36:52 +00:00
}
2002-06-16 20:06:15 +00:00
2002-02-10 02:36:52 +00:00
/*
= = = = = = = = = = = = = = = =
UI_DrawRect
Coordinates are 640 * 480 virtual values
= = = = = = = = = = = = = = = = =
*/
2005-09-07 20:24:33 +00:00
//Makro - added shader
void UI_DrawRect ( float x , float y , float width , float height , const float * color , qhandle_t shader )
2002-06-16 20:06:15 +00:00
{
trap_R_SetColor ( color ) ;
2002-02-10 02:36:52 +00:00
2005-09-07 20:24:33 +00:00
UI_DrawTopBottom ( x , y , width , height , shader ) ;
UI_DrawSides ( x , y , width , height , shader ) ;
2002-02-10 02:36:52 +00:00
2002-06-16 20:06:15 +00:00
trap_R_SetColor ( NULL ) ;
2002-02-10 02:36:52 +00:00
}
2002-06-16 20:06:15 +00:00
void UI_SetColor ( const float * rgba )
{
trap_R_SetColor ( rgba ) ;
2002-02-10 02:36:52 +00:00
}
2002-06-16 20:06:15 +00:00
void UI_UpdateScreen ( void )
{
2002-02-10 02:36:52 +00:00
trap_UpdateScreen ( ) ;
}
2002-06-16 20:06:15 +00:00
void UI_DrawTextBox ( int x , int y , int width , int lines )
2002-02-10 02:36:52 +00:00
{
2002-06-16 20:06:15 +00:00
UI_FillRect ( x + BIGCHAR_WIDTH / 2 , y + BIGCHAR_HEIGHT / 2 , ( width + 1 ) * BIGCHAR_WIDTH ,
( lines + 1 ) * BIGCHAR_HEIGHT , colorBlack ) ;
UI_DrawRect ( x + BIGCHAR_WIDTH / 2 , y + BIGCHAR_HEIGHT / 2 , ( width + 1 ) * BIGCHAR_WIDTH ,
2005-09-07 20:24:33 +00:00
( lines + 1 ) * BIGCHAR_HEIGHT , colorWhite , uiInfo . uiDC . whiteShader ) ;
2002-02-10 02:36:52 +00:00
}
2002-06-16 20:06:15 +00:00
qboolean UI_CursorInRect ( int x , int y , int width , int height )
2002-02-10 02:36:52 +00:00
{
if ( uiInfo . uiDC . cursorx < x | |
2002-06-16 20:06:15 +00:00
uiInfo . uiDC . cursory < y | | uiInfo . uiDC . cursorx > x + width | | uiInfo . uiDC . cursory > y + height )
2002-02-10 02:36:52 +00:00
return qfalse ;
return qtrue ;
}