ColorButtonWidget
This commit is contained in:
@@ -309,6 +309,7 @@
|
||||
<Compile Include="Widgets\BuildPaletteWidget.cs" />
|
||||
<Compile Include="Traits\World\BridgeLayer.cs" />
|
||||
<Compile Include="Widgets\Delegates\LobbyDelegate.cs" />
|
||||
<Compile Include="Widgets\ColorButtonWidget.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||
|
||||
54
OpenRA.Game/Widgets/ColorButtonWidget.cs
Normal file
54
OpenRA.Game/Widgets/ColorButtonWidget.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
namespace OpenRA.Widgets
|
||||
{
|
||||
class ColorButtonWidget : ButtonWidget
|
||||
{
|
||||
public int PaletteIndex = 0;
|
||||
public Func<int> GetPaletteIndex;
|
||||
|
||||
public ColorButtonWidget()
|
||||
: base()
|
||||
{
|
||||
GetPaletteIndex = () => { return PaletteIndex; };
|
||||
}
|
||||
|
||||
public ColorButtonWidget(Widget widget)
|
||||
:base(widget)
|
||||
{
|
||||
PaletteIndex = (widget as ColorButtonWidget).PaletteIndex;
|
||||
GetPaletteIndex = (widget as ColorButtonWidget).GetPaletteIndex;
|
||||
}
|
||||
|
||||
public override Widget Clone()
|
||||
{
|
||||
return new ColorButtonWidget(this);
|
||||
}
|
||||
|
||||
public override void Draw(World world)
|
||||
{
|
||||
if (!IsVisible())
|
||||
{
|
||||
base.Draw(world);
|
||||
return;
|
||||
}
|
||||
|
||||
DrawColorBlock();
|
||||
|
||||
base.Draw(world);
|
||||
}
|
||||
|
||||
void DrawColorBlock()
|
||||
{
|
||||
var pos = DrawPosition();
|
||||
var paletteRect = new Rectangle(pos.X ,pos.Y + 2 , 65, 22);
|
||||
Game.chrome.lineRenderer.FillRect(RectangleF.FromLTRB(paletteRect.Left + Game.viewport.Location.X + 5,
|
||||
paletteRect.Top + Game.viewport.Location.Y + 5,
|
||||
paletteRect.Right + Game.viewport.Location.X - 5,
|
||||
paletteRect.Bottom+Game.viewport.Location.Y - 5),
|
||||
Player.PlayerColors(Game.world)[GetPaletteIndex() % Player.PlayerColors(Game.world).Count].c);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,9 +48,9 @@ namespace OpenRA.Widgets.Delegates
|
||||
if(client.Index == Game.LocalClient.Index)
|
||||
{
|
||||
//TODO: Real Color Button
|
||||
var color = template.GetWidget<ButtonWidget>("COLOR");
|
||||
var color = template.GetWidget<ColorButtonWidget>("COLOR");
|
||||
color.OnMouseUp = CyclePalette;
|
||||
color.GetText = () => c.PaletteIndex.ToString();
|
||||
color.GetPaletteIndex = () => c.PaletteIndex;
|
||||
|
||||
var faction = template.GetWidget<ButtonWidget>("FACTION");
|
||||
faction.OnMouseUp = CycleRace;
|
||||
|
||||
@@ -310,13 +310,13 @@ Container:
|
||||
Height:25
|
||||
X:0
|
||||
Y:5
|
||||
Button@COLOR:
|
||||
ColorButton@COLOR:
|
||||
Id:COLOR
|
||||
Text:Color
|
||||
Width:65
|
||||
Height:25
|
||||
X:100
|
||||
Y:0
|
||||
PaletteIndex:0
|
||||
Button@FACTION:
|
||||
Id:FACTION
|
||||
Text:Faction
|
||||
|
||||
Reference in New Issue
Block a user