diff --git a/osu.Desktop.VisualTests/Program.cs b/osu.Desktop.VisualTests/Program.cs index 4cc7e6278a..9b2d00a219 100644 --- a/osu.Desktop.VisualTests/Program.cs +++ b/osu.Desktop.VisualTests/Program.cs @@ -13,7 +13,7 @@ namespace osu.Desktop.VisualTests [STAThread] public static void Main(string[] args) { - BasicGameHost host = Host.GetSuitableHost(@"osu"); + BasicGameHost host = Host.GetSuitableHost(@"osu-visual-tests"); host.Add(new VisualTestGame()); host.Run(); } diff --git a/osu.Game/Beatmaps/IO/BeatmapResourceStore.cs b/osu.Game/Beatmaps/IO/BeatmapResourceStore.cs deleted file mode 100644 index 005f751aea..0000000000 --- a/osu.Game/Beatmaps/IO/BeatmapResourceStore.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using osu.Framework.IO.Stores; -using osu.Game.Database; - -namespace osu.Game.Beatmaps.IO -{ - public class BeatmapResourceStore : IResourceStore, IDisposable - { - private Dictionary beatmaps = new Dictionary(); - private BeatmapDatabase database; - - public BeatmapResourceStore(BeatmapDatabase database) - { - this.database = database; - } - - public void AddBeatmap(BeatmapSetInfo setInfo) - { - beatmaps.Add(setInfo.BeatmapSetID, database.GetReader(setInfo)); - } - - public void RemoveBeatmap(BeatmapSetInfo setInfo) - { - beatmaps[setInfo.BeatmapSetID].Dispose(); - beatmaps.Remove(setInfo.BeatmapSetID); - } - - public void Dispose() - { - foreach (var b in beatmaps.Values) - b.Dispose(); - } - - public byte[] Get(string name) - { - throw new NotImplementedException(); - } - - public Stream GetStream(string name) - { - string id = name.Remove(name.IndexOf(':')); - string path = name.Substring(name.IndexOf(':') + 1); - var reader = beatmaps[int.Parse(id)]; - return reader.ReadFile(path); - } - } -} \ No newline at end of file diff --git a/osu.Game/GameModes/Play/BeatmapGroup.cs b/osu.Game/GameModes/Play/BeatmapGroup.cs index 3b0dfe1bd5..63aa65b832 100644 --- a/osu.Game/GameModes/Play/BeatmapGroup.cs +++ b/osu.Game/GameModes/Play/BeatmapGroup.cs @@ -35,8 +35,8 @@ namespace osu.Game.GameModes.Play } } - public event Action SetSelected; - public event Action BeatmapSelected; + public Action SetSelected; + public Action BeatmapSelected; public BeatmapSetInfo BeatmapSet; private BeatmapSetBox setBox; private FlowContainer topContainer; @@ -50,19 +50,13 @@ namespace osu.Game.GameModes.Play if (collapsed == value) return; collapsed = value; - this.ClearTransformations(); + ClearTransformations(); const float uncollapsedAlpha = 1; - Transforms.Add(new TransformAlpha(Clock) - { - StartValue = collapsed ? uncollapsedAlpha : collapsedAlpha, - EndValue = collapsed ? collapsedAlpha : uncollapsedAlpha, - StartTime = Time, - EndTime = Time + 250, - }); + FadeTo(collapsed ? collapsedAlpha : uncollapsedAlpha, 250); if (collapsed) - topContainer.Remove(difficulties); + difficulties.Hide(); else - topContainer.Add(difficulties); + difficulties.Show(); setBox.ClearTransformations(); setBox.Width = collapsed ? collapsedWidth : 1; // TODO: Transform setBox.BorderColour = new Color4( @@ -73,21 +67,6 @@ namespace osu.Game.GameModes.Play setBox.GlowRadius = collapsed ? 0 : 5; } } - - private void updateSelected(BeatmapInfo map) - { - int selected = BeatmapSet.Beatmaps.IndexOf(map); - var buttons = difficulties.Children.ToList(); - for (int i = 0; i < buttons.Count; i++) - { - var button = buttons[i] as BeatmapButton; - float targetWidth = 1 - Math.Abs((selected - i) * 0.025f); - targetWidth = MathHelper.Clamp(targetWidth, 0.8f, 1); - button.Width = targetWidth; // TODO: Transform - button.Selected = selected == i; - } - BeatmapSelected?.Invoke(BeatmapSet, map); - } public BeatmapGroup(BeatmapSetInfo beatmapSet) { @@ -104,7 +83,7 @@ namespace osu.Game.GameModes.Play RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Direction = FlowDirection.VerticalOnly, - Children = new[] + Children = new Drawable[] { setBox = new BeatmapSetBox(beatmapSet) { @@ -112,36 +91,45 @@ namespace osu.Game.GameModes.Play Width = collapsedWidth, Anchor = Anchor.TopRight, Origin = Anchor.TopRight, + }, + difficulties = new FlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Margin = new MarginPadding { Top = 5 }, + Padding = new MarginPadding { Left = 75 }, + Spacing = new Vector2(0, 5), + Direction = FlowDirection.VerticalOnly, + Alpha = 0, + Children = BeatmapSet.Beatmaps.Select( + b => { + float width = difficultyWidth; + if (difficultyWidth > 0.8f) difficultyWidth -= 0.025f; + return new BeatmapPanel(BeatmapSet, b) + { + MapSelected = updateSelected, + Selected = width == 1, + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + RelativeSizeAxes = Axes.X, + Width = width, + }; + }) } } } }; - difficulties = new FlowContainer // Deliberately not added to children - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Margin = new MarginPadding { Top = 5 }, - Padding = new MarginPadding { Left = 75 }, - Spacing = new Vector2(0, 5), - Direction = FlowDirection.VerticalOnly, - Children = this.BeatmapSet.Beatmaps.Select( - b => { - float width = difficultyWidth; - if (difficultyWidth > 0.8f) difficultyWidth -= 0.025f; - return new BeatmapButton(this.BeatmapSet, b) - { - MapSelected = beatmap => updateSelected(beatmap), - Selected = width == 1, - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - RelativeSizeAxes = Axes.X, - Width = width, - }; - }) - }; + collapsed = true; } + private void updateSelected(BeatmapInfo map) + { + foreach (BeatmapPanel panel in difficulties.Children) + panel.Selected = panel.Beatmap == map; + BeatmapSelected?.Invoke(BeatmapSet, map); + } + protected override bool OnClick(InputState state) { SetSelected?.Invoke(BeatmapSet); @@ -151,12 +139,8 @@ namespace osu.Game.GameModes.Play class BeatmapSetBox : Container { - private BeatmapSetInfo beatmapSet; - private Sprite backgroundImage; - public BeatmapSetBox(BeatmapSetInfo beatmapSet) { - this.beatmapSet = beatmapSet; AutoSizeAxes = Axes.Y; Masking = true; CornerRadius = 5; @@ -177,12 +161,6 @@ namespace osu.Game.GameModes.Play Size = Vector2.One, Children = new Drawable[] { - backgroundImage = new Sprite - { - RelativeSizeAxes = Axes.X, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - }, new Box // TODO: Gradient { Colour = new Color4(0, 0, 0, 100), @@ -202,12 +180,12 @@ namespace osu.Game.GameModes.Play // TODO: Make these italic new SpriteText { - Text = this.beatmapSet.Metadata.Title ?? this.beatmapSet.Metadata.TitleUnicode, + Text = beatmapSet.Metadata.Title ?? beatmapSet.Metadata.TitleUnicode, TextSize = 20 }, new SpriteText { - Text = this.beatmapSet.Metadata.Artist ?? this.beatmapSet.Metadata.ArtistUnicode, + Text = beatmapSet.Metadata.Artist ?? beatmapSet.Metadata.ArtistUnicode, TextSize = 16 }, new FlowContainer diff --git a/osu.Game/GameModes/Play/BeatmapButton.cs b/osu.Game/GameModes/Play/BeatmapPanel.cs similarity index 88% rename from osu.Game/GameModes/Play/BeatmapButton.cs rename to osu.Game/GameModes/Play/BeatmapPanel.cs index d31f1b3a54..ca37292894 100644 --- a/osu.Game/GameModes/Play/BeatmapButton.cs +++ b/osu.Game/GameModes/Play/BeatmapPanel.cs @@ -2,29 +2,22 @@ //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Collections.Generic; -using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Input; -using osu.Game.Beatmaps; -using osu.Game.GameModes.Backgrounds; -using osu.Framework; using osu.Game.Database; using osu.Framework.Graphics.Primitives; using OpenTK.Graphics; using OpenTK; using osu.Game.Graphics; -using osu.Framework.Graphics.Transformations; using osu.Game.Graphics.UserInterface; namespace osu.Game.GameModes.Play { - class BeatmapButton : Container + class BeatmapPanel : Container { - private BeatmapSetInfo beatmapSet; - private BeatmapInfo beatmap; + public BeatmapInfo Beatmap; public Action MapSelected; @@ -47,10 +40,9 @@ namespace osu.Game.GameModes.Play } } - public BeatmapButton(BeatmapSetInfo set, BeatmapInfo beatmap) + public BeatmapPanel(BeatmapSetInfo set, BeatmapInfo beatmap) { - this.beatmapSet = set; - this.beatmap = beatmap; + Beatmap = beatmap; AutoSizeAxes = Axes.Y; Masking = true; CornerRadius = 5; @@ -109,7 +101,7 @@ namespace osu.Game.GameModes.Play protected override bool OnClick(InputState state) { - MapSelected?.Invoke(beatmap); + MapSelected?.Invoke(Beatmap); return true; } } diff --git a/osu.Game/GameModes/Play/PlaySongSelect.cs b/osu.Game/GameModes/Play/PlaySongSelect.cs index 7e68fef78d..3f23b362f3 100644 --- a/osu.Game/GameModes/Play/PlaySongSelect.cs +++ b/osu.Game/GameModes/Play/PlaySongSelect.cs @@ -34,59 +34,6 @@ namespace osu.Game.GameModes.Play private ScrollContainer scrollContainer; private FlowContainer setList; - private void selectBeatmapSet(BeatmapSetInfo beatmapSet) - { - selectedBeatmapSet = beatmapSet; - foreach (var child in setList.Children) - { - var childGroup = child as BeatmapGroup; - if (childGroup.BeatmapSet == beatmapSet) - { - childGroup.Collapsed = false; - selectedBeatmap = childGroup.SelectedBeatmap; - } - else - childGroup.Collapsed = true; - } - } - - private void selectBeatmap(BeatmapSetInfo set, BeatmapInfo beatmap) - { - selectBeatmapSet(set); - selectedBeatmap = beatmap; - } - - private Stopwatch watch = new Stopwatch(); - - private void addBeatmapSet(BeatmapSetInfo beatmapSet) - { - watch.Reset(); - watch.Start(); - beatmapSet = beatmaps.GetWithChildren(beatmapSet.BeatmapSetID); - beatmapSet.Beatmaps.ForEach(b => beatmaps.GetChildren(b)); - beatmapSet.Beatmaps = beatmapSet.Beatmaps.OrderBy(b => b.BaseDifficulty.OverallDifficulty) - .ToList(); - Scheduler.Add(() => - { - var group = new BeatmapGroup(beatmapSet); - group.SetSelected += selectBeatmapSet; - group.BeatmapSelected += selectBeatmap; - setList.Add(group); - if (setList.Children.Count() == 1) - { - selectedBeatmapSet = group.BeatmapSet; - selectedBeatmap = group.SelectedBeatmap; - group.Collapsed = false; - } - }); - } - - private void addBeatmapSets() - { - foreach (var beatmapSet in beatmaps.Query()) - addBeatmapSet(beatmapSet); - } - public PlaySongSelect() { const float scrollWidth = 640; @@ -169,13 +116,13 @@ namespace osu.Game.GameModes.Play { base.Load(game); - OsuGame osu = game as OsuGame; - if (osu != null) + OsuGame osuGame = game as OsuGame; + if (osuGame != null) { - playMode = osu.PlayMode; + playMode = osuGame.PlayMode; playMode.ValueChanged += PlayMode_ValueChanged; // Temporary: - scrollContainer.Padding = new MarginPadding { Top = osu.Toolbar.Height }; + scrollContainer.Padding = new MarginPadding { Top = osuGame.Toolbar.Height }; } beatmaps = (game as OsuGameBase).Beatmaps; @@ -193,5 +140,60 @@ namespace osu.Game.GameModes.Play private void PlayMode_ValueChanged(object sender, EventArgs e) { } + + private void selectBeatmapSet(BeatmapSetInfo beatmapSet) + { + if (selectedBeatmapSet == beatmapSet) + return; + selectedBeatmapSet = beatmapSet; + foreach (var child in setList.Children) + { + var childGroup = child as BeatmapGroup; + if (childGroup.BeatmapSet == beatmapSet) + { + childGroup.Collapsed = false; + selectedBeatmap = childGroup.SelectedBeatmap; + } + else + childGroup.Collapsed = true; + } + } + + private void selectBeatmap(BeatmapSetInfo set, BeatmapInfo beatmap) + { + if (selectedBeatmap == beatmap) + return; + selectBeatmapSet(set); + selectedBeatmap = beatmap; + } + + private void addBeatmapSet(BeatmapSetInfo beatmapSet) + { + beatmapSet = beatmaps.GetWithChildren(beatmapSet.BeatmapSetID); + beatmapSet.Beatmaps.ForEach(b => beatmaps.GetChildren(b)); + beatmapSet.Beatmaps = beatmapSet.Beatmaps.OrderBy(b => b.BaseDifficulty.OverallDifficulty) + .ToList(); + Scheduler.Add(() => + { + var group = new BeatmapGroup(beatmapSet) + { + SetSelected = selectBeatmapSet, + BeatmapSelected = selectBeatmap, + }; + setList.Add(group); + if (setList.Children.Count() == 1) + { + selectedBeatmapSet = group.BeatmapSet; + selectedBeatmap = group.SelectedBeatmap; + group.Collapsed = false; + } + }); + } + + private void addBeatmapSets() + { + foreach (var beatmapSet in beatmaps.Query()) + addBeatmapSet(beatmapSet); + } } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 380073e87c..1cd073a00e 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -117,7 +117,7 @@ - + @@ -191,7 +191,6 @@ -