X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fmenu%2Fmenu.qc;h=9331364108cd5a2cfd17429178a5035c69e7793b;hb=561489d21c9053b7103c6604c362aa24ee5c7916;hp=891235def666700cc2a0865d8809d9512a1b43ac;hpb=fe65404b4515e2f7db18a71c9953f318003b214e;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/menu/menu.qc b/qcsrc/menu/menu.qc index 891235def..933136410 100644 --- a/qcsrc/menu/menu.qc +++ b/qcsrc/menu/menu.qc @@ -13,14 +13,14 @@ #include "xonotic/serverlist.qh" #include "xonotic/slider_resolution.qh" -.string cvarName; +.string controlledCvar; #include "xonotic/util.qh" -#include "../common/items/_mod.qh" +#include #include -#include "../common/mapinfo.qh" -#include "../common/mutators/base.qh" +#include +#include int mouseButtonsPressed; vector menuMousePos; @@ -69,7 +69,7 @@ void m_init() cvar_set("_menu_prvm_language", prvm_language); #ifdef WATERMARK - LOG_INFOF("^4MQC Build information: ^1%s", WATERMARK); + LOG_TRACEF("^4MQC Build information: ^1%s", WATERMARK); #endif // list all game dirs (TEST) @@ -221,6 +221,8 @@ void m_init_delayed() } if (Menu_Active) m_display(); // delayed menu display + + cvar_set("_menu_initialized", "2"); } void m_keyup(float key, float ascii) @@ -481,7 +483,7 @@ entity m_findtooltipitem(entity root, vector pos) { it = it.itemFromPoint(it, pos); if (it.tooltip) best = it; - else if (menu_tooltips == 2 && (it.cvarName || it.onClickCommand)) best = it; + else if (menu_tooltips == 2 && (it.controlledCvar || it.onClickCommand)) best = it; it = NULL; } else if (it.instanceOfModalController) @@ -494,7 +496,7 @@ entity m_findtooltipitem(entity root, vector pos) } if (!it) break; if (it.tooltip) best = it; - else if (menu_tooltips == 2 && (it.cvarName || it.onClickCommand)) best = it; + else if (menu_tooltips == 2 && (it.controlledCvar || it.onClickCommand)) best = it; pos = globalToBox(pos, it.Container_origin, it.Container_size); } @@ -505,11 +507,14 @@ string gettooltip() if (menu_tooltips == 2) { string s; - if (menuTooltipItem.cvarName) + if (menuTooltipItem.controlledCvar) { - if (getCvarsMulti(menuTooltipItem)) s = - strcat("[", menuTooltipItem.cvarName, " ", getCvarsMulti(menuTooltipItem), "]"); - else s = strcat("[", menuTooltipItem.cvarName, "]"); + string cvar_list = getCvarsMulti(menuTooltipItem); + if (cvar_list) + cvar_list = strcat(menuTooltipItem.controlledCvar, " ", cvar_list); + else + cvar_list = menuTooltipItem.controlledCvar; + s = strcat("[", cvar_list, " \"", cvar_string(menuTooltipItem.controlledCvar), "\"]"); } else if (menuTooltipItem.onClickCommand) { @@ -669,23 +674,32 @@ void m_tooltip(vector pos) } } +const int MIN_DISCONNECTION_TIME = 1; float autocvar_menu_force_on_disconnection; +bool autocvar_g_campaign; void m_draw(float width, float height) { - if (autocvar_menu_force_on_disconnection > 0) + static float connected_time; + if (clientstate() == CS_DISCONNECTED) { - static float connected_time; - if (clientstate() == CS_DISCONNECTED) + if (connected_time && time - connected_time > MIN_DISCONNECTION_TIME) { - if (connected_time && time - connected_time > autocvar_menu_force_on_disconnection) + if (autocvar_g_campaign) { - m_toggle(true); - connected_time = 0; + // in the case player uses the disconnect command (in the console or with a key) + // reset g_campaign and update menu items to reflect cvar values that may have been restored after quiting the campaign + // see also LEAVEMATCH_CMD + cvar_set("g_campaign", "0"); + m_sync(); } + if (autocvar_menu_force_on_disconnection > 0) + m_toggle(true); + localcmd("\nmenu_cmd directmenu Welcome RESET\n"); + connected_time = 0; } - else - connected_time = time; } + else + connected_time = time; m_gamestatus(); @@ -708,7 +722,9 @@ void m_draw(float width, float height) menuNotTheFirstFrame = true; if (Menu_Active && !cvar("menu_video_played")) { - localcmd("cd loop $menu_cdtrack; play sound/announcer/default/welcome.wav\n"); + localcmd("cd loop $menu_cdtrack\n"); + // TODO: use this when we have a welcome sound + //localcmd("cd loop $menu_cdtrack; play sound/announcer/default/welcome.wav\n"); menuLogoAlpha = -0.8; // no idea why, but when I start this at zero, it jumps instead of fading FIXME } // ALWAYS set this cvar; if we start but menu is not active, this means we want no background music! @@ -955,12 +971,16 @@ void m_goto(string itemname) if (gamestatus & (GAME_ISSERVER | GAME_CONNECTED)) { m_hide(); + return; } - else - { - m_activate_window(main.mainNexposee); - m_display(); - } + itemname = "nexposee"; + } + + if (itemname == "nexposee") + { + // unlike 'togglemenu 1', this closes modal and root dialogs if opened + m_activate_window(main.mainNexposee); + m_display(); } else {