Поддержка локализации для панели взаимодействий (#2587)
This commit is contained in:
parent
66daea20b4
commit
6fc7a1d2d0
2 changed files with 14 additions and 16 deletions
|
|
@ -31,6 +31,7 @@ public sealed partial class CustomInteractionEditor : DefaultWindow
|
|||
#region Dependencies
|
||||
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] protected readonly ILocalizationManager Loc = default!;
|
||||
[Dependency] private readonly CustomInteractionService _customInteractionService = default!;
|
||||
|
||||
private readonly SharedAudioSystem _audio = default!;
|
||||
|
|
@ -147,10 +148,10 @@ public sealed partial class CustomInteractionEditor : DefaultWindow
|
|||
_categoryIds[categoryId] = string.Empty;
|
||||
|
||||
categoryId++;
|
||||
foreach (var category in _prototypeManager.EnumeratePrototypes<InteractionCategoryPrototype>().OrderBy(c => c.Name))
|
||||
foreach (var category in _prototypeManager.EnumeratePrototypes<InteractionCategoryPrototype>().OrderBy(c => Loc.GetString(c.Name)))
|
||||
{
|
||||
_categoryIds[categoryId] = category.ID;
|
||||
CategoryOption.AddItem(category.Name, categoryId);
|
||||
CategoryOption.AddItem(Loc.GetString(category.Name), categoryId);
|
||||
|
||||
if (category.ID == _interaction.CategoryId)
|
||||
{
|
||||
|
|
@ -166,10 +167,10 @@ public sealed partial class CustomInteractionEditor : DefaultWindow
|
|||
_iconIds[iconId] = string.Empty;
|
||||
|
||||
iconId++;
|
||||
foreach (var icon in _prototypeManager.EnumeratePrototypes<InteractionIconPrototype>().OrderBy(i => i.Name))
|
||||
foreach (var icon in _prototypeManager.EnumeratePrototypes<InteractionIconPrototype>().OrderBy(i => Loc.GetString(i.Name)))
|
||||
{
|
||||
_iconIds[iconId] = icon.ID;
|
||||
IconOption.AddItem(icon.Name, iconId);
|
||||
IconOption.AddItem(Loc.GetString(icon.Name), iconId);
|
||||
|
||||
if (icon.ID == _interaction.IconId)
|
||||
{
|
||||
|
|
@ -185,10 +186,10 @@ public sealed partial class CustomInteractionEditor : DefaultWindow
|
|||
_effectIds[effectId] = string.Empty;
|
||||
|
||||
effectId++;
|
||||
foreach (var effect in _prototypeManager.EnumeratePrototypes<InteractionEntityEffectPrototype>().OrderBy(e => e.Name))
|
||||
foreach (var effect in _prototypeManager.EnumeratePrototypes<InteractionEntityEffectPrototype>().OrderBy(e => Loc.GetString(e.Name)))
|
||||
{
|
||||
_effectIds[effectId] = effect.ID;
|
||||
EffectOption.AddItem(effect.Name, effectId);
|
||||
EffectOption.AddItem(Loc.GetString(effect.Name), effectId);
|
||||
|
||||
if (effect.ID == _interaction.EntityEffectId)
|
||||
{
|
||||
|
|
@ -204,10 +205,10 @@ public sealed partial class CustomInteractionEditor : DefaultWindow
|
|||
_soundIds[soundId] = string.Empty;
|
||||
|
||||
soundId++;
|
||||
foreach (var sound in _prototypeManager.EnumeratePrototypes<InteractionSoundPrototype>().OrderBy(s => s.Name))
|
||||
foreach (var sound in _prototypeManager.EnumeratePrototypes<InteractionSoundPrototype>().OrderBy(s => Loc.GetString(s.Name)))
|
||||
{
|
||||
_soundIds[soundId] = sound.ID;
|
||||
SoundOption.AddItem(sound.Name, soundId);
|
||||
SoundOption.AddItem(Loc.GetString(sound.Name), soundId);
|
||||
soundId++;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ public sealed partial class InteractionsUIWindow : DefaultWindow
|
|||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||
[Dependency] private readonly CustomInteractionService _customInteractionService = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] protected readonly ILocalizationManager Loc = default!;
|
||||
|
||||
private readonly SpriteSystem _spriteSystem;
|
||||
|
||||
|
|
@ -159,13 +160,9 @@ public sealed partial class InteractionsUIWindow : DefaultWindow
|
|||
if (!isCustom)
|
||||
{
|
||||
if (_prototypeManager.TryIndex<InteractionPrototype>(interactionId, out var prototype))
|
||||
{
|
||||
interactionName = prototype.Name;
|
||||
}
|
||||
interactionName = Loc.GetString(prototype.Name);
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -281,7 +278,7 @@ public sealed partial class InteractionsUIWindow : DefaultWindow
|
|||
|
||||
if (!categorizedInteractions.TryGetValue(categoryId, out _))
|
||||
{
|
||||
var categoryName = category.Name;
|
||||
var categoryName = Loc.GetString(category.Name);
|
||||
categorizedInteractions[categoryId] = (categoryName, new List<object>());
|
||||
}
|
||||
|
||||
|
|
@ -306,7 +303,7 @@ public sealed partial class InteractionsUIWindow : DefaultWindow
|
|||
if (!categorizedInteractions.TryGetValue(categoryId, out _))
|
||||
{
|
||||
var category = _prototypeManager.Index<InteractionCategoryPrototype>(categoryId);
|
||||
categorizedInteractions[categoryId] = (category.Name, new List<object>());
|
||||
categorizedInteractions[categoryId] = (Loc.GetString(category.Name), new List<object>());
|
||||
}
|
||||
|
||||
if (!_favoriteInteractions.Contains(customInteraction.Id))
|
||||
|
|
@ -1030,7 +1027,7 @@ public sealed partial class InteractionsUIWindow : DefaultWindow
|
|||
return "Не указана";
|
||||
|
||||
if (_prototypeManager.TryIndex<InteractionCategoryPrototype>(categoryId, out var category))
|
||||
return category.Name;
|
||||
return Loc.GetString(category.Name);
|
||||
|
||||
return categoryId;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue