]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
showspawned enabled: show item icon more transparent when all items of the same kind...
authorterencehill <piuntn@gmail.com>
Thu, 6 Aug 2015 09:45:19 +0000 (11:45 +0200)
committerterencehill <piuntn@gmail.com>
Thu, 6 Aug 2015 09:45:19 +0000 (11:45 +0200)
qcsrc/client/hud.qc
qcsrc/server/t_items.qc

index 55bfbe80b1c9091fd1ead580f55289a017df2ee8..b86e9746058a02705239c077ea044aedb179f150 100644 (file)
@@ -4664,12 +4664,13 @@ string GetItemsTimePicture(float i)
        }
 }
 
-void DrawItemsTimeItem(vector myPos, vector mySize, float ar, float itemcode)
+void DrawItemsTimeItem(vector myPos, vector mySize, float ar, float itemcode, float item_time, bool item_available)
 {
        float t = 0;
        vector color = '0 0 0';
        float picalpha;
-       if(ItemsTime_time[itemcode] <= time)
+
+       if(item_available)
        {
                float BLINK_FACTOR = 0.15;
                float BLINK_BASE = 0.85;
@@ -4677,16 +4678,14 @@ void DrawItemsTimeItem(vector myPos, vector mySize, float ar, float itemcode)
                picalpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
        }
        else
-       {
-               picalpha = 1;
-               t = floor(ItemsTime_time[itemcode] - time + 0.999);
-               if(t < 5)
-                       color = '0.7 0 0';
-               else if(t < 10)
-                       color = '0.7 0.7 0';
-               else
-                       color = '1 1 1';
-       }
+               picalpha = 0.3;
+       t = floor(item_time - time + 0.999);
+       if(t < 5)
+               color = '0.7 0 0';
+       else if(t < 10)
+               color = '0.7 0.7 0';
+       else
+               color = '1 1 1';
 
        vector picpos, numpos;
        if(autocvar_hud_panel_itemstime_iconalign)
@@ -4833,13 +4832,23 @@ void HUD_ItemsTime(void)
        HUD_Panel_DrawBg(1);
 
        float row = 0, column = 0;
+       bool item_available;
        for (i = 0; i < ITEMSTIME_MAXITEMS; ++i) {
                if (ItemsTime_time[i] == -1)
                        continue;
+       
+               float item_time = ItemsTime_time[i];
+               if(item_time < -1)
+               {
+                       item_available = true;
+                       item_time = -item_time;
+               }
+               else
+                       item_available = (item_time <= time);
                if (!autocvar_hud_panel_itemstime_showspawned)
-                       if (ItemsTime_time[i] <= time)
+                       if(item_available)
                                continue;
-               DrawItemsTimeItem(pos + eX * column * (itemstime_size.x + offset.x) + eY * row * (itemstime_size.y + offset.y), itemstime_size, ar, i);
+               DrawItemsTimeItem(pos + eX * column * (itemstime_size.x + offset.x) + eY * row * (itemstime_size.y + offset.y), itemstime_size, ar, i, item_time, item_available);
                ++row;
                if(row >= rows)
                {
index d64ba6c837dc24b8ed81a3aed55160d3bbe8d606..e0f5a05e699afab484dfba7e571b872b793a8f54 100644 (file)
@@ -479,6 +479,8 @@ bool Item_ItemsTime_UpdateTime_Check(float item_time, float t)
 {
        if(t == 0 && item_time == -1)
                return true;
+       if(t < 0) // negative means there's another available item of the same kind
+               t = -t;
        if(time < t && (item_time <= time || t < item_time))
                return true;
        return false;
@@ -578,7 +580,21 @@ void Item_Respawn (void)
 
        if(self.flags & FL_POWERUP || self.classname == "item_armor_large" || self.items == IT_HEALTH || (self.weapons & WEPSET_SUPERWEAPONS))
        {
-               Item_ItemsTime_UpdateTime(self, 0);
+               entity head;
+               float t = 0;
+               float isavailable = true;
+               for(head = world; (head = find(head, classname, self.classname)); )
+               {
+                       // in instagib .classname is "instagib" for every item
+                       if(self == head || (g_instagib && self.items != head.items))
+                               continue;
+                       if(head.scheduledrespawntime > time && (t == 0 || head.scheduledrespawntime < t))
+                               t = head.scheduledrespawntime;
+               }
+
+               if(isavailable)
+                       t = -t; // let know the client there's another available item
+               Item_ItemsTime_UpdateTime(self, t);
                Item_ItemsTime_SetTimesForAllPlayers();
        }
 
@@ -717,19 +733,19 @@ void Item_ScheduleRespawnIn(entity e, float t)
                }
                else
                {
+                       bool isavailable = false;
                        for(t = e.scheduledrespawntime, head = world; (head = find(head, classname, e.classname)); )
                        {
                                // in instagib .classname is "instagib" for every item
                                if(e == head || (g_instagib && e.items != head.items))
                                        continue;
                                if(head.scheduledrespawntime <= time)
-                               {
-                                       t = 0;
-                                       break;
-                               }
-                               if(head.scheduledrespawntime < t)
+                                       isavailable = true;
+                               else if(head.scheduledrespawntime < t)
                                        t = head.scheduledrespawntime;
                        }
+                       if(isavailable)
+                               t = -t; // let know the client there's another available item
                }
                Item_ItemsTime_UpdateTime(e, t);
                Item_ItemsTime_SetTimesForAllPlayers();