Skip to content

Commit

Permalink
Fix tab available on low money
Browse files Browse the repository at this point in the history
  • Loading branch information
Porenutak committed Jun 11, 2024
1 parent fa6f1d6 commit 820fdb3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,19 @@ public virtual IEnumerable<ActorInfo> 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))
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Mods.Common/Traits/ProductionQueueFromSelection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 820fdb3

Please sign in to comment.