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