Add more customization to fade, shorten fade in

This commit is contained in:
Gustas
2025-03-10 20:43:43 +02:00
committed by Paul Chote
parent d3b7688a7d
commit 4c551cef00
6 changed files with 26 additions and 10 deletions

View File

@@ -19,12 +19,20 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Fades the world from/to black at the start/end of the game, and can (optionally) desaturate the world")] [Desc("Fades the world from/to black at the start/end of the game, and can (optionally) desaturate the world")]
public class MenuPostProcessEffectInfo : TraitInfo public class MenuPostProcessEffectInfo : TraitInfo
{ {
public readonly int FadeInLength = 10;
[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 to during gameplay. Accepts values of None or Desaturated.")] [Desc("Effect style to fade to during gameplay. Accepts values of None or Desaturated.")]
public readonly MenuPostProcessEffect.EffectType Effect = MenuPostProcessEffect.EffectType.None; public readonly MenuPostProcessEffect.EffectType Effect = MenuPostProcessEffect.EffectType.None;
[Desc("Effect style to fade from when starting the game. Accepts values of None, Black or Desaturated.")]
public readonly MenuPostProcessEffect.EffectType GameStartEffect = MenuPostProcessEffect.EffectType.Black;
[Desc("Effect style to fade to when exiting the game. Accepts values of None, Black or Desaturated.")]
public readonly MenuPostProcessEffect.EffectType GameExitEffect = MenuPostProcessEffect.EffectType.Black;
[Desc("Effect style to fade to when opening the in-game menu. Accepts values of None, Black or Desaturated.")] [Desc("Effect style to fade to when opening the in-game menu. Accepts values of None, Black or Desaturated.")]
public readonly MenuPostProcessEffect.EffectType MenuEffect = MenuPostProcessEffect.EffectType.None; public readonly MenuPostProcessEffect.EffectType MenuEffect = MenuPostProcessEffect.EffectType.None;
@@ -36,8 +44,8 @@ namespace OpenRA.Mods.Common.Traits
public enum EffectType { None, Black, Desaturated } public enum EffectType { None, Black, Desaturated }
public readonly MenuPostProcessEffectInfo Info; public readonly MenuPostProcessEffectInfo Info;
EffectType from = EffectType.Black; EffectType from;
EffectType to = EffectType.Black; EffectType to;
long startTime; long startTime;
long endTime; long endTime;
@@ -46,12 +54,16 @@ namespace OpenRA.Mods.Common.Traits
: base("menufade", PostProcessPassType.AfterShroud) : base("menufade", PostProcessPassType.AfterShroud)
{ {
Info = info; Info = info;
to = info.GameStartEffect;
} }
public void Fade(EffectType type) public void Fade(EffectType type, int length = -1)
{ {
if (length < 0)
length = Info.FadeLength;
startTime = Game.RunTime; startTime = Game.RunTime;
endTime = startTime + Ui.Timestep * Info.FadeLength; endTime = startTime + Ui.Timestep * length;
from = to; from = to;
to = type; to = type;
@@ -74,7 +86,7 @@ namespace OpenRA.Mods.Common.Traits
{ {
// HACK: Defer fade-in until the GameLoaded notification for game saves // HACK: Defer fade-in until the GameLoaded notification for game saves
if (!w.IsLoadingGameSave) if (!w.IsLoadingGameSave)
Fade(Info.Effect); Fade(Info.Effect, Info.FadeInLength);
} }
void INotifyGameLoaded.GameLoaded(World world) void INotifyGameLoaded.GameLoaded(World world)
@@ -83,7 +95,7 @@ namespace OpenRA.Mods.Common.Traits
// to avoid glitches resulting from trying to trigger both // to avoid glitches resulting from trying to trigger both
// the standard and menu fades at the same time // the standard and menu fades at the same time
if (world.IsReplay) if (world.IsReplay)
Fade(Info.Effect); Fade(Info.Effect, Info.FadeInLength);
} }
} }
} }

View File

@@ -263,7 +263,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
Game.RunAfterDelay(exitDelay, () => Game.RunAfterDelay(exitDelay, () =>
{ {
if (Game.IsCurrentWorld(world)) if (Game.IsCurrentWorld(world))
mpe.Fade(MenuPostProcessEffect.EffectType.Black); mpe.Fade(mpe.Info.GameExitEffect);
}); });
exitDelay += 40 * mpe.Info.FadeLength; exitDelay += 40 * mpe.Info.FadeLength;
} }
@@ -288,7 +288,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
void CloseMenu() void CloseMenu()
{ {
Ui.CloseWindow(); Ui.CloseWindow();
mpe?.Fade(MenuPostProcessEffect.EffectType.None); mpe?.Fade(mpe.Info.Effect);
onExit(); onExit();
Ui.ResetTooltips(); Ui.ResetTooltips();
} }
@@ -350,7 +350,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (mpe != null) if (mpe != null)
{ {
if (Game.IsCurrentWorld(world)) if (Game.IsCurrentWorld(world))
mpe.Fade(MenuPostProcessEffect.EffectType.Black); mpe.Fade(mpe.Info.GameExitEffect);
exitDelay += 40 * mpe.Info.FadeLength; exitDelay += 40 * mpe.Info.FadeLength;
} }
@@ -545,7 +545,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
Ui.ResetTooltips(); Ui.ResetTooltips();
void CloseMenu() void CloseMenu()
{ {
mpe?.Fade(MenuPostProcessEffect.EffectType.None); mpe?.Fade(mpe.Info.Effect);
onExit(); onExit();
} }

View File

@@ -106,6 +106,7 @@
ReferenceHue: 0.1 ReferenceHue: 0.1
ReferenceSaturation: 0.75 ReferenceSaturation: 0.75
MenuPostProcessEffect: MenuPostProcessEffect:
FadeInLength: 4
MenuEffect: Desaturated MenuEffect: Desaturated
CloakPaletteEffect: CloakPaletteEffect:
FlashPostProcessEffect: FlashPostProcessEffect:

View File

@@ -26,6 +26,7 @@
BasePalette: d2k BasePalette: d2k
RemapIndex: 255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240 RemapIndex: 255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240
MenuPostProcessEffect: MenuPostProcessEffect:
FadeInLength: 4
FlashPostProcessEffect: FlashPostProcessEffect:
ColorPickerColorShift: ColorPickerColorShift:
BasePalette: colorpicker BasePalette: colorpicker

View File

@@ -75,6 +75,7 @@
BasePalette: player-noshadow BasePalette: player-noshadow
RemapIndex: 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95 RemapIndex: 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95
MenuPostProcessEffect: MenuPostProcessEffect:
FadeInLength: 4
RotationPaletteEffect@defaultwater: RotationPaletteEffect@defaultwater:
Palettes: terrain Palettes: terrain
ExcludeTilesets: DESERT ExcludeTilesets: DESERT

View File

@@ -157,3 +157,4 @@
Name: terrainalpha Name: terrainalpha
Alpha: 0.55 Alpha: 0.55
MenuPostProcessEffect: MenuPostProcessEffect:
FadeInLength: 3