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