]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/minigames/cl_minigames_hud.qc
Merge branch 'master' into Mario/cursor
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / minigames / cl_minigames_hud.qc
1 #include "cl_minigames_hud.qh"
2
3 #include <client/autocvars.qh>
4 #include <common/ent_cs.qh>
5
6 #include "minigames.qh"
7
8 .vector colormod;
9
10 #include <client/hud/hud_config.qh>
11 #include <client/mapvoting.qh>
12
13 // whether the mouse is over the given panel
14 bool HUD_mouse_over(entity somepanel)
15 {
16         vector pos = stov(cvar_string(strcat("hud_panel_", somepanel.panel_name, "_pos")));
17         vector sz = stov(cvar_string(strcat("hud_panel_", somepanel.panel_name, "_size")));
18         return mousepos_x >= pos_x*vid_conwidth  && mousepos_x <= (pos_x+sz_x)*vid_conwidth &&
19                mousepos_y >= pos_y*vid_conheight && mousepos_y <= (pos_y+sz_y)*vid_conheight ;
20 }
21
22 // ====================================================================
23 // Minigame Board
24 // ====================================================================
25
26 // Draws the minigame game board
27 void HUD_MinigameBoard ()
28 {
29         entity hud_minigame = NULL;
30
31         if(!autocvar__hud_configure)
32                 hud_minigame = active_minigame.descriptor;
33         else
34                 hud_minigame = minigame_get_descriptor("nmm");
35
36         if ( !hud_minigame )
37                 return;
38
39         HUD_Panel_LoadCvars();
40
41
42         vector pos, mySize;
43         pos = panel_pos;
44         mySize = panel_size;
45
46         hud_minigame.minigame_hud_board(pos,mySize);
47 }
48
49 // ====================================================================
50 // Minigame Status
51 // ====================================================================
52 // Draws the minigame status panel
53 void HUD_MinigameStatus ()
54 {
55         entity hud_minigame = NULL;
56
57         if(!autocvar__hud_configure)
58                 hud_minigame = active_minigame.descriptor;
59         else
60                 hud_minigame = minigame_get_descriptor("nmm");
61
62         if ( !hud_minigame )
63                 return;
64
65         HUD_Panel_LoadCvars();
66
67
68         vector pos, mySize;
69         pos = panel_pos;
70         mySize = panel_size;
71
72         if(panel_bg_padding)
73         {
74                 pos += '1 1 0' * panel_bg_padding;
75                 mySize -= '2 2 0' * panel_bg_padding;
76         }
77
78         HUD_Scale_Disable();
79         hud_minigame.minigame_hud_status(pos,mySize);
80 }
81
82 // ====================================================================
83 // Minigame Menu
84 // ====================================================================
85
86 // Minigame menu options: list head
87 entity HUD_MinigameMenu_entries;
88 // Minigame menu options: list tail
89 entity HUD_MinigameMenu_last_entry;
90
91 // Minigame menu options: insert entry after the given location
92 void HUD_MinigameMenu_InsertEntry(entity newentry, entity prev)
93 {
94         if ( !HUD_MinigameMenu_entries )
95         {
96                 HUD_MinigameMenu_entries = newentry;
97                 HUD_MinigameMenu_last_entry = newentry;
98                 return;
99         }
100
101         newentry.list_prev = prev;
102         newentry.list_next = prev.list_next;
103         if ( prev.list_next )
104                 prev.list_next.list_prev = newentry;
105         else
106                 HUD_MinigameMenu_last_entry = newentry;
107         prev.list_next = newentry;
108
109 }
110
111
112 // minigame menu item uder the mouse
113 entity HUD_MinigameMenu_activeitem;
114
115 // Click the given item
116 void HUD_MinigameMenu_Click(entity menuitem)
117 {
118         if ( menuitem )
119         {
120                 menuitem.use(menuitem, NULL, NULL);
121         }
122 }
123
124 // Minigame menu options: Remove the given entry
125 // Precondition: the given entry is actually in the list
126 void HUD_MinigameMenu_EraseEntry ( entity e )
127 {
128         // remove child items (if any)
129         if ( e.flags & 2 )
130         {
131                 HUD_MinigameMenu_Click(e);
132         }
133
134         if ( e.list_prev )
135                 e.list_prev.list_next = e.list_next;
136         else
137                 HUD_MinigameMenu_entries = e.list_next;
138
139         if ( e.list_next )
140                 e.list_next.list_prev = e.list_prev;
141         else
142                 HUD_MinigameMenu_last_entry = e.list_prev;
143
144         if ( HUD_MinigameMenu_activeitem == e )
145                 HUD_MinigameMenu_activeitem = NULL;
146
147         delete(e);
148 }
149
150 // Minigame menu options: create entry
151 entity HUD_MinigameMenu_SpawnEntry(string s, vector offset, vector fontsize, vector color,void(entity, entity, entity) click)
152 {
153         entity entry = spawn();
154         entry.message = s;
155         entry.origin = offset;
156         entry.size = fontsize;
157         entry.colormod = color;
158         entry.flags = 0;
159         entry.use = click;
160         panel_pos_y += fontsize_y;
161         return entry;
162 }
163
164 // Spawn a child entry of a collapsable entry
165 entity HUD_MinigameMenu_SpawnSubEntry(string s, void(entity, entity, entity) click, entity parent)
166 {
167         vector item_fontsize = hud_fontsize*1.25;
168         vector item_offset = '1 0 0' * item_fontsize_x;
169         entity item = HUD_MinigameMenu_SpawnEntry(
170                                 s,item_offset,item_fontsize,'0.8 0.8 0.8', click );
171         item.owner = parent;
172         return item;
173 }
174
175 // Click action for Create sub-entries
176 void HUD_MinigameMenu_ClickCreate_Entry(entity this, entity actor, entity trigger)
177 {
178         minigame_cmd("create ", this.netname);
179 }
180
181 // Helper click action for collapsible entries
182 // returns true when you have to create the sub-entries
183 bool HUD_MinigameMenu_Click_ExpandCollapse(entity this)
184 {
185         entity e;
186         if ( this.flags & 2 )
187         {
188                 if ( HUD_MinigameMenu_activeitem &&
189                                 HUD_MinigameMenu_activeitem.owner == this )
190                         HUD_MinigameMenu_activeitem = NULL;
191                 this.flags &= ~2;
192                 for ( e = this.list_next; e != NULL && e.owner == this; e = this.list_next )
193                 {
194                         if ( e.flags & 2 )
195                                 HUD_MinigameMenu_Click(e);
196                         this.list_next = e.list_next;
197                         delete(e);
198                 }
199                 if ( this.list_next )
200                         this.list_next.list_prev = this;
201                 else
202                         HUD_MinigameMenu_last_entry = this;
203         }
204         else
205         {
206                 for ( e = HUD_MinigameMenu_entries; e != NULL; e = e.list_next )
207                 {
208                         if ( e.flags & 2 && e.origin_x == this.origin_x)
209                                 HUD_MinigameMenu_Click(e);
210                 }
211
212                 this.flags |= 2;
213
214                 return true;
215         }
216         return false;
217 }
218
219 // Click action for the Create menu
220 void HUD_MinigameMenu_ClickCreate(entity this, entity actor, entity trigger)
221 {
222         if ( HUD_MinigameMenu_Click_ExpandCollapse(this) )
223         {
224                 entity curr;
225                 entity prev = this;
226                 FOREACH(Minigames, true, {
227                         curr = HUD_MinigameMenu_SpawnSubEntry(it.message, HUD_MinigameMenu_ClickCreate_Entry, this);
228                         curr.netname = it.netname;
229                         curr.model = strzone(minigame_texture(strcat(it.netname,"/icon")));
230                         HUD_MinigameMenu_InsertEntry( curr, prev );
231                         prev = curr;
232                 });
233         }
234 }
235
236 // Click action for Join sub-entries
237 void HUD_MinigameMenu_ClickJoin_Entry(entity this, entity actor, entity trigger)
238 {
239         minigame_cmd("join ",this.netname);
240         HUD_MinigameMenu_EraseEntry(this);
241 }
242
243 // Click action for the Join menu
244 void HUD_MinigameMenu_ClickJoin(entity this, entity actor, entity trigger)
245 {
246         if ( HUD_MinigameMenu_Click_ExpandCollapse(this) )
247         {
248                 entity e = NULL;
249                 entity curr;
250                 entity prev = this;
251                 while( (e = find(e,classname,"minigame")) )
252                 {
253                         if ( e != active_minigame )
254                         {
255                                 curr = HUD_MinigameMenu_SpawnSubEntry(
256                                         e.netname, HUD_MinigameMenu_ClickJoin_Entry, this );
257                                 curr.netname = e.netname;
258                                 curr.model = strzone(minigame_texture(strcat(e.descriptor.netname,"/icon")));
259                                 HUD_MinigameMenu_InsertEntry( curr, prev );
260                                 prev = curr;
261                         }
262                 }
263         }
264 }
265
266 /*// Temporary placeholder for un-implemented Click actions
267 void HUD_MinigameMenu_ClickNoop()
268 {
269         dprint("Placeholder for ",this.message,"\n");
270 }*/
271
272 // Click action for Quit
273 void HUD_MinigameMenu_ClickQuit(entity this, entity actor, entity trigger)
274 {
275         deactivate_minigame();
276         minigame_cmd("end");
277 }
278
279 // Click action for Invite sub-entries
280 void HUD_MinigameMenu_ClickInvite_Entry(entity this, entity actor, entity trigger)
281 {
282         minigame_cmd("invite #",this.netname);
283 }
284
285 // Click action for the Invite menu
286 void HUD_MinigameMenu_ClickInvite(entity this, entity actor, entity trigger)
287 {
288         if ( HUD_MinigameMenu_Click_ExpandCollapse(this) )
289         {
290                 entity e;
291                 entity prev = this;
292                 for(int i = 0; i < maxclients; ++i)
293                 {
294                         if ( player_localnum != i && playerslots[i] && entcs_GetName(i) != "" &&
295                                 !findfloat(NULL,minigame_playerslot,i+1) && playerslots[i].ping )
296                         {
297                                 e = HUD_MinigameMenu_SpawnSubEntry(
298                                         strzone(entcs_GetName(i)), HUD_MinigameMenu_ClickInvite_Entry,
299                                         this );
300                                 e.flags |= 1;
301                                 e.netname = strzone(ftos(i+1));
302                                 e.origin_x *= 2;
303                                 HUD_MinigameMenu_InsertEntry(e,prev);
304                                 prev = e;
305                         }
306                 }
307         }
308 }
309
310 void HUD_MinigameMenu_ClickCustomEntry(entity this, entity actor, entity trigger)
311 {
312         if ( active_minigame )
313                 active_minigame.minigame_event(active_minigame,"menu_click",this.netname);
314 }
315
316 // Adds a game-specific entry to the menu
317 void HUD_MinigameMenu_CustomEntry(entity parent, string menumessage, string event_arg)
318 {
319         entity e = HUD_MinigameMenu_SpawnSubEntry(
320                 menumessage, HUD_MinigameMenu_ClickCustomEntry, parent );
321         e.netname = event_arg;
322         HUD_MinigameMenu_InsertEntry(e, parent);
323         //dprint("CustomEntry ",ftos(num_for_edict(parent))," ",menumessage," ",event_arg,"\n");
324 }
325
326 // Click action for the Current Game menu
327 void HUD_MinigameMenu_ClickCurrentGame(entity this, entity actor, entity trigger)
328 {
329         if ( HUD_MinigameMenu_Click_ExpandCollapse(this) )
330         {
331                 HUD_MinigameMenu_InsertEntry( HUD_MinigameMenu_SpawnSubEntry(
332                         _("Quit"), HUD_MinigameMenu_ClickQuit, this ), this);
333
334                 active_minigame.minigame_event(active_minigame,"menu_show",this);
335
336                 HUD_MinigameMenu_InsertEntry( HUD_MinigameMenu_SpawnSubEntry(
337                         _("Invite"), HUD_MinigameMenu_ClickInvite, this), this);
338         }
339 }
340 // Whether the minigame menu panel is open
341 bool HUD_MinigameMenu_IsOpened()
342 {
343         return HUD_MinigameMenu_entries != NULL;
344 }
345
346 // Close the minigame menu panel
347 void HUD_MinigameMenu_Close(entity this, entity actor, entity trigger)
348 {
349         if ( HUD_MinigameMenu_IsOpened() )
350         {
351                 entity e, p;
352                 for ( e = HUD_MinigameMenu_entries; e != NULL; e = p )
353                 {
354                         p = e.list_next;
355                         delete(e);
356                 }
357                 HUD_MinigameMenu_entries = NULL;
358                 HUD_MinigameMenu_last_entry = NULL;
359                 HUD_MinigameMenu_activeitem = NULL;
360         }
361 }
362
363 // toggle a button to manage the current game
364 void HUD_MinigameMenu_CurrentButton()
365 {
366         entity e;
367         if ( active_minigame )
368         {
369                 for ( e = HUD_MinigameMenu_last_entry; e != NULL; e = e.list_prev )
370                         if ( e.classname == "hud_minigamemenu_exit" )
371                         {
372                                 HUD_MinigameMenu_EraseEntry(e);
373                                 break;
374                         }
375                 entity currb = HUD_MinigameMenu_SpawnEntry(
376                         _("Current Game"), '0 0 0', hud_fontsize*1.5,'0.7 0.84 1', HUD_MinigameMenu_ClickCurrentGame );
377                 currb.classname = "hud_minigamemenu_current";
378                 currb.model = strzone(minigame_texture(strcat(active_minigame.descriptor.netname,"/icon")));
379                 HUD_MinigameMenu_InsertEntry(currb,HUD_MinigameMenu_last_entry);
380                 HUD_MinigameMenu_Click(currb);
381         }
382         else
383         {
384                 entity p;
385                 for ( e = HUD_MinigameMenu_last_entry; e != NULL; e = p.list_prev )
386                 {
387                         p = e;
388                         if ( e.classname == "hud_minigamemenu_current" )
389                         {
390                                 p = e.list_next;
391                                 if ( !p )
392                                         p = HUD_MinigameMenu_last_entry;
393                                 HUD_MinigameMenu_EraseEntry(e);
394                                 break;
395                         }
396                 }
397                 for ( e = HUD_MinigameMenu_last_entry; e != NULL; e = e.list_prev )
398                         if ( e.classname == "hud_minigamemenu_exit" )
399                                 return;
400                 entity exit = HUD_MinigameMenu_SpawnEntry(
401                         _("Exit Menu"),'0 0 0',hud_fontsize*1.5,'0.7 0.84 1', HUD_MinigameMenu_Close);
402                 exit.classname = "hud_minigamemenu_exit";
403                 HUD_MinigameMenu_InsertEntry ( exit, HUD_MinigameMenu_last_entry );
404         }
405 }
406
407 // Open the minigame menu panel
408 void HUD_MinigameMenu_Open()
409 {
410         if ( !HUD_MinigameMenu_IsOpened() )
411         {
412                 HUD_MinigameMenu_InsertEntry( HUD_MinigameMenu_SpawnEntry(
413                         _("Create"), '0 0 0', hud_fontsize*1.5,'0.7 0.84 1', HUD_MinigameMenu_ClickCreate),
414                         HUD_MinigameMenu_last_entry );
415                 HUD_MinigameMenu_InsertEntry ( HUD_MinigameMenu_SpawnEntry(
416                         _("Join"),'0 0 0',hud_fontsize*1.5,'0.7 0.84 1', HUD_MinigameMenu_ClickJoin),
417                         HUD_MinigameMenu_last_entry );
418                 HUD_MinigameMenu_CurrentButton();
419                 HUD_MinigameMenu_activeitem = NULL;
420         }
421 }
422
423 // Handles mouse input on to minigame menu panel
424 void HUD_MinigameMenu_MouseInput()
425 {
426         panel = HUD_PANEL(MINIGAMEMENU);
427
428         HUD_Panel_LoadCvars();
429
430         if(panel_bg_padding)
431         {
432                 panel_pos += '1 1 0' * panel_bg_padding;
433                 panel_size -= '2 2 0' * panel_bg_padding;
434         }
435
436         entity e;
437
438         panel_pos_y += hud_fontsize_y*2;
439
440         HUD_MinigameMenu_activeitem = NULL;
441         vector sz;
442         for ( e = HUD_MinigameMenu_entries; e != NULL; e = e.list_next )
443         {
444                 sz = eX*panel_size_x + eY*e.size_y;
445                 if ( e.model )
446                         sz_y = 22;
447                 if ( !HUD_MinigameMenu_activeitem && mousepos_y >= panel_pos_y && mousepos_y <= panel_pos_y + sz_y )
448                 {
449                         HUD_MinigameMenu_activeitem = e;
450                 }
451                 panel_pos_y += sz_y;
452         }
453 }
454
455 // Draw a menu entry
456 void HUD_MinigameMenu_DrawEntry(vector pos, string s, vector fontsize, vector color)
457 {
458         minigame_drawstring_trunc(panel_size_x-pos_x+panel_pos_x, pos, s,
459                                                           fontsize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
460 }
461 // Draw a color-coded menu
462 void HUD_MinigameMenu_DrawColoredEntry(vector pos, string s, vector fontsize)
463 {
464         minigame_drawcolorcodedstring_trunc(panel_size_x-pos_x+panel_pos_x, pos, s,
465                                                           fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
466 }
467
468 // Minigame menu panel UI
469 void HUD_MinigameMenu ()
470 {
471         if ( !HUD_MinigameMenu_IsOpened() )
472                 return;
473
474         HUD_Panel_LoadCvars();
475
476         HUD_Scale_Disable();
477         HUD_Panel_DrawBg();
478
479         if(panel_bg_padding)
480         {
481                 panel_pos += '1 1 0' * panel_bg_padding;
482                 panel_size -= '2 2 0' * panel_bg_padding;
483         }
484
485         HUD_MinigameMenu_DrawEntry(panel_pos,_("Minigames"),hud_fontsize*2,'0.25 0.47 0.72');
486         panel_pos_y += hud_fontsize_y*2;
487
488         vector color;
489         vector offset;
490         float itemh;
491         vector imgsz = '22 22 0'; // NOTE: if changed, edit where HUD_MinigameMenu_activeitem is selected
492         for ( entity e = HUD_MinigameMenu_entries; e != NULL; e = e.list_next )
493         {
494                 color = e.colormod;
495
496                 offset = e.origin;
497                 itemh = e.size_y;
498
499                 if ( e.model )
500                         itemh = imgsz_y;
501
502                 if ( e.flags & 2 )
503                 {
504                         drawfill(panel_pos, eX*panel_size_x + eY*itemh, e.colormod,
505                                         panel_fg_alpha, DRAWFLAG_NORMAL);
506                         color = '0 0 0';
507                 }
508
509                 if ( e.model )
510                 {
511                         drawpic( panel_pos+offset, e.model, imgsz, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL );
512                         offset_x += imgsz_x;
513                         offset_y = (imgsz_y-e.size_y) / 2;
514                 }
515
516                 if ( e.flags & 1 )
517                         HUD_MinigameMenu_DrawColoredEntry(panel_pos+offset,e.message,e.size);
518                 else
519                         HUD_MinigameMenu_DrawEntry(panel_pos+offset,e.message,e.size,color);
520
521                 if ( e == HUD_MinigameMenu_activeitem )
522                         drawfill(panel_pos, eX*panel_size_x + eY*itemh,'1 1 1', 0.25, DRAWFLAG_ADDITIVE);
523
524                 panel_pos_y += itemh;
525         }
526 }
527
528 // ====================================================================
529 // Minigame Help Panel
530 // ====================================================================
531
532 void HUD_MinigameHelp()
533 {
534         string help_message;
535
536         if(!autocvar__hud_configure)
537                 help_message = active_minigame.message;
538         else
539                 help_message = "Minigame message";
540
541         if ( !help_message )
542                 return;
543
544         HUD_Panel_LoadCvars();
545
546
547         vector pos, mySize;
548         pos = panel_pos;
549         mySize = panel_size;
550
551         if(panel_bg_padding)
552         {
553                 pos += '1 1 0' * panel_bg_padding;
554                 mySize -= '2 2 0' * panel_bg_padding;
555         }
556
557         minigame_drawcolorcodedstring_wrapped( mySize_x, pos, help_message,
558                 hud_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL, 0.5 );
559 }
560
561 // ====================================================================
562 // Minigame Panel Input
563 // ====================================================================
564 float HUD_Minigame_InputEvent(float bInputType, float nPrimary, float nSecondary)
565 {
566
567         if( !HUD_MinigameMenu_IsOpened() || autocvar__hud_configure )
568                 return false;
569
570         if(bInputType == 3)
571         {
572                 mousepos_x = nPrimary;
573                 mousepos_y = nSecondary;
574                 if ( active_minigame && HUD_mouse_over(HUD_PANEL(MINIGAMEBOARD)) )
575                         active_minigame.minigame_event(active_minigame,"mouse_moved",mousepos);
576                 return true;
577
578         }
579         else
580         {
581                 if(bInputType == 0) {
582                         if(nPrimary == K_ALT) hudShiftState |= S_ALT;
583                         if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
584                         if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
585                         if(nPrimary == K_MOUSE1) mouseClicked |= S_MOUSE1;
586                         if(nPrimary == K_MOUSE2) mouseClicked |= S_MOUSE2;
587                 }
588                 else if(bInputType == 1) {
589                         if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
590                         if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
591                         if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
592                         if(nPrimary == K_MOUSE1) mouseClicked -= (mouseClicked & S_MOUSE1);
593                         if(nPrimary == K_MOUSE2) mouseClicked -= (mouseClicked & S_MOUSE2);
594                 }
595
596                 // allow some binds
597                 string con_keys = findkeysforcommand("toggleconsole", 0);
598                 int keys = tokenize(con_keys); // findkeysforcommand returns data for this
599                 int i;
600                 for (i = 0; i < keys; ++i)
601                 {
602                         if(nPrimary == stof(argv(i)))
603                                 return false;
604                 }
605
606                 if ( active_minigame && ( bInputType == 0 || bInputType == 1 ) )
607                 {
608                         string device = "";
609                         string action = bInputType == 0 ? "pressed" : "released";
610                         if ( nPrimary >= K_MOUSE1 && nPrimary <= K_MOUSE16 )
611                         {
612                                 if ( HUD_mouse_over(HUD_PANEL(MINIGAMEBOARD)) )
613                                         device = "mouse";
614                         }
615                         else
616                                 device = "key";
617
618                         if ( device && active_minigame.minigame_event(
619                                         active_minigame,strcat(device,"_",action),nPrimary) )
620                                 return true;
621
622                         /// TODO: bInputType == 2?
623                 }
624
625                 if ( bInputType == 0 )
626                 {
627                         if ( nPrimary == K_MOUSE1 && HUD_MinigameMenu_activeitem &&
628                                 HUD_mouse_over(HUD_PANEL(MINIGAMEMENU)) )
629                         {
630                                 HUD_MinigameMenu_Click(HUD_MinigameMenu_activeitem);
631                                 return true;
632                         }
633                         if ( nPrimary == K_UPARROW || nPrimary == K_KP_UPARROW )
634                         {
635                                 if ( HUD_MinigameMenu_activeitem && HUD_MinigameMenu_activeitem.list_prev )
636                                         HUD_MinigameMenu_activeitem = HUD_MinigameMenu_activeitem.list_prev;
637                                 else
638                                         HUD_MinigameMenu_activeitem = HUD_MinigameMenu_last_entry;
639                                 return true;
640                         }
641                         else if ( nPrimary == K_DOWNARROW || nPrimary == K_KP_DOWNARROW )
642                         {
643                                 if ( HUD_MinigameMenu_activeitem && HUD_MinigameMenu_activeitem.list_next )
644                                         HUD_MinigameMenu_activeitem = HUD_MinigameMenu_activeitem.list_next;
645                                 else
646                                         HUD_MinigameMenu_activeitem = HUD_MinigameMenu_entries;
647                                 return true;
648                         }
649                         else if ( nPrimary == K_HOME || nPrimary == K_KP_HOME )
650                         {
651                                 HUD_MinigameMenu_activeitem = HUD_MinigameMenu_entries;
652                                 return true;
653                         }
654                         else if ( nPrimary == K_END || nPrimary == K_KP_END )
655                         {
656                                 HUD_MinigameMenu_activeitem = HUD_MinigameMenu_entries;
657                                 return true;
658                         }
659                         else if ( nPrimary == K_KP_ENTER || nPrimary == K_ENTER || nPrimary == K_SPACE )
660                         {
661                                 HUD_MinigameMenu_Click(HUD_MinigameMenu_activeitem);
662                                 return true;
663                         }
664                         else if ( nPrimary == K_ESCAPE )
665                         {
666                                 HUD_MinigameMenu_Close(NULL, NULL, NULL);
667                                 return true;
668                         }
669                 }
670         }
671
672         return false;
673
674 }
675
676 void HUD_Minigame_Mouse()
677 {
678         if( !HUD_MinigameMenu_IsOpened() || autocvar__hud_configure || mv_active )
679                 return;
680
681         if ( HUD_MinigameMenu_IsOpened() && HUD_mouse_over(HUD_PANEL(MINIGAMEMENU)) )
682                 HUD_MinigameMenu_MouseInput();
683 }