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(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(strcat(draw_currentSkin, "/skinvalues.txt"), FILE_READ);
165 draw_currentSkin = "gfx/menu/default";
166 fh = fopen(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 if (vdist(pos - menuTooltipAveragedMousePos, <, 0.01))
529 it = m_findtooltipitem(main, pos);
531 if (it.instanceOfListBox && it.isScrolling(it)) it = world;
533 if (it && prev_tooltip != it.tooltip)
535 // fade out if tooltip of a certain item has changed
536 menuTooltipState = 3;
537 if (prev_tooltip) strunzone(prev_tooltip);
538 prev_tooltip = strzone(it.tooltip);
540 else if (menuTooltipItem && !m_testmousetooltipbox(pos))
542 menuTooltipState = 3; // fade out if mouse touches it
550 vector fontsize = '1 0 0' * (SKINFONTSIZE_TOOLTIP / conwidth) + '0 1 0' * (SKINFONTSIZE_TOOLTIP / conheight);
552 // float menuTooltipState; // 0: static, 1: fading in, 2: fading out, 3: forced fading out
553 if (it != menuTooltipItem)
555 switch (menuTooltipState)
560 // another item: fade out first
561 menuTooltipState = 2;
566 menuTooltipState = 1;
567 menuTooltipItem = it;
569 menuTooltipOrigin.x = -1; // unallocated
571 if (menuTooltipText) strunzone(menuTooltipText);
572 menuTooltipText = strzone(gettooltip());
576 for (getWrappedLine_remaining = menuTooltipText; getWrappedLine_remaining; ++i)
578 string s = getWrappedLine(SKINWIDTH_TOOLTIP, fontsize, draw_TextWidth_WithoutColors);
579 float f = draw_TextWidth(s, false, fontsize);
582 menuTooltipSize.x = w + 2 * (SKINMARGIN_TOOLTIP_x / conwidth);
583 menuTooltipSize.y = i * fontsize.y + 2 * (SKINMARGIN_TOOLTIP_y / conheight);
584 menuTooltipSize.z = 0;
588 // changing item while fading in: fade out first
589 menuTooltipState = 2;
592 // changing item while fading out: can't
596 else if (menuTooltipState == 2) // re-fade in?
598 menuTooltipState = 1;
601 switch (menuTooltipState)
604 menuTooltipAlpha = bound(0, menuTooltipAlpha + 5 * frametime, 1);
605 if (menuTooltipAlpha == 1) menuTooltipState = 0;
608 case 3: // forced fade out
609 menuTooltipAlpha = bound(0, menuTooltipAlpha - 2 * frametime, 1);
610 if (menuTooltipAlpha == 0)
612 menuTooltipState = 0;
613 menuTooltipItem = NULL;
618 if (menuTooltipItem == NULL)
622 strunzone(menuTooltipText);
623 menuTooltipText = string_null;
629 if (menu_tooltips != menu_tooltips_old)
631 if (menu_tooltips != 0 && menu_tooltips_old != 0) menuTooltipItem = NULL; // reload tooltip next frame
632 menu_tooltips_old = menu_tooltips;
634 else if (menuTooltipOrigin.x < 0) // unallocated?
636 m_allocatetooltipbox(pos);
638 if (menuTooltipOrigin.x >= 0)
641 vector p = SKINBORDER_TOOLTIP;
643 p.y *= 1 / conheight;
644 draw_BorderPicture(menuTooltipOrigin, SKINGFX_TOOLTIP, menuTooltipSize, '1 1 1', menuTooltipAlpha, p);
645 p = menuTooltipOrigin;
646 p.x += SKINMARGIN_TOOLTIP_x / conwidth;
647 p.y += SKINMARGIN_TOOLTIP_y / conheight;
648 for (getWrappedLine_remaining = menuTooltipText; getWrappedLine_remaining; p.y += fontsize.y)
650 string s = getWrappedLine(SKINWIDTH_TOOLTIP, fontsize, draw_TextWidth_WithoutColors);
651 draw_Text(p, s, fontsize, SKINCOLOR_TOOLTIP, SKINALPHA_TOOLTIP * menuTooltipAlpha, false);
657 void m_draw(float width, float height)
661 execute_next_frame();
663 menuMouseMode = cvar("menu_mouse_absolute");
665 if (anim) anim.tickAll(anim);
667 UpdateConWidthHeight(width, height, cvar("vid_pixelheight"));
669 if (!menuInitialized)
671 // TODO draw an info image about this situation
675 if (!menuNotTheFirstFrame)
677 menuNotTheFirstFrame = true;
678 if (Menu_Active && !cvar("menu_video_played"))
680 localcmd("cd loop $menu_cdtrack; play sound/announcer/default/welcome.wav\n");
681 menuLogoAlpha = -0.8; // no idea why, but when I start this at zero, it jumps instead of fading FIXME
683 // ALWAYS set this cvar; if we start but menu is not active, this means we want no background music!
684 localcmd("set menu_video_played 1\n");
688 float realFrametime = frametime = min(0.2, t - menuPrevTime);
692 t = cvar("menu_slowmo");
705 if (getmousetarget() == (menuMouseMode ? MT_CLIENT : MT_MENU)
706 && (getkeydest() == KEY_MENU || getkeydest() == KEY_MENU_GRABBED))
707 setkeydest(keyGrabber ? KEY_MENU_GRABBED : KEY_MENU);
711 if (cvar("cl_capturevideo")) frametime = t / cvar("cl_capturevideo_fps"); // make capturevideo work smoothly
713 prevMenuAlpha = menuAlpha;
716 if (menuAlpha == 0 && menuLogoAlpha < 2)
718 menuLogoAlpha += 2 * frametime;
722 menuAlpha = min(1, menuAlpha + 5 * frametime);
728 menuAlpha = max(0, menuAlpha - 5 * frametime);
732 draw_reset_cropped();
734 if (!(gamestatus & (GAME_CONNECTED | GAME_ISSERVER)))
736 if (menuLogoAlpha > 0)
739 draw_Fill('0 0 0', '1 1 0', SKINCOLOR_BACKGROUND, 1);
740 drawBackground(SKINGFX_BACKGROUND, bound(0, menuLogoAlpha, 1), SKINALIGN_BACKGROUND, true);
741 draw_reset_cropped();
742 if (menuAlpha <= 0 && SKINALPHA_CURSOR_INTRO > 0)
744 draw_alpha = SKINALPHA_CURSOR_INTRO * bound(0, menuLogoAlpha, 1);
745 draw_drawMousePointer(menuMousePos);
750 else if (SKINALPHA_BACKGROUND_INGAME)
755 drawBackground(SKINGFX_BACKGROUND_INGAME, menuAlpha * SKINALPHA_BACKGROUND_INGAME,
756 SKINALIGN_BACKGROUND_INGAME, false);
757 draw_reset_cropped();
761 if (menuAlpha != prevMenuAlpha) cvar_set("_menu_alpha", ftos(menuAlpha));
763 draw_reset_cropped();
765 draw_reset_cropped();
769 if (prevMenuAlpha > 0) main.initializeDialog(main, main.firstChild);
770 draw_reset_cropped();
775 draw_alpha *= menuAlpha;
779 // do not update mouse position
780 // it prevents mouse jumping to '0 0 0' when menu is fading out
782 else if (menuMouseMode)
784 vector newMouse = globalToBox(getmousepos(), draw_shift, draw_scale);
785 if (newMouse != '0 0 0' && newMouse != menuMousePos)
787 menuMousePos = newMouse;
788 if (mouseButtonsPressed) main.mouseDrag(main, menuMousePos);
789 else main.mouseMove(main, menuMousePos);
792 else if (frametime > 0)
794 vector dMouse = getmousepos() * (frametime / realFrametime); // for capturevideo
795 if (dMouse != '0 0 0')
797 vector minpos = globalToBox('0 0 0', draw_shift, draw_scale);
798 vector maxpos = globalToBox(eX * (realconwidth - 1) + eY * (realconheight - 1), draw_shift, draw_scale);
799 dMouse = globalToBoxSize(dMouse, draw_scale);
800 menuMousePos += dMouse * cvar("menu_mouse_speed");
801 menuMousePos.x = bound(minpos.x, menuMousePos.x, maxpos.x);
802 menuMousePos.y = bound(minpos.y, menuMousePos.y, maxpos.y);
803 if (mouseButtonsPressed) main.mouseDrag(main, menuMousePos);
804 else main.mouseMove(main, menuMousePos);
809 m_tooltip(menuMousePos);
811 draw_alpha = max(draw_alpha, SKINALPHA_CURSOR_INTRO * bound(0, menuLogoAlpha, 1));
813 draw_drawMousePointer(menuMousePos);
815 draw_reset_cropped();
824 setkeydest(KEY_MENU);
825 setmousetarget((menuMouseMode ? MT_CLIENT : MT_MENU));
827 if (!menuInitialized) return;
829 if (mouseButtonsPressed) main.mouseRelease(main, menuMousePos);
830 mouseButtonsPressed = 0;
832 main.focusEnter(main);
833 main.showNotify(main);
839 setkeydest(KEY_GAME);
840 setmousetarget(MT_CLIENT);
842 if (!menuInitialized) return;
844 main.focusLeave(main);
845 main.hideNotify(main);
848 void m_toggle(int mode)
852 if (mode == 1) return;
857 if (mode == 0) return;
865 FOREACH_ENTITY_ORDERED(it.destroy, LAMBDA(
866 if (it.classname == "vtbl") continue;
871 void m_focus_item_chain(entity outermost, entity innermost)
873 if (innermost.parent != outermost) m_focus_item_chain(outermost, innermost.parent);
874 innermost.parent.setFocus(innermost.parent, innermost);
877 void m_activate_window(entity wnd)
879 entity par = wnd.parent;
880 if (par) m_activate_window(par);
882 if (par.instanceOfModalController)
884 if (wnd.tabSelectingButton)
886 TabButton_Click(wnd.tabSelectingButton, wnd);
889 par.initializeDialog(par, wnd);
891 else if (par.instanceOfNexposee)
893 // nexposee (sorry for violating abstraction here)
894 par.selectedChild = wnd;
895 par.animationState = 1;
896 Container_setFocus(par, NULL);
898 else if (par.instanceOfContainer)
901 if (par.focused) par.setFocus(par, wnd);
905 void m_setpointerfocus(entity wnd)
907 if (!wnd.instanceOfContainer) return;
908 entity focus = wnd.preferredFocusedGrandChild(wnd);
910 menuMousePos = focus.origin + 0.5 * focus.size;
911 menuMousePos.x *= 1 / conwidth;
912 menuMousePos.y *= 1 / conheight;
913 entity par = wnd.parent;
914 if (par.focused) par.setFocus(par, wnd);
915 if (wnd.focused) m_focus_item_chain(wnd, focus);
918 void m_goto(string itemname)
920 if (!menuInitialized)
922 if (m_goto_buffer) strunzone(m_goto_buffer);
923 m_goto_buffer = strzone(itemname);
926 if (itemname == "") // this can be called by GameCommand
928 if (gamestatus & (GAME_ISSERVER | GAME_CONNECTED))
934 m_activate_window(main.mainNexposee);
941 for (e = NULL; (e = find(e, name, itemname)); )
942 if (e.classname != "vtbl") break;
944 if ((e) && (!e.requiresConnection || (gamestatus & (GAME_ISSERVER | GAME_CONNECTED))))
947 m_activate_window(e);
948 m_setpointerfocus(e);
954 void m_play_focus_sound()
956 static float menuLastFocusSoundTime;
957 if (cvar("menu_sounds") < 2) return;
958 if (time - menuLastFocusSoundTime <= 0.25) return;
959 localsound(MENU_SOUND_FOCUS);
960 menuLastFocusSoundTime = time;
963 void m_play_click_sound(string soundfile)
965 if (!cvar("menu_sounds")) return;
966 localsound(soundfile);