X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fclient%2Fhud%2Fpanel%2Fpowerups.qc;h=70d41ec47e71f955b242fd72511ed948c80e6f09;hb=1abbb17e725edb42685b92c2e23f4920fe8093d0;hp=076ce918f14723dcde2e755308a3f4379fb885e0;hpb=34e7f534e2015466228eb3a78c9857741b736dca;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/client/hud/panel/powerups.qc b/qcsrc/client/hud/panel/powerups.qc index 076ce918f..70d41ec47 100644 --- a/qcsrc/client/hud/panel/powerups.qc +++ b/qcsrc/client/hud/panel/powerups.qc @@ -1,15 +1,27 @@ #include "powerups.qh" +#include #include +#include // Powerups (#2) +void HUD_Powerups_Export(int fh) +{ + // allow saving cvars that aesthetically change the panel into hud skin files + HUD_Write_Cvar("hud_panel_powerups_iconalign"); + HUD_Write_Cvar("hud_panel_powerups_baralign"); + HUD_Write_Cvar("hud_panel_powerups_progressbar"); + HUD_Write_Cvar("hud_panel_powerups_text"); +} + // Powerup item fields (reusing existing fields) .string message; // Human readable name .string netname; // Icon name .vector colormod; // Color .float count; // Time left .float lifetime; // Maximum time +.float cnt; // Infinite timer entity powerupItems; int powerupItemsCount; @@ -23,7 +35,7 @@ void resetPowerupItems() powerupItemsCount = 0; } -void addPowerupItem(string name, string icon, vector color, float currentTime, float lifeTime) +void addPowerupItem(string name, string icon, vector color, float currentTime, float lifeTime, bool isInfinite) { if(!powerupItems) powerupItems = spawn(); @@ -38,13 +50,14 @@ void addPowerupItem(string name, string icon, vector color, float currentTime, f item.colormod = color; item.count = currentTime; item.lifetime = lifeTime; + item.cnt = isInfinite; ++powerupItemsCount; } int getPowerupItemAlign(int align, int column, int row, int columns, int rows, bool isVertical) { - TC(int, align); TC(int, column); TC(int, row); TC(int, columns); TC(int, rows); TC(bool, isVertical); + TC(int, align); TC(int, column); TC(int, row); TC(int, columns); TC(int, rows); TC(bool, isVertical); if(align < 2) return align; @@ -61,10 +74,6 @@ int getPowerupItemAlign(int align, int column, int row, int columns, int rows, b void HUD_Powerups() { - int allItems = STAT(ITEMS); - int allBuffs = STAT(BUFFS); - float strengthTime, shieldTime, superTime; - // Initialize items if(!autocvar__hud_configure) { @@ -72,37 +81,11 @@ void HUD_Powerups() return; if(STAT(HEALTH) <= 0 && autocvar_hud_panel_powerups_hide_ondeath) return; - //if(!(allItems & (ITEM_Strength.m_itemid | ITEM_Shield.m_itemid | IT_SUPERWEAPON)) && !allBuffs) return; - - strengthTime = bound(0, STAT(STRENGTH_FINISHED) - time, 99); - shieldTime = bound(0, STAT(INVINCIBLE_FINISHED) - time, 99); - superTime = bound(0, STAT(SUPERWEAPONS_FINISHED) - time, 99); - - if(allItems & IT_UNLIMITED_SUPERWEAPONS) - superTime = 99; - - // Prevent stuff to show up on mismatch that will be fixed next frame - if(!(allItems & IT_SUPERWEAPON)) - superTime = 0; - } - else - { - strengthTime = 15; - shieldTime = 27; - superTime = 13; - allBuffs = 0; } // Add items to linked list resetPowerupItems(); - if(strengthTime) - addPowerupItem("Strength", "strength", autocvar_hud_progressbar_strength_color, strengthTime, 30); - if(shieldTime) - addPowerupItem("Shield", "shield", autocvar_hud_progressbar_shield_color, shieldTime, 30); - if(superTime) - addPowerupItem("Superweapons", "superweapons", autocvar_hud_progressbar_superweapons_color, superTime, 30); - MUTATOR_CALLHOOK(HUD_Powerups_add); if(!powerupItemsCount) @@ -167,7 +150,7 @@ void HUD_Powerups() // Draw items from linked list vector itemPos = pos; - vector itemSize = eX * (size.x / columns) + eY * (size.y / rows); + vector itemSize = vec2(size.x / columns, size.y / rows); vector textColor = '1 1 1'; int fullSeconds = 0; @@ -178,7 +161,7 @@ void HUD_Powerups() draw_beginBoldFont(); for(entity item = powerupItems; item.count; item = item.chain) { - itemPos = eX * (pos.x + column * itemSize.x) + eY * (pos.y + row * itemSize.y); + itemPos = vec2(pos.x + column * itemSize.x, pos.y + row * itemSize.y); // Draw progressbar if(autocvar_hud_panel_powerups_progressbar) @@ -194,10 +177,15 @@ void HUD_Powerups() fullSeconds = ceil(item.count); textColor = '0.6 0.6 0.6' + (item.colormod * 0.4); - if(item.count > 1) - DrawNumIcon(itemPos, itemSize, fullSeconds, item.netname, isVertical, align, textColor, panel_fg_alpha); - if(item.count <= 5) - DrawNumIcon_expanding(itemPos, itemSize, fullSeconds, item.netname, isVertical, align, textColor, panel_fg_alpha, bound(0, (fullSeconds - item.count) / 0.5, 1)); + if(item.cnt) + DrawNumIcon(itemPos, itemSize, fullSeconds, item.netname, isVertical, true, align, textColor, panel_fg_alpha); + else + { + if(item.count > 1) + DrawNumIcon(itemPos, itemSize, fullSeconds, item.netname, isVertical, false, align, textColor, panel_fg_alpha); + if(item.count <= 5) + DrawNumIcon_expanding(itemPos, itemSize, fullSeconds, item.netname, isVertical, false, align, textColor, panel_fg_alpha, bound(0, (fullSeconds - item.count) / 0.5, 1)); + } } // Determine next section