From a5051c549bdb83c0d82856501911e4a987bd1e60 Mon Sep 17 00:00:00 2001 From: Hugal31 Date: Fri, 17 Jul 2020 10:44:32 +0200 Subject: [PATCH] Use TheName macro and GrammarComponent (#1396) --- .../Gravity/GravityGeneratorComponent.cs | 2 +- .../Components/Nutrition/FoodComponent.cs | 2 +- .../Components/PottedPlantHideComponent.cs | 4 ++-- .../Components/Weapon/Melee/FlashComponent.cs | 6 +++--- .../BodyPart/DroppedBodyPartComponent.cs | 6 +++--- .../Surgery/Surgeon/SurgeryToolComponent.cs | 19 ++++++++++++++----- Resources/Prototypes/Entities/Mobs/human.yml | 5 +++++ .../Prototypes/Entities/Mobs/observer.yml | 3 +++ 8 files changed, 32 insertions(+), 15 deletions(-) diff --git a/Content.Server/GameObjects/Components/Gravity/GravityGeneratorComponent.cs b/Content.Server/GameObjects/Components/Gravity/GravityGeneratorComponent.cs index 52f8a99fd5..d24c8b8008 100644 --- a/Content.Server/GameObjects/Components/Gravity/GravityGeneratorComponent.cs +++ b/Content.Server/GameObjects/Components/Gravity/GravityGeneratorComponent.cs @@ -120,7 +120,7 @@ namespace Content.Server.GameObjects.Components.Gravity var notifyManager = IoCManager.Resolve(); - notifyManager.PopupMessage(Owner, eventArgs.User, Loc.GetString("You repair the gravity generator with the welder")); + notifyManager.PopupMessage(Owner, eventArgs.User, Loc.GetString("You repair {0:theName} with {1:theName}", Owner, eventArgs.Using)); return true; } diff --git a/Content.Server/GameObjects/Components/Nutrition/FoodComponent.cs b/Content.Server/GameObjects/Components/Nutrition/FoodComponent.cs index 039e3ff759..89c492beaa 100644 --- a/Content.Server/GameObjects/Components/Nutrition/FoodComponent.cs +++ b/Content.Server/GameObjects/Components/Nutrition/FoodComponent.cs @@ -101,7 +101,7 @@ namespace Content.Server.GameObjects.Components.Nutrition if (UsesRemaining <= 0) { - user.PopupMessage(user, Loc.GetString($"The {Owner.Name} is empty!")); + user.PopupMessage(user, Loc.GetString("{0:TheName} is empty!", Owner)); return false; } diff --git a/Content.Server/GameObjects/Components/PottedPlantHideComponent.cs b/Content.Server/GameObjects/Components/PottedPlantHideComponent.cs index 5c1c2cd9e1..249124a5fe 100644 --- a/Content.Server/GameObjects/Components/PottedPlantHideComponent.cs +++ b/Content.Server/GameObjects/Components/PottedPlantHideComponent.cs @@ -46,7 +46,7 @@ namespace Content.Server.GameObjects.Components if (size > MaxItemSize) { Owner.PopupMessage(eventArgs.User, - Loc.GetString("{0:TheName} is too big to fit in the plant!", eventArgs.Using.Name)); + Loc.GetString("{0:TheName} is too big to fit in the plant!", eventArgs.Using)); return false; } @@ -57,7 +57,7 @@ namespace Content.Server.GameObjects.Components return false; } - Owner.PopupMessage(eventArgs.User, Loc.GetString("You hide {0:theName} in the plant.", eventArgs.Using.Name)); + Owner.PopupMessage(eventArgs.User, Loc.GetString("You hide {0:theName} in the plant.", eventArgs.Using)); Rustle(); return true; } diff --git a/Content.Server/GameObjects/Components/Weapon/Melee/FlashComponent.cs b/Content.Server/GameObjects/Components/Weapon/Melee/FlashComponent.cs index 0a9bee0f6f..1edf8e3ef1 100644 --- a/Content.Server/GameObjects/Components/Weapon/Melee/FlashComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Melee/FlashComponent.cs @@ -106,7 +106,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee { sprite.LayerSetState(0, "burnt"); - _notifyManager.PopupMessage(Owner, user, "The flash burns out!"); + _notifyManager.PopupMessage(Owner, user, Loc.GetString("The flash burns out!")); } else if (!_flashing) { @@ -151,7 +151,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee if (entity != user) { - _notifyManager.PopupMessage(user, entity, $"{user.Name} blinds you with the {Owner.Name}"); + _notifyManager.PopupMessage(user, entity, Loc.GetString("{0:TheName} blinds you with {1:theName}", user, Owner)); } } @@ -166,7 +166,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee if (inDetailsRange) { message.AddMarkup(_localizationManager.GetString( - $"The flash has [color=green]{Uses}[/color] uses remaining.")); + "The flash has [color=green]{0}[/color] uses remaining.", Uses)); } } } diff --git a/Content.Server/Health/BodySystem/BodyPart/DroppedBodyPartComponent.cs b/Content.Server/Health/BodySystem/BodyPart/DroppedBodyPartComponent.cs index ffad52bc07..8fc0ee2724 100644 --- a/Content.Server/Health/BodySystem/BodyPart/DroppedBodyPartComponent.cs +++ b/Content.Server/Health/BodySystem/BodyPart/DroppedBodyPartComponent.cs @@ -109,7 +109,7 @@ namespace Content.Server.BodySystem } else //If surgery cannot be performed, show message saying so. { - _sharedNotifyManager.PopupMessage(eventArgs.Target, eventArgs.User, Loc.GetString("You see no way to install the {0}.", Owner.Name)); + _sharedNotifyManager.PopupMessage(eventArgs.Target, eventArgs.User, Loc.GetString("You see no way to install {0:theName}.", Owner)); } } @@ -122,7 +122,7 @@ namespace Content.Server.BodySystem //TODO: sanity checks to see whether user is in range, user is still able-bodied, target is still the same, etc etc if (!_optionsCache.TryGetValue(key, out object targetObject)) { - _sharedNotifyManager.PopupMessage(_bodyManagerComponentCache.Owner, _performerCache, Loc.GetString("You see no useful way to attach the {0} anymore.", Owner.Name)); + _sharedNotifyManager.PopupMessage(_bodyManagerComponentCache.Owner, _performerCache, Loc.GetString("You see no useful way to attach {0:theName} anymore.", Owner)); } string target = targetObject as string; if (!_bodyManagerComponentCache.InstallDroppedBodyPart(this, target)) @@ -131,7 +131,7 @@ namespace Content.Server.BodySystem } else { - _sharedNotifyManager.PopupMessage(_bodyManagerComponentCache.Owner, _performerCache, Loc.GetString("You attach the {0}.", ContainedBodyPart.Name)); + _sharedNotifyManager.PopupMessage(_bodyManagerComponentCache.Owner, _performerCache, Loc.GetString("You attach {0:theName}.", ContainedBodyPart)); } } diff --git a/Content.Server/Health/BodySystem/Surgery/Surgeon/SurgeryToolComponent.cs b/Content.Server/Health/BodySystem/Surgery/Surgeon/SurgeryToolComponent.cs index d908a053fe..bf2e55624f 100644 --- a/Content.Server/Health/BodySystem/Surgery/Surgeon/SurgeryToolComponent.cs +++ b/Content.Server/Health/BodySystem/Surgery/Surgeon/SurgeryToolComponent.cs @@ -12,6 +12,7 @@ using Robust.Shared.GameObjects; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.Random; using Robust.Shared.IoC; +using Robust.Shared.Localization; using Robust.Shared.Log; using Robust.Shared.Serialization; @@ -81,7 +82,7 @@ namespace Content.Server.BodySystem } else //If surgery cannot be performed, show message saying so. { - _sharedNotifyManager.PopupMessage(eventArgs.Target, eventArgs.User, "You see no useful way to use the " + Owner.Name + "."); + SendNoUsefulWayToUsePopup(); } } else if (eventArgs.Target.TryGetComponent(out DroppedBodyPartComponent droppedBodyPart)) //Attempt surgery on a DroppedBodyPart - there's only one possible target so no need for selection UI @@ -102,7 +103,7 @@ namespace Content.Server.BodySystem } else //If surgery cannot be performed, show message saying so. { - _sharedNotifyManager.PopupMessage(eventArgs.Target, eventArgs.User,"You see no useful way to use the " + Owner.Name + "."); + SendNoUsefulWayToUsePopup(); } } } @@ -180,12 +181,12 @@ namespace Content.Server.BodySystem //TODO: sanity checks to see whether user is in range, user is still able-bodied, target is still the same, etc etc if (!_optionsCache.TryGetValue(key, out object targetObject)) { - _sharedNotifyManager.PopupMessage(_bodyManagerComponentCache.Owner, _performerCache, "You see no useful way to use the " + Owner.Name + " anymore."); + SendNoUsefulWayToUseAnymorePopup(); } BodyPart target = targetObject as BodyPart; if (!target.AttemptSurgery(_surgeryType, _bodyManagerComponentCache, this, _performerCache)) { - _sharedNotifyManager.PopupMessage(_bodyManagerComponentCache.Owner, _performerCache, "You see no useful way to use the " + Owner.Name + " anymore."); + SendNoUsefulWayToUseAnymorePopup(); } } @@ -197,14 +198,22 @@ namespace Content.Server.BodySystem //TODO: sanity checks to see whether user is in range, user is still able-bodied, target is still the same, etc etc if (!_optionsCache.TryGetValue(key, out object targetObject)) { - _sharedNotifyManager.PopupMessage(_bodyManagerComponentCache.Owner, _performerCache, "You see no useful way to use the " + Owner.Name + " anymore."); + SendNoUsefulWayToUseAnymorePopup(); } Mechanism target = targetObject as Mechanism; CloseSurgeryUI(_performerCache.GetComponent().playerSession); _callbackCache(target, _bodyManagerComponentCache, this, _performerCache); } + private void SendNoUsefulWayToUsePopup() + { + _sharedNotifyManager.PopupMessage(_bodyManagerComponentCache.Owner, _performerCache, Loc.GetString("You see no useful way to use {0:theName}.", Owner)); + } + private void SendNoUsefulWayToUseAnymorePopup() + { + _sharedNotifyManager.PopupMessage(_bodyManagerComponentCache.Owner, _performerCache, Loc.GetString("You see no useful way to use {0:theName} anymore.", Owner)); + } public override void ExposeData(ObjectSerializer serializer) { diff --git a/Resources/Prototypes/Entities/Mobs/human.yml b/Resources/Prototypes/Entities/Mobs/human.yml index f7db6f6d2b..9a23748bc7 100644 --- a/Resources/Prototypes/Entities/Mobs/human.yml +++ b/Resources/Prototypes/Entities/Mobs/human.yml @@ -139,6 +139,8 @@ range: 0.8 arcwidth: 30 arc: fist + - type: Grammar + proper: true - type: entity save: false @@ -254,3 +256,6 @@ - type: SpeciesVisualizer2D - type: HumanoidAppearance + + - type: Grammar + proper: true diff --git a/Resources/Prototypes/Entities/Mobs/observer.yml b/Resources/Prototypes/Entities/Mobs/observer.yml index 9044015c70..c09d7c7de1 100644 --- a/Resources/Prototypes/Entities/Mobs/observer.yml +++ b/Resources/Prototypes/Entities/Mobs/observer.yml @@ -28,3 +28,6 @@ baseWalkSpeed: 7 - type: MovementIgnoreGravity + + - type: Grammar + proper: true