📄 ui_main.c
字号:
if (!q3Model) {
q3Model = qtrue;
updateModel = qtrue;
}
team[0] = '\0';
} else {
strcpy(team, UI_Cvar_VariableString("ui_teamName"));
strcpy(model, UI_Cvar_VariableString("team_model"));
strcpy(head, UI_Cvar_VariableString("team_headmodel"));
if (q3Model) {
q3Model = qfalse;
updateModel = qtrue;
}
}
if (updateModel) {
memset( &info, 0, sizeof(playerInfo_t) );
viewangles[YAW] = 180 - 10;
viewangles[PITCH] = 0;
viewangles[ROLL] = 0;
VectorClear( moveangles );
UI_PlayerInfo_SetModel( &info, model, head, team);
UI_PlayerInfo_SetInfo( &info, LEGS_IDLE, TORSO_STAND, viewangles, vec3_origin, WP_MACHINEGUN, qfalse );
// UI_RegisterClientModelname( &info, model, head, team);
updateModel = qfalse;
}
UI_DrawPlayer( rect->x, rect->y, rect->w, rect->h, &info, uiInfo.uiDC.realTime / 2);
}
static void UI_DrawNetSource(rectDef_t *rect, float scale, vec4_t color, int textStyle) {
if (ui_netSource.integer < 0 || ui_netSource.integer > numNetSources) {
ui_netSource.integer = 0;
}
Text_Paint(rect->x, rect->y, scale, color, va("Source: %s", netSources[ui_netSource.integer]), 0, 0, textStyle);
}
static void UI_DrawNetMapPreview(rectDef_t *rect, float scale, vec4_t color) {
if (uiInfo.serverStatus.currentServerPreview > 0) {
UI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, uiInfo.serverStatus.currentServerPreview);
} else {
UI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, trap_R_RegisterShaderNoMip("menu/art/unknownmap"));
}
}
static void UI_DrawNetMapCinematic(rectDef_t *rect, float scale, vec4_t color) {
if (ui_currentNetMap.integer < 0 || ui_currentNetMap.integer > uiInfo.mapCount) {
ui_currentNetMap.integer = 0;
trap_Cvar_Set("ui_currentNetMap", "0");
}
if (uiInfo.serverStatus.currentServerCinematic >= 0) {
trap_CIN_RunCinematic(uiInfo.serverStatus.currentServerCinematic);
trap_CIN_SetExtents(uiInfo.serverStatus.currentServerCinematic, rect->x, rect->y, rect->w, rect->h);
trap_CIN_DrawCinematic(uiInfo.serverStatus.currentServerCinematic);
} else {
UI_DrawNetMapPreview(rect, scale, color);
}
}
static void UI_DrawNetFilter(rectDef_t *rect, float scale, vec4_t color, int textStyle) {
if (ui_serverFilterType.integer < 0 || ui_serverFilterType.integer > numServerFilters) {
ui_serverFilterType.integer = 0;
}
Text_Paint(rect->x, rect->y, scale, color, va("Filter: %s", serverFilters[ui_serverFilterType.integer].description), 0, 0, textStyle);
}
static void UI_DrawTier(rectDef_t *rect, float scale, vec4_t color, int textStyle) {
int i;
i = trap_Cvar_VariableValue( "ui_currentTier" );
if (i < 0 || i >= uiInfo.tierCount) {
i = 0;
}
Text_Paint(rect->x, rect->y, scale, color, va("Tier: %s", uiInfo.tierList[i].tierName),0, 0, textStyle);
}
static void UI_DrawTierMap(rectDef_t *rect, int index) {
int i;
i = trap_Cvar_VariableValue( "ui_currentTier" );
if (i < 0 || i >= uiInfo.tierCount) {
i = 0;
}
if (uiInfo.tierList[i].mapHandles[index] == -1) {
uiInfo.tierList[i].mapHandles[index] = trap_R_RegisterShaderNoMip(va("levelshots/%s", uiInfo.tierList[i].maps[index]));
}
UI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, uiInfo.tierList[i].mapHandles[index]);
}
static const char *UI_EnglishMapName(const char *map) {
int i;
for (i = 0; i < uiInfo.mapCount; i++) {
if (Q_stricmp(map, uiInfo.mapList[i].mapLoadName) == 0) {
return uiInfo.mapList[i].mapName;
}
}
return "";
}
static void UI_DrawTierMapName(rectDef_t *rect, float scale, vec4_t color, int textStyle) {
int i, j;
i = trap_Cvar_VariableValue( "ui_currentTier" );
if (i < 0 || i >= uiInfo.tierCount) {
i = 0;
}
j = trap_Cvar_VariableValue("ui_currentMap");
if (j < 0 || j > MAPS_PER_TIER) {
j = 0;
}
Text_Paint(rect->x, rect->y, scale, color, UI_EnglishMapName(uiInfo.tierList[i].maps[j]), 0, 0, textStyle);
}
static void UI_DrawTierGameType(rectDef_t *rect, float scale, vec4_t color, int textStyle) {
int i, j;
i = trap_Cvar_VariableValue( "ui_currentTier" );
if (i < 0 || i >= uiInfo.tierCount) {
i = 0;
}
j = trap_Cvar_VariableValue("ui_currentMap");
if (j < 0 || j > MAPS_PER_TIER) {
j = 0;
}
Text_Paint(rect->x, rect->y, scale, color, uiInfo.gameTypes[uiInfo.tierList[i].gameTypes[j]].gameType , 0, 0, textStyle);
}
#ifndef MISSIONPACK // bk001206
static const char *UI_OpponentLeaderName() {
int i = UI_TeamIndexFromName(UI_Cvar_VariableString("ui_opponentName"));
return uiInfo.teamList[i].teamMembers[0];
}
#endif
static const char *UI_AIFromName(const char *name) {
int j;
for (j = 0; j < uiInfo.aliasCount; j++) {
if (Q_stricmp(uiInfo.aliasList[j].name, name) == 0) {
return uiInfo.aliasList[j].ai;
}
}
return "James";
}
#ifndef MISSIONPACK // bk001206
static const int UI_AIIndex(const char *name) {
int j;
for (j = 0; j < uiInfo.characterCount; j++) {
if (Q_stricmp(name, uiInfo.characterList[j].name) == 0) {
return j;
}
}
return 0;
}
#endif
#ifndef MISSIONPACK // bk001206
static const int UI_AIIndexFromName(const char *name) {
int j;
for (j = 0; j < uiInfo.aliasCount; j++) {
if (Q_stricmp(uiInfo.aliasList[j].name, name) == 0) {
return UI_AIIndex(uiInfo.aliasList[j].ai);
}
}
return 0;
}
#endif
#ifndef MISSIONPACK // bk001206
static const char *UI_OpponentLeaderHead() {
const char *leader = UI_OpponentLeaderName();
return UI_AIFromName(leader);
}
#endif
#ifndef MISSIONPACK // bk001206
static const char *UI_OpponentLeaderModel() {
int i;
const char *head = UI_OpponentLeaderHead();
for (i = 0; i < uiInfo.characterCount; i++) {
if (Q_stricmp(head, uiInfo.characterList[i].name) == 0) {
return uiInfo.characterList[i].base;
}
}
return "James";
}
#endif
static qboolean updateOpponentModel = qtrue;
static void UI_DrawOpponent(rectDef_t *rect) {
static playerInfo_t info2;
char model[MAX_QPATH];
char headmodel[MAX_QPATH];
char team[256];
vec3_t viewangles;
vec3_t moveangles;
if (updateOpponentModel) {
strcpy(model, UI_Cvar_VariableString("ui_opponentModel"));
strcpy(headmodel, UI_Cvar_VariableString("ui_opponentModel"));
team[0] = '\0';
memset( &info2, 0, sizeof(playerInfo_t) );
viewangles[YAW] = 180 - 10;
viewangles[PITCH] = 0;
viewangles[ROLL] = 0;
VectorClear( moveangles );
UI_PlayerInfo_SetModel( &info2, model, headmodel, "");
UI_PlayerInfo_SetInfo( &info2, LEGS_IDLE, TORSO_STAND, viewangles, vec3_origin, WP_MACHINEGUN, qfalse );
UI_RegisterClientModelname( &info2, model, headmodel, team);
updateOpponentModel = qfalse;
}
UI_DrawPlayer( rect->x, rect->y, rect->w, rect->h, &info2, uiInfo.uiDC.realTime / 2);
}
static void UI_NextOpponent() {
int i = UI_TeamIndexFromName(UI_Cvar_VariableString("ui_opponentName"));
int j = UI_TeamIndexFromName(UI_Cvar_VariableString("ui_teamName"));
i++;
if (i >= uiInfo.teamCount) {
i = 0;
}
if (i == j) {
i++;
if ( i >= uiInfo.teamCount) {
i = 0;
}
}
trap_Cvar_Set( "ui_opponentName", uiInfo.teamList[i].teamName );
}
static void UI_PriorOpponent() {
int i = UI_TeamIndexFromName(UI_Cvar_VariableString("ui_opponentName"));
int j = UI_TeamIndexFromName(UI_Cvar_VariableString("ui_teamName"));
i--;
if (i < 0) {
i = uiInfo.teamCount - 1;
}
if (i == j) {
i--;
if ( i < 0) {
i = uiInfo.teamCount - 1;
}
}
trap_Cvar_Set( "ui_opponentName", uiInfo.teamList[i].teamName );
}
static void UI_DrawPlayerLogo(rectDef_t *rect, vec3_t color) {
int i = UI_TeamIndexFromName(UI_Cvar_VariableString("ui_teamName"));
if (uiInfo.teamList[i].teamIcon == -1) {
uiInfo.teamList[i].teamIcon = trap_R_RegisterShaderNoMip(uiInfo.teamList[i].imageName);
uiInfo.teamList[i].teamIcon_Metal = trap_R_RegisterShaderNoMip(va("%s_metal",uiInfo.teamList[i].imageName));
uiInfo.teamList[i].teamIcon_Name = trap_R_RegisterShaderNoMip(va("%s_name", uiInfo.teamList[i].imageName));
}
trap_R_SetColor( color );
UI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, uiInfo.teamList[i].teamIcon );
trap_R_SetColor( NULL );
}
static void UI_DrawPlayerLogoMetal(rectDef_t *rect, vec3_t color) {
int i = UI_TeamIndexFromName(UI_Cvar_VariableString("ui_teamName"));
if (uiInfo.teamList[i].teamIcon == -1) {
uiInfo.teamList[i].teamIcon = trap_R_RegisterShaderNoMip(uiInfo.teamList[i].imageName);
uiInfo.teamList[i].teamIcon_Metal = trap_R_RegisterShaderNoMip(va("%s_metal",uiInfo.teamList[i].imageName));
uiInfo.teamList[i].teamIcon_Name = trap_R_RegisterShaderNoMip(va("%s_name", uiInfo.teamList[i].imageName));
}
trap_R_SetColor( color );
UI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, uiInfo.teamList[i].teamIcon_Metal );
trap_R_SetColor( NULL );
}
static void UI_DrawPlayerLogoName(rectDef_t *rect, vec3_t color) {
int i = UI_TeamIndexFromName(UI_Cvar_VariableString("ui_teamName"));
if (uiInfo.teamList[i].teamIcon == -1) {
uiInfo.teamList[i].teamIcon = trap_R_RegisterShaderNoMip(uiInfo.teamList[i].imageName);
uiInfo.teamList[i].teamIcon_Metal = trap_R_RegisterShaderNoMip(va("%s_metal",uiInfo.teamList[i].imageName));
uiInfo.teamList[i].teamIcon_Name = trap_R_RegisterShaderNoMip(va("%s_name", uiInfo.teamList[i].imageName));
}
trap_R_SetColor( color );
UI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, uiInfo.teamList[i].teamIcon_Name );
trap_R_SetColor( NULL );
}
static void UI_DrawOpponentLogo(rectDef_t *rect, vec3_t color) {
int i = UI_TeamIndexFromName(UI_Cvar_VariableString("ui_opponentName"));
if (uiInfo.teamList[i].teamIcon == -1) {
uiInfo.teamList[i].teamIcon = trap_R_RegisterShaderNoMip(uiInfo.teamList[i].imageName);
uiInfo.teamList[i].teamIcon_Metal = trap_R_RegisterShaderNoMip(va("%s_metal",uiInfo.teamList[i].imageName));
uiInfo.teamList[i].teamIcon_Name = trap_R_RegisterShaderNoMip(va("%s_name", uiInfo.teamList[i].imageName));
}
trap_R_SetColor( color );
UI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, uiInfo.teamList[i].teamIcon );
trap_R_SetColor( NULL );
}
static void UI_DrawOpponentLogoMetal(rectDef_t *rect, vec3_t color) {
int i = UI_TeamIndexFromName(UI_Cvar_VariableString("ui_opponentName"));
if (uiInfo.teamList[i].teamIcon == -1) {
uiInfo.teamList[i].teamIcon = trap_R_RegisterShaderNoMip(uiInfo.teamList[i].imageName);
uiInfo.teamList[i].teamIcon_Metal = trap_R_RegisterShaderNoMip(va("%s_metal",uiInfo.teamList[i].imageName));
uiInfo.teamList[i].teamIcon_Name = trap_R_RegisterShaderNoMip(va("%s_name", uiInfo.teamList[i].imageName));
}
trap_R_SetColor( color );
UI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, uiInfo.teamList[i].teamIcon_Metal );
trap_R_SetColor( NULL );
}
static void UI_DrawOpponentLogoName(rectDef_t *rect, vec3_t color) {
int i = UI_TeamIndexFromName(UI_Cvar_VariableString("ui_opponentName"));
if (uiInfo.teamList[i].teamIcon == -1) {
uiInfo.teamList[i].teamIcon = trap_R_RegisterShaderNoMip(uiInfo.teamList[i].imageName);
uiInfo.teamList[i].teamIcon_Metal = trap_R_RegisterShaderNoMip(va("%s_metal",uiInfo.teamList[i].imageName));
uiInfo.teamList[i].teamIcon_Name = trap_R_RegisterShaderNoMip(va("%s_name", uiInfo.teamList[i].imageName));
}
trap_R_SetColor( color );
UI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, uiInfo.teamList[i].teamIcon_Name );
trap_R_SetColor( NULL );
}
static void UI_DrawAllMapsSelection(rectDef_t *rect, float scale, vec4_t color, int textStyle, qboolean net) {
int map = (net) ? ui_currentNetMap.integer : ui_currentMap.integer;
if (map >= 0 && map < uiInfo.mapCount) {
Text_Paint(rect->x, rect->y, scale, color, uiInfo.mapList[map].mapName, 0, 0, textStyle);
}
}
static void UI_DrawOpponentName(rectDef_t *rect, float scale, vec4_t color, int textStyle) {
Text_Paint(rect->x, rect->y, scale, color, UI_Cvar_VariableString("ui_opponentName"), 0, 0, textStyle);
}
static int UI_OwnerDrawWidth(int ownerDraw, float scale) {
int i, h, value;
const char *text;
const char *s = NULL;
switch (ownerDraw) {
case UI_HANDICAP:
h = Com_Clamp( 5, 100, trap_Cvar_VariableValue("handicap") );
i = 20 - h / 5;
s = handicapValues[i];
break;
case UI_CLANNAME:
s = UI_Cvar_VariableString("ui_teamName");
break;
case UI_GAMETYPE:
s = uiInfo.gameTypes[ui_gameType.integer].gameType;
break;
case UI_SKILL:
i = trap_Cvar_VariableValue( "g_spSkill" );
if (i < 1 || i > numSkillLevels) {
i = 1;
}
s = skillLevels[i-1];
break;
case UI_BLUETEAMNAME:
i = UI_TeamIndexFromName(UI_Cvar_VariableString("ui_blueTeam"));
if (i >= 0 && i < uiInfo.teamCount) {
s = va("%s: %s", "Blue", uiInfo.teamList[i].teamName);
}
break;
case UI_REDTEAMNAME:
i = UI_TeamIndexFromName(UI_Cvar_VariableString("ui_redTeam"));
if (i >= 0 && i < uiInfo.teamCount) {
s = va("%s: %s", "Red", uiInfo.teamList[i].teamName);
}
break;
case UI_BLUETEAM1:
case UI_BLUETEAM2:
case UI_BLUETEAM3:
case UI_BLUETEAM4:
case UI_BLUETEAM5:
value = trap_Cvar_VariableValue(va("ui_blueteam%i", ownerDraw-UI_BLUETEAM1 + 1));
if (value <= 0) {
text = "Closed";
} else if (value == 1) {
text = "Human";
} else {
value -= 2;
if (value >= uiInfo.aliasCount) {
value = 0;
}
text = uiInfo.aliasList[value].name;
}
s = va("%i. %s", ownerDraw-UI_BLUETEAM1 + 1, text);
break;
case UI_REDTEAM1:
case UI_REDTEAM2:
case UI_REDTEAM3:
case UI_REDTEAM4:
case UI_REDTEAM5:
value = trap_Cvar_VariableValue(va("ui_redteam%i", ownerDraw-UI_REDTEAM1 + 1));
if (value <= 0) {
text = "Closed";
} else if (value == 1) {
text = "Human";
} else {
value -= 2;
if (value >= uiInfo.aliasCount) {
value = 0;
}
text = uiInfo.aliasList[value].name;
}
s = va("%i. %s", ownerDraw-UI_REDTEAM1 + 1, text);
break;
case UI_NETSOURCE:
if (ui_netSource.integer < 0 || ui_netSource.integer > uiInfo.numJoinGameTypes) {
ui_netSource.integer = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -