From 820fdb35cbdcdd032302c4a5c4c9b22213c41d05 Mon Sep 17 00:00:00 2001 From: "N.N" Date: Tue, 11 Jun 2024 15:06:57 +0200 Subject: [PATCH] Fix tab available on low money --- OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs | 13 +++++++++++++ .../Traits/ProductionQueueFromSelection.cs | 2 +- .../Widgets/Logic/Ingame/ClassicProductionLogic.cs | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs b/OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs index d5c55ccccebc..d3d273d78bdd 100644 --- a/OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs +++ b/OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs @@ -319,6 +319,19 @@ public virtual IEnumerable BuildableItems() return buildableProducibles; } + public virtual bool AnyItemsToBuild() + { + if (productionTraits.Length > 0 && productionTraits.All(p => p.IsTraitDisabled)) + return false; + if (!Enabled) + return false; + if (developerMode.AllTech && Producible.Keys.Count != 0) + return true; + if (buildableProducibles.Any()) + return true; + return false; + } + public bool CanBuild(ActorInfo actor) { if (!Producible.TryGetValue(actor, out var ps)) diff --git a/OpenRA.Mods.Common/Traits/ProductionQueueFromSelection.cs b/OpenRA.Mods.Common/Traits/ProductionQueueFromSelection.cs index 1c86547be483..c00b85e574a0 100644 --- a/OpenRA.Mods.Common/Traits/ProductionQueueFromSelection.cs +++ b/OpenRA.Mods.Common/Traits/ProductionQueueFromSelection.cs @@ -63,7 +63,7 @@ void INotifySelection.SelectionChanged() .FirstOrDefault(q => q.Enabled && types.Contains(q.Info.Type)); } - if (queue == null || !queue.BuildableItems().Any()) + if (queue == null || !queue.AnyItemsToBuild()) return; if (tabsWidget.Value != null) diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ClassicProductionLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ClassicProductionLogic.cs index b09ce9ded800..f7538b38c6a0 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ClassicProductionLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ClassicProductionLogic.cs @@ -42,7 +42,7 @@ void SelectTab(bool reverse) palette.PickUpCompletedBuilding(); } - button.IsDisabled = () => !queues.Any(q => q.BuildableItems().Any()); + button.IsDisabled = () => !queues.Any(q => q.AnyItemsToBuild()); button.OnMouseUp = mi => SelectTab(mi.Modifiers.HasModifier(Modifiers.Shift)); button.OnKeyPress = e => SelectTab(e.Modifiers.HasModifier(Modifiers.Shift)); button.OnClick = () => SelectTab(false);