Skip to content

Commit

Permalink
merge PlayfieldFade into LayerFade
Browse files Browse the repository at this point in the history
  • Loading branch information
flustix committed Dec 14, 2024
1 parent 8d78a59 commit 15fe452
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 130 deletions.
1 change: 0 additions & 1 deletion fluXis.Game/Graphics/UserInterface/Color/FluXisColors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
21 changes: 13 additions & 8 deletions fluXis.Game/Map/MapEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ public class MapEvents : IDeepCloneable<MapEvents>
[JsonProperty("playfieldscale")]
public List<PlayfieldScaleEvent> PlayfieldScaleEvents { get; private set; } = new();

[JsonProperty("playfieldfade")]
public List<PlayfieldFadeEvent> PlayfieldFadeEvents { get; private set; } = new();

[JsonProperty("playfieldrotate")]
public List<PlayfieldRotateEvent> PlayfieldRotateEvents { get; private set; } = new();

Expand Down Expand Up @@ -63,6 +60,16 @@ public class MapEvents : IDeepCloneable<MapEvents>
[Obsolete($"Use {nameof(LayerFadeEvents)} instead."), JsonProperty("hitfade")]
public List<LayerFadeEvent> LegacyHitObjectFade { set => LayerFadeEvents = LayerFadeEvents.Concat(value).ToList(); }

[Obsolete($"Use {nameof(LayerFadeEvents)} instead."), JsonProperty("playfieldfade")]
public List<LayerFadeEvent> LegacyPlayfieldFade
{
set
{
value.ForEach(v => v.Layer = LayerFadeEvent.FadeLayer.Playfield);
LayerFadeEvents = LayerFadeEvents.Concat(value).ToList();
}
}

#endregion

[JsonIgnore]
Expand All @@ -72,7 +79,6 @@ public class MapEvents : IDeepCloneable<MapEvents>
&& PlayfieldMoveEvents.Count == 0
&& PlayfieldScaleEvents.Count == 0
&& PlayfieldRotateEvents.Count == 0
&& PlayfieldFadeEvents.Count == 0
&& LayerFadeEvents.Count == 0
&& HitObjectEaseEvents.Count == 0
&& ShakeEvents.Count == 0
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -281,7 +287,6 @@ public MapEvents DeepClone()
clone.PlayfieldMoveEvents = new List<PlayfieldMoveEvent>(PlayfieldMoveEvents);
clone.PlayfieldScaleEvents = new List<PlayfieldScaleEvent>(PlayfieldScaleEvents);
clone.PlayfieldRotateEvents = new List<PlayfieldRotateEvent>(PlayfieldRotateEvents);
clone.PlayfieldFadeEvents = new List<PlayfieldFadeEvent>(PlayfieldFadeEvents);
clone.LayerFadeEvents = new List<LayerFadeEvent>(LayerFadeEvents);
clone.HitObjectEaseEvents = new List<HitObjectEaseEvent>(HitObjectEaseEvents);
clone.ShakeEvents = new List<ShakeEvent>(ShakeEvents);
Expand Down
11 changes: 9 additions & 2 deletions fluXis.Game/Map/Structures/Events/LayerFadeEvent.cs
Original file line number Diff line number Diff line change
@@ -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; }
Expand All @@ -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
Expand All @@ -35,6 +39,9 @@ public enum FadeLayer
{
HitObjects,
Stage,
Receptors
Receptors,
Playfield
}

void IApplicableToPlayfield.Apply(Playfield playfield) => Apply(playfield);
}
30 changes: 0 additions & 30 deletions fluXis.Game/Map/Structures/Events/PlayfieldFadeEvent.cs

This file was deleted.

1 change: 0 additions & 1 deletion fluXis.Game/Mods/NoEventMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions fluXis.Game/Online/API/Models/Maps/MapEffectType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 0 additions & 5 deletions fluXis.Game/Screens/Edit/EditorMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ public class EditorMap
public event Action<ShakeEvent> ShakeEventRemoved;
public event Action<ShakeEvent> ShakeEventUpdated;

public event Action<PlayfieldFadeEvent> PlayfieldFadeEventAdded;
public event Action<PlayfieldFadeEvent> PlayfieldFadeEventRemoved;
public event Action<PlayfieldFadeEvent> PlayfieldFadeEventUpdated;

public event Action<PlayfieldMoveEvent> PlayfieldMoveEventAdded;
public event Action<PlayfieldMoveEvent> PlayfieldMoveEventRemoved;
public event Action<PlayfieldMoveEvent> PlayfieldMoveEventUpdated;
Expand Down Expand Up @@ -127,7 +123,6 @@ public void SetupNotifiers()
new ChangeNotifier<FlashEvent>(MapEvents.FlashEvents, obj => FlashEventAdded?.Invoke(obj), obj => FlashEventRemoved?.Invoke(obj), obj => FlashEventUpdated?.Invoke(obj)),
new ChangeNotifier<PlayfieldMoveEvent>(MapEvents.PlayfieldMoveEvents, obj => PlayfieldMoveEventAdded?.Invoke(obj), obj => PlayfieldMoveEventRemoved?.Invoke(obj), obj => PlayfieldMoveEventUpdated?.Invoke(obj)),
new ChangeNotifier<PlayfieldScaleEvent>(MapEvents.PlayfieldScaleEvents, obj => PlayfieldScaleEventAdded?.Invoke(obj), obj => PlayfieldScaleEventRemoved?.Invoke(obj), obj => PlayfieldScaleEventUpdated?.Invoke(obj)),
new ChangeNotifier<PlayfieldFadeEvent>(MapEvents.PlayfieldFadeEvents, obj => PlayfieldFadeEventAdded?.Invoke(obj), obj => PlayfieldFadeEventRemoved?.Invoke(obj), obj => PlayfieldFadeEventUpdated?.Invoke(obj)),
new ChangeNotifier<PlayfieldRotateEvent>(MapEvents.PlayfieldRotateEvents, obj => PlayfieldRotateEventAdded?.Invoke(obj), obj => PlayfieldRotateEventRemoved?.Invoke(obj), obj => PlayfieldRotateEventUpdated?.Invoke(obj)),
new ChangeNotifier<LayerFadeEvent>(MapEvents.LayerFadeEvents, obj => LayerFadeEventAdded?.Invoke(obj), obj => LayerFadeEventRemoved?.Invoke(obj), obj => LayerFadeEventUpdated?.Invoke(obj)),
new ChangeNotifier<HitObjectEaseEvent>(MapEvents.HitObjectEaseEvents, obj => HitObjectEaseEventAdded?.Invoke(obj), obj => HitObjectEaseEventRemoved?.Invoke(obj), obj => HitObjectEaseEventUpdated?.Invoke(obj)),
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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)
{
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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),
Expand All @@ -107,7 +101,6 @@ protected override IEnumerable<AddButtonEntry> 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())),
Expand Down

This file was deleted.

3 changes: 1 addition & 2 deletions fluXis.Game/Screens/Gameplay/Ruleset/Playfields/Playfield.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -168,7 +168,6 @@ private void load(FluXisConfig config)
{
new EventHandler<PlayfieldMoveEvent>(screen.MapEvents.PlayfieldMoveEvents),
new EventHandler<PlayfieldScaleEvent>(screen.MapEvents.PlayfieldScaleEvents),
new EventHandler<PlayfieldFadeEvent>(screen.MapEvents.PlayfieldFadeEvents),
new EventHandler<PlayfieldRotateEvent>(screen.MapEvents.PlayfieldRotateEvents),
new EventHandler<ScrollMultiplierEvent>(screen.MapEvents.ScrollMultiplyEvents),
new EventHandler<TimeOffsetEvent>(screen.MapEvents.TimeOffsetEvents),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"));

Expand Down
4 changes: 2 additions & 2 deletions fluXis.Game/Utils/MapUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 15fe452

Please sign in to comment.