configurable and self-documenting BuildPaletteWidgetName

This commit is contained in:
Matthias Mailänder
2014-07-20 13:54:29 +02:00
parent 1f7b6f431a
commit ea478e8e7f

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2014 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,
@@ -17,21 +17,25 @@ namespace OpenRA.Mods.RA
{
class ChooseBuildTabOnSelectInfo : ITraitInfo
{
public object Create(ActorInitializer init) { return new ChooseBuildTabOnSelect(init); }
public readonly string BuildPaletteWidgetName = "INGAME_BUILD_PALETTE";
public object Create(ActorInitializer init) { return new ChooseBuildTabOnSelect(init, this); }
}
class ChooseBuildTabOnSelect : INotifySelection
{
readonly World world;
readonly ChooseBuildTabOnSelectInfo info;
public ChooseBuildTabOnSelect(ActorInitializer init)
public ChooseBuildTabOnSelect(ActorInitializer init, ChooseBuildTabOnSelectInfo info)
{
world = init.world;
this.info = info;
}
public void SelectionChanged()
{
var palette = Ui.Root.GetOrNull<BuildPaletteWidget>("INGAME_BUILD_PALETTE");
var palette = Ui.Root.GetOrNull<BuildPaletteWidget>(info.BuildPaletteWidgetName);
if (palette == null)
return;