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 #pragma warning disable 649
[Dependency] private readonly IPrototypeManager _prototypeManager; [Dependency] private readonly IPrototypeManager _prototypeManager;
[Dependency] private readonly ILocalizationManager _localizationManager; [Dependency] private readonly ILocalizationManager _loc;
[Dependency] private readonly IEntitySystemManager _entitySystemManager; [Dependency] private readonly IEntitySystemManager _entitySystemManager;
#pragma warning restore 649 #pragma warning restore 649
@@ -103,7 +103,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
void IExamine.Examine(FormattedMessage message) void IExamine.Examine(FormattedMessage message)
{ {
message.AddText(_localizationManager.GetString("Contains:\n")); message.AddText(_loc.GetString("Contains:\n"));
foreach (var reagent in ReagentList) foreach (var reagent in ReagentList)
{ {
if (_prototypeManager.TryIndex(reagent.ReagentId, out ReagentPrototype proto)) if (_prototypeManager.TryIndex(reagent.ReagentId, out ReagentPrototype proto))
@@ -112,7 +112,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
} }
else 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) void IExamine.Examine(FormattedMessage message)
{ {
var loc = IoCManager.Resolve<ILocalizationManager>();
if (Activated) 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 Content.Server.GameObjects.EntitySystems;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
using Robust.Shared.Utility; using Robust.Shared.Utility;
@@ -148,21 +150,18 @@ namespace Content.Server.GameObjects.Components.Interactable.Tools
void IExamine.Examine(FormattedMessage message) void IExamine.Examine(FormattedMessage message)
{ {
var loc = IoCManager.Resolve<ILocalizationManager>();
if (Activated) if (Activated)
{ {
message.PushColor(Color.Orange); message.AddMarkup(loc.GetString("[color=orange]Lit[/color]\n"));
message.AddText("Lit\n");
message.Pop();
} }
else 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.AddMarkup(loc.GetString("Fuel: [color={0}]{1}/{2}[/color].",
message.AddText($"{Math.Round(Fuel)}/{FuelCapacity}"); Fuel < FuelCapacity / 4f ? "darkorange" : "orange", Math.Round(Fuel), FuelCapacity));
message.AddText(".");
message.Pop();
} }
} }
} }

View File

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

View File

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

View File

@@ -7,6 +7,7 @@ using Robust.Shared.Utility;
using System; using System;
using System.Globalization; using System.Globalization;
using Content.Server.GameObjects.EntitySystems; using Content.Server.GameObjects.EntitySystems;
using Robust.Shared.Localization;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
using YamlDotNet.RepresentationModel; using YamlDotNet.RepresentationModel;
@@ -171,9 +172,12 @@ namespace Content.Server.GameObjects.Components.Power
/// <inheritdoc /> /// <inheritdoc />
public void Examine(FormattedMessage message) public void Examine(FormattedMessage message)
{ {
message.PushColor(Color.Yellow); var loc = IoCManager.Resolve<ILocalizationManager>();
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 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.GameObjects;
using Robust.Shared.Interfaces.Reflection; using Robust.Shared.Interfaces.Reflection;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
using Robust.Shared.Utility; using Robust.Shared.Utility;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
@@ -117,7 +118,10 @@ namespace Content.Server.GameObjects.Components.Stack
void IExamine.Examine(FormattedMessage message) 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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Content.Server.GameObjects.Components.Doors;
using Content.Server.GameObjects.Components.Interactable.Tools; using Content.Server.GameObjects.Components.Interactable.Tools;
using Content.Server.GameObjects.Components.VendingMachines; using Content.Server.GameObjects.Components.VendingMachines;
using Content.Server.GameObjects.EntitySystems; using Content.Server.GameObjects.EntitySystems;
@@ -301,15 +300,10 @@ namespace Content.Server.GameObjects.Components
void IExamine.Examine(FormattedMessage message) void IExamine.Examine(FormattedMessage message)
{ {
var loc = IoCManager.Resolve<ILocalizationManager>(); var loc = IoCManager.Resolve<ILocalizationManager>();
message.AddText(loc.GetString("The "));
message.PushColor(Color.LightGray); message.AddMarkup(loc.GetString(IsPanelOpen
message.AddText(loc.GetString("maintenance panel")); ? "The [color=lightgray]maintenance panel[/color] is [color=darkgreen]open[/color]."
message.Pop(); : "The [color=lightgray]maintenance panel[/color] is [color=darkred]closed[/color]."));
message.AddText(loc.GetString(" is "));
message.PushColor(IsPanelOpen ? Color.DarkGreen : Color.DarkRed);
message.AddText(loc.GetString(IsPanelOpen ? "open" : "closed"));
message.Pop();
message.AddText(".");
} }
public void SetStatus(object statusIdentifier, string newMessage) public void SetStatus(object statusIdentifier, string newMessage)