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
|
|
@ -264,7 +264,7 @@ namespace Server.Items
|
|||
list.Add(1070857, m_Hunter.Name); // Caught by ~1_fisherman~
|
||||
}
|
||||
|
||||
list.Add(1070858, $"{m_AnimalWeight}"); // ~1_weight~ stones
|
||||
list.Add(1070858, m_AnimalWeight); // ~1_weight~ stones
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -439,7 +439,7 @@ namespace Server.Items
|
|||
list.Add(1070857, m_Hunter.Name); // Caught by ~1_fisherman~
|
||||
}
|
||||
|
||||
list.Add(1070858, $"{m_AnimalWeight}"); // ~1_weight~ stones
|
||||
list.Add(1070858, m_AnimalWeight); // ~1_weight~ stones
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ namespace Server.Items
|
|||
|
||||
public override void OnSingleClick(Mobile from)
|
||||
{
|
||||
LabelTo(from, 1050039, $"#{LabelNumber}\t#1041645");
|
||||
LabelTo(from, 1050039, $"{LabelNumber:#}\t{1041645:#}");
|
||||
}
|
||||
|
||||
public override void AddNameProperties(IPropertyList list)
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ namespace Server.Items
|
|||
list.Add(1060636); // exceptional
|
||||
}
|
||||
|
||||
list.Add(1060584, $"{m_UsesRemaining}"); // uses remaining: ~1_val~
|
||||
list.Add(1060584, m_UsesRemaining); // uses remaining: ~1_val~
|
||||
}
|
||||
|
||||
public virtual void DisplayDurabilityTo(Mobile m)
|
||||
|
|
|
|||
|
|
@ -246,9 +246,13 @@ namespace Server.Items
|
|||
{
|
||||
list.Add(House != null ? 1062453 : 1060806, $"a recall rune for {desc}"); // ~1_val~ (Trammel)[(House)]
|
||||
}
|
||||
else if (House != null)
|
||||
{
|
||||
list.Add($"a recall rune for {desc} ({m_TargetMap})(House)");
|
||||
}
|
||||
else
|
||||
{
|
||||
list.Add(House != null ? $"a recall rune for {desc} ({m_TargetMap})(House)" : $"a recall rune for {desc} ({m_TargetMap})");
|
||||
list.Add($"a recall rune for {desc} ({m_TargetMap})");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -738,72 +738,72 @@ namespace Server.Items
|
|||
|
||||
if ((prop = 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.BonusDex) != 0)
|
||||
{
|
||||
list.Add(1060409, $"{prop}"); // dexterity bonus ~1_val~
|
||||
list.Add(1060409, prop); // dexterity bonus ~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 = Attributes.AttackChance) != 0)
|
||||
{
|
||||
list.Add(1060415, $"{prop}"); // hit chance increase ~1_val~%
|
||||
list.Add(1060415, prop); // hit chance increase ~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 = Attributes.Luck) != 0)
|
||||
{
|
||||
list.Add(1060436, $"{prop}"); // luck ~1_val~
|
||||
list.Add(1060436, prop); // luck ~1_val~
|
||||
}
|
||||
|
||||
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)
|
||||
|
|
@ -813,17 +813,17 @@ 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 (Attributes.SpellChanneling != 0)
|
||||
|
|
@ -833,30 +833,30 @@ 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~%
|
||||
}
|
||||
|
||||
list.Add(1042886, $"{SpellCount}"); // ~1_NUMBERS_OF_SPELLS~ Spells
|
||||
list.Add(1042886, SpellCount); // ~1_NUMBERS_OF_SPELLS~ Spells
|
||||
}
|
||||
|
||||
public override void OnSingleClick(Mobile from)
|
||||
|
|
|
|||
|
|
@ -50,7 +50,14 @@ namespace Server.Items
|
|||
|
||||
if (r != null)
|
||||
{
|
||||
list.Add(1049644, $"{r.TextDefinition}"); // [~1_stuff~]
|
||||
if (r.TextDefinition.Number > 0)
|
||||
{
|
||||
list.Add(1049644, r.TextDefinition.Number); // [~1_stuff~]
|
||||
}
|
||||
else
|
||||
{
|
||||
list.Add(1049644, r.TextDefinition.String); // [~1_stuff~]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -376,7 +376,7 @@ namespace Server.Items
|
|||
list.Add(1060636); // exceptional
|
||||
}
|
||||
|
||||
list.Add(1060584, $"{m_UsesRemaining}"); // uses remaining: ~1_val~
|
||||
list.Add(1060584, m_UsesRemaining); // uses remaining: ~1_val~
|
||||
|
||||
if (m_ReplenishesCharges)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ namespace Server.Items
|
|||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
list.Add(1060584, $"{m_UsesRemaining}"); // uses remaining: ~1_val~
|
||||
list.Add(1060584, m_UsesRemaining); // uses remaining: ~1_val~
|
||||
|
||||
if (m_Poison != null && m_PoisonCharges > 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ namespace Server.Items
|
|||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
list.Add(1060584, $"{m_UsesRemaining}"); // uses remaining: ~1_val~
|
||||
list.Add(1060584, m_UsesRemaining); // uses remaining: ~1_val~
|
||||
|
||||
if (m_Poison != null && m_PoisonCharges > 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ namespace Server.Items
|
|||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
list.Add(1060584, $"{m_UsesRemaining}"); // uses remaining: ~1_val~
|
||||
list.Add(1060584, m_UsesRemaining); // uses remaining: ~1_val~
|
||||
|
||||
if (m_Poison != null && m_PoisonCharges > 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ namespace Server.Items
|
|||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
list.Add(1060584, $"{m_UsesRemaining}"); // uses remaining: ~1_val~
|
||||
list.Add(1060584, m_UsesRemaining); // uses remaining: ~1_val~
|
||||
|
||||
if (m_Poison != null && m_PoisonCharges > 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ namespace Server.Items
|
|||
list.Add(1060636); // exceptional
|
||||
}
|
||||
|
||||
list.Add(1060584, $"{m_UsesRemaining}"); // uses remaining: ~1_val~
|
||||
list.Add(1060584, m_UsesRemaining); // uses remaining: ~1_val~
|
||||
}
|
||||
|
||||
public virtual void DisplayDurabilityTo(Mobile m)
|
||||
|
|
|
|||
|
|
@ -26,23 +26,24 @@ namespace Server.Items
|
|||
|
||||
public override void AddNameProperty(IPropertyList list)
|
||||
{
|
||||
var v = " ";
|
||||
|
||||
if (!CraftResources.IsStandard(Resource))
|
||||
if (CraftResources.IsStandard(Resource))
|
||||
{
|
||||
var num = CraftResources.GetLocalizationNumber(Resource);
|
||||
|
||||
if (num > 0)
|
||||
{
|
||||
v = $"#{num}";
|
||||
}
|
||||
else
|
||||
{
|
||||
v = CraftResources.GetName(Resource);
|
||||
}
|
||||
list.Add(1061119, " "); // ~1_LEATHER_TYPE~ runic sewing kit
|
||||
return;
|
||||
}
|
||||
|
||||
list.Add(1061119, v); // ~1_LEATHER_TYPE~ runic sewing kit
|
||||
var num = CraftResources.GetLocalizationNumber(Resource);
|
||||
|
||||
if (num > 0)
|
||||
{
|
||||
// ~1_LEATHER_TYPE~ runic sewing kit
|
||||
list.Add(1061119, $"#{num}");
|
||||
}
|
||||
else
|
||||
{
|
||||
// ~1_LEATHER_TYPE~ runic sewing kit
|
||||
list.Add(1061119, CraftResources.GetName(Resource));
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnSingleClick(Mobile from)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue