Merge pull request #3929 from ScottNZ/translation
Add translation support
This commit is contained in:
@@ -16,8 +16,8 @@ namespace OpenRA.Mods.RA
|
||||
[Desc("Shown in the build palette widget.")]
|
||||
public class TooltipInfo : ITraitInfo
|
||||
{
|
||||
public readonly string Description = "";
|
||||
public readonly string Name = "";
|
||||
[Translate] public readonly string Description = "";
|
||||
[Translate] public readonly string Name = "";
|
||||
|
||||
[Desc("Sequence of the actor that contains the cameo.")]
|
||||
public readonly string Icon = "icon";
|
||||
|
||||
@@ -26,9 +26,9 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
public int Columns = 3;
|
||||
public int Rows = 5;
|
||||
|
||||
public string ReadyText = "";
|
||||
public string HoldText = "";
|
||||
public string RequiresText = "";
|
||||
[Translate] public string ReadyText = "";
|
||||
[Translate] public string HoldText = "";
|
||||
[Translate] public string RequiresText = "";
|
||||
|
||||
public int IconWidth = 64;
|
||||
public int IconHeight = 48;
|
||||
@@ -484,7 +484,7 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
var prereqs = buildable.Prerequisites.Select(Description);
|
||||
if (prereqs.Any())
|
||||
{
|
||||
Game.Renderer.Fonts["Regular"].DrawText("{0} {1}".F(RequiresText, prereqs.JoinWith(", ")), p.ToInt2(), Color.White);
|
||||
Game.Renderer.Fonts["Regular"].DrawText(RequiresText.F(prereqs.JoinWith(", ")), p.ToInt2(), Color.White);
|
||||
|
||||
p += new int2(0, 8);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.FileFormats.Graphics;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Widgets;
|
||||
@@ -142,6 +143,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
var maxFrameRate = display.Get<TextFieldWidget>("MAX_FRAMERATE");
|
||||
maxFrameRate.Text = gs.MaxFramerate.ToString();
|
||||
|
||||
var languageDropDownButton = display.Get<DropDownButtonWidget>("LANGUAGE_DROPDOWNBUTTON");
|
||||
languageDropDownButton.OnMouseDown = _ => ShowLanguageDropdown(languageDropDownButton);
|
||||
languageDropDownButton.GetText = () => FieldLoader.Translate(Game.Settings.Graphics.Language);
|
||||
|
||||
// Keys
|
||||
var keys = bg.Get("KEYS_PANE");
|
||||
var keyConfig = Game.Settings.Keys;
|
||||
@@ -270,6 +275,20 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool ShowLanguageDropdown(DropDownButtonWidget dropdown)
|
||||
{
|
||||
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) =>
|
||||
{
|
||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||
() => Game.Settings.Graphics.Language == o,
|
||||
() => Game.Settings.Graphics.Language = o);
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => FieldLoader.Translate(o);
|
||||
return item;
|
||||
};
|
||||
|
||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, Game.modData.Languages, setupItem);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool ShowSoundTickDropdown(DropDownButtonWidget dropdown, SoundSettings audio)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user