Skip to content

Commit

Permalink
Refactor "HitObjectFade" into "LayerFade" and make it support more th…
Browse files Browse the repository at this point in the history
…an just hitobjects
  • Loading branch information
flustix committed Dec 4, 2024
1 parent a6c9346 commit 56e31ea
Show file tree
Hide file tree
Showing 14 changed files with 162 additions and 117 deletions.
2 changes: 1 addition & 1 deletion fluXis.Game/Graphics/Sprites/FluXisIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public enum FluXisIconType
Shake,
Shader,
BeatPulse,
HitObjectFade,
LayerFade,
HitObjectEase,
ScrollMultiply,
TimeOffset
Expand Down
2 changes: 1 addition & 1 deletion fluXis.Game/Graphics/UserInterface/Color/FluXisColors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public static class FluXisColors
public static Colour4 PlayfieldScale => Colour4.FromHex("#D279C4");
public static Colour4 PlayfieldRotate => Colour4.FromHex("#8AF7A2");
public static Colour4 PlayfieldFade => Colour4.FromHex("#0180FE");
public static Colour4 HitObjectFade => Colour4.FromHex("#8AF3F7");
public static Colour4 HitObjectEase => Colour4.FromHex("#5B92FF");
public static Colour4 LayerFade => Colour4.FromHex("#8AF3F7");
public static Colour4 BeatPulse => Colour4.FromHex("#FF6666");
public static Colour4 ScrollMultiply => Colour4.FromHex("#c73673");
public static Colour4 TimeOffset => Colour4.FromHex("#fa8ca1");
Expand Down
20 changes: 14 additions & 6 deletions fluXis.Game/Map/MapEvents.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using fluXis.Game.Map.Structures.Bases;
using fluXis.Game.Map.Structures.Events;
using fluXis.Shared.Utils;
Expand Down Expand Up @@ -33,12 +34,12 @@ public class MapEvents : IDeepCloneable<MapEvents>
[JsonProperty("playfieldrotate")]
public List<PlayfieldRotateEvent> PlayfieldRotateEvents { get; private set; } = new();

[JsonProperty("hitfade")]
public List<HitObjectFadeEvent> HitObjectFadeEvents { get; private set; } = new();

[JsonProperty("hitease")]
public List<HitObjectEaseEvent> HitObjectEaseEvents { get; private set; } = new();

[JsonProperty("layerfade")]
public List<LayerFadeEvent> LayerFadeEvents { get; private set; } = new();

[JsonProperty("shake")]
public List<ShakeEvent> ShakeEvents { get; private set; } = new();

Expand All @@ -57,6 +58,13 @@ public class MapEvents : IDeepCloneable<MapEvents>
[JsonProperty("notes")]
public List<NoteEvent> NoteEvents { get; private set; } = new();

#region Old Prop Names

[Obsolete($"Use {nameof(LayerFadeEvents)} instead."), JsonProperty("hitfade")]
public List<LayerFadeEvent> LegacyHitObjectFade { set => LayerFadeEvents = LayerFadeEvents.Concat(value).ToList(); }

#endregion

[JsonIgnore]
public bool Empty => LaneSwitchEvents.Count == 0
&& FlashEvents.Count == 0
Expand All @@ -65,7 +73,7 @@ public class MapEvents : IDeepCloneable<MapEvents>
&& PlayfieldScaleEvents.Count == 0
&& PlayfieldRotateEvents.Count == 0
&& PlayfieldFadeEvents.Count == 0
&& HitObjectFadeEvents.Count == 0
&& LayerFadeEvents.Count == 0
&& HitObjectEaseEvents.Count == 0
&& ShakeEvents.Count == 0
&& ShaderEvents.Count == 0
Expand Down Expand Up @@ -233,7 +241,7 @@ public MapEvents Sort()
PlayfieldMoveEvents.Sort(compare);
PlayfieldScaleEvents.Sort(compare);
PlayfieldFadeEvents.Sort(compare);
HitObjectFadeEvents.Sort(compare);
LayerFadeEvents.Sort(compare);
HitObjectEaseEvents.Sort(compare);
ShakeEvents.Sort(compare);
ShaderEvents.Sort(compare);
Expand Down Expand Up @@ -266,7 +274,7 @@ public MapEvents DeepClone()
clone.PlayfieldScaleEvents = new List<PlayfieldScaleEvent>(PlayfieldScaleEvents);
clone.PlayfieldRotateEvents = new List<PlayfieldRotateEvent>(PlayfieldRotateEvents);
clone.PlayfieldFadeEvents = new List<PlayfieldFadeEvent>(PlayfieldFadeEvents);
clone.HitObjectFadeEvents = new List<HitObjectFadeEvent>(HitObjectFadeEvents);
clone.LayerFadeEvents = new List<LayerFadeEvent>(LayerFadeEvents);
clone.HitObjectEaseEvents = new List<HitObjectEaseEvent>(HitObjectEaseEvents);
clone.ShakeEvents = new List<ShakeEvent>(ShakeEvents);
clone.ShaderEvents = new List<ShaderEvent>(ShaderEvents);
Expand Down
20 changes: 0 additions & 20 deletions fluXis.Game/Map/Structures/Events/HitObjectFadeEvent.cs

This file was deleted.

40 changes: 40 additions & 0 deletions fluXis.Game/Map/Structures/Events/LayerFadeEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using fluXis.Game.Map.Structures.Bases;
using Newtonsoft.Json;
using osu.Framework.Graphics;

namespace fluXis.Game.Map.Structures.Events;

public class LayerFadeEvent : IMapEvent, IHasDuration, IHasEasing
{
[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("layer")]
public FadeLayer Layer { get; set; } = FadeLayer.HitObjects;

public void Apply(Drawable drawable)
{
// make sure this is set, just in case it's missing
if (Alpha <= 0.0001f)
drawable.AlwaysPresent = true;

using (drawable.BeginAbsoluteSequence(Time))
drawable.FadeTo(Alpha, Duration, Easing);
}

public enum FadeLayer
{
HitObjects,
Stage,
Receptors
}
}
2 changes: 1 addition & 1 deletion fluXis.Game/Mods/NoEventMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void Apply(MapEvents events)
events.PlayfieldScaleEvents.Clear();
events.PlayfieldFadeEvents.Clear();
events.PlayfieldRotateEvents.Clear();
events.HitObjectFadeEvents.Clear();
events.LayerFadeEvents.Clear();
events.HitObjectEaseEvents.Clear();
events.ShakeEvents.Clear();
events.ShaderEvents.Clear();
Expand Down
10 changes: 5 additions & 5 deletions fluXis.Game/Screens/Edit/EditorMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ public class EditorMap
public event Action<PlayfieldScaleEvent> PlayfieldScaleEventRemoved;
public event Action<PlayfieldScaleEvent> PlayfieldScaleEventUpdated;

public event Action<HitObjectFadeEvent> HitObjectFadeEventAdded;
public event Action<HitObjectFadeEvent> HitObjectFadeEventRemoved;
public event Action<HitObjectFadeEvent> HitObjectFadeEventUpdated;

public event Action<HitObjectEaseEvent> HitObjectEaseEventAdded;
public event Action<HitObjectEaseEvent> HitObjectEaseEventRemoved;
public event Action<HitObjectEaseEvent> HitObjectEaseEventUpdated;

public event Action<LayerFadeEvent> LayerFadeEventAdded;
public event Action<LayerFadeEvent> LayerFadeEventRemoved;
public event Action<LayerFadeEvent> LayerFadeEventUpdated;

public event Action<ShaderEvent> ShaderEventAdded;
public event Action<ShaderEvent> ShaderEventRemoved;
public event Action<ShaderEvent> ShaderEventUpdated;
Expand Down Expand Up @@ -130,7 +130,7 @@ public void SetupNotifiers()
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<HitObjectFadeEvent>(MapEvents.HitObjectFadeEvents, obj => HitObjectFadeEventAdded?.Invoke(obj), obj => HitObjectFadeEventRemoved?.Invoke(obj), obj => HitObjectFadeEventUpdated?.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)),
new ChangeNotifier<ShakeEvent>(MapEvents.ShakeEvents, obj => ShakeEventAdded?.Invoke(obj), obj => ShakeEventRemoved?.Invoke(obj), obj => ShakeEventUpdated?.Invoke(obj)),
new ChangeNotifier<ShaderEvent>(MapEvents.ShaderEvents, obj => ShaderEventAdded?.Invoke(obj), obj => ShaderEventRemoved?.Invoke(obj), obj => ShaderEventUpdated?.Invoke(obj)),
Expand Down
14 changes: 7 additions & 7 deletions fluXis.Game/Screens/Edit/Tabs/Design/Points/DesignPointsList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ protected override void RegisterEvents()
Map.PlayfieldScaleEventRemoved += RemovePoint;
Map.MapEvents.PlayfieldScaleEvents.ForEach(AddPoint);

Map.HitObjectFadeEventAdded += AddPoint;
Map.HitObjectFadeEventUpdated += UpdatePoint;
Map.HitObjectFadeEventRemoved += RemovePoint;
Map.MapEvents.HitObjectFadeEvents.ForEach(AddPoint);

Map.HitObjectEaseEventAdded += AddPoint;
Map.HitObjectEaseEventUpdated += UpdatePoint;
Map.HitObjectEaseEventRemoved += RemovePoint;
Map.MapEvents.HitObjectEaseEvents.ForEach(AddPoint);

Map.LayerFadeEventAdded += AddPoint;
Map.LayerFadeEventUpdated += UpdatePoint;
Map.LayerFadeEventRemoved += RemovePoint;
Map.MapEvents.LayerFadeEvents.ForEach(AddPoint);

Map.ShaderEventAdded += AddPoint;
Map.ShaderEventUpdated += UpdatePoint;
Map.ShaderEventRemoved += RemovePoint;
Expand Down Expand Up @@ -86,7 +86,7 @@ protected override PointListEntry CreateEntryFor(ITimedObject obj)
PlayfieldMoveEvent move => new PlayfieldMoveEntry(move),
PlayfieldFadeEvent fade => new PlayfieldFadeEntry(fade),
PlayfieldScaleEvent scale => new PlayfieldScaleEntry(scale),
HitObjectFadeEvent fade => new HitObjectFadeEntry(fade),
LayerFadeEvent fade => new LayerFadeEntry(fade),
HitObjectEaseEvent ease => new HitObjectEaseEntry(ease),
BeatPulseEvent pulse => new BeatPulseEntry(pulse),
PlayfieldRotateEvent rotate => new PlayfieldRotateEntry(rotate),
Expand All @@ -108,8 +108,8 @@ protected override IEnumerable<AddButtonEntry> CreateAddEntries()
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 Fade", FluXisColors.HitObjectFade, () => Create(new HitObjectFadeEvent())),
new("HitObject Ease", FluXisColors.HitObjectEase, () => Create(new HitObjectEaseEvent())),
new("Layer Fade", FluXisColors.LayerFade, () => Create(new LayerFadeEvent())),
new("Beat Pulse", FluXisColors.BeatPulse, () => Create(new BeatPulseEvent())),
new("Shader", FluXisColors.Shader, () => Create(new ShaderEvent { ShaderName = "Bloom" })),
new("Scroll Multiplier", FluXisColors.ScrollMultiply, () => Create(new ScrollMultiplierEvent())),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
using System;
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 LayerFadeEntry : PointListEntry
{
protected override string Text => "Layer Fade";
protected override Colour4 Color => FluXisColors.LayerFade;

private LayerFadeEvent fade => Object as LayerFadeEvent;

public LayerFadeEntry(LayerFadeEvent obj)
: base(obj)
{
}

public override ITimedObject CreateClone() => new LayerFadeEvent
{
Time = Object.Time,
Duration = fade.Duration,
Alpha = fade.Alpha,
Easing = fade.Easing,
Layer = fade.Layer
};

protected override Drawable[] CreateValueContent() => new Drawable[]
{
new FluXisSpriteText
{
Text = $"{fade.Layer.ToString()} {(fade.Alpha * 100).ToStringInvariant()}% {(int)fade.Duration}ms",
Colour = Color
}
};

protected override IEnumerable<Drawable> CreateSettings()
{
return base.CreateSettings().Concat(new Drawable[]
{
new PointSettingsLength<LayerFadeEvent>(Map, fade, BeatLength),
new PointSettingsSlider<float>
{
Text = "Alpha",
TooltipText = "The opacity of the hitobjects.",
CurrentValue = fade.Alpha,
Min = 0,
Max = 1,
OnValueChanged = v =>
{
fade.Alpha = v;
Map.Update(fade);
}
},
new PointSettingsEasing<LayerFadeEvent>(Map, fade),
new PointSettingsDropdown<LayerFadeEvent.FadeLayer>
{
Text = "Layer",
TooltipText = "The layer to adjust the opacity of.",
CurrentValue = fade.Layer,
Items = Enum.GetValues<LayerFadeEvent.FadeLayer>().ToList(),
OnValueChanged = value =>
{
fade.Layer = value;
Map.Update(fade);
}
}
});
}
}
Loading

0 comments on commit 56e31ea

Please sign in to comment.