]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/minigames/cl_minigames_hud.qc
Merge branch 'master' into bones_was_here/q3compat
[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(entity entry, string s, vector offset, vector fontsize, vector color,void(entity, entity, entity) click)
185 {
186         entry.message = s;
187         entry.origin = offset;
188         entry.size = fontsize;
189         entry.colormod = color;
190         entry.flags = 0;
191         entry.use = click;
192         panel_pos_y += fontsize_y;
193         return entry;
194 }
195
196 // Spawn a child entry of a collapsable entry
197 entity HUD_MinigameMenu_SpawnSubEntry(string s, void(entity, entity, entity) click, entity parent)
198 {
199         vector item_fontsize = hud_fontsize*1.25;
200         vector item_offset = '1 0 0' * item_fontsize_x;
201         entity item = HUD_MinigameMenu_SpawnEntry(new(hud_minigamemenu_subentry),
202                                 s,item_offset,item_fontsize,'0.8 0.8 0.8', click );
203         item.owner = parent;
204         return item;
205 }
206
207 // Click action for Create sub-entries
208 void HUD_MinigameMenu_ClickCreate_Entry(entity this, entity actor, entity trigger)
209 {
210         minigame_cmd("create ", this.netname);
211 }
212
213 // Helper click action for collapsible entries
214 // returns true when you have to create the sub-entries
215 bool HUD_MinigameMenu_Click_ExpandCollapse(entity this)
216 {
217         entity e;
218         if ( this.flags & 2 )
219         {
220                 if ( HUD_MinigameMenu_activeitem &&
221                                 HUD_MinigameMenu_activeitem.owner == this )
222                         HUD_MinigameMenu_activeitem = NULL;
223                 this.flags &= ~2;
224                 for ( e = this.list_next; e != NULL && e.owner == this; e = this.list_next )
225                 {
226                         if ( e.flags & 2 )
227                                 HUD_MinigameMenu_Click(e);
228                         this.list_next = e.list_next;
229                         delete(e);
230                 }
231                 if ( this.list_next )
232                         this.list_next.list_prev = this;
233                 else
234                         HUD_MinigameMenu_last_entry = this;
235         }
236         else
237         {
238                 for ( e = HUD_MinigameMenu_entries; e != NULL; e = e.list_next )
239                 {
240                         if ( (e.flags & 2) && e.origin_x == this.origin_x)
241                                 HUD_MinigameMenu_Click(e);
242                 }
243
244                 this.flags |= 2;
245
246                 return true;
247         }
248         return false;
249 }
250
251 // Click action for the Create menu
252 void HUD_MinigameMenu_ClickCreate(entity this, entity actor, entity trigger)
253 {
254         if ( HUD_MinigameMenu_Click_ExpandCollapse(this) )
255         {
256                 entity curr;
257                 entity prev = this;
258                 FOREACH(Minigames, true, {
259                         curr = HUD_MinigameMenu_SpawnSubEntry(it.message, HUD_MinigameMenu_ClickCreate_Entry, this);
260                         curr.netname = it.netname;
261                         curr.model = strzone(minigame_texture(strcat(it.netname,"/icon")));
262                         HUD_MinigameMenu_InsertEntry( curr, prev );
263                         prev = curr;
264                 });
265         }
266 }
267
268 // Click action for Join sub-entries
269 void HUD_MinigameMenu_ClickJoin_Entry(entity this, entity actor, entity trigger)
270 {
271         minigame_cmd("join ",this.netname);
272         HUD_MinigameMenu_EraseEntry(this);
273 }
274
275 // Click action for the Join menu
276 void HUD_MinigameMenu_ClickJoin(entity this, entity actor, entity trigger)
277 {
278         if ( HUD_MinigameMenu_Click_ExpandCollapse(this) )
279         {
280                 entity e = NULL;
281                 entity curr;
282                 entity prev = this;
283                 while( (e = find(e,classname,"minigame")) )
284                 {
285                         if ( e != active_minigame )
286                         {
287                                 curr = HUD_MinigameMenu_SpawnSubEntry(
288                                         e.netname, HUD_MinigameMenu_ClickJoin_Entry, this );
289                                 curr.netname = e.netname;
290                                 curr.model = strzone(minigame_texture(strcat(e.descriptor.netname,"/icon")));
291                                 HUD_MinigameMenu_InsertEntry( curr, prev );
292                                 prev = curr;
293                         }
294                 }
295         }
296 }
297
298 /*// Temporary placeholder for un-implemented Click actions
299 void HUD_MinigameMenu_ClickNoop()
300 {
301         dprint("Placeholder for ",this.message,"\n");
302 }*/
303
304 // Click action for Quit
305 void HUD_MinigameMenu_ClickQuit(entity this, entity actor, entity trigger)
306 {
307         deactivate_minigame();
308         minigame_cmd("end");
309 }
310
311 // Click action for Invite sub-entries
312 void HUD_MinigameMenu_ClickInvite_Entry(entity this, entity actor, entity trigger)
313 {
314         minigame_cmd("invite #",this.netname);
315 }
316
317 // Click action for the Invite menu
318 void HUD_MinigameMenu_ClickInvite(entity this, entity actor, entity trigger)
319 {
320         if ( HUD_MinigameMenu_Click_ExpandCollapse(this) )
321         {
322                 entity e;
323                 entity prev = this;
324                 for(int i = 0; i < maxclients; ++i)
325                 {
326                         if ( player_localnum != i && playerslots[i] && entcs_GetName(i) != "" &&
327                                 !findfloat(NULL,minigame_playerslot,i+1) && playerslots[i].ping )
328                         {
329                                 e = HUD_MinigameMenu_SpawnSubEntry(
330                                         strzone(entcs_GetName(i)), HUD_MinigameMenu_ClickInvite_Entry,
331                                         this );
332                                 e.flags |= 1;
333                                 e.netname = strzone(ftos(i+1));
334                                 e.origin_x *= 2;
335                                 HUD_MinigameMenu_InsertEntry(e,prev);
336                                 prev = e;
337                         }
338                 }
339         }
340 }
341
342 void HUD_MinigameMenu_ClickCustomEntry(entity this, entity actor, entity trigger)
343 {
344         if ( active_minigame )
345                 active_minigame.minigame_event(active_minigame,"menu_click",this.netname);
346 }
347
348 // Adds a game-specific entry to the menu
349 void HUD_MinigameMenu_CustomEntry(entity parent, string menumessage, string event_arg)
350 {
351         entity e = HUD_MinigameMenu_SpawnSubEntry(
352                 menumessage, HUD_MinigameMenu_ClickCustomEntry, parent );
353         e.netname = event_arg;
354         HUD_MinigameMenu_InsertEntry(e, parent);
355         //dprint("CustomEntry ",ftos(num_for_edict(parent))," ",menumessage," ",event_arg,"\n");
356 }
357
358 // Click action for the Current Game menu
359 void HUD_MinigameMenu_ClickCurrentGame(entity this, entity actor, entity trigger)
360 {
361         if ( HUD_MinigameMenu_Click_ExpandCollapse(this) )
362         {
363                 HUD_MinigameMenu_InsertEntry( HUD_MinigameMenu_SpawnSubEntry(
364                         _("Quit"), HUD_MinigameMenu_ClickQuit, this ), this);
365
366                 active_minigame.minigame_event(active_minigame,"menu_show",this);
367
368                 HUD_MinigameMenu_InsertEntry( HUD_MinigameMenu_SpawnSubEntry(
369                         _("Invite"), HUD_MinigameMenu_ClickInvite, this), this);
370         }
371 }
372 // Whether the minigame menu panel is open
373 bool HUD_MinigameMenu_IsOpened()
374 {
375         return HUD_MinigameMenu_entries != NULL;
376 }
377
378 // Close the minigame menu panel
379 void HUD_MinigameMenu_Close(entity this, entity actor, entity trigger)
380 {
381         if ( HUD_MinigameMenu_IsOpened() )
382         {
383                 entity e, p;
384                 for ( e = HUD_MinigameMenu_entries; e != NULL; e = p )
385                 {
386                         p = e.list_next;
387                         delete(e);
388                 }
389                 HUD_MinigameMenu_entries = NULL;
390                 HUD_MinigameMenu_last_entry = NULL;
391                 HUD_MinigameMenu_activeitem = NULL;
392         }
393 }
394
395 // toggle a button to manage the current game
396 void HUD_MinigameMenu_CurrentButton()
397 {
398         entity e;
399         if ( active_minigame )
400         {
401                 for ( e = HUD_MinigameMenu_last_entry; e != NULL; e = e.list_prev )
402                         if ( e.classname == "hud_minigamemenu_exit" )
403                         {
404                                 HUD_MinigameMenu_EraseEntry(e);
405                                 break;
406                         }
407                 entity currb = HUD_MinigameMenu_SpawnEntry(new(hud_minigamemenu_current),
408                         _("Current Game"), '0 0 0', hud_fontsize*1.5,'0.7 0.84 1', HUD_MinigameMenu_ClickCurrentGame );
409                 currb.model = strzone(minigame_texture(strcat(active_minigame.descriptor.netname,"/icon")));
410                 HUD_MinigameMenu_InsertEntry(currb,HUD_MinigameMenu_last_entry);
411                 HUD_MinigameMenu_Click(currb);
412         }
413         else
414         {
415                 entity p;
416                 for ( e = HUD_MinigameMenu_last_entry; e != NULL; e = p.list_prev )
417                 {
418                         p = e;
419                         if ( e.classname == "hud_minigamemenu_current" )
420                         {
421                                 p = e.list_next;
422                                 if ( !p )
423                                         p = HUD_MinigameMenu_last_entry;
424                                 HUD_MinigameMenu_EraseEntry(e);
425                                 break;
426                         }
427                 }
428                 for ( e = HUD_MinigameMenu_last_entry; e != NULL; e = e.list_prev )
429                         if ( e.classname == "hud_minigamemenu_exit" )
430                                 return;
431                 entity exit = HUD_MinigameMenu_SpawnEntry(new(hud_minigamemenu_exit),
432                         _("Exit Menu"),'0 0 0',hud_fontsize*1.5,'0.7 0.84 1', HUD_MinigameMenu_Close);
433                 HUD_MinigameMenu_InsertEntry ( exit, HUD_MinigameMenu_last_entry );
434         }
435 }
436
437 // Open the minigame menu panel
438 void HUD_MinigameMenu_Open()
439 {
440         if ( !mv_active && !HUD_MinigameMenu_IsOpened() )
441         {
442                 HUD_MinigameMenu_InsertEntry( HUD_MinigameMenu_SpawnEntry(new(hud_minigamemenu_entry),
443                         _("Create"), '0 0 0', hud_fontsize*1.5,'0.7 0.84 1', HUD_MinigameMenu_ClickCreate),
444                         HUD_MinigameMenu_last_entry );
445                 HUD_MinigameMenu_InsertEntry ( HUD_MinigameMenu_SpawnEntry(new(hud_minigamemenu_entry),
446                         _("Join"),'0 0 0',hud_fontsize*1.5,'0.7 0.84 1', HUD_MinigameMenu_ClickJoin),
447                         HUD_MinigameMenu_last_entry );
448                 HUD_MinigameMenu_CurrentButton();
449                 HUD_MinigameMenu_activeitem = NULL;
450         }
451 }
452
453 // Handles mouse input on to minigame menu panel
454 void HUD_MinigameMenu_MouseInput()
455 {
456         panel = HUD_PANEL(MINIGAMEMENU);
457
458         HUD_Panel_LoadCvars();
459
460         if(panel_bg_padding)
461         {
462                 panel_pos += '1 1 0' * panel_bg_padding;
463                 panel_size -= '2 2 0' * panel_bg_padding;
464         }
465
466         entity e;
467
468         panel_pos_y += hud_fontsize_y*2;
469
470         HUD_MinigameMenu_activeitem = NULL;
471         vector sz;
472         for ( e = HUD_MinigameMenu_entries; e != NULL; e = e.list_next )
473         {
474                 sz = eX*panel_size_x + eY*e.size_y;
475                 if ( e.model )
476                         sz_y = 22;
477                 if ( !HUD_MinigameMenu_activeitem && mousepos_y >= panel_pos_y && mousepos_y <= panel_pos_y + sz_y )
478                 {
479                         HUD_MinigameMenu_activeitem = e;
480                 }
481                 panel_pos_y += sz_y;
482         }
483 }
484
485 // Draw a menu entry
486 void HUD_MinigameMenu_DrawEntry(vector pos, string s, vector fontsize, vector color)
487 {
488         minigame_drawstring_trunc(panel_size_x-pos_x+panel_pos_x, pos, s,
489                                                           fontsize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
490 }
491 // Draw a color-coded menu
492 void HUD_MinigameMenu_DrawColoredEntry(vector pos, string s, vector fontsize)
493 {
494         minigame_drawcolorcodedstring_trunc(panel_size_x-pos_x+panel_pos_x, pos, s,
495                                                           fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
496 }
497
498 // Minigame menu panel UI
499 void HUD_MinigameMenu ()
500 {
501         if (mv_active)
502         {
503                 if (HUD_MinigameMenu_IsOpened())
504                         HUD_MinigameMenu_Close(NULL, NULL, NULL);
505                 return;
506         }
507
508         if ( !HUD_MinigameMenu_IsOpened() )
509                 return;
510
511         HUD_Panel_LoadCvars();
512
513         HUD_Scale_Disable();
514         HUD_Panel_DrawBg();
515
516         if(panel_bg_padding)
517         {
518                 panel_pos += '1 1 0' * panel_bg_padding;
519                 panel_size -= '2 2 0' * panel_bg_padding;
520         }
521
522         HUD_MinigameMenu_DrawEntry(panel_pos,_("Minigames"),hud_fontsize*2,'0.25 0.47 0.72');
523         panel_pos_y += hud_fontsize_y*2;
524
525         vector color;
526         vector offset;
527         float itemh;
528         vector imgsz = '22 22 0'; // NOTE: if changed, edit where HUD_MinigameMenu_activeitem is selected
529         for ( entity e = HUD_MinigameMenu_entries; e != NULL; e = e.list_next )
530         {
531                 color = e.colormod;
532
533                 offset = e.origin;
534                 itemh = e.size_y;
535
536                 if ( e.model )
537                         itemh = imgsz_y;
538
539                 if ( e.flags & 2 )
540                 {
541                         drawfill(panel_pos, eX*panel_size_x + eY*itemh, e.colormod,
542                                         panel_fg_alpha, DRAWFLAG_NORMAL);
543                         color = '0 0 0';
544                 }
545
546                 if ( e.model )
547                 {
548                         drawpic( panel_pos+offset, e.model, imgsz, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL );
549                         offset_x += imgsz_x;
550                         offset_y = (imgsz_y-e.size_y) / 2;
551                 }
552
553                 if ( e.flags & 1 )
554                         HUD_MinigameMenu_DrawColoredEntry(panel_pos+offset,e.message,e.size);
555                 else
556                         HUD_MinigameMenu_DrawEntry(panel_pos+offset,e.message,e.size,color);
557
558                 if ( e == HUD_MinigameMenu_activeitem )
559                         drawfill(panel_pos, eX*panel_size_x + eY*itemh,'1 1 1', 0.25, DRAWFLAG_ADDITIVE);
560
561                 panel_pos_y += itemh;
562         }
563 }
564
565 // ====================================================================
566 // Minigame Help Panel
567 // ====================================================================
568
569 void HUD_MinigameHelp()
570 {
571         if (!HUD_MinigameMenu_IsOpened())
572                 return;
573
574         string help_message;
575
576         if(!autocvar__hud_configure)
577         {
578                 if (!active_minigame)
579                         return;
580                 help_message = active_minigame.message;
581         }
582         else
583                 help_message = _("Minigame message");
584
585         if ( !help_message )
586                 return;
587
588         HUD_Panel_LoadCvars();
589
590
591         vector pos, mySize;
592         pos = panel_pos;
593         mySize = panel_size;
594
595         if(panel_bg_padding)
596         {
597                 pos += '1 1 0' * panel_bg_padding;
598                 mySize -= '2 2 0' * panel_bg_padding;
599         }
600
601         minigame_drawcolorcodedstring_wrapped( mySize_x, pos, help_message,
602                 hud_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL, 0.5 );
603 }
604
605 // ====================================================================
606 // Minigame Panel Input
607 // ====================================================================
608 float HUD_Minigame_InputEvent(float bInputType, float nPrimary, float nSecondary)
609 {
610
611         if( !HUD_MinigameMenu_IsOpened() || autocvar__hud_configure )
612                 return false;
613
614         if(bInputType == 3)
615         {
616                 mousepos_x = nPrimary;
617                 mousepos_y = nSecondary;
618                 if ( active_minigame && HUD_mouse_over(HUD_PANEL(MINIGAMEBOARD)) )
619                         active_minigame.minigame_event(active_minigame,"mouse_moved",mousepos);
620                 return true;
621
622         }
623         else
624         {
625                 if(bInputType == 0) {
626                         if(nPrimary == K_ALT) hudShiftState |= S_ALT;
627                         if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
628                         if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
629                         if(nPrimary == K_MOUSE1) mouseClicked |= S_MOUSE1;
630                         if(nPrimary == K_MOUSE2) mouseClicked |= S_MOUSE2;
631                 }
632                 else if(bInputType == 1) {
633                         if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
634                         if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
635                         if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
636                         if(nPrimary == K_MOUSE1) mouseClicked -= (mouseClicked & S_MOUSE1);
637                         if(nPrimary == K_MOUSE2) mouseClicked -= (mouseClicked & S_MOUSE2);
638                 }
639
640                 // allow some binds
641                 string con_keys = findkeysforcommand("toggleconsole", 0);
642                 int keys = tokenize(con_keys); // findkeysforcommand returns data for this
643                 int i;
644                 for (i = 0; i < keys; ++i)
645                 {
646                         if(nPrimary == stof(argv(i)))
647                                 return false;
648                 }
649
650                 if ( active_minigame && ( bInputType == 0 || bInputType == 1 ) )
651                 {
652                         string device = "";
653                         string action = bInputType == 0 ? "pressed" : "released";
654                         if ( nPrimary >= K_MOUSE1 && nPrimary <= K_MOUSE16 )
655                         {
656                                 if ( HUD_mouse_over(HUD_PANEL(MINIGAMEBOARD)) )
657                                         device = "mouse";
658                         }
659                         else
660                                 device = "key";
661
662                         if ( device && active_minigame.minigame_event(
663                                         active_minigame,strcat(device,"_",action),nPrimary) )
664                                 return true;
665
666                         /// TODO: bInputType == 2?
667                 }
668
669                 if ( bInputType == 0 )
670                 {
671                         if ( nPrimary == K_MOUSE1 && HUD_MinigameMenu_activeitem &&
672                                 HUD_mouse_over(HUD_PANEL(MINIGAMEMENU)) )
673                         {
674                                 HUD_MinigameMenu_Click(HUD_MinigameMenu_activeitem);
675                                 return true;
676                         }
677                         if ( nPrimary == K_UPARROW || nPrimary == K_KP_UPARROW )
678                         {
679                                 if ( HUD_MinigameMenu_activeitem && HUD_MinigameMenu_activeitem.list_prev )
680                                         HUD_MinigameMenu_activeitem = HUD_MinigameMenu_activeitem.list_prev;
681                                 else
682                                         HUD_MinigameMenu_activeitem = HUD_MinigameMenu_last_entry;
683                                 return true;
684                         }
685                         else if ( nPrimary == K_DOWNARROW || nPrimary == K_KP_DOWNARROW )
686                         {
687                                 if ( HUD_MinigameMenu_activeitem && HUD_MinigameMenu_activeitem.list_next )
688                                         HUD_MinigameMenu_activeitem = HUD_MinigameMenu_activeitem.list_next;
689                                 else
690                                         HUD_MinigameMenu_activeitem = HUD_MinigameMenu_entries;
691                                 return true;
692                         }
693                         else if ( nPrimary == K_HOME || nPrimary == K_KP_HOME )
694                         {
695                                 HUD_MinigameMenu_activeitem = HUD_MinigameMenu_entries;
696                                 return true;
697                         }
698                         else if ( nPrimary == K_END || nPrimary == K_KP_END )
699                         {
700                                 HUD_MinigameMenu_activeitem = HUD_MinigameMenu_entries;
701                                 return true;
702                         }
703                         else if ( nPrimary == K_KP_ENTER || nPrimary == K_ENTER || nPrimary == K_SPACE )
704                         {
705                                 HUD_MinigameMenu_Click(HUD_MinigameMenu_activeitem);
706                                 return true;
707                         }
708                         else if ( nPrimary == K_ESCAPE )
709                         {
710                                 HUD_MinigameMenu_Close(NULL, NULL, NULL);
711                                 return true;
712                         }
713                 }
714         }
715
716         return false;
717
718 }
719
720 void HUD_Minigame_Mouse()
721 {
722         if( !HUD_MinigameMenu_IsOpened() || autocvar__hud_configure || mv_active )
723                 return;
724
725         if ( HUD_MinigameMenu_IsOpened() && HUD_mouse_over(HUD_PANEL(MINIGAMEMENU)) )
726                 HUD_MinigameMenu_MouseInput();
727 }