#1241 fixed - crash in ChooseBuildTabOnSelect.SelectionChanged

This commit is contained in:
Chris Forbes
2011-11-04 19:03:38 +13:00
parent 192cbaf744
commit bc5efa3fc5

View File

@@ -31,14 +31,17 @@ namespace OpenRA.Mods.RA
public void SelectionChanged()
{
var palette = Widget.RootWidget.GetWidget<BuildPaletteWidget>("INGAME_BUILD_PALETTE");
if (palette == null)
return;
// Queue-per-structure
var perqueue = world.Selection.Actors.FirstOrDefault(
a => a.IsInWorld && a.World.LocalPlayer == a.Owner && a.HasTrait<ProductionQueue>());
if (perqueue != null)
{
Widget.RootWidget.GetWidget<BuildPaletteWidget>("INGAME_BUILD_PALETTE")
.SetCurrentTab(perqueue.TraitsImplementing<ProductionQueue>().First());
palette.SetCurrentTab(perqueue.TraitsImplementing<ProductionQueue>().First());
return;
}
@@ -51,9 +54,8 @@ namespace OpenRA.Mods.RA
if (types.Length == 0)
return;
Widget.RootWidget.GetWidget<BuildPaletteWidget>("INGAME_BUILD_PALETTE")
.SetCurrentTab(world.LocalPlayer.PlayerActor.TraitsImplementing<ProductionQueue>()
.FirstOrDefault(t => types.Contains(t.Info.Type)));
palette.SetCurrentTab(world.LocalPlayer.PlayerActor.TraitsImplementing<ProductionQueue>()
.FirstOrDefault(t => types.Contains(t.Info.Type)));
}
}
}