3 #include "xonotic/util.qh"
5 #include "../common/items/all.qh"
6 #include "../common/weapons/all.qh"
7 #include "../common/mapinfo.qh"
8 #include "../common/mutators/base.qh"
10 int mouseButtonsPressed;
18 bool menuNotTheFirstFrame;
21 float conwidth_s, conheight_s;
22 float vidwidth_s, vidheight_s, vidpixelheight_s;
23 float realconwidth, realconheight;
28 vidwidth_s = vidheight_s = vidpixelheight_s = 0; // Force updateConwidths on next draw
36 if (isserver()) gamestatus |= GAME_ISSERVER;
37 if (clientstate() == CS_CONNECTED || isdemo()) gamestatus |= GAME_CONNECTED;
38 if (cvar("developer")) gamestatus |= GAME_DEVELOPER;
43 bool restarting = false;
44 cvar_set("_menu_alpha", "0");
45 prvm_language = cvar_string("prvm_language");
46 if (prvm_language == "")
49 cvar_set("prvm_language", prvm_language);
50 localcmd("\nmenu_restart\n");
53 prvm_language = strzone(prvm_language);
54 cvar_set("_menu_prvm_language", prvm_language);
57 LOG_INFOF("^4MQC Build information: ^1%s\n", WATERMARK);
60 // list all game dirs (TEST)
61 if (cvar("developer"))
63 for (int i = 0; ; ++i)
65 string s = getgamedirinfo(i, GETGAMEDIRINFO_NAME);
67 LOG_TRACE(s, ": ", getgamedirinfo(i, GETGAMEDIRINFO_DESCRIPTION));
71 // needs to be done so early because of the constants they create
74 static_init_precache();
76 RegisterSLCategories();
78 float ddsload = cvar("r_texture_dds_load");
79 float texcomp = cvar("gl_texturecompression");
81 if (ddsload != cvar("r_texture_dds_load") || texcomp != cvar("gl_texturecompression")) localcmd("\nr_restart\n");
85 if (cvar("_menu_initialized")) // always show menu after menu_restart
88 cvar_set("_menu_initialized", "1");
92 const float MENU_ASPECT = 1280 / 1024;
94 void draw_reset_cropped()
96 draw_reset(conwidth, conheight, 0.5 * (realconwidth - conwidth), 0.5 * (realconheight - conheight));
98 void draw_reset_full()
100 draw_reset(realconwidth, realconheight, 0, 0);
103 void UpdateConWidthHeight(float w, float h, float p)
105 if (w != vidwidth_s || h != vidheight_s || p != vidpixelheight_s)
107 if (updateConwidths(w, h, p)) localcmd(sprintf("\nexec %s\n", cvar_string("menu_font_cfg")));
110 vidpixelheight_s = p;
112 conwidth_s = conwidth;
113 conheight_s = conheight;
114 realconwidth = cvar("vid_conwidth");
115 realconheight = cvar("vid_conheight");
116 if (realconwidth / realconheight > MENU_ASPECT)
119 conwidth = realconheight * MENU_ASPECT;
120 conheight = realconheight;
125 conwidth = realconwidth;
126 conheight = realconwidth / MENU_ASPECT;
130 if (conwidth_s != conwidth || conheight_s != conheight)
132 draw_reset_cropped();
133 main.resizeNotify(main, '0 0 0', eX * conwidth + eY * conheight, '0 0 0', eX * conwidth + eY * conheight);
138 vidwidth_s = vidheight_s = vidpixelheight_s = 0; // retry next frame
142 string m_goto_buffer;
143 void m_init_delayed()
145 draw_reset_cropped();
147 menuInitialized = false;
148 if (!preMenuInit()) return;
149 menuInitialized = true;
152 if (cvar_string("menu_skin") != "")
154 draw_currentSkin = strcat("gfx/menu/", cvar_string("menu_skin"));
155 fh = fopen(language_filename(strcat(draw_currentSkin, "/skinvalues.txt")), FILE_READ);
157 if (fh < 0 && cvar_defstring("menu_skin") != "")
159 cvar_set("menu_skin", cvar_defstring("menu_skin"));
160 draw_currentSkin = strcat("gfx/menu/", cvar_string("menu_skin"));
161 fh = fopen(language_filename(strcat(draw_currentSkin, "/skinvalues.txt")), FILE_READ);
165 draw_currentSkin = "gfx/menu/default";
166 fh = fopen(language_filename(strcat(draw_currentSkin, "/skinvalues.txt")), FILE_READ);
168 if (fh < 0) error("cannot load any menu skin\n");
169 draw_currentSkin = strzone(draw_currentSkin);
170 for (string s; (s = fgets(fh)); )
172 // these two are handled by skinlist.qc
173 if (substring(s, 0, 6) == "title ") continue;
174 if (substring(s, 0, 7) == "author ") continue;
175 int n = tokenize_console(s);
177 Skin_ApplySetting(argv(0), substring(s, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)));
181 int glob = search_begin(strcat(draw_currentSkin, "/*.tga"), true, true);
184 for (int i = 0, n = search_getsize(glob); i < n; ++i)
185 precache_pic(search_getfilename(glob, i));
189 draw_setMousePointer(SKINGFX_CURSOR, SKINSIZE_CURSOR, SKINOFFSET_CURSOR);
191 anim = NEW(AnimHost);
192 main = NEW(MainWindow);
193 main.configureMainWindow(main);
195 main.resizeNotify(main, '0 0 0', eX * conwidth + eY * conheight, '0 0 0', eX * conwidth + eY * conheight);
198 menuMousePos = '0.5 0.5 0';
204 m_goto(m_goto_buffer);
205 strunzone(m_goto_buffer);
206 m_goto_buffer = string_null;
209 if (Menu_Active) m_display(); // delayed menu display
212 void m_keyup(float key, float ascii)
214 if (!menuInitialized) return;
215 if (!Menu_Active) return;
216 draw_reset_cropped();
217 main.keyUp(main, key, ascii, menuShiftState);
218 if (key >= K_MOUSE1 && key <= K_MOUSE3)
220 --mouseButtonsPressed;
221 if (!mouseButtonsPressed) main.mouseRelease(main, menuMousePos);
222 if (mouseButtonsPressed < 0)
224 mouseButtonsPressed = 0;
225 LOG_TRACE("Warning: released an already released button\n");
228 if (key == K_ALT) menuShiftState &= ~S_ALT;
229 if (key == K_CTRL) menuShiftState &= ~S_CTRL;
230 if (key == K_SHIFT) menuShiftState &= ~S_SHIFT;
233 void m_keydown(float key, float ascii)
235 if (!menuInitialized) return;
236 if (!Menu_Active) return;
238 if (menuMouseMode && key >= K_MOUSE1 && key <= K_MOUSE3)
240 // detect a click outside of the game window
241 vector p = getmousepos();
242 if (p.x < 0 || p.x > realconwidth || p.y < 0 || p.y > realconheight)
244 ++mouseButtonsPressed;
251 entity e = keyGrabber;
253 e.keyGrabbed(e, key, ascii);
257 draw_reset_cropped();
258 if (!mouseButtonsPressed && key >= K_MOUSE1 && key <= K_MOUSE3) main.mousePress(main, menuMousePos);
259 if (!main.keyDown(main, key, ascii, menuShiftState))
261 // disable menu on unhandled ESC
263 if (gamestatus & (GAME_ISSERVER | GAME_CONNECTED)) // don't back out to console only
267 if (key >= K_MOUSE1 && key <= K_MOUSE3)
269 ++mouseButtonsPressed;
270 if (mouseButtonsPressed > 10)
272 mouseButtonsPressed = 10;
273 LOG_TRACE("Warning: pressed an already pressed button\n");
276 if (key == K_ALT) menuShiftState |= S_ALT;
277 if (key == K_CTRL) menuShiftState |= S_CTRL;
278 if (key == K_SHIFT) menuShiftState |= S_SHIFT;
288 void draw_Picture_Aligned(vector algn, float scalemode, string img, float a)
290 vector sz = draw_PictureSize(img);
291 bool width_is_larger = (sz.x * draw_scale.y >= sz.y * draw_scale.x);
292 vector isz_w = '1 0 0' + '0 1 0' * ((sz.y / sz.x) * (draw_scale.x / draw_scale.y));
293 vector isz_h = '0 1 0' + '1 0 0' * ((sz.x / sz.y) * (draw_scale.y / draw_scale.x));
299 isz = (width_is_larger ? isz_h : isz_w);
301 case SCALEMODE_LETTERBOX:
302 isz = (width_is_larger ? isz_w : isz_h);
304 case SCALEMODE_WIDTH:
307 case SCALEMODE_HEIGHT:
310 case SCALEMODE_STRETCH:
314 vector org = eX * (algn.x * (1 - isz.x)) + eY * (algn.y * (1 - isz.y));
315 draw_Picture(org, img, isz, '1 1 1', a);
318 void drawBackground(string img, float a, string algn, float force1)
320 if (main.mainNexposee.ModalController_state == 0) return;
322 int scalemode = SCALEMODE_CROP;
323 for (int i = 0, l = 0; i < strlen(algn); ++i)
325 string c = substring(algn, i, 1);
329 scalemode = SCALEMODE_CROP;
332 scalemode = SCALEMODE_LETTERBOX;
335 scalemode = SCALEMODE_HEIGHT;
338 scalemode = SCALEMODE_WIDTH;
341 scalemode = SCALEMODE_STRETCH;
343 case "1": case "4": case "7":
346 case "2": case "5": case "8":
349 case "3": case "6": case "9":
358 case "7": case "8": case "9":
361 case "4": case "5": case "6":
364 case "1": case "2": case "3":
373 draw_Picture_Aligned(v, scalemode, img, a);
377 // force all secondary layers to use alpha 1. Prevents ugly issues
378 // with overlap. It's a flag because it cannot be used for the
380 draw_Picture_Aligned(v, scalemode, strcat(img, "_l", ftos(l + 1)), 1);
384 draw_Picture_Aligned(v, scalemode, strcat(img, "_l", ftos(l + 1)), a);
392 int menu_tooltips_old;
393 vector menuTooltipAveragedMousePos;
394 entity menuTooltipItem;
395 vector menuTooltipOrigin;
396 vector menuTooltipSize;
397 float menuTooltipAlpha;
398 string menuTooltipText;
399 int menuTooltipState; // 0: static, 1: fading in, 2: fading out, 3: forced fading out
400 bool m_testmousetooltipbox(vector pos)
403 (pos.x >= menuTooltipOrigin.x && pos.x < menuTooltipOrigin.x + menuTooltipSize.x)
404 && (pos.y >= menuTooltipOrigin.y && pos.y < menuTooltipOrigin.y + menuTooltipSize.y)
407 bool m_testtooltipbox(vector tooltippos)
409 if (tooltippos.x < 0) return false;
410 if (tooltippos.y < 0) return false;
411 if (tooltippos.x + menuTooltipSize.x > 1) return false;
412 if (tooltippos.y + menuTooltipSize.y > 1) return false;
413 menuTooltipOrigin = tooltippos;
416 bool m_allocatetooltipbox(vector pos)
419 avoidplus.x = (SKINAVOID_TOOLTIP_x + SKINSIZE_CURSOR_x - SKINOFFSET_CURSOR_x * SKINSIZE_CURSOR_x) / conwidth;
420 avoidplus.y = (SKINAVOID_TOOLTIP_y + SKINSIZE_CURSOR_y - SKINOFFSET_CURSOR_y * SKINSIZE_CURSOR_y) / conheight;
424 avoidminus.x = (SKINAVOID_TOOLTIP_x + SKINOFFSET_CURSOR_x * SKINSIZE_CURSOR_x) / conwidth + menuTooltipSize.x;
425 avoidminus.y = (SKINAVOID_TOOLTIP_y + SKINOFFSET_CURSOR_y * SKINSIZE_CURSOR_y) / conheight + menuTooltipSize.y;
429 vector v = pos + avoidplus;
430 if (m_testtooltipbox(v)) return true;
433 v.x = pos.x - menuTooltipSize.x * 0.5;
434 if (m_testtooltipbox(v)) return true;
437 v.x = pos.x - avoidminus.x;
438 if (m_testtooltipbox(v)) return true;
441 v.y = pos.y - avoidminus.y;
442 if (m_testtooltipbox(v)) return true;
445 v.x = pos.x - menuTooltipSize.x * 0.5;
446 if (m_testtooltipbox(v)) return true;
449 v.x = pos.x + avoidplus.x;
450 if (m_testtooltipbox(v)) return true;
454 entity m_findtooltipitem(entity root, vector pos)
457 for (entity it = root; it.instanceOfContainer; )
459 while (it.instanceOfNexposee && it.focusedChild)
461 it = it.focusedChild;
462 pos = globalToBox(pos, it.Container_origin, it.Container_size);
464 if (it.instanceOfNexposee)
466 it = it.itemFromPoint(it, pos);
467 if (it.tooltip) best = it;
468 else if (menu_tooltips == 2 && (it.cvarName || it.onClickCommand)) best = it;
471 else if (it.instanceOfModalController)
473 it = it.focusedChild;
477 it = it.itemFromPoint(it, pos);
480 if (it.tooltip) best = it;
481 else if (menu_tooltips == 2 && (it.cvarName || it.onClickCommand)) best = it;
482 pos = globalToBox(pos, it.Container_origin, it.Container_size);
489 if (menu_tooltips == 2)
492 if (menuTooltipItem.cvarName)
494 if (getCvarsMulti(menuTooltipItem)) s =
495 strcat("[", menuTooltipItem.cvarName, " ", getCvarsMulti(menuTooltipItem), "]");
496 else s = strcat("[", menuTooltipItem.cvarName, "]");
498 else if (menuTooltipItem.onClickCommand)
500 s = strcat("<", menuTooltipItem.onClickCommand, ">");
504 return menuTooltipItem.tooltip;
506 if (menuTooltipItem.tooltip) return strcat(menuTooltipItem.tooltip, " ", s);
509 return menuTooltipItem.tooltip;
511 void m_tooltip(vector pos)
513 static string prev_tooltip;
515 menu_tooltips = cvar("menu_tooltips");
518 // don't return immediately, fade out the active tooltip first
519 if (menuTooltipItem == NULL) return;
521 menu_tooltips_old = menu_tooltips;
525 float f = bound(0, frametime * 2, 1);
526 menuTooltipAveragedMousePos = menuTooltipAveragedMousePos * (1 - f) + pos * f;
527 f = vlen(pos - menuTooltipAveragedMousePos);
530 it = m_findtooltipitem(main, pos);
532 if (it.instanceOfListBox && it.isScrolling(it)) it = world;
534 if (it && prev_tooltip != it.tooltip)
536 // fade out if tooltip of a certain item has changed
537 menuTooltipState = 3;
538 if (prev_tooltip) strunzone(prev_tooltip);
539 prev_tooltip = strzone(it.tooltip);
541 else if (menuTooltipItem && !m_testmousetooltipbox(pos))
543 menuTooltipState = 3; // fade out if mouse touches it
551 vector fontsize = '1 0 0' * (SKINFONTSIZE_TOOLTIP / conwidth) + '0 1 0' * (SKINFONTSIZE_TOOLTIP / conheight);
553 // float menuTooltipState; // 0: static, 1: fading in, 2: fading out, 3: forced fading out
554 if (it != menuTooltipItem)
556 switch (menuTooltipState)
561 // another item: fade out first
562 menuTooltipState = 2;
567 menuTooltipState = 1;
568 menuTooltipItem = it;
570 menuTooltipOrigin.x = -1; // unallocated
572 if (menuTooltipText) strunzone(menuTooltipText);
573 menuTooltipText = strzone(gettooltip());
577 for (getWrappedLine_remaining = menuTooltipText; getWrappedLine_remaining; ++i)
579 string s = getWrappedLine(SKINWIDTH_TOOLTIP, fontsize, draw_TextWidth_WithoutColors);
580 float f = draw_TextWidth(s, false, fontsize);
583 menuTooltipSize.x = w + 2 * (SKINMARGIN_TOOLTIP_x / conwidth);
584 menuTooltipSize.y = i * fontsize.y + 2 * (SKINMARGIN_TOOLTIP_y / conheight);
585 menuTooltipSize.z = 0;
589 // changing item while fading in: fade out first
590 menuTooltipState = 2;
593 // changing item while fading out: can't
597 else if (menuTooltipState == 2) // re-fade in?
599 menuTooltipState = 1;
602 switch (menuTooltipState)
605 menuTooltipAlpha = bound(0, menuTooltipAlpha + 5 * frametime, 1);
606 if (menuTooltipAlpha == 1) menuTooltipState = 0;
609 case 3: // forced fade out
610 menuTooltipAlpha = bound(0, menuTooltipAlpha - 2 * frametime, 1);
611 if (menuTooltipAlpha == 0)
613 menuTooltipState = 0;
614 menuTooltipItem = NULL;
619 if (menuTooltipItem == NULL)
623 strunzone(menuTooltipText);
624 menuTooltipText = string_null;
630 if (menu_tooltips != menu_tooltips_old)
632 if (menu_tooltips != 0 && menu_tooltips_old != 0) menuTooltipItem = NULL; // reload tooltip next frame
633 menu_tooltips_old = menu_tooltips;
635 else if (menuTooltipOrigin.x < 0) // unallocated?
637 m_allocatetooltipbox(pos);
639 if (menuTooltipOrigin.x >= 0)
642 vector p = SKINBORDER_TOOLTIP;
644 p.y *= 1 / conheight;
645 draw_BorderPicture(menuTooltipOrigin, SKINGFX_TOOLTIP, menuTooltipSize, '1 1 1', menuTooltipAlpha, p);
646 p = menuTooltipOrigin;
647 p.x += SKINMARGIN_TOOLTIP_x / conwidth;
648 p.y += SKINMARGIN_TOOLTIP_y / conheight;
649 for (getWrappedLine_remaining = menuTooltipText; getWrappedLine_remaining; p.y += fontsize.y)
651 string s = getWrappedLine(SKINWIDTH_TOOLTIP, fontsize, draw_TextWidth_WithoutColors);
652 draw_Text(p, s, fontsize, SKINCOLOR_TOOLTIP, SKINALPHA_TOOLTIP * menuTooltipAlpha, false);
658 void m_draw(float width, float height)
662 execute_next_frame();
664 menuMouseMode = cvar("menu_mouse_absolute");
666 if (anim) anim.tickAll(anim);
668 UpdateConWidthHeight(width, height, cvar("vid_pixelheight"));
670 if (!menuInitialized)
672 // TODO draw an info image about this situation
676 if (!menuNotTheFirstFrame)
678 menuNotTheFirstFrame = true;
679 if (Menu_Active && !cvar("menu_video_played"))
681 localcmd("cd loop $menu_cdtrack; play sound/announcer/default/welcome.wav\n");
682 menuLogoAlpha = -0.8; // no idea why, but when I start this at zero, it jumps instead of fading FIXME
684 // ALWAYS set this cvar; if we start but menu is not active, this means we want no background music!
685 localcmd("set menu_video_played 1\n");
689 float realFrametime = frametime = min(0.2, t - menuPrevTime);
693 t = cvar("menu_slowmo");
706 if (getmousetarget() == (menuMouseMode ? MT_CLIENT : MT_MENU)
707 && (getkeydest() == KEY_MENU || getkeydest() == KEY_MENU_GRABBED))
708 setkeydest(keyGrabber ? KEY_MENU_GRABBED : KEY_MENU);
712 if (cvar("cl_capturevideo")) frametime = t / cvar("cl_capturevideo_fps"); // make capturevideo work smoothly
714 prevMenuAlpha = menuAlpha;
717 if (menuAlpha == 0 && menuLogoAlpha < 2)
719 menuLogoAlpha += 2 * frametime;
723 menuAlpha = min(1, menuAlpha + 5 * frametime);
729 menuAlpha = max(0, menuAlpha - 5 * frametime);
733 draw_reset_cropped();
735 if (!(gamestatus & (GAME_CONNECTED | GAME_ISSERVER)))
737 if (menuLogoAlpha > 0)
740 draw_Fill('0 0 0', '1 1 0', SKINCOLOR_BACKGROUND, 1);
741 drawBackground(SKINGFX_BACKGROUND, bound(0, menuLogoAlpha, 1), SKINALIGN_BACKGROUND, true);
742 draw_reset_cropped();
743 if (menuAlpha <= 0 && SKINALPHA_CURSOR_INTRO > 0)
745 draw_alpha = SKINALPHA_CURSOR_INTRO * bound(0, menuLogoAlpha, 1);
746 draw_drawMousePointer(menuMousePos);
751 else if (SKINALPHA_BACKGROUND_INGAME)
756 drawBackground(SKINGFX_BACKGROUND_INGAME, menuAlpha * SKINALPHA_BACKGROUND_INGAME,
757 SKINALIGN_BACKGROUND_INGAME, false);
758 draw_reset_cropped();
762 if (menuAlpha != prevMenuAlpha) cvar_set("_menu_alpha", ftos(menuAlpha));
764 draw_reset_cropped();
766 draw_reset_cropped();
770 if (prevMenuAlpha > 0) main.initializeDialog(main, main.firstChild);
771 draw_reset_cropped();
776 draw_alpha *= menuAlpha;
780 // do not update mouse position
781 // it prevents mouse jumping to '0 0 0' when menu is fading out
783 else if (menuMouseMode)
785 vector newMouse = globalToBox(getmousepos(), draw_shift, draw_scale);
786 if (newMouse != '0 0 0' && newMouse != menuMousePos)
788 menuMousePos = newMouse;
789 if (mouseButtonsPressed) main.mouseDrag(main, menuMousePos);
790 else main.mouseMove(main, menuMousePos);
793 else if (frametime > 0)
795 vector dMouse = getmousepos() * (frametime / realFrametime); // for capturevideo
796 if (dMouse != '0 0 0')
798 vector minpos = globalToBox('0 0 0', draw_shift, draw_scale);
799 vector maxpos = globalToBox(eX * (realconwidth - 1) + eY * (realconheight - 1), draw_shift, draw_scale);
800 dMouse = globalToBoxSize(dMouse, draw_scale);
801 menuMousePos += dMouse * cvar("menu_mouse_speed");
802 menuMousePos.x = bound(minpos.x, menuMousePos.x, maxpos.x);
803 menuMousePos.y = bound(minpos.y, menuMousePos.y, maxpos.y);
804 if (mouseButtonsPressed) main.mouseDrag(main, menuMousePos);
805 else main.mouseMove(main, menuMousePos);
810 m_tooltip(menuMousePos);
812 draw_alpha = max(draw_alpha, SKINALPHA_CURSOR_INTRO * bound(0, menuLogoAlpha, 1));
814 draw_drawMousePointer(menuMousePos);
816 draw_reset_cropped();
825 setkeydest(KEY_MENU);
826 setmousetarget((menuMouseMode ? MT_CLIENT : MT_MENU));
828 if (!menuInitialized) return;
830 if (mouseButtonsPressed) main.mouseRelease(main, menuMousePos);
831 mouseButtonsPressed = 0;
833 main.focusEnter(main);
834 main.showNotify(main);
840 setkeydest(KEY_GAME);
841 setmousetarget(MT_CLIENT);
843 if (!menuInitialized) return;
845 main.focusLeave(main);
846 main.hideNotify(main);
849 void m_toggle(int mode)
853 if (mode == 1) return;
858 if (mode == 0) return;
866 FOREACH_ENTITY_ORDERED(it.destroy, LAMBDA(
867 if (it.classname == "vtbl") continue;
872 void m_focus_item_chain(entity outermost, entity innermost)
874 if (innermost.parent != outermost) m_focus_item_chain(outermost, innermost.parent);
875 innermost.parent.setFocus(innermost.parent, innermost);
878 void m_activate_window(entity wnd)
880 entity par = wnd.parent;
881 if (par) m_activate_window(par);
883 if (par.instanceOfModalController)
885 if (wnd.tabSelectingButton)
887 TabButton_Click(wnd.tabSelectingButton, wnd);
890 par.initializeDialog(par, wnd);
892 else if (par.instanceOfNexposee)
894 // nexposee (sorry for violating abstraction here)
895 par.selectedChild = wnd;
896 par.animationState = 1;
897 Container_setFocus(par, NULL);
899 else if (par.instanceOfContainer)
902 if (par.focused) par.setFocus(par, wnd);
906 void m_setpointerfocus(entity wnd)
908 if (!wnd.instanceOfContainer) return;
909 entity focus = wnd.preferredFocusedGrandChild(wnd);
911 menuMousePos = focus.origin + 0.5 * focus.size;
912 menuMousePos.x *= 1 / conwidth;
913 menuMousePos.y *= 1 / conheight;
914 entity par = wnd.parent;
915 if (par.focused) par.setFocus(par, wnd);
916 if (wnd.focused) m_focus_item_chain(wnd, focus);
919 void m_goto(string itemname)
921 if (!menuInitialized)
923 if (m_goto_buffer) strunzone(m_goto_buffer);
924 m_goto_buffer = strzone(itemname);
927 if (itemname == "") // this can be called by GameCommand
929 if (gamestatus & (GAME_ISSERVER | GAME_CONNECTED))
935 m_activate_window(main.mainNexposee);
942 for (e = NULL; (e = find(e, name, itemname)); )
943 if (e.classname != "vtbl") break;
945 if ((e) && (!e.requiresConnection || (gamestatus & (GAME_ISSERVER | GAME_CONNECTED))))
948 m_activate_window(e);
949 m_setpointerfocus(e);
955 void m_play_focus_sound()
957 static float menuLastFocusSoundTime;
958 if (cvar("menu_sounds") < 2) return;
959 if (time - menuLastFocusSoundTime <= 0.25) return;
960 localsound(MENU_SOUND_FOCUS);
961 menuLastFocusSoundTime = time;
964 void m_play_click_sound(string soundfile)
966 if (!cvar("menu_sounds")) return;
967 localsound(soundfile);