Merge pull request #5354 from pchote/fading

Add TD fade to/from black behavior to other mods.
This commit is contained in:
Matthias Mailänder
2014-05-19 08:11:44 +02:00
12 changed files with 44 additions and 97 deletions

View File

@@ -19,11 +19,29 @@ namespace OpenRA.Mods.RA.Widgets.Logic
[ObjectCreator.UseCtor]
public IngameMenuLogic(Widget widget, World world, Action onExit, WorldRenderer worldRenderer)
{
var resumeDisabled = false;
var mpe = world.WorldActor.TraitOrDefault<MenuPaletteEffect>();
Action onQuit = () =>
{
onExit();
LeaveGame(world);
Sound.PlayNotification(world.Map.Rules, null, "Speech", "Leave", world.LocalPlayer == null ? null : world.LocalPlayer.Country.Race);
resumeDisabled = true;
var exitDelay = 1200;
if (mpe != null)
{
Game.RunAfterDelay(exitDelay, () => mpe.Fade(MenuPaletteEffect.EffectType.Black));
exitDelay += 40 * mpe.Info.FadeLength;
}
Game.RunAfterDelay(exitDelay, () =>
{
Game.Disconnect();
Ui.ResetAll();
Game.LoadShellMap();
});
};
Action onSurrender = () =>
{
world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false));
@@ -32,22 +50,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
widget.Get<ButtonWidget>("DISCONNECT").OnClick = () =>
{
bool gameOver = world.LocalPlayer != null && world.LocalPlayer.WinState != WinState.Undefined;
if (gameOver)
{
onQuit();
}
else
{
widget.Visible = false;
ConfirmationDialogs.PromptConfirmAction(
"Abort Mission",
"Leave this game and return to the menu?",
onQuit,
() => widget.Visible = true,
"Abort");
}
widget.Visible = false;
ConfirmationDialogs.PromptConfirmAction("Abort Mission", "Leave this game and return to the menu?", onQuit, () => widget.Visible = true);
};
widget.Get<ButtonWidget>("SETTINGS").OnClick = () =>
@@ -65,7 +69,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic
widget.Visible = false;
Ui.OpenWindow("MUSIC_PANEL", new WidgetArgs { { "onExit", () => { widget.Visible = true; } } });
};
widget.Get<ButtonWidget>("RESUME").OnClick = () => onExit();
var resumeButton = widget.Get<ButtonWidget>("RESUME");
resumeButton.OnClick = () => onExit();
resumeButton.IsDisabled = () => resumeDisabled;
widget.Get<ButtonWidget>("SURRENDER").OnClick = () =>
{
@@ -79,13 +86,5 @@ namespace OpenRA.Mods.RA.Widgets.Logic
};
widget.Get("SURRENDER").IsVisible = () => world.LocalPlayer != null && world.LocalPlayer.WinState == WinState.Undefined;
}
void LeaveGame(World world)
{
Sound.PlayNotification(world.Map.Rules, null, "Speech", "Leave", world.LocalPlayer == null ? null : world.LocalPlayer.Country.Race);
Game.Disconnect();
Ui.CloseWindow();
Game.LoadShellMap();
}
}
}

View File

@@ -1,23 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2014 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
namespace OpenRA.Mods.RA.Widgets.Logic
{
public class ShellmapDesaturationLogic
{
[ObjectCreator.UseCtor]
public ShellmapDesaturationLogic(World world)
{
var paletteEffect = world.WorldActor.TraitOrDefault<MenuPaletteEffect>();
if (paletteEffect != null)
paletteEffect.Fade(MenuPaletteEffect.EffectType.Desaturated);
}
}
}