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