unify cheats panels

This commit is contained in:
Chris Forbes
2012-04-24 20:03:44 +12:00
parent 6559d8d8bc
commit 84a50e8e86
9 changed files with 104 additions and 161 deletions

View File

@@ -74,7 +74,6 @@
<Compile Include="Widgets\CncWorldInteractionControllerWidget.cs" />
<Compile Include="Widgets\LogicTickerWidget.cs" />
<Compile Include="Widgets\Logic\ButtonTooltipLogic.cs" />
<Compile Include="Widgets\Logic\CncCheatsLogic.cs" />
<Compile Include="Widgets\Logic\CncConquestObjectivesLogic.cs" />
<Compile Include="Widgets\Logic\CncIngameChromeLogic.cs" />
<Compile Include="Widgets\Logic\CncIngameMenuLogic.cs" />

View File

@@ -326,7 +326,6 @@
<Compile Include="Widgets\Logic\ModBrowserLogic.cs" />
<Compile Include="Widgets\Logic\ColorPickerLogic.cs" />
<Compile Include="Widgets\Logic\ConnectionLogic.cs" />
<Compile Include="Widgets\Logic\DeveloperModeLogic.cs" />
<Compile Include="Widgets\Logic\DiplomacyLogic.cs" />
<Compile Include="Widgets\Logic\DirectConnectLogic.cs" />
<Compile Include="Widgets\Logic\DownloadPackagesLogic.cs" />
@@ -361,6 +360,7 @@
<Compile Include="InfiltrateForExploration.cs" />
<Compile Include="InfiltrateForCash.cs" />
<Compile Include="RenderShroudCircle.cs" />
<Compile Include="Widgets\Logic\CheatsLogic.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">

View File

@@ -9,55 +9,54 @@
#endregion
using System;
using OpenRA;
using OpenRA.Traits;
using OpenRA.Widgets;
namespace OpenRA.Mods.Cnc.Widgets.Logic
namespace OpenRA.Mods.RA.Widgets.Logic
{
public class CncCheatsLogic
public class CheatsLogic
{
[ObjectCreator.UseCtor]
public CncCheatsLogic(Widget widget, Action onExit, World world)
public CheatsLogic(Widget widget, Action onExit, World world)
{
var panel = widget;
var devTrait = world.LocalPlayer.PlayerActor.Trait<DeveloperMode>();
var shroudCheckbox = panel.GetWidget<CheckboxWidget>("DISABLE_SHROUD");
var shroudCheckbox = widget.GetWidget<CheckboxWidget>("DISABLE_SHROUD");
shroudCheckbox.IsChecked = () => devTrait.DisableShroud;
shroudCheckbox.OnClick = () => Order(world, "DevShroud");
var pathCheckbox = panel.GetWidget<CheckboxWidget>("SHOW_UNIT_PATHS");
var pathCheckbox = widget.GetWidget<CheckboxWidget>("SHOW_UNIT_PATHS");
pathCheckbox.IsChecked = () => devTrait.PathDebug;
pathCheckbox.OnClick = () => Order(world, "DevPathDebug");
panel.GetWidget<ButtonWidget>("GIVE_CASH").OnClick = () =>
widget.GetWidget<ButtonWidget>("GIVE_CASH").OnClick = () =>
world.IssueOrder(new Order("DevGiveCash", world.LocalPlayer.PlayerActor, false));
var fastBuildCheckbox = panel.GetWidget<CheckboxWidget>("INSTANT_BUILD");
var fastBuildCheckbox = widget.GetWidget<CheckboxWidget>("INSTANT_BUILD");
fastBuildCheckbox.IsChecked = () => devTrait.FastBuild;
fastBuildCheckbox.OnClick = () => Order(world, "DevFastBuild");
var fastChargeCheckbox = panel.GetWidget<CheckboxWidget>("INSTANT_CHARGE");
var fastChargeCheckbox = widget.GetWidget<CheckboxWidget>("INSTANT_CHARGE");
fastChargeCheckbox.IsChecked = () => devTrait.FastCharge;
fastChargeCheckbox.OnClick = () => Order(world, "DevFastCharge");
var allTechCheckbox = panel.GetWidget<CheckboxWidget>("ENABLE_TECH");
var allTechCheckbox = widget.GetWidget<CheckboxWidget>("ENABLE_TECH");
allTechCheckbox.IsChecked = () => devTrait.AllTech;
allTechCheckbox.OnClick = () => Order(world, "DevEnableTech");
var powerCheckbox = panel.GetWidget<CheckboxWidget>("UNLIMITED_POWER");
var powerCheckbox = widget.GetWidget<CheckboxWidget>("UNLIMITED_POWER");
powerCheckbox.IsChecked = () => devTrait.UnlimitedPower;
powerCheckbox.OnClick = () => Order(world, "DevUnlimitedPower");
var buildAnywhereCheckbox = panel.GetWidget<CheckboxWidget>("BUILD_ANYWHERE");
var buildAnywhereCheckbox = widget.GetWidget<CheckboxWidget>("BUILD_ANYWHERE");
buildAnywhereCheckbox.IsChecked = () => devTrait.BuildAnywhere;
buildAnywhereCheckbox.OnClick = () => Order(world, "DevBuildAnywhere");
panel.GetWidget<ButtonWidget>("GIVE_EXPLORATION").OnClick = () =>
widget.GetWidget<ButtonWidget>("GIVE_EXPLORATION").OnClick = () =>
world.IssueOrder(new Order("DevGiveExploration", world.LocalPlayer.PlayerActor, false));
panel.GetWidget<ButtonWidget>("CLOSE").OnClick = () => { Ui.CloseWindow(); onExit(); };
widget.GetWidget<ButtonWidget>("CLOSE").OnClick = () => { Ui.CloseWindow(); onExit(); };
}
public void Order(World world, string order)

View File

@@ -1,71 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#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 = Ui.Root.GetWidget("INGAME_ROOT").GetWidget("DEVELOPERMODE_BG");
var devModeButton = Ui.Root.GetWidget<ButtonWidget>("INGAME_DEVELOPERMODE_BUTTON");
devModeButton.OnClick = () => devmodeBG.Visible ^= true;
var devTrait = world.LocalPlayer.PlayerActor.Trait<DeveloperMode>();
var shroudCheckbox = devmodeBG.GetWidget<CheckboxWidget>("CHECKBOX_SHROUD");
shroudCheckbox.IsChecked = () => devTrait.DisableShroud;
shroudCheckbox.OnClick = () => Order(world, "DevShroud");
var pathCheckbox = devmodeBG.GetWidget<CheckboxWidget>("CHECKBOX_PATHDEBUG");
pathCheckbox.IsChecked = () => devTrait.PathDebug;
pathCheckbox.OnClick = () => Order(world, "DevPathDebug");
var fastBuildCheckbox = devmodeBG.GetWidget<CheckboxWidget>("INSTANT_BUILD");
fastBuildCheckbox.IsChecked = () => devTrait.FastBuild;
fastBuildCheckbox.OnClick = () => Order(world, "DevFastBuild");
var fastChargeCheckbox = devmodeBG.GetWidget<CheckboxWidget>("INSTANT_CHARGE");
fastChargeCheckbox.IsChecked = () => devTrait.FastCharge;
fastChargeCheckbox.OnClick = () => Order(world, "DevFastCharge");
var allTechCheckbox = devmodeBG.GetWidget<CheckboxWidget>("ENABLE_TECH");
allTechCheckbox.IsChecked = () => devTrait.AllTech;
allTechCheckbox.OnClick = () => Order(world, "DevEnableTech");
var powerCheckbox = devmodeBG.GetWidget<CheckboxWidget>("UNLIMITED_POWER");
powerCheckbox.IsChecked = () => devTrait.UnlimitedPower;
powerCheckbox.OnClick = () => Order(world, "DevUnlimitedPower");
var buildAnywhereCheckbox = devmodeBG.GetWidget<CheckboxWidget>("BUILD_ANYWHERE");
buildAnywhereCheckbox.IsChecked = () => devTrait.BuildAnywhere;
buildAnywhereCheckbox.OnClick = () => Order(world, "DevBuildAnywhere");
devmodeBG.GetWidget<ButtonWidget>("GIVE_CASH").OnClick = () =>
world.IssueOrder(new Order("DevGiveCash", world.LocalPlayer.PlayerActor, false));
devmodeBG.GetWidget<ButtonWidget>("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));
}
}
}

View File

@@ -30,6 +30,13 @@ namespace OpenRA.Mods.RA.Widgets.Logic
r.GetWidget<ButtonWidget>("INGAME_OPTIONS_BUTTON").OnClick = () =>
optionsBG.Visible = !optionsBG.Visible;
var cheatsButton = gameRoot.GetWidget<ButtonWidget>("CHEATS_BUTTON");
cheatsButton.OnClick = () =>
{
Game.OpenWindow("CHEATS_PANEL", new WidgetArgs() {{"onExit", () => {} }});
};
cheatsButton.IsVisible = () => world.LocalPlayer != null && world.LobbyInfo.GlobalSettings.AllowCheats;
optionsBG.GetWidget<ButtonWidget>("DISCONNECT").OnClick = () => LeaveGame(optionsBG);

View File

@@ -1,5 +1,5 @@
Container@CHEATS_PANEL:
Logic:CncCheatsLogic
Logic:CheatsLogic
X:(WINDOW_RIGHT - WIDTH)/2
Y:(WINDOW_BOTTOM - 110)/2
Width:590

View File

@@ -0,0 +1,76 @@
Background@CHEATS_PANEL:
Logic:CheatsLogic
X:(WINDOW_RIGHT - WIDTH)/2
Y:(WINDOW_BOTTOM - HEIGHT)/2
Width:350
Height:420
Visible:true
Children:
Label@LABEL_TITLE:
X:(PARENT_RIGHT - WIDTH)/2
Y:20
Width:250
Height:25
Text:Developer Mode
Align:Center
Checkbox@DISABLE_SHROUD:
X:30
Y:50
Height:20
Width:PARENT_RIGHT - 30
Text:Disable Shroud
Button@GIVE_EXPLORATION
X:30
Y:80
Width:200
Height:20
Text: Give Exploration
Checkbox@SHOW_UNIT_PATHS:
X:30
Y:110
Width:PARENT_RIGHT - 30
Height:20
Text:Show Unit Paths
Button@GIVE_CASH:
X:30
Y:140
Width:200
Height:20
Text: Give Cash
Checkbox@INSTANT_BUILD:
X:30
Y:170
Width:PARENT_RIGHT - 30
Height:20
Text:Instant Build Speed
Checkbox@INSTANT_CHARGE:
X:30
Y:200
Width:PARENT_RIGHT - 30
Height:20
Text:Support Powers Charge Instantly
Checkbox@ENABLE_TECH:
X:30
Y:230
Width:PARENT_RIGHT - 30
Height:20
Text:Build Everything
Checkbox@UNLIMITED_POWER:
X:30
Y:260
Width:PARENT_RIGHT - 30
Height:20
Text:Unlimited Power
Checkbox@BUILD_ANYWHERE:
X:30
Y:290
Width:PARENT_RIGHT - 30
Height:20
Text:Build Anywhere
Button@CLOSE:
X:30
Y:360
Width:PARENT_RIGHT - 30
Height:20
Text:Close
Key:escape

View File

@@ -73,12 +73,12 @@ Container@INGAME_ROOT:
Height:25
Text:Diplomacy
Font:Bold
Button@INGAME_DEVELOPERMODE_BUTTON:
Button@CHEATS_BUTTON:
X:324
Y:0
Width:160
Height:25
Text:Developer Mode
Text:Cheats
Visible:false
Font:Bold
RadarBin@INGAME_RADAR_BIN:
@@ -199,75 +199,6 @@ Container@INGAME_ROOT:
Width: 760
Height: 30
UseContrast: yes
Background@DEVELOPERMODE_BG:
Logic:DeveloperModeLogic
X:(WINDOW_RIGHT - WIDTH)/2
Y:(WINDOW_BOTTOM - HEIGHT)/2
Width:350
Height:370
Visible:false
Children:
Label@LABEL_TITLE:
X:(PARENT_RIGHT - WIDTH)/2
Y:20
Width:250
Height:25
Text:Developer Mode
Align:Center
Checkbox@CHECKBOX_SHROUD
X:30
Y:50
Height:20
Width:PARENT_RIGHT - 30
Text:Disable Shroud
Button@GIVE_EXPLORATION
X:30
Y:80
Width:200
Height:20
Text: Give Exploration
Checkbox@CHECKBOX_PATHDEBUG:
X:30
Y:110
Width:PARENT_RIGHT - 30
Height:20
Text:Show Unit Paths
Button@GIVE_CASH
X:30
Y:140
Width:200
Height:20
Text: Give Cash
Checkbox@INSTANT_BUILD
X:30
Y:170
Width:PARENT_RIGHT - 30
Height:20
Text:Instant Build Speed
Checkbox@INSTANT_CHARGE
X:30
Y:200
Width:PARENT_RIGHT - 30
Height:20
Text:Support Powers Charge Instantly
Checkbox@ENABLE_TECH
X:30
Y:230
Width:PARENT_RIGHT - 30
Height:20
Text:Build Everything
Checkbox@UNLIMITED_POWER
X:30
Y:260
Width:PARENT_RIGHT - 30
Height:20
Text:Unlimited Power
Checkbox@BUILD_ANYWHERE
X:30
Y:290
Width:PARENT_RIGHT - 30
Height:20
Text:Build Anywhere
Background@PERF_BG:
ClickThrough:true
Background:dialog4

View File

@@ -63,6 +63,8 @@ ChromeLayout:
mods/ra/chrome/replaybrowser.yaml
mods/ra/chrome/dropdowns.yaml
mods/ra/chrome/modchooser.yaml
mods/ra/chrome/cheats.yaml
Weapons:
mods/ra/weapons.yaml