From 806f0fd270d9216cb5eb273d9b3cb96db7f0dcf8 Mon Sep 17 00:00:00 2001 From: Ivaylo Draganov Date: Fri, 27 Sep 2024 16:56:40 +0300 Subject: [PATCH] Fix being able to click through some areas of the production palette in RA The production palette in RA is assembled from a foreground and a background. The foreground provides most of the visible graphics (such as the metallic chrome) but it has to let clicks go through to the production icons. The background is the one that has to stop the clicks then but it was not wide enough (because the art is only for the background behind production icons and not the whole chrome). Trying to fix that by wrapping the image in wider container that has `ClickThrough` set to `false` revealed that there is a bug with the cloning logic for `ContainerWidget`. It simply did not copy the `ClickThrough` field and it was always `true` for cloned widgets. So the value in YAML was lost when the template was cloned. --- OpenRA.Game/Widgets/Widget.cs | 6 +++++- mods/ra/chrome/ingame-player.yaml | 16 ++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/OpenRA.Game/Widgets/Widget.cs b/OpenRA.Game/Widgets/Widget.cs index 35b9f2eca9..c57bf2b1be 100644 --- a/OpenRA.Game/Widgets/Widget.cs +++ b/OpenRA.Game/Widgets/Widget.cs @@ -626,7 +626,11 @@ namespace OpenRA.Widgets public ContainerWidget() { IgnoreMouseOver = true; } public ContainerWidget(ContainerWidget other) - : base(other) { IgnoreMouseOver = true; } + : base(other) + { + ClickThrough = other.ClickThrough; + IgnoreMouseOver = true; + } public override string GetCursor(int2 pos) { return null; } public override Widget Clone() { return new ContainerWidget(this); } diff --git a/mods/ra/chrome/ingame-player.yaml b/mods/ra/chrome/ingame-player.yaml index f1eb04995f..6377c35677 100644 --- a/mods/ra/chrome/ingame-player.yaml +++ b/mods/ra/chrome/ingame-player.yaml @@ -431,14 +431,18 @@ Container@PLAYER_WIDGETS: Children: Container@PALETTE_BACKGROUND: Children: - Image@ROW_TEMPLATE: - Logic: AddFactionSuffixLogic - X: 40 - Width: 190 + Container@ROW_TEMPLATE: + Width: 238 Height: 47 ClickThrough: false - ImageCollection: sidebar - ImageName: background-iconbg + Children: + Image@ROW_BGND: + Logic: AddFactionSuffixLogic + X: 40 + Width: 190 + Height: 47 + ImageCollection: sidebar + ImageName: background-iconbg Image@BOTTOM_CAP: Logic: AddFactionSuffixLogic Width: 238