From 1cf5e73c5851730ca29457e217080269ebc9ca6a Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Wed, 15 Aug 2012 11:31:55 +0200 Subject: [PATCH] decide which CSQC HUD elements are bold font and which not --- qcsrc/client/Main.qc | 2 +- qcsrc/client/hud.qc | 78 +++++++++++++++++++++++++-------- qcsrc/client/mapvoting.qc | 2 + qcsrc/client/miscfunctions.qc | 10 +++++ qcsrc/client/scoreboard.qc | 11 +++++ qcsrc/client/waypointsprites.qc | 2 + 6 files changed, 86 insertions(+), 19 deletions(-) diff --git a/qcsrc/client/Main.qc b/qcsrc/client/Main.qc index 3ac1e9cf7..01f84f3f2 100644 --- a/qcsrc/client/Main.qc +++ b/qcsrc/client/Main.qc @@ -118,7 +118,7 @@ void CSQC_Init(void) ClientProgsDB = db_load("client.db"); compressShortVector_init(); - drawfont = FONT_USER+1; + draw_endBoldFont(); menu_visible = FALSE; menu_show = menu_show_error; menu_action = menu_sub_null; diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index 6500cee56..2e3607ff4 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -476,6 +476,8 @@ void HUD_Weapons(void) HUD_Panel_UpdateCvars(weapons); HUD_Panel_ApplyFadeAlpha(); + draw_beginBoldFont(); + // calculate fading effect to weapon images for when the panel is idle if(autocvar_hud_panel_weapons_fade) { @@ -808,6 +810,8 @@ void HUD_Weapons(void) ++column; } } + + draw_endBoldFont(); } // Ammo (#1) @@ -908,6 +912,9 @@ void HUD_Ammo(void) HUD_Panel_UpdateCvars(ammo); HUD_Panel_ApplyFadeAlpha(); + + draw_beginBoldFont(); + vector pos, mySize; pos = panel_pos; mySize = panel_size; @@ -958,35 +965,40 @@ void HUD_Ammo(void) if(autocvar__hud_configure) { DrawAmmoItem(pos, ammo_size, 2, true, FALSE); //show rockets - return; } + else + { + stat_items = getstati(STAT_ITEMS, 0, 24); + if (stat_items & IT_UNLIMITED_WEAPON_AMMO) + infinite_ammo = TRUE; + for (i = 0; i < AMMO_COUNT; ++i) { + currently_selected = stat_items & GetAmmoItemCode(i); + if (currently_selected) + { + DrawAmmoItem(pos, ammo_size, i, true, infinite_ammo); + break; + } + } + } + } + else + { stat_items = getstati(STAT_ITEMS, 0, 24); if (stat_items & IT_UNLIMITED_WEAPON_AMMO) infinite_ammo = TRUE; for (i = 0; i < AMMO_COUNT; ++i) { currently_selected = stat_items & GetAmmoItemCode(i); - if (currently_selected) + DrawAmmoItem(pos + eX * column * (ammo_size_x + offset_x) + eY * row * (ammo_size_y + offset_y), ammo_size, i, currently_selected, infinite_ammo); + ++row; + if(row >= rows) { - DrawAmmoItem(pos, ammo_size, i, true, infinite_ammo); - return; + row = 0; + column = column + 1; } } - return; // nothing to display } - stat_items = getstati(STAT_ITEMS, 0, 24); - if (stat_items & IT_UNLIMITED_WEAPON_AMMO) - infinite_ammo = TRUE; - for (i = 0; i < AMMO_COUNT; ++i) { - currently_selected = stat_items & GetAmmoItemCode(i); - DrawAmmoItem(pos + eX * column * (ammo_size_x + offset_x) + eY * row * (ammo_size_y + offset_y), ammo_size, i, currently_selected, infinite_ammo); - ++row; - if(row >= rows) - { - row = 0; - column = column + 1; - } - } + draw_endBoldFont(); } void DrawNumIcon_expanding(vector myPos, vector mySize, float x, string icon, float vertical, float icon_right_align, vector color, float theAlpha, float fadelerp) @@ -1107,6 +1119,9 @@ void HUD_Powerups(void) HUD_Panel_UpdateCvars(powerups); HUD_Panel_ApplyFadeAlpha(); + + draw_beginBoldFont(); + vector pos, mySize; pos = panel_pos; mySize = panel_size; @@ -1273,6 +1288,8 @@ void HUD_Powerups(void) DrawNumIcon_expanding(pos + superweapons_offset, mySize, superweapons, "superweapons", is_vertical, superweapons_iconalign, '1 1 1', 1, bound(0, (superweapons - superweapons_time) / 0.5, 1)); } } + + draw_endBoldFont(); } // Health/armor (#3) @@ -2440,6 +2457,9 @@ void HUD_Timer(void) HUD_Panel_UpdateCvars(timer); HUD_Panel_ApplyFadeAlpha(); + + draw_beginBoldFont(); + vector pos, mySize; pos = panel_pos; mySize = panel_size; @@ -2482,6 +2502,8 @@ void HUD_Timer(void) } drawstring_aspect(pos, timer, mySize, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL); + + draw_endBoldFont(); } // Radar (#6) @@ -2806,6 +2828,7 @@ void HUD_Score(void) score = me.(scores[ps_primary]); timer = TIME_ENCODED_TOSTRING(score); + draw_beginBoldFont(); if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) { // distribution display distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]); @@ -2826,6 +2849,7 @@ void HUD_Score(void) if (distribution <= 0) HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); drawstring_aspect(pos, timer, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + draw_endBoldFont(); } else if (!teamplay) { // non-teamgames if ((spectatee_status == -1 && !autocvar__hud_configure) || autocvar_hud_panel_score_rankings) { @@ -2859,6 +2883,7 @@ void HUD_Score(void) string distribution_str; distribution_str = ftos(distribution); + draw_beginBoldFont(); if (distribution >= 0) { if (distribution > 0) @@ -2867,6 +2892,7 @@ void HUD_Score(void) } drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL); drawstring_aspect(pos + eX * 0.75 * mySize_x, distribution_str, eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL); + draw_endBoldFont(); } else { // teamgames float scores_count, row, column, rows, columns; local noref vector offset; // fteqcc sucks @@ -2909,6 +2935,7 @@ void HUD_Score(void) float max_fragcount; max_fragcount = -99; + draw_beginBoldFont(); for(tm = teams.sort_next; tm; tm = tm.sort_next) { if(tm.team == COLOR_SPECTATOR) continue; @@ -2943,6 +2970,7 @@ void HUD_Score(void) ++rows; } } + draw_endBoldFont(); } } @@ -2961,6 +2989,9 @@ void HUD_RaceTimer (void) HUD_Panel_UpdateCvars(racetimer); HUD_Panel_ApplyFadeAlpha(); + + draw_beginBoldFont(); + vector pos, mySize; pos = panel_pos; mySize = panel_size; @@ -3089,6 +3120,8 @@ void HUD_RaceTimer (void) } } } + + draw_endBoldFont(); } // Vote window (#9) @@ -3911,6 +3944,9 @@ void HUD_ModIcons(void) HUD_Panel_UpdateCvars(modicons); HUD_Panel_ApplyFadeAlpha(); + + draw_beginBoldFont(); + vector pos, mySize; pos = panel_pos; mySize = panel_size; @@ -3949,6 +3985,8 @@ void HUD_ModIcons(void) HUD_Mod_Dom(pos, mySize); else if(gametype == MAPINFO_TYPE_KEEPAWAY) HUD_Mod_Keepaway(pos, mySize); + + draw_endBoldFont(); } // Draw pressed keys (#11) @@ -4371,6 +4409,8 @@ void HUD_Physics(void) HUD_Panel_UpdateCvars(physics); HUD_Panel_ApplyFadeAlpha(); + draw_beginBoldFont(); + HUD_Panel_DrawBg(1); if(panel_bg_padding) { @@ -4623,6 +4663,8 @@ void HUD_Physics(void) tmp_offset_y = (panel_size_y - tmp_size_y) / 2; if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 3) drawstring_aspect(panel_pos + acceleration_offset + tmp_offset, strcat(ftos_decimals(acceleration, 2), "g"), tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + + draw_endBoldFont(); } // CenterPrint (#16) diff --git a/qcsrc/client/mapvoting.qc b/qcsrc/client/mapvoting.qc index 4cb8dad05..750bd2a75 100644 --- a/qcsrc/client/mapvoting.qc +++ b/qcsrc/client/mapvoting.qc @@ -194,6 +194,7 @@ void MapVote_Draw() pos_y = ymin; pos_z = 0; + draw_beginBoldFont(); map = _("Vote for a map"); pos_x = center - stringwidth(map, false, '12 0 0'); drawstring(pos, map, '24 24 0', '1 1 1', 1, DRAWFLAG_NORMAL); @@ -205,6 +206,7 @@ void MapVote_Draw() drawstring(pos, map, '16 16 0', '0 1 0', 1, DRAWFLAG_NORMAL); pos_y += 22; pos_x = xmin; + draw_endBoldFont(); // base for multi-column stuff... ymin = pos_y; diff --git a/qcsrc/client/miscfunctions.qc b/qcsrc/client/miscfunctions.qc index 070096fbf..72bb9c5c4 100644 --- a/qcsrc/client/miscfunctions.qc +++ b/qcsrc/client/miscfunctions.qc @@ -627,3 +627,13 @@ void URI_Get_Callback(float id, float status, string data) print(sprintf(_("Received HTTP request data for an invalid id %d.\n"), id)); } } + +void draw_beginBoldFont() +{ + drawfont = FONT_USER+2; +} + +void draw_endBoldFont() +{ + drawfont = FONT_USER+1; +} diff --git a/qcsrc/client/scoreboard.qc b/qcsrc/client/scoreboard.qc index 935a0277a..69a296796 100644 --- a/qcsrc/client/scoreboard.qc +++ b/qcsrc/client/scoreboard.qc @@ -341,6 +341,7 @@ void Cmd_HUD_SetFields(float argc) hud_fontsize = HUD_GetFontsize("hud_fontsize"); + draw_beginBoldFont(); for(i = 0; i < argc - 1; ++i) { float nocomplain; @@ -477,6 +478,7 @@ void Cmd_HUD_SetFields(float argc) } hud_field[hud_num_fields] = SP_END; + draw_endBoldFont(); } // MOVEUP:: @@ -840,6 +842,7 @@ vector HUD_Scoreboard_MakeTable(vector pos, entity tm, vector rgb, vector bg_siz } // print the strings of the columns headers and draw the columns + draw_beginBoldFont(); for(i = 0; i < hud_num_fields; ++i) { if(hud_field[i] == SP_SEPARATOR) @@ -882,6 +885,7 @@ vector HUD_Scoreboard_MakeTable(vector pos, entity tm, vector rgb, vector bg_siz pos_x -= hud_fontsize_x; } } + draw_endBoldFont(); pos_x = xmin; pos_y += 1.25 * hud_fontsize_y; // skip the header @@ -1220,7 +1224,9 @@ void HUD_DrawScoreboard() // Heading vector sb_heading_fontsize; sb_heading_fontsize = hud_fontsize * 2; + draw_beginBoldFont(); drawstring(pos, _("Scoreboard"), sb_heading_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL); + draw_endBoldFont(); pos_y += sb_heading_fontsize_y + hud_fontsize_y * 0.25; @@ -1236,6 +1242,7 @@ void HUD_DrawScoreboard() if(tm.team == COLOR_SPECTATOR) continue; + draw_beginBoldFont(); rgb = GetTeamRGB(tm.team); str = ftos(tm.(teamscores[ts_primary])); drawstring(pos + team_score_baseoffset - eX * stringwidth(str, FALSE, hud_fontsize * 1.5), str, hud_fontsize * 1.5, rgb, scoreboard_alpha_fg, DRAWFLAG_NORMAL); @@ -1245,6 +1252,8 @@ void HUD_DrawScoreboard() str = ftos(tm.(teamscores[ts_secondary])); drawstring(pos + team_score_baseoffset - eX * stringwidth(str, FALSE, hud_fontsize) + eY * hud_fontsize_y * 1.5, str, hud_fontsize, rgb, scoreboard_alpha_fg, DRAWFLAG_NORMAL); } + draw_endBoldFont(); + pos = HUD_Scoreboard_MakeTable(pos, tm, rgb, bg_size); } } @@ -1302,7 +1311,9 @@ void HUD_DrawScoreboard() if(specs) { + draw_beginBoldFont(); drawstring(tmp, _("Spectators"), hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL); + draw_endBoldFont(); pos_y += 1.25 * hud_fontsize_y; } diff --git a/qcsrc/client/waypointsprites.qc b/qcsrc/client/waypointsprites.qc index 78ddc8b79..513c66eb8 100644 --- a/qcsrc/client/waypointsprites.qc +++ b/qcsrc/client/waypointsprites.qc @@ -595,6 +595,7 @@ void Draw_WaypointSprite() if(autocvar_g_waypointsprite_uppercase) txt = strtoupper(txt); + draw_beginBoldFont(); if(self.health >= 0) { o = drawspritetext(o, ang, (SPRITE_HEALTHBAR_WIDTH + 2 * SPRITE_HEALTHBAR_BORDER) * t, rgb, a, waypointsprite_fontsize * '1 1 0', txt); @@ -630,6 +631,7 @@ void Draw_WaypointSprite() { o = drawspritetext(o, ang, 0, rgb, a, waypointsprite_fontsize * '1 1 0', txt); } + draw_endBoldFont(); } void Ent_RemoveWaypointSprite() -- 2.39.2