choose build palette on select production building

This commit is contained in:
Chris Forbes
2010-02-08 20:33:41 +13:00
parent 0fbabfc3aa
commit 671c1707e7
4 changed files with 37 additions and 0 deletions

View File

@@ -1191,5 +1191,13 @@ namespace OpenRa
renderer.DrawText(sp.Info.LongDesc.Replace("\\n", "\n"), pos, Color.White);
}
}
public void SetCurrentTab(string produces)
{
if (!paletteOpen)
paletteAnimating = true;
paletteOpen = true;
currentTab = produces;
}
}
}

View File

@@ -118,6 +118,7 @@
<Compile Include="Support\OpenAlInterop.cs" />
<Compile Include="Support\PerfHistory.cs" />
<Compile Include="Sync.cs" />
<Compile Include="Traits\ChoosePaletteOnSelect.cs" />
<Compile Include="Traits\CrateSpawner.cs" />
<Compile Include="Traits\OreGrowth.cs" />
<Compile Include="Traits\OreRefinery.cs" />

View File

@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OpenRa.Traits
{
class ChoosePaletteOnSelectInfo : StatelessTraitInfo<ChoosePaletteOnSelect> { }
class ChoosePaletteOnSelect : INotifySelection
{
public void SelectionChanged()
{
var firstItem = Game.controller.selection.Actors.FirstOrDefault(
a => a.World.LocalPlayer == a.Owner && a.traits.Contains<Production>());
if (firstItem == null)
return;
var produces = firstItem.Info.Traits.Get<ProductionInfo>().Produces.FirstOrDefault();
if (produces == null)
return;
Game.chrome.SetCurrentTab(produces);
}
}
}

View File

@@ -71,6 +71,7 @@ World:
LightPaletteRotator:
BuildingInfluence:
UnitInfluence:
ChoosePaletteOnSelect:
PaletteFromFile@terrain_temperat:
Name: terrain
Filename: temperat.pal