more chrome
This commit is contained in:
@@ -8,8 +8,6 @@ using System.Linq;
|
||||
|
||||
namespace OpenRa.Game
|
||||
{
|
||||
using GRegion = OpenRa.Game.Graphics.Region;
|
||||
|
||||
class Sidebar
|
||||
{
|
||||
Player player;
|
||||
@@ -19,7 +17,6 @@ namespace OpenRa.Game
|
||||
Sprite blank;
|
||||
Animation ready;
|
||||
Animation cantBuild;
|
||||
readonly GRegion region;
|
||||
public float Width { get { return spriteWidth * 2; } }
|
||||
|
||||
Dictionary<string, Sprite> sprites = new Dictionary<string,Sprite>();
|
||||
@@ -33,30 +30,30 @@ namespace OpenRa.Game
|
||||
|
||||
public Sidebar( Renderer renderer, Player player )
|
||||
{
|
||||
this.player = player;
|
||||
this.renderer = renderer;
|
||||
region = GRegion.Create(Game.viewport, DockStyle.Right, /*128*/0, Paint, MouseHandler);
|
||||
region.UseScissor = false;
|
||||
region.AlwaysWantMovement = true;
|
||||
Game.viewport.AddRegion( region );
|
||||
spriteRenderer = new SpriteRenderer(renderer, false);
|
||||
clockRenderer = new SpriteRenderer(renderer, true);
|
||||
//this.player = player;
|
||||
//this.renderer = renderer;
|
||||
//region = GRegion.Create(Game.viewport, DockStyle.Right, /*128*/0, Paint, MouseHandler);
|
||||
//region.UseScissor = false;
|
||||
//region.AlwaysWantMovement = true;
|
||||
//Game.viewport.AddRegion( region );
|
||||
//spriteRenderer = new SpriteRenderer(renderer, false);
|
||||
//clockRenderer = new SpriteRenderer(renderer, true);
|
||||
|
||||
for( int i = 0 ; i < groups.Length ; i++ )
|
||||
LoadSprites( groups[ i ] );
|
||||
//for( int i = 0 ; i < groups.Length ; i++ )
|
||||
// LoadSprites( groups[ i ] );
|
||||
|
||||
foreach (string group in groups)
|
||||
{
|
||||
clockAnimations.Add( group, new Animation( "clock" ) );
|
||||
clockAnimations[ group ].PlayFetchIndex( "idle", ClockAnimFrame( group ) );
|
||||
}
|
||||
//foreach (string group in groups)
|
||||
//{
|
||||
// clockAnimations.Add( group, new Animation( "clock" ) );
|
||||
// clockAnimations[ group ].PlayFetchIndex( "idle", ClockAnimFrame( group ) );
|
||||
//}
|
||||
|
||||
blank = SheetBuilder.Add(new Size((int)spriteWidth, (int)spriteHeight), 16);
|
||||
ready = new Animation("pips");
|
||||
ready.PlayRepeating("ready");
|
||||
//blank = SheetBuilder.Add(new Size((int)spriteWidth, (int)spriteHeight), 16);
|
||||
//ready = new Animation("pips");
|
||||
//ready.PlayRepeating("ready");
|
||||
|
||||
cantBuild = new Animation("clock");
|
||||
cantBuild.PlayFetchIndex("idle", () => 0);
|
||||
//cantBuild = new Animation("clock");
|
||||
//cantBuild.PlayFetchIndex("idle", () => 0);
|
||||
}
|
||||
|
||||
const int NumClockFrames = 54;
|
||||
@@ -130,59 +127,59 @@ namespace OpenRa.Game
|
||||
|
||||
void Paint()
|
||||
{
|
||||
PopulateItemList();
|
||||
//PopulateItemList();
|
||||
|
||||
foreach( var i in items ) /* draw the buttons */
|
||||
i.Paint(spriteRenderer, region.Location);
|
||||
spriteRenderer.Flush();
|
||||
////foreach( var i in items ) /* draw the buttons */
|
||||
//// i.Paint(spriteRenderer, region.Location);
|
||||
//spriteRenderer.Flush();
|
||||
|
||||
foreach( var i in items ) /* draw the status overlays */
|
||||
{
|
||||
var group = Rules.UnitCategory[ i.Tag ];
|
||||
var producing = player.Producing( group );
|
||||
if( producing != null && producing.Item == i.Tag )
|
||||
{
|
||||
clockAnimations[ group ].Tick();
|
||||
clockRenderer.DrawSprite( clockAnimations[ group ].Image, region.Location.ToFloat2() + i.location, 0 );
|
||||
//foreach( var i in items ) /* draw the status overlays */
|
||||
//{
|
||||
// var group = Rules.UnitCategory[ i.Tag ];
|
||||
// var producing = player.Producing( group );
|
||||
// if( producing != null && producing.Item == i.Tag )
|
||||
// {
|
||||
// clockAnimations[ group ].Tick();
|
||||
// clockRenderer.DrawSprite( clockAnimations[ group ].Image, region.Location.ToFloat2() + i.location, 0 );
|
||||
|
||||
if (producing.Done)
|
||||
{
|
||||
ready.Play("ready");
|
||||
clockRenderer.DrawSprite(ready.Image, region.Location.ToFloat2() + i.location + new float2((64 - ready.Image.size.X) / 2, 2), 0);
|
||||
}
|
||||
else if (producing.Paused)
|
||||
{
|
||||
ready.Play("hold");
|
||||
clockRenderer.DrawSprite(ready.Image, region.Location.ToFloat2() + i.location + new float2((64 - ready.Image.size.X) / 2, 2), 0);
|
||||
}
|
||||
}
|
||||
else if (producing != null)
|
||||
clockRenderer.DrawSprite(cantBuild.Image, region.Location.ToFloat2() + i.location, 0);
|
||||
}
|
||||
// if (producing.Done)
|
||||
// {
|
||||
// ready.Play("ready");
|
||||
// clockRenderer.DrawSprite(ready.Image, region.Location.ToFloat2() + i.location + new float2((64 - ready.Image.size.X) / 2, 2), 0);
|
||||
// }
|
||||
// else if (producing.Paused)
|
||||
// {
|
||||
// ready.Play("hold");
|
||||
// clockRenderer.DrawSprite(ready.Image, region.Location.ToFloat2() + i.location + new float2((64 - ready.Image.size.X) / 2, 2), 0);
|
||||
// }
|
||||
// }
|
||||
// else if (producing != null)
|
||||
// clockRenderer.DrawSprite(cantBuild.Image, region.Location.ToFloat2() + i.location, 0);
|
||||
//}
|
||||
|
||||
Fill(region.Size.Y + region.Location.Y, new float2(region.Location.X, buildPos + region.Location.Y));
|
||||
Fill(region.Size.Y + region.Location.Y, new float2(region.Location.X + spriteWidth, unitPos + region.Location.Y));
|
||||
//Fill(region.Size.Y + region.Location.Y, new float2(region.Location.X, buildPos + region.Location.Y));
|
||||
//Fill(region.Size.Y + region.Location.Y, new float2(region.Location.X + spriteWidth, unitPos + region.Location.Y));
|
||||
|
||||
spriteRenderer.Flush();
|
||||
clockRenderer.Flush();
|
||||
//spriteRenderer.Flush();
|
||||
//clockRenderer.Flush();
|
||||
|
||||
if (mouseOverItem != null)
|
||||
{
|
||||
/* draw the sidebar help for this item */
|
||||
/* todo: draw a solid background of the appropriate color */
|
||||
var ui = Rules.UnitInfo[mouseOverItem.Tag];
|
||||
var text = string.Format(ui.Cost > 0 ? "{0} ($ {1})" : "{0}", /* abilities! */
|
||||
ui.Description, ui.Cost);
|
||||
//if (mouseOverItem != null)
|
||||
//{
|
||||
// /* draw the sidebar help for this item */
|
||||
// /* todo: draw a solid background of the appropriate color */
|
||||
// var ui = Rules.UnitInfo[mouseOverItem.Tag];
|
||||
// var text = string.Format(ui.Cost > 0 ? "{0} ($ {1})" : "{0}", /* abilities! */
|
||||
// ui.Description, ui.Cost);
|
||||
|
||||
var size = renderer.MeasureText(text);
|
||||
// var size = renderer.MeasureText(text);
|
||||
|
||||
var pos = region.Position + mouseOverItem.location.ToInt2() -new int2(size.X+ 10, 0);
|
||||
renderer.DrawText( text, pos + new int2(0,-1), Color.Black );
|
||||
renderer.DrawText(text, pos + new int2(0, 1), Color.Black);
|
||||
renderer.DrawText(text, pos + new int2(1, 0), Color.Black);
|
||||
renderer.DrawText(text, pos + new int2(-1, 0), Color.Black);
|
||||
renderer.DrawText(text, pos , Color.White);
|
||||
}
|
||||
// var pos = region.Position + mouseOverItem.location.ToInt2() -new int2(size.X+ 10, 0);
|
||||
// renderer.DrawText( text, pos + new int2(0,-1), Color.Black );
|
||||
// renderer.DrawText(text, pos + new int2(0, 1), Color.Black);
|
||||
// renderer.DrawText(text, pos + new int2(1, 0), Color.Black);
|
||||
// renderer.DrawText(text, pos + new int2(-1, 0), Color.Black);
|
||||
// renderer.DrawText(text, pos , Color.White);
|
||||
//}
|
||||
}
|
||||
|
||||
public SidebarItem GetItem(float2 point)
|
||||
|
||||
Reference in New Issue
Block a user