X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fmenu%2Fmenu.qc;h=ab940a3656481b1378c1bfffba10ce131c610665;hp=92da56a25377baee061139f736433b684aea0458;hb=2886ed5676755f4242704d64d3315124026496bb;hpb=a0351dd36fefcce48c4467548c7d47d0aca2076e diff --git a/qcsrc/menu/menu.qc b/qcsrc/menu/menu.qc index 92da56a253..ab940a3656 100644 --- a/qcsrc/menu/menu.qc +++ b/qcsrc/menu/menu.qc @@ -21,11 +21,12 @@ void SUB_Null() { }; void() m_init = { cvar_set("_menu_alpha", "0"); + prvm_language = strzone(cvar_string("prvm_language")); check_unacceptable_compiler_bugs(); #ifdef WATERMARK - print("^4MQC Build information: ", WATERMARK(), "\n"); + print(sprintf(_("^4MQC Build information: %s\n"), WATERMARK())); #endif // list all game dirs (TEST) @@ -115,18 +116,18 @@ void() m_init_delayed = if(cvar_string("menu_skin") != "") { draw_currentSkin = strcat("gfx/menu/", cvar_string("menu_skin")); - fh = fopen(strcat(draw_currentSkin, "/skinvalues.txt"), FILE_READ); + fh = fopen(language_filename(strcat(draw_currentSkin, "/skinvalues.txt")), FILE_READ); } if(fh < 0) if(cvar_defstring("menu_skin") != "") { draw_currentSkin = strcat("gfx/menu/", cvar_defstring("menu_skin")); - fh = fopen(strcat(draw_currentSkin, "/skinvalues.txt"), FILE_READ); + fh = fopen(language_filename(strcat(draw_currentSkin, "/skinvalues.txt")), FILE_READ); } if(fh < 0) { draw_currentSkin = "gfx/menu/default"; - fh = fopen(strcat(draw_currentSkin, "/skinvalues.txt"), FILE_READ); + fh = fopen(language_filename(strcat(draw_currentSkin, "/skinvalues.txt")), FILE_READ); } draw_currentSkin = strzone(draw_currentSkin); while((s = fgets(fh))) @@ -241,8 +242,8 @@ void draw_Picture_Aligned(vector algn, float scalemode, string img, float a) sz = draw_PictureSize(img); width_is_larger = (sz_x * draw_scale_y >= sz_y * draw_scale_x); - isz_w = '1 0 0' + '0 1 0' * ((sz_y / sz_x) * (draw_scale_x / draw_scale_y)); - isz_h = '0 1 0' + '1 0 0' * ((sz_x / sz_y) * (draw_scale_y / draw_scale_x)); + isz_w = '1 0 0' + '0 1 0' * ((sz_y / sz_x) * (draw_scale_x / draw_scale_y)); + isz_h = '0 1 0' + '1 0 0' * ((sz_x / sz_y) * (draw_scale_y / draw_scale_x)); switch(scalemode) { @@ -318,16 +319,19 @@ void(string img, float a, string algn, float force1) drawBackground = } } +float menu_tooltips; +float menu_tooltips_old; vector menuTooltipAveragedMousePos; entity menuTooltipItem; vector menuTooltipOrigin; vector menuTooltipSize; float menuTooltipAlpha; -float menuTooltipState; // 0: no tooltip, 1: fading in, 2: displaying, 3: fading out -float m_testmousetooltipbox(vector pos) +string menuTooltipText; +float menuTooltipState; // 0: static, 1: fading in, 2: fading out +float m_testmousetooltipbox() { - if(pos_x >= menuTooltipOrigin_x && pos_x < menuTooltipOrigin_x + menuTooltipSize_x) - if(pos_y >= menuTooltipOrigin_y && pos_y < menuTooltipOrigin_y + menuTooltipSize_y) + if(menuMousePos_x >= menuTooltipOrigin_x && menuMousePos_x < menuTooltipOrigin_x + menuTooltipSize_x) + if(menuMousePos_y >= menuTooltipOrigin_y && menuMousePos_y < menuTooltipOrigin_y + menuTooltipSize_y) return FALSE; return TRUE; } @@ -409,6 +413,8 @@ 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; it = world; } else if(it.instanceOfModalController) @@ -419,28 +425,62 @@ entity m_findtooltipitem(entity root, vector pos) break; if(it.tooltip) best = it; + else if(menu_tooltips == 2 && (it.cvarName || it.onClickCommand)) + best = it; pos = globalToBox(pos, it.Container_origin, it.Container_size); } return best; } -void m_tooltip(vector pos) +string gettooltip() +{ + if (menu_tooltips == 2) + { + string s; + if (menuTooltipItem.cvarName) + { + if (getCvarsMulti(menuTooltipItem)) + s = strcat("[", menuTooltipItem.cvarName, " ", getCvarsMulti(menuTooltipItem), "]"); + else + s = strcat("[", menuTooltipItem.cvarName, "]"); + } + else if (menuTooltipItem.onClickCommand) + s = strcat("<", menuTooltipItem.onClickCommand, ">"); + else + return menuTooltipItem.tooltip; + if (menuTooltipItem.tooltip) + return strcat(menuTooltipItem.tooltip, " ", s); + return s; + } + return menuTooltipItem.tooltip; +} +void m_tooltip() { float f, i, w; entity it; vector fontsize, p; string s; - fontsize = '1 0 0' * (SKINFONTSIZE_TOOLTIP / conwidth) + '0 1 0' * (SKINFONTSIZE_TOOLTIP / conheight); - - f = bound(0, frametime * 2, 1); - menuTooltipAveragedMousePos = menuTooltipAveragedMousePos * (1 - f) + pos * f; - f = vlen(pos - menuTooltipAveragedMousePos); - - if(f < 0.01) - it = m_findtooltipitem(main, pos); - else + menu_tooltips = cvar("menu_tooltips"); + if (!menu_tooltips) + { + // don't return immediately, fade out the active tooltip first + if (menuTooltipItem == world) + return; it = world; + menu_tooltips_old = menu_tooltips; + } + else + { + f = bound(0, frametime * 2, 1); + menuTooltipAveragedMousePos = menuTooltipAveragedMousePos * (1 - f) + menuMousePos * f; + f = vlen(menuMousePos - menuTooltipAveragedMousePos); + if(f < 0.01) + it = m_findtooltipitem(main, menuMousePos); + else + it = world; + } + fontsize = '1 0 0' * (SKINFONTSIZE_TOOLTIP / conwidth) + '0 1 0' * (SKINFONTSIZE_TOOLTIP / conheight); // float menuTooltipState; // 0: static, 1: fading in, 2: fading out if(it != menuTooltipItem) @@ -460,9 +500,11 @@ void m_tooltip(vector pos) menuTooltipItem = it; menuTooltipOrigin_x = -1; // unallocated + + menuTooltipText = strzone(gettooltip()); i = 0; - w = 0; - getWrappedLine_remaining = it.tooltip; + w = 0; + getWrappedLine_remaining = menuTooltipText; while(getWrappedLine_remaining) { s = getWrappedLine(SKINWIDTH_TOOLTIP, fontsize, draw_TextWidth_WithoutColors); @@ -489,7 +531,7 @@ void m_tooltip(vector pos) menuTooltipState = 1; if(menuTooltipItem) - if(!m_testmousetooltipbox(pos)) + if(!m_testmousetooltipbox()) menuTooltipState = 2; // fade out if mouse touches it switch(menuTooltipState) @@ -511,8 +553,14 @@ void m_tooltip(vector pos) if(menuTooltipItem) { - if(menuTooltipOrigin_x < 0) // unallocated? - m_allocatetooltipbox(pos); + if(menu_tooltips != menu_tooltips_old) + { + if (menu_tooltips != 0 && menu_tooltips_old != 0) + menuTooltipItem = world; // reload tooltip next frame + menu_tooltips_old = menu_tooltips; + } + else if(menuTooltipOrigin_x < 0) // unallocated? + m_allocatetooltipbox(menuMousePos); if(menuTooltipOrigin_x >= 0) { @@ -524,7 +572,7 @@ void m_tooltip(vector pos) p = menuTooltipOrigin; p_x += SKINMARGIN_TOOLTIP_x / conwidth; p_y += SKINMARGIN_TOOLTIP_y / conheight; - getWrappedLine_remaining = menuTooltipItem.tooltip; + getWrappedLine_remaining = menuTooltipText; while(getWrappedLine_remaining) { s = getWrappedLine(SKINWIDTH_TOOLTIP, fontsize, draw_TextWidth_WithoutColors); @@ -700,7 +748,7 @@ void() m_draw = } main.draw(main); - m_tooltip(menuMousePos); + m_tooltip(); draw_alpha = max(draw_alpha, SKINALPHA_CURSOR_INTRO * bound(0, menuLogoAlpha, 1)); @@ -834,7 +882,9 @@ void(string itemname) m_goto = } else { - e = findstring(NULL, name, itemname); + for(e = NULL; (e = findstring(e, name, itemname)); ) + if(e.classname != "vtbl") + break; if(e) { m_hide(); @@ -853,10 +903,18 @@ void() m_goto_skin_selector = m_goto("skinselector"); } +void() m_goto_language_selector = +{ + if(!menuInitialized) + return; + // TODO add code to switch back to the language selector (no idea how to do it now) + m_goto("languageselector"); +} + void() m_goto_video_settings = { if(!menuInitialized) return; - // TODO add code to switch back to the skin selector (no idea how to do it now) + // TODO add code to switch back to the video settings (no idea how to do it now) m_goto("videosettings"); }