]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/minigames/cl_minigames_hud.qc
Minigame code and cfg
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / minigames / cl_minigames_hud.qc
1 #include "minigames.qh"
2 #include "../../client/mapvoting.qh"
3
4 float HUD_mouse_over(entity somepanel)
5 {
6         vector pos = stov(cvar_string(strcat("hud_panel_", somepanel.panel_name, "_pos")));
7         vector sz = stov(cvar_string(strcat("hud_panel_", somepanel.panel_name, "_size")));
8         return mousepos_x >= pos_x*vid_conwidth  && mousepos_x <= (pos_x+sz_x)*vid_conwidth && 
9                mousepos_y >= pos_y*vid_conheight && mousepos_y <= (pos_y+sz_y)*vid_conheight ;
10 }
11
12 // ====================================================================
13 // Minigame Board
14 // ====================================================================
15
16 void HUD_MinigameBoard ()
17 {
18         entity hud_minigame = world;
19         
20         if(!autocvar__hud_configure)
21                 hud_minigame = active_minigame.descriptor;
22         else
23                 hud_minigame = minigame_get_descriptor("nmm");
24         
25         if ( !hud_minigame )
26                 return;
27         
28         HUD_Panel_UpdateCvars();
29         
30         
31         vector pos, mySize;
32         pos = panel_pos;
33         mySize = panel_size;
34         
35         hud_minigame.minigame_hud_board(pos,mySize);
36 }
37
38 // ====================================================================
39 // Minigame Status
40 // ====================================================================
41 void HUD_MinigameStatus ()
42 {
43         entity hud_minigame = world;
44         
45         if(!autocvar__hud_configure)
46                 hud_minigame = active_minigame.descriptor;
47         else
48                 hud_minigame = minigame_get_descriptor("nmm");
49         
50         if ( !hud_minigame )
51                 return;
52         
53         HUD_Panel_UpdateCvars();
54         
55         
56         vector pos, mySize;
57         pos = panel_pos;
58         mySize = panel_size;
59         
60         if(panel_bg_padding)
61         {
62                 pos += '1 1 0' * panel_bg_padding;
63                 mySize -= '2 2 0' * panel_bg_padding;
64         }
65         
66         hud_minigame.minigame_hud_status(pos,mySize);
67 }
68
69 // ====================================================================
70 // Minigame Menu
71 // ====================================================================
72
73 // Minigame menu options: list head
74 entity HUD_MinigameMenu_entries;
75 // Minigame menu options: list tail
76 entity HUD_MinigameMenu_last_entry;
77
78 // Minigame menu options: insert entry after the given location
79 void HUD_MinigameMenu_InsertEntry(entity new, entity prev)
80 {
81         if ( !HUD_MinigameMenu_entries )
82         {
83                 HUD_MinigameMenu_entries = new;
84                 HUD_MinigameMenu_last_entry = new;
85                 return;
86         }
87         
88         new.list_prev = prev;
89         new.list_next = prev.list_next;
90         if ( prev.list_next )
91                 prev.list_next.list_prev = new;
92         else
93                 HUD_MinigameMenu_last_entry = new;
94         prev.list_next = new;
95         
96 }
97
98
99 // minigame menu item uder the mouse
100 entity HUD_MinigameMenu_activeitem;
101
102 // Click the given item
103 void HUD_MinigameMenu_Click(entity menuitem)
104 {
105         if ( menuitem )
106         {
107                 entity e = self;
108                 self = menuitem;
109                 menuitem.use();
110                 self = e;
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 {
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 float HUD_MinigameMenu_Click_ExpandCollapse()
174 {
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         }
192         else
193         {
194                 for ( e = HUD_MinigameMenu_entries; e != world; e = e.list_next )
195                 {
196                         if ( e.flags & 2 && e.origin_x == self.origin_x)
197                                 HUD_MinigameMenu_Click(e);
198                 }
199                 
200                 self.flags |= 2;
201                 
202                 return true;
203         }
204         return false;
205 }
206
207 // Click action for the Create menu
208 void HUD_MinigameMenu_ClickCreate()
209 {
210         if ( HUD_MinigameMenu_Click_ExpandCollapse() )
211         {
212                 entity e;
213                 entity curr;
214                 entity prev = self;
215                 for ( e = minigame_descriptors; e != world; e = e.list_next )
216                 {
217                         curr = HUD_MinigameMenu_SpawnSubEntry(
218                                 e.message, HUD_MinigameMenu_ClickCreate_Entry,  self );
219                         curr.netname = e.netname;
220                         curr.model = strzone(minigame_texture(strcat(e.netname,"/icon")));
221                         HUD_MinigameMenu_InsertEntry( curr, prev );
222                         prev = curr;
223                 }
224         }
225 }
226
227 // Click action for Join sub-entries
228 void HUD_MinigameMenu_ClickJoin_Entry()
229 {
230         minigame_cmd("join ",self.netname);
231         HUD_MinigameMenu_EraseEntry(self);
232 }
233
234 // Click action for the Join menu
235 void HUD_MinigameMenu_ClickJoin()
236 {
237         if ( HUD_MinigameMenu_Click_ExpandCollapse() )
238         {
239                 entity e = world;
240                 entity curr;
241                 entity prev = self;
242                 while( (e = find(e,classname,"minigame")) )
243                 {
244                         if ( e != active_minigame )
245                         {
246                                 curr = HUD_MinigameMenu_SpawnSubEntry(
247                                         e.netname, HUD_MinigameMenu_ClickJoin_Entry, self );
248                                 curr.netname = e.netname;
249                                 curr.model = strzone(minigame_texture(strcat(e.descriptor.netname,"/icon")));
250                                 HUD_MinigameMenu_InsertEntry( curr, prev );
251                                 prev = curr;
252                         }
253                 }
254         }
255 }
256
257 /*// Temporary placeholder for un-implemented Click actions
258 void HUD_MinigameMenu_ClickNoop()
259 {
260         dprint("Placeholder for ",self.message,"\n");
261 }*/
262
263 // Click action for Quit
264 void HUD_MinigameMenu_ClickQuit()
265 {
266         minigame_cmd("end");
267 }
268
269 // Click action for Invite sub-entries
270 void HUD_MinigameMenu_ClickInvite_Entry()
271 {
272         minigame_cmd("invite #",self.netname);
273 }
274
275 // Click action for the Invite menu
276 void HUD_MinigameMenu_ClickInvite()
277 {
278         if ( HUD_MinigameMenu_Click_ExpandCollapse() )
279         {
280                 float i;
281                 entity e;
282                 entity prev = self;
283                 for(i = 0; i < maxclients; ++i)
284                 {
285                         if ( player_localnum != i && playerslots[i] && GetPlayerName(i) != "" &&
286                                 !findfloat(world,minigame_playerslot,i+1) && playerslots[i].ping )
287                         {
288                                 e = HUD_MinigameMenu_SpawnSubEntry(
289                                         strzone(GetPlayerName(i)), HUD_MinigameMenu_ClickInvite_Entry,
290                                         self );
291                                 e.flags |= 1;
292                                 e.netname = strzone(ftos(i+1));
293                                 e.origin_x *= 2;
294                                 HUD_MinigameMenu_InsertEntry(e,prev);
295                                 prev = e;
296                         }
297                 }
298         }
299 }
300
301 void HUD_MinigameMenu_ClickCustomEntry()
302 {
303         if ( active_minigame )
304                 active_minigame.minigame_event(active_minigame,"menu_click",self.netname);
305 }
306
307 // Adds a game-specific entry to the menu
308 void HUD_MinigameMenu_CustomEntry(entity parent, string menumessage, string event_arg)
309 {
310         entity e = HUD_MinigameMenu_SpawnSubEntry(
311                 menumessage, HUD_MinigameMenu_ClickCustomEntry, parent );
312         e.netname = event_arg;
313         HUD_MinigameMenu_InsertEntry(e, parent);
314         dprint("CustomEntry ",ftos(num_for_edict(parent))," ",menumessage," ",event_arg,"\n");
315 }
316
317 // Click action for the Current Game menu
318 void HUD_MinigameMenu_ClickCurrentGame()
319 {
320         if ( HUD_MinigameMenu_Click_ExpandCollapse() )
321         {
322                 HUD_MinigameMenu_InsertEntry( HUD_MinigameMenu_SpawnSubEntry(
323                         _("Quit"), HUD_MinigameMenu_ClickQuit, self ), self);
324                 
325                 active_minigame.minigame_event(active_minigame,"menu_show",self);
326                 
327                 HUD_MinigameMenu_InsertEntry( HUD_MinigameMenu_SpawnSubEntry(
328                         _("Invite"), HUD_MinigameMenu_ClickInvite, self), self);
329         }
330 }
331 // Whether the minigame menu panel is open
332 float HUD_MinigameMenu_IsOpened()
333 {
334         return !!HUD_MinigameMenu_entries;
335 }
336
337 // Close the minigame menu panel
338 void HUD_MinigameMenu_Close()
339 {
340         if ( HUD_MinigameMenu_IsOpened() )
341         {
342                 entity e, p;
343                 for ( e = HUD_MinigameMenu_entries; e != world; e = p )
344                 {
345                         p = e.list_next;
346                         remove(e);
347                 }
348                 HUD_MinigameMenu_entries = world;
349                 HUD_MinigameMenu_last_entry = world;
350                 HUD_MinigameMenu_activeitem = world;
351                 if(autocvar_hud_cursormode)
352                 if ( !autocvar__hud_configure )
353                         setcursormode(0);
354         }
355 }
356
357 // toggle a button to manage the current game
358 void HUD_MinigameMenu_CurrentButton()
359 {
360         entity e;
361         if ( active_minigame )
362         {
363                 for ( e = HUD_MinigameMenu_last_entry; e != world; e = e.list_prev )
364                         if ( e.classname == "hud_minigamemenu_exit" )
365                         {
366                                 HUD_MinigameMenu_EraseEntry(e);
367                                 break;
368                         }
369                 entity currb = HUD_MinigameMenu_SpawnEntry(
370                         _("Current Game"), '0 0 0', hud_fontsize*1.5,'0.7 0.84 1', HUD_MinigameMenu_ClickCurrentGame );
371                 currb.classname = "hud_minigamemenu_current";
372                 currb.model = strzone(minigame_texture(strcat(active_minigame.descriptor.netname,"/icon")));
373                 HUD_MinigameMenu_InsertEntry(currb,HUD_MinigameMenu_last_entry);
374                 HUD_MinigameMenu_Click(currb);
375         }
376         else 
377         {
378                 entity p;
379                 for ( e = HUD_MinigameMenu_last_entry; e != world; e = p.list_prev )
380                 {
381                         p = e;
382                         if ( e.classname == "hud_minigamemenu_current" )
383                         {
384                                 p = e.list_next;
385                                 if ( !p )
386                                         p = HUD_MinigameMenu_last_entry;
387                                 HUD_MinigameMenu_EraseEntry(e);
388                                 break;
389                         }
390                 }
391                 for ( e = HUD_MinigameMenu_last_entry; e != world; e = e.list_prev )
392                         if ( e.classname == "hud_minigamemenu_exit" )
393                                 return;
394                 entity exit = HUD_MinigameMenu_SpawnEntry(
395                         _("Exit Menu"),'0 0 0',hud_fontsize*1.5,'0.7 0.84 1', HUD_MinigameMenu_Close);
396                 exit.classname = "hud_minigamemenu_exit";
397                 HUD_MinigameMenu_InsertEntry ( exit, HUD_MinigameMenu_last_entry );
398         }
399 }
400
401 // Open the minigame menu panel
402 void HUD_MinigameMenu_Open()
403 {
404         if ( !HUD_MinigameMenu_IsOpened() )
405         {
406                 HUD_MinigameMenu_InsertEntry( HUD_MinigameMenu_SpawnEntry(
407                         _("Create"), '0 0 0', hud_fontsize*1.5,'0.7 0.84 1', HUD_MinigameMenu_ClickCreate),
408                         HUD_MinigameMenu_last_entry );
409                 HUD_MinigameMenu_InsertEntry ( HUD_MinigameMenu_SpawnEntry(
410                         _("Join"),'0 0 0',hud_fontsize*1.5,'0.7 0.84 1', HUD_MinigameMenu_ClickJoin),
411                         HUD_MinigameMenu_last_entry );
412                 HUD_MinigameMenu_CurrentButton();
413                 HUD_MinigameMenu_activeitem = world;
414                 if(autocvar_hud_cursormode)
415                         setcursormode(1);
416         }
417 }
418
419 // Handles mouse input on to minigame menu panel
420 void HUD_MinigameMenu_MouseInput()
421 {
422         panel = HUD_PANEL(MINIGAME_MENU);
423
424         HUD_Panel_UpdateCvars();
425
426         if(panel_bg_padding)
427         {
428                 panel_pos += '1 1 0' * panel_bg_padding;
429                 panel_size -= '2 2 0' * panel_bg_padding;
430         }
431         
432         entity e;
433         
434         panel_pos_y += hud_fontsize_y*2;
435         
436         HUD_MinigameMenu_activeitem = world;
437         vector sz;
438         for ( e = HUD_MinigameMenu_entries; e != world; e = e.list_next )
439         {
440                 sz = eX*panel_size_x + eY*e.size_y;
441                 if ( e.model )
442                         sz_y = 22;
443                 if ( !HUD_MinigameMenu_activeitem && mousepos_y >= panel_pos_y && mousepos_y <= panel_pos_y + sz_y )
444                 {
445                         HUD_MinigameMenu_activeitem = e;
446                 }
447                 panel_pos_y += sz_y;
448         }
449 }
450
451 // Draw a menu entry
452 void HUD_MinigameMenu_DrawEntry(vector pos, string s, vector fontsize, vector color)
453 {
454         minigame_drawstring_trunc(panel_size_x-pos_x+panel_pos_x, pos, s,
455                                                           fontsize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
456 }
457 // Draw a color-coded menu
458 void HUD_MinigameMenu_DrawColoredEntry(vector pos, string s, vector fontsize)
459 {
460         minigame_drawcolorcodedstring_trunc(panel_size_x-pos_x+panel_pos_x, pos, s,
461                                                           fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
462 }
463
464 // minigame menu panel UI
465 void HUD_MinigameMenu ()
466 {       
467         if ( !HUD_MinigameMenu_IsOpened() )
468                 return;
469         
470         HUD_Panel_UpdateCvars();
471         
472         HUD_Panel_DrawBg(1);
473         
474         if(panel_bg_padding)
475         {
476                 panel_pos += '1 1 0' * panel_bg_padding;
477                 panel_size -= '2 2 0' * panel_bg_padding;
478         }
479
480         HUD_MinigameMenu_DrawEntry(panel_pos,_("Minigames"),hud_fontsize*2,'0.25 0.47 0.72');
481         panel_pos_y += hud_fontsize_y*2;
482         
483         entity e;
484         vector color;
485         vector offset;
486         float itemh;
487         vector imgsz = '22 22 0'; // NOTE: if changed, edit where HUD_MinigameMenu_activeitem is selected
488         for ( e = HUD_MinigameMenu_entries; e != world; e = e.list_next )
489         {
490                 color = e.colormod;
491                 
492                 offset = e.origin;
493                 itemh = e.size_y;
494                 
495                 if ( e.model )
496                         itemh = imgsz_y;
497                 
498                 if ( e.flags & 2 )
499                 {
500                         drawfill(panel_pos, eX*panel_size_x + eY*itemh, e.colormod, 
501                                         panel_fg_alpha, DRAWFLAG_NORMAL);
502                         color = '0 0 0';
503                 }
504
505                 if ( e.model )
506                 {
507                         drawpic( panel_pos+offset, e.model, imgsz, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL );
508                         offset_x += imgsz_x;
509                         offset_y = (imgsz_y-e.size_y) / 2;
510                 }
511                 
512                 if ( e.flags & 1 )
513                         HUD_MinigameMenu_DrawColoredEntry(panel_pos+offset,e.message,e.size);
514                 else
515                         HUD_MinigameMenu_DrawEntry(panel_pos+offset,e.message,e.size,color);
516                 
517                 if ( e == HUD_MinigameMenu_activeitem )
518                         drawfill(panel_pos, eX*panel_size_x + eY*itemh,'1 1 1', 0.25, DRAWFLAG_ADDITIVE);
519                 
520                 panel_pos_y += itemh;
521         }
522 }
523
524 // ====================================================================
525 // Minigame Help Panel
526 // ====================================================================
527
528 void HUD_MinigameHelp()
529 {
530         string help_message;
531         
532         if(!autocvar__hud_configure)
533                 help_message = active_minigame.message;
534         else
535                 help_message = "Minigame message";
536         
537         if ( !help_message )
538                 return;
539         
540         HUD_Panel_UpdateCvars();
541         
542         
543         vector pos, mySize;
544         pos = panel_pos;
545         mySize = panel_size;
546         
547         if(panel_bg_padding)
548         {
549                 pos += '1 1 0' * panel_bg_padding;
550                 mySize -= '2 2 0' * panel_bg_padding;
551         }
552         
553         minigame_drawcolorcodedstring_wrapped( mySize_x, pos, help_message, 
554                 hud_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL, 0.5 );
555 }
556
557 // ====================================================================
558 // Minigame Panel Input
559 // ====================================================================
560 float HUD_Minigame_InputEvent(float bInputType, float nPrimary, float nSecondary)
561 {
562                 
563         if( !HUD_MinigameMenu_IsOpened() || autocvar__hud_configure )
564                 return false;
565
566         if(bInputType == 3)
567         {
568                 mousepos_x = nPrimary;
569                 mousepos_y = nSecondary;
570                 if ( minigame_isactive() && HUD_mouse_over(HUD_PANEL(MINIGAME_BOARD)) )
571                         active_minigame.minigame_event(active_minigame,"mouse_moved",mousepos);
572                 return true;
573                 
574         }
575         else
576         {
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                 float keys;
596                 float i;
597                 con_keys = findkeysforcommand("toggleconsole", 0);
598                 keys = tokenize(con_keys); // findkeysforcommand returns data for this
599                 for (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 float HUD_Minigame_Showpanels()
697 {
698         return HUD_MinigameMenu_IsOpened() && ( autocvar__hud_configure || minigame_isactive() );
699 }