Fix build tab selection
This commit is contained in:
@@ -30,18 +30,27 @@ namespace OpenRA.Mods.RA.Widgets
|
|||||||
|
|
||||||
public void SelectionChanged()
|
public void SelectionChanged()
|
||||||
{
|
{
|
||||||
var firstItem = world.Selection.Actors.FirstOrDefault(
|
// Queue-per-structure
|
||||||
a => a.World.LocalPlayer == a.Owner && a.HasTrait<Production>());
|
var perqueue = world.Selection.Actors.FirstOrDefault(
|
||||||
|
a => a.World.LocalPlayer == a.Owner && a.HasTrait<ProductionQueue>());
|
||||||
if (firstItem == null)
|
|
||||||
|
if (perqueue != null)
|
||||||
|
{
|
||||||
|
Widget.RootWidget.GetWidget<BuildPaletteWidget>("INGAME_BUILD_PALETTE")
|
||||||
|
.SetCurrentTab(perqueue.TraitsImplementing<ProductionQueue>().First());
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Queue-per-player
|
||||||
|
var types = world.Selection.Actors.SelectMany(a => a.TraitsImplementing<Production>())
|
||||||
|
.SelectMany(t => t.Info.Produces)
|
||||||
|
.Distinct();
|
||||||
|
|
||||||
|
if (types.Count() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
var produces = firstItem.Info.Traits.Get<ProductionInfo>().Produces.FirstOrDefault();
|
Widget.RootWidget.GetWidget<BuildPaletteWidget>("INGAME_BUILD_PALETTE")
|
||||||
if (produces == null)
|
.SetCurrentTab(world.LocalPlayer.PlayerActor.TraitsImplementing<ProductionQueue>().FirstOrDefault(t => types.Contains(t.Info.Type)));
|
||||||
return;
|
|
||||||
|
|
||||||
//Widget.RootWidget.GetWidget<BuildPaletteWidget>("INGAME_BUILD_PALETTE")
|
|
||||||
// .SetCurrentTab(produces);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user