Add fade in/out effects to RA and TS.
The palette effect interacts badly with the multiplicative blending in D2K.
This commit is contained in:
@@ -16,12 +16,13 @@ using OpenRA.Traits;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
namespace OpenRA.Mods.RA
|
||||||
{
|
{
|
||||||
|
[Desc("Fades the world from/to black at the start/end of the game, and can (optionally) desaturate the world")]
|
||||||
public class MenuPaletteEffectInfo : ITraitInfo
|
public class MenuPaletteEffectInfo : ITraitInfo
|
||||||
{
|
{
|
||||||
[Desc("Time (in ticks) to fade between states")]
|
[Desc("Time (in ticks) to fade between states")]
|
||||||
public readonly int FadeLength = 10;
|
public readonly int FadeLength = 10;
|
||||||
|
|
||||||
[Desc("Effect style to fade into")]
|
[Desc("Effect style to fade to. Accepts values of None or Desaturated")]
|
||||||
public readonly MenuPaletteEffect.EffectType Effect = MenuPaletteEffect.EffectType.None;
|
public readonly MenuPaletteEffect.EffectType Effect = MenuPaletteEffect.EffectType.None;
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new MenuPaletteEffect(this); }
|
public object Create(ActorInitializer init) { return new MenuPaletteEffect(this); }
|
||||||
|
|||||||
@@ -19,11 +19,29 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
public IngameMenuLogic(Widget widget, World world, Action onExit, WorldRenderer worldRenderer)
|
public IngameMenuLogic(Widget widget, World world, Action onExit, WorldRenderer worldRenderer)
|
||||||
{
|
{
|
||||||
|
var resumeDisabled = false;
|
||||||
|
var mpe = world.WorldActor.TraitOrDefault<MenuPaletteEffect>();
|
||||||
|
|
||||||
Action onQuit = () =>
|
Action onQuit = () =>
|
||||||
{
|
{
|
||||||
onExit();
|
Sound.PlayNotification(world.Map.Rules, null, "Speech", "Leave", world.LocalPlayer == null ? null : world.LocalPlayer.Country.Race);
|
||||||
LeaveGame(world);
|
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 = () =>
|
Action onSurrender = () =>
|
||||||
{
|
{
|
||||||
world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false));
|
world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false));
|
||||||
@@ -32,22 +50,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
|
|
||||||
widget.Get<ButtonWidget>("DISCONNECT").OnClick = () =>
|
widget.Get<ButtonWidget>("DISCONNECT").OnClick = () =>
|
||||||
{
|
{
|
||||||
bool gameOver = world.LocalPlayer != null && world.LocalPlayer.WinState != WinState.Undefined;
|
widget.Visible = false;
|
||||||
|
ConfirmationDialogs.PromptConfirmAction("Abort Mission", "Leave this game and return to the menu?", onQuit, () => widget.Visible = true);
|
||||||
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.Get<ButtonWidget>("SETTINGS").OnClick = () =>
|
widget.Get<ButtonWidget>("SETTINGS").OnClick = () =>
|
||||||
@@ -65,7 +69,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
widget.Visible = false;
|
widget.Visible = false;
|
||||||
Ui.OpenWindow("MUSIC_PANEL", new WidgetArgs { { "onExit", () => { widget.Visible = true; } } });
|
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 = () =>
|
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;
|
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ World:
|
|||||||
LoadWidgetAtGameStart:
|
LoadWidgetAtGameStart:
|
||||||
Widget: INGAME_ROOT
|
Widget: INGAME_ROOT
|
||||||
ScreenShaker:
|
ScreenShaker:
|
||||||
|
MenuPaletteEffect:
|
||||||
WaterPaletteRotation:
|
WaterPaletteRotation:
|
||||||
ExcludePalettes: player, effect
|
ExcludePalettes: player, effect
|
||||||
ChronoshiftPaletteEffect:
|
ChronoshiftPaletteEffect:
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ World:
|
|||||||
ActorMap:
|
ActorMap:
|
||||||
LoadWidgetAtGameStart:
|
LoadWidgetAtGameStart:
|
||||||
Widget: INGAME_ROOT
|
Widget: INGAME_ROOT
|
||||||
|
MenuPaletteEffect:
|
||||||
BuildingInfluence:
|
BuildingInfluence:
|
||||||
ChooseBuildTabOnSelect:
|
ChooseBuildTabOnSelect:
|
||||||
PaletteFromFile@player:
|
PaletteFromFile@player:
|
||||||
|
|||||||
Reference in New Issue
Block a user