diff --git a/OpenRA.Mods.Cnc/CncMenuPaletteEffect.cs b/OpenRA.Mods.Cnc/CncMenuPaletteEffect.cs index 6f2f99b739..9dc8e234ed 100644 --- a/OpenRA.Mods.Cnc/CncMenuPaletteEffect.cs +++ b/OpenRA.Mods.Cnc/CncMenuPaletteEffect.cs @@ -15,21 +15,26 @@ using OpenRA.Traits; namespace OpenRA.Mods.Cnc { - class CncMenuPaletteEffectInfo : TraitInfo { } + public class CncMenuPaletteEffectInfo : ITraitInfo + { + public readonly int FadeLength = 10; + + public object Create(ActorInitializer init) { return new CncMenuPaletteEffect(this); } + } public class CncMenuPaletteEffect : IPaletteModifier, ITick { public enum EffectType { None, Black, Desaturated } - - const int effectLength = 10; - int remainingFrames; + public readonly CncMenuPaletteEffectInfo Info; + int remainingFrames; EffectType from = EffectType.Black; EffectType to = EffectType.Black; + public CncMenuPaletteEffect(CncMenuPaletteEffectInfo info) { Info = info; } public void Fade(EffectType type) { - remainingFrames = effectLength; + remainingFrames = Info.FadeLength; from = to; to = type; } @@ -76,7 +81,7 @@ namespace OpenRA.Mods.Cnc else { var f = ColorForEffect(from, orig); - pal.Value.SetColor(x, OpenRA.Graphics.Util.Lerp((float)remainingFrames / effectLength, t, f)); + pal.Value.SetColor(x, OpenRA.Graphics.Util.Lerp((float)remainingFrames / Info.FadeLength, t, f)); } } } diff --git a/OpenRA.Mods.Cnc/Widgets/CncIngameChromeLogic.cs b/OpenRA.Mods.Cnc/Widgets/CncIngameChromeLogic.cs index 92ef75308c..e03637c40b 100755 --- a/OpenRA.Mods.Cnc/Widgets/CncIngameChromeLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/CncIngameChromeLogic.cs @@ -12,6 +12,7 @@ using System; using System.Drawing; using OpenRA.Mods.RA; using OpenRA.Widgets; +using OpenRA.Mods.RA.Activities; namespace OpenRA.Mods.Cnc.Widgets { @@ -94,23 +95,34 @@ namespace OpenRA.Mods.Cnc.Widgets [ObjectCreator.Param] World world, [ObjectCreator.Param] Action onExit) { + var resumeDisabled = false; menu = widget.GetWidget("INGAME_MENU"); - world.WorldActor.Trait().Fade(CncMenuPaletteEffect.EffectType.Desaturated); + var mpe = world.WorldActor.Trait(); + mpe.Fade(CncMenuPaletteEffect.EffectType.Desaturated); bool hideButtons = false; menu.GetWidget("MENU_BUTTONS").IsVisible = () => !hideButtons; + // TODO: Create a mechanism to do things like this cleaner. Also needed for scripted missions Action onQuit = () => { - Game.DisconnectOnly(); - Widget.RootWidget.RemoveChildren(); - Game.LoadShellMap(); + Sound.Play("batlcon1.aud"); + resumeDisabled = true; + world.WorldActor.QueueActivity(new Wait(30)); + world.WorldActor.QueueActivity(new CallFunc(() => mpe.Fade(CncMenuPaletteEffect.EffectType.Black))); + world.WorldActor.QueueActivity(new Wait(mpe.Info.FadeLength)); + world.WorldActor.QueueActivity(new CallFunc(() => + { + Game.DisconnectOnly(); + Widget.RootWidget.RemoveChildren(); + Game.LoadShellMap(); + })); }; Action doNothing = () => {}; menu.GetWidget("QUIT_BUTTON").OnClick = () => - PromptConfirmAction("Quit", "Are you sure you want to quit?", onQuit, doNothing); + PromptConfirmAction("Abort Mission", "Leave this game and return to the menu?", onQuit, doNothing); Action onSurrender = () => world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false)); var surrenderButton = menu.GetWidget("SURRENDER_BUTTON"); @@ -137,7 +149,9 @@ namespace OpenRA.Mods.Cnc.Widgets }); }; - menu.GetWidget("RESUME_BUTTON").OnClick = () => + var resumeButton = menu.GetWidget("RESUME_BUTTON"); + resumeButton.IsDisabled = () => resumeDisabled; + resumeButton.OnClick = () => { Widget.RootWidget.RemoveChild(menu); world.WorldActor.Trait().Fade(CncMenuPaletteEffect.EffectType.None); diff --git a/mods/cnc/chrome/ingamemenu.yaml b/mods/cnc/chrome/ingamemenu.yaml index 7527a69523..5e8d5a0cb7 100644 --- a/mods/cnc/chrome/ingamemenu.yaml +++ b/mods/cnc/chrome/ingamemenu.yaml @@ -32,7 +32,7 @@ Container@INGAME_MENU: Y:0 Width:140 Height:35 - Text:Quit + Text:Abort Mission Button@SURRENDER_BUTTON: Id:SURRENDER_BUTTON X:150 @@ -87,7 +87,6 @@ Container@INGAME_MENU: Width:PARENT_RIGHT Height:25 Font:Bold - WordWrap:true Align:Center Button@CANCEL_BUTTON: Id:CANCEL_BUTTON