Unify cheats -> debug and adjust plumbing for new RA UI.

This commit is contained in:
Paul Chote
2014-07-17 13:54:30 +12:00
parent e7ae615ac9
commit 9e2b3ce0b8
14 changed files with 43 additions and 24 deletions

View File

@@ -411,7 +411,6 @@
<Compile Include="InfiltrateForExploration.cs" />
<Compile Include="InfiltrateForCash.cs" />
<Compile Include="RenderShroudCircle.cs" />
<Compile Include="Widgets\Logic\CheatsLogic.cs" />
<Compile Include="CloakPaletteEffect.cs" />
<Compile Include="Widgets\ColorPreviewManagerWidget.cs" />
<Compile Include="Infiltrates.cs" />
@@ -542,6 +541,7 @@
<Compile Include="Widgets\Logic\Ingame\IngameSiloBarLogic.cs" />
<Compile Include="Widgets\Logic\Ingame\LoadIngamePlayerOrObserverUILogic.cs" />
<Compile Include="Widgets\MenuButtonWidget.cs" />
<Compile Include="Widgets\Logic\DebugMenuLogic.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj">

View File

@@ -15,12 +15,10 @@ using OpenRA.Widgets;
namespace OpenRA.Mods.RA.Widgets.Logic
{
public class CheatsLogic
public class DebugMenuLogic
{
public static MersenneTwister CosmeticRandom = new MersenneTwister();
[ObjectCreator.UseCtor]
public CheatsLogic(Widget widget, Action onExit, World world)
public DebugMenuLogic(Widget widget, Action onExit, World world, bool transient)
{
var devTrait = world.LocalPlayer.PlayerActor.Trait<DeveloperMode>();
@@ -117,7 +115,18 @@ namespace OpenRA.Mods.RA.Widgets.Logic
var close = widget.GetOrNull<ButtonWidget>("CLOSE");
if (close != null)
close.OnClick = () => { Ui.CloseWindow(); onExit(); };
{
close.OnClick = () =>
{
if (transient)
{
Ui.CloseWindow();
Ui.Root.RemoveChild(widget);
}
onExit();
};
}
}
public void Order(World world, string order)

View File

@@ -97,11 +97,14 @@ namespace OpenRA.Mods.RA.Widgets.Logic
diplomacyButton.IsVisible = () => validPlayers > 0;
Widget cheats = null;
cheats = Game.LoadWidget(world, "CHEATS_PANEL", playerWidgets, new WidgetArgs
cheats = Game.LoadWidget(world, "INGAME_DEBUG_BG", playerWidgets, new WidgetArgs
{
{ "transient", true },
{ "onExit", () => cheats.Visible = false }
});
var cheatsButton = playerWidgets.Get<ButtonWidget>("CHEATS_BUTTON");
cheats.Visible = false;
var cheatsButton = playerWidgets.Get<ButtonWidget>("INGAME_DEBUG_BUTTON");
cheatsButton.OnClick = () => cheats.Visible ^= true;
cheatsButton.IsVisible = () => world.LobbyInfo.GlobalSettings.AllowCheats;

View File

@@ -62,6 +62,13 @@ namespace OpenRA.Mods.RA.Widgets.Logic
options.OnClick = () => OpenMenuPanel(options);
}
var debug = widget.GetOrNull<MenuButtonWidget>("DEBUG_BUTTON");
if (debug != null)
{
debug.IsVisible = () => world.LobbyInfo.GlobalSettings.AllowCheats;
debug.IsDisabled = () => disableSystemButtons;
debug.OnClick = () => OpenMenuPanel(debug);
}
}
void OpenMenuPanel(MenuButtonWidget button)