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