Expose game speeds to localisation.

This commit is contained in:
Matthias Mailänder
2022-10-23 19:32:44 +02:00
committed by abcdefg30
parent 425c678cd9
commit efe65701e4
7 changed files with 36 additions and 27 deletions

View File

@@ -314,12 +314,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var speeds = modData.Manifest.Get<GameSpeeds>().Speeds;
gameSpeed = "default";
gameSpeedButton.GetText = () => speeds[gameSpeed].Name;
var speedText = new CachedTransform<string, string>(s => modData.Translation.GetString(speeds[s].Name));
gameSpeedButton.GetText = () => speedText.Update(gameSpeed);
gameSpeedButton.OnMouseDown = _ =>
{
var options = speeds.Select(s => new DropDownOption
{
Title = s.Value.Name,
Title = modData.Translation.GetString(s.Value.Name),
IsSelected = () => gameSpeed == s.Key,
OnClick = () => gameSpeed = s.Key
});