#region Copyright & License Information /* * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. * This file is part of OpenRA. * * OpenRA is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * OpenRA is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with OpenRA. If not, see . */ #endregion using System; using OpenRA; using OpenRA.Traits; using OpenRA.Widgets; namespace OpenRA.Mods.RA.Widgets.Delegates { public class DeveloperModeDelegate : IWidgetDelegate { [ObjectCreator.UseCtor] public DeveloperModeDelegate( [ObjectCreator.Param] World world ) { var devmodeBG = Widget.RootWidget.GetWidget("INGAME_ROOT").GetWidget("DEVELOPERMODE_BG"); var devModeButton = Widget.RootWidget.GetWidget("INGAME_DEVELOPERMODE_BUTTON"); devModeButton.OnMouseUp = mi => { devmodeBG.Visible ^= true; return true; }; var devTrait = world.LocalPlayer.PlayerActor.Trait(); devmodeBG.GetWidget("CHECKBOX_SHROUD").BindReadOnly(devTrait, "DisableShroud"); devmodeBG.GetWidget("CHECKBOX_SHROUD").OnChange += _ => Order(world, "DevShroud"); devmodeBG.GetWidget("CHECKBOX_UNITDEBUG").BindReadOnly(devTrait, "UnitInfluenceDebug"); devmodeBG.GetWidget("CHECKBOX_UNITDEBUG").OnChange += _ => Order(world, "DevUnitDebug"); devmodeBG.GetWidget("CHECKBOX_PATHDEBUG").BindReadOnly(devTrait, "PathDebug"); devmodeBG.GetWidget("CHECKBOX_PATHDEBUG").OnChange += _ => Order(world, "DevPathDebug"); devmodeBG.GetWidget("GIVE_CASH").OnMouseUp = mi => { world.IssueOrder(new Order("DevGiveCash", world.LocalPlayer.PlayerActor, false)); return true; }; devmodeBG.GetWidget("INSTANT_BUILD").BindReadOnly(devTrait, "FastBuild"); devmodeBG.GetWidget("INSTANT_BUILD").OnChange += _ => Order(world, "DevFastBuild"); devmodeBG.GetWidget("INSTANT_CHARGE").BindReadOnly(devTrait, "FastCharge"); devmodeBG.GetWidget("INSTANT_CHARGE").OnChange += _ => Order(world, "DevFastCharge"); devmodeBG.GetWidget("ENABLE_TECH").BindReadOnly(devTrait, "AllTech"); devmodeBG.GetWidget("ENABLE_TECH").OnChange += _ => Order(world, "DevEnableTech"); devmodeBG.GetWidget("UNLIMITED_POWER").BindReadOnly(devTrait, "UnlimitedPower"); devmodeBG.GetWidget("UNLIMITED_POWER").OnChange += _ => Order(world, "DevUnlimitedPower"); devmodeBG.GetWidget("BUILD_ANYWHERE").BindReadOnly(devTrait, "BuildAnywhere"); devmodeBG.GetWidget("BUILD_ANYWHERE").OnChange += _ => Order(world, "DevBuildAnywhere"); devmodeBG.GetWidget("GIVE_EXPLORATION").OnMouseUp = mi => { world.IssueOrder(new Order("DevGiveExploration", world.LocalPlayer.PlayerActor, false)); return true; }; devModeButton.IsVisible = () => { return world.LobbyInfo.GlobalSettings.AllowCheats; }; } public void Order(World world, string order) { world.IssueOrder(new Order(order, world.LocalPlayer.PlayerActor, false)); } } }