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")]
public class MenuPostProcessEffectInfo : TraitInfo
{
public readonly int FadeInLength = 10;
[Desc("Time (in ticks) to fade between states")]
public readonly int FadeLength = 10;
[Desc("Effect style to fade to during gameplay. Accepts values of None or Desaturated.")]
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.")]
public readonly MenuPostProcessEffect.EffectType MenuEffect = MenuPostProcessEffect.EffectType.None;
@@ -36,8 +44,8 @@ namespace OpenRA.Mods.Common.Traits
public enum EffectType { None, Black, Desaturated }
public readonly MenuPostProcessEffectInfo Info;
EffectType from = EffectType.Black;
EffectType to = EffectType.Black;
EffectType from;
EffectType to;
long startTime;
long endTime;
@@ -46,12 +54,16 @@ namespace OpenRA.Mods.Common.Traits
: base("menufade", PostProcessPassType.AfterShroud)
{
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;
endTime = startTime + Ui.Timestep * Info.FadeLength;
endTime = startTime + Ui.Timestep * length;
from = to;
to = type;
@@ -74,7 +86,7 @@ namespace OpenRA.Mods.Common.Traits
{
// HACK: Defer fade-in until the GameLoaded notification for game saves
if (!w.IsLoadingGameSave)
Fade(Info.Effect);
Fade(Info.Effect, Info.FadeInLength);
}
void INotifyGameLoaded.GameLoaded(World world)
@@ -83,7 +95,7 @@ namespace OpenRA.Mods.Common.Traits
// to avoid glitches resulting from trying to trigger both
// the standard and menu fades at the same time
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, () =>
{
if (Game.IsCurrentWorld(world))
mpe.Fade(MenuPostProcessEffect.EffectType.Black);
mpe.Fade(mpe.Info.GameExitEffect);
});
exitDelay += 40 * mpe.Info.FadeLength;
}
@@ -288,7 +288,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
void CloseMenu()
{
Ui.CloseWindow();
mpe?.Fade(MenuPostProcessEffect.EffectType.None);
mpe?.Fade(mpe.Info.Effect);
onExit();
Ui.ResetTooltips();
}
@@ -350,7 +350,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (mpe != null)
{
if (Game.IsCurrentWorld(world))
mpe.Fade(MenuPostProcessEffect.EffectType.Black);
mpe.Fade(mpe.Info.GameExitEffect);
exitDelay += 40 * mpe.Info.FadeLength;
}
@@ -545,7 +545,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
Ui.ResetTooltips();
void CloseMenu()
{
mpe?.Fade(MenuPostProcessEffect.EffectType.None);
mpe?.Fade(mpe.Info.Effect);
onExit();
}

View File

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

View File

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

View File

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

View File

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