Add an order button for beacon placement.
This commit is contained in:
@@ -488,6 +488,7 @@
|
||||
<Compile Include="Attack\AttackGarrisoned.cs" />
|
||||
<Compile Include="Widgets\Logic\LobbyMapPreviewLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\ButtonTooltipLogic.cs" />
|
||||
<Compile Include="Orders\BeaconOrderGenerator.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||
|
||||
35
OpenRA.Mods.RA/Orders/BeaconOrderGenerator.cs
Normal file
35
OpenRA.Mods.RA/Orders/BeaconOrderGenerator.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* 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,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Graphics;
|
||||
|
||||
namespace OpenRA.Mods.RA.Orders
|
||||
{
|
||||
public class BeaconOrderGenerator : IOrderGenerator
|
||||
{
|
||||
public IEnumerable<Order> Order(World world, CPos xy, MouseInput mi)
|
||||
{
|
||||
if (mi.Button != MouseButton.Left)
|
||||
world.CancelInputMode();
|
||||
|
||||
if (world.Map.IsInMap(xy))
|
||||
{
|
||||
world.CancelInputMode();
|
||||
yield return new Order("PlaceBeacon", world.LocalPlayer.PlayerActor, false) { TargetLocation = xy };
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Tick(World world) { }
|
||||
public IEnumerable<IRenderable> Render(WorldRenderer wr, World world) { yield break; }
|
||||
public void RenderAfterWorld(WorldRenderer wr, World world) { }
|
||||
public string GetCursor(World world, CPos xy, MouseInput mi) { return world.Map.IsInMap(xy) ? "ability" : "generic-blocked"; }
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,13 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
BindOrderButton<RepairOrderGenerator>(world, repair, "repair");
|
||||
}
|
||||
|
||||
var beacon = widget.GetOrNull<ButtonWidget>("BEACON_BUTTON");
|
||||
if (beacon != null)
|
||||
{
|
||||
beacon.GetKey = _ => Game.Settings.Keys.PlaceBeaconKey;
|
||||
BindOrderButton<BeaconOrderGenerator>(world, beacon, "beacon");
|
||||
}
|
||||
|
||||
var power = widget.GetOrNull<ButtonWidget>("POWER_BUTTON");
|
||||
if (power != null)
|
||||
{
|
||||
|
||||
@@ -65,9 +65,6 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
if (key == ks.ToggleStatusBarsKey)
|
||||
return ToggleStatusBars();
|
||||
|
||||
if (key == ks.PlaceBeaconKey)
|
||||
return PerformPlaceBeacon();
|
||||
|
||||
// Put all functions that aren't unit-specific before this line!
|
||||
if (!world.Selection.Actors.Any())
|
||||
return false;
|
||||
@@ -189,15 +186,6 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PerformPlaceBeacon()
|
||||
{
|
||||
if (world.LocalPlayer == null)
|
||||
return true;
|
||||
|
||||
world.OrderGenerator = new GenericSelectTarget(world.LocalPlayer.PlayerActor, "PlaceBeacon", "ability");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CycleBases()
|
||||
{
|
||||
var bases = world.ActorsWithTrait<BaseBuilding>()
|
||||
|
||||
Reference in New Issue
Block a user