mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 16:59:53 +09:00
move logic to DirectPanel and reuse stuff for the PreviewButton
This commit is contained in:
35
osu.Game/Audio/AudioLoadWrapper.cs
Normal file
35
osu.Game/Audio/AudioLoadWrapper.cs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Audio;
|
||||||
|
using osu.Framework.Audio.Track;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace osu.Game.Audio
|
||||||
|
{
|
||||||
|
public class AudioLoadWrapper : Drawable
|
||||||
|
{
|
||||||
|
private readonly string preview;
|
||||||
|
|
||||||
|
public Track Preview;
|
||||||
|
|
||||||
|
public AudioLoadWrapper(string preview)
|
||||||
|
{
|
||||||
|
this.preview = preview;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(AudioManager audio)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(preview))
|
||||||
|
{
|
||||||
|
Preview = audio.Track.Get(preview);
|
||||||
|
Preview.Volume.Value = 0.5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -15,6 +15,9 @@ using osu.Game.Graphics.Containers;
|
|||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
|
using osu.Game.Audio;
|
||||||
|
using osu.Game.Overlays.Direct;
|
||||||
|
using osu.Framework.Configuration;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.BeatmapSet
|
namespace osu.Game.Overlays.BeatmapSet
|
||||||
{
|
{
|
||||||
@ -24,27 +27,10 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
|
|
||||||
private readonly Container audioWrapper;
|
private readonly Container audioWrapper;
|
||||||
private readonly Box bg, progress;
|
private readonly Box bg, progress;
|
||||||
private readonly SpriteIcon icon;
|
private readonly PlayButton playButton;
|
||||||
private readonly LoadingAnimation loadingAnimation;
|
|
||||||
|
|
||||||
private Track preview;
|
private Track preview;
|
||||||
|
private readonly Bindable<bool> playing = new Bindable<bool>();
|
||||||
private bool loading
|
|
||||||
{
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (value)
|
|
||||||
{
|
|
||||||
loadingAnimation.Show();
|
|
||||||
icon.FadeOut(transition_duration * 5, Easing.OutQuint);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
loadingAnimation.Hide();
|
|
||||||
icon.FadeIn(transition_duration, Easing.OutQuint);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private BeatmapSetInfo beatmapSet;
|
private BeatmapSetInfo beatmapSet;
|
||||||
public BeatmapSetInfo BeatmapSet
|
public BeatmapSetInfo BeatmapSet
|
||||||
@ -55,42 +41,11 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
if (value == beatmapSet) return;
|
if (value == beatmapSet) return;
|
||||||
beatmapSet = value;
|
beatmapSet = value;
|
||||||
|
|
||||||
Playing = false;
|
playing.Value = false;
|
||||||
preview = null;
|
preview = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool playing;
|
|
||||||
public bool Playing
|
|
||||||
{
|
|
||||||
get { return playing; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (value == playing) return;
|
|
||||||
playing = value;
|
|
||||||
|
|
||||||
if (preview == null)
|
|
||||||
{
|
|
||||||
loading = true;
|
|
||||||
audioWrapper.Child = new AsyncLoadWrapper(new AudioLoadWrapper(BeatmapSet)
|
|
||||||
{
|
|
||||||
OnLoadComplete = d =>
|
|
||||||
{
|
|
||||||
loading = false;
|
|
||||||
|
|
||||||
preview = (d as AudioLoadWrapper)?.Preview;
|
|
||||||
Playing = Playing;
|
|
||||||
updatePlayingState();
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
updatePlayingState();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public PreviewButton()
|
public PreviewButton()
|
||||||
{
|
{
|
||||||
Height = 42;
|
Height = 42;
|
||||||
@ -116,22 +71,16 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
Alpha = 0f,
|
Alpha = 0f,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
icon = new SpriteIcon
|
playButton = new PlayButton(playing)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Icon = FontAwesome.fa_play,
|
|
||||||
Size = new Vector2(18),
|
Size = new Vector2(18),
|
||||||
Shadow = false,
|
|
||||||
},
|
|
||||||
loadingAnimation = new LoadingAnimation
|
|
||||||
{
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
Action = () => Playing = !Playing;
|
Action = () => playing.Value = !playing.Value;
|
||||||
|
playing.ValueChanged += updatePlayingState;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -144,12 +93,12 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
if (Playing && preview != null)
|
if (playing.Value && preview != null)
|
||||||
{
|
{
|
||||||
progress.Width = (float)(preview.CurrentTime / preview.Length);
|
progress.Width = (float)(preview.CurrentTime / preview.Length);
|
||||||
if (preview.HasCompleted)
|
if (preview.HasCompleted)
|
||||||
{
|
{
|
||||||
Playing = false;
|
playing.Value = false;
|
||||||
preview = null;
|
preview = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -157,7 +106,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
Playing = false;
|
playing.Value = false;
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,44 +122,35 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
base.OnHoverLost(state);
|
base.OnHoverLost(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updatePlayingState()
|
private void updatePlayingState(bool newValue)
|
||||||
{
|
{
|
||||||
if (preview == null) return;
|
if (preview == null)
|
||||||
|
|
||||||
if (Playing)
|
|
||||||
{
|
{
|
||||||
icon.Icon = FontAwesome.fa_stop;
|
playButton.Loading = true;
|
||||||
progress.FadeIn(100);
|
audioWrapper.Child = new AsyncLoadWrapper(new AudioLoadWrapper(BeatmapSet.OnlineInfo.Preview)
|
||||||
|
{
|
||||||
|
OnLoadComplete = d =>
|
||||||
|
{
|
||||||
|
playButton.Loading = false;
|
||||||
|
|
||||||
preview.Seek(0);
|
preview = (d as AudioLoadWrapper)?.Preview;
|
||||||
preview.Start();
|
playing.TriggerChange();
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
icon.Icon = FontAwesome.fa_play;
|
if (newValue)
|
||||||
progress.FadeOut(100);
|
|
||||||
preview.Stop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class AudioLoadWrapper : Drawable
|
|
||||||
{
|
|
||||||
private readonly string preview;
|
|
||||||
|
|
||||||
public Track Preview;
|
|
||||||
|
|
||||||
public AudioLoadWrapper(BeatmapSetInfo set)
|
|
||||||
{
|
|
||||||
preview = set.OnlineInfo.Preview;
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(AudioManager audio)
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrEmpty(preview))
|
|
||||||
{
|
{
|
||||||
Preview = audio.Track.Get(preview);
|
progress.FadeIn(100);
|
||||||
Preview.Volume.Value = 0.5;
|
|
||||||
|
preview.Seek(0);
|
||||||
|
preview.Start();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
progress.FadeOut(100);
|
||||||
|
preview.Stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ namespace osu.Game.Overlays.Direct
|
|||||||
private Box progressBar;
|
private Box progressBar;
|
||||||
|
|
||||||
protected override PlayButton PlayButton => playButton;
|
protected override PlayButton PlayButton => playButton;
|
||||||
|
protected override Box PreviewBar => progressBar;
|
||||||
|
|
||||||
public DirectGridPanel(BeatmapSetInfo beatmap) : base(beatmap)
|
public DirectGridPanel(BeatmapSetInfo beatmap) : base(beatmap)
|
||||||
{
|
{
|
||||||
@ -197,20 +198,8 @@ namespace osu.Game.Overlays.Direct
|
|||||||
Margin = new MarginPadding { Top = 5, Left = 10 },
|
Margin = new MarginPadding { Top = 5, Left = 10 },
|
||||||
Size = new Vector2(30),
|
Size = new Vector2(30),
|
||||||
Alpha = 0,
|
Alpha = 0,
|
||||||
TrackUrl = "https://b.ppy.sh/preview/" + SetInfo.OnlineBeatmapSetID + ".mp3",
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
PreviewPlaying.ValueChanged += newValue => playButton.FadeTo(newValue || IsHovered ? 1 : 0, 120, Easing.InOutQuint);
|
|
||||||
PreviewPlaying.ValueChanged += newValue => progressBar.FadeTo(newValue ? 1 : 0, 120, Easing.InOutQuint);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Update()
|
|
||||||
{
|
|
||||||
base.Update();
|
|
||||||
|
|
||||||
if (PreviewPlaying && playButton.Track != null)
|
|
||||||
progressBar.Width = (float)(playButton.Track.CurrentTime / playButton.Track.Length);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ using osu.Framework.Localisation;
|
|||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Direct
|
namespace osu.Game.Overlays.Direct
|
||||||
{
|
{
|
||||||
@ -33,6 +34,7 @@ namespace osu.Game.Overlays.Direct
|
|||||||
private Box progressBar;
|
private Box progressBar;
|
||||||
|
|
||||||
protected override PlayButton PlayButton => playButton;
|
protected override PlayButton PlayButton => playButton;
|
||||||
|
protected override Box PreviewBar => progressBar;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(LocalisationEngine localisation, OsuColour colours)
|
private void load(LocalisationEngine localisation, OsuColour colours)
|
||||||
@ -70,7 +72,6 @@ namespace osu.Game.Overlays.Direct
|
|||||||
Size = new Vector2(height / 2),
|
Size = new Vector2(height / 2),
|
||||||
FillMode = FillMode.Fit,
|
FillMode = FillMode.Fit,
|
||||||
Alpha = 0,
|
Alpha = 0,
|
||||||
TrackUrl = "https://b.ppy.sh/preview/" + SetInfo.OnlineBeatmapSetID + ".mp3",
|
|
||||||
},
|
},
|
||||||
new FillFlowContainer
|
new FillFlowContainer
|
||||||
{
|
{
|
||||||
@ -165,17 +166,6 @@ namespace osu.Game.Overlays.Direct
|
|||||||
Colour = colours.Yellow,
|
Colour = colours.Yellow,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
PreviewPlaying.ValueChanged += newValue => playButton.FadeTo(newValue || IsHovered ? 1 : 0, 120, Easing.InOutQuint);
|
|
||||||
PreviewPlaying.ValueChanged += newValue => progressBar.FadeTo(newValue ? 1 : 0, 120, Easing.InOutQuint);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Update()
|
|
||||||
{
|
|
||||||
base.Update();
|
|
||||||
|
|
||||||
if (PreviewPlaying && playButton.Track != null)
|
|
||||||
progressBar.Width = (float)(playButton.Track.CurrentTime / playButton.Track.Length);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,8 @@ using osu.Framework.Logging;
|
|||||||
using osu.Game.Overlays.Notifications;
|
using osu.Game.Overlays.Notifications;
|
||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
|
using osu.Framework.Audio.Track;
|
||||||
|
using osu.Game.Audio;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Direct
|
namespace osu.Game.Overlays.Direct
|
||||||
{
|
{
|
||||||
@ -39,9 +41,12 @@ namespace osu.Game.Overlays.Direct
|
|||||||
private BeatmapManager beatmaps;
|
private BeatmapManager beatmaps;
|
||||||
private NotificationOverlay notifications;
|
private NotificationOverlay notifications;
|
||||||
private BeatmapSetOverlay beatmapSetOverlay;
|
private BeatmapSetOverlay beatmapSetOverlay;
|
||||||
|
private Container audioWrapper;
|
||||||
|
|
||||||
|
protected Track Preview;
|
||||||
public readonly Bindable<bool> PreviewPlaying = new Bindable<bool>();
|
public readonly Bindable<bool> PreviewPlaying = new Bindable<bool>();
|
||||||
protected abstract PlayButton PlayButton { get; }
|
protected abstract PlayButton PlayButton { get; }
|
||||||
|
protected abstract Box PreviewBar { get; }
|
||||||
|
|
||||||
protected override Container<Drawable> Content => content;
|
protected override Container<Drawable> Content => content;
|
||||||
|
|
||||||
@ -82,6 +87,7 @@ namespace osu.Game.Overlays.Direct
|
|||||||
EdgeEffect = edgeEffectNormal,
|
EdgeEffect = edgeEffectNormal,
|
||||||
Children = new[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
|
audioWrapper = new Container(),
|
||||||
// temporary blackness until the actual background loads.
|
// temporary blackness until the actual background loads.
|
||||||
BlackBackground = new Box
|
BlackBackground = new Box
|
||||||
{
|
{
|
||||||
@ -106,6 +112,53 @@ namespace osu.Game.Overlays.Direct
|
|||||||
|
|
||||||
if (downloadRequest != null)
|
if (downloadRequest != null)
|
||||||
attachDownload(downloadRequest);
|
attachDownload(downloadRequest);
|
||||||
|
|
||||||
|
PreviewPlaying.ValueChanged += newValue => PlayButton.FadeTo(newValue || IsHovered ? 1 : 0, 120, Easing.InOutQuint);
|
||||||
|
PreviewPlaying.ValueChanged += newValue => PreviewBar.FadeTo(newValue ? 1 : 0, 120, Easing.InOutQuint);
|
||||||
|
PreviewPlaying.ValueChanged += setPlaying;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setPlaying(bool newValue)
|
||||||
|
{
|
||||||
|
if (newValue)
|
||||||
|
{
|
||||||
|
if(Preview == null)
|
||||||
|
{
|
||||||
|
PlayButton.Loading = true;
|
||||||
|
audioWrapper.Child = new AsyncLoadWrapper(new AudioLoadWrapper("https://b.ppy.sh/preview/" + SetInfo.OnlineBeatmapSetID + ".mp3")
|
||||||
|
{
|
||||||
|
OnLoadComplete = d =>
|
||||||
|
{
|
||||||
|
PlayButton.Loading = false;
|
||||||
|
Preview = (d as AudioLoadWrapper)?.Preview;
|
||||||
|
Preview.Start();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Preview.Start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Preview?.Stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
if (PreviewPlaying && Preview != null)
|
||||||
|
{
|
||||||
|
PreviewBar.Width = (float)(Preview.CurrentTime / Preview.Length);
|
||||||
|
if (Preview.HasCompleted)
|
||||||
|
{
|
||||||
|
PreviewPlaying.Value = false;
|
||||||
|
Preview = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnHover(InputState state)
|
protected override bool OnHover(InputState state)
|
||||||
|
@ -11,81 +11,70 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Direct
|
namespace osu.Game.Overlays.Direct
|
||||||
{
|
{
|
||||||
public class PlayButton : Container
|
public class PlayButton : Container
|
||||||
{
|
{
|
||||||
public string TrackUrl;
|
private readonly Bindable<bool> playing;
|
||||||
|
|
||||||
public Bindable<bool> Playing;
|
|
||||||
|
|
||||||
public Track Track;
|
|
||||||
private Bindable<WorkingBeatmap> gameBeatmap;
|
|
||||||
private AudioManager audio;
|
|
||||||
|
|
||||||
private Color4 hoverColour;
|
private Color4 hoverColour;
|
||||||
private readonly SpriteIcon icon;
|
private readonly SpriteIcon icon;
|
||||||
|
private readonly LoadingAnimation loadingAnimation;
|
||||||
|
private const float transition_duration = 500;
|
||||||
|
|
||||||
|
private bool loading;
|
||||||
|
public bool Loading
|
||||||
|
{
|
||||||
|
get { return loading; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
loading = value;
|
||||||
|
if (value)
|
||||||
|
{
|
||||||
|
loadingAnimation.Show();
|
||||||
|
icon.FadeOut(transition_duration * 5, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
loadingAnimation.Hide();
|
||||||
|
icon.FadeIn(transition_duration, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public PlayButton(Bindable<bool> playing)
|
public PlayButton(Bindable<bool> playing)
|
||||||
{
|
{
|
||||||
Playing = playing;
|
this.playing = playing;
|
||||||
Add(icon = new SpriteIcon
|
AddRange(new Drawable[]
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
icon = new SpriteIcon
|
||||||
Origin = Anchor.Centre,
|
{
|
||||||
FillMode = FillMode.Fit,
|
Anchor = Anchor.Centre,
|
||||||
RelativeSizeAxes = Axes.Both,
|
Origin = Anchor.Centre,
|
||||||
Icon = FontAwesome.fa_play,
|
FillMode = FillMode.Fit,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Icon = FontAwesome.fa_play,
|
||||||
|
},
|
||||||
|
loadingAnimation = new LoadingAnimation(),
|
||||||
});
|
});
|
||||||
|
|
||||||
Playing.ValueChanged += newValue => icon.Icon = newValue ? (Track == null ? FontAwesome.fa_spinner : FontAwesome.fa_pause) : FontAwesome.fa_play;
|
playing.ValueChanged += newValue => icon.Icon = newValue ? FontAwesome.fa_pause : FontAwesome.fa_play;
|
||||||
|
|
||||||
Playing.ValueChanged += newValue =>
|
playing.ValueChanged += newValue => icon.FadeColour(newValue || IsHovered ? hoverColour : Color4.White, 120, Easing.InOutQuint);
|
||||||
{
|
|
||||||
if (newValue)
|
|
||||||
Track?.Start();
|
|
||||||
else
|
|
||||||
Track?.Stop();
|
|
||||||
};
|
|
||||||
|
|
||||||
Playing.ValueChanged += newValue => icon.FadeColour(newValue || IsHovered ? hoverColour : Color4.White, 120, Easing.InOutQuint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colour, OsuGameBase game, AudioManager audio)
|
private void load(OsuColour colour)
|
||||||
{
|
{
|
||||||
hoverColour = colour.Yellow;
|
hoverColour = colour.Yellow;
|
||||||
gameBeatmap = game.Beatmap;
|
|
||||||
this.audio = audio;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task loadTask;
|
|
||||||
|
|
||||||
protected override bool OnClick(InputState state)
|
protected override bool OnClick(InputState state)
|
||||||
{
|
{
|
||||||
gameBeatmap.Value.Track.Stop();
|
playing.Value = !playing.Value;
|
||||||
|
|
||||||
Playing.Value = !Playing.Value;
|
|
||||||
|
|
||||||
if (loadTask == null)
|
|
||||||
{
|
|
||||||
icon.Spin(2000, RotationDirection.Clockwise);
|
|
||||||
|
|
||||||
loadTask = Task.Run(() =>
|
|
||||||
{
|
|
||||||
Track = audio.Track.Get(TrackUrl);
|
|
||||||
Track.Looping = true;
|
|
||||||
if (Playing)
|
|
||||||
Track.Start();
|
|
||||||
|
|
||||||
icon.ClearTransforms();
|
|
||||||
icon.Rotation = 0;
|
|
||||||
Playing.TriggerChange();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +86,7 @@ namespace osu.Game.Overlays.Direct
|
|||||||
|
|
||||||
protected override void OnHoverLost(InputState state)
|
protected override void OnHoverLost(InputState state)
|
||||||
{
|
{
|
||||||
if(!Playing)
|
if(!playing.Value)
|
||||||
icon.FadeColour(Color4.White, 120, Easing.InOutQuint);
|
icon.FadeColour(Color4.White, 120, Easing.InOutQuint);
|
||||||
base.OnHoverLost(state);
|
base.OnHoverLost(state);
|
||||||
}
|
}
|
||||||
|
@ -239,6 +239,7 @@
|
|||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Audio\AudioLoadWrapper.cs" />
|
||||||
<Compile Include="Audio\SampleInfo.cs" />
|
<Compile Include="Audio\SampleInfo.cs" />
|
||||||
<Compile Include="Audio\SampleInfoList.cs" />
|
<Compile Include="Audio\SampleInfoList.cs" />
|
||||||
<Compile Include="Beatmaps\Beatmap.cs" />
|
<Compile Include="Beatmaps\Beatmap.cs" />
|
||||||
|
Reference in New Issue
Block a user