]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Implement map_background: load a map as the main menu background TimePath/map_background
authorTimePath <andrew.hardaker1995@gmail.com>
Fri, 30 Mar 2018 08:07:50 +0000 (19:07 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Fri, 30 Mar 2018 08:07:50 +0000 (19:07 +1100)
qcsrc/menu/menu.qc
qcsrc/server/_mod.inc
qcsrc/server/_mod.qh
qcsrc/server/map_background.qc [new file with mode: 0644]
qcsrc/server/map_background.qh [new file with mode: 0644]

index af14e0842b4dc749897a45e7fc2f18ae2dcaf6c4..59d2738d07ea6f66b695eb5484340872c77e9e22 100644 (file)
@@ -245,6 +245,10 @@ void m_keyup(float key, float ascii)
        if (key == K_SHIFT) menuShiftState &= ~S_SHIFT;
 }
 
+string autocvar_map_background, map_background;
+int autocvar_map_background_state;
+#define map_background_active (map_background && autocvar_map_background_state && (gamestatus & GAME_ISSERVER))
+
 void m_keydown(float key, float ascii)
 {
        if (!menuInitialized) return;
@@ -276,8 +280,15 @@ void m_keydown(float key, float ascii)
                {
                        // disable menu on unhandled ESC
                        if (key == K_ESCAPE)
-                               if (gamestatus & (GAME_ISSERVER | GAME_CONNECTED))  // don't back out to console only
-                                       m_hide();
+            {
+                if (map_background_active) {
+                    // prevent playing the background map
+                } else if (!(gamestatus & (GAME_ISSERVER | GAME_CONNECTED))) {
+                    // don't back out to console only
+                } else {
+                    m_hide();
+                }
+            }
                }
        }
        if (key >= K_MOUSE1 && key <= K_MOUSE3)
@@ -678,6 +689,22 @@ void m_tooltip(vector pos)
 float autocvar_menu_force_on_disconnection;
 void m_draw(float width, float height)
 {
+    bool map_background_change = false;
+    if (autocvar_map_background != map_background) {
+        map_background_change = true;
+        map_background && strunzone(map_background);
+        map_background = strzone(autocvar_map_background);
+    }
+    if (map_background_change || !(gamestatus & (GAME_ISSERVER | GAME_CONNECTED))) {
+        if (map_background) {
+            cvar_set("map_background_state", "2");
+            localcmd(sprintf("\nmap %s\n", map_background));
+        }
+    }
+    if (map_background_active) {
+        m_toggle(true);
+    }
+
        if (autocvar_menu_force_on_disconnection > 0)
        {
                static float connected_time;
index 569301c5d65c369b60deb900f44be3bf1447c5bf..559e0e14416bbb0a46580f6d2d98f2e64e3d24bf 100644 (file)
@@ -15,6 +15,7 @@
 #include <server/ipban.qc>
 #include <server/item_key.qc>
 #include <server/items.qc>
+#include <server/map_background.qc>
 #include <server/mapvoting.qc>
 #include <server/matrix.qc>
 #include <server/miscfunctions.qc>
index 2013fd6bb5db5c521737cf0985fc65c13a43846e..56f0e098c7e51b3d8b24e215d0615456e80a9fae 100644 (file)
@@ -15,6 +15,7 @@
 #include <server/ipban.qh>
 #include <server/item_key.qh>
 #include <server/items.qh>
+#include <server/map_background.qh>
 #include <server/mapvoting.qh>
 #include <server/matrix.qh>
 #include <server/miscfunctions.qh>
diff --git a/qcsrc/server/map_background.qc b/qcsrc/server/map_background.qc
new file mode 100644 (file)
index 0000000..1266635
--- /dev/null
@@ -0,0 +1,6 @@
+#include "map_background.qh"
+
+int autocvar_map_background_state;
+STATIC_INIT(map_background) {
+    cvar_set("map_background_state", ftos(autocvar_map_background_state > 1));
+}
diff --git a/qcsrc/server/map_background.qh b/qcsrc/server/map_background.qh
new file mode 100644 (file)
index 0000000..6f70f09
--- /dev/null
@@ -0,0 +1 @@
+#pragma once