]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
The quick menu panel can now handle mouse input
authorterencehill <piuntn@gmail.com>
Mon, 7 Nov 2011 17:04:03 +0000 (18:04 +0100)
committerterencehill <piuntn@gmail.com>
Mon, 7 Nov 2011 17:04:03 +0000 (18:04 +0100)
qcsrc/client/View.qc
qcsrc/client/hud.qc

index ac976db67bdd76f3c12c2fc75bdd00b4a00cf0d8..025740a55f533983ec5b3c5f68aa6e62bcad6eb5 100644 (file)
@@ -468,7 +468,7 @@ void CSQC_UpdateView(float w, float h)
        }
        
        // do lockview after event chase camera so that it still applies whenever necessary.
-       if(autocvar_cl_lockview || (autocvar__hud_configure && spectatee_status <= 0) || intermission > 1)
+       if(autocvar_cl_lockview || (autocvar__hud_configure && spectatee_status <= 0) || intermission > 1 || HUD_QuickMenu_IsOpened())
        {
                R_SetView(VF_ORIGIN, freeze_org);
                R_SetView(VF_ANGLES, freeze_ang);
@@ -1434,18 +1434,21 @@ void CSQC_UpdateView(float w, float h)
 
        if(autocvar__hud_configure)
                HUD_Panel_Mouse();
-    
-    if(hud && !intermission)
-    {        
-        if(hud == HUD_SPIDERBOT)
-            CSQC_SPIDER_HUD();
-        else if(hud == HUD_WAKIZASHI)
-            CSQC_WAKIZASHI_HUD();
-        else if(hud == HUD_RAPTOR)
-            CSQC_RAPTOR_HUD();
-        else if(hud == HUD_BUMBLEBEE)
-            CSQC_BUMBLE_HUD();
-    }
+       else if (HUD_QuickMenu_IsOpened())
+               HUD_Panel_QuickMenu_Mouse();
+
+       if(hud && !intermission)
+       {
+               if(hud == HUD_SPIDERBOT)
+                       CSQC_SPIDER_HUD();
+               else if(hud == HUD_WAKIZASHI)
+                       CSQC_WAKIZASHI_HUD();
+               else if(hud == HUD_RAPTOR)
+                       CSQC_RAPTOR_HUD();
+               else if(hud == HUD_BUMBLEBEE)
+                       CSQC_BUMBLE_HUD();
+       }
+
        // let's reset the view back to normal for the end
        R_SetView(VF_MIN, '0 0 0');
        R_SetView(VF_SIZE, '1 0 0' * w + '0 1 0' * h);
index 931f586d907e5680492ec5ce43afac4bd948fa4f..3ed5688f61f2ce1e7773ce2814089419d4d4b647 100644 (file)
@@ -4861,6 +4861,7 @@ void HUD_QuickMenu_Close()
                HUD_QuickMenu_clear_entry(i);
        QuickMenu_Entries = 0;
        hud_panel_quickmenu = 0;
+       mouseClicked = 0;
        HUD_QuickMenu_Buffer_Close();
 }
 
@@ -5004,7 +5005,6 @@ float HUD_Panel_QuickMenu_InputEvent(float bInputType, float nPrimary, float nSe
        string s;
 
        // we only care for keyboard events
-       // TODO: mouse input handling
        if(bInputType != 0 && bInputType != 1)
                return false;
 
@@ -5036,12 +5036,71 @@ float HUD_Panel_QuickMenu_InputEvent(float bInputType, float nPrimary, float nSe
                        return true;
                HUD_QuickMenu_ActionForNumber(stof(chr2str(nPrimary)));
        }
+       if(nPrimary == K_MOUSE1)
+       {
+               if(bInputType == 0) // key pressed
+                       mouseClicked |= S_MOUSE1;
+               else if(bInputType == 1) // key released
+                       mouseClicked -= (mouseClicked & S_MOUSE1);
+       }
+       else if(nPrimary == K_MOUSE2)
+       {
+               if(bInputType == 0) // key pressed
+                       mouseClicked |= S_MOUSE2;
+               else if(bInputType == 1) // key released
+                       mouseClicked -= (mouseClicked & S_MOUSE2);
+       }
        else if(hit_con_bind)
                return false;
 
        return true;
 }
+void HUD_Panel_QuickMenu_Mouse()
+{
+       if (mouseClicked & S_MOUSE2)
+       {
+               HUD_QuickMenu_Close();
+               return;
+       }
+
+       mousepos = mousepos + getmousepos() * autocvar_menu_mouse_speed;
+
+       mousepos_x = bound(0, mousepos_x, vid_conwidth);
+       mousepos_y = bound(0, mousepos_y, vid_conheight);
+
+       HUD_Panel_UpdatePosSize(quickmenu)
+       float first_entry_pos, entries_height;
+       vector fontsize;
+       fontsize = '1 1 0' * (panel_size_y / QUICKMENU_MAXLINES);
+       first_entry_pos = panel_pos_y + ((QUICKMENU_MAXLINES - QuickMenu_Entries) * fontsize_y) / 2;
+       entries_height = panel_size_y - ((QUICKMENU_MAXLINES - QuickMenu_Entries) * fontsize_y);
+
+       if (mousepos_x >= panel_pos_x && mousepos_y >= first_entry_pos && mousepos_x <= panel_pos_x + panel_size_x && mousepos_y <= first_entry_pos + entries_height)
+       {
+               float entry_num;
+               entry_num = floor((mousepos_y - first_entry_pos) / fontsize_y);
+               if (QuickMenu_IsLastPage || entry_num != QUICKMENU_MAXLINES - 2)
+               {
+                       panel_pos_y = first_entry_pos + entry_num * fontsize_y;
+                       vector color;
+                       if (mouseClicked & S_MOUSE1)
+                       {
+                               color = '0 1 0';
+                               if (entry_num < QUICKMENU_MAXLINES - 1)
+                                       HUD_QuickMenu_ActionForNumber(entry_num + 1);
+                               else
+                                       HUD_QuickMenu_ActionForNumber(0);
+                               mouseClicked -= (mouseClicked & S_MOUSE1);
+                       }
+                       else
+                               color = '1 1 1';
+                       drawfill(panel_pos, eX * panel_size_x + eY * fontsize_y, color, .2, DRAWFLAG_NORMAL);
+               }
+       }
 
+       const vector cursorsize = '32 32 0';
+       drawpic(mousepos, strcat("gfx/menu/", autocvar_menu_skin, "/cursor.tga"), cursorsize, '1 1 1', 0.8, DRAWFLAG_NORMAL);
+}
 void HUD_QuickMenu(void)
 {
        if(!autocvar__hud_configure)