Extract translation strings.
This commit is contained in:
committed by
teinarss
parent
8201a57b10
commit
cc58fe1a0f
@@ -112,7 +112,7 @@ namespace OpenRA.Mods.Common.Server
|
||||
static readonly string ChangedMap = "changed-map";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string BotsDisabled = "bots-disabled";
|
||||
static readonly string MapBotsDisabled = "map-bots-disabled";
|
||||
|
||||
[TranslationReference("player", "name", "value")]
|
||||
static readonly string ValueChanged = "value-changed";
|
||||
@@ -624,7 +624,7 @@ namespace OpenRA.Mods.Common.Server
|
||||
if (!server.LobbyInfo.GlobalSettings.EnableSingleplayer)
|
||||
server.SendLocalizedMessage(TwoHumansRequired);
|
||||
else if (server.Map.Players.Players.Where(p => p.Value.Playable).All(p => !p.Value.AllowBots))
|
||||
server.SendLocalizedMessage(BotsDisabled);
|
||||
server.SendLocalizedMessage(MapBotsDisabled);
|
||||
|
||||
var briefing = MissionBriefingOrDefault(server);
|
||||
if (briefing != null)
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
enum ActorIDStatus { Normal = 0, Duplicate = 1, Empty = 3 }
|
||||
|
||||
readonly WorldRenderer worldRenderer;
|
||||
readonly ModData modData;
|
||||
readonly EditorActorLayer editorActorLayer;
|
||||
readonly EditorActionManager editorActionManager;
|
||||
readonly EditorViewportControllerWidget editor;
|
||||
@@ -42,6 +43,16 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
readonly int editPanelPadding; // Padding between right edge of actor and the edit panel.
|
||||
readonly long scrollVisibleTimeout = 100; // Delay after scrolling map before edit widget becomes visible again.
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string DuplicateActorId = "duplicate-actor-id";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string EnterActorId = "enter-actor-id";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string Owner = "owner";
|
||||
|
||||
long lastScrollTime = 0;
|
||||
int2 lastScrollPosition = int2.Zero;
|
||||
|
||||
@@ -74,9 +85,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public ActorEditLogic(Widget widget, World world, WorldRenderer worldRenderer, Dictionary<string, MiniYaml> logicArgs)
|
||||
public ActorEditLogic(Widget widget, ModData modData, World world, WorldRenderer worldRenderer, Dictionary<string, MiniYaml> logicArgs)
|
||||
{
|
||||
this.modData = modData;
|
||||
this.worldRenderer = worldRenderer;
|
||||
|
||||
editorActorLayer = world.WorldActor.Trait<EditorActorLayer>();
|
||||
editorActionManager = world.WorldActor.Trait<EditorActionManager>();
|
||||
|
||||
@@ -101,7 +114,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
actorIDErrorLabel = actorEditPanel.Get<LabelWidget>("ACTOR_ID_ERROR_LABEL");
|
||||
actorIDErrorLabel.IsVisible = () => actorIDStatus != ActorIDStatus.Normal;
|
||||
actorIDErrorLabel.GetText = () => actorIDStatus == ActorIDStatus.Duplicate ?
|
||||
"Duplicate Actor ID" : "Enter an Actor ID";
|
||||
modData.Translation.GetString(DuplicateActorId)
|
||||
: modData.Translation.GetString(EnterActorId);
|
||||
|
||||
if (logicArgs.TryGetValue("EditPanelPadding", out var yaml))
|
||||
editPanelPadding = FieldLoader.GetValue<int>("EditPanelPadding", yaml.Value);
|
||||
@@ -131,7 +145,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (editorActorLayer[actorId] != null)
|
||||
{
|
||||
nextActorIDStatus = ActorIDStatus.Duplicate;
|
||||
actorIDErrorLabel.Text = "Duplicate ActorID";
|
||||
actorIDErrorLabel.Text = modData.Translation.GetString(DuplicateActorId);
|
||||
actorIDErrorLabel.Visible = true;
|
||||
return;
|
||||
}
|
||||
@@ -215,7 +229,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
// Add owner dropdown
|
||||
var ownerContainer = dropdownOptionTemplate.Clone();
|
||||
ownerContainer.Get<LabelWidget>("LABEL").GetText = () => "Owner";
|
||||
var owner = modData.Translation.GetString(Owner);
|
||||
ownerContainer.Get<LabelWidget>("LABEL").GetText = () => owner;
|
||||
var ownerDropdown = ownerContainer.Get<DropDownButtonWidget>("OPTION");
|
||||
var selectedOwner = actor.Owner;
|
||||
|
||||
|
||||
@@ -42,11 +42,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
readonly ActorSelectorActor[] allActors;
|
||||
readonly EditorCursorLayer editorCursor;
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string Type = "type";
|
||||
|
||||
PlayerReference selectedOwner;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public ActorSelectorLogic(Widget widget, World world, WorldRenderer worldRenderer)
|
||||
: base(widget, world, worldRenderer, "ACTORTEMPLATE_LIST", "ACTORPREVIEW_TEMPLATE")
|
||||
public ActorSelectorLogic(Widget widget, ModData modData, World world, WorldRenderer worldRenderer)
|
||||
: base(widget, modData, world, worldRenderer, "ACTORTEMPLATE_LIST", "ACTORPREVIEW_TEMPLATE")
|
||||
{
|
||||
mapRules = world.Map.Rules;
|
||||
ownersDropDown = widget.Get<DropDownButtonWidget>("OWNERS_DROPDOWN");
|
||||
@@ -112,7 +115,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (tooltip != null)
|
||||
searchTerms.Add(tooltip.Name);
|
||||
|
||||
var tooltipText = (tooltip == null ? "Type: " : tooltip.Name + "\nType: ") + a.Name;
|
||||
var type = modData.Translation.GetString(Type);
|
||||
var tooltipText = (tooltip == null ? $"{type}: " : tooltip.Name + $"\n{type}: ") + a.Name;
|
||||
allActorsTemp.Add(new ActorSelectorActor(a, editorData.Categories, searchTerms.ToArray(), tooltipText));
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
public abstract class CommonSelectorLogic : ChromeLogic
|
||||
{
|
||||
protected readonly Widget Widget;
|
||||
protected readonly ModData ModData;
|
||||
protected readonly TextFieldWidget SearchTextField;
|
||||
protected readonly World World;
|
||||
protected readonly WorldRenderer WorldRenderer;
|
||||
@@ -33,9 +34,22 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
protected string[] allCategories;
|
||||
protected string searchFilter;
|
||||
|
||||
public CommonSelectorLogic(Widget widget, World world, WorldRenderer worldRenderer, string templateListId, string previewTemplateId)
|
||||
[TranslationReference]
|
||||
static readonly string None = "none";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string SearchResults = "search-results";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string All = "all";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string Multiple = "multiple";
|
||||
|
||||
public CommonSelectorLogic(Widget widget, ModData modData, World world, WorldRenderer worldRenderer, string templateListId, string previewTemplateId)
|
||||
{
|
||||
Widget = widget;
|
||||
ModData = modData;
|
||||
World = world;
|
||||
WorldRenderer = worldRenderer;
|
||||
Editor = widget.Parent.Get<EditorViewportControllerWidget>("MAP_EDITOR");
|
||||
@@ -61,18 +75,18 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
categorySelector.GetText = () =>
|
||||
{
|
||||
if (SelectedCategories.Count == 0)
|
||||
return "None";
|
||||
return ModData.Translation.GetString(None);
|
||||
|
||||
if (!string.IsNullOrEmpty(searchFilter))
|
||||
return "Search Results";
|
||||
return ModData.Translation.GetString(SearchResults);
|
||||
|
||||
if (SelectedCategories.Count == 1)
|
||||
return SelectedCategories.First();
|
||||
|
||||
if (SelectedCategories.Count == allCategories.Length)
|
||||
return "All";
|
||||
return ModData.Translation.GetString(All);
|
||||
|
||||
return "Multiple";
|
||||
return ModData.Translation.GetString(Multiple);
|
||||
};
|
||||
|
||||
categorySelector.OnMouseDown = _ =>
|
||||
|
||||
@@ -43,8 +43,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
readonly EditorCursorLayer editorCursor;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public TileSelectorLogic(Widget widget, World world, WorldRenderer worldRenderer)
|
||||
: base(widget, world, worldRenderer, "TILETEMPLATE_LIST", "TILEPREVIEW_TEMPLATE")
|
||||
public TileSelectorLogic(Widget widget, ModData modData, World world, WorldRenderer worldRenderer)
|
||||
: base(widget, modData, world, worldRenderer, "TILETEMPLATE_LIST", "TILEPREVIEW_TEMPLATE")
|
||||
{
|
||||
terrainInfo = world.Map.Rules.TerrainInfo as ITemplatedTerrainInfo;
|
||||
if (terrainInfo == null)
|
||||
|
||||
@@ -29,16 +29,31 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
IngameInfoPanel activePanel;
|
||||
readonly bool hasError;
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string Objectives = "objectives";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string Briefing = "briefing";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string Options = "options";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string Debug = "debug";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string Chat = "chat";
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public GameInfoLogic(Widget widget, ModData modData, World world, IngameInfoPanel initialPanel, Action<bool> hideMenu)
|
||||
{
|
||||
var panels = new Dictionary<IngameInfoPanel, (string Panel, string Label, Action<ButtonWidget, Widget> Setup)>()
|
||||
{
|
||||
{ IngameInfoPanel.Objectives, ("OBJECTIVES_PANEL", "Objectives", SetupObjectivesPanel) },
|
||||
{ IngameInfoPanel.Map, ("MAP_PANEL", "Briefing", SetupMapPanel) },
|
||||
{ IngameInfoPanel.LobbbyOptions, ("LOBBY_OPTIONS_PANEL", "Options", SetupLobbyOptionsPanel) },
|
||||
{ IngameInfoPanel.Debug, ("DEBUG_PANEL", "Debug", SetupDebugPanel) },
|
||||
{ IngameInfoPanel.Chat, ("CHAT_PANEL", "Chat", SetupChatPanel) }
|
||||
{ IngameInfoPanel.Objectives, ("OBJECTIVES_PANEL", Objectives, SetupObjectivesPanel) },
|
||||
{ IngameInfoPanel.Map, ("MAP_PANEL", Briefing, SetupMapPanel) },
|
||||
{ IngameInfoPanel.LobbbyOptions, ("LOBBY_OPTIONS_PANEL", Options, SetupLobbyOptionsPanel) },
|
||||
{ IngameInfoPanel.Debug, ("DEBUG_PANEL", Debug, SetupDebugPanel) },
|
||||
{ IngameInfoPanel.Chat, ("CHAT_PANEL", Chat, SetupChatPanel) }
|
||||
};
|
||||
|
||||
this.world = world;
|
||||
@@ -91,7 +106,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
if (tabButton != null)
|
||||
{
|
||||
tabButton.Text = info.Label;
|
||||
tabButton.Text = modData.Translation.GetString(info.Label);
|
||||
tabButton.OnClick = () =>
|
||||
{
|
||||
if (activePanel == IngameInfoPanel.Chat)
|
||||
|
||||
@@ -21,8 +21,17 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
readonly ContainerWidget template;
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string InProgress = "in-progress";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string Accomplished = "accomplished";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string Failed = "failed";
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public GameInfoObjectivesLogic(Widget widget, World world)
|
||||
public GameInfoObjectivesLogic(Widget widget, World world, ModData modData)
|
||||
{
|
||||
var player = world.RenderPlayer ?? world.LocalPlayer;
|
||||
|
||||
@@ -43,8 +52,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}
|
||||
|
||||
var missionStatus = widget.Get<LabelWidget>("MISSION_STATUS");
|
||||
missionStatus.GetText = () => player.WinState == WinState.Undefined ? "In progress" :
|
||||
player.WinState == WinState.Won ? "Accomplished" : "Failed";
|
||||
var inProgress = modData.Translation.GetString(InProgress);
|
||||
var accomplished = modData.Translation.GetString(Accomplished);
|
||||
var failed = modData.Translation.GetString(Failed);
|
||||
missionStatus.GetText = () => player.WinState == WinState.Undefined ? inProgress :
|
||||
player.WinState == WinState.Won ? accomplished : failed;
|
||||
missionStatus.GetColor = () => player.WinState == WinState.Undefined ? Color.White :
|
||||
player.WinState == WinState.Won ? Color.LimeGreen : Color.Red;
|
||||
|
||||
|
||||
@@ -18,8 +18,20 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
public class GameTimerLogic : ChromeLogic
|
||||
{
|
||||
[TranslationReference]
|
||||
static readonly string Paused = "paused";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string MaxSpeed = "max-speed";
|
||||
|
||||
[TranslationReference("percentage")]
|
||||
static readonly string Speed = "speed";
|
||||
|
||||
[TranslationReference("percentage")]
|
||||
static readonly string Complete = "complete";
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public GameTimerLogic(Widget widget, OrderManager orderManager, World world)
|
||||
public GameTimerLogic(Widget widget, ModData modData, OrderManager orderManager, World world)
|
||||
{
|
||||
var timer = widget.GetOrNull<LabelWidget>("GAME_TIMER");
|
||||
var status = widget.GetOrNull<LabelWidget>("GAME_TIMER_STATUS");
|
||||
@@ -31,12 +43,17 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
Func<bool> paused = () => world.Paused || world.ReplayTimestep == 0;
|
||||
|
||||
var pausedText = modData.Translation.GetString(Paused);
|
||||
var maxSpeedText = modData.Translation.GetString(MaxSpeed);
|
||||
var speedText = new CachedTransform<int, string>(p =>
|
||||
modData.Translation.GetString(Speed, Translation.Arguments("percentage", p)));
|
||||
|
||||
if (timer != null)
|
||||
{
|
||||
timer.GetText = () =>
|
||||
{
|
||||
if (status == null && paused() && shouldShowStatus())
|
||||
return "Paused";
|
||||
return pausedText;
|
||||
|
||||
var timeLimit = tlm?.TimeLimit ?? 0;
|
||||
var displayTick = timeLimit > 0 ? timeLimit - world.WorldTick : world.WorldTick;
|
||||
@@ -51,22 +68,24 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
status.GetText = () =>
|
||||
{
|
||||
if (paused())
|
||||
return "Paused";
|
||||
return pausedText;
|
||||
|
||||
if (world.ReplayTimestep == 1)
|
||||
return "Max Speed";
|
||||
return maxSpeedText;
|
||||
|
||||
return $"{world.Timestep * 100 / world.ReplayTimestep}% Speed";
|
||||
return speedText.Update(world.Timestep * 100 / world.ReplayTimestep);
|
||||
};
|
||||
}
|
||||
|
||||
var timerText = new CachedTransform<int, string>(p =>
|
||||
modData.Translation.GetString(Complete, Translation.Arguments("percentage", p)));
|
||||
if (timer is LabelWithTooltipWidget timerTooltip)
|
||||
{
|
||||
var connection = orderManager.Connection as ReplayConnection;
|
||||
if (connection != null && connection.FinalGameTick != 0)
|
||||
timerTooltip.GetTooltipText = () => $"{world.WorldTick * 100 / connection.FinalGameTick}% complete";
|
||||
timerTooltip.GetTooltipText = () => timerText.Update(world.WorldTick * 100 / connection.FinalGameTick);
|
||||
else if (connection != null && connection.TickCount != 0)
|
||||
timerTooltip.GetTooltipText = () => $"{orderManager.NetFrameNumber * 100 / connection.TickCount}% complete";
|
||||
timerTooltip.GetTooltipText = () => timerText.Update(orderManager.NetFrameNumber * 100 / connection.TickCount);
|
||||
else
|
||||
timerTooltip.GetTooltipText = null;
|
||||
}
|
||||
|
||||
@@ -23,26 +23,32 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
readonly World world;
|
||||
readonly Player player;
|
||||
readonly PlayerResources playerResources;
|
||||
readonly string cashLabel;
|
||||
readonly LabelWithTooltipWidget cashLabel;
|
||||
readonly CachedTransform<(int Resources, int Capacity), string> siloUsageTooltipCache;
|
||||
readonly string cashTemplate;
|
||||
|
||||
int nextCashTickTime = 0;
|
||||
int displayResources;
|
||||
string displayLabel;
|
||||
|
||||
string siloUsageTooltip = "";
|
||||
|
||||
[TranslationReference("resources", "capacity")]
|
||||
static readonly string SiloUsage = "silo-usage";
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public IngameCashCounterLogic(Widget widget, World world)
|
||||
public IngameCashCounterLogic(Widget widget, ModData modData, World world)
|
||||
{
|
||||
var cash = widget.Get<LabelWithTooltipWidget>("CASH");
|
||||
|
||||
this.world = world;
|
||||
player = world.LocalPlayer;
|
||||
playerResources = player.PlayerActor.Trait<PlayerResources>();
|
||||
displayResources = playerResources.Cash + playerResources.Resources;
|
||||
cashLabel = cash.Text;
|
||||
displayLabel = cashLabel.F(displayResources);
|
||||
|
||||
cash.GetText = () => displayLabel;
|
||||
cash.GetTooltipText = () => $"Silo Usage: {playerResources.Resources}/{playerResources.ResourceCapacity}";
|
||||
siloUsageTooltipCache = new CachedTransform<(int Resources, int Capacity), string>(x =>
|
||||
modData.Translation.GetString(SiloUsage, Translation.Arguments("resources", x.Resources, "capacity", x.Capacity)));
|
||||
cashLabel = widget.Get<LabelWithTooltipWidget>("CASH");
|
||||
cashLabel.GetTooltipText = () => siloUsageTooltip;
|
||||
|
||||
cashTemplate = cashLabel.Text;
|
||||
}
|
||||
|
||||
public override void Tick()
|
||||
@@ -73,7 +79,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}
|
||||
}
|
||||
|
||||
displayLabel = cashLabel.F(displayResources);
|
||||
siloUsageTooltip = siloUsageTooltipCache.Update((playerResources.Resources, playerResources.ResourceCapacity));
|
||||
cashLabel.Text = cashTemplate.F(displayResources);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,15 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
readonly bool isMenuChat;
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string Team = "team";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string All = "all";
|
||||
|
||||
[TranslationReference("seconds")]
|
||||
static readonly string ChatAvailability = "chat-availability";
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public IngameChatLogic(Widget widget, OrderManager orderManager, World world, ModData modData, bool isMenuChat, Dictionary<string, MiniYaml> logicArgs)
|
||||
{
|
||||
@@ -57,6 +66,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var disableTeamChat = alwaysDisabled || (world.LocalPlayer != null && !players.Any(p => p.IsAlliedWith(world.LocalPlayer)));
|
||||
var teamChat = !disableTeamChat;
|
||||
|
||||
var teamMessage = modData.Translation.GetString(Team);
|
||||
var allMessage = modData.Translation.GetString(All);
|
||||
|
||||
tabCompletion.Commands = chatTraits.OfType<ChatCommands>().ToArray().SelectMany(x => x.Commands.Keys);
|
||||
tabCompletion.Names = orderManager.LobbyInfo.Clients.Select(c => c.Name).Distinct().ToList();
|
||||
|
||||
@@ -81,7 +93,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
chatChrome.Visible = true;
|
||||
|
||||
var chatMode = chatChrome.Get<ButtonWidget>("CHAT_MODE");
|
||||
chatMode.GetText = () => teamChat && !disableTeamChat ? "Team" : "All";
|
||||
chatMode.GetText = () => teamChat && !disableTeamChat ? teamMessage : allMessage;
|
||||
chatMode.OnClick = () => teamChat ^= true;
|
||||
|
||||
// Enable teamchat if we are a player and die,
|
||||
@@ -171,7 +183,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
return true;
|
||||
};
|
||||
|
||||
chatDisabledLabel = new CachedTransform<int, string>(x => x > 0 ? $"Chat available in {x} seconds..." : "Chat Disabled");
|
||||
chatDisabledLabel = new CachedTransform<int, string>(x => modData.Translation.GetString(ChatAvailability, Translation.Arguments("seconds", x)));
|
||||
|
||||
if (!isMenuChat)
|
||||
{
|
||||
|
||||
@@ -17,15 +17,18 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
public class IngamePowerBarLogic : ChromeLogic
|
||||
{
|
||||
[TranslationReference]
|
||||
static readonly string PowerUsage = "power-usage";
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public IngamePowerBarLogic(Widget widget, World world)
|
||||
public IngamePowerBarLogic(Widget widget, ModData modData, World world)
|
||||
{
|
||||
var powerManager = world.LocalPlayer.PlayerActor.Trait<PowerManager>();
|
||||
var powerBar = widget.Get<ResourceBarWidget>("POWERBAR");
|
||||
|
||||
powerBar.GetProvided = () => powerManager.PowerProvided;
|
||||
powerBar.GetUsed = () => powerManager.PowerDrained;
|
||||
powerBar.TooltipFormat = "Power Usage: {0}/{1}";
|
||||
powerBar.TooltipFormat = modData.Translation.GetString(PowerUsage) + ": {0}/{1}";
|
||||
powerBar.GetBarColor = () =>
|
||||
{
|
||||
if (powerManager.PowerState == PowerState.Critical)
|
||||
|
||||
@@ -17,8 +17,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
public class IngamePowerCounterLogic : ChromeLogic
|
||||
{
|
||||
[TranslationReference]
|
||||
static readonly string PowerUsage = "power-usage";
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public IngamePowerCounterLogic(Widget widget, World world)
|
||||
public IngamePowerCounterLogic(Widget widget, ModData modData, World world)
|
||||
{
|
||||
var powerManager = world.LocalPlayer.PlayerActor.Trait<PowerManager>();
|
||||
var power = widget.Get<LabelWithTooltipWidget>("POWER");
|
||||
@@ -26,8 +29,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
powerIcon.GetImageName = () => powerManager.ExcessPower < 0 ? "power-critical" : "power-normal";
|
||||
power.GetColor = () => powerManager.ExcessPower < 0 ? Color.Red : Color.White;
|
||||
power.GetText = () => powerManager.PowerProvided == 1000000 ? "inf" : powerManager.ExcessPower.ToString();
|
||||
power.GetTooltipText = () => "Power Usage: " + powerManager.PowerDrained.ToString() +
|
||||
power.GetText = () => powerManager.PowerProvided == 1000000 ? "∞" : powerManager.ExcessPower.ToString();
|
||||
power.GetTooltipText = () => modData.Translation.GetString(PowerUsage) + ": " + powerManager.PowerDrained.ToString() +
|
||||
(powerManager.PowerProvided != 1000000 ? "/" + powerManager.PowerProvided.ToString() : "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,15 +17,18 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
public class IngameSiloBarLogic : ChromeLogic
|
||||
{
|
||||
[TranslationReference]
|
||||
static readonly string SiloUsage = "silo-usage";
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public IngameSiloBarLogic(Widget widget, World world)
|
||||
public IngameSiloBarLogic(Widget widget, ModData modData, World world)
|
||||
{
|
||||
var playerResources = world.LocalPlayer.PlayerActor.Trait<PlayerResources>();
|
||||
var siloBar = widget.Get<ResourceBarWidget>("SILOBAR");
|
||||
|
||||
siloBar.GetProvided = () => playerResources.ResourceCapacity;
|
||||
siloBar.GetUsed = () => playerResources.Resources;
|
||||
siloBar.TooltipFormat = "Silo Usage: {0}/{1}";
|
||||
siloBar.TooltipFormat = modData.Translation.GetString(SiloUsage) + ": {0}/{1}";
|
||||
siloBar.GetBarColor = () =>
|
||||
{
|
||||
if (playerResources.Resources == playerResources.ResourceCapacity)
|
||||
|
||||
@@ -35,6 +35,21 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
CameraOption selected;
|
||||
readonly LabelWidget shroudLabel;
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string CameraOptionAllPlayers = "camera-option-all-players";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string CameraOptionDisableShroud = "camera-option-disable-shroud";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string CameraOptionOther = "camera-option-other";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string Players = "players";
|
||||
|
||||
[TranslationReference("team")]
|
||||
static readonly string Team = "team-no-team";
|
||||
|
||||
class CameraOption
|
||||
{
|
||||
public readonly Player Player;
|
||||
@@ -86,10 +101,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
var groups = new Dictionary<string, IEnumerable<CameraOption>>();
|
||||
|
||||
combined = new CameraOption(this, world, "All Players", world.Players.First(p => p.InternalName == "Everyone"));
|
||||
disableShroud = new CameraOption(this, world, "Disable Shroud", null);
|
||||
combined = new CameraOption(this, world, modData.Translation.GetString(CameraOptionAllPlayers), world.Players.First(p => p.InternalName == "Everyone"));
|
||||
disableShroud = new CameraOption(this, world, modData.Translation.GetString(CameraOptionDisableShroud), null);
|
||||
if (!limitViews)
|
||||
groups.Add("Other", new List<CameraOption>() { combined, disableShroud });
|
||||
groups.Add(modData.Translation.GetString(CameraOptionOther), new List<CameraOption>() { combined, disableShroud });
|
||||
|
||||
teams = world.Players.Where(p => !p.NonCombatant && p.Playable)
|
||||
.Select(p => new CameraOption(this, p))
|
||||
@@ -101,7 +116,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
foreach (var t in teams)
|
||||
{
|
||||
totalPlayers += t.Count();
|
||||
var label = noTeams ? "Players" : t.Key == 0 ? "No Team" : $"Team {t.Key}";
|
||||
var label = noTeams ? modData.Translation.GetString(Players) : modData.Translation.GetString(Team, Translation.Arguments("team", t.Key));
|
||||
groups.Add(label, t);
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,36 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
readonly string clickSound = ChromeMetrics.Get<string>("ClickSound");
|
||||
ObserverStatsPanel activePanel;
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string InformationNone = "information-none";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string Basic = "basic";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string Economy = "economy";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string Production = "production";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string SupportPowers = "support-powers";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string Combat = "combat";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string Army = "army";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string EarningsGraph = "earnings-graph";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string ArmyGraph = "army-graph";
|
||||
|
||||
[TranslationReference("team")]
|
||||
static readonly string Team = "team-no-team";
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public ObserverStatsLogic(World world, ModData modData, WorldRenderer worldRenderer, Widget widget, Dictionary<string, MiniYaml> logicArgs)
|
||||
{
|
||||
@@ -111,6 +141,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var statsDropDown = widget.Get<DropDownButtonWidget>("STATS_DROPDOWN");
|
||||
Func<string, ObserverStatsPanel, ScrollItemWidget, Action, StatsDropDownOption> createStatsOption = (title, panel, template, a) =>
|
||||
{
|
||||
title = modData.Translation.GetString(title);
|
||||
return new StatsDropDownOption
|
||||
{
|
||||
Title = title,
|
||||
@@ -134,24 +165,25 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
new StatsDropDownOption
|
||||
{
|
||||
Title = "Information: None",
|
||||
Title = modData.Translation.GetString(InformationNone),
|
||||
IsSelected = () => activePanel == ObserverStatsPanel.None,
|
||||
OnClick = () =>
|
||||
{
|
||||
statsDropDown.GetText = () => "Information: None";
|
||||
var informationNone = modData.Translation.GetString(InformationNone);
|
||||
statsDropDown.GetText = () => informationNone;
|
||||
playerStatsPanel.Visible = false;
|
||||
ClearStats();
|
||||
activePanel = ObserverStatsPanel.None;
|
||||
}
|
||||
},
|
||||
createStatsOption("Basic", ObserverStatsPanel.Basic, basicPlayerTemplate, () => DisplayStats(BasicStats)),
|
||||
createStatsOption("Economy", ObserverStatsPanel.Economy, economyPlayerTemplate, () => DisplayStats(EconomyStats)),
|
||||
createStatsOption("Production", ObserverStatsPanel.Production, productionPlayerTemplate, () => DisplayStats(ProductionStats)),
|
||||
createStatsOption("Support Powers", ObserverStatsPanel.SupportPowers, supportPowersPlayerTemplate, () => DisplayStats(SupportPowerStats)),
|
||||
createStatsOption("Combat", ObserverStatsPanel.Combat, combatPlayerTemplate, () => DisplayStats(CombatStats)),
|
||||
createStatsOption("Army", ObserverStatsPanel.Army, armyPlayerTemplate, () => DisplayStats(ArmyStats)),
|
||||
createStatsOption("Earnings (graph)", ObserverStatsPanel.Graph, null, () => IncomeGraph()),
|
||||
createStatsOption("Army (graph)", ObserverStatsPanel.ArmyGraph, null, () => ArmyValueGraph()),
|
||||
createStatsOption(Basic, ObserverStatsPanel.Basic, basicPlayerTemplate, () => DisplayStats(BasicStats, modData)),
|
||||
createStatsOption(Economy, ObserverStatsPanel.Economy, economyPlayerTemplate, () => DisplayStats(EconomyStats, modData)),
|
||||
createStatsOption(Production, ObserverStatsPanel.Production, productionPlayerTemplate, () => DisplayStats(ProductionStats, modData)),
|
||||
createStatsOption(SupportPowers, ObserverStatsPanel.SupportPowers, supportPowersPlayerTemplate, () => DisplayStats(SupportPowerStats, modData)),
|
||||
createStatsOption(Combat, ObserverStatsPanel.Combat, combatPlayerTemplate, () => DisplayStats(CombatStats, modData)),
|
||||
createStatsOption(Army, ObserverStatsPanel.Army, armyPlayerTemplate, () => DisplayStats(ArmyStats, modData)),
|
||||
createStatsOption(EarningsGraph, ObserverStatsPanel.Graph, null, () => IncomeGraph()),
|
||||
createStatsOption(ArmyGraph, ObserverStatsPanel.ArmyGraph, null, () => ArmyValueGraph()),
|
||||
};
|
||||
|
||||
Func<StatsDropDownOption, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) =>
|
||||
@@ -230,7 +262,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
(p.PlayerActor.TraitOrDefault<PlayerStatistics>() ?? new PlayerStatistics(p.PlayerActor)).ArmySamples.Select(s => (float)s)));
|
||||
}
|
||||
|
||||
void DisplayStats(Func<Player, ScrollItemWidget> createItem)
|
||||
void DisplayStats(Func<Player, ScrollItemWidget> createItem, ModData modData)
|
||||
{
|
||||
foreach (var team in teams)
|
||||
{
|
||||
@@ -240,7 +272,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
tt.IgnoreMouseOver = true;
|
||||
|
||||
var teamLabel = tt.Get<LabelWidget>("TEAM");
|
||||
var teamText = team.Key == 0 ? "No Team" : "Team " + team.Key;
|
||||
var teamText = modData.Translation.GetString(Team, Translation.Arguments("team-no-team", team.Key));
|
||||
teamLabel.GetText = () => teamText;
|
||||
tt.Bounds.Width = teamLabel.Bounds.Width = Game.Renderer.Fonts[tt.Font].Measure(tt.Get<LabelWidget>("TEAM").GetText()).X;
|
||||
|
||||
|
||||
@@ -18,8 +18,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
public class WorldTooltipLogic : ChromeLogic
|
||||
{
|
||||
[TranslationReference]
|
||||
static readonly string UnrevealedTerrain = "unrevealed-terrain";
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public WorldTooltipLogic(Widget widget, World world, TooltipContainerWidget tooltipContainer, ViewportControllerWidget viewport)
|
||||
public WorldTooltipLogic(Widget widget, ModData modData, World world, TooltipContainerWidget tooltipContainer, ViewportControllerWidget viewport)
|
||||
{
|
||||
widget.IsVisible = () => viewport.TooltipType != WorldTooltipType.None;
|
||||
var label = widget.Get<LabelWidget>("LABEL");
|
||||
@@ -54,7 +57,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
switch (viewport.TooltipType)
|
||||
{
|
||||
case WorldTooltipType.Unexplored:
|
||||
labelText = "Unrevealed Terrain";
|
||||
labelText = modData.Translation.GetString(UnrevealedTerrain);
|
||||
break;
|
||||
case WorldTooltipType.Resource:
|
||||
labelText = viewport.ResourceTooltip;
|
||||
|
||||
Reference in New Issue
Block a user