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