Unify cheats -> debug and adjust plumbing for new RA UI.
This commit is contained in:
@@ -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)
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user