Cheats menu

This commit is contained in:
Paul Chote
2011-05-15 19:34:06 +12:00
parent 0b0fac3c4b
commit 810953ea94
6 changed files with 180 additions and 5 deletions

View File

@@ -85,6 +85,7 @@
<Compile Include="Widgets\CncModBrowserLogic.cs" /> <Compile Include="Widgets\CncModBrowserLogic.cs" />
<Compile Include="Widgets\CncPerfDebugLogic.cs" /> <Compile Include="Widgets\CncPerfDebugLogic.cs" />
<Compile Include="Widgets\CncSettingsLogic.cs" /> <Compile Include="Widgets\CncSettingsLogic.cs" />
<Compile Include="Widgets\CncCheatsLogic.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj"> <ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">

View File

@@ -0,0 +1,80 @@
#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 <http://www.gnu.org/licenses/>.
*/
#endregion
using System;
using OpenRA;
using OpenRA.Traits;
using OpenRA.Widgets;
namespace OpenRA.Mods.Cnc.Widgets
{
public class CncCheatsLogic : IWidgetDelegate
{
[ObjectCreator.UseCtor]
public CncCheatsLogic([ObjectCreator.Param] Widget widget,
[ObjectCreator.Param] World world)
{
var panel = widget.GetWidget("CHEATS_PANEL");
var devTrait = world.LocalPlayer.PlayerActor.Trait<DeveloperMode>();
var shroudCheckbox = panel.GetWidget<CncCheckboxWidget>("SHROUD_CHECKBOX");
shroudCheckbox.IsChecked = () => devTrait.DisableShroud;
shroudCheckbox.OnClick = () => Order(world, "DevShroud");
var pathCheckbox = panel.GetWidget<CncCheckboxWidget>("PATHDEBUG_CHECKBOX");
pathCheckbox.IsChecked = () => devTrait.PathDebug;
pathCheckbox.OnClick = () => Order(world, "DevPathDebug");
panel.GetWidget<CncMenuButtonWidget>("GIVE_CASH_BUTTON").OnClick = () =>
world.IssueOrder(new Order("DevGiveCash", world.LocalPlayer.PlayerActor, false));
var fastBuildCheckbox = panel.GetWidget<CncCheckboxWidget>("INSTANT_BUILD_CHECKBOX");
fastBuildCheckbox.IsChecked = () => devTrait.FastBuild;
fastBuildCheckbox.OnClick = () => Order(world, "DevFastBuild");
var fastChargeCheckbox = panel.GetWidget<CncCheckboxWidget>("INSTANT_CHARGE_CHECKBOX");
fastChargeCheckbox.IsChecked = () => devTrait.FastCharge;
fastChargeCheckbox.OnClick = () => Order(world, "DevFastCharge");
var allTechCheckbox = panel.GetWidget<CncCheckboxWidget>("ENABLE_TECH_CHECKBOX");
allTechCheckbox.IsChecked = () => devTrait.AllTech;
allTechCheckbox.OnClick = () => Order(world, "DevEnableTech");
var powerCheckbox = panel.GetWidget<CncCheckboxWidget>("UNLIMITED_POWER_CHECKBOX");
powerCheckbox.IsChecked = () => devTrait.UnlimitedPower;
powerCheckbox.OnClick = () => Order(world, "DevUnlimitedPower");
var buildAnywhereCheckbox = panel.GetWidget<CncCheckboxWidget>("BUILD_ANYWHERE_CHECKBOX");
buildAnywhereCheckbox.IsChecked = () => devTrait.BuildAnywhere;
buildAnywhereCheckbox.OnClick = () => Order(world, "DevBuildAnywhere");
panel.GetWidget<CncMenuButtonWidget>("GIVE_EXPLORATION_BUTTON").OnClick = () =>
world.IssueOrder(new Order("DevGiveExploration", world.LocalPlayer.PlayerActor, false));
panel.GetWidget<CncMenuButtonWidget>("CLOSE_BUTTON").OnClick = Widget.CloseWindow;
}
public void Order(World world, string order)
{
world.IssueOrder(new Order(order, world.LocalPlayer.PlayerActor, false));
}
}
}

View File

@@ -65,6 +65,10 @@ namespace OpenRA.Mods.Cnc.Widgets
}); });
}; };
var cheatsButton = ingameRoot.GetWidget<CncMenuButtonWidget>("CHEATS_BUTTON");
cheatsButton.OnClick = () => Game.OpenWindow("CHEATS_PANEL", new WidgetArgs());
cheatsButton.IsVisible = () => world.LobbyInfo.GlobalSettings.AllowCheats;
var postgameBG = ingameRoot.GetWidget("POSTGAME_BG"); var postgameBG = ingameRoot.GetWidget("POSTGAME_BG");
postgameBG.IsVisible = () => postgameBG.IsVisible = () =>
{ {

View File

@@ -0,0 +1,90 @@
Container@CHEATS_PANEL:
Id:CHEATS_PANEL
Delegate:CncCheatsLogic
X:(WINDOW_RIGHT - WIDTH)/2
Y:(WINDOW_BOTTOM - 110)/2
Width:590
Height:145
Children:
Label@TITLE:
Width:590
Y:0-25
Font:BigBold
Contrast:true
Align:Center
Text:Cheats
Background@bg:
Width:590
Height:110
Background:panel-black
Children:
CncCheckbox@INSTANT_BUILD:
Id:INSTANT_BUILD_CHECKBOX
X:15
Y:15
Width:200
Height:20
Text:Instant Build Speed
CncCheckbox@ENABLE_TECH:
Id:ENABLE_TECH_CHECKBOX
X:15
Y:45
Width:200
Height:20
Text:Build Everything
CncCheckbox@BUILD_ANYWHERE:
Id:BUILD_ANYWHERE_CHECKBOX
X:15
Y:75
Width:200
Height:20
Text:Build Anywhere
CncCheckbox@UNLIMITED_POWER:
Id:UNLIMITED_POWER_CHECKBOX
X:200
Y:15
Width:200
Height:20
Text:Unlimited Power
CncCheckbox@INSTANT_CHARGE:
Id:INSTANT_CHARGE_CHECKBOX
X:200
Y:45
Width:200
Height:20
Text:Instant Charge Time
CncCheckbox@CHECKBOX_SHROUD:
Id:SHROUD_CHECKBOX
X:400
Y:15
Height:20
Width:200
Text:Disable Shroud
CncCheckbox@CHECKBOX_PATHDEBUG:
Id:PATHDEBUG_CHECKBOX
X:400
Y:45
Width:200
Height:20
Text:Show Unit Paths
CncMenuButton@CLOSE_BUTTON:
Id:CLOSE_BUTTON
X:0
Y:109
Width:140
Height:35
Text:Close
CncMenuButton@GIVE_CASH:
Id:GIVE_CASH_BUTTON
X:300
Y:109
Width:140
Height:35
Text:Give Cash
CncMenuButton@GIVE_EXPLORATION:
Id:GIVE_EXPLORATION_BUTTON
X:450
Y:109
Width:140
Height:35
Text:Give Exploration

View File

@@ -33,14 +33,13 @@ Container@INGAME_ROOT:
Height:35 Height:35
Text:Diplomacy Text:Diplomacy
Bold:True Bold:True
CncMenuButton@DEVELOPERMODE_BUTTON: CncMenuButton@CHEATS_BUTTON:
Id:DEVELOPERMODE_BUTTON Id:CHEATS_BUTTON
X:295 X:295
Y:5 Y:5
Width:160 Width:160
Height:25 Height:35
Text:Developer Mode Text:Cheats
Visible:false
Bold:True Bold:True
WorldTooltip: WorldTooltip:
ChatDisplay@CHAT_DISPLAY: ChatDisplay@CHAT_DISPLAY:

View File

@@ -75,6 +75,7 @@ ChromeLayout:
mods/cnc/chrome/music.yaml mods/cnc/chrome/music.yaml
mods/cnc/chrome/modchooser.yaml mods/cnc/chrome/modchooser.yaml
mods/cnc/chrome/preferences.yaml mods/cnc/chrome/preferences.yaml
mods/cnc/chrome/cheats.yaml
Weapons: Weapons:
mods/cnc/weapons.yaml mods/cnc/weapons.yaml