Localize & fancify all the examine tooltips with markup.

This commit is contained in:
Pieter-Jan Briers
2019-10-13 22:49:07 +02:00
parent d629dc449f
commit fd109436e5
8 changed files with 38 additions and 46 deletions

View File

@@ -22,7 +22,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
{
#pragma warning disable 649
[Dependency] private readonly IPrototypeManager _prototypeManager;
[Dependency] private readonly ILocalizationManager _localizationManager;
[Dependency] private readonly ILocalizationManager _loc;
[Dependency] private readonly IEntitySystemManager _entitySystemManager;
#pragma warning restore 649
@@ -42,7 +42,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
/// </summary>
[Verb]
private sealed class FillTargetVerb : Verb<SolutionComponent>
{
{
protected override string GetText(IEntity user, SolutionComponent component)
{
if(!user.TryGetComponent<HandsComponent>(out var hands))
@@ -103,7 +103,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
void IExamine.Examine(FormattedMessage message)
{
message.AddText(_localizationManager.GetString("Contains:\n"));
message.AddText(_loc.GetString("Contains:\n"));
foreach (var reagent in ReagentList)
{
if (_prototypeManager.TryIndex(reagent.ReagentId, out ReagentPrototype proto))
@@ -112,7 +112,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
}
else
{
message.AddText(_localizationManager.GetString("Unknown reagent:") + $"{reagent.Quantity}u\n");
message.AddText(_loc.GetString("Unknown reagent: {0}u\n", reagent.Quantity));
}
}
}

View File

@@ -77,9 +77,11 @@ namespace Content.Server.GameObjects.Components.Interactable
void IExamine.Examine(FormattedMessage message)
{
var loc = IoCManager.Resolve<ILocalizationManager>();
if (Activated)
{
message.AddText("The light is currently on.");
message.AddMarkup(loc.GetString("The light is currently [color=darkgreen]on[/color]."));
}
}

View File

@@ -2,6 +2,8 @@
using Content.Server.GameObjects.EntitySystems;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Maths;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;
@@ -148,21 +150,18 @@ namespace Content.Server.GameObjects.Components.Interactable.Tools
void IExamine.Examine(FormattedMessage message)
{
var loc = IoCManager.Resolve<ILocalizationManager>();
if (Activated)
{
message.PushColor(Color.Orange);
message.AddText("Lit\n");
message.Pop();
message.AddMarkup(loc.GetString("[color=orange]Lit[/color]\n"));
}
else
{
message.AddText("Not lit\n");
message.AddText(loc.GetString("Not lit\n"));
}
message.AddText("Fuel: ");
message.PushColor(Fuel < FuelCapacity / 4f ? Color.DarkOrange : Color.Orange);
message.AddText($"{Math.Round(Fuel)}/{FuelCapacity}");
message.AddText(".");
message.Pop();
message.AddMarkup(loc.GetString("Fuel: [color={0}]{1}/{2}[/color].",
Fuel < FuelCapacity / 4f ? "darkorange" : "orange", Math.Round(Fuel), FuelCapacity));
}
}
}

View File

@@ -1,4 +1,3 @@
using System;
using Content.Server.GameObjects.Components.Sound;
using Content.Server.GameObjects.EntitySystems;
using Content.Shared.Audio;
@@ -7,7 +6,7 @@ using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
using Robust.Shared.Localization;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Serialization;
@@ -81,17 +80,11 @@ namespace Content.Server.GameObjects.Components.Items
Roll();
}
public void Examine(FormattedMessage message)
void IExamine.Examine(FormattedMessage message)
{
message.AddText("A dice with ");
message.PushColor(new Color(1F, 0.75F, 0.75F));
message.AddText(_sides.ToString());
message.Pop();
message.AddText(" sides.\nIt has landed on a ");
message.PushColor(new Color(1F, 1F, 1F));
message.AddText(_currentSide.ToString());
message.Pop();
message.AddText(".");
var loc = IoCManager.Resolve<ILocalizationManager>();
message.AddMarkup(loc.GetString("A dice with [color=lightgray]{0}[/color] sides.\n" +
"It has landed on a [color=white]{1}[/color].", _sides, _currentSide));
}
}
}

View File

@@ -221,11 +221,7 @@ namespace Content.Server.GameObjects.Components.Power
if (!Powered)
{
message.AddText(loc.GetString("The device is "));
message.PushColor(Color.Orange);
message.AddText(loc.GetString("not powered"));
message.Pop();
message.AddText(".");
message.AddMarkup(loc.GetString("The device is [color=orange]not powered[/color]."));
}
}

View File

@@ -7,6 +7,7 @@ using Robust.Shared.Utility;
using System;
using System.Globalization;
using Content.Server.GameObjects.EntitySystems;
using Robust.Shared.Localization;
using Robust.Shared.Maths;
using Robust.Shared.ViewVariables;
using YamlDotNet.RepresentationModel;
@@ -167,13 +168,16 @@ namespace Content.Server.GameObjects.Components.Power
}
AddCharge(RequestCharge(frameTime));
}
/// <inheritdoc />
public void Examine(FormattedMessage message)
{
message.PushColor(Color.Yellow);
var chargePercent = Math.Round(100*(Capacity != 0f ? (Charge/Capacity) : 1f), 2).ToString(NumberFormatInfo.InvariantInfo);
message.AddText($"Charge: {Math.Round(Charge, 2)}J / {Capacity}J ({chargePercent}%)\nRate: {ChargeRate}W IN, {DistributionRate}W OUT");
var loc = IoCManager.Resolve<ILocalizationManager>();
var chargePercent = Math.Round(100*Charge/Capacity, 2);
message.AddMarkup(loc.GetString(
"[color=yellow]Charge: {0}J / {1}J ({2}%)\nRate: {3}W IN, {4}W OUT[/color]",
Math.Round(Charge, 2), Capacity, chargePercent, ChargeRate, DistributionRate));
}
}
}

View File

@@ -3,6 +3,7 @@ using Content.Server.GameObjects.EntitySystems;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.Reflection;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
@@ -117,7 +118,10 @@ namespace Content.Server.GameObjects.Components.Stack
void IExamine.Examine(FormattedMessage message)
{
message.AddText($"There are {Count} things in the stack.");
var loc = IoCManager.Resolve<ILocalizationManager>();
message.AddMarkup(loc.GetPluralString(
"There is [color=lightgray]1[/color] thing in the stack",
"There are [color=lightgray]{0}[/color] things in the stack.", Count, Count));
}
}

View File

@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Content.Server.GameObjects.Components.Doors;
using Content.Server.GameObjects.Components.Interactable.Tools;
using Content.Server.GameObjects.Components.VendingMachines;
using Content.Server.GameObjects.EntitySystems;
@@ -301,15 +300,10 @@ namespace Content.Server.GameObjects.Components
void IExamine.Examine(FormattedMessage message)
{
var loc = IoCManager.Resolve<ILocalizationManager>();
message.AddText(loc.GetString("The "));
message.PushColor(Color.LightGray);
message.AddText(loc.GetString("maintenance panel"));
message.Pop();
message.AddText(loc.GetString(" is "));
message.PushColor(IsPanelOpen ? Color.DarkGreen : Color.DarkRed);
message.AddText(loc.GetString(IsPanelOpen ? "open" : "closed"));
message.Pop();
message.AddText(".");
message.AddMarkup(loc.GetString(IsPanelOpen
? "The [color=lightgray]maintenance panel[/color] is [color=darkgreen]open[/color]."
: "The [color=lightgray]maintenance panel[/color] is [color=darkred]closed[/color]."));
}
public void SetStatus(object statusIdentifier, string newMessage)