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)
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)))
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)
{
}
}
+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;
}
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)
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)
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);
menuTooltipState = 1;
if(menuTooltipItem)
- if(!m_testmousetooltipbox(pos))
+ if(!m_testmousetooltipbox())
menuTooltipState = 2; // fade out if mouse touches it
switch(menuTooltipState)
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)
{
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);
}
main.draw(main);
- m_tooltip(menuMousePos);
+ m_tooltip();
draw_alpha = max(draw_alpha, SKINALPHA_CURSOR_INTRO * bound(0, menuLogoAlpha, 1));
}
else
{
- e = findstring(NULL, name, itemname);
+ for(e = NULL; (e = findstring(e, name, itemname)); )
+ if(e.classname != "vtbl")
+ break;
if(e)
{
m_hide();
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");
}