Reimplement production queue switching from selection.
This commit is contained in:
@@ -94,6 +94,7 @@
|
|||||||
<Compile Include="Widgets\SiloBarWidget.cs" />
|
<Compile Include="Widgets\SiloBarWidget.cs" />
|
||||||
<Compile Include="Widgets\ProductionTabsWidget.cs" />
|
<Compile Include="Widgets\ProductionTabsWidget.cs" />
|
||||||
<Compile Include="Widgets\ProductionPaletteWidget.cs" />
|
<Compile Include="Widgets\ProductionPaletteWidget.cs" />
|
||||||
|
<Compile Include="ProductionQueueFromSelection.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||||
|
|||||||
46
OpenRA.Mods.Cnc/ProductionQueueFromSelection.cs
Normal file
46
OpenRA.Mods.Cnc/ProductionQueueFromSelection.cs
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||||
|
* This file is part of OpenRA, which is free software. It is made
|
||||||
|
* available to you under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation. For more information,
|
||||||
|
* see COPYING.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
using OpenRA.Widgets;
|
||||||
|
using OpenRA.Mods.Cnc.Widgets;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.RA.Widgets
|
||||||
|
{
|
||||||
|
class ProductionQueueFromSelectionInfo : ITraitInfo
|
||||||
|
{
|
||||||
|
public string ProductionTabsWidget = null;
|
||||||
|
public object Create( ActorInitializer init ) { return new ProductionQueueFromSelection(init.world, this); }
|
||||||
|
}
|
||||||
|
|
||||||
|
class ProductionQueueFromSelection : INotifySelection
|
||||||
|
{
|
||||||
|
ProductionQueueFromSelectionInfo info;
|
||||||
|
readonly World world;
|
||||||
|
|
||||||
|
public ProductionQueueFromSelection(World world, ProductionQueueFromSelectionInfo info)
|
||||||
|
{
|
||||||
|
this.world = world;
|
||||||
|
this.info = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SelectionChanged()
|
||||||
|
{
|
||||||
|
// Find an actor with a queue
|
||||||
|
var producer = world.Selection.Actors.FirstOrDefault(a => a.IsInWorld
|
||||||
|
&& a.World.LocalPlayer == a.Owner
|
||||||
|
&& a.HasTrait<ProductionQueue>());
|
||||||
|
if (producer != null)
|
||||||
|
Widget.RootWidget.GetWidget<ProductionTabsWidget>(info.ProductionTabsWidget)
|
||||||
|
.SelectQueue(producer.TraitsImplementing<ProductionQueue>().First());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -212,5 +212,12 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
|
|
||||||
return (leftPressed || rightPressed);
|
return (leftPressed || rightPressed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SelectQueue(ProductionQueue queue)
|
||||||
|
{
|
||||||
|
QueueType = queue.Info.Group;
|
||||||
|
Widget.RootWidget.GetWidget<ProductionPaletteWidget>(PaletteWidget)
|
||||||
|
.CurrentQueue = queue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,8 @@ World:
|
|||||||
Country@nod:
|
Country@nod:
|
||||||
Name: Nod
|
Name: Nod
|
||||||
Race: nod
|
Race: nod
|
||||||
# ChooseBuildTabOnSelect:
|
ProductionQueueFromSelection:
|
||||||
|
ProductionTabsWidget: PRODUCTION_TABS
|
||||||
BibLayer:
|
BibLayer:
|
||||||
ResourceLayer:
|
ResourceLayer:
|
||||||
ResourceType@green-tib:
|
ResourceType@green-tib:
|
||||||
|
|||||||
Reference in New Issue
Block a user