From 15fe45247ab45f5016d311c77d654b0a7ebe6913 Mon Sep 17 00:00:00 2001 From: flustix Date: Sat, 14 Dec 2024 15:32:41 +0100 Subject: [PATCH] merge `PlayfieldFade` into `LayerFade` --- .../UserInterface/Color/FluXisColors.cs | 1 - fluXis.Game/Map/MapEvents.cs | 21 +++--- .../Map/Structures/Events/LayerFadeEvent.cs | 11 ++- .../Structures/Events/PlayfieldFadeEvent.cs | 30 --------- fluXis.Game/Mods/NoEventMod.cs | 1 - .../Online/API/Models/Maps/MapEffectType.cs | 3 + fluXis.Game/Screens/Edit/EditorMap.cs | 5 -- .../Design/Playfield/EditorDesignPlayfield.cs | 6 +- .../Tabs/Design/Points/DesignPointsList.cs | 7 -- .../Points/Entries/PlayfieldFadeEntry.cs | 67 ------------------- .../Gameplay/Ruleset/Playfields/Playfield.cs | 3 +- .../MapSet/DrawableMapSetDifficulty.cs | 3 - fluXis.Game/Utils/MapUtils.cs | 4 +- 13 files changed, 32 insertions(+), 130 deletions(-) delete mode 100644 fluXis.Game/Map/Structures/Events/PlayfieldFadeEvent.cs delete mode 100644 fluXis.Game/Screens/Edit/Tabs/Design/Points/Entries/PlayfieldFadeEntry.cs diff --git a/fluXis.Game/Graphics/UserInterface/Color/FluXisColors.cs b/fluXis.Game/Graphics/UserInterface/Color/FluXisColors.cs index fb25e1f3..79530d37 100644 --- a/fluXis.Game/Graphics/UserInterface/Color/FluXisColors.cs +++ b/fluXis.Game/Graphics/UserInterface/Color/FluXisColors.cs @@ -42,7 +42,6 @@ public static class FluXisColors public static Colour4 PlayfieldMove => Colour4.FromHex("#01FE55"); public static Colour4 PlayfieldScale => Colour4.FromHex("#D279C4"); public static Colour4 PlayfieldRotate => Colour4.FromHex("#8AF7A2"); - public static Colour4 PlayfieldFade => Colour4.FromHex("#0180FE"); public static Colour4 HitObjectEase => Colour4.FromHex("#5B92FF"); public static Colour4 LayerFade => Colour4.FromHex("#8AF3F7"); public static Colour4 BeatPulse => Colour4.FromHex("#FF6666"); diff --git a/fluXis.Game/Map/MapEvents.cs b/fluXis.Game/Map/MapEvents.cs index aad534b1..890b2fd1 100644 --- a/fluXis.Game/Map/MapEvents.cs +++ b/fluXis.Game/Map/MapEvents.cs @@ -28,9 +28,6 @@ public class MapEvents : IDeepCloneable [JsonProperty("playfieldscale")] public List PlayfieldScaleEvents { get; private set; } = new(); - [JsonProperty("playfieldfade")] - public List PlayfieldFadeEvents { get; private set; } = new(); - [JsonProperty("playfieldrotate")] public List PlayfieldRotateEvents { get; private set; } = new(); @@ -63,6 +60,16 @@ public class MapEvents : IDeepCloneable [Obsolete($"Use {nameof(LayerFadeEvents)} instead."), JsonProperty("hitfade")] public List LegacyHitObjectFade { set => LayerFadeEvents = LayerFadeEvents.Concat(value).ToList(); } + [Obsolete($"Use {nameof(LayerFadeEvents)} instead."), JsonProperty("playfieldfade")] + public List LegacyPlayfieldFade + { + set + { + value.ForEach(v => v.Layer = LayerFadeEvent.FadeLayer.Playfield); + LayerFadeEvents = LayerFadeEvents.Concat(value).ToList(); + } + } + #endregion [JsonIgnore] @@ -72,7 +79,6 @@ public class MapEvents : IDeepCloneable && PlayfieldMoveEvents.Count == 0 && PlayfieldScaleEvents.Count == 0 && PlayfieldRotateEvents.Count == 0 - && PlayfieldFadeEvents.Count == 0 && LayerFadeEvents.Count == 0 && HitObjectEaseEvents.Count == 0 && ShakeEvents.Count == 0 @@ -207,11 +213,12 @@ private MapEvents loadLegacy(string content) if (args.Length < 3) continue; - PlayfieldFadeEvents.Add(new PlayfieldFadeEvent + LayerFadeEvents.Add(new LayerFadeEvent() { Time = float.Parse(args[0], CultureInfo.InvariantCulture), Duration = float.Parse(args[1], CultureInfo.InvariantCulture), - Alpha = float.Parse(args[2], CultureInfo.InvariantCulture) + Alpha = float.Parse(args[2], CultureInfo.InvariantCulture), + Layer = LayerFadeEvent.FadeLayer.Playfield }); break; @@ -248,7 +255,6 @@ public MapEvents Sort() PulseEvents.Sort(compare); PlayfieldMoveEvents.Sort(compare); PlayfieldScaleEvents.Sort(compare); - PlayfieldFadeEvents.Sort(compare); LayerFadeEvents.Sort(compare); HitObjectEaseEvents.Sort(compare); ShakeEvents.Sort(compare); @@ -281,7 +287,6 @@ public MapEvents DeepClone() clone.PlayfieldMoveEvents = new List(PlayfieldMoveEvents); clone.PlayfieldScaleEvents = new List(PlayfieldScaleEvents); clone.PlayfieldRotateEvents = new List(PlayfieldRotateEvents); - clone.PlayfieldFadeEvents = new List(PlayfieldFadeEvents); clone.LayerFadeEvents = new List(LayerFadeEvents); clone.HitObjectEaseEvents = new List(HitObjectEaseEvents); clone.ShakeEvents = new List(ShakeEvents); diff --git a/fluXis.Game/Map/Structures/Events/LayerFadeEvent.cs b/fluXis.Game/Map/Structures/Events/LayerFadeEvent.cs index 606eb5de..3eff3048 100644 --- a/fluXis.Game/Map/Structures/Events/LayerFadeEvent.cs +++ b/fluXis.Game/Map/Structures/Events/LayerFadeEvent.cs @@ -1,10 +1,11 @@ using fluXis.Game.Map.Structures.Bases; +using fluXis.Game.Screens.Gameplay.Ruleset.Playfields; using Newtonsoft.Json; using osu.Framework.Graphics; namespace fluXis.Game.Map.Structures.Events; -public class LayerFadeEvent : IMapEvent, IHasDuration, IHasEasing +public class LayerFadeEvent : IMapEvent, IApplicableToPlayfield, IHasDuration, IHasEasing { [JsonProperty("time")] public double Time { get; set; } @@ -21,6 +22,9 @@ public class LayerFadeEvent : IMapEvent, IHasDuration, IHasEasing [JsonProperty("layer")] public FadeLayer Layer { get; set; } = FadeLayer.HitObjects; + [JsonProperty("playfield")] + public int PlayfieldIndex { get; set; } + public void Apply(Drawable drawable) { // make sure this is set, just in case it's missing @@ -35,6 +39,9 @@ public enum FadeLayer { HitObjects, Stage, - Receptors + Receptors, + Playfield } + + void IApplicableToPlayfield.Apply(Playfield playfield) => Apply(playfield); } diff --git a/fluXis.Game/Map/Structures/Events/PlayfieldFadeEvent.cs b/fluXis.Game/Map/Structures/Events/PlayfieldFadeEvent.cs deleted file mode 100644 index 3346892a..00000000 --- a/fluXis.Game/Map/Structures/Events/PlayfieldFadeEvent.cs +++ /dev/null @@ -1,30 +0,0 @@ -using fluXis.Game.Map.Structures.Bases; -using fluXis.Game.Screens.Gameplay.Ruleset.Playfields; -using Newtonsoft.Json; -using osu.Framework.Graphics; - -namespace fluXis.Game.Map.Structures.Events; - -public class PlayfieldFadeEvent : IMapEvent, IHasDuration, IHasEasing, IApplicableToPlayfield -{ - [JsonProperty("time")] - public double Time { get; set; } - - [JsonProperty("duration")] - public double Duration { get; set; } - - [JsonProperty("alpha")] - public float Alpha { get; set; } = 1; - - [JsonProperty("ease")] - public Easing Easing { get; set; } - - [JsonProperty("playfield")] - public int PlayfieldIndex { get; set; } - - public void Apply(Playfield playfield) - { - using (playfield.BeginAbsoluteSequence(Time)) - playfield.FadeTo(Alpha, Duration, Easing); - } -} diff --git a/fluXis.Game/Mods/NoEventMod.cs b/fluXis.Game/Mods/NoEventMod.cs index edbcf7db..6980cf14 100644 --- a/fluXis.Game/Mods/NoEventMod.cs +++ b/fluXis.Game/Mods/NoEventMod.cs @@ -22,7 +22,6 @@ public void Apply(MapEvents events) events.PulseEvents.Clear(); events.PlayfieldMoveEvents.Clear(); events.PlayfieldScaleEvents.Clear(); - events.PlayfieldFadeEvents.Clear(); events.PlayfieldRotateEvents.Clear(); events.LayerFadeEvents.Clear(); events.HitObjectEaseEvents.Clear(); diff --git a/fluXis.Game/Online/API/Models/Maps/MapEffectType.cs b/fluXis.Game/Online/API/Models/Maps/MapEffectType.cs index f0be7233..2dbbcecc 100644 --- a/fluXis.Game/Online/API/Models/Maps/MapEffectType.cs +++ b/fluXis.Game/Online/API/Models/Maps/MapEffectType.cs @@ -12,7 +12,10 @@ public enum MapEffectType : ulong PlayfieldMove = 1 << 4, PlayfieldScale = 1 << 5, PlayfieldRotate = 1 << 6, + + // UNUSED // PlayfieldFade = 1 << 7, + Shake = 1 << 8, Shader = 1 << 9, BeatPulse = 1 << 10, diff --git a/fluXis.Game/Screens/Edit/EditorMap.cs b/fluXis.Game/Screens/Edit/EditorMap.cs index a2d698c1..26849472 100644 --- a/fluXis.Game/Screens/Edit/EditorMap.cs +++ b/fluXis.Game/Screens/Edit/EditorMap.cs @@ -70,10 +70,6 @@ public class EditorMap public event Action ShakeEventRemoved; public event Action ShakeEventUpdated; - public event Action PlayfieldFadeEventAdded; - public event Action PlayfieldFadeEventRemoved; - public event Action PlayfieldFadeEventUpdated; - public event Action PlayfieldMoveEventAdded; public event Action PlayfieldMoveEventRemoved; public event Action PlayfieldMoveEventUpdated; @@ -127,7 +123,6 @@ public void SetupNotifiers() new ChangeNotifier(MapEvents.FlashEvents, obj => FlashEventAdded?.Invoke(obj), obj => FlashEventRemoved?.Invoke(obj), obj => FlashEventUpdated?.Invoke(obj)), new ChangeNotifier(MapEvents.PlayfieldMoveEvents, obj => PlayfieldMoveEventAdded?.Invoke(obj), obj => PlayfieldMoveEventRemoved?.Invoke(obj), obj => PlayfieldMoveEventUpdated?.Invoke(obj)), new ChangeNotifier(MapEvents.PlayfieldScaleEvents, obj => PlayfieldScaleEventAdded?.Invoke(obj), obj => PlayfieldScaleEventRemoved?.Invoke(obj), obj => PlayfieldScaleEventUpdated?.Invoke(obj)), - new ChangeNotifier(MapEvents.PlayfieldFadeEvents, obj => PlayfieldFadeEventAdded?.Invoke(obj), obj => PlayfieldFadeEventRemoved?.Invoke(obj), obj => PlayfieldFadeEventUpdated?.Invoke(obj)), new ChangeNotifier(MapEvents.PlayfieldRotateEvents, obj => PlayfieldRotateEventAdded?.Invoke(obj), obj => PlayfieldRotateEventRemoved?.Invoke(obj), obj => PlayfieldRotateEventUpdated?.Invoke(obj)), new ChangeNotifier(MapEvents.LayerFadeEvents, obj => LayerFadeEventAdded?.Invoke(obj), obj => LayerFadeEventRemoved?.Invoke(obj), obj => LayerFadeEventUpdated?.Invoke(obj)), new ChangeNotifier(MapEvents.HitObjectEaseEvents, obj => HitObjectEaseEventAdded?.Invoke(obj), obj => HitObjectEaseEventRemoved?.Invoke(obj), obj => HitObjectEaseEventUpdated?.Invoke(obj)), diff --git a/fluXis.Game/Screens/Edit/Tabs/Design/Playfield/EditorDesignPlayfield.cs b/fluXis.Game/Screens/Edit/Tabs/Design/Playfield/EditorDesignPlayfield.cs index 649f70e7..818fa7e3 100644 --- a/fluXis.Game/Screens/Edit/Tabs/Design/Playfield/EditorDesignPlayfield.cs +++ b/fluXis.Game/Screens/Edit/Tabs/Design/Playfield/EditorDesignPlayfield.cs @@ -1,5 +1,6 @@ using System.Linq; using fluXis.Game.Map.Structures.Bases; +using fluXis.Game.Map.Structures.Events; using fluXis.Game.Screens.Edit.Tabs.Shared.Lines; using fluXis.Game.Screens.Gameplay.Ruleset; using fluXis.Game.Skinning; @@ -127,7 +128,8 @@ private void updateRotation() private void updateAlpha() { - var current = map.MapEvents.PlayfieldFadeEvents.Where(applies).LastOrDefault(e => e.Time <= clock.CurrentTime); + var events = map.MapEvents.LayerFadeEvents.Where(x => x.Layer == LayerFadeEvent.FadeLayer.Playfield).Where(applies).ToList(); + var current = events.LastOrDefault(e => e.Time <= clock.CurrentTime); if (current == null) { @@ -144,7 +146,7 @@ private void updateAlpha() return; } - var previous = map.MapEvents.PlayfieldFadeEvents.Where(applies).LastOrDefault(e => e.Time < current.Time); + var previous = events.LastOrDefault(e => e.Time < current.Time); var start = previous?.Alpha ?? 1; if (progress < 0) diff --git a/fluXis.Game/Screens/Edit/Tabs/Design/Points/DesignPointsList.cs b/fluXis.Game/Screens/Edit/Tabs/Design/Points/DesignPointsList.cs index 3b7b86c2..617cbd08 100644 --- a/fluXis.Game/Screens/Edit/Tabs/Design/Points/DesignPointsList.cs +++ b/fluXis.Game/Screens/Edit/Tabs/Design/Points/DesignPointsList.cs @@ -21,11 +21,6 @@ protected override void RegisterEvents() Map.ShakeEventRemoved += RemovePoint; Map.MapEvents.ShakeEvents.ForEach(AddPoint); - Map.PlayfieldFadeEventAdded += AddPoint; - Map.PlayfieldFadeEventUpdated += UpdatePoint; - Map.PlayfieldFadeEventRemoved += RemovePoint; - Map.MapEvents.PlayfieldFadeEvents.ForEach(AddPoint); - Map.PlayfieldMoveEventAdded += AddPoint; Map.PlayfieldMoveEventUpdated += UpdatePoint; Map.PlayfieldMoveEventRemoved += RemovePoint; @@ -84,7 +79,6 @@ protected override PointListEntry CreateEntryFor(ITimedObject obj) FlashEvent flash => new FlashEntry(flash), ShakeEvent shake => new ShakeEntry(shake), PlayfieldMoveEvent move => new PlayfieldMoveEntry(move), - PlayfieldFadeEvent fade => new PlayfieldFadeEntry(fade), PlayfieldScaleEvent scale => new PlayfieldScaleEntry(scale), LayerFadeEvent fade => new LayerFadeEntry(fade), HitObjectEaseEvent ease => new HitObjectEaseEntry(ease), @@ -107,7 +101,6 @@ protected override IEnumerable CreateAddEntries() new("Playfield Move", FluXisColors.PlayfieldMove, () => Create(new PlayfieldMoveEvent())), new("Playfield Scale", FluXisColors.PlayfieldScale, () => Create(new PlayfieldScaleEvent())), new("Playfield Rotate", FluXisColors.PlayfieldRotate, () => Create(new PlayfieldRotateEvent())), - new("Playfield Fade", FluXisColors.PlayfieldFade, () => Create(new PlayfieldFadeEvent())), new("HitObject Ease", FluXisColors.HitObjectEase, () => Create(new HitObjectEaseEvent())), new("Layer Fade", FluXisColors.LayerFade, () => Create(new LayerFadeEvent())), new("Beat Pulse", FluXisColors.BeatPulse, () => Create(new BeatPulseEvent())), diff --git a/fluXis.Game/Screens/Edit/Tabs/Design/Points/Entries/PlayfieldFadeEntry.cs b/fluXis.Game/Screens/Edit/Tabs/Design/Points/Entries/PlayfieldFadeEntry.cs deleted file mode 100644 index 921f8995..00000000 --- a/fluXis.Game/Screens/Edit/Tabs/Design/Points/Entries/PlayfieldFadeEntry.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using fluXis.Game.Graphics.Sprites; -using fluXis.Game.Graphics.UserInterface.Color; -using fluXis.Game.Map.Structures.Bases; -using fluXis.Game.Map.Structures.Events; -using fluXis.Game.Screens.Edit.Tabs.Shared.Points.List; -using fluXis.Game.Screens.Edit.Tabs.Shared.Points.Settings; -using fluXis.Game.Screens.Edit.Tabs.Shared.Points.Settings.Preset; -using fluXis.Game.Utils; -using osu.Framework.Graphics; - -namespace fluXis.Game.Screens.Edit.Tabs.Design.Points.Entries; - -public partial class PlayfieldFadeEntry : PointListEntry -{ - protected override string Text => "Playfield Fade"; - protected override Colour4 Color => FluXisColors.PlayfieldFade; - - private PlayfieldFadeEvent fade => Object as PlayfieldFadeEvent; - - public PlayfieldFadeEntry(PlayfieldFadeEvent obj) - : base(obj) - { - } - - public override ITimedObject CreateClone() => new PlayfieldFadeEvent - { - Time = Object.Time, - Duration = fade.Duration, - Alpha = fade.Alpha - }; - - protected override Drawable[] CreateValueContent() - { - return new Drawable[] - { - new FluXisSpriteText - { - Text = $"{(fade.Alpha * 100).ToStringInvariant()}% {(int)fade.Duration}ms", - Colour = Color - } - }; - } - - protected override IEnumerable CreateSettings() - { - return base.CreateSettings().Concat(new Drawable[] - { - new PointSettingsLength(Map, fade, BeatLength), - new PointSettingsSlider - { - Text = "Alpha", - TooltipText = "The opacity of the playfield.", - CurrentValue = fade.Alpha, - Min = 0, - Max = 1, - OnValueChanged = v => - { - fade.Alpha = v; - Map.Update(fade); - } - }, - new PointSettingsEasing(Map, fade) - }); - } -} diff --git a/fluXis.Game/Screens/Gameplay/Ruleset/Playfields/Playfield.cs b/fluXis.Game/Screens/Gameplay/Ruleset/Playfields/Playfield.cs index 4a55c521..f18a866e 100644 --- a/fluXis.Game/Screens/Gameplay/Ruleset/Playfields/Playfield.cs +++ b/fluXis.Game/Screens/Gameplay/Ruleset/Playfields/Playfield.cs @@ -152,12 +152,12 @@ private void load(FluXisConfig config) screen.MapEvents.LayerFadeEvents.Where(x => x.Layer == LayerFadeEvent.FadeLayer.HitObjects).ForEach(e => e.Apply(Manager)); screen.MapEvents.LayerFadeEvents.Where(x => x.Layer == LayerFadeEvent.FadeLayer.Stage).ForEach(e => e.Apply(stage)); screen.MapEvents.LayerFadeEvents.Where(x => x.Layer == LayerFadeEvent.FadeLayer.Receptors).ForEach(e => e.Apply(Receptors)); + screen.MapEvents.LayerFadeEvents.Where(x => x.Layer == LayerFadeEvent.FadeLayer.Playfield).ForEach(e => e.Apply(this)); if (canSeek) { screen.MapEvents.PlayfieldMoveEvents.ForEach(e => e.Apply(this)); screen.MapEvents.PlayfieldScaleEvents.ForEach(e => e.Apply(this)); - screen.MapEvents.PlayfieldFadeEvents.ForEach(e => e.Apply(this)); screen.MapEvents.PlayfieldRotateEvents.ForEach(e => e.Apply(this)); screen.MapEvents.ScrollMultiplyEvents.ForEach(e => e.Apply(Manager)); screen.MapEvents.TimeOffsetEvents.ForEach(e => e.Apply(Manager)); @@ -168,7 +168,6 @@ private void load(FluXisConfig config) { new EventHandler(screen.MapEvents.PlayfieldMoveEvents), new EventHandler(screen.MapEvents.PlayfieldScaleEvents), - new EventHandler(screen.MapEvents.PlayfieldFadeEvents), new EventHandler(screen.MapEvents.PlayfieldRotateEvents), new EventHandler(screen.MapEvents.ScrollMultiplyEvents), new EventHandler(screen.MapEvents.TimeOffsetEvents), diff --git a/fluXis.Game/Screens/Select/List/Drawables/MapSet/DrawableMapSetDifficulty.cs b/fluXis.Game/Screens/Select/List/Drawables/MapSet/DrawableMapSetDifficulty.cs index 7e4a54fd..387a790e 100644 --- a/fluXis.Game/Screens/Select/List/Drawables/MapSet/DrawableMapSetDifficulty.cs +++ b/fluXis.Game/Screens/Select/List/Drawables/MapSet/DrawableMapSetDifficulty.cs @@ -324,9 +324,6 @@ private GimmickIcon[] getIcons() if (effects.HasFlag(MapEffectType.PlayfieldRotate)) icons.Add(new GimmickIcon(FluXisIconType.PlayfieldRotate, "Contains playfield rotates")); - if (effects.HasFlag(MapEffectType.PlayfieldFade)) - icons.Add(new GimmickIcon(FluXisIconType.PlayfieldFade, "Contains playfield fades")); - if (effects.HasFlag(MapEffectType.Shake)) icons.Add(new GimmickIcon(FluXisIconType.Shake, "Contains shakes")); diff --git a/fluXis.Game/Utils/MapUtils.cs b/fluXis.Game/Utils/MapUtils.cs index 220a1a41..e9bff80b 100644 --- a/fluXis.Game/Utils/MapUtils.cs +++ b/fluXis.Game/Utils/MapUtils.cs @@ -182,8 +182,8 @@ public static MapEffectType GetEffects(MapEvents events) if (events.PlayfieldRotateEvents.Count > 0) effects |= MapEffectType.PlayfieldRotate; - if (events.PlayfieldFadeEvents.Count > 0) - effects |= MapEffectType.PlayfieldFade; + /*if (events.PlayfieldFadeEvents.Count > 0) + effects |= MapEffectType.PlayfieldFade;*/ if (events.ShakeEvents.Count > 0) effects |= MapEffectType.Shake;