sidebar on-hold/cancel works correctly

This commit is contained in:
Chris Forbes
2009-11-01 19:25:28 +13:00
parent 4336c2af35
commit b9af0d42fe
2 changed files with 40 additions and 6 deletions

View File

@@ -151,8 +151,16 @@ namespace OpenRa.Game
clockRenderer.DrawSprite( clockAnimations[ group ].Image, region.Location.ToFloat2() + i.location, 0 ); clockRenderer.DrawSprite( clockAnimations[ group ].Image, region.Location.ToFloat2() + i.location, 0 );
if (producing.Done) 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); 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) else if (producing != null)
clockRenderer.DrawSprite(cantBuild.Image, region.Location.ToFloat2() + i.location, 0); clockRenderer.DrawSprite(cantBuild.Image, region.Location.ToFloat2() + i.location, 0);
} }
@@ -206,10 +214,14 @@ namespace OpenRa.Game
if( item == null ) if( item == null )
return; return;
string group = Rules.UnitCategory[item.Tag];
var producing = player.Producing(group);
if( mi.Button == MouseButtons.Left && mi.Event == MouseInputEvent.Down ) if( mi.Button == MouseButtons.Left && mi.Event == MouseInputEvent.Down )
{ {
string group = Rules.UnitCategory[ item.Tag ]; /* todo: move all this shit elsewhere! we can't have it in the UI if it's going to be
var producing = player.Producing(group); * correct in netplay!! */
if (producing == null) if (producing == null)
{ {
var ui = Rules.UnitInfo[item.Tag]; var ui = Rules.UnitInfo[item.Tag];
@@ -225,16 +237,36 @@ namespace OpenRa.Game
player.BeginProduction(group, player.BeginProduction(group,
new ProductionItem(item.Tag, (int)time, ui.Cost, complete)); new ProductionItem(item.Tag, (int)time, ui.Cost, complete));
Game.PlaySound("abldgin1.aud", false);
} }
else if (producing.Item == item.Tag && producing.Done) else if (producing.Item == item.Tag)
{ {
if (producing.Done)
Build(item); Build(item);
else
producing.Paused = false;
}
else
{
Game.PlaySound("progres1.aud", false);
} }
} }
else if (mi.Button == MouseButtons.Right && mi.Event == MouseInputEvent.Down) else if (mi.Button == MouseButtons.Right && mi.Event == MouseInputEvent.Down)
{ {
if (item.Tag != producing.Item) return;
if (producing.Paused || producing.Done)
{
Game.PlaySound("cancld1.aud", false);
player.CancelProduction(Rules.UnitCategory[item.Tag]); player.CancelProduction(Rules.UnitCategory[item.Tag]);
} }
else
{
Game.PlaySound("onhold1.aud", false);
producing.Paused = true;
}
}
} }
} }
} }

View File

@@ -53,9 +53,11 @@ namespace OpenRa.Game
case "DeliverOre": case "DeliverOre":
{ {
var mobile = order.Subject.traits.Get<Mobile>(); var mobile = order.Subject.traits.Get<Mobile>();
mobile.Cancel(order.Subject);
mobile.QueueActivity(new Mobile.MoveTo(order.TargetActor.Location + new int2(1, 2))); mobile.QueueActivity(new Mobile.MoveTo(order.TargetActor.Location + new int2(1, 2)));
mobile.QueueActivity(new Mobile.Turn(64)); mobile.QueueActivity(new Mobile.Turn(64));
/* todo: actual deliver activity! */
/* todo: actual deliver activity! [animation + add cash] */
break; break;
} }
case "PlaceBuilding": case "PlaceBuilding":