X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fclient%2Fhud.qc;h=b341f10515da597bbba1e90a3632e336f9a4c21b;hp=30be665922f4a5e723b420acad77a0dd1f60bbec;hb=4c1fcf7b3bdaee8fd10d48d2ac5b21c3a9371de1;hpb=98f8da7bc16b8034bda40bc6b23efc99fed2db3e diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index 30be665922..b341f10515 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -284,10 +284,9 @@ void HUD_DrawCenterPrint (void) sz = 0.8 + (a / 5); - if(centerprint_num * cvar("scr_centersize") > 24 && HUD_WouldDrawScoreboard()) // 24 = height of Scoreboard text - { + if(centerprint_num * cvar("scr_centersize") > 24 && scoreboard_active) // 24 = height of Scoreboard text centerprint_start_y = scoreboard_bottom + centerprint_fontsize_y; - } + pos = centerprint_start; for (i=0; i vid_conwidth) + tmp_size_x = vid_conwidth - panel_pos_x; + if (panel_pos_y + panel_size_copied_y > vid_conheight) + tmp_size_y = vid_conheight - panel_pos_y; + + if (panel_size == tmp_size) + return true; + + // backup first! + panel_pos_backup = panel_pos; + panel_size_backup = panel_size; + highlightedPanel_backup = highlightedPanel_prev; + + string s; + s = strcat(ftos(tmp_size_x/vid_conwidth), " ", ftos(tmp_size_y/vid_conheight)); + cvar_set(strcat("hud_panel_", panel_name, "_size"), s); } else if(nPrimary == 'z') // undo last action { @@ -1306,22 +1314,26 @@ void HUD_Panel_Highlight() } float highlightcheck; -float would_backup; +vector prev_pos, prev_size; void HUD_Panel_Mouse() { // TODO: needs better check... is there any float that contains the current state of the menu? _menu_alpha isn't apparently updated the frame the menu gets enabled - if (menu_enabled == 0) // menu dialog closed, enable normal alpha stuff again - disable_menu_alphacheck = 0; if (autocvar__menu_alpha == 0 && time - menu_enabled_time > 0.5) menu_enabled = 0; /* - print("Disable menu_alphacheck: ", ftos(disable_menu_alphacheck), "\n"); + print("menu_enabled: ", ftos(menu_enabled), "\n"); print("Highlighted: ", ftos(highlightedPanel), "\n"); print("Menu alpha: ", cvar_string("_menu_alpha"), "\n"); */ - if(mouseClicked == 0 && disable_menu_alphacheck != 2 && highlightedPanel >= 0) { // don't reset these variables in disable_menu_alphacheck mode 2! + // instantly hide the editor cursor if we open the HUDExit dialog + // as hud_fade_alpha doesn't decrease to 0 in this case + // TODO: find a way to fade the cursor out even in this case + if(menu_enabled == 1 || (menu_enabled == 2 && !hud_fade_alpha)) + return; + + if(mouseClicked == 0 && menu_enabled != 2 && highlightedPanel >= 0) { // don't reset these variables in menu_enabled mode 2! highlightedPanel = -1; highlightedAction = 0; } @@ -1335,22 +1347,29 @@ void HUD_Panel_Mouse() if(mouseClicked) { - vector prev_pos, prev_size; if(prevMouseClicked == 0) { HUD_Panel_Highlight(); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin // and calls HUD_Panel_UpdatePosSizeForId() for the highlighted panel - would_backup = TRUE; - } - else if (would_backup) - { - // this is not the actual backup! Saving pos and size values - // only to check later if they are different from new values prev_pos = panel_pos; prev_size = panel_size; } + else + HUD_Panel_UpdatePosSizeForId(highlightedPanel) - hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions); + if (prev_pos != panel_pos || prev_size != panel_size) + { + hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions); + // backup! + panel_pos_backup = prev_pos; + panel_size_backup = prev_size; + highlightedPanel_backup = highlightedPanel; + } + else + // in case the clicked panel is inside another panel and we aren't + // moving it, avoid the immediate "fix" of its position/size + // (often unwanted and hateful) by disabling collisions check + hud_configure_checkcollisions = false; if(highlightedAction == 1) HUD_Panel_SetPos(mousepos - panel_click_distance); @@ -1373,24 +1392,11 @@ void HUD_Panel_Mouse() HUD_Panel_SetPosSize(mySize); } - HUD_Panel_UpdatePosSizeForId(highlightedPanel) - if (prevMouseClicked) - if (would_backup) - if (prev_pos != panel_pos || prev_size != panel_size) - { - // backup! - panel_pos_backup = prev_pos; - panel_size_backup = prev_size; - highlightedPanel_backup = highlightedPanel; - would_backup = FALSE; - } - // doubleclick check if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0) { mouseClicked = 0; // to prevent spam, I guess. - disable_menu_alphacheck = 2; - menu_enabled = 1; + menu_enabled = 2; menu_enabled_time = time; HUD_Panel_GetName(highlightedPanel) localcmd("menu_showhudoptions ", panel_name, "\n"); @@ -1412,13 +1418,13 @@ void HUD_Panel_Mouse() cursorsize = '32 32 0'; if(highlightcheck == 0) - drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL); + drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), '32 32 0', '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL); else if(highlightcheck == 1) - drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_move.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL); + drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_move.tga"), '32 32 0', '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL); else if(highlightcheck == 2) - drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL); + drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize.tga"), '32 32 0', '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL); else - drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize2.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL); + drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize2.tga"), '32 32 0', '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL); prevMouseClicked = mouseClicked; } @@ -1471,6 +1477,7 @@ float GetAmmoTypeForWep(float i) case WEP_UZI: return 1; case WEP_CAMPINGRIFLE: return 1; case WEP_GRENADE_LAUNCHER: return 2; + case WEP_MINE_LAYER: return 2; case WEP_ELECTRO: return 3; case WEP_CRYLINK: return 3; case WEP_HLAC: return 3; @@ -1650,6 +1657,10 @@ void HUD_Weapons(void) vector wpnpos; vector wpnsize; + float show_accuracy; + if(autocvar_hud_panel_weapons_accuracy && acc_levels) + show_accuracy = true; + for(i = 0; i < weapon_cnt; ++i) { wpnpos = panel_pos + eX * column * panel_size_x*(1/columns) + eY * row * panel_size_y*(1/rows); @@ -1663,7 +1674,7 @@ void HUD_Weapons(void) drawpic_aspect_skin(wpnpos, "weapon_current_bg", wpnsize, '1 1 1', fade * panel_fg_alpha, DRAWFLAG_NORMAL); // draw the weapon accuracy - if(acc_levels) + if(show_accuracy) { float weapon_hit, weapon_damage; weapon_damage = weapon_fired[self.weapon-WEP_FIRST]; @@ -2248,12 +2259,10 @@ void HUD_HealthArmor(void) mySize -= '2 2 0' * panel_bg_padding; } - float armor, health; + float armor, health, fuel; armor = getstati(STAT_ARMOR); health = getstati(STAT_HEALTH); - - float fuel; - fuel = getstati(GetAmmoStat(4)); // how much fuel do we have? + fuel = getstati(STAT_FUEL); if(autocvar__hud_configure) { @@ -2577,13 +2586,16 @@ void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float killnotify_victims[0] = strzone(victim); } -void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) +void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s1 = attacker, s2 = victim { float w; float alsoprint, gentle; alsoprint = (autocvar_hud_panel_notify_print || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages); + if (msg == MSG_SUICIDE && gametype == GAME_CTS) // selfkill isn't interesting in CTS and only spams up the notify panel + return; + if(msg == MSG_SUICIDE) { w = DEATH_WEAPONOF(type); if(WEP_VALID(w)) { @@ -2658,101 +2670,104 @@ void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) } else if(type == KILL_FIRST_BLOOD) print("^1",s1, "^1 drew first blood", "\n"); - // TODO: icon! else if (type == DEATH_TELEFRAG) { - HUD_KillNotify_Push(s2, s1, 1, DEATH_TELEFRAG); + HUD_KillNotify_Push(s1, s2, 1, DEATH_TELEFRAG); if(gentle) - print ("^1",s1, "^1 tried to occupy ", s2, "^1's teleport destination space\n"); + print ("^1",s2, "^1 tried to occupy ", s1, "^1's teleport destination space\n"); else - print ("^1",s1, "^1 was telefragged by ", s2, "\n"); + print ("^1",s2, "^1 was telefragged by ", s1, "\n"); } else if (type == DEATH_DROWN) { - HUD_KillNotify_Push(s2, s1, 1, DEATH_DROWN); + HUD_KillNotify_Push(s1, s2, 1, DEATH_DROWN); if(alsoprint) - print ("^1",s1, "^1 was drowned by ", s2, "\n"); + print ("^1",s2, "^1 was drowned by ", s1, "\n"); } else if (type == DEATH_SLIME) { - HUD_KillNotify_Push(s2, s1, 1, DEATH_SLIME); + HUD_KillNotify_Push(s1, s2, 1, DEATH_SLIME); if(alsoprint) - print ("^1",s1, "^1 was slimed by ", s2, "\n"); + print ("^1",s2, "^1 was slimed by ", s1, "\n"); } else if (type == DEATH_LAVA) { - HUD_KillNotify_Push(s2, s1, 1, DEATH_LAVA); + HUD_KillNotify_Push(s1, s2, 1, DEATH_LAVA); if(alsoprint) - print ("^1",s1, "^1 was cooked by ", s2, "\n"); + print ("^1",s2, "^1 was cooked by ", s1, "\n"); } else if (type == DEATH_FALL) { - HUD_KillNotify_Push(s2, s1, 1, DEATH_FALL); + HUD_KillNotify_Push(s1, s2, 1, DEATH_FALL); if(alsoprint) - print ("^1",s1, "^1 was grounded by ", s2, "\n"); + print ("^1",s2, "^1 was grounded by ", s1, "\n"); } else if (type == DEATH_SHOOTING_STAR) { - HUD_KillNotify_Push(s2, s1, 1, DEATH_SHOOTING_STAR); + HUD_KillNotify_Push(s1, s2, 1, DEATH_SHOOTING_STAR); if(alsoprint) - print ("^1",s1, "^1 was shot into space by ", s2, "\n"); + print ("^1",s2, "^1 was shot into space by ", s1, "\n"); } else if (type == DEATH_SWAMP) { - HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC); + HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC); if(alsoprint) - print ("^1",s1, "^1 was conserved by ", s2, "\n"); + print ("^1",s2, "^1 was conserved by ", s1, "\n"); } else if (type == DEATH_HURTTRIGGER) { - HUD_KillNotify_Push(s2, s1, 1, DEATH_HURTTRIGGER); + HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER); if(alsoprint) - print("^1",s1, "^1 was thrown into a world of hurt by ", s2, "\n"); + print("^1",s2, "^1 was thrown into a world of hurt by ", s1, "\n"); } else if(type == DEATH_SBCRUSH) { - HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC); + HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC); if(alsoprint) - print ("^1",s1, "^1 was crushed by ^1", s2, "\n"); + print ("^1",s2, "^1 was crushed by ^1", s1, "\n"); } else if(type == DEATH_SBMINIGUN) { - HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC); + HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC); if(alsoprint) - print ("^1",s1, "^1 got shredded by ^1", s2, "\n"); + print ("^1",s2, "^1 got shredded by ^1", s1, "\n"); } else if(type == DEATH_SBROCKET) { - HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC); + HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC); if(alsoprint) - print ("^1",s1, "^1 was blased to bits by ^1", s2, "\n"); + print ("^1",s2, "^1 was blased to bits by ^1", s1, "\n"); } else if(type == DEATH_SBBLOWUP) { - HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC); + HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC); if(alsoprint) - print ("^1",s1, "^1 got caught in the destruction of ^1", s2, "'s vehicle\n"); + print ("^1",s2, "^1 got caught in the destruction of ^1", s1, "'s vehicle\n"); } else if(type == DEATH_WAKIGUN) { - HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC); + HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC); if(alsoprint) - print ("^1",s1, "^1 was bolted down by ^1", s2, "\n"); + print ("^1",s2, "^1 was bolted down by ^1", s1, "\n"); } else if(type == DEATH_WAKIROCKET) { - HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC); + HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC); if(alsoprint) - print ("^1",s1, "^1 could find no shelter from ^1", s2, "'s rockets\n"); + print ("^1",s2, "^1 could find no shelter from ^1", s1, "'s rockets\n"); } else if(type == DEATH_WAKIBLOWUP) { - HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC); + HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC); if(alsoprint) - print ("^1",s1, "^1 dies when ^1", s2, "'s wakizashi dies.\n"); + print ("^1",s2, "^1 dies when ^1", s1, "'s wakizashi dies.\n"); } else if(type == DEATH_TURRET) { - HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC); + HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC); if(alsoprint) - print ("^1",s1, "^1 was pushed into the line of fire by ^1", s2, "\n"); + print ("^1",s2, "^1 was pushed into the line of fire by ^1", s1, "\n"); } else if(type == DEATH_TOUCHEXPLODE) { - HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC); + HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC); if(alsoprint) - print ("^1",s1, "^1 was pushed into an accident by ^1", s2, "\n"); + print ("^1",s2, "^1 was pushed into an accident by ^1", s1, "\n"); } else if(type == DEATH_CHEAT) { - HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC); + HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC); if(alsoprint) - print ("^1",s1, "^1 was unfairly eliminated by ^1", s2, "\n"); + print ("^1",s2, "^1 was unfairly eliminated by ^1", s1, "\n"); } else if (type == DEATH_FIRE) { - HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC); + HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC); if(alsoprint) - print ("^1",s1, "^1 was burnt to death by ^1", s2, "\n"); + print ("^1",s2, "^1 was burnt to death by ^1", s1, "\n"); } else if (type == DEATH_CUSTOM) { - HUD_KillNotify_Push(s2, s1, 1, DEATH_CUSTOM); + HUD_KillNotify_Push(s1, s2, 1, DEATH_CUSTOM); if(alsoprint) - print ("^1",s1, "^1 ", s2, "\n"); + print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n"); + } else if (type == DEATH_HURTTRIGGER) { + HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER); + if(alsoprint) + print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n"); } else { - HUD_KillNotify_Push(s2, s1, 1, DEATH_GENERIC); + HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC); if(alsoprint) - print ("^1",s1, "^1 was fragged by ", s2, "\n"); + print ("^1",s2, "^1 was fragged by ", s1, "\n"); } } else if(msg == MSG_SPREE) { if(type == KILL_END_SPREE) { @@ -2853,11 +2868,11 @@ void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) } else if (type == DEATH_CUSTOM) { HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM); if(alsoprint) - print ("^1",s1, "^1 ", s2, "\n"); + print("^1", sprintf(s2, strcat(s1, "^1")), "\n"); } else if (type == DEATH_HURTTRIGGER) { HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER); if(alsoprint) - print ("^1",s1, "^1 was in the wrong place\n"); + print("^1", sprintf(s2, strcat(s1, "^1")), "\n"); } else if(type == DEATH_TOUCHEXPLODE) { HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC); if(alsoprint) @@ -2907,6 +2922,19 @@ void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) HUD_KillNotify_Push(s1, s2, 0, INFO_CAPTUREFLAG); print(s1, "^7 captured the ", s2, s3, "\n"); } + } else if(msg == MSG_RACE) { + if(type == RACE_SERVER_RECORD) { + HUD_KillNotify_Push(s1, s2, 1, RACE_SERVER_RECORD); + } + else if(type == RACE_NEW_RANK) { + HUD_KillNotify_Push(s1, s2, 1, RACE_NEW_RANK); + } + else if(type == RACE_NEW_TIME) { + HUD_KillNotify_Push(s1, s2, 1, RACE_NEW_TIME); + } + else if(type == RACE_FAIL) { + HUD_KillNotify_Push(s1, s2, 1, RACE_FAIL); + } } } @@ -3243,6 +3271,22 @@ void HUD_Notify (void) { s = "notify_void"; } + else if(killnotify_deathtype[j] == RACE_SERVER_RECORD) + { + s = "race_newrecordserver"; + } + else if(killnotify_deathtype[j] == RACE_NEW_RANK) + { + s = "race_newrankyellow"; + } + else if(killnotify_deathtype[j] == RACE_NEW_TIME) + { + s = "race_newtime"; + } + else if(killnotify_deathtype[j] == RACE_FAIL) + { + s = "race_newfail"; + } if(s != "" && a) { drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL); @@ -3733,15 +3777,37 @@ float vote_change; // "time" when vote_active changed void HUD_VoteWindow(void) { + if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE)) + { + vote_active = 1; + vote_called_vote = "^2Name ^7instead of \"^1Unregistered player\" ^7in stats"; + } + if(!autocvar_hud_panel_vote && !autocvar__hud_configure) return; active_panel = HUD_PANEL_VOTE; HUD_Panel_UpdateCvars(vote); + if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE)) + { + panel_pos = eX * 0.3 * vid_conwidth + eY * 0.1 * vid_conheight; + panel_size = eX * 0.4 * vid_conwidth + eY * 0.3 * vid_conheight; + } vector pos, mySize; pos = panel_pos; mySize = panel_size; + if(!autocvar__hud_configure) + { + panel_fg_alpha = autocvar_hud_panel_fg_alpha; + panel_bg_alpha_str = autocvar_hud_panel_vote_bg_alpha; + + if(panel_bg_alpha_str == "") { + panel_bg_alpha_str = ftos(autocvar_hud_panel_bg_alpha); + } + panel_bg_alpha = stof(panel_bg_alpha_str); + } + string s; float a; if(vote_active != vote_prev) { @@ -3764,9 +3830,9 @@ void HUD_VoteWindow(void) if(!vote_alpha) return; - a = vote_alpha * bound(autocvar_hud_panel_vote_alreadyvoted_alpha, 1 - vote_highlighted, 1); - + a = panel_bg_alpha * vote_alpha * bound(autocvar_hud_panel_vote_alreadyvoted_alpha, 1 - vote_highlighted, 1); HUD_Panel_DrawBg(a); + a = panel_fg_alpha * vote_alpha * bound(autocvar_hud_panel_vote_alreadyvoted_alpha, 1 - vote_highlighted, 1); if(panel_bg_padding) { pos += '1 1 0' * panel_bg_padding; @@ -3792,37 +3858,43 @@ void HUD_VoteWindow(void) mySize = newSize; s = "A vote has been called for:"; - drawstring_aspect(pos, s, eX * mySize_x + eY * (2/8) * mySize_y, '1 1 1', a * panel_fg_alpha, DRAWFLAG_NORMAL); - s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (1.75/8), stringwidth_colors); + if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE)) + s = "Allow servers to store and display your name?"; + drawstring_aspect(pos, s, eX * mySize_x + eY * (2/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL); + s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (1/8), stringwidth_colors); if(autocvar__hud_configure) s = "^1Configure the HUD"; - drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize_y, s, eX * mySize_x + eY * (1.75/8) * mySize_y, a * panel_fg_alpha, DRAWFLAG_NORMAL); + drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize_y, s, eX * mySize_x + eY * (1.75/8) * mySize_y, a, DRAWFLAG_NORMAL); // print the yes/no counts - s = strcat("Yes (", getcommandkey("not bound", "vyes"), "): ", ftos(vote_yescount)); - drawstring_aspect(pos + eY * (4/8) * mySize_y, s, eX * 0.5 * mySize_x + eY * (1.5/8) * mySize_y, '0 1 0', a * panel_fg_alpha, DRAWFLAG_NORMAL); - s = strcat("No (", getcommandkey("not bound", "vno"), "): ", ftos(vote_nocount)); - drawstring_aspect(pos + eX * 0.5 * mySize_x + eY * (4/8) * mySize_y, s, eX * 0.5 * mySize_x + eY * (1.5/8) * mySize_y, '1 0 0', a * panel_fg_alpha, DRAWFLAG_NORMAL); + s = strcat("Yes (", getcommandkey("vyes", "vyes"), "): ", ftos(vote_yescount)); + if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE)) + s = strcat("Yes: (press y)"); + drawstring_aspect(pos + eY * (4/8) * mySize_y, s, eX * 0.5 * mySize_x + eY * (1.5/8) * mySize_y, '0 1 0', a, DRAWFLAG_NORMAL); + s = strcat("No (", getcommandkey("vno", "vno"), "): ", ftos(vote_nocount)); + if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE)) + s = strcat("No: (press n)"); + drawstring_aspect(pos + eX * 0.5 * mySize_x + eY * (4/8) * mySize_y, s, eX * 0.5 * mySize_x + eY * (1.5/8) * mySize_y, '1 0 0', a, DRAWFLAG_NORMAL); // draw the progress bar backgrounds - drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_back", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a * panel_fg_alpha, DRAWFLAG_NORMAL); + drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_back", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL); // draw the highlights if(vote_highlighted == 1) { drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y); - drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '0 1 0', a * panel_fg_alpha, DRAWFLAG_NORMAL); + drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL); } else if(vote_highlighted == 2) { drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y); - drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '0 1 0', a * panel_fg_alpha, DRAWFLAG_NORMAL); + drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL); } // draw the progress bars drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y); - drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '0 1 0', a * panel_fg_alpha, DRAWFLAG_NORMAL); + drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL); drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y); - drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 0 0', a * panel_fg_alpha, DRAWFLAG_NORMAL); + drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL); drawresetcliparea(); @@ -3836,6 +3908,37 @@ void HUD_VoteWindow(void) float mod_active; // is there any active mod icon? +// Clan Arena HUD modicons +void HUD_Mod_CA(vector pos, vector mySize) +{ + mod_active = 1; // CA should never hide the mod icons panel + float redalive, bluealive; + redalive = getstati(STAT_REDALIVE); + bluealive = getstati(STAT_BLUEALIVE); + + drawfont = hud_bigfont; + vector redpos, bluepos; + if(mySize_x > mySize_y) + { + redpos = pos; + bluepos = pos + eY * 0.5 * mySize_y; + drawpic_aspect_skin(redpos, "player_red.tga", 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + drawstring_aspect(redpos + eX * 0.5 * mySize_x, ftos(redalive), 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + drawpic_aspect_skin(bluepos, "player_blue.tga", 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + drawstring_aspect(bluepos + eX * 0.5 * mySize_x, ftos(bluealive), 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + } + else + { + redpos = pos; + bluepos = pos + eY * 0.5 * mySize_y; + drawpic_aspect_skin(redpos, "player_red.tga", eX * mySize_x + eY * 0.3 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + drawstring_aspect(redpos + eY * 0.3 * mySize_y, ftos(redalive), eX * mySize_x + eY * 0.2 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + drawpic_aspect_skin(bluepos, "player_blue.tga", eX * mySize_x + eY * 0.3 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + drawstring_aspect(bluepos + eY * 0.3 * mySize_y, ftos(bluealive), eX * mySize_x + eY * 0.2 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + } + drawfont = hud_font; +} + // CTF HUD modicon section float redflag_prevframe, blueflag_prevframe; // status during previous frame float redflag_prevstatus, blueflag_prevstatus; // last remembered status @@ -4220,16 +4323,31 @@ void HUD_Mod_Race(vector pos, vector mySize) crecordtime_prev = t; crecordtime_change_time = time; } + + vector textPos, medalPos; + float squareSize; + if(mySize_x > mySize_y) { + // text on left side + squareSize = min(mySize_y, mySize_x/2); + textPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eY * 0.5 * (mySize_y - squareSize); + medalPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eX * 0.5 * mySize_x + eY * 0.5 * (mySize_y - squareSize); + } else { + // text on top + squareSize = min(mySize_x, mySize_y/2); + textPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eX * 0.5 * (mySize_x - squareSize);; + medalPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eY * 0.5 * mySize_y + eX * 0.5 * (mySize_x - squareSize); + } + f = time - crecordtime_change_time; if (f > 1) { - drawstring_aspect(pos, "Personal best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); - drawstring_aspect(pos + eY * 0.25 * mySize_y, TIME_ENCODED_TOSTRING(t), eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + drawstring_aspect(textPos, "Personal best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + drawstring_aspect(textPos + eY * 0.25 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); } else { - drawstring_aspect(pos, "Personal best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); - drawstring_aspect(pos + eY * 0.25 * mySize_y, TIME_ENCODED_TOSTRING(t), eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); - drawstring_aspect_expanding(pos, "Personal best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f); - drawstring_aspect_expanding(pos + eY * 0.25 * mySize_y, TIME_ENCODED_TOSTRING(t), eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f); + drawstring_aspect(textPos, "Personal best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + drawstring_aspect(textPos + eY * 0.25 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + drawstring_aspect_expanding(pos, "Personal best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f); + drawstring_aspect_expanding(pos + eY * 0.25 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f); } // server record @@ -4241,13 +4359,13 @@ void HUD_Mod_Race(vector pos, vector mySize) f = time - srecordtime_change_time; if (f > 1) { - drawstring_aspect(pos + eY * 0.5 * mySize_y, "Server best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); - drawstring_aspect(pos + eY * 0.75 * mySize_y, TIME_ENCODED_TOSTRING(t), eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + drawstring_aspect(textPos + eY * 0.5 * squareSize, "Server best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + drawstring_aspect(textPos + eY * 0.75 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); } else { - drawstring_aspect(pos + eY * 0.5 * mySize_y, "Server best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); - drawstring_aspect(pos + eY * 0.75 * mySize_y, TIME_ENCODED_TOSTRING(t), eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); - drawstring_aspect_expanding(pos + eY * 0.5 * mySize_y, "Server best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f); - drawstring_aspect_expanding(pos + eY * 0.75 * mySize_y, TIME_ENCODED_TOSTRING(t), eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f); + drawstring_aspect(textPos + eY * 0.5 * squareSize, "Server best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + drawstring_aspect(textPos + eY * 0.75 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + drawstring_aspect_expanding(textPos + eY * 0.5 * squareSize, "Server best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f); + drawstring_aspect_expanding(textPos + eY * 0.75 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f); } if (race_status != race_status_prev || race_status_name != race_status_name_prev) { @@ -4258,13 +4376,12 @@ void HUD_Mod_Race(vector pos, vector mySize) race_status_name_prev = strzone(race_status_name); } - pos_x += mySize_x/2; // race "awards" float a; a = bound(0, race_status_time - time, 1); string s; - s = textShortenToWidth(race_status_name, mySize_y, '1 1 0' * 0.1 * mySize_y, stringwidth_colors); + s = textShortenToWidth(race_status_name, squareSize, '1 1 0' * 0.1 * squareSize, stringwidth_colors); float rank; if(race_status > 0) @@ -4273,27 +4390,27 @@ void HUD_Mod_Race(vector pos, vector mySize) rankname = race_PlaceName(rank); vector namepos; - namepos = pos + '0.5 0.9 0' * mySize_y - eX * stringwidth(s, TRUE, '1 1 0' * 0.1 * mySize_y); + namepos = medalPos + '0 0.8 0' * squareSize; vector rankpos; - rankpos = pos + '0.5 0.25 0' * mySize_y - eX * stringwidth(rankname, TRUE, '1 1 0' * 0.15 * mySize_y); + rankpos = medalPos + '0 0.15 0' * squareSize; if(race_status == 0) - drawpic_aspect_skin(pos, "race_newfail", '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL); + drawpic_aspect_skin(medalPos, "race_newfail", '1 1 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL); else if(race_status == 1) { - drawpic_aspect_skin(pos, "race_newtime", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL); - drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL); - drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL); + drawpic_aspect_skin(medalPos + '0.1 0 0' * squareSize, "race_newtime", '1 1 0' * 0.8 * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL); + drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL); + drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL); } else if(race_status == 2) { if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank) - drawpic_aspect_skin(pos, "race_newrankgreen", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL); + drawpic_aspect_skin(medalPos + '0.1 0 0' * squareSize, "race_newrankgreen", '1 1 0' * 0.8 * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL); else - drawpic_aspect_skin(pos, "race_newrankyellow", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL); - drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL); - drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL); + drawpic_aspect_skin(medalPos + '0.1 0 0' * squareSize, "race_newrankyellow", '1 1 0' * 0.8 * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL); + drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL); + drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL); } else if(race_status == 3) { - drawpic_aspect_skin(pos, "race_newrecordserver", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL); - drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL); - drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL); + drawpic_aspect_skin(medalPos + '0.1 0 0' * squareSize, "race_newrecordserver", '1 1 0' * 0.8 * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL); + drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL); + drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL); } if (race_status_time - time <= 0) { @@ -4318,7 +4435,7 @@ void HUD_ModIcons(void) if(!autocvar_hud_panel_modicons && !autocvar__hud_configure) return; - if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && !autocvar__hud_configure) + if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && gametype != GAME_CA && !autocvar__hud_configure) return; active_panel = HUD_PANEL_MODICONS; @@ -4355,6 +4472,8 @@ void HUD_ModIcons(void) HUD_Mod_NexBall(pos, mySize); else if(gametype == GAME_CTS || gametype == GAME_RACE) HUD_Mod_Race(pos, mySize); + else if(gametype == GAME_CA) + HUD_Mod_CA(pos, mySize); } // Draw pressed keys (#11) @@ -4431,8 +4550,15 @@ void HUD_Chat(void) { panel_pos_y = panel_bg_border; panel_size_y = vid_conheight - panel_bg_border * 2; - if(panel_bg == "0") - panel_bg = "border"; // force a border when maximized + if(panel_bg == "0") // force a border when maximized + { + if(precache_pic(panel_bg) == "") { + panel_bg = strcat(hud_skin_path, "/border_default"); + if(precache_pic(panel_bg) == "") { + panel_bg = "gfx/hud/default/border_default"; + } + } + } panel_bg_alpha = max(0.75, panel_bg_alpha); // force an alpha of at least 0.75 } @@ -4500,29 +4626,32 @@ void HUD_EngineInfo(void) mySize -= '2 2 0' * panel_bg_padding; } + float currentTime = gettime(GETTIME_REALTIME); if(cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage")) { - frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + frametime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P + float currentframetime = currentTime - prevfps_time; + frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + currentframetime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P frametimeavg2 = frametimeavg1; frametimeavg1 = frametimeavg; float weight; weight = cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage_new_weight"); - if(frametime > 0.0001) // filter out insane values which sometimes seem to occur and throw off the average? If you are getting 10,000 fps or more, then you don't need a framerate counter. + if(currentframetime > 0.0001) // filter out insane values which sometimes seem to occur and throw off the average? If you are getting 10,000 fps or more, then you don't need a framerate counter. { - if(fabs(prevfps - (1/frametimeavg)) > prevfps * cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage_instantupdate_change_threshold")) // if there was a big jump in fps, just force prevfps at current (1/frametime) to make big updates instant - prevfps = (1/frametime); + if(fabs(prevfps - (1/frametimeavg)) > prevfps * cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage_instantupdate_change_threshold")) // if there was a big jump in fps, just force prevfps at current (1/currentframetime) to make big updates instant + prevfps = (1/currentframetime); prevfps = (1 - weight) * prevfps + weight * (1/frametimeavg); // framecounter just used so there's no need for a new variable, think of it as "frametime average" } + prevfps_time = currentTime; } else { framecounter += 1; - if(time - prevfps_time > cvar("hud_panel_engineinfo_framecounter_time")) + if(currentTime - prevfps_time > cvar("hud_panel_engineinfo_framecounter_time")) { - prevfps = framecounter/cvar("hud_panel_engineinfo_framecounter_time"); + prevfps = framecounter/(currentTime - prevfps_time); framecounter = 0; - prevfps_time = time; + prevfps_time = currentTime; } } @@ -4535,6 +4664,11 @@ void HUD_EngineInfo(void) // Info messages panel (#14) // +#define drawInfoMessage(s)\ + if(autocvar_hud_panel_infomessages_flip)\ + o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);\ + drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);\ + o_y += fontsize_y; void HUD_InfoMessages(void) { if(!autocvar_hud_panel_infomessages && !autocvar__hud_configure) @@ -4593,35 +4727,22 @@ void HUD_InfoMessages(void) s = "^1Observing"; else s = strcat("^1Spectating: ^7", GetPlayerName(spectatee_status - 1)); - - if(autocvar_hud_panel_infomessages_flip) - o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize); - drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL); - o += eY * fontsize_y; + drawInfoMessage(s) if(spectatee_status == -1) - s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate"); + s = strcat("^1Press ^3", getcommandkey("primary fire", "+fire"), "^1 to spectate"); else - s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player"); - if(autocvar_hud_panel_infomessages_flip) - o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize); - drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL); - o += eY * fontsize_y; + s = strcat("^1Press ^3", getcommandkey("primary fire", "+fire"), "^1 for another player"); + drawInfoMessage(s) if(spectatee_status == -1) s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed"); else - s = strcat("^1Press ^3", getcommandkey("secondary fire", "+attack2"), "^1 to observe"); - if(autocvar_hud_panel_infomessages_flip) - o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize); - drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL); - o += eY * fontsize_y; + s = strcat("^1Press ^3", getcommandkey("secondary fire", "+fire2"), "^1 to observe"); + drawInfoMessage(s) s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info"); - if(autocvar_hud_panel_infomessages_flip) - o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize); - drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL); - o += eY * fontsize_y; + drawInfoMessage(s) if(gametype == GAME_ARENA) s = "^1Wait for your turn to join"; @@ -4638,10 +4759,7 @@ void HUD_InfoMessages(void) } else s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join"); - if(autocvar_hud_panel_infomessages_flip) - o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize); - drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL); - o += eY * fontsize_y; + drawInfoMessage(s) //show restart countdown: if (time < getstatf(STAT_GAMESTARTTIME)) { @@ -4650,16 +4768,13 @@ void HUD_InfoMessages(void) countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time); s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds"); drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL); - o += eY * fontsize_y; + o_y += fontsize_y; } } if(warmup_stage && !intermission) { s = "^2Currently in ^1warmup^2 stage!"; - if(autocvar_hud_panel_infomessages_flip) - o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize); - drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL); - o += eY * fontsize_y; + drawInfoMessage(s) } string blinkcolor; @@ -4684,18 +4799,12 @@ void HUD_InfoMessages(void) else s = strcat("^2Waiting for others to ready up..."); } - if(autocvar_hud_panel_infomessages_flip) - o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize); - drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL); - o += eY * fontsize_y; + drawInfoMessage(s) } else if(warmup_stage && !intermission && !spectatee_status) { s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup"); - if(autocvar_hud_panel_infomessages_flip) - o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize); - drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL); - o += eY * fontsize_y; + drawInfoMessage(s) } if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger) @@ -4721,11 +4830,7 @@ void HUD_InfoMessages(void) if (tm.team != COLOR_SPECTATOR) if (tm.team_size == ts_max) s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust"); - - if(autocvar_hud_panel_infomessages_flip) - o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize); - drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL); - o += eY * fontsize_y; + drawInfoMessage(s) } } } @@ -4733,25 +4838,13 @@ void HUD_InfoMessages(void) else { s = "^7Press ^3ESC ^7to show HUD options."; - if(autocvar_hud_panel_infomessages_flip) - o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize); - drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL); - o += eY * fontsize_y; + drawInfoMessage(s) s = "^3Doubleclick ^7a panel for panel-specific options."; - if(autocvar_hud_panel_infomessages_flip) - o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize); - drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL); - o += eY * fontsize_y; + drawInfoMessage(s) s = "^3CTRL ^7to disable collision testing, ^3SHIFT ^7and"; - if(autocvar_hud_panel_infomessages_flip) - o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize); - drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL); - o += eY * fontsize_y; + drawInfoMessage(s) s = "^3ALT ^7+ ^3ARROW KEYS ^7for fine adjustments."; - if(autocvar_hud_panel_infomessages_flip) - o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize); - drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL); - o += eY * fontsize_y; + drawInfoMessage(s) } } @@ -4802,11 +4895,11 @@ void HUD_ShowSpeed(void) pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position"); drawfont = hud_bigfont; - drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', autocvar_hud_panel_fg_alpha, DRAWFLAG_NORMAL); + drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', autocvar_hud_panel_fg_alpha * hud_fade_alpha, DRAWFLAG_NORMAL); if (cvar("cl_showspeed_z") == 1) { zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit); - drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', autocvar_hud_panel_fg_alpha, DRAWFLAG_NORMAL); + drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', autocvar_hud_panel_fg_alpha * hud_fade_alpha, DRAWFLAG_NORMAL); } drawfont = hud_font; @@ -4834,6 +4927,8 @@ void HUD_ShowAcceleration(void) f = bound(0, f * 10, 1); acc_avg = acc_avg * (1 - f) + acceleration * f; acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED); + if (acceleration == 0) + return; pos = top - sz/2 * eY + (cvar("cl_showacceleration_position") * vid_conheight) * eY; @@ -4843,18 +4938,16 @@ void HUD_ShowAcceleration(void) if (cvar("cl_showacceleration_color_custom")) rgb = stov(cvar_string("cl_showacceleration_color")); else { - rgb = '1 1 1'; - if (acceleration < 0) { + if (acceleration < 0) rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1); - } else if (acceleration > 0) { + else rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1); - } } if (acceleration > 0) - HUD_Panel_DrawProgressBar(pos, 0, acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * autocvar_hud_panel_fg_alpha, DRAWFLAG_NORMAL); - else if (acceleration < 0) - HUD_Panel_DrawProgressBar(pos + acceleration * scale * '40 0 0', 0, -acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * autocvar_hud_panel_fg_alpha, DRAWFLAG_NORMAL); + HUD_Panel_DrawProgressBar(pos, 0, acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * autocvar_hud_panel_fg_alpha * hud_fade_alpha, DRAWFLAG_NORMAL); + else + HUD_Panel_DrawProgressBar(pos + acceleration * scale * '40 0 0', 0, -acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * autocvar_hud_panel_fg_alpha * hud_fade_alpha, DRAWFLAG_NORMAL); } void HUD_Reset (void) @@ -4905,7 +4998,7 @@ void HUD_Main (void) hud_skin_path = strcat("gfx/hud/", autocvar_hud_skin); // global hud alpha fade - if(disable_menu_alphacheck == 1) + if(menu_enabled == 1) hud_fade_alpha = 1; else hud_fade_alpha = (1 - autocvar__menu_alpha); @@ -4918,11 +5011,10 @@ void HUD_Main (void) else if(autocvar__menu_alpha == 0 && scoreboard_fade_alpha == 0) hud_fade_alpha = 1; - hud_border_thickness = bound(0, cvar("hud_border_thickness"), 5); - hud_accuracy_border_thickness = bound(0, cvar_or("hud_accuracy_border_thickness", 1), 5); - hud_fontsize = HUD_GetFontsize("hud_fontsize"); - hud_fontsize_spec = HUD_GetFontsize("hud_fontsize_spec"); + + if(!autocvar__hud_configure && !hud_fade_alpha) + return; // Drawing stuff @@ -4942,29 +5034,29 @@ void HUD_Main (void) } } - float f; - vector color; - if((teamplay) && autocvar_hud_dock_color_team) { - f = stof(getplayerkey(player_localentnum - 1, "colors")); - color = colormapPaletteColor(mod(f, 16), 1) * autocvar_hud_dock_color_team; - } - else if(autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && autocvar_hud_dock_color_team) { - color = '1 0 0' * autocvar_hud_dock_color_team; - } - else if(autocvar_hud_dock_color == "shirt") { - f = stof(getplayerkey(player_localentnum - 1, "colors")); - color = colormapPaletteColor(floor(f / 16), 0); - } - else if(autocvar_hud_dock_color == "pants") { - f = stof(getplayerkey(player_localentnum - 1, "colors")); - color = colormapPaletteColor(mod(f, 16), 1); - } - else - color = stov(autocvar_hud_dock_color); - // draw the dock if(autocvar_hud_dock != "" && autocvar_hud_dock != "0") { + float f; + vector color; + if((teamplay) && autocvar_hud_dock_color_team) { + f = stof(getplayerkey(player_localentnum - 1, "colors")); + color = colormapPaletteColor(mod(f, 16), 1) * autocvar_hud_dock_color_team; + } + else if(autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && autocvar_hud_dock_color_team) { + color = '1 0 0' * autocvar_hud_dock_color_team; + } + else if(autocvar_hud_dock_color == "shirt") { + f = stof(getplayerkey(player_localentnum - 1, "colors")); + color = colormapPaletteColor(floor(f / 16), 0); + } + else if(autocvar_hud_dock_color == "pants") { + f = stof(getplayerkey(player_localentnum - 1, "colors")); + color = colormapPaletteColor(mod(f, 16), 1); + } + else + color = stov(autocvar_hud_dock_color); + string pic; pic = strcat(hud_skin_path, "/", autocvar_hud_dock); if(precache_pic(pic) == "") { @@ -5008,5 +5100,6 @@ void HUD_Main (void) hud_configure_prev = autocvar__hud_configure; if (!autocvar__hud_configure) // hud config mode disabled, enable normal alpha stuff again - disable_menu_alphacheck = 0; + if (menu_enabled) + menu_enabled = 0; }