From: TimePath Date: Fri, 30 Mar 2018 08:07:50 +0000 (+1100) Subject: Implement map_background: load a map as the main menu background X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=63a8f717e10023a511b402c095b0d5ab64539c9e;p=xonotic%2Fxonotic-data.pk3dir.git Implement map_background: load a map as the main menu background --- diff --git a/qcsrc/menu/menu.qc b/qcsrc/menu/menu.qc index af14e0842..59d2738d0 100644 --- a/qcsrc/menu/menu.qc +++ b/qcsrc/menu/menu.qc @@ -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; diff --git a/qcsrc/server/_mod.inc b/qcsrc/server/_mod.inc index 569301c5d..559e0e144 100644 --- a/qcsrc/server/_mod.inc +++ b/qcsrc/server/_mod.inc @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include diff --git a/qcsrc/server/_mod.qh b/qcsrc/server/_mod.qh index 2013fd6bb..56f0e098c 100644 --- a/qcsrc/server/_mod.qh +++ b/qcsrc/server/_mod.qh @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include diff --git a/qcsrc/server/map_background.qc b/qcsrc/server/map_background.qc new file mode 100644 index 000000000..1266635e0 --- /dev/null +++ b/qcsrc/server/map_background.qc @@ -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 index 000000000..6f70f09be --- /dev/null +++ b/qcsrc/server/map_background.qh @@ -0,0 +1 @@ +#pragma once