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