reaction/code/cgame/cg_info.c

489 lines
14 KiB
C
Raw Normal View History

//-----------------------------------------------------------------------------
//
// $Id$
//
//-----------------------------------------------------------------------------
//
2001-12-31 16:28:42 +00:00
// $Log$
// Revision 1.37 2002/11/09 14:13:32 makro
// Added tdmMode info to the loading screen
//
2002-08-29 04:42:41 +00:00
// Revision 1.36 2002/08/29 04:42:40 blaze
// Anti OGC code
//
// Revision 1.35 2002/08/28 02:06:21 blaze
// Add SV_PURE DISABLED when connecting to a server with pure disabled. It still prints PURE SERVER when it\'s enabled, but clients may not notice it when it\'s gone.
//
// Revision 1.34 2002/06/29 04:15:15 jbravo
// CTF is now CTB. no weapons while the case is in hand other than pistol or knife
//
// Revision 1.33 2002/06/16 20:06:13 jbravo
// Reindented all the source files with "indent -kr -ut -i8 -l120 -lc120 -sob -bad -bap"
//
// Revision 1.32 2002/06/16 19:12:52 jbravo
// Removed the MISSIONPACK ifdefs and missionpack only code.
//
2002-06-08 14:07:52 +00:00
// Revision 1.31 2002/06/08 14:07:52 makro
// no message
//
// Revision 1.30 2002/06/08 11:41:01 makro
// The loading screen code will now look for
// levelshots/load_mapname.tga first
//
2002-06-03 19:19:43 +00:00
// Revision 1.29 2002/06/03 19:19:43 niceass
// matchmode change
//
2002-06-01 13:35:47 +00:00
// Revision 1.28 2002/06/01 13:35:47 makro
// Added clapper to loading screen
//
2002-05-31 19:01:33 +00:00
// Revision 1.27 2002/05/31 19:01:33 makro
// Unfixed something
//
// Revision 1.26 2002/05/31 00:17:06 jbravo
// Slicers fix for the weaponswitching issue
//
// Revision 1.25 2002/05/28 21:06:37 jbravo
// I broke the progressbar. Final fix for that
//
2002-05-28 03:10:50 +00:00
// Revision 1.24 2002/05/28 03:10:50 jbravo
// My fixups broke stuff
//
2002-05-27 17:47:19 +00:00
// Revision 1.23 2002/05/27 17:47:19 jbravo
// Fixes and cleanups
//
2002-05-26 06:17:27 +00:00
// Revision 1.22 2002/05/26 06:17:27 makro
// Loading screen again
//
2002-05-26 05:15:16 +00:00
// Revision 1.21 2002/05/26 05:15:16 niceass
// pregress bar
//
2002-05-26 05:00:19 +00:00
// Revision 1.20 2002/05/26 05:00:19 makro
// Loading screen
//
2002-05-25 16:39:16 +00:00
// Revision 1.19 2002/05/25 16:39:16 makro
// Loading screen
//
2002-05-25 10:40:31 +00:00
// Revision 1.18 2002/05/25 10:40:31 makro
// Loading screen
//
2002-05-24 18:41:34 +00:00
// Revision 1.17 2002/05/24 18:41:34 makro
// Loading screen
//
2002-05-02 23:04:59 +00:00
// Revision 1.16 2002/05/02 23:04:59 makro
// Loading screen. Jump kicks
//
// Revision 1.15 2002/05/02 12:44:07 makro
// Customizable color for the loading screen text
//
2002-03-31 03:31:24 +00:00
// Revision 1.14 2002/03/31 03:31:24 jbravo
// Compiler warning cleanups
//
// Revision 1.13 2002/03/24 21:24:51 makro
// Added a drop-shadow effect to the loading screen
//
// Revision 1.12 2002/03/03 18:10:20 makro
// Changed the colors for the 'loading map' screen a bit
//
2002-01-11 20:20:58 +00:00
// Revision 1.11 2002/01/11 20:20:57 jbravo
// Adding TP to main branch
//
// Revision 1.10 2002/01/11 19:48:29 jbravo
// Formatted the source in non DOS format.
//
2001-12-31 16:28:42 +00:00
// Revision 1.9 2001/12/31 16:28:41 jbravo
// I made a Booboo with the Log tag.
//
//
//-----------------------------------------------------------------------------
2001-05-06 20:50:27 +00:00
// Copyright (C) 1999-2000 Id Software, Inc.
//
// cg_info.c -- display information while data is being loading
#include "cg_local.h"
#define MAX_LOADING_PLAYER_ICONS 16
#define MAX_LOADING_ITEM_ICONS 26
static int loadingPlayerIconCount;
static int loadingItemIconCount;
static qhandle_t loadingPlayerIcons[MAX_LOADING_PLAYER_ICONS];
static qhandle_t loadingItemIcons[MAX_LOADING_ITEM_ICONS];
2001-05-06 20:50:27 +00:00
/*
===================
CG_DrawLoadingIcons
===================
2002-03-31 03:31:24 +00:00
// JBravo: apparently not used.
2001-05-06 20:50:27 +00:00
*/
2002-03-31 03:31:24 +00:00
/*
2001-05-06 20:50:27 +00:00
static void CG_DrawLoadingIcons( void ) {
int n;
int x, y;
for( n = 0; n < loadingPlayerIconCount; n++ ) {
x = 16 + n * 78;
y = 324-40;
CG_DrawPic( x, y, 64, 64, loadingPlayerIcons[n] );
}
for( n = 0; n < loadingItemIconCount; n++ ) {
y = 400-40;
if( n >= 13 ) {
y += 40;
}
x = 16 + n % 13 * 48;
CG_DrawPic( x, y, 32, 32, loadingItemIcons[n] );
}
}
2002-03-31 03:31:24 +00:00
*/
2001-05-06 20:50:27 +00:00
/*
======================
CG_LoadingString
======================
*/
void CG_LoadingString(const char *s)
{
Q_strncpyz(cg.infoScreenText, s, sizeof(cg.infoScreenText));
2001-05-06 20:50:27 +00:00
trap_UpdateScreen();
}
/*
===================
CG_LoadingItem
===================
*/
void CG_LoadingItem(int itemNum)
{
gitem_t *item;
2001-05-06 20:50:27 +00:00
item = &bg_itemlist[itemNum];
if (item->icon && loadingItemIconCount < MAX_LOADING_ITEM_ICONS) {
loadingItemIcons[loadingItemIconCount++] = trap_R_RegisterShaderNoMip(item->icon);
2001-05-06 20:50:27 +00:00
}
CG_LoadingString(item->pickup_name);
2001-05-06 20:50:27 +00:00
}
/*
===================
CG_LoadingClient
===================
*/
void CG_LoadingClient(int clientNum)
{
const char *info;
char *skin;
char personality[MAX_QPATH];
char model[MAX_QPATH];
char iconName[MAX_QPATH];
info = CG_ConfigString(CS_PLAYERS + clientNum);
if (loadingPlayerIconCount < MAX_LOADING_PLAYER_ICONS) {
Q_strncpyz(model, Info_ValueForKey(info, "model"), sizeof(model));
skin = strrchr(model, '/');
if (skin) {
2001-05-06 20:50:27 +00:00
*skin++ = '\0';
} else {
skin = "default";
}
Com_sprintf(iconName, MAX_QPATH, "models/players/%s/icon_%s.tga", model, skin);
loadingPlayerIcons[loadingPlayerIconCount] = trap_R_RegisterShaderNoMip(iconName);
if (!loadingPlayerIcons[loadingPlayerIconCount]) {
Com_sprintf(iconName, MAX_QPATH, "models/players/characters/%s/icon_%s.tga", model, skin);
loadingPlayerIcons[loadingPlayerIconCount] = trap_R_RegisterShaderNoMip(iconName);
}
if (!loadingPlayerIcons[loadingPlayerIconCount]) {
// Elder: changed
Com_sprintf(iconName, MAX_QPATH, "models/players/%s/icon_%s.tga", DEFAULT_MODEL, DEFAULT_SKIN);
//Com_sprintf( iconName, MAX_QPATH, "models/players/%s/icon_%s.tga", DEFAULT_MODEL, "default" );
loadingPlayerIcons[loadingPlayerIconCount] = trap_R_RegisterShaderNoMip(iconName);
2001-05-06 20:50:27 +00:00
}
if (loadingPlayerIcons[loadingPlayerIconCount]) {
2001-05-06 20:50:27 +00:00
loadingPlayerIconCount++;
}
}
Q_strncpyz(personality, Info_ValueForKey(info, "n"), sizeof(personality));
Q_CleanStr(personality);
2001-05-06 20:50:27 +00:00
if (cgs.gametype == GT_SINGLE_PLAYER) {
trap_S_RegisterSound(va("sound/player/announce/%s.wav", personality), qtrue);
2001-05-06 20:50:27 +00:00
}
CG_LoadingString(personality);
2001-05-06 20:50:27 +00:00
}
/*
====================
CG_DrawInformation
Draw all the status / pacifier stuff during level loading
====================
*/
2002-05-25 10:40:31 +00:00
#define LS_TOPMARGIN 72
#define LS_BOTTOMMARGIN 48
#define LS_CHAR_WIDTH 8
#define LS_CHAR_HEIGHT 12
void CG_DrawInformation(void)
{
const char *s;
const char *info;
const char *sysInfo;
const char *line;
int x = 8, y, value, bar = 0;
qhandle_t levelshot, shadow, clapper;
//qhandle_t detail;
qhandle_t percentBox;
char buf[1024];
//qboolean skipdetail;
vec4_t color1 = { .75, .75, .75, 1 }, color2 = {
1, 1, 1, 1};
info = CG_ConfigString(CS_SERVERINFO);
sysInfo = CG_ConfigString(CS_SYSTEMINFO);
2001-05-06 20:50:27 +00:00
2002-05-25 10:40:31 +00:00
/* Makro - no longer used
//Makro - settings read from the worldspawn entity
s = CG_ConfigString( CS_LOADINGSCREEN );
color1[0] = atof(Info_ValueForKey(s, "r1"));
color1[1] = atof(Info_ValueForKey(s, "g1"));
color1[2] = atof(Info_ValueForKey(s, "b1"));
color2[0] = atof(Info_ValueForKey(s, "r2"));
color2[1] = atof(Info_ValueForKey(s, "g2"));
color2[2] = atof(Info_ValueForKey(s, "b2"));
color1[3] = color2[3] = 1;
skipdetail = ( atoi(Info_ValueForKey(s, "nodetail")) != 0 );
*/
s = Info_ValueForKey(info, "mapname");
shadow = trap_R_RegisterShaderNoMip("ui/assets/rq3-main-shadow-1.tga");
levelshot = trap_R_RegisterShaderNoMip(va("levelshots/load_%s.tga", s));
2002-05-26 06:17:27 +00:00
percentBox = trap_R_RegisterShaderNoMip("gfx/percent.tga");
//Makro - added
if (!levelshot) {
levelshot = trap_R_RegisterShaderNoMip(va("levelshots/%s.tga", s));
}
if (!levelshot) {
//Elder: changed
levelshot = trap_R_RegisterShaderNoMip("levelshots/rq3-unknownmap.tga");
//skipdetail = qtrue;
2001-05-06 20:50:27 +00:00
}
trap_R_SetColor(NULL);
CG_DrawPic(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, levelshot);
2001-05-06 20:50:27 +00:00
2002-05-25 10:40:31 +00:00
/* Makro - removed
// blend a detail texture over it
//Elder: changed to RQ3 detail overlay
if (!skipdetail) {
detail = trap_R_RegisterShader( "rq3-levelShotDetail" );
trap_R_DrawStretchPic( 0, 0, cgs.glconfig.vidWidth, cgs.glconfig.vidHeight, 0, 0, 2.5, 2, detail );
}
*/
//Elder: "Letterbox" mask
//Makro - changed it a bit
CG_FillRect(0, 0, SCREEN_WIDTH, LS_TOPMARGIN, colorBlack);
CG_FillRect(0, LS_TOPMARGIN, SCREEN_WIDTH, 2, colorMdGrey);
CG_FillRect(0, SCREEN_HEIGHT - LS_BOTTOMMARGIN, SCREEN_WIDTH, LS_BOTTOMMARGIN, colorBlack);
CG_FillRect(0, SCREEN_HEIGHT - LS_BOTTOMMARGIN - 2, SCREEN_WIDTH, 2, colorMdGrey);
//Makro - shadow
CG_DrawPic(0, LS_TOPMARGIN + 2, 640, 12, shadow);
//Elder: mapname
2002-05-24 18:41:34 +00:00
//Makro - removed
//UI_DrawProportionalString(x, 26, s, UI_LEFT|UI_DROPSHADOW, colorDkGrey);
//CG_DrawBigStringColor(4, 24, s, color_red);
2001-05-06 20:50:27 +00:00
//Elder: removed
2001-05-06 20:50:27 +00:00
// draw the icons of things as they are loaded
//CG_DrawLoadingIcons();
2001-05-06 20:50:27 +00:00
// draw info string information
//Elder: Initial y-position
2002-05-25 10:40:31 +00:00
y = LS_TOPMARGIN - 8 - LS_CHAR_HEIGHT;
2001-05-06 20:50:27 +00:00
// map-specific message (long map name)
s = CG_ConfigString(CS_MESSAGE);
if (s[0]) {
2002-05-25 10:40:31 +00:00
//Makro - allow color-coded text; also changed to use custom color instead of colorLtGrey
//CG_DrawSmallStringColor(x, y, s, colorMdGrey);
2002-05-25 10:40:31 +00:00
//CG_DrawStringExt(x, y, s, colorWhite, qtrue, qfalse, LS_CHAR_WIDTH, LS_CHAR_HEIGHT, 0);
2002-05-26 05:00:19 +00:00
CG_DrawStringExt(x, y, s, color1, qtrue, qfalse, LS_CHAR_WIDTH, LS_CHAR_HEIGHT, 0);
2002-05-25 10:40:31 +00:00
y -= (2 * LS_CHAR_HEIGHT);
}
2002-05-25 10:40:31 +00:00
//y += LS_CHAR_HEIGHT;
2001-05-06 20:50:27 +00:00
// game type
switch (cgs.gametype) {
2001-05-06 20:50:27 +00:00
case GT_FFA:
2002-05-31 19:01:33 +00:00
line = "CLASSIC ACTION DEATHMATCH";
2001-05-06 20:50:27 +00:00
break;
case GT_SINGLE_PLAYER:
2002-05-31 19:01:33 +00:00
line = "SINGLE PLAYER";
2001-05-06 20:50:27 +00:00
break;
case GT_TOURNAMENT:
2002-05-31 19:01:33 +00:00
line = "TOURNAMENT";
2001-05-06 20:50:27 +00:00
break;
//Makro - added tdmMode
2001-05-06 20:50:27 +00:00
case GT_TEAM:
line = (atoi(Info_ValueForKey(info, "g_RQ3_tdmMode")) != 0) ? "TEAM DEATHMATCH (CLASSIC)" : "TEAM DEATHMATCH (TP-STYLE)";
2001-05-06 20:50:27 +00:00
break;
2002-01-11 20:20:58 +00:00
// JBravo: teamplay stuff.
case GT_TEAMPLAY:
//Makro - changed from RQ3 Teamplay
2002-05-31 19:01:33 +00:00
line = "CLASSIC ACTION TEAMPLAY";
2002-01-11 20:20:58 +00:00
break;
// JBravo: now knows as CTB
2001-05-06 20:50:27 +00:00
case GT_CTF:
line = "CAPTURE THE BRIEFCASE";
2001-05-06 20:50:27 +00:00
break;
default:
2002-05-31 19:01:33 +00:00
line = "UNKNOWN GAMETYPE";
2001-05-06 20:50:27 +00:00
break;
}
2002-08-29 04:42:41 +00:00
// JBravo: the call to Q_strupr seems to crash Q3 when running as dll or .so. Attempting a fix
2002-05-31 19:01:33 +00:00
// Makro: the fix crashes Q3 with .dll's, unfixing ;P
//strcat (line, '\0');
//line = Q_strupr(line);
2002-08-29 04:42:41 +00:00
2002-05-24 18:41:34 +00:00
// cheats warning
s = Info_ValueForKey(sysInfo, "sv_cheats");
2002-05-25 10:40:31 +00:00
//Makro - didn't like this
//if ( s[0] == '1' ) {
if (atoi(s))
2002-05-24 18:41:34 +00:00
line = va("%s / CHEATS ARE ENABLED", line);
2002-06-03 19:19:43 +00:00
if (cg_RQ3_matchmode.integer)
2002-06-03 19:19:43 +00:00
line = va("%s / MATCHMODE", line);
s = Info_ValueForKey(sysInfo, "sv_pure");
if (atoi(s) == 0)
line = va("%s / SV_PURE OFF", line);
//Makro - custom color; changed from colorWhite
2002-05-25 10:40:31 +00:00
//CG_DrawSmallStringColor(x, y, line, color2);
CG_DrawStringExt(x, y, line, color2, qfalse, qfalse, LS_CHAR_WIDTH, LS_CHAR_HEIGHT, 0);
y -= LS_CHAR_HEIGHT;
2002-05-24 18:41:34 +00:00
line = "";
2002-05-25 10:40:31 +00:00
// pure server
s = Info_ValueForKey(sysInfo, "sv_pure");
if (atoi(s)) {
if (line[0])
line = va("%s / ", line);
2002-05-25 10:40:31 +00:00
line = va("%sPURE SERVER", line);
}
value = atoi(Info_ValueForKey(info, "timelimit"));
if (value) {
2002-05-24 18:41:34 +00:00
line = va("TIMELIMIT %i", value);
2001-05-06 20:50:27 +00:00
}
if (cgs.gametype <= GT_TEAM) {
value = atoi(Info_ValueForKey(info, "fraglimit"));
if (value) {
if (line[0])
line = va("%s / ", line);
2002-05-25 10:40:31 +00:00
line = va("%sFRAGLIMIT %i", line, value);
2001-05-06 20:50:27 +00:00
}
2002-05-26 05:00:19 +00:00
} else if (cgs.gametype == GT_TEAMPLAY) {
value = atoi(Info_ValueForKey(info, "g_RQ3_roundlimit"));
if (value) {
if (line[0])
line = va("%s / ", line);
2002-05-26 05:00:19 +00:00
line = va("%sROUNDLIMIT %i", line, value);
}
} else {
value = atoi(Info_ValueForKey(info, "capturelimit"));
if (value) {
if (line[0])
line = va("%s / ", line);
2002-05-25 10:40:31 +00:00
line = va("%sCAPTURELIMIT %i", line, value);
2001-05-06 20:50:27 +00:00
}
}
2002-05-24 18:41:34 +00:00
2002-05-25 10:40:31 +00:00
//Makro - don't write unless there's something to write
if (line[0]) {
2002-05-25 10:40:31 +00:00
CG_DrawStringExt(x, y, line, color2, qfalse, qfalse, LS_CHAR_WIDTH, LS_CHAR_HEIGHT, 0);
y -= LS_CHAR_HEIGHT;
}
line = "";
// don't print server lines if playing a local game
trap_Cvar_VariableStringBuffer("sv_running", buf, sizeof(buf));
if (!atoi(buf)) {
2002-05-25 10:40:31 +00:00
// server hostname
Q_strncpyz(buf, Info_ValueForKey(info, "sv_hostname"), 1024);
2002-05-25 10:40:31 +00:00
Q_CleanStr(buf);
if (buf[0] && Q_stricmp(buf, "noname")) {
line = va("%s", buf);
}
// server-specific message of the day
s = CG_ConfigString(CS_MOTD);
if (s[0]) {
if (line[0])
line = va("%s / ", line);
2002-05-25 10:40:31 +00:00
line = va("%s%s", line, s);
}
//Makro - don't write unless there's something to write
if (line[0]) {
2002-05-25 10:40:31 +00:00
CG_DrawStringExt(x, y, line, color2, qfalse, qfalse, LS_CHAR_WIDTH, LS_CHAR_HEIGHT, 0);
2002-05-25 16:39:16 +00:00
y -= LS_CHAR_HEIGHT;
}
2002-05-25 10:40:31 +00:00
}
// BOTTOM //
// the first 150 rows are reserved for the client connection
// screen to write into
//y = SCREEN_HEIGHT - (int) (0.5 * (LS_BOTTOMMARGIN + LS_CHAR_HEIGHT));
y = SCREEN_HEIGHT - LS_BOTTOMMARGIN + 8;
if (cg.infoScreenText[0]) {
CG_DrawStringExt(x, y, va("LOADING... %s", Q_strupr(cg.infoScreenText)), color2, qfalse, qfalse,
LS_CHAR_WIDTH, LS_CHAR_HEIGHT, 0);
2002-05-25 10:40:31 +00:00
//UI_DrawProportionalString(SCREEN_WIDTH - 8, y, va("LOADING... %s", Q_strupr(cg.infoScreenText)), UI_RIGHT, colorWhite);
} else {
CG_DrawStringExt(x, y, "AWAITING SNAPSHOT...", color2, qfalse, qfalse, LS_CHAR_WIDTH, LS_CHAR_HEIGHT,
0);
2002-05-25 10:40:31 +00:00
//UI_DrawProportionalString(SCREEN_WIDTH - 8, y, "AWAITING SNAPSHOT...", UI_RIGHT, colorWhite);
}
2002-05-24 18:41:34 +00:00
2002-05-26 06:17:27 +00:00
//y += 24;
clapper = trap_R_RegisterShaderNoMip(va("levelshots/clapper_%s.tga", Info_ValueForKey(info, "mapname")));
2002-06-01 13:35:47 +00:00
if (clapper) {
y = LS_TOPMARGIN - 8 - LS_CHAR_HEIGHT;
CG_DrawPic(392, 296, 240, 180, clapper);
}
2002-05-26 05:15:16 +00:00
2002-05-26 06:17:27 +00:00
if (percentBox) {
trap_R_SetColor(colorWhite);
for (bar = 0; bar < ceil(cg.loadingMapPercent * 10) && bar < 10; bar++) {
CG_DrawPic(SCREEN_WIDTH - (11 - bar) * 10, y, 8, 8, percentBox);
}
trap_R_SetColor(colorDkGrey);
for (; bar < 10; bar++) {
2002-05-26 06:17:27 +00:00
CG_DrawPic(SCREEN_WIDTH - (11 - bar) * 10, y, 8, 8, percentBox);
}
} else {
for (bar = 0; bar < ceil(cg.loadingMapPercent * 10) && bar < 10; bar++) {
CG_FillRect(SCREEN_WIDTH - (11 - bar) * 10, y, 8, 8, colorWhite);
2002-05-26 06:17:27 +00:00
}
2002-05-26 05:15:16 +00:00
for (; bar < 10; bar++) {
CG_FillRect(SCREEN_WIDTH - (11 - bar) * 10, y, 8, 8, colorDkGrey);
2002-05-26 06:17:27 +00:00
}
2002-05-26 05:15:16 +00:00
}
2002-05-26 06:17:27 +00:00
2001-05-06 20:50:27 +00:00
}