Merge pull request #5354 from pchote/fading
Add TD fade to/from black behavior to other mods.
This commit is contained in:
@@ -87,7 +87,6 @@
|
|||||||
<Compile Include="RenderGunboat.cs" />
|
<Compile Include="RenderGunboat.cs" />
|
||||||
<Compile Include="SpawnViceroid.cs" />
|
<Compile Include="SpawnViceroid.cs" />
|
||||||
<Compile Include="TiberiumRefinery.cs" />
|
<Compile Include="TiberiumRefinery.cs" />
|
||||||
<Compile Include="Widgets\CncWidgetUtils.cs" />
|
|
||||||
<Compile Include="Widgets\Logic\CncConquestObjectivesLogic.cs" />
|
<Compile Include="Widgets\Logic\CncConquestObjectivesLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\CncIngameChromeLogic.cs" />
|
<Compile Include="Widgets\Logic\CncIngameChromeLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\CncIngameMenuLogic.cs" />
|
<Compile Include="Widgets\Logic\CncIngameMenuLogic.cs" />
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
#region Copyright & License Information
|
|
||||||
/*
|
|
||||||
* Copyright 2007-2011 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
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using OpenRA.Widgets;
|
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Widgets
|
|
||||||
{
|
|
||||||
public static class CncWidgetUtils
|
|
||||||
{
|
|
||||||
public static void PromptConfirmAction(string title, string text, Action onConfirm, Action onCancel)
|
|
||||||
{
|
|
||||||
var prompt = Ui.OpenWindow("CONFIRM_PROMPT");
|
|
||||||
prompt.Get<LabelWidget>("PROMPT_TITLE").GetText = () => title;
|
|
||||||
prompt.Get<LabelWidget>("PROMPT_TEXT").GetText = () => text;
|
|
||||||
|
|
||||||
prompt.Get<ButtonWidget>("CONFIRM_BUTTON").OnClick = () =>
|
|
||||||
{
|
|
||||||
Ui.CloseWindow();
|
|
||||||
onConfirm();
|
|
||||||
};
|
|
||||||
|
|
||||||
prompt.Get<ButtonWidget>("CANCEL_BUTTON").OnClick = () =>
|
|
||||||
{
|
|
||||||
Ui.CloseWindow();
|
|
||||||
onCancel();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -28,9 +28,6 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
public CncIngameChromeLogic(Widget widget, World world)
|
public CncIngameChromeLogic(Widget widget, World world)
|
||||||
{
|
{
|
||||||
this.world = world;
|
this.world = world;
|
||||||
world.WorldActor.Trait<MenuPaletteEffect>()
|
|
||||||
.Fade(MenuPaletteEffect.EffectType.None);
|
|
||||||
|
|
||||||
ingameRoot = widget.Get("INGAME_ROOT");
|
ingameRoot = widget.Get("INGAME_ROOT");
|
||||||
var playerRoot = ingameRoot.Get("PLAYER_ROOT");
|
var playerRoot = ingameRoot.Get("PLAYER_ROOT");
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ using System;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
using OpenRA.Mods.RA;
|
using OpenRA.Mods.RA;
|
||||||
|
using OpenRA.Mods.RA.Widgets;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
@@ -53,13 +54,13 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
Action doNothing = () => { };
|
Action doNothing = () => { };
|
||||||
|
|
||||||
menu.Get<ButtonWidget>("QUIT_BUTTON").OnClick = () =>
|
menu.Get<ButtonWidget>("QUIT_BUTTON").OnClick = () =>
|
||||||
CncWidgetUtils.PromptConfirmAction("Abort Mission", "Leave this game and return to the menu?", onQuit, doNothing);
|
ConfirmationDialogs.PromptConfirmAction("Abort Mission", "Leave this game and return to the menu?", onQuit, doNothing);
|
||||||
|
|
||||||
Action onSurrender = () => world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false));
|
Action onSurrender = () => world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false));
|
||||||
var surrenderButton = menu.Get<ButtonWidget>("SURRENDER_BUTTON");
|
var surrenderButton = menu.Get<ButtonWidget>("SURRENDER_BUTTON");
|
||||||
surrenderButton.IsDisabled = () => (world.LocalPlayer == null || world.LocalPlayer.WinState != WinState.Undefined);
|
surrenderButton.IsDisabled = () => (world.LocalPlayer == null || world.LocalPlayer.WinState != WinState.Undefined);
|
||||||
surrenderButton.OnClick = () =>
|
surrenderButton.OnClick = () =>
|
||||||
CncWidgetUtils.PromptConfirmAction("Surrender", "Are you sure you want to surrender?", onSurrender, doNothing);
|
ConfirmationDialogs.PromptConfirmAction("Surrender", "Are you sure you want to surrender?", onSurrender, doNothing);
|
||||||
|
|
||||||
menu.Get<ButtonWidget>("MUSIC_BUTTON").OnClick = () =>
|
menu.Get<ButtonWidget>("MUSIC_BUTTON").OnClick = () =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,14 +16,19 @@ 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")]
|
||||||
public readonly int FadeLength = 10;
|
public readonly int FadeLength = 10;
|
||||||
|
|
||||||
|
[Desc("Effect style to fade to. Accepts values of None or Desaturated")]
|
||||||
|
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); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MenuPaletteEffect : IPaletteModifier, ITickRender
|
public class MenuPaletteEffect : IPaletteModifier, ITickRender, IWorldLoaded
|
||||||
{
|
{
|
||||||
public enum EffectType { None, Black, Desaturated }
|
public enum EffectType { None, Black, Desaturated }
|
||||||
public readonly MenuPaletteEffectInfo Info;
|
public readonly MenuPaletteEffectInfo Info;
|
||||||
@@ -84,5 +89,10 @@ namespace OpenRA.Mods.RA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void WorldLoaded(World w, WorldRenderer wr)
|
||||||
|
{
|
||||||
|
Fade(Info.Effect);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -411,7 +411,6 @@
|
|||||||
<Compile Include="Widgets\Logic\ReplayBrowserLogic.cs" />
|
<Compile Include="Widgets\Logic\ReplayBrowserLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\ServerBrowserLogic.cs" />
|
<Compile Include="Widgets\Logic\ServerBrowserLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\ServerCreationLogic.cs" />
|
<Compile Include="Widgets\Logic\ServerCreationLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\ShellmapDesaturationLogic.cs" />
|
|
||||||
<Compile Include="Widgets\MoneyBinWidget.cs" />
|
<Compile Include="Widgets\MoneyBinWidget.cs" />
|
||||||
<Compile Include="Widgets\ObserverProductionIconsWidget.cs" />
|
<Compile Include="Widgets\ObserverProductionIconsWidget.cs" />
|
||||||
<Compile Include="Widgets\ObserverSupportPowerIconsWidget.cs" />
|
<Compile Include="Widgets\ObserverSupportPowerIconsWidget.cs" />
|
||||||
|
|||||||
@@ -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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,8 +3,6 @@ Container@MENU_BACKGROUND:
|
|||||||
Height: WINDOW_BOTTOM
|
Height: WINDOW_BOTTOM
|
||||||
Logic: CncMainMenuLogic
|
Logic: CncMainMenuLogic
|
||||||
Children:
|
Children:
|
||||||
Container@SHELLMAP_DESATURATION:
|
|
||||||
Logic: ShellmapDesaturationLogic
|
|
||||||
Container@SHELLMAP_DECORATIONS:
|
Container@SHELLMAP_DECORATIONS:
|
||||||
Children:
|
Children:
|
||||||
Image@RETICLE:
|
Image@RETICLE:
|
||||||
|
|||||||
@@ -990,6 +990,8 @@ Rules:
|
|||||||
-SpawnMPUnits:
|
-SpawnMPUnits:
|
||||||
-MPStartLocations:
|
-MPStartLocations:
|
||||||
-CrateSpawner:
|
-CrateSpawner:
|
||||||
|
MenuPaletteEffect:
|
||||||
|
Effect: Desaturated
|
||||||
PlayMusicOnMapLoad:
|
PlayMusicOnMapLoad:
|
||||||
Music: map1
|
Music: map1
|
||||||
Loop: true
|
Loop: true
|
||||||
|
|||||||
@@ -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