]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/minigames/cl_minigames_hud.qc
Update default video settings
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / minigames / cl_minigames_hud.qc
index 74c867c3ac337ed85fc6ac98d0d6dabcc9a4d0a5..174bec63a91a309633b80a84f759707b5bf77ec1 100644 (file)
@@ -1,7 +1,7 @@
 #include "cl_minigames_hud.qh"
 
-#include <client/autocvars.qh>
 #include <client/draw.qh>
+#include <client/hud/_mod.qh>
 #include <client/hud/hud_config.qh>
 #include <client/mapvoting.qh>
 #include <common/ent_cs.qh>
@@ -138,7 +138,6 @@ void HUD_MinigameMenu_InsertEntry(entity newentry, entity prev)
        else
                HUD_MinigameMenu_last_entry = newentry;
        prev.list_next = newentry;
-
 }
 
 
@@ -538,8 +537,7 @@ void HUD_MinigameMenu ()
 
                if ( e.flags & 2 )
                {
-                       drawfill(panel_pos, eX*panel_size_x + eY*itemh, e.colormod,
-                                       panel_fg_alpha, DRAWFLAG_NORMAL);
+                       drawfill(panel_pos, eX*panel_size_x + eY*itemh, e.colormod, panel_fg_alpha, DRAWFLAG_NORMAL);
                        color = '0 0 0';
                }
 
@@ -556,7 +554,7 @@ void HUD_MinigameMenu ()
                        HUD_MinigameMenu_DrawEntry(panel_pos+offset,e.message,e.size,color);
 
                if ( e == HUD_MinigameMenu_activeitem )
-                       drawfill(panel_pos, eX*panel_size_x + eY*itemh,'1 1 1', 0.25, DRAWFLAG_ADDITIVE);
+                       drawfill(panel_pos, eX*panel_size_x + eY*itemh,'1 1 1', 0.25 * panel_fg_alpha, DRAWFLAG_ADDITIVE);
 
                panel_pos_y += itemh;
        }
@@ -618,103 +616,122 @@ float HUD_Minigame_InputEvent(float bInputType, float nPrimary, float nSecondary
                if ( active_minigame && HUD_mouse_over(HUD_PANEL(MINIGAMEBOARD)) )
                        active_minigame.minigame_event(active_minigame,"mouse_moved",mousepos);
                return true;
-
        }
-       else
-       {
-               if(bInputType == 0) {
-                       if(nPrimary == K_ALT) hudShiftState |= S_ALT;
-                       if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
-                       if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
-                       if(nPrimary == K_MOUSE1) mouseClicked |= S_MOUSE1;
-                       if(nPrimary == K_MOUSE2) mouseClicked |= S_MOUSE2;
-               }
-               else if(bInputType == 1) {
-                       if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
-                       if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
-                       if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
-                       if(nPrimary == K_MOUSE1) mouseClicked -= (mouseClicked & S_MOUSE1);
-                       if(nPrimary == K_MOUSE2) mouseClicked -= (mouseClicked & S_MOUSE2);
-               }
 
-               // allow some binds
-               string con_keys = findkeysforcommand("toggleconsole", 0);
-               int keys = tokenize(con_keys); // findkeysforcommand returns data for this
-               int i;
-               for (i = 0; i < keys; ++i)
-               {
-                       if(nPrimary == stof(argv(i)))
-                               return false;
-               }
+       if(bInputType == 2)
+       {
+               if ( active_minigame && HUD_mouse_over(HUD_PANEL(MINIGAMEBOARD)) )
+                       active_minigame.minigame_event(active_minigame,"mouse_moved",mousepos);
+               return false;
+       }
 
-               if ( active_minigame && ( bInputType == 0 || bInputType == 1 ) )
-               {
-                       string device = "";
-                       string action = bInputType == 0 ? "pressed" : "released";
-                       if ( nPrimary >= K_MOUSE1 && nPrimary <= K_MOUSE16 )
-                       {
-                               if ( HUD_mouse_over(HUD_PANEL(MINIGAMEBOARD)) )
-                                       device = "mouse";
-                       }
-                       else
-                               device = "key";
+       // at this point bInputType can only be 0 or 1 (key pressed or released)
+       bool key_pressed = (bInputType == 0);
 
-                       if ( device && active_minigame.minigame_event(
-                                       active_minigame,strcat(device,"_",action),nPrimary) )
-                               return true;
+       if(key_pressed) {
+               if(nPrimary == K_ALT) hudShiftState |= S_ALT;
+               if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
+               if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
+               if(nPrimary == K_MOUSE1) mouseClicked |= S_MOUSE1;
+               if(nPrimary == K_MOUSE2) mouseClicked |= S_MOUSE2;
+       }
+       else {
+               if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
+               if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
+               if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
+               if(nPrimary == K_MOUSE1) mouseClicked -= (mouseClicked & S_MOUSE1);
+               if(nPrimary == K_MOUSE2) mouseClicked -= (mouseClicked & S_MOUSE2);
+       }
 
-                       /// TODO: bInputType == 2?
-               }
+       // allow some binds
+       string con_keys = findkeysforcommand("toggleconsole", 0);
+       int keys = tokenize(con_keys); // findkeysforcommand returns data for this
+       int i;
+       for (i = 0; i < keys; ++i)
+       {
+               if(nPrimary == stof(argv(i)))
+                       return false;
+       }
 
-               if ( bInputType == 0 )
+       if ( active_minigame )
+       {
+               string device = "";
+               string action = key_pressed ? "pressed" : "released";
+               if ( nPrimary >= K_MOUSE1 && nPrimary <= K_MOUSE16 )
                {
-                       if ( nPrimary == K_MOUSE1 && HUD_MinigameMenu_activeitem &&
-                               HUD_mouse_over(HUD_PANEL(MINIGAMEMENU)) )
-                       {
-                               HUD_MinigameMenu_Click(HUD_MinigameMenu_activeitem);
-                               return true;
-                       }
-                       if ( nPrimary == K_UPARROW || nPrimary == K_KP_UPARROW )
-                       {
-                               if ( HUD_MinigameMenu_activeitem && HUD_MinigameMenu_activeitem.list_prev )
-                                       HUD_MinigameMenu_activeitem = HUD_MinigameMenu_activeitem.list_prev;
-                               else
-                                       HUD_MinigameMenu_activeitem = HUD_MinigameMenu_last_entry;
-                               return true;
-                       }
-                       else if ( nPrimary == K_DOWNARROW || nPrimary == K_KP_DOWNARROW )
-                       {
-                               if ( HUD_MinigameMenu_activeitem && HUD_MinigameMenu_activeitem.list_next )
-                                       HUD_MinigameMenu_activeitem = HUD_MinigameMenu_activeitem.list_next;
-                               else
-                                       HUD_MinigameMenu_activeitem = HUD_MinigameMenu_entries;
-                               return true;
-                       }
-                       else if ( nPrimary == K_HOME || nPrimary == K_KP_HOME )
-                       {
-                               HUD_MinigameMenu_activeitem = HUD_MinigameMenu_entries;
-                               return true;
-                       }
-                       else if ( nPrimary == K_END || nPrimary == K_KP_END )
-                       {
-                               HUD_MinigameMenu_activeitem = HUD_MinigameMenu_entries;
-                               return true;
-                       }
-                       else if ( nPrimary == K_KP_ENTER || nPrimary == K_ENTER || nPrimary == K_SPACE )
-                       {
-                               HUD_MinigameMenu_Click(HUD_MinigameMenu_activeitem);
-                               return true;
-                       }
-                       else if ( nPrimary == K_ESCAPE )
-                       {
-                               HUD_MinigameMenu_Close(NULL, NULL, NULL);
-                               return true;
-                       }
+                       if ( HUD_mouse_over(HUD_PANEL(MINIGAMEBOARD)) )
+                               device = "mouse";
                }
+               else
+                       device = "key";
+
+               if ( device && active_minigame.minigame_event(
+                               active_minigame,strcat(device,"_",action),nPrimary) )
+                       return true;
        }
 
-       return false;
+       if ( nPrimary == K_MOUSE2 )
+       {
+               return true;
+       }
+       if ( nPrimary == K_MOUSE1 )
+       {
+               if (!key_pressed)
+                       return true;
+               if (HUD_MinigameMenu_activeitem && HUD_mouse_over(HUD_PANEL(MINIGAMEMENU)))
+                       HUD_MinigameMenu_Click(HUD_MinigameMenu_activeitem);
+               return true;
+       }
+       if ( nPrimary == K_UPARROW || nPrimary == K_KP_UPARROW )
+       {
+               if (!key_pressed)
+                       return true;
+               if ( HUD_MinigameMenu_activeitem && HUD_MinigameMenu_activeitem.list_prev )
+                       HUD_MinigameMenu_activeitem = HUD_MinigameMenu_activeitem.list_prev;
+               else
+                       HUD_MinigameMenu_activeitem = HUD_MinigameMenu_last_entry;
+               return true;
+       }
+       else if ( nPrimary == K_DOWNARROW || nPrimary == K_KP_DOWNARROW )
+       {
+               if (!key_pressed)
+                       return true;
+               if ( HUD_MinigameMenu_activeitem && HUD_MinigameMenu_activeitem.list_next )
+                       HUD_MinigameMenu_activeitem = HUD_MinigameMenu_activeitem.list_next;
+               else
+                       HUD_MinigameMenu_activeitem = HUD_MinigameMenu_entries;
+               return true;
+       }
+       else if ( nPrimary == K_HOME || nPrimary == K_KP_HOME )
+       {
+               if (!key_pressed)
+                       return true;
+               HUD_MinigameMenu_activeitem = HUD_MinigameMenu_entries;
+               return true;
+       }
+       else if ( nPrimary == K_END || nPrimary == K_KP_END )
+       {
+               if (!key_pressed)
+                       return true;
+               HUD_MinigameMenu_activeitem = HUD_MinigameMenu_entries;
+               return true;
+       }
+       else if ( nPrimary == K_KP_ENTER || nPrimary == K_ENTER || nPrimary == K_SPACE )
+       {
+               if (!key_pressed)
+                       return true;
+               HUD_MinigameMenu_Click(HUD_MinigameMenu_activeitem);
+               return true;
+       }
+       else if ( nPrimary == K_ESCAPE )
+       {
+               if (!key_pressed)
+                       return true;
+               HUD_MinigameMenu_Close(NULL, NULL, NULL);
+               return true;
+       }
 
+       return false;
 }
 
 void HUD_Minigame_Mouse()