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