Improve ExaminedEvent to handle newlines for you with helper methods.

This commit is contained in:
Pieter-Jan Briers
2021-09-15 16:58:15 +02:00
parent 9c7b061d13
commit cd6c2bb373
13 changed files with 76 additions and 38 deletions

View File

@@ -58,10 +58,9 @@ namespace Content.Server.Construction
{
if (component.Target != null)
{
args.Message.AddMarkup(
Loc.GetString(
"construction-component-to-create-header",
("targetName", component.Target.Name)) + "\n");
args.PushMarkup(Loc.GetString(
"construction-component-to-create-header",
("targetName", component.Target.Name)));
}
if (component.Edge == null && component.TargetNextEdge != null)

View File

@@ -59,10 +59,8 @@ namespace Content.Server.Dice
private void OnExamined(EntityUid uid, DiceComponent dice, ExaminedEvent args)
{
//No details check, since the sprite updates to show the side.
args.Message.PushNewline();
args.Message.AddMarkup(Loc.GetString("dice-component-on-examine-message-part-1", ("sidesAmount", dice.Sides)));
args.Message.PushNewline();
args.Message.AddMarkup(Loc.GetString("dice-component-on-examine-message-part-2", ("currentSide", dice.CurrentSide)));
args.PushMarkup(Loc.GetString("dice-component-on-examine-message-part-1", ("sidesAmount", dice.Sides)));
args.PushMarkup(Loc.GetString("dice-component-on-examine-message-part-2", ("currentSide", dice.CurrentSide)));
}
}
}

View File

@@ -169,15 +169,13 @@ namespace Content.Server.Flash
{
if (!comp.HasUses)
{
args.Message.AddText("\n");
args.Message.AddText(Loc.GetString("flash-component-examine-empty"));
args.PushText(Loc.GetString("flash-component-examine-empty"));
return;
}
if (args.IsInDetailsRange)
{
args.Message.AddText("\n");
args.Message.AddMarkup(
args.PushMarkup(
Loc.GetString(
"flash-component-examine-detail-count",
("count", comp.Uses),

View File

@@ -32,7 +32,7 @@ namespace Content.Server.Fluids
{
if (ComponentManager.TryGetComponent<SlipperyComponent>(uid, out var slippery) && slippery.Slippery)
{
args.Message.AddText(Loc.GetString("puddle-component-examine-is-slipper-text"));
args.PushText(Loc.GetString("puddle-component-examine-is-slipper-text"));
}
}

View File

@@ -86,7 +86,7 @@ namespace Content.Server.Ghost
? Loc.GetString("comp-ghost-examine-time-minutes", ("minutes", timeSinceDeath.Minutes))
: Loc.GetString("comp-ghost-examine-time-seconds", ("seconds", timeSinceDeath.Seconds));
args.Message.AddMarkup(deathTimeInfo);
args.PushMarkup(deathTimeInfo);
}
private void OnMindRemovedMessage(EntityUid uid, GhostComponent component, MindRemovedMessage args)

View File

@@ -192,7 +192,7 @@ namespace Content.Server.Hands
{
foreach (var inhand in component.GetAllHeldItems())
{
args.Message.AddText($"\n{Loc.GetString("comp-hands-examine", ("user", component.Owner), ("item", inhand.Owner))}");
args.PushText(Loc.GetString("comp-hands-examine", ("user", component.Owner), ("item", inhand.Owner)));
}
}

View File

@@ -52,11 +52,10 @@ namespace Content.Server.Lock
private void OnExamined(EntityUid eUI, LockComponent lockComp, ExaminedEvent args)
{
args.Message.AddText("\n");
args.Message.AddText(Loc.GetString(lockComp.Locked
? "lock-comp-on-examined-is-locked"
: "lock-comp-on-examined-is-unlocked",
("entityName", lockComp.Owner.Name)));
args.PushText(Loc.GetString(lockComp.Locked
? "lock-comp-on-examined-is-locked"
: "lock-comp-on-examined-is-unlocked",
("entityName", lockComp.Owner.Name)));
}
public void DoLock(LockComponent lockComp, ActivateInWorldEvent args)
@@ -72,7 +71,7 @@ namespace Content.Server.Lock
{
SoundSystem.Play(Filter.Pvs(lockComp.Owner), lockComp.LockSound.GetSound(), lockComp.Owner, AudioParams.Default.WithVolume(-5));
}
if (lockComp.Owner.TryGetComponent(out AppearanceComponent? appearanceComp))
{
appearanceComp.SetData(StorageVisuals.Locked, true);
@@ -96,7 +95,7 @@ namespace Content.Server.Lock
{
SoundSystem.Play(Filter.Pvs(lockComp.Owner), lockComp.UnlockSound.GetSound(), lockComp.Owner, AudioParams.Default.WithVolume(-5));
}
if (lockComp.Owner.TryGetComponent(out AppearanceComponent? appearanceComp))
{
appearanceComp.SetData(StorageVisuals.Locked, false);

View File

@@ -108,11 +108,10 @@ namespace Content.Server.Stunnable
private void OnExamined(EntityUid uid, StunbatonComponent comp, ExaminedEvent args)
{
args.Message.AddText("\n");
var msg = comp.Activated
? Loc.GetString("comp-stunbaton-examined-on")
: Loc.GetString("comp-stunbaton-examined-off");
args.Message.AddMarkup(msg);
args.PushMarkup(msg);
}
private void StunEntity(IEntity entity, StunbatonComponent comp)

View File

@@ -28,16 +28,16 @@ namespace Content.Server.Tools
{
if (component.WelderLit)
{
args.Message.AddMarkup(Loc.GetString("welder-component-on-examine-welder-lit-message") + "\n");
args.PushMarkup(Loc.GetString("welder-component-on-examine-welder-lit-message"));
}
else
{
args.Message.AddText(Loc.GetString("welder-component-on-examine-welder-not-lit-message") + "\n");
args.PushMarkup(Loc.GetString("welder-component-on-examine-welder-not-lit-message"));
}
if (args.IsInDetailsRange)
{
args.Message.AddMarkup(Loc.GetString("welder-component-on-examine-detailed-message",
args.PushMarkup(Loc.GetString("welder-component-on-examine-detailed-message",
("colorName", component.Fuel < component.FuelCapacity / 4f ? "darkorange" : "orange"),
("fuelLeft", Math.Round(component.Fuel)),
("fuelCapacity", component.FuelCapacity)));