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