]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add compass panel, somewhat a CGaz compass clone
authorJuhu <5894800-Juhu_@users.noreply.gitlab.com>
Wed, 31 Mar 2021 11:53:58 +0000 (13:53 +0200)
committerJuhu <5894800-Juhu_@users.noreply.gitlab.com>
Wed, 31 Mar 2021 11:57:12 +0000 (13:57 +0200)
21 files changed:
_hud_common.cfg
_hud_descriptions.cfg
hud_luma.cfg
hud_luminos.cfg
hud_luminos_minimal.cfg
hud_luminos_minimal_xhair.cfg
hud_luminos_old.cfg
hud_nexuiz.cfg
qcsrc/client/hud/hud.qh
qcsrc/client/hud/panel/_mod.inc
qcsrc/client/hud/panel/_mod.qh
qcsrc/client/hud/panel/compass.qc [new file with mode: 0644]
qcsrc/client/hud/panel/compass.qh [new file with mode: 0644]
qcsrc/client/mutators/events.qh
qcsrc/common/gamemodes/gamemode/cts/cl_cts.qc
qcsrc/common/gamemodes/gamemode/race/cl_race.qc
qcsrc/menu/xonotic/_mod.inc
qcsrc/menu/xonotic/_mod.qh
qcsrc/menu/xonotic/dialog_hudpanel_compass.qc [new file with mode: 0644]
qcsrc/menu/xonotic/dialog_hudpanel_compass.qh [new file with mode: 0644]
qcsrc/menu/xonotic/mainwindow.qc

index a62837f5f8b4f0881871938eb9246a8aaa534eb8..a96316683ccf1bd39a88b6b2e62b778f896452ec 100644 (file)
@@ -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"
@@ -180,6 +182,19 @@ seta hud_panel_strafehud_timeout_direction "0.5" "time (in seconds) it takes unt
 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 ${* ?}"
 
index 02d2d5a0f46adb114c507ccbc327b5dc57ed39c3..a4a6cd8ba7cc6f5e30e2865b27cf6dfadcbe2bee 100644 (file)
@@ -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"
index 9ad2425a7c498bf97171eff9bea3acbb18ca03a3..2186ced223cade033b4983dc1a934166b89a9d24 100644 (file)
@@ -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
index c642ac38f46121727ce1487c6a78b6cc8a8d2462..328cc50698331b5f9e682532283fe350494fd8a4 100644 (file)
@@ -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
index d15dd868ac2c37c074f2a17da73137ebb99774a6..a170e2c9f1f025d4d8266317ff21ed0888be1b6a 100644 (file)
@@ -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
index 11c57ee484bdc0344e34c507f5408a9d35d41a1a..a38895c65673aada088d7a74e1a9dbad7847cb4e 100644 (file)
@@ -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
index 42a79015cdc43267e21a93505aa7a287987c133a..675e5bd5b90cf3b4af0a3b806c14687691b76c69 100644 (file)
@@ -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
index 9200283c3d3c1aeaed050a7933f4f9e675039ca7..a12289522224fd30cb4db7ca6ba0f621b30bfcd6 100644 (file)
@@ -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
index 14e1af0a0df3f0ba27f6a43ce5cc53f063da8394..b7c3b488db5086ffcf340c15e3cc1597d45b1867 100644 (file)
@@ -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:
index 68e368ed13cb0c9dad0227073710fe0f885c7c57..17082e0ad889c3d863c1bef528db0ff61e8fc2eb 100644 (file)
@@ -2,6 +2,7 @@
 #include <client/hud/panel/ammo.qc>
 #include <client/hud/panel/centerprint.qc>
 #include <client/hud/panel/chat.qc>
+#include <client/hud/panel/compass.qc>
 #include <client/hud/panel/engineinfo.qc>
 #include <client/hud/panel/healtharmor.qc>
 #include <client/hud/panel/infomessages.qc>
index 1b45f0cd042a5be7fa4b42483c1e08039c04f636..62e925c75dccc0728cb423d44571561a539bd98a 100644 (file)
@@ -2,6 +2,7 @@
 #include <client/hud/panel/ammo.qh>
 #include <client/hud/panel/centerprint.qh>
 #include <client/hud/panel/chat.qh>
+#include <client/hud/panel/compass.qh>
 #include <client/hud/panel/engineinfo.qh>
 #include <client/hud/panel/healtharmor.qh>
 #include <client/hud/panel/infomessages.qh>
diff --git a/qcsrc/client/hud/panel/compass.qc b/qcsrc/client/hud/panel/compass.qc
new file mode 100644 (file)
index 0000000..14a5ab9
--- /dev/null
@@ -0,0 +1,158 @@
+// Author: Juhu
+
+#include "compass.qh"
+
+#include <client/draw.qh>
+#include <common/physics/player.qh>
+#include <lib/csqcmodel/cl_player.qh>
+
+// 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 (file)
index 0000000..1648966
--- /dev/null
@@ -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);
index 6f6f34399f18e19a476771b9b7d41bc0bf237daa..55f468f191e52503241379475b0a47ead4ed4136 100644 (file)
@@ -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);
 
index ce095bf2032a0e1a63fccaaac1fc0c3840d91148..458c457ed971625c4f17987017bf72af39fb4802 100644 (file)
@@ -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
index 4311ce777aa813560420fa6cb2bc3fb0df62696f..49a355fa8c68eda48828c1e49a0bb6f8d2300376 100644 (file)
@@ -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
index 0f9a960c92f657e0dc00ba00ff1ea3a26bdb10bd..c4773bacf09e4723917d5d6ed31294c03122f40b 100644 (file)
@@ -24,6 +24,7 @@
 #include <menu/xonotic/dialog_hudpanel_ammo.qc>
 #include <menu/xonotic/dialog_hudpanel_centerprint.qc>
 #include <menu/xonotic/dialog_hudpanel_chat.qc>
+#include <menu/xonotic/dialog_hudpanel_compass.qc>
 #include <menu/xonotic/dialog_hudpanel_engineinfo.qc>
 #include <menu/xonotic/dialog_hudpanel_healtharmor.qc>
 #include <menu/xonotic/dialog_hudpanel_infomessages.qc>
index 2bb4ccead24a71d6df581c6db654e49acd47cb7e..99226f81637fc44ce594a13ba38c14a7401d0592 100644 (file)
@@ -24,6 +24,7 @@
 #include <menu/xonotic/dialog_hudpanel_ammo.qh>
 #include <menu/xonotic/dialog_hudpanel_centerprint.qh>
 #include <menu/xonotic/dialog_hudpanel_chat.qh>
+#include <menu/xonotic/dialog_hudpanel_compass.qh>
 #include <menu/xonotic/dialog_hudpanel_engineinfo.qh>
 #include <menu/xonotic/dialog_hudpanel_healtharmor.qh>
 #include <menu/xonotic/dialog_hudpanel_infomessages.qh>
diff --git a/qcsrc/menu/xonotic/dialog_hudpanel_compass.qc b/qcsrc/menu/xonotic/dialog_hudpanel_compass.qc
new file mode 100644 (file)
index 0000000..d4500db
--- /dev/null
@@ -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 (file)
index 0000000..e879fe6
--- /dev/null
@@ -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)
index 89a61fb0d89d2fff669177c4245b5c738d0aad4c..4d3ce09ca79acca789c23bb060698de96bf35f63 100644 (file)
@@ -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);