diff --git a/OpenRA.Mods.Common/EditorBrushes/EditorMarkerLayerBrush.cs b/OpenRA.Mods.Common/EditorBrushes/EditorMarkerLayerBrush.cs index df59813646..26eebf8363 100644 --- a/OpenRA.Mods.Common/EditorBrushes/EditorMarkerLayerBrush.cs +++ b/OpenRA.Mods.Common/EditorBrushes/EditorMarkerLayerBrush.cs @@ -163,9 +163,13 @@ namespace OpenRA.Mods.Common.Widgets this.paintTiles = paintTiles; this.markerLayerOverlay = markerLayerOverlay; - Text = type != null - ? FluentProvider.GetMessage(AddedMarkerTiles, "count", paintTiles.Length, "type", type) - : FluentProvider.GetMessage(RemovedMarkerTiles, "count", paintTiles.Length); + if (type != null) + { + var typeLabel = FluentProvider.GetMessage(markerLayerOverlay.Info.Colors.ElementAt(type.Value).Key); + Text = FluentProvider.GetMessage(AddedMarkerTiles, "count", paintTiles.Length, "type", typeLabel); + } + else + Text = FluentProvider.GetMessage(RemovedMarkerTiles, "count", paintTiles.Length); } public void Execute() { } @@ -202,7 +206,8 @@ namespace OpenRA.Mods.Common.Widgets this.markerLayerOverlay = markerLayerOverlay; tiles = markerLayerOverlay.Tiles[tile].ToImmutableArray(); - Text = FluentProvider.GetMessage(ClearedSelectedMarkerTiles, "count", tiles.Length, "type", tile); + var typeLabel = FluentProvider.GetMessage(markerLayerOverlay.Info.Colors.ElementAt(tile).Key); + Text = FluentProvider.GetMessage(ClearedSelectedMarkerTiles, "count", tiles.Length, "type", typeLabel); } public void Execute() diff --git a/OpenRA.Mods.Common/Traits/World/MarkerLayerOverlay.cs b/OpenRA.Mods.Common/Traits/World/MarkerLayerOverlay.cs index 60c8a3a30e..16c56f21af 100644 --- a/OpenRA.Mods.Common/Traits/World/MarkerLayerOverlay.cs +++ b/OpenRA.Mods.Common/Traits/World/MarkerLayerOverlay.cs @@ -31,18 +31,19 @@ namespace OpenRA.Mods.Common.Traits [Desc("The widget tree to open when the tool is selected.")] public readonly string PanelWidget = "MARKER_TOOL_PANEL"; + [FluentReference(LintDictionaryReference.Keys)] [Desc("A list of colors to be used for drawing.")] - public readonly Color[] Colors = - [ - Color.FromArgb(255, 0, 0), - Color.FromArgb(255, 127, 0), - Color.FromArgb(255, 238, 70), - Color.FromArgb(0, 255, 33), - Color.FromArgb(0, 255, 255), - Color.FromArgb(0, 42, 255), - Color.FromArgb(165, 0, 255), - Color.FromArgb(255, 0, 220), - ]; + public readonly Dictionary Colors = new() + { + { "notification-added-marker-tiles-markers.red", Color.FromArgb(255, 0, 0) }, + { "notification-added-marker-tiles-markers.orange", Color.FromArgb(255, 127, 0) }, + { "notification-added-marker-tiles-markers.yellow", Color.FromArgb(255, 238, 70) }, + { "notification-added-marker-tiles-markers.green", Color.FromArgb(0, 255, 33) }, + { "notification-added-marker-tiles-markers.cyan", Color.FromArgb(0, 255, 255) }, + { "notification-added-marker-tiles-markers.blue", Color.FromArgb(0, 42, 255) }, + { "notification-added-marker-tiles-markers.purple", Color.FromArgb(165, 0, 255) }, + { "notification-added-marker-tiles-markers.magenta", Color.FromArgb(255, 0, 220) } + }; [Desc("Default alpha blend.")] public readonly int Alpha = 85; @@ -139,7 +140,7 @@ namespace OpenRA.Mods.Common.Traits PanelWidget = info.PanelWidget; tileAlpha = info.Alpha; - alphaBlendColors = new Color[info.Colors.Length]; + alphaBlendColors = new Color[info.Colors.Count]; UpdateTileAlpha(); CellLayer = new CellLayer(map); @@ -184,8 +185,8 @@ namespace OpenRA.Mods.Common.Traits void UpdateTileAlpha() { - for (var i = 0; i < Info.Colors.Length; i++) - alphaBlendColors[i] = Color.FromArgb(tileAlpha, Info.Colors[i]); + for (var i = 0; i < Info.Colors.Count; i++) + alphaBlendColors[i] = Color.FromArgb(tileAlpha, Info.Colors.ElementAt(i).Value); } public void ClearSelected(int tileType) diff --git a/OpenRA.Mods.Common/UpdateRules/Rules/20250330/EditorMarkerTileLabels.cs b/OpenRA.Mods.Common/UpdateRules/Rules/20250330/EditorMarkerTileLabels.cs new file mode 100644 index 0000000000..699232362a --- /dev/null +++ b/OpenRA.Mods.Common/UpdateRules/Rules/20250330/EditorMarkerTileLabels.cs @@ -0,0 +1,44 @@ +#region Copyright & License Information +/* + * Copyright (c) The OpenRA Developers and Contributors + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. For more + * information, see COPYING. + */ +#endregion + +using System.Collections.Generic; +using OpenRA.Primitives; + +namespace OpenRA.Mods.Common.UpdateRules.Rules +{ + /// + /// Adds color names to the editor history list. + /// + public class EditorMarkerTileLabels : UpdateRule, IBeforeUpdateActors + { + public override string Name => "Add labels to MarkerLayerOverlay colors."; + public override string Description => "Adds color names to the editor history list."; + + public override IEnumerable UpdateActorNode(ModData modData, MiniYamlNodeBuilder actorNode) + { + foreach (var layerNode in actorNode.ChildrenMatching("MarkerLayerOverlay")) + { + foreach (var colorsNode in layerNode.ChildrenMatching("Colors")) + { + var colors = FieldLoader.GetValue("Colors", colorsNode.Value.Value); + colorsNode.Value.Value = null; + foreach (var color in colors) + { + var c = FieldSaver.FormatValue(color); + colorsNode.AddNode("notification-added-marker-tiles-markers." + c, c); + } + } + } + + yield break; + } + } +} diff --git a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs index 6ca5356007..76a1b3a3ca 100644 --- a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs +++ b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs @@ -71,6 +71,7 @@ namespace OpenRA.Mods.Common.UpdateRules // bleed only changes here. new ReplaceBaseAttackNotifier(), new RemoveBuildingInfoAllowPlacementOnResources(), + new EditorMarkerTileLabels(), ]), ]; diff --git a/OpenRA.Mods.Common/Widgets/Logic/Editor/MapMarkerTilesLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Editor/MapMarkerTilesLogic.cs index ae2f626345..55fede4746 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Editor/MapMarkerTilesLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Editor/MapMarkerTilesLogic.cs @@ -71,7 +71,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic tileColorPanel.RemoveChildren(); var colors = markerLayerTrait.Info.Colors; - for (var colorIndex = 0; colorIndex < colors.Length; colorIndex++) + for (var colorIndex = 0; colorIndex < colors.Count; colorIndex++) { var scrollItem = SetupColorSwatchItem(colorIndex, colorSwatchTemplate); tileColorPanel.AddChild(scrollItem); @@ -92,8 +92,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic editor.SetBrush(new EditorMarkerLayerBrush(editor, index, worldRenderer)); }); - var colorWidget = item.Get("TILE_PREVIEW"); - colorWidget.GetColor = () => colors[index]; + var color = colors.ElementAt(index).Value; + item.Get("TILE_PREVIEW").GetColor = () => color; return item; } diff --git a/mods/common/fluent/common.ftl b/mods/common/fluent/common.ftl index c3c764dd16..013c86f360 100644 --- a/mods/common/fluent/common.ftl +++ b/mods/common/fluent/common.ftl @@ -809,17 +809,30 @@ notification-added-tile = Added tile { $id } notification-filled-tile = Filled with tile { $id } ## EditorMarkerLayerBrush +notification-added-marker-tiles-markers = + .red = red + .orange = orange + .yellow = yellow + .green = green + .cyan = cyan + .blue = blue + .purple = purple + .magenta = magenta notification-added-marker-tiles = { $count -> - [one] Added one marker tile of type { $type } - *[other] Added { $count } marker tiles of type { $type } + [one] Added { $type } marker tile + *[other] Added { $count } { $type } marker tiles } notification-removed-marker-tiles = { $count -> - [one] Removed one marker tile + [one] Removed marker tile *[other] Removed { $count } marker tiles } -notification-cleared-selected-marker-tiles = Cleared { $count } marker tiles of type { $type } +notification-cleared-selected-marker-tiles = + { $count -> + [one] Cleared { $type } marker tile + *[other] Cleared { $count } { $type } marker tiles + } notification-cleared-all-marker-tiles = Cleared { $count } marker tiles ## EditorActionManager