Fix incorrect default state. Handle input better.

This commit is contained in:
Dean Herbert
2017-04-14 14:40:52 +09:00
parent 09195a03a2
commit 8c41707ac7
4 changed files with 43 additions and 414 deletions

View File

@ -11,7 +11,7 @@ using osu.Framework.Allocation;
namespace osu.Game.Screens.Play
{
public class SongProgress : OverlayContainer
public class SongProgress : OverlayContainer
{
private const int progress_height = 5;
@ -51,6 +51,7 @@ namespace osu.Game.Screens.Play
{
RelativeSizeAxes = Axes.X;
Height = progress_height + SongProgressGraph.Column.HEIGHT + handle_size.Y;
Y = progress_height;
Children = new Drawable[]
{
@ -64,8 +65,9 @@ namespace osu.Game.Screens.Play
},
bar = new SongProgressBar(progress_height, SongProgressGraph.Column.HEIGHT, handle_size)
{
Origin = Anchor.BottomLeft,
Alpha = 0,
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
SeekRequested = delegate (float position)
{
OnSeek?.Invoke(position);
@ -74,26 +76,40 @@ namespace osu.Game.Screens.Play
};
}
protected override void LoadComplete()
{
State = Visibility.Visible;
}
private void updateProgress()
{
bar.UpdatePosition((float)progress);
graph.Progress = (int)(graph.ColumnCount * progress);
}
private bool barVisible;
public void ToggleBar()
{
barVisible = !barVisible;
updateBarVisibility();
}
private void updateBarVisibility()
{
bar.FadeTo(barVisible ? 1 : 0, transition_duration, EasingTypes.In);
MoveTo(new Vector2(0, barVisible ? 0 : progress_height), transition_duration, EasingTypes.In);
}
protected override void PopIn()
{
bar.IsEnabled = true;
updateProgress(); //in case progress was changed while the bar was hidden
bar.FadeIn(transition_duration, EasingTypes.In);
MoveTo(Vector2.Zero, transition_duration, EasingTypes.In);
updateBarVisibility();
FadeIn(100);
}
protected override void PopOut()
{
bar.IsEnabled = false;
bar.FadeOut(transition_duration, EasingTypes.In);
MoveTo(new Vector2(0f, progress_height), transition_duration, EasingTypes.In);
FadeOut(100);
}
protected override void Update()

View File

@ -14,18 +14,20 @@ namespace osu.Game.Screens.Play
{
public Color4 FillColour
{
get { return FillContainer.Colour; }
set { FillContainer.Colour = value; }
get { return Fill.Colour; }
set { Fill.Colour = value; }
}
public SongProgressBar(float barHeight, float handleBarHeight, Vector2 handleSize)
{
Height = barHeight + handleBarHeight + handleSize.Y;
FillContainer.RelativeSizeAxes = Axes.X;
FillContainer.Height = barHeight;
Fill.RelativeSizeAxes = Axes.X;
Fill.Height = barHeight;
Add(new Box
{
Name = "Background",
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
RelativeSizeAxes = Axes.X,
@ -34,7 +36,8 @@ namespace osu.Game.Screens.Play
Alpha = 0.5f,
Depth = 1
});
FillContainer.Add(new Container
Fill.Add(new Container
{
Origin = Anchor.BottomRight,
Anchor = Anchor.BottomRight,