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