From feef5be143cc83c0eb99c72557f8379ec4c98a93 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Wed, 30 Oct 2024 18:27:19 +0000 Subject: [PATCH] Allow mods to override Encyclopedia preview owners. --- OpenRA.Mods.Common/Traits/Encyclopedia.cs | 3 +++ OpenRA.Mods.Common/Widgets/Logic/EncyclopediaLogic.cs | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Traits/Encyclopedia.cs b/OpenRA.Mods.Common/Traits/Encyclopedia.cs index 17a0d6d53b..6ef50adfe7 100644 --- a/OpenRA.Mods.Common/Traits/Encyclopedia.cs +++ b/OpenRA.Mods.Common/Traits/Encyclopedia.cs @@ -28,6 +28,9 @@ namespace OpenRA.Mods.Common.Traits [Desc("Scale the actor preview.")] public readonly float Scale = 1f; + [Desc("Sets the player color of the actor preview to a player defined in the shellmap.")] + public readonly string PreviewOwner = null; + [Desc("Ignore the Buildable trait when listing information.")] public readonly bool HideBuildable = false; diff --git a/OpenRA.Mods.Common/Widgets/Logic/EncyclopediaLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/EncyclopediaLogic.cs index 6b52cc2500..eb4e9547ad 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/EncyclopediaLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/EncyclopediaLogic.cs @@ -162,9 +162,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic var selectedInfo = info[actor]; selectedActor = actor; + Player previewOwner = null; + if (!string.IsNullOrEmpty(selectedInfo.PreviewOwner)) + previewOwner = world.Players.FirstOrDefault(p => p.InternalName == selectedInfo.PreviewOwner); + var typeDictionary = new TypeDictionary() { - new OwnerInit(world.WorldActor.Owner), + new OwnerInit(previewOwner ?? world.WorldActor.Owner), new FactionInit(world.WorldActor.Owner.PlayerReference.Faction) };