Commit 63f5e2c0 authored by terencehill's avatar terencehill

showspawned enabled: show item icon more transparent when all items of the...

showspawned enabled: show item icon more transparent when all items of the same kind aren't available, show it at full alpha if at least one item is available; update time when an item is taken in order to always refer to the next item of the same kind going to respawn
parent 0f4a81dd
......@@ -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)
{
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment