X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fmenu%2Fmenu.qc;h=fb6c4aeeda60a612cbe47ffe4c6804022b315c23;hp=1c7ed0386f5d63b90a1655c2e202ef639a7d40d8;hb=60b0e81cdaed847a7aac9d234f219937ab9462b2;hpb=724a41faf2cbfd86d41f3ab59ff8326a831a8326 diff --git a/qcsrc/menu/menu.qc b/qcsrc/menu/menu.qc index 1c7ed0386..fb6c4aeed 100644 --- a/qcsrc/menu/menu.qc +++ b/qcsrc/menu/menu.qc @@ -1,9 +1,24 @@ #include "menu.qh" -#include "classes.qc" + +#include "item.qh" + +#include "anim/animhost.qh" + +#include "item/dialog.qh" +#include "item/listbox.qh" +#include "item/nexposee.qh" + +#include "xonotic/commandbutton.qh" +#include "xonotic/mainwindow.qh" +#include "xonotic/serverlist.qh" +#include "xonotic/slider_resolution.qh" + +.string cvarName; + #include "xonotic/util.qh" -#include "../common/items/all.qh" -#include "../common/weapons/all.qh" +#include "../common/items/_mod.qh" +#include #include "../common/mapinfo.qh" #include "../common/mutators/base.qh" @@ -54,7 +69,7 @@ void m_init() cvar_set("_menu_prvm_language", prvm_language); #ifdef WATERMARK - LOG_INFOF("^4MQC Build information: ^1%s\n", WATERMARK); + LOG_INFOF("^4MQC Build information: ^1%s", WATERMARK); #endif // list all game dirs (TEST) @@ -202,8 +217,7 @@ void m_init_delayed() if (m_goto_buffer) { m_goto(m_goto_buffer); - strunzone(m_goto_buffer); - m_goto_buffer = string_null; + strfree(m_goto_buffer); } if (Menu_Active) m_display(); // delayed menu display @@ -222,7 +236,7 @@ void m_keyup(float key, float ascii) if (mouseButtonsPressed < 0) { mouseButtonsPressed = 0; - LOG_TRACE("Warning: released an already released button\n"); + LOG_TRACE("Warning: released an already released button"); } } if (key == K_ALT) menuShiftState &= ~S_ALT; @@ -255,7 +269,8 @@ void m_keydown(float key, float ascii) else { draw_reset_cropped(); - if (!mouseButtonsPressed && key >= K_MOUSE1 && key <= K_MOUSE3) main.mousePress(main, menuMousePos); + if (!mouseButtonsPressed && key >= K_MOUSE1 && key <= K_MOUSE3) + main.mousePress(main, menuMousePos); if (!main.keyDown(main, key, ascii, menuShiftState)) { // disable menu on unhandled ESC @@ -270,7 +285,7 @@ void m_keydown(float key, float ascii) if (mouseButtonsPressed > 10) { mouseButtonsPressed = 10; - LOG_TRACE("Warning: pressed an already pressed button\n"); + LOG_TRACE("Warning: pressed an already pressed button"); } } if (key == K_ALT) menuShiftState |= S_ALT; @@ -384,7 +399,7 @@ void drawBackground(string img, float a, string algn, float force1) draw_Picture_Aligned(v, scalemode, strcat(img, "_l", ftos(l + 1)), a); } ++l; - : nopic +LABEL(nopic) } } @@ -528,14 +543,13 @@ void m_tooltip(vector pos) { it = m_findtooltipitem(main, pos); - if (it.instanceOfListBox && it.isScrolling(it)) it = world; + if (it.instanceOfListBox && it.isScrolling(it)) it = NULL; if (it && prev_tooltip != it.tooltip) { // fade out if tooltip of a certain item has changed menuTooltipState = 3; - if (prev_tooltip) strunzone(prev_tooltip); - prev_tooltip = strzone(it.tooltip); + strcpy(prev_tooltip, it.tooltip); } else if (menuTooltipItem && !m_testmousetooltipbox(pos)) { @@ -568,14 +582,15 @@ void m_tooltip(vector pos) menuTooltipOrigin.x = -1; // unallocated - if (menuTooltipText) strunzone(menuTooltipText); - menuTooltipText = strzone(gettooltip()); + strcpy(menuTooltipText, gettooltip()); int i = 0; float w = 0; - for (getWrappedLine_remaining = menuTooltipText; getWrappedLine_remaining; ++i) + for (getWrappedLine_remaining = menuTooltipText; getWrappedLine_remaining && i <= 16; ++i) { string s = getWrappedLine(SKINWIDTH_TOOLTIP, fontsize, draw_TextWidth_WithoutColors); + if (i == 16) + s = "..."; float f = draw_TextWidth(s, false, fontsize); if (f > w) w = f; } @@ -617,11 +632,7 @@ void m_tooltip(vector pos) if (menuTooltipItem == NULL) { - if (menuTooltipText) - { - strunzone(menuTooltipText); - menuTooltipText = string_null; - } + strfree(menuTooltipText); return; } else @@ -645,17 +656,36 @@ void m_tooltip(vector pos) p = menuTooltipOrigin; p.x += SKINMARGIN_TOOLTIP_x / conwidth; p.y += SKINMARGIN_TOOLTIP_y / conheight; - for (getWrappedLine_remaining = menuTooltipText; getWrappedLine_remaining; p.y += fontsize.y) + int i = 0; + for (getWrappedLine_remaining = menuTooltipText; getWrappedLine_remaining && i <= 16; ++i, p.y += fontsize.y) { string s = getWrappedLine(SKINWIDTH_TOOLTIP, fontsize, draw_TextWidth_WithoutColors); + if (i == 16) + s = "..."; draw_Text(p, s, fontsize, SKINCOLOR_TOOLTIP, SKINALPHA_TOOLTIP * menuTooltipAlpha, false); } } } } +float autocvar_menu_force_on_disconnection; void m_draw(float width, float height) { + if (autocvar_menu_force_on_disconnection > 0) + { + static float connected_time; + if (clientstate() == CS_DISCONNECTED) + { + if (connected_time && time - connected_time > autocvar_menu_force_on_disconnection) + { + m_toggle(true); + connected_time = 0; + } + } + else + connected_time = time; + } + m_gamestatus(); execute_next_frame(); @@ -774,15 +804,11 @@ void m_draw(float width, float height) draw_alpha *= menuAlpha; - if (!Menu_Active) - { - // do not update mouse position - // it prevents mouse jumping to '0 0 0' when menu is fading out - } - else if (menuMouseMode) + if (menuMouseMode) { - vector newMouse = globalToBox(getmousepos(), draw_shift, draw_scale); - if (newMouse != '0 0 0' && newMouse != menuMousePos) + vector rawMousePos = getmousepos(); + vector newMouse = globalToBox(rawMousePos, draw_shift, draw_scale); + if (rawMousePos != '0 0 0' && newMouse != menuMousePos) { menuMousePos = newMouse; if (mouseButtonsPressed) main.mouseDrag(main, menuMousePos); @@ -816,6 +842,7 @@ void m_draw(float width, float height) postMenuDraw(); frametime = 0; + IL_ENDFRAME(); } void m_display() @@ -862,10 +889,10 @@ void m_toggle(int mode) void Shutdown() { m_hide(); - FOREACH_ENTITY_ORDERED(it.destroy, LAMBDA( + FOREACH_ENTITY_ORDERED(it.destroy, { if (it.classname == "vtbl") continue; it.destroy(it); - )); + }); } void m_focus_item_chain(entity outermost, entity innermost) @@ -919,8 +946,7 @@ void m_goto(string itemname) { if (!menuInitialized) { - if (m_goto_buffer) strunzone(m_goto_buffer); - m_goto_buffer = strzone(itemname); + strcpy(m_goto_buffer, itemname); return; } if (itemname == "") // this can be called by GameCommand @@ -943,6 +969,8 @@ void m_goto(string itemname) if ((e) && (!e.requiresConnection || (gamestatus & (GAME_ISSERVER | GAME_CONNECTED)))) { + if(!Menu_Active) + e.hideMenuOnClose = true; m_hide(); m_activate_window(e); m_setpointerfocus(e);