From f8fd182f4c9d44790436a2e1aff424c1bdeeb6da Mon Sep 17 00:00:00 2001 From: terencehill Date: Sat, 30 Jul 2016 16:23:31 +0200 Subject: [PATCH] Make the scoreboard a panel --- _hud_common.cfg | 1 + _hud_descriptions.cfg | 9 +++ defaultXonotic.cfg | 3 - hud_luma.cfg | 9 +++ hud_luminos.cfg | 9 +++ hud_luminos_minimal.cfg | 9 +++ hud_luminos_minimal_xhair.cfg | 9 +++ hud_luminos_old.cfg | 9 +++ hud_nexuiz.cfg | 9 +++ qcsrc/client/autocvars.qh | 3 - qcsrc/client/hud/hud.qc | 27 +++++-- qcsrc/client/hud/hud.qh | 1 + qcsrc/client/hud/panel/centerprint.qc | 17 ++--- qcsrc/client/scoreboard.qc | 100 ++++++++++++++++---------- qcsrc/client/view.qc | 1 - 15 files changed, 155 insertions(+), 61 deletions(-) diff --git a/_hud_common.cfg b/_hud_common.cfg index 7bf9111cd..bc82ac12f 100644 --- a/_hud_common.cfg +++ b/_hud_common.cfg @@ -44,6 +44,7 @@ seta hud_panel_centerprint 1 "enable this panel" //seta hud_panel_mapvote 1 "enable this panel" seta hud_panel_itemstime 2 "enable this panel, 1 = show when spectating, 2 = even playing in warmup stage" //seta hud_panel_quickmenu 1 "enable this panel" +//seta hud_panel_scoreboard 1 "enable this panel" seta hud_panel_weapons_dynamichud 1 "apply the dynamic hud effects to this panel" seta hud_panel_ammo_dynamichud 1 "apply the dynamic hud effects to this panel" diff --git a/_hud_descriptions.cfg b/_hud_descriptions.cfg index ee4689890..c829a22d9 100644 --- a/_hud_descriptions.cfg +++ b/_hud_descriptions.cfg @@ -355,3 +355,12 @@ seta hud_panel_quickmenu_bg_alpha "" "if set to something else than \"\" = overr seta hud_panel_quickmenu_bg_border "" "if set to something else than \"\" = override default size of border around the background" seta hud_panel_quickmenu_bg_padding "" "if set to something else than \"\" = override default padding of contents from border" seta hud_panel_quickmenu_align "" "text alignment: 0 left, 0.5 center, 1 right" + +seta hud_panel_scoreboard_pos "" "position of this base of the panel" +seta hud_panel_scoreboard_size "" "size of this panel" +seta hud_panel_scoreboard_bg "" "if set to something else than \"\" = override default background" +seta hud_panel_scoreboard_bg_color "" "if set to something else than \"\" = override default panel background color" +seta hud_panel_scoreboard_bg_color_team "" "override panel color with team color in team based games" +seta hud_panel_scoreboard_bg_alpha "" "if set to something else than \"\" = override default panel background alpha" +seta hud_panel_scoreboard_bg_border "" "if set to something else than \"\" = override default size of border around the background" +seta hud_panel_scoreboard_bg_padding "" "if set to something else than \"\" = override default padding of contents from border" diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index 11ba8e4ff..38fcb477c 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -850,9 +850,6 @@ seta scoreboard_fadeoutspeed 5 "speed at which scoreboard fades out, higher is f seta scoreboard_highlight 1 "enable highlighting for rows and columns in the scoreboard" seta scoreboard_highlight_alpha 0.08 "highlight alpha value (depends on hud_scoreboard_highlight 1)" seta scoreboard_highlight_alpha_self 0.3 "self highlight alpha value" -seta scoreboard_offset_left 0.15 "how far (by percent) the scoreboard is offset from the left screen edge" -seta scoreboard_offset_right 0.15 "how far (by percent) the scoreboard is offset from the right screen edge" -seta scoreboard_offset_vertical 0.05 "how far (by percent) the scoreboard is offset from the top and bottom of the screen" seta scoreboard_bg_scale 0.25 "scale for the tiled scoreboard background" seta scoreboard_respawntime_decimals 1 "decimal places to show for the respawntime countdown display on the scoreboard" seta scoreboard_dynamichud 0 "apply the dynamic hud effects to the scoreboard" diff --git a/hud_luma.cfg b/hud_luma.cfg index 2f4f31e92..95005af0b 100644 --- a/hud_luma.cfg +++ b/hud_luma.cfg @@ -357,4 +357,13 @@ seta hud_panel_quickmenu_bg_border "" seta hud_panel_quickmenu_bg_padding "" seta hud_panel_quickmenu_align "0" +seta hud_panel_scoreboard_pos "0.150000 0.150000" +seta hud_panel_scoreboard_size "0.700000 0.700000" +seta hud_panel_scoreboard_bg "0" +seta hud_panel_scoreboard_bg_color "" +seta hud_panel_scoreboard_bg_color_team "" +seta hud_panel_scoreboard_bg_alpha "" +seta hud_panel_scoreboard_bg_border "" +seta hud_panel_scoreboard_bg_padding "" + menu_sync diff --git a/hud_luminos.cfg b/hud_luminos.cfg index 3d259ebf3..e41d6e207 100644 --- a/hud_luminos.cfg +++ b/hud_luminos.cfg @@ -357,4 +357,13 @@ seta hud_panel_quickmenu_bg_border "" seta hud_panel_quickmenu_bg_padding "" seta hud_panel_quickmenu_align "0" +seta hud_panel_scoreboard_pos "0.150000 0.150000" +seta hud_panel_scoreboard_size "0.700000 0.700000" +seta hud_panel_scoreboard_bg "0" +seta hud_panel_scoreboard_bg_color "" +seta hud_panel_scoreboard_bg_color_team "" +seta hud_panel_scoreboard_bg_alpha "" +seta hud_panel_scoreboard_bg_border "" +seta hud_panel_scoreboard_bg_padding "" + menu_sync diff --git a/hud_luminos_minimal.cfg b/hud_luminos_minimal.cfg index c1ac51b7a..372c37297 100644 --- a/hud_luminos_minimal.cfg +++ b/hud_luminos_minimal.cfg @@ -357,4 +357,13 @@ seta hud_panel_quickmenu_bg_border "" seta hud_panel_quickmenu_bg_padding "" seta hud_panel_quickmenu_align "0" +seta hud_panel_scoreboard_pos "0.150000 0.150000" +seta hud_panel_scoreboard_size "0.700000 0.700000" +seta hud_panel_scoreboard_bg "0" +seta hud_panel_scoreboard_bg_color "" +seta hud_panel_scoreboard_bg_color_team "" +seta hud_panel_scoreboard_bg_alpha "" +seta hud_panel_scoreboard_bg_border "" +seta hud_panel_scoreboard_bg_padding "" + menu_sync diff --git a/hud_luminos_minimal_xhair.cfg b/hud_luminos_minimal_xhair.cfg index d6125985b..53d1a9b9c 100644 --- a/hud_luminos_minimal_xhair.cfg +++ b/hud_luminos_minimal_xhair.cfg @@ -357,4 +357,13 @@ seta hud_panel_quickmenu_bg_border "" seta hud_panel_quickmenu_bg_padding "" seta hud_panel_quickmenu_align "0" +seta hud_panel_scoreboard_pos "0.150000 0.150000" +seta hud_panel_scoreboard_size "0.700000 0.700000" +seta hud_panel_scoreboard_bg "0" +seta hud_panel_scoreboard_bg_color "" +seta hud_panel_scoreboard_bg_color_team "" +seta hud_panel_scoreboard_bg_alpha "" +seta hud_panel_scoreboard_bg_border "" +seta hud_panel_scoreboard_bg_padding "" + menu_sync diff --git a/hud_luminos_old.cfg b/hud_luminos_old.cfg index 4ee800521..e4fe3675f 100644 --- a/hud_luminos_old.cfg +++ b/hud_luminos_old.cfg @@ -357,4 +357,13 @@ seta hud_panel_quickmenu_bg_border "" seta hud_panel_quickmenu_bg_padding "" seta hud_panel_quickmenu_align "1" +seta hud_panel_scoreboard_pos "0.150000 0.150000" +seta hud_panel_scoreboard_size "0.700000 0.700000" +seta hud_panel_scoreboard_bg "0" +seta hud_panel_scoreboard_bg_color "" +seta hud_panel_scoreboard_bg_color_team "" +seta hud_panel_scoreboard_bg_alpha "" +seta hud_panel_scoreboard_bg_border "" +seta hud_panel_scoreboard_bg_padding "" + menu_sync diff --git a/hud_nexuiz.cfg b/hud_nexuiz.cfg index df565ef68..d6f7741c0 100644 --- a/hud_nexuiz.cfg +++ b/hud_nexuiz.cfg @@ -357,4 +357,13 @@ seta hud_panel_quickmenu_bg_border "" seta hud_panel_quickmenu_bg_padding "" seta hud_panel_quickmenu_align "0" +seta hud_panel_scoreboard_pos "0.150000 0.150000" +seta hud_panel_scoreboard_size "0.700000 0.700000" +seta hud_panel_scoreboard_bg "0" +seta hud_panel_scoreboard_bg_color "" +seta hud_panel_scoreboard_bg_color_team "" +seta hud_panel_scoreboard_bg_alpha "" +seta hud_panel_scoreboard_bg_border "" +seta hud_panel_scoreboard_bg_padding "" + menu_sync diff --git a/qcsrc/client/autocvars.qh b/qcsrc/client/autocvars.qh index d159cd317..7edf9970e 100644 --- a/qcsrc/client/autocvars.qh +++ b/qcsrc/client/autocvars.qh @@ -414,9 +414,6 @@ float autocvar_scoreboard_fadeoutspeed = 5; bool autocvar_scoreboard_highlight; float autocvar_scoreboard_highlight_alpha = 0.10; float autocvar_scoreboard_highlight_alpha_self = 0.25; -float autocvar_scoreboard_offset_left; -float autocvar_scoreboard_offset_right; -float autocvar_scoreboard_offset_vertical; float autocvar_scoreboard_respawntime_decimals; bool autocvar_scoreboard_dynamichud = false; bool autocvar_v_flipped; diff --git a/qcsrc/client/hud/hud.qc b/qcsrc/client/hud/hud.qc index d575e8cb5..62f5dcb6d 100644 --- a/qcsrc/client/hud/hud.qc +++ b/qcsrc/client/hud/hud.qc @@ -490,17 +490,24 @@ void Hud_Dynamic_Frame() hud_shift_current = hud_shift; } +// Scoreboard panel +// +void HUD_DrawScoreboard(); +void HUD_Scoreboard(void) +{ + HUD_DrawScoreboard(); +} + void HUD_Main() { int i; - // global hud alpha fade + // global hud alpha fade (scoreboard-related panels behave differently and override it temporarly) if(menu_enabled == 1) hud_fade_alpha = 1; + else if(!autocvar__hud_configure) + hud_fade_alpha = (1 - scoreboard_fade_alpha) * (1 - autocvar__menu_alpha); else - hud_fade_alpha = (1 - autocvar__menu_alpha); - - if(scoreboard_fade_alpha) - hud_fade_alpha = (1 - scoreboard_fade_alpha); + hud_fade_alpha = 1 - autocvar__menu_alpha; HUD_Configure_Frame(); @@ -510,8 +517,14 @@ void HUD_Main() // they must fade only when the menu does if(scoreboard_fade_alpha == 1) { - HUD_Panel_Draw(HUD_PANEL(CENTERPRINT)); - return; + if(autocvar__menu_alpha == 1) + return; + if(scoreboard_fade_alpha == 1) + { + HUD_Panel_Draw(HUD_PANEL(SCOREBOARD)); + HUD_Panel_Draw(HUD_PANEL(CENTERPRINT)); + return; + } } if(!autocvar__hud_configure && !hud_fade_alpha) diff --git a/qcsrc/client/hud/hud.qh b/qcsrc/client/hud/hud.qh index 2a5344466..75b7f9ffc 100644 --- a/qcsrc/client/hud/hud.qh +++ b/qcsrc/client/hud/hud.qh @@ -235,6 +235,7 @@ REGISTER_HUD_PANEL(MINIGAME_MENU, HUD_MinigameMenu, minigamemenu, PANEL_CO REGISTER_HUD_PANEL(MAPVOTE, MapVote_Draw, mapvote, PANEL_CONFIG_NO , PANEL_SHOW_MAPVOTE ) REGISTER_HUD_PANEL(ITEMSTIME, HUD_ItemsTime, itemstime, PANEL_CONFIG_MAIN, PANEL_SHOW_MAINGAME) REGISTER_HUD_PANEL(QUICKMENU, HUD_QuickMenu, quickmenu, PANEL_CONFIG_MAIN, PANEL_SHOW_MAINGAME) +REGISTER_HUD_PANEL(SCOREBOARD, HUD_Scoreboard, scoreboard, PANEL_CONFIG_NO , PANEL_SHOW_ALWAYS ) // always add new panels to the end of list // Because calling lots of functions in QC apparently cuts fps in half on many machines: diff --git a/qcsrc/client/hud/panel/centerprint.qc b/qcsrc/client/hud/panel/centerprint.qc index e2e82acff..7dfaa909e 100644 --- a/qcsrc/client/hud/panel/centerprint.qc +++ b/qcsrc/client/hud/panel/centerprint.qc @@ -155,13 +155,14 @@ void HUD_CenterPrint () } // this panel fades only when the menu does - float hud_fade_alpha_save = 0; - if(scoreboard_fade_alpha) - { - hud_fade_alpha_save = hud_fade_alpha; + float hud_fade_alpha_save = hud_fade_alpha; + if(menu_enabled == 1) + hud_fade_alpha = 1; + else hud_fade_alpha = 1 - autocvar__menu_alpha; - } + HUD_Panel_UpdateCvars(); + hud_fade_alpha = hud_fade_alpha_save; if ( HUD_Radar_Clickable() ) { @@ -171,17 +172,13 @@ void HUD_CenterPrint () panel_pos = eY * hud_panel_radar_bottom + eX * 0.5 * (vid_conwidth - panel_size_x); panel_size_y = min(panel_size_y, vid_conheight - hud_panel_radar_bottom); } - else if(scoreboard_fade_alpha) + else if(!autocvar__hud_configure && scoreboard_fade_alpha) { - hud_fade_alpha = hud_fade_alpha_save; - // move the panel below the scoreboard if (scoreboard_bottom >= 0.96 * vid_conheight) return; vector target_pos; - target_pos = eY * scoreboard_bottom + eX * 0.5 * (vid_conwidth - panel_size.x); - if(target_pos.y > panel_pos.y) { panel_pos = panel_pos + (target_pos - panel_pos) * sqrt(scoreboard_fade_alpha); diff --git a/qcsrc/client/scoreboard.qc b/qcsrc/client/scoreboard.qc index b86e0d8f6..cc605d630 100644 --- a/qcsrc/client/scoreboard.qc +++ b/qcsrc/client/scoreboard.qc @@ -989,9 +989,7 @@ vector HUD_Scoreboard_MakeTable(vector pos, entity tm, vector rgb, vector bg_siz } float HUD_WouldDrawScoreboard() { - if (autocvar__hud_configure) - return 0; - else if (QuickMenu_IsOpened()) + if (QuickMenu_IsOpened()) return 0; else if (HUD_Radar_Clickable()) return 0; @@ -1255,57 +1253,85 @@ float hud_woulddrawscoreboard_prev; float hud_woulddrawscoreboard_change; // "time" at which HUD_WouldDrawScoreboard() changed void HUD_DrawScoreboard() { - float hud_woulddrawscoreboard; - hud_woulddrawscoreboard = scoreboard_active; - if(hud_woulddrawscoreboard != hud_woulddrawscoreboard_prev) { - hud_woulddrawscoreboard_change = time; - hud_woulddrawscoreboard_prev = hud_woulddrawscoreboard; - } + if(!autocvar__hud_configure) + { + float hud_woulddrawscoreboard; + hud_woulddrawscoreboard = scoreboard_active; + if(hud_woulddrawscoreboard != hud_woulddrawscoreboard_prev) { + hud_woulddrawscoreboard_change = time; + hud_woulddrawscoreboard_prev = hud_woulddrawscoreboard; + } + + if(hud_woulddrawscoreboard) { + if(menu_enabled == 1) + scoreboard_fade_alpha = 1; + float scoreboard_fadeinspeed = autocvar_scoreboard_fadeinspeed; + if (scoreboard_fadeinspeed) + scoreboard_fade_alpha = bound (0, (time - hud_woulddrawscoreboard_change) * scoreboard_fadeinspeed, 1); + else + scoreboard_fade_alpha = 1; + } + else { + float scoreboard_fadeoutspeed = autocvar_scoreboard_fadeoutspeed; + if (scoreboard_fadeoutspeed) + scoreboard_fade_alpha = bound (0, (1/scoreboard_fadeoutspeed - (time - hud_woulddrawscoreboard_change)) * scoreboard_fadeoutspeed, 1); + else + scoreboard_fade_alpha = 0; + } - if(hud_woulddrawscoreboard) { - float scoreboard_fadeinspeed = autocvar_scoreboard_fadeinspeed; - if (scoreboard_fadeinspeed) - scoreboard_fade_alpha = bound (0, (time - hud_woulddrawscoreboard_change) * scoreboard_fadeinspeed, 1); - else - scoreboard_fade_alpha = 1; + if (!scoreboard_fade_alpha) + return; } - else { - float scoreboard_fadeoutspeed = autocvar_scoreboard_fadeoutspeed; - if (scoreboard_fadeoutspeed) - scoreboard_fade_alpha = bound (0, (1/scoreboard_fadeoutspeed - (time - hud_woulddrawscoreboard_change)) * scoreboard_fadeoutspeed, 1); - else - scoreboard_fade_alpha = 0; - } - - if (!scoreboard_fade_alpha) - return; + else + scoreboard_fade_alpha = 0; if (autocvar_scoreboard_dynamichud) HUD_Scale_Enable(); else HUD_Scale_Disable(); - HUD_UpdatePlayerTeams(); + float hud_fade_alpha_save = hud_fade_alpha; + if(menu_enabled == 1) + hud_fade_alpha = 1; + else + hud_fade_alpha = scoreboard_fade_alpha * (1 - autocvar__menu_alpha); + HUD_Panel_UpdateCvars(); - scoreboard_alpha_bg = autocvar_scoreboard_alpha_bg * scoreboard_fade_alpha * (1 - autocvar__menu_alpha); - scoreboard_alpha_fg = autocvar_scoreboard_alpha_fg * scoreboard_fade_alpha * (1 - autocvar__menu_alpha); + scoreboard_alpha_bg = autocvar_scoreboard_alpha_bg * panel_fg_alpha; + scoreboard_alpha_fg = autocvar_scoreboard_alpha_fg * panel_fg_alpha; scoreboard_highlight = autocvar_scoreboard_highlight; - scoreboard_highlight_alpha = autocvar_scoreboard_highlight_alpha * scoreboard_alpha_fg; - scoreboard_highlight_alpha_self = autocvar_scoreboard_highlight_alpha_self * scoreboard_alpha_fg; - scoreboard_alpha_name = autocvar_scoreboard_alpha_name * scoreboard_alpha_fg; - scoreboard_alpha_name_self = autocvar_scoreboard_alpha_name_self * scoreboard_alpha_fg; + scoreboard_highlight_alpha = autocvar_scoreboard_highlight_alpha * panel_fg_alpha; + scoreboard_highlight_alpha_self = autocvar_scoreboard_highlight_alpha_self * panel_fg_alpha; + scoreboard_alpha_name = autocvar_scoreboard_alpha_name * panel_fg_alpha; + scoreboard_alpha_name_self = autocvar_scoreboard_alpha_name_self * panel_fg_alpha; + + hud_fade_alpha = hud_fade_alpha_save; + + // don't overlap with con_notify + if(!autocvar__hud_configure) + panel_pos_y = max((autocvar_con_notify * autocvar_con_notifysize), panel_pos_y); + + HUD_Panel_DrawBg(scoreboard_fade_alpha); + + if(panel_bg_padding) + { + panel_pos += '1 1 0' * panel_bg_padding; + panel_size -= '2 2 0' * panel_bg_padding; + } + + HUD_UpdatePlayerTeams(); vector rgb, pos, tmp; entity pl, tm; string str; - xmin = (autocvar_scoreboard_offset_left * vid_conwidth); - ymin = max((autocvar_con_notify * autocvar_con_notifysize), (autocvar_scoreboard_offset_vertical * vid_conwidth)); + xmin = panel_pos_x; + ymin = panel_pos_y; - xmax = ((1 - autocvar_scoreboard_offset_right) * vid_conwidth); - ymax = (vid_conheight - ymin); + xmax = panel_pos_x + panel_size_x; + ymax = panel_pos_y + panel_size_y; - sbwidth = xmax - xmin; + sbwidth = panel_size_x; // Initializes position pos.x = xmin; diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index 1458efe15..47cf9337d 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -1350,7 +1350,6 @@ void HUD_Draw(entity this) Accuracy_LoadLevels(); HUD_Main(); - HUD_DrawScoreboard(); HUD_Scale_Disable(); } -- 2.39.2