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