From: terencehill Date: Thu, 8 Oct 2015 19:02:50 +0000 (+0200) Subject: Clean up HUD code: X-Git-Tag: xonotic-v0.8.2~1799^2~13 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=8c7cd804a5fa9b90d8c2753265727f5ea32087cb;p=xonotic%2Fxonotic-data.pk3dir.git Clean up HUD code: * vehicle crosshair code is now separated from vehicle HUD code and gets called right after the normal crosshair code * the new function HUD_Draw() takes care of drawing HUD and crosshair, instead of UpdateCrosshair(!) --- diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index 3bb5585f3..defec0708 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -457,6 +457,31 @@ bool WantEventchase() return false; } +void HUD_Vehicle() +{ + if(!hud || intermission) + return; + + if(hud == HUD_BUMBLEBEE_GUN) + CSQC_BUMBLE_GUN_HUD(); + else { + Vehicle info = get_vehicleinfo(hud); + info.vr_hud(info); + } +} + +void HUD_Crosshair_Vehicle() +{ + if(!hud || intermission) + return; + + if(hud != HUD_BUMBLEBEE_GUN) + { + Vehicle info = get_vehicleinfo(hud); + info.vr_crosshair(info); + } +} + vector damage_blurpostprocess, content_blurpostprocess; float unaccounted_damage = 0; @@ -484,7 +509,7 @@ void UpdateDamage() spectatee_status_prev = spectatee_status; } -void UpdateHitsound() +void HitSound() { // varying sound pitch @@ -533,34 +558,13 @@ void UpdateHitsound() } } -void UpdateCrosshair() +void HUD_Crosshair() {SELFPARAM(); static float rainbow_last_flicker; static vector rainbow_prev_color; entity e = self; float f, i, j; vector v; - if(getstati(STAT_FROZEN)) - drawfill('0 0 0', eX * vid_conwidth + eY * vid_conheight, ((getstatf(STAT_REVIVE_PROGRESS)) ? ('0.25 0.90 1' + ('1 0 0' * getstatf(STAT_REVIVE_PROGRESS)) + ('0 1 1' * getstatf(STAT_REVIVE_PROGRESS) * -1)) : '0.25 0.90 1'), autocvar_hud_colorflash_alpha, DRAWFLAG_ADDITIVE); - else if (getstatf(STAT_HEALING_ORB)>time) - drawfill('0 0 0', eX * vid_conwidth + eY * vid_conheight, NADE_TYPE_HEAL.m_color, autocvar_hud_colorflash_alpha*getstatf(STAT_HEALING_ORB_ALPHA), DRAWFLAG_ADDITIVE); - if(!intermission) - if(getstatf(STAT_NADE_TIMER) && autocvar_cl_nade_timer) // give nade top priority, as it's a matter of life and death - { - DrawCircleClippedPic(eX * 0.5 * vid_conwidth + eY * 0.6 * vid_conheight, 0.1 * vid_conheight, "gfx/crosshair_ring.tga", getstatf(STAT_NADE_TIMER), '0.25 0.90 1' + ('1 0 0' * getstatf(STAT_NADE_TIMER)) - ('0 1 1' * getstatf(STAT_NADE_TIMER)), autocvar_hud_colorflash_alpha, DRAWFLAG_ADDITIVE); - drawstring_aspect(eY * 0.64 * vid_conheight, ((autocvar_cl_nade_timer == 2) ? _("Nade timer") : ""), eX * vid_conwidth + eY * 0.025 * vid_conheight, '1 1 1', 1, DRAWFLAG_NORMAL); - } - else if(getstatf(STAT_REVIVE_PROGRESS)) - { - DrawCircleClippedPic(eX * 0.5 * vid_conwidth + eY * 0.6 * vid_conheight, 0.1 * vid_conheight, "gfx/crosshair_ring.tga", getstatf(STAT_REVIVE_PROGRESS), '0.25 0.90 1', autocvar_hud_colorflash_alpha, DRAWFLAG_ADDITIVE); - drawstring_aspect(eY * 0.64 * vid_conheight, _("Revival progress"), eX * vid_conwidth + eY * 0.025 * vid_conheight, '1 1 1', 1, DRAWFLAG_NORMAL); - } - - if(autocvar_r_letterbox == 0) - if(autocvar_viewsize < 120) - CSQC_common_hud(); - - // crosshair goes VERY LAST if(!scoreboard_active && !camera_active && intermission != 2 && spectatee_status != -1 && hud == HUD_NORMAL && !csqcplayer.viewloc && !HUD_MinigameMenu_IsOpened() ) @@ -1007,6 +1011,35 @@ void UpdateCrosshair() } } +void HUD_Draw() +{ + if(getstati(STAT_FROZEN)) + drawfill('0 0 0', eX * vid_conwidth + eY * vid_conheight, ((getstatf(STAT_REVIVE_PROGRESS)) ? ('0.25 0.90 1' + ('1 0 0' * getstatf(STAT_REVIVE_PROGRESS)) + ('0 1 1' * getstatf(STAT_REVIVE_PROGRESS) * -1)) : '0.25 0.90 1'), autocvar_hud_colorflash_alpha, DRAWFLAG_ADDITIVE); + else if (getstatf(STAT_HEALING_ORB)>time) + drawfill('0 0 0', eX * vid_conwidth + eY * vid_conheight, NADE_TYPE_HEAL.m_color, autocvar_hud_colorflash_alpha*getstatf(STAT_HEALING_ORB_ALPHA), DRAWFLAG_ADDITIVE); + if(!intermission) + if(getstatf(STAT_NADE_TIMER) && autocvar_cl_nade_timer) // give nade top priority, as it's a matter of life and death + { + DrawCircleClippedPic(eX * 0.5 * vid_conwidth + eY * 0.6 * vid_conheight, 0.1 * vid_conheight, "gfx/crosshair_ring.tga", getstatf(STAT_NADE_TIMER), '0.25 0.90 1' + ('1 0 0' * getstatf(STAT_NADE_TIMER)) - ('0 1 1' * getstatf(STAT_NADE_TIMER)), autocvar_hud_colorflash_alpha, DRAWFLAG_ADDITIVE); + drawstring_aspect(eY * 0.64 * vid_conheight, ((autocvar_cl_nade_timer == 2) ? _("Nade timer") : ""), eX * vid_conwidth + eY * 0.025 * vid_conheight, '1 1 1', 1, DRAWFLAG_NORMAL); + } + else if(getstatf(STAT_REVIVE_PROGRESS)) + { + DrawCircleClippedPic(eX * 0.5 * vid_conwidth + eY * 0.6 * vid_conheight, 0.1 * vid_conheight, "gfx/crosshair_ring.tga", getstatf(STAT_REVIVE_PROGRESS), '0.25 0.90 1', autocvar_hud_colorflash_alpha, DRAWFLAG_ADDITIVE); + drawstring_aspect(eY * 0.64 * vid_conheight, _("Revival progress"), eX * vid_conwidth + eY * 0.025 * vid_conheight, '1 1 1', 1, DRAWFLAG_NORMAL); + } + + if(autocvar_r_letterbox == 0) + if(autocvar_viewsize < 120) + CSQC_common_hud(); + + // crosshair goes VERY LAST + UpdateDamage(); + HUD_Crosshair(); + HUD_Crosshair_Vehicle(); + HitSound(); +} + bool ov_enabled; float oldr_nearclip; float oldr_farclip_base; @@ -1810,9 +1843,7 @@ void CSQC_UpdateView(float w, float h) scoreboard_active = HUD_WouldDrawScoreboard(); - UpdateDamage(); - UpdateCrosshair(); - UpdateHitsound(); + HUD_Draw(); if(NextFrameCommand) { @@ -1856,14 +1887,6 @@ void CSQC_UpdateView(float w, float h) else HUD_Radar_Mouse(); - if(hud && !intermission) - if(hud == HUD_BUMBLEBEE_GUN) - CSQC_BUMBLE_GUN_HUD(); - else { - Vehicle info = get_vehicleinfo(hud); - info.vr_hud(info); - } - cl_notice_run(); // let's reset the view back to normal for the end @@ -1871,13 +1894,13 @@ void CSQC_UpdateView(float w, float h) setproperty(VF_SIZE, '1 0 0' * w + '0 1 0' * h); } - void CSQC_common_hud(void) { if(!(gametype == MAPINFO_TYPE_RACE || gametype == MAPINFO_TYPE_CTS)) Accuracy_LoadLevels(); HUD_Main(); // always run these functions for alpha checks + HUD_Vehicle(); HUD_DrawScoreboard(); // scoreboard/accuracy, map/gametype voting screen diff --git a/qcsrc/common/vehicles/cl_vehicles.qc b/qcsrc/common/vehicles/cl_vehicles.qc index 3472a7f1c..07a3cc9fd 100644 --- a/qcsrc/common/vehicles/cl_vehicles.qc +++ b/qcsrc/common/vehicles/cl_vehicles.qc @@ -119,12 +119,9 @@ void Vehicles_drawHUD( string iconAmmo1, vector colorAmmo1, string iconAmmo2, - vector colorAmmo2, - string crosshair) -{SELFPARAM(); - if(autocvar_r_letterbox) - return; - + vector colorAmmo2) +{ + SELFPARAM(); if(scoreboard_showscores) return; @@ -314,6 +311,13 @@ void Vehicles_drawHUD( drawstring(tmpPos, _("No left gunner!"), tmpSize, '1 1 1', hudAlpha * blinkValue, DRAWFLAG_NORMAL); } } +} + +void Vehicles_drawCrosshair(string crosshair) +{ + SELFPARAM(); + vector tmpSize = '0 0 0'; + vector tmpPos = '0 0 0'; // Raptor bomb crosshair if(hud == VEH_RAPTOR.vehicleid && weapon2mode != RSM_FLARE) @@ -327,6 +331,7 @@ void Vehicles_drawHUD( dropmark.gravity = 1; } + float reload2 = getstati(STAT_VEHICLESTAT_RELOAD2) * 0.01; if(reload2 == 1) { setorigin(dropmark, pmove_org); diff --git a/qcsrc/common/vehicles/vehicle.qh b/qcsrc/common/vehicles/vehicle.qh index 80787b4ae..58a2b7330 100644 --- a/qcsrc/common/vehicles/vehicle.qh +++ b/qcsrc/common/vehicles/vehicle.qh @@ -48,6 +48,8 @@ CLASS(Vehicle, Object) METHOD(Vehicle, vr_impact, void(Vehicle)) { } /** (CLIENT) logic to run every frame */ METHOD(Vehicle, vr_hud, void(Vehicle)) { } + /** (CLIENT) logic to run every frame */ + METHOD(Vehicle, vr_crosshair, void(Vehicle)) { } ENDCLASS(Vehicle) // vehicle spawn flags (need them here for common registrations) diff --git a/qcsrc/common/vehicles/vehicle/bumblebee.qc b/qcsrc/common/vehicles/vehicle/bumblebee.qc index b64ac0203..7f5bfea3a 100644 --- a/qcsrc/common/vehicles/vehicle/bumblebee.qc +++ b/qcsrc/common/vehicles/vehicle/bumblebee.qc @@ -953,16 +953,18 @@ void CSQC_BUMBLE_GUN_HUD() { Vehicles_drawHUD("vehicle_gunner", "vehicle_gunner_weapon1", string_null, "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color, - string_null, '0 0 0', - string_null); + string_null, '0 0 0'); } METHOD(Bumblebee, vr_hud, void(Bumblebee thisveh)) { Vehicles_drawHUD(VEH_BUMBLEBEE.m_icon, "vehicle_bumble_weapon1", "vehicle_bumble_weapon2", "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color, - "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color, - vCROSS_HEAL); + "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color); + } + METHOD(Bumblebee, vr_crosshair, void(Bumblebee thisveh)) + { + Vehicles_drawCrosshair(vCROSS_HEAL); } METHOD(Bumblebee, vr_setup, void(Bumblebee thisveh)) { diff --git a/qcsrc/common/vehicles/vehicle/racer.qc b/qcsrc/common/vehicles/vehicle/racer.qc index 2b5950a25..38c6844d4 100644 --- a/qcsrc/common/vehicles/vehicle/racer.qc +++ b/qcsrc/common/vehicles/vehicle/racer.qc @@ -655,8 +655,11 @@ void racer_draw() { Vehicles_drawHUD(VEH_RACER.m_icon, "vehicle_racer_weapon1", "vehicle_racer_weapon2", "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color, - "vehicle_icon_ammo2", autocvar_hud_progressbar_vehicles_ammo2_color, - vCROSS_GUIDE); + "vehicle_icon_ammo2", autocvar_hud_progressbar_vehicles_ammo2_color); + } + METHOD(Racer, vr_crosshair, void(Racer thisveh)) + { + Vehicles_drawCrosshair(vCROSS_GUIDE); } #endif METHOD(Racer, vr_setup, void(Racer thisveh)) diff --git a/qcsrc/common/vehicles/vehicle/raptor.qc b/qcsrc/common/vehicles/vehicle/raptor.qc index 1f623379e..b170dd557 100644 --- a/qcsrc/common/vehicles/vehicle/raptor.qc +++ b/qcsrc/common/vehicles/vehicle/raptor.qc @@ -773,6 +773,12 @@ spawnfunc(vehicle_raptor) #ifdef CSQC METHOD(Raptor, vr_hud, void(Raptor thisveh)) + { + Vehicles_drawHUD(VEH_RAPTOR.m_icon, "vehicle_raptor_weapon1", "vehicle_raptor_weapon2", + "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color, + "vehicle_icon_ammo2", autocvar_hud_progressbar_vehicles_ammo2_color); + } + METHOD(Raptor, vr_crosshair, void(Raptor thisveh)) { string crosshair; @@ -783,10 +789,7 @@ spawnfunc(vehicle_raptor) default: crosshair = vCROSS_BURST; } - Vehicles_drawHUD(VEH_RAPTOR.m_icon, "vehicle_raptor_weapon1", "vehicle_raptor_weapon2", - "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color, - "vehicle_icon_ammo2", autocvar_hud_progressbar_vehicles_ammo2_color, - crosshair); + Vehicles_drawCrosshair(crosshair); } METHOD(Raptor, vr_setup, void(Raptor thisveh)) { diff --git a/qcsrc/common/vehicles/vehicle/spiderbot.qc b/qcsrc/common/vehicles/vehicle/spiderbot.qc index ee79966ef..7971cfb79 100644 --- a/qcsrc/common/vehicles/vehicle/spiderbot.qc +++ b/qcsrc/common/vehicles/vehicle/spiderbot.qc @@ -645,6 +645,12 @@ float autocvar_cl_vehicle_spiderbot_cross_alpha = 0.6; float autocvar_cl_vehicle_spiderbot_cross_size = 1; METHOD(Spiderbot, vr_hud, void(Spiderbot thisveh)) + { + Vehicles_drawHUD(VEH_SPIDERBOT.m_icon, "vehicle_spider_weapon1", "vehicle_spider_weapon2", + "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color, + "vehicle_icon_ammo2", autocvar_hud_progressbar_vehicles_ammo2_color); + } + METHOD(Spiderbot, vr_crosshair, void(Spiderbot thisveh)) { string crosshair; @@ -656,10 +662,7 @@ float autocvar_cl_vehicle_spiderbot_cross_size = 1; default: crosshair = vCROSS_BURST; } - Vehicles_drawHUD(VEH_SPIDERBOT.m_icon, "vehicle_spider_weapon1", "vehicle_spider_weapon2", - "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color, - "vehicle_icon_ammo2", autocvar_hud_progressbar_vehicles_ammo2_color, - crosshair); + Vehicles_drawCrosshair(crosshair); } METHOD(Spiderbot, vr_setup, void(Spiderbot thisveh)) {