Hook up sell/repair buttons
This commit is contained in:
@@ -13,6 +13,7 @@ using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Widgets;
|
||||
using OpenRA.Mods.RA;
|
||||
using OpenRA.Mods.RA.Orders;
|
||||
|
||||
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
{
|
||||
@@ -68,6 +69,16 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
playerWidgets.IsVisible = () => true;
|
||||
|
||||
var sidebarRoot = playerWidgets.GetWidget("SIDEBAR_BACKGROUND");
|
||||
|
||||
var sellButton = sidebarRoot.GetWidget<ButtonWidget>("SELL_BUTTON");
|
||||
sellButton.IsDisabled = () => world.OrderGenerator is SellOrderGenerator;
|
||||
sellButton.OnClick = () => world.ToggleInputMode<SellOrderGenerator>();
|
||||
|
||||
var repairButton = sidebarRoot.GetWidget<ButtonWidget>("REPAIR_BUTTON");
|
||||
repairButton.IsDisabled = () => world.OrderGenerator is RepairOrderGenerator
|
||||
|| !RepairOrderGenerator.PlayerIsAllowedToRepair( world );
|
||||
repairButton.OnClick = () => world.ToggleInputMode<RepairOrderGenerator>();
|
||||
|
||||
var playerResources = world.LocalPlayer.PlayerActor.Trait<PlayerResources>();
|
||||
sidebarRoot.GetWidget<LabelWidget>("CASH_DISPLAY").GetText = () =>
|
||||
"${0}".F(playerResources.DisplayCash + playerResources.DisplayOre);
|
||||
@@ -114,7 +125,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
{ "onExit", () => ingameRoot.IsVisible = () => true }
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
var cheatsButton = ingameRoot.GetWidget<ButtonWidget>("CHEATS_BUTTON");
|
||||
cheatsButton.OnClick = () =>
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Orders
|
||||
{
|
||||
class RepairOrderGenerator : IOrderGenerator
|
||||
public class RepairOrderGenerator : IOrderGenerator
|
||||
{
|
||||
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Orders
|
||||
{
|
||||
class SellOrderGenerator : IOrderGenerator
|
||||
public class SellOrderGenerator : IOrderGenerator
|
||||
{
|
||||
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
|
||||
@@ -102,16 +102,16 @@ Container@INGAME_ROOT:
|
||||
Height:25
|
||||
Text:Opt
|
||||
Font:Bold
|
||||
Button@SELL:
|
||||
Id:SELL
|
||||
Button@SELL_BUTTON:
|
||||
Id:SELL_BUTTON
|
||||
X:80
|
||||
Y:0-24
|
||||
Width:35
|
||||
Height:25
|
||||
Text:$
|
||||
Font:Bold
|
||||
Button@REPAIR:
|
||||
Id:SELL
|
||||
Button@REPAIR_BUTTON:
|
||||
Id:REPAIR_BUTTON
|
||||
X:120
|
||||
Y:0-24
|
||||
Width:35
|
||||
|
||||
Reference in New Issue
Block a user