1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-12 01:07:25 +08:00
This commit is contained in:
DrabWeb 2017-09-12 21:24:43 -03:00
parent d09bcabc8f
commit 680f2e232c
6 changed files with 185 additions and 180 deletions

View File

@ -15,7 +15,7 @@ namespace osu.Game.Overlays.OnlineBeatmapSet
{
public class BasicStats : Container
{
private readonly Statistic length, bpm, circleCount, sliderCount;
private readonly Statistic length, circleCount, sliderCount;
private BeatmapInfo beatmap;
public BeatmapInfo Beatmap
@ -43,7 +43,7 @@ namespace osu.Game.Overlays.OnlineBeatmapSet
Children = new[]
{
length = new Statistic(FontAwesome.fa_clock_o, "Length") { Width = statWidth },
bpm = new Statistic(FontAwesome.fa_circle, "BPM")
new Statistic(FontAwesome.fa_circle, "BPM")
{
Width = statWidth,
Value = set.OnlineInfo.BPM.ToString(@"0.##"),

View File

@ -152,7 +152,6 @@ namespace osu.Game.Overlays.OnlineBeatmapSet
public BeatmapTile(BeatmapInfo beatmap, Bindable<BeatmapInfo> bindable)
{
this.beatmap = beatmap;
this.bindable.BindTo(bindable);
Size = new Vector2(size);
Margin = new MarginPadding { Horizontal = tile_spacing / 2 };
@ -179,7 +178,8 @@ namespace osu.Game.Overlays.OnlineBeatmapSet
};
Action = () => this.bindable.Value = beatmap;
this.bindable.ValueChanged += bindable_ValueChanged;
this.bindable.ValueChanged += beatmapChanged;
this.bindable.BindTo(bindable);
}
protected override bool OnHover(InputState state)
@ -193,9 +193,10 @@ namespace osu.Game.Overlays.OnlineBeatmapSet
{
if (bindable.Value != beatmap)
fadeOut();
base.OnHoverLost(state);
}
private void bindable_ValueChanged(BeatmapInfo value)
private void beatmapChanged(BeatmapInfo value)
{
if (value == beatmap)
fadeIn();

View File

@ -55,9 +55,18 @@ namespace osu.Game.Overlays.OnlineBeatmapSet
Favourited.ValueChanged += value =>
{
pink.FadeTo(value ? 1 : 0, 200);
icon.Icon = value ? FontAwesome.fa_heart : FontAwesome.fa_heart_o;
if (value)
{
pink.FadeIn(200);
icon.Icon = FontAwesome.fa_heart;
}
else
{
pink.FadeOut(200);
icon.Icon = FontAwesome.fa_heart_o;
}
};
Action = () => Favourited.Value = !Favourited.Value;
}

View File

@ -14,32 +14,32 @@ namespace osu.Game.Overlays.OnlineBeatmapSet
{
private readonly Container content;
protected override Container<Drawable> Content => content;
protected override Container<Drawable> Content => content;
public HeaderButton()
public HeaderButton()
{
CornerRadius = 3;
Masking = true;
InternalChildren = new Drawable[]
{
CornerRadius = 3;
Masking = true;
InternalChildren = new Drawable[]
new Box
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = OsuColour.FromHex(@"094c5f"),
},
new Triangles
{
RelativeSizeAxes = Axes.Both,
ColourLight = OsuColour.FromHex(@"0f7c9b"),
ColourDark = OsuColour.FromHex(@"094c5f"),
TriangleScale = 1.5f,
},
content = new Container
{
RelativeSizeAxes = Axes.Both,
},
};
}
RelativeSizeAxes = Axes.Both,
Colour = OsuColour.FromHex(@"094c5f"),
},
new Triangles
{
RelativeSizeAxes = Axes.Both,
ColourLight = OsuColour.FromHex(@"0f7c9b"),
ColourDark = OsuColour.FromHex(@"094c5f"),
TriangleScale = 1.5f,
},
content = new Container
{
RelativeSizeAxes = Axes.Both,
},
};
}
}
}

View File

@ -1,143 +1,144 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Track;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
namespace osu.Game.Overlays.OnlineBeatmapSet
{
public class PreviewButton : OsuClickableContainer
{
private readonly BeatmapSetInfo set;
private readonly Box bg, progress;
private readonly SpriteIcon icon;
private AudioManager audio;
private Track preview;
private bool playing = false;
public bool Playing
{
get { return playing; }
set
{
if (value == playing) return;
playing = value;
if (Playing)
{
icon.Icon = FontAwesome.fa_stop;
progress.FadeIn(100);
loadPreview();
preview.Start();
}
else
{
icon.Icon = FontAwesome.fa_play;
progress.FadeOut(100);
preview.Stop();
}
}
}
public PreviewButton(BeatmapSetInfo set)
{
this.set = set;
Height = 42;
Children = new Drawable[]
{
bg = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black.Opacity(0.25f),
},
new Container
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
RelativeSizeAxes = Axes.X,
Height = 3,
Child = progress = new Box
{
RelativeSizeAxes = Axes.Both,
Width = 0f,
Alpha = 0f,
},
},
icon = new SpriteIcon
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Icon = FontAwesome.fa_play,
Size = new Vector2(18),
Shadow = false,
},
};
Action = () => Playing = !Playing;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours, AudioManager audio)
{
this.audio = audio;
progress.Colour = colours.Yellow;
loadPreview();
}
protected override void Update()
{
base.Update();
if (Playing)
{
progress.Width = (float)(preview.CurrentTime / preview.Length);
if (preview.HasCompleted) Playing = false;
}
}
protected override void Dispose(bool isDisposing)
{
Playing = false;
base.Dispose(isDisposing);
}
protected override bool OnHover(InputState state)
{
bg.FadeColour(Color4.Black.Opacity(0.5f), 100);
return base.OnHover(state);
}
protected override void OnHoverLost(InputState state)
{
bg.FadeColour(Color4.Black.Opacity(0.25f), 100);
}
private void loadPreview()
{
if (preview?.HasCompleted ?? true)
{
preview = audio.Track.Get(set.OnlineInfo.Preview);
preview.Volume.Value = 0.5;
}
else
{
preview.Seek(0);
}
}
}
}
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Track;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
namespace osu.Game.Overlays.OnlineBeatmapSet
{
public class PreviewButton : OsuClickableContainer
{
private readonly BeatmapSetInfo set;
private readonly Box bg, progress;
private readonly SpriteIcon icon;
private AudioManager audio;
private Track preview;
private bool playing;
public bool Playing
{
get { return playing; }
set
{
if (value == playing) return;
playing = value;
if (Playing)
{
icon.Icon = FontAwesome.fa_stop;
progress.FadeIn(100);
loadPreview();
preview.Start();
}
else
{
icon.Icon = FontAwesome.fa_play;
progress.FadeOut(100);
preview.Stop();
}
}
}
public PreviewButton(BeatmapSetInfo set)
{
this.set = set;
Height = 42;
Children = new Drawable[]
{
bg = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black.Opacity(0.25f),
},
new Container
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
RelativeSizeAxes = Axes.X,
Height = 3,
Child = progress = new Box
{
RelativeSizeAxes = Axes.Both,
Width = 0f,
Alpha = 0f,
},
},
icon = new SpriteIcon
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Icon = FontAwesome.fa_play,
Size = new Vector2(18),
Shadow = false,
},
};
Action = () => Playing = !Playing;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours, AudioManager audio)
{
this.audio = audio;
progress.Colour = colours.Yellow;
loadPreview();
}
protected override void Update()
{
base.Update();
if (Playing)
{
progress.Width = (float)(preview.CurrentTime / preview.Length);
if (preview.HasCompleted) Playing = false;
}
}
protected override void Dispose(bool isDisposing)
{
Playing = false;
base.Dispose(isDisposing);
}
protected override bool OnHover(InputState state)
{
bg.FadeColour(Color4.Black.Opacity(0.5f), 100);
return base.OnHover(state);
}
protected override void OnHoverLost(InputState state)
{
bg.FadeColour(Color4.Black.Opacity(0.25f), 100);
base.OnHoverLost(state);
}
private void loadPreview()
{
if (preview?.HasCompleted ?? true)
{
preview = audio.Track.Get(set.OnlineInfo.Preview);
preview.Volume.Value = 0.5;
}
else
{
preview.Seek(0);
}
}
}
}

View File

@ -106,12 +106,6 @@ namespace osu.Game.Overlays.OnlineBeatmapSet
base.UpdateAfterChildren();
graph.Padding = new MarginPadding { Top = header.DrawHeight };
}
protected override void Update()
{
base.Update();
percentContainer.Width = successRate.Length;
}
}