Skip to content

Commit

Permalink
Merge pull request #416 from LumpBloom7/Non-sprite-HitObjectLines
Browse files Browse the repository at this point in the history
Use CircularProgress instead of Texture for HitObjectLines
  • Loading branch information
LumpBloom7 authored Nov 17, 2022
2 parents 5bb854e + 6c7ea8f commit 3995c23
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 1,892 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
Expand Up @@ -2,8 +2,7 @@
using osu.Framework.Bindables;
using osu.Framework.Graphics;
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 +14,8 @@ public class DrawableLine : PoolableDrawable

public LineLifetimeEntry Entry = null!;

public LineType Type;
private CircularProgress line = null!;

public DrawableLine()
{
RelativeSizeAxes = Axes.Both;
Expand All @@ -27,18 +27,20 @@ public DrawableLine()
private readonly BindableDouble animationDuration = new BindableDouble(1000);

[BackgroundDependencyLoader]
private void load(SentakkiRulesetConfigManager? sentakkiConfigs, TextureStore textures)
private void load(SentakkiRulesetConfigManager? sentakkiConfigs)
{
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 +50,7 @@ protected override void PrepareForUse()

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

Expand All @@ -59,27 +62,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 @@ -12,7 +12,7 @@ namespace osu.Game.Rulesets.Sentakki.UI.Components.HitObjectLine
{
public class LineLifetimeEntry : LifetimeEntry
{
public BindableDouble AnimationDuration = new BindableDouble(1000);
private readonly BindableDouble AnimationDuration = new BindableDouble(1000);
public double AdjustedAnimationDuration => AnimationDuration.Value * GameplaySpeed;

public double GameplaySpeed => drawableRuleset?.GameplaySpeed ?? 1;
Expand All @@ -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 All @@ -92,23 +95,6 @@ private void refreshLifetime(ValueChangedEvent<double> valueChangedEvent)
LifetimeEnd = StartTime;
}

private static LineType getLineTypeForDistance(int distance)
{
switch (distance)
{
case 0:
return LineType.Single;
case 1:
return LineType.OneAway;
case 2:
return LineType.TwoAway;
case 3:
return LineType.ThreeAway;
default:
return LineType.FullCircle;
}
}

private static int getDelta(SentakkiLanedHitObject a, SentakkiLanedHitObject b)
{
int delta = b.Lane - a.Lane;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
Expand All @@ -21,7 +20,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 +40,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 +53,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 +129,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 };
}
}
}
11 changes: 0 additions & 11 deletions osu.Game.Rulesets.Sentakki/UI/Components/HitObjectLine/LineType.cs

This file was deleted.

0 comments on commit 3995c23

Please sign in to comment.