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