]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud.qc
Merge branch 'fruitiex/newpanelhud_stable' into fruitiex/newpanelhud
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud.qc
index 2cdd8a9160c5fec30ffa0668dbe92e1ee763dfb1..088424eab54984eb045f18bdc1aeb9a6e933c8a6 100644 (file)
@@ -579,6 +579,7 @@ void HUD_Panel_ExportCfg(string cfgname)
                fputs(fh, strcat("seta hud_skin \"", cvar_string("hud_skin"), "\"", "\n"));
                fputs(fh, strcat("seta hud_bg \"", cvar_string("hud_bg"), "\"", "\n"));
                fputs(fh, strcat("seta hud_bg_color \"", cvar_string("hud_bg_color"), "\"", "\n"));
+               fputs(fh, strcat("seta hud_bg_color_team \"", cvar_string("hud_bg_color_team"), "\"", "\n"));
                fputs(fh, strcat("seta hud_bg_alpha \"", cvar_string("hud_bg_alpha"), "\"", "\n"));
                fputs(fh, strcat("seta hud_bg_border \"", cvar_string("hud_bg_border"), "\"", "\n"));
                fputs(fh, strcat("seta hud_bg_padding \"", cvar_string("hud_bg_padding"), "\"", "\n"));
@@ -587,6 +588,7 @@ void HUD_Panel_ExportCfg(string cfgname)
 
                fputs(fh, strcat("seta hud_dock \"", cvar_string("hud_dock"), "\"", "\n"));
                fputs(fh, strcat("seta hud_dock_color \"", cvar_string("hud_dock_color"), "\"", "\n"));
+               fputs(fh, strcat("seta hud_dock_color_team \"", cvar_string("hud_dock_color_team"), "\"", "\n"));
                fputs(fh, strcat("seta hud_dock_alpha \"", ftos(cvar("hud_dock_alpha")), "\"", "\n"));
                fputs(fh, "\n");
 
@@ -608,6 +610,7 @@ void HUD_Panel_ExportCfg(string cfgname)
                        fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_size \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_size")), "\"", "\n"));
                        fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg")), "\"", "\n"));
                        fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_color \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_color")), "\"", "\n"));
+                       fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_color_team \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_color_team")), "\"", "\n"));
                        fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_alpha \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_alpha")), "\"", "\n"));
                        fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_border \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_border")), "\"", "\n"));
                        fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_padding \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_padding")), "\"", "\n"));
@@ -730,12 +733,24 @@ vector HUD_Panel_GetColor(float id)
        float f;
        vector color_vec;
        string color;
-       color = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color"));
+
+       // fetch per-panel color
+       if(teamplay && cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color_team")) != "") {
+               f = stof(getplayerkey(self.sv_entnum, "colors"));
+               color = vtos(colormapPaletteColor(mod(f, 16), 1) * cvar(strcat("hud_", HUD_Panel_GetName(id), "_bg_color_team")));
+       }
+       else
+               color = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color"));
        color_vec = stov(color);
-       if(color == "") {
+
+       if(color == "") { // fetch default color
                color = cvar_string("hud_bg_color");
                color_vec = stov(color);
-               if(color == "shirt") {
+               if(teamplay && cvar(strcat("hud_bg_color_team"))) {
+                       f = stof(getplayerkey(self.sv_entnum, "colors"));
+                       color_vec = colormapPaletteColor(mod(f, 16), 1) * cvar("hud_bg_color_team");
+               }
+               else if(color == "shirt") {
                        f = stof(getplayerkey(self.sv_entnum, "colors"));
                        color_vec = colormapPaletteColor(floor(f / 16), 0);
                }
@@ -762,7 +777,11 @@ vector HUD_Panel_Dock_GetColor(void)
        string color;
        color = cvar_string("hud_dock_color");
        color_vec = stov(color);
-       if(color == "shirt") {
+       if(teamplay && cvar(strcat("hud_dock_color_team"))) {
+               f = stof(getplayerkey(self.sv_entnum, "colors"));
+               color_vec = colormapPaletteColor(mod(f, 16), 1) * cvar("hud_dock_color_team");
+       }
+       else if(color == "shirt") {
                f = stof(getplayerkey(self.sv_entnum, "colors"));
                color_vec = colormapPaletteColor(floor(f / 16), 0);
        }
@@ -2019,17 +2038,35 @@ string Weapon_KillMessage(float id)
        return strcat("[no suicide message for weapon ", ftos(id), "!]");
 }
 
+float killnotify_times[10];
+float killnotify_weapons[10];
+string killnotify_attackers[10];
+string killnotify_victims[10];
+void HUD_KillNotify_Push(string attacker, string victim, float wpn)
+{
+       float i;
+       for (i = 9; i > 0; --i) {
+               killnotify_times[i] = killnotify_times[i-1];
+               killnotify_weapons[i] = killnotify_weapons[i-1];
+               killnotify_attackers[i] = killnotify_attackers[i-1];
+               killnotify_victims[i] = killnotify_victims[i-1];
+       }
+       killnotify_times[0] = time;
+       killnotify_weapons[0] = wpn;
+       killnotify_attackers[0] = attacker;
+       killnotify_victims[0] = victim;
+}
+
 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg)
 {
        if(msg == MSG_SUICIDE) {
-               float w;
-               string w_typestring;
-
-               w = DEATH_WEAPONOF(type);
                // TODO: cl_gentle
                // TODO: way of finding out secondary?
-               if(type == DEATH_WEAPON)
-                       print("^1", s1, "^1 ", Weapon_SuicideMessage(stof(s3)), "\n");
+               if(type == DEATH_WEAPON) {
+                       HUD_KillNotify_Push(s1, "", stof(s3));
+                       if (!HUD_Panel_CheckActive(4) || cvar("hud_notify_print"))
+                               print("^1", s1, "^1 ", Weapon_SuicideMessage(stof(s2)), "\n");
+               }
                else if (type == DEATH_KILL)
                        print ("^1",s1, "^1 couldn't take it anymore\n");
                else if (type == DEATH_ROT)
@@ -2070,8 +2107,11 @@ void HUD_KillNotify(string s1, string s2, string s3, float type, float msg)
                }
                else if(type == KILL_FIRST_BLOOD)
                        print("^1",s1, "^1 drew first blood", "\n");
-               else if (type == DEATH_WEAPON)
-                       print("^1", s1, "^1 ", Weapon_KillMessage(stof(s3)), "\n");
+               else if (type == DEATH_WEAPON) {
+                       HUD_KillNotify_Push(s1, s2, stof(s3));
+                       if (!HUD_Panel_CheckActive(4) || cvar("hud_notify_print"))
+                               print("^1", s1, "^1 ", Weapon_KillMessage(stof(s3)), "\n");
+               }
                else if (type == DEATH_TELEFRAG)
                        print ("^1",s1, "^1 was telefragged by ", s2, "\n");
                else if (type == DEATH_DROWN)
@@ -2283,6 +2323,15 @@ void HUD_Notify (void)
                mySize -= '2 2 0' * padding;
        }
 
+       float entries;
+       entries = 4 * mySize_y/mySize_x;
+       float i;
+       for(i = 0; i <= entries; ++i)
+       {
+               drawcolorcodedstring(pos + eY * i * (mySize_y/entries),killnotify_attackers[i], '1 1 0' * (mySize_y/entries), hud_alpha_fg, DRAWFLAG_NORMAL);
+               drawcolorcodedstring(pos + eX * 0.35 * mySize_x + eY * i * (mySize_y/entries),ftos(killnotify_weapons[i]), '1 1 0' * (mySize_y/entries), hud_alpha_fg, DRAWFLAG_NORMAL);
+               drawcolorcodedstring(pos + eX * 0.75 * mySize_x + eY * i * (mySize_y/entries),killnotify_victims[i], '1 1 0' * (mySize_y/entries), hud_alpha_fg, DRAWFLAG_NORMAL);
+       }
        /* This will come later.
        string s;
        entity tm;
@@ -3547,6 +3596,23 @@ void HUD_Main (void)
        hud_configure = cvar("_hud_configure");
 
        // Drawing stuff
+
+       // HUD configure visible grid
+       if(hud_configure && cvar("hud_configure_grid") && cvar("hud_configure_grid_alpha"))
+       {
+               float i;
+               // x-axis
+               for(i = 0; i < vid_conwidth/cvar("hud_configure_grid_x"); ++i)
+               {
+                       drawfill(eX * i * cvar("hud_configure_grid_x"), eX + eY * vid_conheight, '0.5 0.5 0.5', cvar("hud_configure_grid_alpha"), DRAWFLAG_NORMAL);
+               }
+               // y-axis
+               for(i = 0; i < vid_conheight/cvar("hud_configure_grid_y"); ++i)
+               {
+                       drawfill(eY * i * cvar("hud_configure_grid_y"), eY + eX * vid_conwidth, '0.5 0.5 0.5', cvar("hud_configure_grid_alpha"), DRAWFLAG_NORMAL);
+               }
+       }
+
        if(cvar_string("hud_dock") != "")
                drawpic_skin('0 0 0', cvar_string("hud_dock"), eX * vid_conwidth + eY * vid_conheight, HUD_Panel_Dock_GetColor(), cvar("hud_dock_alpha"), DRAWFLAG_NORMAL);