]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Damagetext: simplify format specifier
authorTimePath <andrew.hardaker1995@gmail.com>
Sun, 13 Mar 2016 09:57:44 +0000 (20:57 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Sun, 13 Mar 2016 09:57:44 +0000 (20:57 +1100)
qcsrc/common/mutators/mutator/damagetext/damagetext.qc

index 866ffeb4c743e155c9f89c8b158d72a4d2d2e98a..70c57485314367a6eda9dfddd58d4336ca4c51c5 100644 (file)
@@ -13,7 +13,7 @@ REGISTER_MUTATOR(damagetext, true);
 #if defined(CSQC) || defined(MENUQC)
 // no translatable cvar description please
 AUTOCVAR_SAVE(cl_damagetext,                    bool,   false,      "Draw damage dealt where you hit the enemy");
-AUTOCVAR_SAVE(cl_damagetext_format,             string, "-%3$$d",   "How to format the damage text. 1$ is health, 2$ is armor, 3$ is both");
+AUTOCVAR_SAVE(cl_damagetext_format,             string, "-{total}", "How to format the damage text. {health}, {armor}, {total}");
 AUTOCVAR_SAVE(cl_damagetext_color,              vector, '1 1 0',    "Damage text color");
 AUTOCVAR_SAVE(cl_damagetext_color_per_weapon,   bool,   false,      "Damage text uses weapon color");
 AUTOCVAR_SAVE(cl_damagetext_size,               float,  8,          "Damage text font size");
@@ -51,7 +51,10 @@ CLASS(DamageText, Object)
                 Weapon w = DEATH_WEAPONOF(this.m_deathtype);
                 if (w != WEP_Null) rgb = w.wpcolor;
             }
-            string s = sprintf(autocvar_cl_damagetext_format, this.m_damage, this.m_armordamage, this.m_damage + this.m_armordamage);
+            string s = autocvar_cl_damagetext_format;
+            s = strreplace("{health}", sprintf("%d", this.m_damage), s);
+            s = strreplace("{armor}",  sprintf("%d", this.m_armordamage), s);
+            s = strreplace("{total}",  sprintf("%d", this.m_damage + this.m_armordamage), s);
             drawcolorcodedstring2(pos, s, this.m_size * '1 1 0', rgb, this.alpha, DRAWFLAG_NORMAL);
         }
     }