-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #339 from andy840119/pooling-playfield
Enable pooling for karaoke DHOs
- Loading branch information
Showing
12 changed files
with
239 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,22 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using osu.Framework.Bindables; | ||
using osu.Game.Rulesets.Judgements; | ||
using osu.Game.Rulesets.Objects; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.Objects | ||
{ | ||
public class BarLine : KaraokeHitObject, IBarLine | ||
{ | ||
public bool Major { get; set; } | ||
public bool Major | ||
{ | ||
get => MajorBindable.Value; | ||
set => MajorBindable.Value = value; | ||
} | ||
|
||
public readonly Bindable<bool> MajorBindable = new BindableBool(); | ||
|
||
public override Judgement CreateJudgement() => new IgnoreJudgement(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using JetBrains.Annotations; | ||
using osu.Framework.Allocation; | ||
using osu.Framework.Bindables; | ||
using osu.Framework.Graphics; | ||
using osu.Framework.Graphics.Containers; | ||
using osu.Framework.Graphics.Shapes; | ||
using osuTK; | ||
using osuTK.Graphics; | ||
|
@@ -24,46 +28,96 @@ public class DrawableBarLine : DrawableKaraokeScrollingHitObject<BarLine> | |
/// </summary> | ||
private const float triangle_offset = 9; | ||
|
||
public DrawableBarLine(BarLine barLine) | ||
/// <summary> | ||
/// The visual line tracker. | ||
/// </summary> | ||
private Box line; | ||
|
||
/// <summary> | ||
/// Container with triangles. Only visible for major lines. | ||
/// </summary> | ||
private Container triangleContainer; | ||
|
||
private readonly Bindable<bool> major = new Bindable<bool>(); | ||
|
||
public DrawableBarLine() | ||
: this(null) | ||
{ | ||
} | ||
|
||
public DrawableBarLine([CanBeNull] BarLine barLine) | ||
: base(barLine) | ||
{ | ||
} | ||
|
||
[BackgroundDependencyLoader] | ||
private void load() | ||
{ | ||
RelativeSizeAxes = Axes.Y; | ||
Width = 2f; | ||
|
||
AddInternal(new Box | ||
{ | ||
Name = "Bar line", | ||
Anchor = Anchor.CentreLeft, | ||
Origin = Anchor.CentreLeft, | ||
RelativeSizeAxes = Axes.Both, | ||
Colour = new Color4(255, 204, 33, 255), | ||
}); | ||
|
||
if (barLine.Major) | ||
AddRangeInternal(new Drawable[] | ||
{ | ||
AddInternal(new EquilateralTriangle | ||
line = new Box | ||
{ | ||
Name = "Up triangle", | ||
Anchor = Anchor.TopCentre, | ||
Origin = Anchor.Centre, | ||
Size = new Vector2(triangle_width), | ||
Y = -triangle_offset, | ||
Rotation = 180 | ||
}); | ||
|
||
AddInternal(new EquilateralTriangle | ||
Name = "Bar line", | ||
Anchor = Anchor.CentreLeft, | ||
Origin = Anchor.CentreLeft, | ||
RelativeSizeAxes = Axes.Both, | ||
Colour = new Color4(255, 204, 33, 255), | ||
}, | ||
triangleContainer = new Container | ||
{ | ||
Name = "Down triangle", | ||
Anchor = Anchor.BottomCentre, | ||
Anchor = Anchor.Centre, | ||
Origin = Anchor.Centre, | ||
Size = new Vector2(triangle_width), | ||
Y = triangle_offset, | ||
Rotation = 0 | ||
}); | ||
} | ||
|
||
if (!barLine.Major) | ||
Alpha = 0.2f; | ||
RelativeSizeAxes = Axes.Both, | ||
Children = new [] | ||
{ | ||
new EquilateralTriangle | ||
{ | ||
Name = "Up triangle", | ||
Anchor = Anchor.TopCentre, | ||
Origin = Anchor.Centre, | ||
Size = new Vector2(triangle_width), | ||
Y = -triangle_offset, | ||
Rotation = 180 | ||
}, | ||
new EquilateralTriangle | ||
{ | ||
Name = "Down triangle", | ||
Anchor = Anchor.BottomCentre, | ||
Origin = Anchor.Centre, | ||
Size = new Vector2(triangle_width), | ||
Y = triangle_offset, | ||
Rotation = 0 | ||
} | ||
} | ||
} | ||
}); | ||
} | ||
|
||
protected override void LoadComplete() | ||
{ | ||
base.LoadComplete(); | ||
major.BindValueChanged(updateMajor, true); | ||
} | ||
|
||
private void updateMajor(ValueChangedEvent<bool> major) | ||
{ | ||
line.Alpha = major.NewValue ? 1f : 0.75f; | ||
triangleContainer.Alpha = major.NewValue ? 1 : 0; | ||
} | ||
|
||
protected override void OnApply() | ||
{ | ||
base.OnApply(); | ||
major.BindTo(HitObject.MajorBindable); | ||
} | ||
|
||
protected override void OnFree() | ||
{ | ||
base.OnFree(); | ||
major.UnbindFrom(HitObject.MajorBindable); | ||
} | ||
|
||
protected override void UpdateInitialTransforms() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.