]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud/panel/modicons.qc
Merged Lyberta/GunGame into Lyberta/master
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud / panel / modicons.qc
index c63683dc805fd444649754408ebf969fd48d3cc8..2513a803f344cc13c5fc35062920a8a3a085bf93 100644 (file)
@@ -743,6 +743,103 @@ void HUD_Mod_GG(vector pos, vector mySize)
                DRAWFLAG_NORMAL);
 }
 
+// Lyberta: surv
+void HUD_Mod_SURV(vector mypos, vector mysize)
+{
+       mod_active = 1; // required in each mod function that always shows something
+       float defenderhealth = STAT(SURV_DEFENDER_HEALTH);
+       // Draw a health bar
+       float margin = mysize.y / 10; // Leave a small margin to be stylish
+       vector healthbarpos = mypos;
+       healthbarpos.x += margin;
+       healthbarpos.y += margin;
+       vector healthbarsize = mysize;
+       healthbarsize.x -= margin * 2;
+       healthbarsize.y -= margin * 2;
+       vector healthbarcolor;
+       healthbarcolor.z = 0;
+       if (defenderhealth > 0.5)
+       {
+               healthbarcolor.x = defenderhealth * -2 + 2;
+               healthbarcolor.y = 1;
+       }
+       else
+       {
+               healthbarcolor.x = 1;
+               healthbarcolor.y = defenderhealth;
+       }
+       HUD_Panel_DrawProgressBar(healthbarpos, healthbarsize, "progressbar",
+               defenderhealth, false, 0, healthbarcolor, 0.50, DRAWFLAG_NORMAL);
+       // Draw defender picture
+       int defenderteam = STAT(SURV_DEFENDER_TEAM);
+       string defenderpic = "";
+       vector defendercolor;
+       switch (defenderteam)
+       {
+               case 1:
+               {
+                       defenderpic = "player_red";
+                       defendercolor = '1 0 0';
+                       break;
+               }
+               case 2:
+               {
+                       defenderpic = "player_blue";
+                       defendercolor = '0 0 1';
+                       break;
+               }
+               default:
+               {
+                       defendercolor = '1 1 1';
+                       break;
+               }
+       }
+       vector picpos = mypos;
+       vector picsize = mysize;
+       picsize.x = picsize.y;
+       drawpic_aspect_skin(picpos, defenderpic, picsize, '1 1 1', 1,
+               DRAWFLAG_NORMAL);
+       // Draw number of defenders
+       int numalive = STAT(SURV_DEFENDERS_ALIVE);
+       vector alivepos = mypos;
+       alivepos.x += picsize.x;
+       vector alivesize = picsize;
+       drawstring_aspect(alivepos, ftos(numalive), alivesize, defendercolor, 1,
+               DRAWFLAG_NORMAL);
+       // Draw the time left
+       float roundtime = STAT(SURV_ROUND_TIME);
+       if (roundtime < 0)
+       {
+               roundtime = 0;
+       }
+       vector roundtimepos = mypos;
+       roundtimepos.x += picsize.x * 2;
+       vector roundtimesize = mysize;
+       roundtimesize.x = mysize.x - picsize.x * 2;
+       drawstring_aspect(roundtimepos, seconds_tostring(roundtime), roundtimesize,
+               '1 1 1', 1, DRAWFLAG_NORMAL);
+       if (autocvar_developer == 0)
+       {
+               return;
+       }
+       // Debug info below
+       int redalive = STAT(REDALIVE);
+       int bluealive = STAT(BLUEALIVE);
+       int yellowalive = STAT(YELLOWALIVE);
+       int pinkalive = STAT(PINKALIVE);
+       string message = strcat(ftos(redalive), "/", ftos(yellowalive));
+       vector redpos = mypos;
+       redpos.y += mysize.y;
+       vector statsize = mysize;
+       statsize.x /= 2;
+       drawstring_aspect(redpos, message, statsize, '1 0 0', 1, DRAWFLAG_NORMAL);
+       message = strcat(ftos(bluealive), "/", ftos(pinkalive));
+       vector bluepos = mypos;
+       bluepos.x += mysize.x / 2;
+       bluepos.y += mysize.y;
+       drawstring_aspect(bluepos, message, statsize, '0 0 1', 1, DRAWFLAG_NORMAL);
+}
+
 void HUD_ModIcons_SetFunc()
 {
        HUD_ModIcons_GameType = gametype.m_modicons;