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