]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/menu/menu.qc
give the magic numbers names
[divverent/nexuiz.git] / data / qcsrc / menu / menu.qc
1 ///////////////////////////////////////////////
2 // Menu Source File
3 ///////////////////////
4 // This file belongs to dpmod/darkplaces
5 // AK contains all menu functions (especially the required ones)
6 ///////////////////////////////////////////////
7
8 float mouseButtonsPressed;
9 vector menuMousePos;
10 float menuShiftState;
11 float menuPrevTime;
12 float menuAlpha;
13 float menuLogoAlpha;
14 float prevMenuAlpha;
15 float menuInitialized;
16 float menuNotTheFirstFrame;
17 float menuMouseMode;
18
19 void SUB_Null() { };
20
21 void() m_init =
22 {
23         dprint_load();
24         check_unacceptable_compiler_bugs();
25
26         // list all game dirs (TEST)
27         if(cvar("developer"))
28         {
29                 float i;
30                 string s;
31                 for(i = 0; ; ++i)
32                 {
33                         s = getgamedirinfo(i, GETGAMEDIRINFO_NAME);
34                         if not(s)
35                                 break;
36                         print(s, ": ", getgamedirinfo(i, GETGAMEDIRINFO_DESCRIPTION));
37                 }
38         }
39 }
40
41 void UpdateConWidthHeight()
42 {
43         float conwidth_s, conheight_s;
44         conwidth_s = conwidth;
45         conheight_s = conheight;
46         conwidth = cvar("vid_conwidth");
47         conheight = cvar("vid_conheight");
48         if(conwidth < 800)
49         {
50                 conheight *= 800 / conwidth;
51                 conwidth = 800;
52         }
53         if(conheight < 600)
54         {
55                 conwidth *= 600 / conheight;
56                 conheight = 600;
57         }
58         if(main)
59         {
60                 if(conwidth_s != conwidth || conheight_s != conheight)
61                 {
62                         draw_reset();
63                         main.resizeNotify(main, '0 0 0', eX * conwidth + eY * conheight, '0 0 0', eX * conwidth + eY * conheight);
64                 }
65         }
66 }
67
68 void() m_init_delayed =
69 {
70         float fh, glob, n, i;
71         string s;
72
73         dprint_load();
74
75         menuInitialized = 0;
76         if(!preMenuInit())
77                 return;
78         menuInitialized = 1;
79         GameCommand_Init();
80
81         RegisterWeapons();
82
83         fh = -1;
84         if(cvar_string("menu_skin") != "")
85         {
86                 draw_currentSkin = strcat("gfx/menu/", cvar_string("menu_skin"));
87                 fh = fopen(strcat(draw_currentSkin, "/skinvalues.txt"), FILE_READ);
88         }
89         if(fh < 0)
90         if(cvar_defstring("menu_skin") != "")
91         {
92                 draw_currentSkin = strcat("gfx/menu/", cvar_defstring("menu_skin"));
93                 fh = fopen(strcat(draw_currentSkin, "/skinvalues.txt"), FILE_READ);
94         }
95         if(fh < 0)
96         {
97                 draw_currentSkin = "gfx/menu/default";
98                 fh = fopen(strcat(draw_currentSkin, "/skinvalues.txt"), FILE_READ);
99         }
100         draw_currentSkin = strzone(draw_currentSkin);
101         while((s = fgets(fh)))
102         {
103                 // these two are handled by skinlist.qc
104                 if(substring(s, 0, 6) == "title ")
105                         continue;
106                 if(substring(s, 0, 7) == "author ")
107                         continue;
108                 n = tokenize_console(s);
109                 if(n >= 2)
110                         Skin_ApplySetting(argv(0), substring(s, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)));
111         }
112         fclose(fh);
113
114         glob = search_begin(strcat(draw_currentSkin, "/*.tga"), TRUE, TRUE);
115         if(glob >= 0)
116         {
117                 n = search_getsize(glob);
118                 for(i = 0; i < n; ++i)
119                         precache_pic(search_getfilename(glob, i));
120                 search_end(glob);
121         }
122
123         draw_setMousePointer(SKINGFX_CURSOR, SKINSIZE_CURSOR, SKINOFFSET_CURSOR);
124
125         conwidth = conheight = -1;
126         draw_reset();
127         UpdateConWidthHeight();
128
129         loadTooltips();
130         main = spawnMainWindow(); main.configureMainWindow(main);
131         unloadTooltips();
132
133         main.resizeNotify(main, '0 0 0', eX * conwidth + eY * conheight, '0 0 0', eX * conwidth + eY * conheight);
134         main.focused = 1;
135         menuShiftState = 0;
136         menuMousePos = '0.5 0.5 0';
137
138         if(Menu_Active)
139                 m_display(); // delayed menu display
140 };
141
142 void(float key, float ascii) m_keyup =
143 {
144         if(!menuInitialized)
145                 return;
146         if(!Menu_Active)
147                 return;
148         draw_reset();
149         main.keyUp(main, key, ascii, menuShiftState);
150         if(key >= K_MOUSE1 && key <= K_MOUSE3)
151         {
152                 --mouseButtonsPressed;
153                 if(!mouseButtonsPressed)
154                         main.mouseRelease(main, menuMousePos);
155                 if(mouseButtonsPressed < 0)
156                 {
157                         mouseButtonsPressed = 0;
158                         print("Warning: released an already released button\n");
159                 }
160         }
161         if(key == K_ALT) menuShiftState -= (menuShiftState & S_ALT);
162         if(key == K_CTRL) menuShiftState -= (menuShiftState & S_CTRL);
163         if(key == K_SHIFT) menuShiftState -= (menuShiftState & S_SHIFT);
164 };
165
166 void(float key, float ascii) m_keydown =
167 {
168         if(!menuInitialized)
169                 return;
170         if(!Menu_Active)
171                 return;
172         if(keyGrabber)
173         {
174                 entity e;
175                 e = keyGrabber;
176                 keyGrabber = NULL;
177                 e.keyGrabbed(e, key, ascii);
178         }
179         else
180         {
181                 draw_reset();
182                 if(key >= K_MOUSE1 && key <= K_MOUSE3)
183                         if(!mouseButtonsPressed)
184                                 main.mousePress(main, menuMousePos);
185                 if(!main.keyDown(main, key, ascii, menuShiftState))
186                         if(key == K_ESCAPE)
187                                 if(gamestatus & (GAME_ISSERVER | GAME_CONNECTED)) // don't back out to console only
188                                         m_hide(); // disable menu on unhandled ESC
189         }
190         if(key >= K_MOUSE1 && key <= K_MOUSE3)
191         {
192                 ++mouseButtonsPressed;
193                 if(mouseButtonsPressed > 10)
194                 {
195                         mouseButtonsPressed = 10;
196                         print("Warning: pressed an already pressed button\n");
197                 }
198         }
199         if(key == K_ALT) menuShiftState |= S_ALT;
200         if(key == K_CTRL) menuShiftState |= S_CTRL;
201         if(key == K_SHIFT) menuShiftState |= S_SHIFT;
202 };
203
204 void(string img, float a) drawBackground =
205 {
206         vector sz;
207         vector isz;
208         sz = draw_PictureSize(img);
209         // keep aspect of image
210         if(sz_x * draw_scale_y >= sz_y * draw_scale_x)
211         {
212                 // that is, sz_x/sz_y >= draw_scale_x/draw_scale_y
213                 // match up the height
214                 isz_y = 1;
215                 isz_x = isz_y * (sz_x / sz_y) * (draw_scale_y / draw_scale_x);
216         }
217         else
218         {
219                 // that is, sz_x/sz_y <= draw_scale_x/draw_scale_y
220                 // match up the width
221                 isz_x = 1;
222                 isz_y = isz_x * (sz_y / sz_x) * (draw_scale_x / draw_scale_y);
223         }
224         draw_Picture('0.5 0.5 0' - 0.5 * isz, img, isz, '1 1 1', a);
225 }
226
227
228 vector menuTooltipAveragedMousePos;
229 entity menuTooltipItem;
230 vector menuTooltipOrigin;
231 vector menuTooltipSize;
232 float menuTooltipAlpha;
233 float menuTooltipState; // 0: no tooltip, 1: fading in, 2: displaying, 3: fading out
234 float m_testmousetooltipbox(vector pos)
235 {
236         if(pos_x >= menuTooltipOrigin_x && pos_x < menuTooltipOrigin_x + menuTooltipSize_x)
237         if(pos_y >= menuTooltipOrigin_y && pos_y < menuTooltipOrigin_y + menuTooltipSize_y)
238                 return FALSE;
239         return TRUE;
240 }
241 float m_testtooltipbox(vector tooltippos)
242 {
243         if(tooltippos_x < 0)
244                 return FALSE;
245         if(tooltippos_y < 0)
246                 return FALSE;
247         if(tooltippos_x + menuTooltipSize_x > 1)
248                 return FALSE;
249         if(tooltippos_y + menuTooltipSize_y > 1)
250                 return FALSE;
251         /*
252         menuTooltipOrigin_x = rint(tooltippos_x * cvar("vid_width")) / cvar("vid_width");
253         menuTooltipOrigin_y = rint(tooltippos_y * cvar("vid_height")) / cvar("vid_height");
254         menuTooltipOrigin_z = 0;
255         */
256         menuTooltipOrigin = tooltippos;
257         return TRUE;
258 }
259 float m_allocatetooltipbox(vector pos)
260 {
261         vector avoidplus, avoidminus;
262         vector v;
263
264         avoidplus_x = (SKINAVOID_TOOLTIP_x + SKINSIZE_CURSOR_x - SKINOFFSET_CURSOR_x) / conwidth;
265         avoidplus_y = (SKINAVOID_TOOLTIP_y + SKINSIZE_CURSOR_y - SKINOFFSET_CURSOR_y) / conheight;
266         avoidplus_z = 0;
267
268         avoidminus_x = (SKINAVOID_TOOLTIP_x + SKINOFFSET_CURSOR_x) / conwidth + menuTooltipSize_x;
269         avoidminus_y = (SKINAVOID_TOOLTIP_y + SKINOFFSET_CURSOR_y) / conheight + menuTooltipSize_y;
270         avoidminus_z = 0;
271
272         // bottom right
273         v = pos + avoidplus;
274         if(m_testtooltipbox(v))
275                 return TRUE;
276         
277         // bottom center
278         v_x = pos_x - menuTooltipSize_x * 0.5;
279         if(m_testtooltipbox(v))
280                 return TRUE;
281
282         // bottom left
283         v_x = pos_x - avoidminus_x;
284         if(m_testtooltipbox(v))
285                 return TRUE;
286
287         // top left
288         v_y = pos_y - avoidminus_y;
289         if(m_testtooltipbox(v))
290                 return TRUE;
291
292         // top center
293         v_x = pos_x - menuTooltipSize_x * 0.5;
294         if(m_testtooltipbox(v))
295                 return TRUE;
296         
297         // top right
298         v_x = pos_x + avoidplus_x;
299         if(m_testtooltipbox(v))
300                 return TRUE;
301         
302         return FALSE;
303 }
304 entity m_findtooltipitem(entity root, vector pos)
305 {
306         entity it;
307         entity best;
308
309         best = world;
310         it = root;
311
312         while(it.instanceOfContainer)
313         {
314                 while(it.instanceOfNexposee && it.focusedChild)
315                 {
316                         it = it.focusedChild;
317                         pos = globalToBox(pos, it.Container_origin, it.Container_size);
318                 }
319                 if(it.instanceOfNexposee)
320                 {
321                         it = it.itemFromPoint(it, pos);
322                         if(it.tooltip)
323                                 best = it;
324                         it = world;
325                 }
326                 else if(it.instanceOfModalController)
327                         it = it.focusedChild;
328                 else
329                         it = it.itemFromPoint(it, pos);
330                 if(!it)
331                         break;
332                 if(it.tooltip)
333                         best = it;
334                 pos = globalToBox(pos, it.Container_origin, it.Container_size);
335         }
336
337         return best;
338 }
339 void m_tooltip(vector pos)
340 {
341         float f, i, w;
342         entity it;
343         vector fontsize, p;
344         string s;
345
346         fontsize = '1 0 0' * (SKINFONTSIZE_TOOLTIP / conwidth) + '0 1 0' * (SKINFONTSIZE_TOOLTIP / conheight);
347
348         f = bound(0, frametime * 2, 1);
349         menuTooltipAveragedMousePos = menuTooltipAveragedMousePos * (1 - f) + pos * f;
350         f = vlen(pos - menuTooltipAveragedMousePos);
351
352         if(f < 0.01)
353                 it = m_findtooltipitem(main, pos);
354         else    
355                 it = world;
356
357         // float menuTooltipState; // 0: static, 1: fading in, 2: fading out
358         if(it != menuTooltipItem)
359         {
360                 switch(menuTooltipState)
361                 {
362                         case 0:
363                                 if(menuTooltipItem)
364                                 {
365                                         // another item: fade out first
366                                         menuTooltipState = 2;
367                                 }
368                                 else
369                                 {
370                                         // new item: fade in
371                                         menuTooltipState = 1;
372                                         menuTooltipItem = it;
373
374                                         menuTooltipOrigin_x = -1; // unallocated
375                                         i = 0;
376                                         w =  0;
377                                         getWrappedLine_remaining = it.tooltip;
378                                         while(getWrappedLine_remaining)
379                                         {
380                                                 s = getWrappedLine(SKINWIDTH_TOOLTIP / fontsize_x, draw_TextWidth_WithoutColors);
381                                                 ++i;
382                                                 f = draw_TextWidth(s, FALSE);
383                                                 if(f > w)
384                                                         w = f;
385                                         }
386                                         menuTooltipSize_x = w * fontsize_x + 2 * (SKINMARGIN_TOOLTIP_x / conwidth);
387                                         menuTooltipSize_y = i * fontsize_y + 2 * (SKINMARGIN_TOOLTIP_y / conheight);
388                                         menuTooltipSize_z = 0;
389                                 }
390                                 break;
391                         case 1:
392                                 // changing item while fading in: fade out first
393                                 menuTooltipState = 2;
394                                 break;
395                         case 2:
396                                 // changing item while fading out: can't
397                                 break;
398                 }
399         }
400         else if(menuTooltipState == 2) // re-fade in?
401                 menuTooltipState = 1;
402
403         if(menuTooltipItem)
404                 if(!m_testmousetooltipbox(pos))
405                         menuTooltipState = 2; // fade out if mouse touches it
406
407         switch(menuTooltipState)
408         {
409                 case 1:
410                         menuTooltipAlpha = bound(0, menuTooltipAlpha + 5 * frametime, 1);
411                         if(menuTooltipAlpha == 1)
412                                 menuTooltipState = 0;
413                         break;
414                 case 2:
415                         menuTooltipAlpha = bound(0, menuTooltipAlpha - 2 * frametime, 1);
416                         if(menuTooltipAlpha == 0)
417                         {
418                                 menuTooltipState = 0;
419                                 menuTooltipItem = world;
420                         }
421                         break;
422         }
423
424         if(menuTooltipItem)
425         {
426                 if(menuTooltipOrigin_x < 0) // unallocated?
427                         m_allocatetooltipbox(pos);
428
429                 if(menuTooltipOrigin_x >= 0)
430                 {
431                         // draw the tooltip!
432                         p = SKINBORDER_TOOLTIP;
433                         p_x *= 1 / conwidth;
434                         p_y *= 1 / conheight;
435                         draw_BorderPicture(menuTooltipOrigin, SKINGFX_TOOLTIP, menuTooltipSize, '1 1 1', menuTooltipAlpha, p);
436                         p = menuTooltipOrigin;
437                         p_x += SKINMARGIN_TOOLTIP_x / conwidth;
438                         p_y += SKINMARGIN_TOOLTIP_y / conheight;
439                         getWrappedLine_remaining = menuTooltipItem.tooltip;
440                         while(getWrappedLine_remaining)
441                         {
442                                 s = getWrappedLine(SKINWIDTH_TOOLTIP / fontsize_x, draw_TextWidth_WithoutColors);
443                                 draw_Text(p, s, fontsize, '1 1 1', SKINALPHA_TOOLTIP * menuTooltipAlpha, FALSE);
444                                 p_y += fontsize_y;
445                         }
446                 }
447         }
448 }
449
450 void() m_draw =
451 {
452         float t;
453         float realFrametime;
454
455         menuMouseMode = cvar("menu_mouse_absolute");
456
457         if(main)
458                 UpdateConWidthHeight();
459
460         if(!menuInitialized)
461         {
462                 // TODO draw an info image about this situation
463                 m_init_delayed();
464                 return;
465         }
466         if(!menuNotTheFirstFrame)
467         {
468                 menuNotTheFirstFrame = 1;
469                 if(Menu_Active)
470                 if(!cvar("menu_video_played"))
471                 {
472                         localcmd("set menu_video_played 1; cd loop $menu_cdtrack; play sound/announcer/male/welcome.ogg\n");
473                         menuLogoAlpha = -0.8; // no idea why, but when I start this at zero, it jumps instead of fading
474                 }
475         }
476
477         t = gettime();
478         realFrametime = frametime = min(0.2, t - menuPrevTime);
479         menuPrevTime = t;
480         time += frametime;
481
482         t = cvar("menu_slowmo");
483         if(t)
484         {
485                 frametime *= t;
486                 realFrametime *= t;
487         }
488         else
489                 t = 1;
490
491         if(Menu_Active)
492         {
493                 if(getmousetarget() == (menuMouseMode ? MT_CLIENT : MT_MENU) && (getkeydest() == KEY_MENU || getkeydest() == KEY_MENU_GRABBED))
494                         setkeydest(keyGrabber ? KEY_MENU_GRABBED : KEY_MENU);
495                 else
496                         m_hide();
497         }
498
499         if(cvar("cl_capturevideo"))
500                 frametime = t / cvar("cl_capturevideo_fps"); // make capturevideo work smoothly
501
502         dprint_load();
503         gamestatus = 0;
504         if(isserver())
505                 gamestatus = gamestatus | GAME_ISSERVER;
506         if(clientstate() == CS_CONNECTED)
507                 gamestatus = gamestatus | GAME_CONNECTED;
508         if(cvar("developer"))
509                 gamestatus = gamestatus | GAME_DEVELOPER;
510
511         prevMenuAlpha = menuAlpha;
512         if(Menu_Active)
513         {
514                 if(menuAlpha == 0 && menuLogoAlpha < 2)
515                 {
516                         menuLogoAlpha = menuLogoAlpha + frametime * 2;
517                 }
518                 else
519                 {
520                         menuAlpha = min(1, menuAlpha + frametime * 5);
521                         menuLogoAlpha = 2;
522                 }
523         }
524         else
525         {
526                 menuAlpha = max(0, menuAlpha - frametime * 5);
527                 menuLogoAlpha = 2;
528         }
529
530         draw_reset();
531
532         if(!(gamestatus & (GAME_CONNECTED | GAME_ISSERVER)))
533         {
534                 if(menuLogoAlpha > 0)
535                 {
536                         drawBackground(SKINGFX_BACKGROUND, bound(0, menuLogoAlpha, 1));
537                         if(menuAlpha <= 0 && SKINALPHA_CURSOR_INTRO > 0)
538                         {
539                                 draw_alpha = SKINALPHA_CURSOR_INTRO * bound(0, menuLogoAlpha, 1);
540                                 draw_drawMousePointer(menuMousePos);
541                                 draw_alpha = 1;
542                         }
543                 }
544         }
545         else if(SKINALPHA_BACKGROUND_INGAME)
546         {
547                 if(menuAlpha > 0)
548                         drawBackground(SKINGFX_BACKGROUND_INGAME, menuAlpha * SKINALPHA_BACKGROUND_INGAME);
549         }
550
551         draw_reset();
552         preMenuDraw();
553         draw_reset();
554
555         if(menuAlpha <= 0)
556         {
557                 if(prevMenuAlpha > 0)
558                         main.initializeDialog(main, main.firstChild);
559                 draw_reset();
560                 postMenuDraw();
561                 return;
562         }
563
564         draw_alpha *= menuAlpha;
565
566         if(menuMouseMode)
567         {
568                 vector newMouse;
569                 newMouse = globalToBoxSize(getmousepos(), draw_scale);
570                 if(newMouse != '0 0 0')
571                         if(newMouse != menuMousePos)
572                         {
573                                 menuMousePos = newMouse;
574                                 if(mouseButtonsPressed)
575                                         main.mouseDrag(main, menuMousePos);
576                                 else
577                                         main.mouseMove(main, menuMousePos);
578                         }
579         }
580         else
581         {
582                 if(frametime > 0)
583                 {
584                         vector dMouse;
585                         dMouse = getmousepos() * (frametime / realFrametime); // for capturevideo
586                         if(dMouse != '0 0 0')
587                         {
588                                 dMouse = globalToBoxSize(dMouse, draw_scale);
589                                 menuMousePos += dMouse * cvar("menu_mouse_speed");
590                                 menuMousePos_x = bound(0, menuMousePos_x, 1);
591                                 menuMousePos_y = bound(0, menuMousePos_y, 1);
592                                 if(mouseButtonsPressed)
593                                         main.mouseDrag(main, menuMousePos);
594                                 else
595                                         main.mouseMove(main, menuMousePos);
596                         }
597                 }
598         }
599         main.draw(main);
600
601         m_tooltip(menuMousePos);
602
603         draw_alpha = max(draw_alpha, SKINALPHA_CURSOR_INTRO * bound(0, menuLogoAlpha, 1));
604
605         draw_drawMousePointer(menuMousePos);
606
607         draw_reset();
608         postMenuDraw();
609
610         frametime = 0;
611 };
612
613 void() m_display =
614 {
615         Menu_Active = true;
616         setkeydest(KEY_MENU);
617         setmousetarget((menuMouseMode ? MT_CLIENT : MT_MENU));
618
619         if(!menuInitialized)
620                 return;
621
622         if(mouseButtonsPressed)
623                 main.mouseRelease(main, menuMousePos);
624         mouseButtonsPressed = 0;
625
626         main.focusEnter(main);
627         main.showNotify(main);
628 };
629
630 void() m_hide =
631 {
632         Menu_Active = false;
633         setkeydest(KEY_GAME);
634         setmousetarget(MT_CLIENT);
635
636         if(!menuInitialized)
637                 return;
638
639         main.focusLeave(main);
640         main.hideNotify(main);
641 };
642
643 void() m_toggle =
644 {
645         if(Menu_Active)
646                 m_hide();
647         else
648                 m_display();
649 };
650
651 void() m_shutdown =
652 {
653         entity e;
654
655         m_hide();
656         for(e = NULL; (e = nextent(e)) != NULL; )
657         {
658                 if(e.destroy)
659                         e.destroy(e);
660         }
661 };
662
663 void m_focus_item_chain(entity outermost, entity innermost)
664 {
665         if(innermost.parent != outermost)
666                 m_focus_item_chain(outermost, innermost.parent);
667         innermost.parent.setFocus(innermost.parent, innermost);
668 }
669
670 void m_activate_window(entity wnd)
671 {
672         entity par;
673         par = wnd.parent;
674         if(par)
675                 m_activate_window(par);
676
677         if(par.instanceOfModalController)
678         {
679                 if(wnd.tabSelectingButton)
680                         // tabs
681                         TabButton_Click(wnd.tabSelectingButton, wnd);
682                 else
683                         // root
684                         par.initializeDialog(par, wnd);
685         }
686         else if(par.instanceOfNexposee)
687         {
688                 // nexposee (sorry for violating abstraction here)
689                 par.selectedChild = wnd;
690                 par.animationState = 1;
691                 setFocusContainer(par, NULL);
692         }
693         else if(par.instanceOfContainer)
694         {
695                 // other containers
696                 if(par.focused)
697                         par.setFocus(par, wnd);
698         }
699 }
700
701 void m_setpointerfocus(entity wnd)
702 {
703         if(wnd.instanceOfContainer)
704         {
705                 entity focus = wnd.preferredFocusedGrandChild(wnd);
706                 if(focus)
707                 {
708                         menuMousePos = focus.origin + 0.5 * focus.size;
709                         menuMousePos_x *= 1 / conwidth;
710                         menuMousePos_y *= 1 / conheight;
711                         if(wnd.focused) // why does this never happen?
712                                 m_focus_item_chain(wnd, focus);
713                 }
714         }
715 }
716
717 void(string itemname) m_goto =
718 {
719         entity e;
720         if(!menuInitialized)
721                 return;
722         if(itemname == "") // this can be called by GameCommand
723         {
724                 if(gamestatus & (GAME_ISSERVER | GAME_CONNECTED))
725                         m_hide();
726                 else
727                 {
728                         m_activate_window(main.mainNexposee);
729                         m_display();
730                 }
731         }
732         else
733         {
734                 e = findstring(NULL, name, itemname);
735                 if(e)
736                 {
737                         m_hide();
738                         m_activate_window(e);
739                         m_setpointerfocus(e);
740                         m_display();
741                 }
742         }
743 }
744
745 void() m_goto_skin_selector =
746 {
747         if(!menuInitialized)
748                 return;
749         // TODO add code to switch back to the skin selector (no idea how to do it now)
750         m_goto("skinselector");
751 }