From 1e505f722046be5a3a0242267b951ca2abee81f6 Mon Sep 17 00:00:00 2001 From: Juhu <5894800-Juhu_@users.noreply.gitlab.com> Date: Wed, 31 Mar 2021 14:00:25 +0200 Subject: [PATCH] Add patch from Juhu/compass branch: "Add compass panel, somewhat a CGaz compass clone" --- _hud_common.cfg | 15 ++ _hud_descriptions.cfg | 9 + 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/hud/hud.qh | 1 + qcsrc/client/hud/panel/_mod.inc | 1 + qcsrc/client/hud/panel/_mod.qh | 1 + qcsrc/client/hud/panel/compass.qc | 158 ++++++++++++++++++ qcsrc/client/hud/panel/compass.qh | 19 +++ qcsrc/client/mutators/events.qh | 3 + qcsrc/common/gamemodes/gamemode/cts/cl_cts.qc | 5 + .../common/gamemodes/gamemode/race/cl_race.qc | 5 + qcsrc/menu/xonotic/_mod.inc | 1 + qcsrc/menu/xonotic/_mod.qh | 1 + qcsrc/menu/xonotic/dialog_hudpanel_compass.qc | 107 ++++++++++++ qcsrc/menu/xonotic/dialog_hudpanel_compass.qh | 13 ++ qcsrc/menu/xonotic/mainwindow.qc | 5 + 21 files changed, 398 insertions(+) create mode 100644 qcsrc/client/hud/panel/compass.qc create mode 100644 qcsrc/client/hud/panel/compass.qh create mode 100644 qcsrc/menu/xonotic/dialog_hudpanel_compass.qc create mode 100644 qcsrc/menu/xonotic/dialog_hudpanel_compass.qh diff --git a/_hud_common.cfg b/_hud_common.cfg index ca6e7fb02..0cfb19c9c 100644 --- a/_hud_common.cfg +++ b/_hud_common.cfg @@ -49,6 +49,7 @@ seta hud_panel_scoreboard_accuracy 1 "show weapon accuracy stats panel in the sc seta hud_panel_scoreboard_ctf_leaderboard 1 "show a capture time rankings leaderboard in the scoreboard if allowed by the server" seta hud_panel_scoreboard_itemstats 1 "show item stats panel in the scoreboard" seta hud_panel_strafehud 3 "enable this panel, 1 = show if not observing, 2 = show always, 3 = show only in race/cts if not observing" +seta hud_panel_compass 0 "enable this panel, 1 = show if not observing, 2 = show always, 3 = show only in race/cts if not observing" 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" @@ -69,6 +70,7 @@ seta hud_panel_centerprint_dynamichud 1 "apply the dynamic hud effects to t seta hud_panel_itemstime_dynamichud 1 "apply the dynamic hud effects to this panel" seta hud_panel_scoreboard_dynamichud 0 "apply the dynamic hud effects to this panel" seta hud_panel_strafehud_dynamichud 1 "apply the dynamic hud effects to this panel" +seta hud_panel_compass_dynamichud 1 "apply the dynamic hud effects to this panel" seta hud_panel_weapons_ammo_full_shells 60 "show 100% of the status bar at this ammo count" seta hud_panel_weapons_ammo_full_nails 320 "show 100% of the status bar at this ammo count" @@ -187,6 +189,19 @@ seta hud_panel_strafehud_timeout_turn "0.1" "time (in seconds) after releasing t seta hud_panel_strafehud_antiflicker_angle "0.01" "how many degrees from 0° to 180° the hud ignores if it could cause visual disturbances otherwise (and to counter rounding errors)" seta hud_panel_strafehud_antiflicker_speed "0.0001" "how many qu/s the hud ignores if it could cause visual disturbances otherwise (and to counter rounding errors)" +seta hud_panel_compass_north_color "1 0.5 0" "color of the north compass quarter" +seta hud_panel_compass_east_color "0.25 0.75 0" "color of the east compass quarter" +seta hud_panel_compass_south_color "0.75 0.25 1" "color of the south compass quarter" +seta hud_panel_compass_west_color "0.25 1 0.75" "color of the west compass quarter" +seta hud_panel_compass_quarter_alpha "0.8" "opacity of the compass quarters" +seta hud_panel_compass_arrow_color "1 1 1" "color of the velocity direction arrow" +seta hud_panel_compass_arrow_snap_color "1 0 0" "color of the arrow if the velocity direction snaps to a 90° angle" +seta hud_panel_compass_arrow_alpha "1" "opacity of the velocity arrow" +seta hud_panel_compass_arrow_size "0.5" "size of the velocity arrow relative to the panel height" +seta hud_panel_compass_line_color "1 1 1" "color of the orienting lines" +seta hud_panel_compass_line_alpha "1" "opacity of the orienting lines" +seta hud_panel_compass_line_size "0.2" "size of the orienting lines relative to the panel height" + // hud panel aliases alias quickmenu "cl_cmd hud quickmenu ${* ?}" diff --git a/_hud_descriptions.cfg b/_hud_descriptions.cfg index 02d2d5a0f..a4a6cd8ba 100644 --- a/_hud_descriptions.cfg +++ b/_hud_descriptions.cfg @@ -389,3 +389,12 @@ seta hud_panel_strafehud_bg_color_team "" "override panel color with team color seta hud_panel_strafehud_bg_alpha "" "if set to something else than \"\" = override default panel background alpha" seta hud_panel_strafehud_bg_border "" "if set to something else than \"\" = override default size of border around the background" seta hud_panel_strafehud_bg_padding "" "if set to something else than \"\" = override default padding of contents from border" + +seta hud_panel_compass_pos "" "position of this base of the panel" +seta hud_panel_compass_size "" "size of this panel" +seta hud_panel_compass_bg "" "if set to something else than \"\" = override default background" +seta hud_panel_compass_bg_color "" "if set to something else than \"\" = override default panel background color" +seta hud_panel_compass_bg_color_team "" "override panel color with team color in team based games" +seta hud_panel_compass_bg_alpha "" "if set to something else than \"\" = override default panel background alpha" +seta hud_panel_compass_bg_border "" "if set to something else than \"\" = override default size of border around the background" +seta hud_panel_compass_bg_padding "" "if set to something else than \"\" = override default padding of contents from border" diff --git a/hud_luma.cfg b/hud_luma.cfg index 9ad2425a7..2186ced22 100644 --- a/hud_luma.cfg +++ b/hud_luma.cfg @@ -391,4 +391,13 @@ seta hud_panel_strafehud_bg_alpha "0.7" seta hud_panel_strafehud_bg_border "" seta hud_panel_strafehud_bg_padding "" +seta hud_panel_compass_pos "0.290000 0.530000" +seta hud_panel_compass_size "0.420000 0.030000" +seta hud_panel_compass_bg "0" +seta hud_panel_compass_bg_color "" +seta hud_panel_compass_bg_color_team "" +seta hud_panel_compass_bg_alpha "0.7" +seta hud_panel_compass_bg_border "" +seta hud_panel_compass_bg_padding "" + menu_sync diff --git a/hud_luminos.cfg b/hud_luminos.cfg index c642ac38f..328cc5069 100644 --- a/hud_luminos.cfg +++ b/hud_luminos.cfg @@ -391,4 +391,13 @@ seta hud_panel_strafehud_bg_alpha "" seta hud_panel_strafehud_bg_border "" seta hud_panel_strafehud_bg_padding "" +seta hud_panel_compass_pos "0.300000 0.530000" +seta hud_panel_compass_size "0.400000 0.030000" +seta hud_panel_compass_bg "" +seta hud_panel_compass_bg_color "" +seta hud_panel_compass_bg_color_team "" +seta hud_panel_compass_bg_alpha "" +seta hud_panel_compass_bg_border "" +seta hud_panel_compass_bg_padding "" + menu_sync diff --git a/hud_luminos_minimal.cfg b/hud_luminos_minimal.cfg index d15dd868a..a170e2c9f 100644 --- a/hud_luminos_minimal.cfg +++ b/hud_luminos_minimal.cfg @@ -391,4 +391,13 @@ seta hud_panel_strafehud_bg_alpha "" seta hud_panel_strafehud_bg_border "" seta hud_panel_strafehud_bg_padding "" +seta hud_panel_compass_pos "0.350000 0.525000" +seta hud_panel_compass_size "0.300000 0.027500" +seta hud_panel_compass_bg "" +seta hud_panel_compass_bg_color "" +seta hud_panel_compass_bg_color_team "" +seta hud_panel_compass_bg_alpha "" +seta hud_panel_compass_bg_border "" +seta hud_panel_compass_bg_padding "" + menu_sync diff --git a/hud_luminos_minimal_xhair.cfg b/hud_luminos_minimal_xhair.cfg index 11c57ee48..a38895c65 100644 --- a/hud_luminos_minimal_xhair.cfg +++ b/hud_luminos_minimal_xhair.cfg @@ -391,4 +391,13 @@ seta hud_panel_strafehud_bg_alpha "" seta hud_panel_strafehud_bg_border "" seta hud_panel_strafehud_bg_padding "" +seta hud_panel_compass_pos "0.300000 0.675000" +seta hud_panel_compass_size "0.400000 0.017500" +seta hud_panel_compass_bg "" +seta hud_panel_compass_bg_color "" +seta hud_panel_compass_bg_color_team "" +seta hud_panel_compass_bg_alpha "" +seta hud_panel_compass_bg_border "" +seta hud_panel_compass_bg_padding "" + menu_sync diff --git a/hud_luminos_old.cfg b/hud_luminos_old.cfg index 42a79015c..675e5bd5b 100644 --- a/hud_luminos_old.cfg +++ b/hud_luminos_old.cfg @@ -391,4 +391,13 @@ seta hud_panel_strafehud_bg_alpha "" seta hud_panel_strafehud_bg_border "" seta hud_panel_strafehud_bg_padding "" +seta hud_panel_compass_pos "0.320000 0.715000" +seta hud_panel_compass_size "0.360000 0.025000" +seta hud_panel_compass_bg "" +seta hud_panel_compass_bg_color "" +seta hud_panel_compass_bg_color_team "" +seta hud_panel_compass_bg_alpha "" +seta hud_panel_compass_bg_border "" +seta hud_panel_compass_bg_padding "" + menu_sync diff --git a/hud_nexuiz.cfg b/hud_nexuiz.cfg index 9200283c3..a12289522 100644 --- a/hud_nexuiz.cfg +++ b/hud_nexuiz.cfg @@ -391,4 +391,13 @@ seta hud_panel_strafehud_bg_alpha "" seta hud_panel_strafehud_bg_border "" seta hud_panel_strafehud_bg_padding "" +seta hud_panel_compass_pos "0.330000 0.530000" +seta hud_panel_compass_size "0.340000 0.030000" +seta hud_panel_compass_bg "0" +seta hud_panel_compass_bg_color "" +seta hud_panel_compass_bg_color_team "" +seta hud_panel_compass_bg_alpha "" +seta hud_panel_compass_bg_border "" +seta hud_panel_compass_bg_padding "" + menu_sync diff --git a/qcsrc/client/hud/hud.qh b/qcsrc/client/hud/hud.qh index 14e1af0a0..b7c3b488d 100644 --- a/qcsrc/client/hud/hud.qh +++ b/qcsrc/client/hud/hud.qh @@ -274,6 +274,7 @@ REGISTER_HUD_PANEL(ITEMSTIME, HUD_ItemsTime, PANEL_CONFIG_MAIN | PANE REGISTER_HUD_PANEL(QUICKMENU, HUD_QuickMenu, PANEL_CONFIG_MAIN , PANEL_SHOW_MAINGAME | PANEL_SHOW_MINIGAME ) // QUICKMENU REGISTER_HUD_PANEL(SCOREBOARD, Scoreboard_Draw, PANEL_CONFIG_NO , PANEL_SHOW_MAINGAME | PANEL_SHOW_MINIGAME | PANEL_SHOW_MAPVOTE | PANEL_SHOW_WITH_SB) // SCOREBOARD REGISTER_HUD_PANEL(STRAFEHUD, HUD_StrafeHUD, PANEL_CONFIG_MAIN | PANEL_CONFIG_CANBEOFF, PANEL_SHOW_MAINGAME ) // STRAFEHUD +REGISTER_HUD_PANEL(COMPASS, HUD_Compass, PANEL_CONFIG_MAIN | PANEL_CONFIG_CANBEOFF, PANEL_SHOW_MAINGAME ) // COMPASS // 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/_mod.inc b/qcsrc/client/hud/panel/_mod.inc index 68e368ed1..17082e0ad 100644 --- a/qcsrc/client/hud/panel/_mod.inc +++ b/qcsrc/client/hud/panel/_mod.inc @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include diff --git a/qcsrc/client/hud/panel/_mod.qh b/qcsrc/client/hud/panel/_mod.qh index 1b45f0cd0..62e925c75 100644 --- a/qcsrc/client/hud/panel/_mod.qh +++ b/qcsrc/client/hud/panel/_mod.qh @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include diff --git a/qcsrc/client/hud/panel/compass.qc b/qcsrc/client/hud/panel/compass.qc new file mode 100644 index 000000000..14a5ab999 --- /dev/null +++ b/qcsrc/client/hud/panel/compass.qc @@ -0,0 +1,158 @@ +// Author: Juhu + +#include "compass.qh" + +#include +#include +#include + +// Compass (#26) + +void HUD_Compass_Export(int fh) +{ + // allow saving cvars that aesthetically change the panel into hud skin files +} + +// provide basic panel cvars to old clients +// TODO remove them after a future release (0.8.2+) +noref string autocvar_hud_panel_compass_pos = "0.290000 0.530000"; +noref string autocvar_hud_panel_compass_size = "0.420000 0.030000"; +noref string autocvar_hud_panel_compass_bg = "0"; +noref string autocvar_hud_panel_compass_bg_color = ""; +noref string autocvar_hud_panel_compass_bg_color_team = ""; +noref string autocvar_hud_panel_compass_bg_alpha = "0.7"; +noref string autocvar_hud_panel_compass_bg_border = ""; +noref string autocvar_hud_panel_compass_bg_padding = ""; + +void HUD_Compass() +{ + // generic hud routines + if(!autocvar__hud_configure) + { + if(!autocvar_hud_panel_compass || + (spectatee_status == -1 && (autocvar_hud_panel_compass == 1 || autocvar_hud_panel_compass == 3)) || + (autocvar_hud_panel_compass == 3 && !MUTATOR_CALLHOOK(HUD_Compass_showoptional))) return; + } + + HUD_Panel_LoadCvars(); + + if(autocvar_hud_panel_compass_dynamichud) + { + HUD_Scale_Enable(); + } + else + { + HUD_Scale_Disable(); + } + + HUD_Panel_DrawBg(); + + if(panel_bg_padding) + { + panel_pos += '1 1 0' * panel_bg_padding; + panel_size -= '2 2 0' * panel_bg_padding; + } + + // draw compass + if(csqcplayer) + { + // get the world axis + float angle = !autocvar__hud_configure ? PHYS_INPUT_ANGLES(csqcplayer).y : 0; + float move_angle = !autocvar__hud_configure ? vectoangles(csqcplayer.velocity).y : 0; + float speed = !autocvar__hud_configure ? vlen(vec2(csqcplayer.velocity)) : 320; + vector line_size = panel_size; + line_size.x = line_size.y = autocvar_hud_panel_compass_line_size * panel_size.y; + if(angle < 0) + angle += 360; + + // make the compass move opposite to the rotation direction + if(!autocvar_v_flipped) + { + angle = 360 - angle; + move_angle = 360 - move_angle; + } + + // get the size of one quarter of the compass + vector quarter_size = panel_size; + quarter_size.x /= 4; + + // calculate how much the compass quarters differ from their 90° alignment + float alignment_offset = angle % 90 / 90 * quarter_size.x; + + // draw the four compass quarters + for(int i = 0; i < 4; ++i){ + float offset = quarter_size.x*i; + vector color; + + // calculate an angle to determine which compass quarter to draw next + float draw_angle = angle + 90*i; + if(draw_angle >= 360) + draw_angle -= 360; + + // chooses the color for each compass quarter + if(draw_angle < 90) + color = !autocvar_v_flipped ? autocvar_hud_panel_compass_south_color : autocvar_hud_panel_compass_east_color; + else if(draw_angle < 180) + color = !autocvar_v_flipped ? autocvar_hud_panel_compass_west_color : autocvar_hud_panel_compass_north_color; + else if(draw_angle < 270) + color = !autocvar_v_flipped ? autocvar_hud_panel_compass_north_color : autocvar_hud_panel_compass_west_color; + else + color = !autocvar_v_flipped ? autocvar_hud_panel_compass_east_color : autocvar_hud_panel_compass_south_color; + + // if the compass quarter doesn't wrap around just draw it all at once + if(offset - alignment_offset >= 0) + { + // draw the compass quarter + drawfill(panel_pos + eX * (offset - alignment_offset), quarter_size, color, autocvar_hud_panel_compass_quarter_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); + // draw the orienting lines + drawfill(panel_pos + eX * (offset - alignment_offset + quarter_size.x/2 - line_size.x/2) + eY * (panel_size.y - line_size.y), line_size, autocvar_hud_panel_compass_line_color, autocvar_hud_panel_compass_line_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); + } + // if it does wrap around draw each part seperately on both ends of the hud panel + else + { + // draw the compass quarter + drawfill(panel_pos, quarter_size - eX * alignment_offset, color, autocvar_hud_panel_compass_quarter_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); + drawfill(panel_pos + eX * (panel_size.x - alignment_offset), quarter_size - eX * (quarter_size.x - alignment_offset), color, autocvar_hud_panel_compass_quarter_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); + // draw the orienting lines + if(angle % 90 <= 45) + drawfill(panel_pos + eX * (quarter_size.x/2 - alignment_offset - line_size.x/2) + eY * (panel_size.y - line_size.y), line_size, autocvar_hud_panel_compass_line_color, autocvar_hud_panel_compass_line_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); + if(angle % 90 >= 45) + drawfill(panel_pos + eX * (panel_size.x - alignment_offset + quarter_size.x/2 - line_size.x/2) + eY * (panel_size.y - line_size.y), line_size, autocvar_hud_panel_compass_line_color, autocvar_hud_panel_compass_line_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); + } + } + + // if the player is moving show the velocity direction relative to the view direction + if(speed > 0) + { + bool bkwd = false; + float offset_angle = move_angle - angle; + + // wrap around overflows + if(offset_angle <= -180) + offset_angle += 360; + if(offset_angle > 180) + offset_angle -= 360; + + // shift the arrow by 180 degrees and flip it if looking backwards + if(fabs(offset_angle) > 90) + { + bkwd = true; + offset_angle += 180; + if(offset_angle > 180) + offset_angle -= 360; + } + Compass_drawArrow(panel_pos + eX * (offset_angle / 360 * panel_size.x + panel_size.x/2) + eY * (panel_size.y), autocvar_hud_panel_compass_arrow_size * panel_size.y, (!autocvar__hud_configure && move_angle % 90 == 0 ? autocvar_hud_panel_compass_arrow_snap_color : autocvar_hud_panel_compass_arrow_color), autocvar_hud_panel_compass_arrow_alpha, bkwd); + } + } +} + +// draw an arrow (inspired by drawspritearrow() in common/mutators/mutator/waypoints/waypointsprites.qc) +void Compass_drawArrow(vector origin, float size, vector color, float alpha, bool flipped) +{ + R_BeginPolygon("", DRAWFLAG_NORMAL, true); + R_PolygonVertex(origin + (flipped ? size*eY : '0 0 0') , '0 0 0', color, alpha); + R_PolygonVertex(origin + (flipped ? '0 0 0' : size*eY) - size*eX, '0 0 0', color, alpha); + R_PolygonVertex(origin + (flipped ? '0 0 0' : size*eY) + size*eX, '0 0 0', color, alpha); + R_EndPolygon(); +} + diff --git a/qcsrc/client/hud/panel/compass.qh b/qcsrc/client/hud/panel/compass.qh new file mode 100644 index 000000000..16489664d --- /dev/null +++ b/qcsrc/client/hud/panel/compass.qh @@ -0,0 +1,19 @@ +#pragma once +#include "../panel.qh" + +int autocvar_hud_panel_compass = 0; +bool autocvar_hud_panel_compass_dynamichud = true; +vector autocvar_hud_panel_compass_north_color = '1 0.5 0'; +vector autocvar_hud_panel_compass_east_color = '0.25 0.75 0'; +vector autocvar_hud_panel_compass_south_color = '0.75 0.25 1'; +vector autocvar_hud_panel_compass_west_color = '0.25 1 0.75'; +float autocvar_hud_panel_compass_quarter_alpha = 0.8; +vector autocvar_hud_panel_compass_arrow_color = '1 1 1'; +vector autocvar_hud_panel_compass_arrow_snap_color = '1 0 0'; +float autocvar_hud_panel_compass_arrow_alpha = 1; +float autocvar_hud_panel_compass_arrow_size = 0.5; +vector autocvar_hud_panel_compass_line_color = '1 1 1'; +float autocvar_hud_panel_compass_line_alpha = 1; +float autocvar_hud_panel_compass_line_size = 0.2; + +void Compass_drawArrow(vector, float, vector, float, bool); diff --git a/qcsrc/client/mutators/events.qh b/qcsrc/client/mutators/events.qh index 6f6f34399..55f468f19 100644 --- a/qcsrc/client/mutators/events.qh +++ b/qcsrc/client/mutators/events.qh @@ -124,6 +124,9 @@ MUTATOR_HOOKABLE(HUD_Physics_showoptional, EV_NO_ARGS); /** return true to show the strafehud when optional mode is enabled */ MUTATOR_HOOKABLE(HUD_StrafeHUD_showoptional, EV_NO_ARGS); +/** return true to show the compass HUD panel when optional mode is enabled */ +MUTATOR_HOOKABLE(HUD_Compass_showoptional, EV_NO_ARGS); + /** return true to hide the score HUD panel */ MUTATOR_HOOKABLE(HUD_Score_show, EV_NO_ARGS); diff --git a/qcsrc/common/gamemodes/gamemode/cts/cl_cts.qc b/qcsrc/common/gamemodes/gamemode/cts/cl_cts.qc index ce095bf20..458c457ed 100644 --- a/qcsrc/common/gamemodes/gamemode/cts/cl_cts.qc +++ b/qcsrc/common/gamemodes/gamemode/cts/cl_cts.qc @@ -14,6 +14,11 @@ MUTATOR_HOOKFUNCTION(cl_cts, HUD_StrafeHUD_showoptional) return ISGAMETYPE(CTS); // show the optional strafehud } +MUTATOR_HOOKFUNCTION(cl_cts, HUD_Compass_showoptional) +{ + return ISGAMETYPE(CTS); // show the optional compass +} + MUTATOR_HOOKFUNCTION(cl_cts, HUD_Score_show) { return spectatee_status == -1 && ISGAMETYPE(CTS); // hide the score panel while observing diff --git a/qcsrc/common/gamemodes/gamemode/race/cl_race.qc b/qcsrc/common/gamemodes/gamemode/race/cl_race.qc index 4311ce777..49a355fa8 100644 --- a/qcsrc/common/gamemodes/gamemode/race/cl_race.qc +++ b/qcsrc/common/gamemodes/gamemode/race/cl_race.qc @@ -161,6 +161,11 @@ MUTATOR_HOOKFUNCTION(cl_race, HUD_StrafeHUD_showoptional) return ISGAMETYPE(RACE); // show the optional strafehud } +MUTATOR_HOOKFUNCTION(cl_race, HUD_Compass_showoptional) +{ + return ISGAMETYPE(RACE); // show the optional compass +} + MUTATOR_HOOKFUNCTION(cl_race, HUD_Score_show) { return spectatee_status == -1 && ISGAMETYPE(RACE); // hide the score panel while observing diff --git a/qcsrc/menu/xonotic/_mod.inc b/qcsrc/menu/xonotic/_mod.inc index 0f9a960c9..c4773bacf 100644 --- a/qcsrc/menu/xonotic/_mod.inc +++ b/qcsrc/menu/xonotic/_mod.inc @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include diff --git a/qcsrc/menu/xonotic/_mod.qh b/qcsrc/menu/xonotic/_mod.qh index 2bb4ccead..99226f816 100644 --- a/qcsrc/menu/xonotic/_mod.qh +++ b/qcsrc/menu/xonotic/_mod.qh @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include diff --git a/qcsrc/menu/xonotic/dialog_hudpanel_compass.qc b/qcsrc/menu/xonotic/dialog_hudpanel_compass.qc new file mode 100644 index 000000000..d4500db6f --- /dev/null +++ b/qcsrc/menu/xonotic/dialog_hudpanel_compass.qc @@ -0,0 +1,107 @@ +#include "dialog_hudpanel_compass.qh" + +#include "colorpicker_string.qh" +#include "button.qh" +#include "slider.qh" +#include "textlabel.qh" +#include "textslider.qh" + +void Compass_CenterPanel(entity btn, entity me) +{ + vector size = stov(str_cvar("hud_panel_compass_size")); + vector pos = stov(str_cvar("hud_panel_compass_pos")); + pos.x = 0.5 - size.x / 2; + cvar_set("hud_panel_compass_pos", strcat(ftos(pos.x), " ", ftos(pos.y))); +} + +void Compass_ColorReset(entity btn, entity me) +{ + cvar_set("hud_panel_compass_north_color", cvar_defstring("hud_panel_compass_north_color")); + cvar_set("hud_panel_compass_east_color", cvar_defstring("hud_panel_compass_east_color")); + cvar_set("hud_panel_compass_south_color", cvar_defstring("hud_panel_compass_south_color")); + cvar_set("hud_panel_compass_west_color", cvar_defstring("hud_panel_compass_west_color")); + cvar_set("hud_panel_compass_arrow_color", cvar_defstring("hud_panel_compass_arrow_color")); + cvar_set("hud_panel_compass_arrow_snap_color", cvar_defstring("hud_panel_compass_arrow_snap_color")); + cvar_set("hud_panel_compass_line_color", cvar_defstring("hud_panel_compass_line_color")); +} + +void XonoticHUDCompassDialog_fill(entity me) +{ + entity e; + string panelname = "compass"; + + me.TR(me); + me.TD(me, 1, 4, e = makeXonoticTextSlider("hud_panel_compass")); + e.addValue(e, _("Disable"), "0"); + e.addValue(e, _("Enable"), "1"); + e.addValue(e, _("Enable even observing"), "2"); + e.addValue(e, _("Enable only in Race/CTS"), "3"); + e.configureXonoticTextSliderValues(e); + + dialog_hudpanel_main_settings(me, panelname); + me.TR(me); + + me.TD(me, 1, 1.9, e = makeXonoticButton(_("Center panel"), '0 0 0')); + e.onClick = Compass_CenterPanel; + e.onClickEntity = me; + me.TDempty(me, 0.2); + me.TD(me, 1, 1.9, e = makeXonoticButton(_("Reset colors"), '0 0 0')); + e.onClick = Compass_ColorReset; + e.onClickEntity = me; + me.TR(me); + + me.TD(me, 1, 0.9, e = makeXonoticTextLabel(0, _("North:"))); + me.TDempty(me, 0.2); + me.TD(me, 1, 0.9, e = makeXonoticTextLabel(0, _("South:"))); + me.TDempty(me, 0.2); + me.TD(me, 1, 0.9, e = makeXonoticTextLabel(0, _("West:"))); + me.TDempty(me, 0.2); + me.TD(me, 1, 0.9, e = makeXonoticTextLabel(0, _("East:"))); + me.TR(me); + me.TD(me, 2, 0.9, e = makeXonoticColorpickerString("hud_panel_compass_north_color", "hud_panel_compass_north_color")); + me.TDempty(me, 0.2); + me.TD(me, 2, 0.9, e = makeXonoticColorpickerString("hud_panel_compass_south_color", "hud_panel_compass_south_color")); + me.TDempty(me, 0.2); + me.TD(me, 2, 0.9, e = makeXonoticColorpickerString("hud_panel_compass_west_color", "hud_panel_compass_west_color")); + me.TDempty(me, 0.2); + me.TD(me, 2, 0.9, e = makeXonoticColorpickerString("hud_panel_compass_east_color", "hud_panel_compass_east_color")); + me.TR(me); + me.TR(me); + me.TD(me, 1, 4, e = makeXonoticTextLabel(0, _("Transparency:"))); + me.TR(me); + me.TD(me, 1, 4, e = makeXonoticSlider(0, 1, 0.1, "hud_panel_compass_quarter_alpha")); + me.TR(me); + + me.TD(me, 1, 4, e = makeXonoticTextLabel(0, _("Arrow:"))); + me.TR(me); + me.TD(me, 1, 1.9, e = makeXonoticTextLabel(0, _("Normal:"))); + me.TDempty(me, 0.2); + me.TD(me, 1, 1.9, e = makeXonoticTextLabel(0, _("Snap:"))); + me.TR(me); + me.TD(me, 2, 1.9, e = makeXonoticColorpickerString("hud_panel_compass_arrow_color", "hud_panel_compass_arrow_color")); + me.TDempty(me, 0.2); + me.TD(me, 2, 1.9, e = makeXonoticColorpickerString("hud_panel_compass_arrow_snap_color", "hud_panel_compass_arrow_snap_color")); + me.TR(me); + me.TR(me); + me.TD(me, 1, 1.9, e = makeXonoticTextLabel(0, _("Transparency:"))); + me.TDempty(me, 0.2); + me.TD(me, 1, 1.9, e = makeXonoticTextLabel(0, _("Size:"))); + me.TR(me); + me.TD(me, 1, 1.9, e = makeXonoticSlider(0, 1, 0.1, "hud_panel_compass_arrow_alpha")); + me.TDempty(me, 0.2); + me.TD(me, 1, 1.9, e = makeXonoticSlider(0.1, 0.75, 0.05, "hud_panel_compass_arrow_size")); + me.TR(me); + + me.TD(me, 1, 4, e = makeXonoticTextLabel(0, _("Orienting lines:"))); + me.TR(me); + me.TD(me, 2, 4, e = makeXonoticColorpickerString("hud_panel_compass_line_color", "hud_panel_compass_line_color")); + me.TR(me); + me.TR(me); + me.TD(me, 1, 1.9, e = makeXonoticTextLabel(0, _("Transparency:"))); + me.TDempty(me, 0.2); + me.TD(me, 1, 1.9, e = makeXonoticTextLabel(0, _("Size:"))); + me.TR(me); + me.TD(me, 1, 1.9, e = makeXonoticSlider(0, 1, 0.1, "hud_panel_compass_line_alpha")); + me.TDempty(me, 0.2); + me.TD(me, 1, 1.9, e = makeXonoticSlider(0.1, 0.75, 0.05, "hud_panel_compass_line_size")); +} diff --git a/qcsrc/menu/xonotic/dialog_hudpanel_compass.qh b/qcsrc/menu/xonotic/dialog_hudpanel_compass.qh new file mode 100644 index 000000000..e879fe634 --- /dev/null +++ b/qcsrc/menu/xonotic/dialog_hudpanel_compass.qh @@ -0,0 +1,13 @@ +#pragma once + +#include "rootdialog.qh" +CLASS(XonoticHUDCompassDialog, XonoticRootDialog) + METHOD(XonoticHUDCompassDialog, fill, void(entity)); + ATTRIB(XonoticHUDCompassDialog, title, string, _("Compass Panel")); + ATTRIB(XonoticHUDCompassDialog, color, vector, SKINCOLOR_DIALOG_TEAMSELECT); + ATTRIB(XonoticHUDCompassDialog, intendedWidth, float, 0.4); + ATTRIB(XonoticHUDCompassDialog, rows, float, 26.5); + ATTRIB(XonoticHUDCompassDialog, columns, float, 4); + ATTRIB(XonoticHUDCompassDialog, name, string, "HUDcompass"); + ATTRIB(XonoticHUDCompassDialog, requiresConnection, float, true); +ENDCLASS(XonoticHUDCompassDialog) diff --git a/qcsrc/menu/xonotic/mainwindow.qc b/qcsrc/menu/xonotic/mainwindow.qc index 89a61fb0d..4d3ce09ca 100644 --- a/qcsrc/menu/xonotic/mainwindow.qc +++ b/qcsrc/menu/xonotic/mainwindow.qc @@ -26,6 +26,7 @@ #include "dialog_hudpanel_itemstime.qh" #include "dialog_hudpanel_quickmenu.qh" #include "dialog_hudpanel_strafehud.qh" +#include "dialog_hudpanel_compass.qh" #include "dialog_settings_input_userbind.qh" #include "dialog_settings_bindings_reset.qh" @@ -195,6 +196,10 @@ void MainWindow_configureMainWindow(entity me) i.configureDialog(i); me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z); + i = NEW(XonoticHUDCompassDialog); + i.configureDialog(i); + me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z); + // dialogs used by settings me.userbindEditDialog = i = NEW(XonoticUserbindEditDialog); i.configureDialog(i); -- 2.39.2