mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 14:13:01 +08:00
Improve song selection layout, database loading
Also adds event that notifes the song select when a beatmap is added.
This commit is contained in:
parent
a14edc06c8
commit
674f624bfc
@ -223,7 +223,6 @@ namespace osu.Game.Beatmaps.Formats
|
||||
line = stream.ReadLine();
|
||||
if (line == null)
|
||||
break;
|
||||
line = line.Trim();
|
||||
if (string.IsNullOrEmpty(line))
|
||||
continue;
|
||||
if (line.StartsWith(@"osu file format v"))
|
||||
@ -274,4 +273,4 @@ namespace osu.Game.Beatmaps.Formats
|
||||
return beatmap;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ namespace osu.Game.Database
|
||||
{
|
||||
private static SQLiteConnection connection { get; set; }
|
||||
private BasicStorage storage;
|
||||
public event Action<BeatmapSetInfo> BeatmapSetAdded;
|
||||
|
||||
public BeatmapDatabase(BasicStorage storage)
|
||||
{
|
||||
@ -75,6 +76,7 @@ namespace osu.Game.Database
|
||||
connection.Insert(beatmapSet);
|
||||
beatmapSet.BeatmapMetadataID = connection.Insert(metadata);
|
||||
connection.UpdateWithChildren(beatmapSet);
|
||||
BeatmapSetAdded?.Invoke(beatmapSet);
|
||||
}
|
||||
|
||||
public ArchiveReader GetReader(BeatmapSetInfo beatmapSet)
|
||||
|
@ -4,8 +4,10 @@
|
||||
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.Game.Beatmaps;
|
||||
using osu.Game.GameModes.Backgrounds;
|
||||
using osu.Framework;
|
||||
|
||||
@ -20,16 +22,16 @@ namespace osu.Game.GameModes.Play
|
||||
|
||||
private FlowContainer setList;
|
||||
|
||||
private Drawable createSetUI(BeatmapSet bset)
|
||||
{
|
||||
return new SpriteText { Text = bset.Metadata.Title };
|
||||
}
|
||||
|
||||
private void addBeatmapSets()
|
||||
{
|
||||
var sets = (Game as OsuGame).Beatmaps.GetBeatmapSets();
|
||||
foreach (var beatmapSet in sets)
|
||||
{
|
||||
setList.Add(new SpriteText
|
||||
{
|
||||
Text = beatmapSet.Metadata.Title
|
||||
});
|
||||
}
|
||||
setList.Add(createSetUI(beatmapSet));
|
||||
}
|
||||
|
||||
public override void Load(BaseGame game)
|
||||
@ -41,13 +43,22 @@ namespace osu.Game.GameModes.Play
|
||||
playMode = osu.PlayMode;
|
||||
playMode.ValueChanged += PlayMode_ValueChanged;
|
||||
|
||||
Add(setList = new FlowContainer
|
||||
Add(new ScrollContainer
|
||||
{
|
||||
Direction = FlowDirection.VerticalOnly,
|
||||
Padding = new OpenTK.Vector2(0, osu.Toolbar.Height)
|
||||
OriginPosition = new OpenTK.Vector2(0, -osu.Toolbar.Height),
|
||||
Children = new[]
|
||||
{
|
||||
setList = new FlowContainer
|
||||
{
|
||||
Direction = FlowDirection.VerticalOnly,
|
||||
Padding = new OpenTK.Vector2(25, 25)
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
addBeatmapSets();
|
||||
|
||||
(Game as OsuGame).Beatmaps.BeatmapSetAdded += bset => setList.Add(createSetUI(bset));
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
|
Loading…
Reference in New Issue
Block a user