]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud.qc
Merge commit 'origin/fruitiex/newpanelhud' into diabolik/newpanelhud
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud.qc
index 7d87df8f7d347649848ac8db2f76e6396d424cc8..c4bd34bc6b8aabdab7f70462ba3ccbbb77d7cac1 100644 (file)
@@ -550,26 +550,6 @@ HUD panels
 ==================
 */
 
-string HUD_Panel_GetName(float id)
-{
-       switch(id) {
-               case 0: return "weaponicons"; break;
-               case 1: return "inventory"; break;
-               case 2: return "powerups"; break;
-               case 3: return "healtharmor"; break;
-               case 4: return "notify"; break;
-               case 5: return "timer"; break;
-               case 6: return "radar"; break;
-               case 7: return "score"; break;
-               case 8: return "racetimer"; break;
-               case 9: return "vote"; break;
-               case 10: return "modicons"; break;
-               case 11: return "pressedkeys"; break;
-               case 12: return "chat"; break;
-               default: return "";
-       }
-}
-
 // Save the config
 void HUD_Panel_ExportCfg(string cfgname)
 {
@@ -604,7 +584,7 @@ void HUD_Panel_ExportCfg(string cfgname)
 
                // common cvars for all panels
                float i;
-               for (i = 0; i < panel_cnt; ++i)
+               for (i = 0; i < HUD_PANEL_NUM; ++i)
                {
                        fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), " ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i)))), "\n"));
                        fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_pos \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_pos")), "\"", "\n"));
@@ -896,7 +876,7 @@ vector HUD_Panel_CheckMove(float id, vector myPos, vector mySize)
        myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
        targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
 
-       for (i = 0; i < panel_cnt; ++i) {
+       for (i = 0; i < HUD_PANEL_NUM; ++i) {
                if(i == id || !HUD_Panel_CheckActive(i))
                        continue;
 
@@ -1000,7 +980,7 @@ vector HUD_Panel_CheckResize(float id, vector myPos, vector mySize)
        myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
        targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
 
-       for (i = 0; i < panel_cnt; ++i) {
+       for (i = 0; i < HUD_PANEL_NUM; ++i) {
                if(i == id || !HUD_Panel_CheckActive(i))
                        continue;
 
@@ -1161,6 +1141,8 @@ void HUD_Panel_SetPosSize(float id, vector resizeorigin)
 
 float mouseClicked;
 float prevMouseClicked; // previous state
+float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
+vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
 {
        if(!hud_configure)
@@ -1218,16 +1200,26 @@ void HUD_Panel_Mouse()
 
        if(mouseClicked)
        {
+               if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos)
+               {
+                       mouseClicked = 0; // to prevent spam, I guess.
+                       print("Doubleclick!\n");
+                       return;
+               }
+
                float i, border;
                vector panelPos;
                vector panelSize;
 
-               for(i = 0; i <= panel_cnt; ++i)
+               for(i = 0; i <= HUD_PANEL_NUM; ++i)
                {
                        panelPos = HUD_Panel_GetPos(i);
                        panelSize = HUD_Panel_GetSize(i);
                        border = HUD_Panel_GetBorder(i);
                        if(prevMouseClicked == 0) {
+                               prevMouseClickedTime = time;
+                               prevMouseClickedPos = mousepos;
+
                                // move
                                if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y)
                                {
@@ -1332,7 +1324,7 @@ float weaponorder_cmp(float i, float j, entity pass)
 
 void HUD_WeaponIcons()
 {
-       float id = 0;
+       float id = HUD_PANEL_WEAPONICONS;
        float alpha, stat_weapons; // "constants"
        vector pos, mySize, accuracy_color;
        float i, weapid, fade, weapon_stats, weapon_hit, weapon_damage, weapon_cnt; // variables
@@ -1474,7 +1466,7 @@ string GetAmmoPicture(float i)
 
 void HUD_Inventory()
 {
-       float id = 1;
+       float id = HUD_PANEL_INVENTORY;
        float i;
        float stat_items;
 
@@ -1565,7 +1557,7 @@ void HUD_Inventory()
 // Powerups (#2)
 //
 void HUD_Powerups() {
-       float id = 2;
+       float id = HUD_PANEL_POWERUPS;
        float stat_items;
        stat_items = getstati(STAT_ITEMS);
 
@@ -1789,7 +1781,7 @@ void HUD_Powerups() {
 //
 void HUD_HealthArmor(void)
 {
-       float id = 3;
+       float id = HUD_PANEL_HEALTHARMOR;
        vector pos, mySize;
        pos = HUD_Panel_GetPos(id);
        mySize = HUD_Panel_GetSize(id);
@@ -2420,7 +2412,7 @@ void HUD_Centerprint(string s1, float type, float msg)
 
 void HUD_Notify (void)
 {
-       float id = 4;
+       float id = HUD_PANEL_NOTIFY;
        vector pos, mySize;
        pos = HUD_Panel_GetPos(id);
        mySize = HUD_Panel_GetSize(id);
@@ -2686,7 +2678,7 @@ void HUD_Notify (void)
 //
 void HUD_Timer()
 {
-       float id = 5;
+       float id = HUD_PANEL_TIMER;
        vector pos, mySize;
        pos = HUD_Panel_GetPos(id);
        mySize = HUD_Panel_GetSize(id);
@@ -2745,7 +2737,7 @@ void HUD_Timer()
 //
 void HUD_Radar(void)
 {
-       float id = 6;
+       float id = HUD_PANEL_RADAR;
        vector pos, mySize;
        pos = HUD_Panel_GetPos(id);
        mySize = HUD_Panel_GetSize(id);
@@ -2871,7 +2863,7 @@ void HUD_Radar(void)
 //
 void HUD_Score()
 {
-       float id = 7;
+       float id = HUD_PANEL_SCORE;
        vector pos, mySize;
        pos = HUD_Panel_GetPos(id);
        mySize = HUD_Panel_GetSize(id);
@@ -3019,7 +3011,7 @@ void HUD_Score()
 // Race timer (#8)
 //
 void HUD_RaceTimer (void) {
-       float id = 8;
+       float id = HUD_PANEL_RACETIMER;
        vector pos, mySize;
        pos = HUD_Panel_GetPos(id);
        mySize = HUD_Panel_GetSize(id);
@@ -3162,7 +3154,7 @@ float vote_change; // "time" when vote_active changed
 
 void HUD_VoteWindow(void) 
 {
-       float id = 9;
+       float id = HUD_PANEL_VOTE;
        vector pos, mySize;
        pos = HUD_Panel_GetPos(id);
        mySize = HUD_Panel_GetSize(id);
@@ -3668,7 +3660,7 @@ void HUD_ModIcons(void)
        if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && !hud_configure)
                return;
 
-       float id = 10;
+       float id = HUD_PANEL_MODICONS;
        vector pos, mySize;
        pos = HUD_Panel_GetPos(id);
        mySize = HUD_Panel_GetSize(id);
@@ -3709,7 +3701,7 @@ void HUD_ModIcons(void)
 //
 void HUD_DrawPressedKeys(void)
 {
-       float id = 11;
+       float id = HUD_PANEL_PRESSEDKEYS;
        vector pos, mySize;
        pos = HUD_Panel_GetPos(id);
        mySize = HUD_Panel_GetSize(id);
@@ -3740,7 +3732,7 @@ void HUD_DrawPressedKeys(void)
 float chat_prevtime;
 void HUD_Chat(void)
 {
-       float id = 12;
+       float id = HUD_PANEL_CHAT;
        vector pos, mySize;
        pos = HUD_Panel_GetPos(id);
        mySize = HUD_Panel_GetSize(id);