fix: Fixes localization corner cases with OPL (#1050)
## Changes
- [X] Adds OPL convenience methods
- `opl.Add(cliloc, value)` and `opl.Add(value)` - value as an integer or string works just like `opl.Add(cliloc, $"{value}")`
- `opl.AddLocalized(cliloc, clilocValue)` - works the same as `opl.Add(cliloc, $"#{clilocValue}");`
- [X] Simplifies basic `list.Add()` situations
- [X] Changes cliloc as an argument so it works with custom IPropertyList implementations (HTML)
- [X] Fixes plants so they support the old localization and new (changed in 7.0.12.0+)
- [X] Exposes more methods to override for Item to make creating custom OPL possible.
## Important Notes
* Using a ternary as an argument, like this `opl.Add(number, showType ? $"{type}\t{value}" : $"{value}");` _will not use the correct string interpolation_. This means if you use a custom PropertyList (for HTML or some other purpose), the property list won't be localized properly.
* All localization values must be interpolated, even if they are literal strings, or integers. Example: `opl.Add(number, $"{"Charges"}\t{m_Charges}");` is correct. Using the following: `$"Charges\t{m_Charges}"` will not work for custom PropertyList implementations!
This commit is contained in:
parent
12404ba6f6
commit
b74b47159f
75 changed files with 715 additions and 477 deletions
|
|
@ -2778,7 +2778,14 @@ namespace Server.Items
|
|||
|
||||
if (oreType != 0)
|
||||
{
|
||||
list.Add(1053099, name != null ? $"#{oreType}\t{name}" : $"#{oreType}\t#{LabelNumber}"); // ~1_oretype~ ~2_armortype~
|
||||
if (name != null)
|
||||
{
|
||||
list.Add(1053099, $"{oreType:#}\t{name}"); // ~1_oretype~ ~2_armortype~
|
||||
}
|
||||
else
|
||||
{
|
||||
list.Add(1053099, $"{oreType:#}\t{LabelNumber:#}"); // ~1_oretype~ ~2_armortype~
|
||||
}
|
||||
}
|
||||
else if (name == null)
|
||||
{
|
||||
|
|
@ -2848,12 +2855,12 @@ namespace Server.Items
|
|||
|
||||
if (ArtifactRarity > 0)
|
||||
{
|
||||
list.Add(1061078, $"{ArtifactRarity}"); // artifact rarity ~1_val~
|
||||
list.Add(1061078, ArtifactRarity); // artifact rarity ~1_val~
|
||||
}
|
||||
|
||||
if (this is IUsesRemaining usesRemaining && usesRemaining.ShowUsesRemaining)
|
||||
{
|
||||
list.Add(1060584, $"{usesRemaining.UsesRemaining}"); // uses remaining: ~1_val~
|
||||
list.Add(1060584, usesRemaining.UsesRemaining); // uses remaining: ~1_val~
|
||||
}
|
||||
|
||||
if (m_Poison != null && m_PoisonCharges > 0)
|
||||
|
|
@ -2897,107 +2904,107 @@ namespace Server.Items
|
|||
|
||||
if ((prop = GetDamageBonus() + Attributes.WeaponDamage) != 0)
|
||||
{
|
||||
list.Add(1060401, $"{prop}"); // damage increase ~1_val~%
|
||||
list.Add(1060401, prop); // damage increase ~1_val~%
|
||||
}
|
||||
|
||||
if ((prop = Attributes.DefendChance) != 0)
|
||||
{
|
||||
list.Add(1060408, $"{prop}"); // defense chance increase ~1_val~%
|
||||
list.Add(1060408, prop); // defense chance increase ~1_val~%
|
||||
}
|
||||
|
||||
if ((prop = Attributes.EnhancePotions) != 0)
|
||||
{
|
||||
list.Add(1060411, $"{prop}"); // enhance potions ~1_val~%
|
||||
list.Add(1060411, prop); // enhance potions ~1_val~%
|
||||
}
|
||||
|
||||
if ((prop = Attributes.CastRecovery) != 0)
|
||||
{
|
||||
list.Add(1060412, $"{prop}"); // faster cast recovery ~1_val~
|
||||
list.Add(1060412, prop); // faster cast recovery ~1_val~
|
||||
}
|
||||
|
||||
if ((prop = Attributes.CastSpeed) != 0)
|
||||
{
|
||||
list.Add(1060413, $"{prop}"); // faster casting ~1_val~
|
||||
list.Add(1060413, prop); // faster casting ~1_val~
|
||||
}
|
||||
|
||||
if ((prop = GetHitChanceBonus() + Attributes.AttackChance) != 0)
|
||||
{
|
||||
list.Add(1060415, $"{prop}"); // hit chance increase ~1_val~%
|
||||
list.Add(1060415, prop); // hit chance increase ~1_val~%
|
||||
}
|
||||
|
||||
if ((prop = WeaponAttributes.HitColdArea) != 0)
|
||||
{
|
||||
list.Add(1060416, $"{prop}"); // hit cold area ~1_val~%
|
||||
list.Add(1060416, prop); // hit cold area ~1_val~%
|
||||
}
|
||||
|
||||
if ((prop = WeaponAttributes.HitDispel) != 0)
|
||||
{
|
||||
list.Add(1060417, $"{prop}"); // hit dispel ~1_val~%
|
||||
list.Add(1060417, prop); // hit dispel ~1_val~%
|
||||
}
|
||||
|
||||
if ((prop = WeaponAttributes.HitEnergyArea) != 0)
|
||||
{
|
||||
list.Add(1060418, $"{prop}"); // hit energy area ~1_val~%
|
||||
list.Add(1060418, prop); // hit energy area ~1_val~%
|
||||
}
|
||||
|
||||
if ((prop = WeaponAttributes.HitFireArea) != 0)
|
||||
{
|
||||
list.Add(1060419, $"{prop}"); // hit fire area ~1_val~%
|
||||
list.Add(1060419, prop); // hit fire area ~1_val~%
|
||||
}
|
||||
|
||||
if ((prop = WeaponAttributes.HitFireball) != 0)
|
||||
{
|
||||
list.Add(1060420, $"{prop}"); // hit fireball ~1_val~%
|
||||
list.Add(1060420, prop); // hit fireball ~1_val~%
|
||||
}
|
||||
|
||||
if ((prop = WeaponAttributes.HitHarm) != 0)
|
||||
{
|
||||
list.Add(1060421, $"{prop}"); // hit harm ~1_val~%
|
||||
list.Add(1060421, prop); // hit harm ~1_val~%
|
||||
}
|
||||
|
||||
if ((prop = WeaponAttributes.HitLeechHits) != 0)
|
||||
{
|
||||
list.Add(1060422, $"{prop}"); // hit life leech ~1_val~%
|
||||
list.Add(1060422, prop); // hit life leech ~1_val~%
|
||||
}
|
||||
|
||||
if ((prop = WeaponAttributes.HitLightning) != 0)
|
||||
{
|
||||
list.Add(1060423, $"{prop}"); // hit lightning ~1_val~%
|
||||
list.Add(1060423, prop); // hit lightning ~1_val~%
|
||||
}
|
||||
|
||||
if ((prop = WeaponAttributes.HitLowerAttack) != 0)
|
||||
{
|
||||
list.Add(1060424, $"{prop}"); // hit lower attack ~1_val~%
|
||||
list.Add(1060424, prop); // hit lower attack ~1_val~%
|
||||
}
|
||||
|
||||
if ((prop = WeaponAttributes.HitLowerDefend) != 0)
|
||||
{
|
||||
list.Add(1060425, $"{prop}"); // hit lower defense ~1_val~%
|
||||
list.Add(1060425, prop); // hit lower defense ~1_val~%
|
||||
}
|
||||
|
||||
if ((prop = WeaponAttributes.HitMagicArrow) != 0)
|
||||
{
|
||||
list.Add(1060426, $"{prop}"); // hit magic arrow ~1_val~%
|
||||
list.Add(1060426, prop); // hit magic arrow ~1_val~%
|
||||
}
|
||||
|
||||
if ((prop = WeaponAttributes.HitLeechMana) != 0)
|
||||
{
|
||||
list.Add(1060427, $"{prop}"); // hit mana leech ~1_val~%
|
||||
list.Add(1060427, prop); // hit mana leech ~1_val~%
|
||||
}
|
||||
|
||||
if ((prop = WeaponAttributes.HitPhysicalArea) != 0)
|
||||
{
|
||||
list.Add(1060428, $"{prop}"); // hit physical area ~1_val~%
|
||||
list.Add(1060428, prop); // hit physical area ~1_val~%
|
||||
}
|
||||
|
||||
if ((prop = WeaponAttributes.HitPoisonArea) != 0)
|
||||
{
|
||||
list.Add(1060429, $"{prop}"); // hit poison area ~1_val~%
|
||||
list.Add(1060429, prop); // hit poison area ~1_val~%
|
||||
}
|
||||
|
||||
if ((prop = WeaponAttributes.HitLeechStam) != 0)
|
||||
{
|
||||
list.Add(1060430, $"{prop}"); // hit stamina leech ~1_val~%
|
||||
list.Add(1060430, prop); // hit stamina leech ~1_val~%
|
||||
}
|
||||
|
||||
if (ImmolatingWeaponSpell.IsImmolating(this))
|
||||
|
|
@ -3007,42 +3014,42 @@ namespace Server.Items
|
|||
|
||||
if (Core.ML && (ranged?.Velocity ?? 0) != 0)
|
||||
{
|
||||
list.Add(1072793, $"{prop}"); // Velocity ~1_val~%
|
||||
list.Add(1072793, prop); // Velocity ~1_val~%
|
||||
}
|
||||
|
||||
if ((prop = Attributes.BonusDex) != 0)
|
||||
{
|
||||
list.Add(1060409, $"{prop}"); // dexterity bonus ~1_val~
|
||||
list.Add(1060409, prop); // dexterity bonus ~1_val~
|
||||
}
|
||||
|
||||
if ((prop = Attributes.BonusHits) != 0)
|
||||
{
|
||||
list.Add(1060431, $"{prop}"); // hit point increase ~1_val~
|
||||
list.Add(1060431, prop); // hit point increase ~1_val~
|
||||
}
|
||||
|
||||
if ((prop = Attributes.BonusInt) != 0)
|
||||
{
|
||||
list.Add(1060432, $"{prop}"); // intelligence bonus ~1_val~
|
||||
list.Add(1060432, prop); // intelligence bonus ~1_val~
|
||||
}
|
||||
|
||||
if ((prop = Attributes.LowerManaCost) != 0)
|
||||
{
|
||||
list.Add(1060433, $"{prop}"); // lower mana cost ~1_val~%
|
||||
list.Add(1060433, prop); // lower mana cost ~1_val~%
|
||||
}
|
||||
|
||||
if ((prop = Attributes.LowerRegCost) != 0)
|
||||
{
|
||||
list.Add(1060434, $"{prop}"); // lower reagent cost ~1_val~%
|
||||
list.Add(1060434, prop); // lower reagent cost ~1_val~%
|
||||
}
|
||||
|
||||
if ((prop = GetLowerStatReq()) != 0)
|
||||
{
|
||||
list.Add(1060435, $"{prop}"); // lower requirements ~1_val~%
|
||||
list.Add(1060435, prop); // lower requirements ~1_val~%
|
||||
}
|
||||
|
||||
if ((prop = GetLuckBonus() + Attributes.Luck) != 0)
|
||||
{
|
||||
list.Add(1060436, $"{prop}"); // luck ~1_val~
|
||||
list.Add(1060436, prop); // luck ~1_val~
|
||||
}
|
||||
|
||||
if ((prop = WeaponAttributes.MageWeapon) != 0)
|
||||
|
|
@ -3052,12 +3059,12 @@ namespace Server.Items
|
|||
|
||||
if ((prop = Attributes.BonusMana) != 0)
|
||||
{
|
||||
list.Add(1060439, $"{prop}"); // mana increase ~1_val~
|
||||
list.Add(1060439, prop); // mana increase ~1_val~
|
||||
}
|
||||
|
||||
if ((prop = Attributes.RegenMana) != 0)
|
||||
{
|
||||
list.Add(1060440, $"{prop}"); // mana regeneration ~1_val~
|
||||
list.Add(1060440, prop); // mana regeneration ~1_val~
|
||||
}
|
||||
|
||||
if (Attributes.NightSight != 0)
|
||||
|
|
@ -3067,22 +3074,22 @@ namespace Server.Items
|
|||
|
||||
if ((prop = Attributes.ReflectPhysical) != 0)
|
||||
{
|
||||
list.Add(1060442, $"{prop}"); // reflect physical damage ~1_val~%
|
||||
list.Add(1060442, prop); // reflect physical damage ~1_val~%
|
||||
}
|
||||
|
||||
if ((prop = Attributes.RegenStam) != 0)
|
||||
{
|
||||
list.Add(1060443, $"{prop}"); // stamina regeneration ~1_val~
|
||||
list.Add(1060443, prop); // stamina regeneration ~1_val~
|
||||
}
|
||||
|
||||
if ((prop = Attributes.RegenHits) != 0)
|
||||
{
|
||||
list.Add(1060444, $"{prop}"); // hit point regeneration ~1_val~
|
||||
list.Add(1060444, prop); // hit point regeneration ~1_val~
|
||||
}
|
||||
|
||||
if ((prop = WeaponAttributes.SelfRepair) != 0)
|
||||
{
|
||||
list.Add(1060450, $"{prop}"); // self repair ~1_val~
|
||||
list.Add(1060450, prop); // self repair ~1_val~
|
||||
}
|
||||
|
||||
if (Attributes.SpellChanneling != 0)
|
||||
|
|
@ -3092,27 +3099,27 @@ namespace Server.Items
|
|||
|
||||
if ((prop = Attributes.SpellDamage) != 0)
|
||||
{
|
||||
list.Add(1060483, $"{prop}"); // spell damage increase ~1_val~%
|
||||
list.Add(1060483, prop); // spell damage increase ~1_val~%
|
||||
}
|
||||
|
||||
if ((prop = Attributes.BonusStam) != 0)
|
||||
{
|
||||
list.Add(1060484, $"{prop}"); // stamina increase ~1_val~
|
||||
list.Add(1060484, prop); // stamina increase ~1_val~
|
||||
}
|
||||
|
||||
if ((prop = Attributes.BonusStr) != 0)
|
||||
{
|
||||
list.Add(1060485, $"{prop}"); // strength bonus ~1_val~
|
||||
list.Add(1060485, prop); // strength bonus ~1_val~
|
||||
}
|
||||
|
||||
if ((prop = Attributes.WeaponSpeed) != 0)
|
||||
{
|
||||
list.Add(1060486, $"{prop}"); // swing speed increase ~1_val~%
|
||||
list.Add(1060486, prop); // swing speed increase ~1_val~%
|
||||
}
|
||||
|
||||
if (Core.ML && (prop = Attributes.IncreasedKarmaLoss) != 0)
|
||||
{
|
||||
list.Add(1075210, $"{prop}"); // Increased Karma Loss ~1val~%
|
||||
list.Add(1075210, prop); // Increased Karma Loss ~1val~%
|
||||
}
|
||||
|
||||
GetDamageTypes(
|
||||
|
|
@ -3128,37 +3135,37 @@ namespace Server.Items
|
|||
|
||||
if (phys != 0)
|
||||
{
|
||||
list.Add(1060403, $"{phys}"); // physical damage ~1_val~%
|
||||
list.Add(1060403, phys); // physical damage ~1_val~%
|
||||
}
|
||||
|
||||
if (fire != 0)
|
||||
{
|
||||
list.Add(1060405, $"{fire}"); // fire damage ~1_val~%
|
||||
list.Add(1060405, fire); // fire damage ~1_val~%
|
||||
}
|
||||
|
||||
if (cold != 0)
|
||||
{
|
||||
list.Add(1060404, $"{cold}"); // cold damage ~1_val~%
|
||||
list.Add(1060404, cold); // cold damage ~1_val~%
|
||||
}
|
||||
|
||||
if (pois != 0)
|
||||
{
|
||||
list.Add(1060406, $"{pois}"); // poison damage ~1_val~%
|
||||
list.Add(1060406, pois); // poison damage ~1_val~%
|
||||
}
|
||||
|
||||
if (nrgy != 0)
|
||||
{
|
||||
list.Add(1060407, $"{nrgy}"); // energy damage ~1_val
|
||||
list.Add(1060407, nrgy); // energy damage ~1_val
|
||||
}
|
||||
|
||||
if (Core.ML && chaos != 0)
|
||||
{
|
||||
list.Add(1072846, $"{chaos}"); // chaos damage ~1_val~%
|
||||
list.Add(1072846, chaos); // chaos damage ~1_val~%
|
||||
}
|
||||
|
||||
if (Core.ML && direct != 0)
|
||||
{
|
||||
list.Add(1079978, $"{direct}"); // Direct Damage: ~1_PERCENT~%
|
||||
list.Add(1079978, direct); // Direct Damage: ~1_PERCENT~%
|
||||
}
|
||||
|
||||
list.Add(1061168, $"{MinDamage}\t{MaxDamage}"); // weapon damage ~1_val~ - ~2_val~
|
||||
|
|
@ -3174,14 +3181,14 @@ namespace Server.Items
|
|||
|
||||
if (MaxRange > 1)
|
||||
{
|
||||
list.Add(1061169, $"{MaxRange}"); // range ~1_val~
|
||||
list.Add(1061169, MaxRange); // range ~1_val~
|
||||
}
|
||||
|
||||
var strReq = AOS.Scale(StrRequirement, 100 - GetLowerStatReq());
|
||||
|
||||
if (strReq > 0)
|
||||
{
|
||||
list.Add(1061170, $"{strReq}"); // strength requirement ~1_val~
|
||||
list.Add(1061170, strReq); // strength requirement ~1_val~
|
||||
}
|
||||
|
||||
if (Layer == Layer.TwoHanded)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue