1 ///////////////////////////////////////////////
3 ///////////////////////
4 // This file belongs to dpmod/darkplaces
5 // AK contains all menu functions (especially the required ones)
6 ///////////////////////////////////////////////
8 float mouseButtonsPressed;
15 float menuInitialized;
16 float menuNotTheFirstFrame;
19 float conwidth_s, conheight_s, vidwidth_s, vidheight_s, vidpixelheight_s,
20 realconwidth, realconheight, screenconwidth, screenconheight;
25 vidwidth_s = vidheight_s = vidpixelheight_s = 0; // Force updateConwidths on next draw.
34 gamestatus = gamestatus | GAME_ISSERVER;
35 if(clientstate() == CS_CONNECTED || isdemo())
36 gamestatus = gamestatus | GAME_CONNECTED;
38 gamestatus = gamestatus | GAME_DEVELOPER;
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);
56 check_unacceptable_compiler_bugs();
59 print(sprintf(_("^4MQC Build information: ^1%s\n"), WATERMARK));
62 // list all game dirs (TEST)
69 s = getgamedirinfo(i, GETGAMEDIRINFO_NAME);
72 dprint(s, ": ", getgamedirinfo(i, GETGAMEDIRINFO_DESCRIPTION));
76 // needs to be done so early because of the constants they create
77 CALL_ACCUMULATED_FUNCTION(RegisterWeapons);
78 CALL_ACCUMULATED_FUNCTION(RegisterGametypes);
80 float ddsload = cvar("r_texture_dds_load");
81 float texcomp = cvar("gl_texturecompression");
83 if(ddsload != cvar("r_texture_dds_load") || texcomp != cvar("gl_texturecompression"))
84 localcmd("\nr_restart\n");
88 if(cvar("_menu_initialized")) // always show menu after menu_restart
92 cvar_set("_menu_initialized", "1");
96 const float MENU_ASPECT = 1.25; // 1280x1024
97 const float MENU_MINHEIGHT = 600;
99 void draw_reset_cropped()
101 draw_reset(screenconwidth, screenconheight, 0.5 * (realconwidth - screenconwidth), 0.5 * (realconheight - screenconheight));
103 void draw_reset_full()
105 draw_reset(realconwidth, realconheight, 0, 0);
108 void UpdateConWidthHeight(float w, float h, float p)
110 if (w != vidwidth_s || h != vidheight_s || p != vidpixelheight_s)
112 updateConwidths(w, h, p);
115 vidpixelheight_s = p;
117 conwidth_s = conwidth;
118 conheight_s = conheight;
119 realconwidth = cvar("vid_conwidth");
120 realconheight = cvar("vid_conheight");
121 if(realconwidth / realconheight > MENU_ASPECT)
124 conwidth = realconheight * MENU_ASPECT;
125 conheight = realconheight;
130 conwidth = realconwidth;
131 conheight = realconwidth / MENU_ASPECT;
133 screenconwidth = conwidth;
134 screenconheight = conheight;
135 if(conwidth < MENU_MINHEIGHT * MENU_ASPECT)
137 conheight *= MENU_MINHEIGHT * MENU_ASPECT / conwidth;
138 conwidth = MENU_MINHEIGHT * MENU_ASPECT;
140 if(conheight < MENU_MINHEIGHT)
142 conwidth *= MENU_MINHEIGHT / conheight;
143 conheight = MENU_MINHEIGHT;
147 if(conwidth_s != conwidth || conheight_s != conheight)
149 draw_reset_cropped();
150 main.resizeNotify(main, '0 0 0', eX * conwidth + eY * conheight, '0 0 0', eX * conwidth + eY * conheight);
155 vidwidth_s = vidheight_s = vidpixelheight_s = 0; // retry next frame
159 string m_goto_buffer;
160 void m_init_delayed()
162 float fh, glob, n, i;
165 draw_reset_cropped();
173 if(cvar_string("menu_skin") != "")
175 draw_currentSkin = strcat("gfx/menu/", cvar_string("menu_skin"));
176 fh = fopen(language_filename(strcat(draw_currentSkin, "/skinvalues.txt")), FILE_READ);
179 if(cvar_defstring("menu_skin") != "")
181 cvar_set("menu_skin", cvar_defstring("menu_skin"));
182 draw_currentSkin = strcat("gfx/menu/", cvar_string("menu_skin"));
183 fh = fopen(language_filename(strcat(draw_currentSkin, "/skinvalues.txt")), FILE_READ);
187 draw_currentSkin = "gfx/menu/default";
188 fh = fopen(language_filename(strcat(draw_currentSkin, "/skinvalues.txt")), FILE_READ);
192 error("cannot load any menu skin\n");
194 draw_currentSkin = strzone(draw_currentSkin);
195 while((s = fgets(fh)))
197 // these two are handled by skinlist.qc
198 if(substring(s, 0, 6) == "title ")
200 if(substring(s, 0, 7) == "author ")
202 n = tokenize_console(s);
204 Skin_ApplySetting(argv(0), substring(s, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)));
208 glob = search_begin(strcat(draw_currentSkin, "/*.tga"), TRUE, TRUE);
211 n = search_getsize(glob);
212 for(i = 0; i < n; ++i)
213 precache_pic(search_getfilename(glob, i));
217 draw_setMousePointer(SKINGFX_CURSOR, SKINSIZE_CURSOR, SKINOFFSET_CURSOR);
220 anim = spawnAnimHost();
221 main = spawnMainWindow(); main.configureMainWindow(main);
224 main.resizeNotify(main, '0 0 0', eX * conwidth + eY * conheight, '0 0 0', eX * conwidth + eY * conheight);
227 menuMousePos = '0.5 0.5 0';
233 m_goto(m_goto_buffer);
234 strunzone(m_goto_buffer);
235 m_goto_buffer = string_null;
239 m_display(); // delayed menu display
242 void m_keyup (float key, float ascii)
248 draw_reset_cropped();
249 main.keyUp(main, key, ascii, menuShiftState);
250 if(key >= K_MOUSE1 && key <= K_MOUSE3)
252 --mouseButtonsPressed;
253 if(!mouseButtonsPressed)
254 main.mouseRelease(main, menuMousePos);
255 if(mouseButtonsPressed < 0)
257 mouseButtonsPressed = 0;
258 dprint("Warning: released an already released button\n");
261 if(key == K_ALT) menuShiftState -= (menuShiftState & S_ALT);
262 if(key == K_CTRL) menuShiftState -= (menuShiftState & S_CTRL);
263 if(key == K_SHIFT) menuShiftState -= (menuShiftState & S_SHIFT);
266 void m_keydown(float key, float ascii)
274 if(key >= K_MOUSE1 && key <= K_MOUSE3)
276 // detect a click outside of the game window
277 vector p = getmousepos();
278 if(p_x < 0 || p_x > realconwidth || p_y < 0 || p_y > realconheight)
280 ++mouseButtonsPressed;
290 e.keyGrabbed(e, key, ascii);
294 draw_reset_cropped();
295 if(key >= K_MOUSE1 && key <= K_MOUSE3)
296 if(!mouseButtonsPressed)
297 main.mousePress(main, menuMousePos);
298 if(!main.keyDown(main, key, ascii, menuShiftState))
300 if(gamestatus & (GAME_ISSERVER | GAME_CONNECTED)) // don't back out to console only
301 m_hide(); // disable menu on unhandled ESC
303 if(key >= K_MOUSE1 && key <= K_MOUSE3)
305 ++mouseButtonsPressed;
306 if(mouseButtonsPressed > 10)
308 mouseButtonsPressed = 10;
309 dprint("Warning: pressed an already pressed button\n");
312 if(key == K_ALT) menuShiftState |= S_ALT;
313 if(key == K_CTRL) menuShiftState |= S_CTRL;
314 if(key == K_SHIFT) menuShiftState |= S_SHIFT;
317 const float SCALEMODE_CROP = 0;
318 const float SCALEMODE_LETTERBOX = 1;
319 const float SCALEMODE_WIDTH = 2;
320 const float SCALEMODE_HEIGHT = 3;
321 const float SCALEMODE_STRETCH = 4;
322 void draw_Picture_Aligned(vector algn, float scalemode, string img, float a)
324 vector sz, org, isz, isz_w, isz_h;
325 float width_is_larger;
327 sz = draw_PictureSize(img);
328 width_is_larger = (sz_x * draw_scale_y >= sz_y * draw_scale_x);
329 isz_w = '1 0 0' + '0 1 0' * ((sz_y / sz_x) * (draw_scale_x / draw_scale_y));
330 isz_h = '0 1 0' + '1 0 0' * ((sz_x / sz_y) * (draw_scale_y / draw_scale_x));
339 isz = (width_is_larger ? isz_h : isz_w);
341 case SCALEMODE_LETTERBOX:
342 isz = (width_is_larger ? isz_w : isz_h);
344 case SCALEMODE_WIDTH:
347 case SCALEMODE_HEIGHT:
350 case SCALEMODE_STRETCH:
355 org = eX * (algn_x * (1 - isz_x)) + eY * (algn_y * (1 - isz_y));
356 draw_Picture(org, img, isz, '1 1 1', a);
359 void drawBackground(string img, float a, string algn, float force1)
361 if(main.mainNexposee.ModalController_state == 0)
371 scalemode = SCALEMODE_CROP;
374 for(i = 0; i < strlen(algn); ++i)
376 c = substring(algn, i, 1);
379 case "c": scalemode = SCALEMODE_CROP; goto nopic;
380 case "l": scalemode = SCALEMODE_LETTERBOX; goto nopic;
381 case "h": scalemode = SCALEMODE_HEIGHT; goto nopic;
382 case "w": scalemode = SCALEMODE_WIDTH; goto nopic;
383 case "s": scalemode = SCALEMODE_STRETCH; goto nopic;
384 case "1": case "4": case "7": v_x = 0.0; break;
385 case "2": case "5": case "8": v_x = 0.5; break;
386 case "3": case "6": case "9": v_x = 1.0; break;
387 default: v_x = random(); break;
391 case "7": case "8": case "9": v_y = 0.0; break;
392 case "4": case "5": case "6": v_y = 0.5; break;
393 case "1": case "2": case "3": v_y = 1.0; break;
394 default: v_y = random(); break;
397 draw_Picture_Aligned(v, scalemode, img, a);
399 // force all secondary layers to use alpha 1. Prevents ugly issues
400 // with overlap. It's a flag because it cannot be used for the
402 draw_Picture_Aligned(v, scalemode, strcat(img, "_l", ftos(l+1)), 1);
404 draw_Picture_Aligned(v, scalemode, strcat(img, "_l", ftos(l+1)), a);
411 float menu_tooltips_old;
412 vector menuTooltipAveragedMousePos;
413 entity menuTooltipItem;
414 vector menuTooltipOrigin;
415 vector menuTooltipSize;
416 float menuTooltipAlpha;
417 string menuTooltipText;
418 float menuTooltipState; // 0: static, 1: fading in, 2: fading out
419 float m_testmousetooltipbox(vector pos)
421 if(pos_x >= menuTooltipOrigin_x && pos_x < menuTooltipOrigin_x + menuTooltipSize_x)
422 if(pos_y >= menuTooltipOrigin_y && pos_y < menuTooltipOrigin_y + menuTooltipSize_y)
426 float m_testtooltipbox(vector tooltippos)
432 if(tooltippos_x + menuTooltipSize_x > 1)
434 if(tooltippos_y + menuTooltipSize_y > 1)
436 menuTooltipOrigin = tooltippos;
439 float m_allocatetooltipbox(vector pos)
441 vector avoidplus, avoidminus;
444 avoidplus_x = (SKINAVOID_TOOLTIP_x + SKINSIZE_CURSOR_x - SKINOFFSET_CURSOR_x * SKINSIZE_CURSOR_x) / conwidth;
445 avoidplus_y = (SKINAVOID_TOOLTIP_y + SKINSIZE_CURSOR_y - SKINOFFSET_CURSOR_y * SKINSIZE_CURSOR_y) / conheight;
448 avoidminus_x = (SKINAVOID_TOOLTIP_x + SKINOFFSET_CURSOR_x * SKINSIZE_CURSOR_x) / conwidth + menuTooltipSize_x;
449 avoidminus_y = (SKINAVOID_TOOLTIP_y + SKINOFFSET_CURSOR_y * SKINSIZE_CURSOR_y) / conheight + menuTooltipSize_y;
454 if(m_testtooltipbox(v))
458 v_x = pos_x - menuTooltipSize_x * 0.5;
459 if(m_testtooltipbox(v))
463 v_x = pos_x - avoidminus_x;
464 if(m_testtooltipbox(v))
468 v_y = pos_y - avoidminus_y;
469 if(m_testtooltipbox(v))
473 v_x = pos_x - menuTooltipSize_x * 0.5;
474 if(m_testtooltipbox(v))
478 v_x = pos_x + avoidplus_x;
479 if(m_testtooltipbox(v))
484 entity m_findtooltipitem(entity root, vector pos)
492 while(it.instanceOfContainer)
494 while(it.instanceOfNexposee && it.focusedChild)
496 it = it.focusedChild;
497 pos = globalToBox(pos, it.Container_origin, it.Container_size);
499 if(it.instanceOfNexposee)
501 it = it.itemFromPoint(it, pos);
504 else if(menu_tooltips == 2 && (it.cvarName || it.onClickCommand))
508 else if(it.instanceOfModalController)
509 it = it.focusedChild;
511 it = it.itemFromPoint(it, pos);
516 else if(menu_tooltips == 2 && (it.cvarName || it.onClickCommand))
518 pos = globalToBox(pos, it.Container_origin, it.Container_size);
525 if (menu_tooltips == 2)
528 if (menuTooltipItem.cvarName)
530 if (getCvarsMulti(menuTooltipItem))
531 s = strcat("[", menuTooltipItem.cvarName, " ", getCvarsMulti(menuTooltipItem), "]");
533 s = strcat("[", menuTooltipItem.cvarName, "]");
535 else if (menuTooltipItem.onClickCommand)
536 s = strcat("<", menuTooltipItem.onClickCommand, ">");
538 return menuTooltipItem.tooltip;
539 if (menuTooltipItem.tooltip)
540 return strcat(menuTooltipItem.tooltip, " ", s);
543 return menuTooltipItem.tooltip;
545 void m_tooltip(vector pos)
552 menu_tooltips = cvar("menu_tooltips");
555 // don't return immediately, fade out the active tooltip first
556 if (menuTooltipItem == world)
559 menu_tooltips_old = menu_tooltips;
563 f = bound(0, frametime * 2, 1);
564 menuTooltipAveragedMousePos = menuTooltipAveragedMousePos * (1 - f) + pos * f;
565 f = vlen(pos - menuTooltipAveragedMousePos);
567 it = m_findtooltipitem(main, pos);
571 fontsize = '1 0 0' * (SKINFONTSIZE_TOOLTIP / conwidth) + '0 1 0' * (SKINFONTSIZE_TOOLTIP / conheight);
573 // float menuTooltipState; // 0: static, 1: fading in, 2: fading out
574 if(it != menuTooltipItem)
576 switch(menuTooltipState)
581 // another item: fade out first
582 menuTooltipState = 2;
587 menuTooltipState = 1;
588 menuTooltipItem = it;
590 menuTooltipOrigin_x = -1; // unallocated
593 strunzone(menuTooltipText);
594 menuTooltipText = strzone(gettooltip());
598 getWrappedLine_remaining = menuTooltipText;
599 while(getWrappedLine_remaining)
601 s = getWrappedLine(SKINWIDTH_TOOLTIP, fontsize, draw_TextWidth_WithoutColors);
603 f = draw_TextWidth(s, FALSE, fontsize);
607 menuTooltipSize_x = w + 2 * (SKINMARGIN_TOOLTIP_x / conwidth);
608 menuTooltipSize_y = i * fontsize_y + 2 * (SKINMARGIN_TOOLTIP_y / conheight);
609 menuTooltipSize_z = 0;
613 // changing item while fading in: fade out first
614 menuTooltipState = 2;
617 // changing item while fading out: can't
621 else if(menuTooltipState == 2) // re-fade in?
622 menuTooltipState = 1;
625 if(!m_testmousetooltipbox(pos))
626 menuTooltipState = 2; // fade out if mouse touches it
628 switch(menuTooltipState)
631 menuTooltipAlpha = bound(0, menuTooltipAlpha + 5 * frametime, 1);
632 if(menuTooltipAlpha == 1)
633 menuTooltipState = 0;
636 menuTooltipAlpha = bound(0, menuTooltipAlpha - 2 * frametime, 1);
637 if(menuTooltipAlpha == 0)
639 menuTooltipState = 0;
640 menuTooltipItem = world;
645 if(menuTooltipItem == world)
649 strunzone(menuTooltipText);
650 menuTooltipText = string_null;
656 if(menu_tooltips != menu_tooltips_old)
658 if (menu_tooltips != 0 && menu_tooltips_old != 0)
659 menuTooltipItem = world; // reload tooltip next frame
660 menu_tooltips_old = menu_tooltips;
662 else if(menuTooltipOrigin_x < 0) // unallocated?
663 m_allocatetooltipbox(pos);
665 if(menuTooltipOrigin_x >= 0)
668 p = SKINBORDER_TOOLTIP;
670 p_y *= 1 / conheight;
671 draw_BorderPicture(menuTooltipOrigin, SKINGFX_TOOLTIP, menuTooltipSize, '1 1 1', menuTooltipAlpha, p);
672 p = menuTooltipOrigin;
673 p_x += SKINMARGIN_TOOLTIP_x / conwidth;
674 p_y += SKINMARGIN_TOOLTIP_y / conheight;
675 getWrappedLine_remaining = menuTooltipText;
676 while(getWrappedLine_remaining)
678 s = getWrappedLine(SKINWIDTH_TOOLTIP, fontsize, draw_TextWidth_WithoutColors);
679 draw_Text(p, s, fontsize, '1 1 1', SKINALPHA_TOOLTIP * menuTooltipAlpha, FALSE);
686 void m_draw(float width, float height)
693 execute_next_frame();
695 menuMouseMode = cvar("menu_mouse_absolute");
700 UpdateConWidthHeight(width, height, cvar("vid_pixelheight"));
704 // TODO draw an info image about this situation
708 if(!menuNotTheFirstFrame)
710 menuNotTheFirstFrame = 1;
712 if(!cvar("menu_video_played"))
714 localcmd("cd loop $menu_cdtrack; play sound/announcer/default/welcome.wav\n");
715 menuLogoAlpha = -0.8; // no idea why, but when I start this at zero, it jumps instead of fading FIXME
717 // ALWAYS set this cvar; if we start but menu is not active, this means we want no background music!
718 localcmd("set menu_video_played 1\n");
722 realFrametime = frametime = min(0.2, t - menuPrevTime);
726 t = cvar("menu_slowmo");
737 if(getmousetarget() == (menuMouseMode ? MT_CLIENT : MT_MENU) && (getkeydest() == KEY_MENU || getkeydest() == KEY_MENU_GRABBED))
738 setkeydest(keyGrabber ? KEY_MENU_GRABBED : KEY_MENU);
743 if(cvar("cl_capturevideo"))
744 frametime = t / cvar("cl_capturevideo_fps"); // make capturevideo work smoothly
746 prevMenuAlpha = menuAlpha;
749 if(menuAlpha == 0 && menuLogoAlpha < 2)
751 menuLogoAlpha = menuLogoAlpha + frametime * 2;
755 menuAlpha = min(1, menuAlpha + frametime * 5);
761 menuAlpha = max(0, menuAlpha - frametime * 5);
765 draw_reset_cropped();
767 if(!(gamestatus & (GAME_CONNECTED | GAME_ISSERVER)))
769 if(menuLogoAlpha > 0)
772 draw_Fill('0 0 0', '1 1 0', SKINCOLOR_BACKGROUND, 1);
773 drawBackground(SKINGFX_BACKGROUND, bound(0, menuLogoAlpha, 1), SKINALIGN_BACKGROUND, TRUE);
774 draw_reset_cropped();
775 if(menuAlpha <= 0 && SKINALPHA_CURSOR_INTRO > 0)
777 draw_alpha = SKINALPHA_CURSOR_INTRO * bound(0, menuLogoAlpha, 1);
778 draw_drawMousePointer(menuMousePos);
783 else if(SKINALPHA_BACKGROUND_INGAME)
788 drawBackground(SKINGFX_BACKGROUND_INGAME, menuAlpha * SKINALPHA_BACKGROUND_INGAME, SKINALIGN_BACKGROUND_INGAME, FALSE);
789 draw_reset_cropped();
793 if(menuAlpha != prevMenuAlpha)
794 cvar_set("_menu_alpha", ftos(menuAlpha));
796 draw_reset_cropped();
798 draw_reset_cropped();
802 if(prevMenuAlpha > 0)
803 main.initializeDialog(main, main.firstChild);
804 draw_reset_cropped();
809 draw_alpha *= menuAlpha;
813 // do not update mouse position
814 // it prevents mouse jumping to '0 0 0' when menu is fading out
816 else if(menuMouseMode)
819 newMouse = globalToBox(getmousepos(), draw_shift, draw_scale);
820 if(newMouse != '0 0 0')
821 if(newMouse != menuMousePos)
823 menuMousePos = newMouse;
824 if(mouseButtonsPressed)
825 main.mouseDrag(main, menuMousePos);
827 main.mouseMove(main, menuMousePos);
834 vector dMouse, minpos, maxpos;
835 dMouse = getmousepos() * (frametime / realFrametime); // for capturevideo
836 if(dMouse != '0 0 0')
838 minpos = globalToBox('0 0 0', draw_shift, draw_scale);
839 maxpos = globalToBox(eX * (realconwidth - 1) + eY * (realconheight - 1), draw_shift, draw_scale);
840 dMouse = globalToBoxSize(dMouse, draw_scale);
841 menuMousePos += dMouse * cvar("menu_mouse_speed");
842 menuMousePos_x = bound(minpos_x, menuMousePos_x, maxpos_x);
843 menuMousePos_y = bound(minpos_y, menuMousePos_y, maxpos_y);
844 if(mouseButtonsPressed)
845 main.mouseDrag(main, menuMousePos);
847 main.mouseMove(main, menuMousePos);
853 m_tooltip(menuMousePos);
855 draw_alpha = max(draw_alpha, SKINALPHA_CURSOR_INTRO * bound(0, menuLogoAlpha, 1));
857 draw_drawMousePointer(menuMousePos);
859 draw_reset_cropped();
868 setkeydest(KEY_MENU);
869 setmousetarget((menuMouseMode ? MT_CLIENT : MT_MENU));
874 if(mouseButtonsPressed)
875 main.mouseRelease(main, menuMousePos);
876 mouseButtonsPressed = 0;
878 main.focusEnter(main);
879 main.showNotify(main);
885 setkeydest(KEY_GAME);
886 setmousetarget(MT_CLIENT);
891 main.focusLeave(main);
892 main.hideNotify(main);
895 void m_toggle(float mode)
916 for(e = NULL; (e = nextent(e)) != NULL; )
918 if(e.classname != "vtbl")
924 void m_focus_item_chain(entity outermost, entity innermost)
926 if(innermost.parent != outermost)
927 m_focus_item_chain(outermost, innermost.parent);
928 innermost.parent.setFocus(innermost.parent, innermost);
931 void m_activate_window(entity wnd)
936 m_activate_window(par);
938 if(par.instanceOfModalController)
940 if(wnd.tabSelectingButton)
942 TabButton_Click(wnd.tabSelectingButton, wnd);
945 par.initializeDialog(par, wnd);
947 else if(par.instanceOfNexposee)
949 // nexposee (sorry for violating abstraction here)
950 par.selectedChild = wnd;
951 par.animationState = 1;
952 Container_setFocus(par, NULL);
954 else if(par.instanceOfContainer)
958 par.setFocus(par, wnd);
962 void m_setpointerfocus(entity wnd)
964 if(wnd.instanceOfContainer)
966 entity focus = wnd.preferredFocusedGrandChild(wnd);
969 menuMousePos = focus.origin + 0.5 * focus.size;
970 menuMousePos_x *= 1 / conwidth;
971 menuMousePos_y *= 1 / conheight;
972 if(wnd.focused) // why does this never happen?
973 m_focus_item_chain(wnd, focus);
978 void m_goto(string itemname)
984 strunzone(m_goto_buffer);
985 m_goto_buffer = strzone(itemname);
988 if(itemname == "") // this can be called by GameCommand
990 if(gamestatus & (GAME_ISSERVER | GAME_CONNECTED))
996 m_activate_window(main.mainNexposee);
1002 for(e = NULL; (e = find(e, name, itemname)); )
1003 if(e.classname != "vtbl")
1006 if((e) && (!e.requiresConnection || (gamestatus & (GAME_ISSERVER | GAME_CONNECTED))))
1009 m_activate_window(e);
1010 m_setpointerfocus(e);