"Battle control terminated"
This commit is contained in:
@@ -15,21 +15,26 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Cnc
|
||||
{
|
||||
class CncMenuPaletteEffectInfo : TraitInfo<CncMenuPaletteEffect> { }
|
||||
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 }
|
||||
public readonly CncMenuPaletteEffectInfo Info;
|
||||
|
||||
const int effectLength = 10;
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<CncMenuPaletteEffect>().Fade(CncMenuPaletteEffect.EffectType.Desaturated);
|
||||
var mpe = world.WorldActor.Trait<CncMenuPaletteEffect>();
|
||||
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 = () =>
|
||||
{
|
||||
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<ButtonWidget>("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<ButtonWidget>("SURRENDER_BUTTON");
|
||||
@@ -137,7 +149,9 @@ namespace OpenRA.Mods.Cnc.Widgets
|
||||
});
|
||||
};
|
||||
|
||||
menu.GetWidget<ButtonWidget>("RESUME_BUTTON").OnClick = () =>
|
||||
var resumeButton = menu.GetWidget<ButtonWidget>("RESUME_BUTTON");
|
||||
resumeButton.IsDisabled = () => resumeDisabled;
|
||||
resumeButton.OnClick = () =>
|
||||
{
|
||||
Widget.RootWidget.RemoveChild(menu);
|
||||
world.WorldActor.Trait<CncMenuPaletteEffect>().Fade(CncMenuPaletteEffect.EffectType.None);
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user