Custom button widget for new sidebar

This commit is contained in:
Paul Chote
2011-03-08 23:19:15 +13:00
parent 19b2e3e521
commit 631630fbff
2 changed files with 46 additions and 0 deletions

View File

@@ -328,6 +328,7 @@
<Compile Include="Widgets\Delegates\GameInitDelegate.cs" />
<Compile Include="AttackWander.cs" />
<Compile Include="ScaredyCat.cs" />
<Compile Include="Widgets\SidebarButtonWidget.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">

View File

@@ -0,0 +1,45 @@
#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;
using System.Drawing;
using OpenRA.Graphics;
using OpenRA.Widgets;
namespace OpenRA.Mods.RA
{
public class SidebarButtonWidget : ButtonWidget
{
public string Image = "";
readonly World world;
[ObjectCreator.UseCtor]
public SidebarButtonWidget( [ObjectCreator.Param] World world )
: base()
{
this.world = world;
}
protected SidebarButtonWidget(SidebarButtonWidget widget)
: base(widget)
{
this.world = widget.world;
}
public override void DrawInner()
{
var state = Depressed ? "pressed" :
RenderBounds.Contains(Viewport.LastMousePos) ? "hover" : "normal";
WidgetUtils.DrawRGBA(ChromeProvider.GetImage(Image + "-" + world.LocalPlayer.Country.Race, state), RenderOrigin);
}
}
}