From: TimePath Date: Sun, 13 Mar 2016 09:57:44 +0000 (+1100) Subject: Damagetext: simplify format specifier X-Git-Tag: xonotic-v0.8.2~1097 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=c0f78e0a9c09b12e57965f31fdfccf56e5815b84;p=xonotic%2Fxonotic-data.pk3dir.git Damagetext: simplify format specifier --- diff --git a/qcsrc/common/mutators/mutator/damagetext/damagetext.qc b/qcsrc/common/mutators/mutator/damagetext/damagetext.qc index 866ffeb4c..70c574853 100644 --- a/qcsrc/common/mutators/mutator/damagetext/damagetext.qc +++ b/qcsrc/common/mutators/mutator/damagetext/damagetext.qc @@ -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); } }