Skip to content

Commit

Permalink
Replace sprite HitObjectLines with CircularProgress
Browse files Browse the repository at this point in the history
  • Loading branch information
LumpBloom7 committed Nov 17, 2022
1 parent 9f8a70f commit 82e0f80
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 1,860 deletions.
363 changes: 0 additions & 363 deletions assets/HitObjectLines/135.svg

This file was deleted.

363 changes: 0 additions & 363 deletions assets/HitObjectLines/180.svg

This file was deleted.

363 changes: 0 additions & 363 deletions assets/HitObjectLines/225.svg

This file was deleted.

356 changes: 0 additions & 356 deletions assets/HitObjectLines/360.svg

This file was deleted.

363 changes: 0 additions & 363 deletions assets/HitObjectLines/90.svg

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Pooling;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Rulesets.Sentakki.Configuration;
using osuTK;

Expand All @@ -15,7 +16,8 @@ public class DrawableLine : PoolableDrawable

public LineLifetimeEntry Entry = null!;

public LineType Type;
private CircularProgress line = null!;

public DrawableLine()
{
RelativeSizeAxes = Axes.Both;
Expand All @@ -32,13 +34,15 @@ private void load(SentakkiRulesetConfigManager? sentakkiConfigs, TextureStore te
sentakkiConfigs?.BindWith(SentakkiRulesetSettings.AnimationDuration, animationDuration);
animationDuration.BindValueChanged(_ => resetAnimation());

AddInternal(new Sprite()
AddInternal(line = new CircularProgress()
{
RelativeSizeAxes = Axes.Both,
FillMode = FillMode.Fit,
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Texture = textures.Get(LineTexturePath)
InnerRadius = 0.026f,
RoundedCaps = true,
Alpha = 0.8f,
});
}

Expand All @@ -48,6 +52,7 @@ protected override void PrepareForUse()

Colour = Entry.Colour;
Rotation = Entry.Rotation;
line.Current.Value = Entry.AngleRange;
resetAnimation();
}

Expand All @@ -59,27 +64,5 @@ private void resetAnimation()
using (BeginAbsoluteSequence(Entry.StartTime - Entry.AdjustedAnimationDuration))
this.FadeIn(Entry.AdjustedAnimationDuration / 2).Then().ScaleTo(1, Entry.AdjustedAnimationDuration / 2).Then().FadeOut();
}

public string LineTexturePath
{
get
{
switch (Type)
{
case LineType.Single:
return "Lines/90";
case LineType.OneAway:
return "Lines/135";
case LineType.TwoAway:
return "Lines/180";
case LineType.ThreeAway:
return "Lines/225";
case LineType.FullCircle:
return "Lines/360";
default:
return "";
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public LineLifetimeEntry(BindableDouble AnimationDuration, DrawableSentakkiRules

public List<SentakkiLanedHitObject> HitObjects = new List<SentakkiLanedHitObject>();

public LineType Type { get; private set; }
public float AngleRange { get; private set; }
public ColourInfo Colour { get; private set; }
public float Rotation { get; private set; }

Expand Down Expand Up @@ -61,12 +61,12 @@ public void UpdateLine()
{
if (HitObjects.Count == 1)
{
Type = LineType.Single;
AngleRange = 0.25f;

var hitObject = HitObjects.First();

Colour = hitObject.Break ? Color4.OrangeRed : hitObject.DefaultNoteColour;
Rotation = hitObject.Lane.GetRotationForLane();
Rotation = hitObject.Lane.GetRotationForLane() - 45;
}
else if (HitObjects.Count > 1)
{
Expand All @@ -76,10 +76,13 @@ public void UpdateLine()
int delta = maxDelta - minDelta;

bool allBreaks = HitObjects.All(h => h.Break);

Type = getLineTypeForDistance(Math.Abs(delta));
Colour = Color4.Gold;
Rotation = anchor.Lane.GetRotationForLane() + (delta * 22.5f);

int angleRange = 90 + (45 * delta);

AngleRange = angleRange / 360f;

Rotation = anchor.Lane.GetRotationForLane() + (delta * 22.5f) - (angleRange / 2);
}

// Notify the renderer that the line may be updated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class LineRenderer : CompositeDrawable
private readonly Dictionary<LifetimeEntry, DrawableLine> linesInUse = new Dictionary<LifetimeEntry, DrawableLine>();
private readonly LifetimeEntryManager lifetimeManager = new LifetimeEntryManager();

private readonly Dictionary<LineType, DrawablePool<DrawableLine>> linePools = new Dictionary<LineType, DrawablePool<DrawableLine>>();
private DrawablePool<DrawableLine> linePool = null!;

public LineRenderer()
{
Expand All @@ -41,10 +41,7 @@ private void load(SentakkiRulesetConfigManager? sentakkiConfigs)
{
sentakkiConfigs?.BindWith(SentakkiRulesetSettings.AnimationDuration, animationDuration);

foreach (var type in Enum.GetValues(typeof(LineType)).OfType<LineType>())
linePools.Add(type, new DrawableLinePool(type));

AddRangeInternal(linePools.Values);
AddInternal(linePool = new DrawablePool<DrawableLine>(5));
}

protected override bool CheckChildrenLife()
Expand All @@ -57,7 +54,7 @@ protected override bool CheckChildrenLife()
private void onEntryBecameAlive(LifetimeEntry entry)
{
var laneLifetimeEntry = (LineLifetimeEntry)entry;
var line = linePools[laneLifetimeEntry.Type].Get();
var line = linePool.Get();
line.Entry = laneLifetimeEntry;

linesInUse[entry] = line;
Expand Down Expand Up @@ -133,19 +130,5 @@ private void addHitObjectToEntry(double entryTime, SentakkiLanedHitObject hitObj
}
lineEntries[entryTime].Add(hitObject);
}

public class DrawableLinePool : DrawablePool<DrawableLine>
{
private readonly LineType type;

public DrawableLinePool(LineType type)
: base(5)
{
this.type = type;
}

protected override DrawableLine CreateNewDrawable()
=> new DrawableLine { Type = type };
}
}
}

0 comments on commit 82e0f80

Please sign in to comment.