X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fmenu%2Fmenu.qc;h=96d98b9c502149cfe54d18461cbc08ec9ff0c1e6;hb=8ba1f6c672361186033b8bebc3be677ac94bd4da;hp=5e98da110504c06e7a4dc433e03b4edd6e34db37;hpb=c98bb7952507474a128d9b250abccb8a77bb6fd6;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/menu/menu.qc b/qcsrc/menu/menu.qc index 5e98da110..96d98b9c5 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 #include "../common/mapinfo.qh" #include "../common/mutators/base.qh" @@ -152,18 +167,18 @@ void m_init_delayed() if (cvar_string("menu_skin") != "") { draw_currentSkin = strcat("gfx/menu/", cvar_string("menu_skin")); - fh = fopen(language_filename(strcat(draw_currentSkin, "/skinvalues.txt")), FILE_READ); + fh = fopen(strcat(draw_currentSkin, "/skinvalues.txt"), FILE_READ); } if (fh < 0 && cvar_defstring("menu_skin") != "") { cvar_set("menu_skin", cvar_defstring("menu_skin")); draw_currentSkin = strcat("gfx/menu/", cvar_string("menu_skin")); - fh = fopen(language_filename(strcat(draw_currentSkin, "/skinvalues.txt")), FILE_READ); + fh = fopen(strcat(draw_currentSkin, "/skinvalues.txt"), FILE_READ); } if (fh < 0) { draw_currentSkin = "gfx/menu/default"; - fh = fopen(language_filename(strcat(draw_currentSkin, "/skinvalues.txt")), FILE_READ); + fh = fopen(strcat(draw_currentSkin, "/skinvalues.txt"), FILE_READ); } if (fh < 0) error("cannot load any menu skin\n"); draw_currentSkin = strzone(draw_currentSkin); @@ -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) } } @@ -524,12 +539,11 @@ void m_tooltip(vector pos) { float f = bound(0, frametime * 2, 1); menuTooltipAveragedMousePos = menuTooltipAveragedMousePos * (1 - f) + pos * f; - f = vlen(pos - menuTooltipAveragedMousePos); - if (f < 0.01) + if (vdist(pos - menuTooltipAveragedMousePos, <, 0.01)) { 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) { @@ -574,9 +588,11 @@ void m_tooltip(vector pos) 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; } @@ -646,17 +662,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(); @@ -775,15 +810,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); @@ -863,10 +894,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)