#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.Logic { public class DeveloperModeLogic { [ObjectCreator.UseCtor] public DeveloperModeLogic(World world) { var devmodeBG = Widget.RootWidget.GetWidget("INGAME_ROOT").GetWidget("DEVELOPERMODE_BG"); var devModeButton = Widget.RootWidget.GetWidget("INGAME_DEVELOPERMODE_BUTTON"); devModeButton.OnClick = () => devmodeBG.Visible ^= true; var devTrait = world.LocalPlayer.PlayerActor.Trait(); var shroudCheckbox = devmodeBG.GetWidget("CHECKBOX_SHROUD"); shroudCheckbox.IsChecked = () => devTrait.DisableShroud; shroudCheckbox.OnClick = () => Order(world, "DevShroud"); var pathCheckbox = devmodeBG.GetWidget("CHECKBOX_PATHDEBUG"); pathCheckbox.IsChecked = () => devTrait.PathDebug; pathCheckbox.OnClick = () => Order(world, "DevPathDebug"); var fastBuildCheckbox = devmodeBG.GetWidget("INSTANT_BUILD"); fastBuildCheckbox.IsChecked = () => devTrait.FastBuild; fastBuildCheckbox.OnClick = () => Order(world, "DevFastBuild"); var fastChargeCheckbox = devmodeBG.GetWidget("INSTANT_CHARGE"); fastChargeCheckbox.IsChecked = () => devTrait.FastCharge; fastChargeCheckbox.OnClick = () => Order(world, "DevFastCharge"); var allTechCheckbox = devmodeBG.GetWidget("ENABLE_TECH"); allTechCheckbox.IsChecked = () => devTrait.AllTech; allTechCheckbox.OnClick = () => Order(world, "DevEnableTech"); var powerCheckbox = devmodeBG.GetWidget("UNLIMITED_POWER"); powerCheckbox.IsChecked = () => devTrait.UnlimitedPower; powerCheckbox.OnClick = () => Order(world, "DevUnlimitedPower"); var buildAnywhereCheckbox = devmodeBG.GetWidget("BUILD_ANYWHERE"); buildAnywhereCheckbox.IsChecked = () => devTrait.BuildAnywhere; buildAnywhereCheckbox.OnClick = () => Order(world, "DevBuildAnywhere"); devmodeBG.GetWidget("GIVE_CASH").OnClick = () => world.IssueOrder(new Order("DevGiveCash", world.LocalPlayer.PlayerActor, false)); devmodeBG.GetWidget("GIVE_EXPLORATION").OnClick = () => world.IssueOrder(new Order("DevGiveExploration", world.LocalPlayer.PlayerActor, false)); devModeButton.IsVisible = () => { return world.LobbyInfo.GlobalSettings.AllowCheats; }; } public void Order(World world, string order) { world.IssueOrder(new Order(order, world.LocalPlayer.PlayerActor, false)); } } }