Add a backup for unloaded bots

This commit is contained in:
Gustas
2025-03-30 13:53:19 +03:00
committed by Paul Chote
parent 27297a1ba9
commit d70c30763b
4 changed files with 62 additions and 11 deletions

View File

@@ -249,11 +249,26 @@ namespace OpenRA
/// </summary>
public string GetMessage(string key, object[] args = null)
{
// PERF: instead of loading mod level strings per each MapPreview, reuse the already loaded one in FluentProvider.
if (FluentProvider.TryGetModMessage(key, out var message, args))
if (TryGetMessage(key, out var message, args))
return message;
return innerData.FluentBundle?.GetMessage(key, args) ?? key;
return key;
}
/// <summary>
/// Functionality mirrors <see cref="FluentProvider.TryGetMessage"/>, except instead of using
/// loaded <see cref="Map"/>'s fluent bundle as backup, we use this <see cref="MapPreview"/>'s.
/// </summary>
public bool TryGetMessage(string key, out string message, object[] args = null)
{
// PERF: instead of loading mod level strings per each MapPreview, reuse the already loaded one in FluentProvider.
if (FluentProvider.TryGetModMessage(key, out message, args))
return true;
if (innerData.FluentBundle == null)
return false;
return innerData.FluentBundle.TryGetMessage(key, out message, args);
}
Sprite minimap;