fix: Update LabelTo, SendMessage, etc to Interpolated Strings (#1283)

This commit is contained in:
Fabrizio 2022-11-29 04:58:12 +01:00 • committed by GitHub
parent 0facd73842
commit 537526a328
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
94 changed files with 514 additions and 769 deletions

View file

@ -672,7 +672,14 @@ public class Container : Item
if (CheckContentDisplay(from))
{
LabelTo(from, "({0} item{2}, {1} stones)", TotalItems, TotalWeight, TotalItems != 1 ? "s" : string.Empty);
if (TotalItems == 1)
{
LabelTo(from, $"({TotalItems} item, {TotalWeight} stones)");
}
else
{
LabelTo(from, $"({TotalItems} items, {TotalWeight} stones)");
}
}
// LabelTo( from, 1050044, String.Format( "{0}\t{1}", TotalItems.ToString(), TotalWeight.ToString() ) );

View file

@ -2235,11 +2235,6 @@ public class Item : IHued, IComparable<Item>, ISpawnable, IObjectPropertyListEnt
to.NetState.SendMessage(Serial, m_ItemID, MessageType.Label, 0x3B2, 3, false, "ENU", "", text);
}
public void LabelTo(Mobile to, string format, params object[] args)
{
LabelTo(to, string.Format(format, args));
}
public void LabelToAffix(Mobile to, int number, AffixType type, string affix, string args = "")
{
to.NetState.SendMessageLocalizedAffix(Serial, m_ItemID, MessageType.Label, 0x3B2, 3, number, "", type, affix, args);

View file

@ -117,7 +117,7 @@ public sealed class VirtualCheck : Item
public override void OnSingleClick(Mobile from)
{
LabelTo(from, "Offer: {0:#,0} platinum, {1:#,0} gold", Plat, Gold);
LabelTo(from, $"Offer: {Plat:#,0} platinum, {Gold:#,0} gold");
}
public override void GetProperties(IPropertyList list)

View file

@ -1004,7 +1004,7 @@ public class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPropertyLis
Delta(MobileDelta.Noto);
InvalidateProperties();
SendMessage("Your access level has been changed. You are now {0}.", GetAccessLevelName(value));
SendMessage($"Your access level has been changed. You are now {GetAccessLevelName(value)}.");
ClearScreen();
SendEverything();
@ -8092,11 +8092,6 @@ public class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPropertyLis
public void SayTo(Mobile to, string text) => SayTo(to, false, text);
public void SayTo(Mobile to, string format, params object[] args) => SayTo(to, false, string.Format(format, args));
public void SayTo(Mobile to, bool ascii, string format, params object[] args) =>
SayTo(to, ascii, string.Format(format, args));
public void SayTo(Mobile to, int number, string args = "") =>
to.NetState.SendMessageLocalized(Serial, Body, MessageType.Regular, SpeechHue, 3, number, Name, args);
@ -8104,8 +8099,6 @@ public class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPropertyLis
public void Say(string text) => PublicOverheadMessage(MessageType.Regular, SpeechHue, false, text);
public void Say(string format, params object[] args) => Say(string.Format(format, args));
public void Say(int number, AffixType type, string affix, string args) =>
PublicOverheadMessage(MessageType.Regular, SpeechHue, number, type, affix, args);
@ -8113,21 +8106,15 @@ public class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPropertyLis
public void Emote(string text) => PublicOverheadMessage(MessageType.Emote, EmoteHue, false, text);
public void Emote(string format, params object[] args) => Emote(string.Format(format, args));
public void Emote(int number, string args = "") => PublicOverheadMessage(MessageType.Emote, EmoteHue, number, args);
public void Whisper(string text) => PublicOverheadMessage(MessageType.Whisper, WhisperHue, false, text);
public void Whisper(string format, params object[] args) => Whisper(string.Format(format, args));
public void Whisper(int number, string args = "") =>
PublicOverheadMessage(MessageType.Whisper, WhisperHue, number, args);
public void Yell(string text) => PublicOverheadMessage(MessageType.Yell, YellHue, false, text);
public void Yell(string format, params object[] args) => Yell(string.Format(format, args));
public void Yell(int number, string args = "") =>
PublicOverheadMessage(MessageType.Yell, YellHue, number, args);
@ -9105,26 +9092,14 @@ public class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPropertyLis
public void SendMessage(string text) => SendMessage(0x3B2, text);
public void SendMessage(string format, params object[] args) =>
SendMessage(0x3B2, string.Format(format, args));
public void SendMessage(int hue, string text) =>
m_NetState.SendMessage(Serial.MinusOne, -1, MessageType.Regular, hue, 3, false, "ENU", "System", text);
public void SendMessage(int hue, string format, params object[] args) =>
SendMessage(hue, string.Format(format, args));
public void SendAsciiMessage(string text) => SendAsciiMessage(0x3B2, text);
public void SendAsciiMessage(string format, params object[] args) =>
SendAsciiMessage(0x3B2, string.Format(format, args));
public void SendAsciiMessage(int hue, string text) =>
m_NetState.SendMessage(Serial.MinusOne, -1, MessageType.Regular, hue, 3, true, null, "System", text);
public void SendAsciiMessage(int hue, string format, params object[] args) =>
SendAsciiMessage(hue, string.Format(format, args));
/// <summary>
/// Overridable. Event invoked when the Mobile is double clicked. By default, this method can either dismount or open the
/// paperdoll.

View file

@ -378,19 +378,16 @@ public class SecureTrade
if (platSend > 0 && goldSend > 0)
{
left.SendMessage(
"You traded {0:#,0} platinum and {1:#,0} gold to {2}.",
platSend,
goldSend,
right.RawName
$"You traded {platSend:#,0} platinum and {goldSend:#,0} gold to {right.RawName}."
);
}
else if (platSend > 0)
{
left.SendMessage("You traded {0:#,0} platinum to {1}.", platSend, right.RawName);
left.SendMessage($"You traded {platSend:#,0} platinum to {right.RawName}.");
}
else if (goldSend > 0)
{
left.SendMessage("You traded {0:#,0} gold to {1}.", goldSend, right.RawName);
left.SendMessage($"You traded {goldSend:#,0} gold to {right.RawName}.");
}
}
@ -399,19 +396,16 @@ public class SecureTrade
if (platRecv > 0 && goldRecv > 0)
{
left.SendMessage(
"You received {0:#,0} platinum and {1:#,0} gold from {2}.",
platRecv,
goldRecv,
right.RawName
$"You received {platRecv:#,0} platinum and {goldRecv:#,0} gold from {right.RawName}."
);
}
else if (platRecv > 0)
{
left.SendMessage("You received {0:#,0} platinum from {1}.", platRecv, right.RawName);
left.SendMessage($"You received {platRecv:#,0} platinum from {right.RawName}.");
}
else if (goldRecv > 0)
{
left.SendMessage("You received {0:#,0} gold from {1}.", goldRecv, right.RawName);
left.SendMessage($"You received {goldRecv:#,0} gold from {right.RawName}.");
}
}
}

View file

@ -246,10 +246,6 @@ public static class World
NetState.FlushAll();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Broadcast(int hue, bool ascii, string format, params object[] args) =>
Broadcast(hue, ascii, string.Format(format, args));
internal static void LoadEntities(string basePath, Dictionary<ulong, string> typesDb)
{
IIndexInfo<Serial> itemIndexInfo = new EntityTypeIndex("Items");