mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 03:25:11 +08:00
Refactor database to reuse existing types
This commit is contained in:
parent
23bc26ddac
commit
e9a45de51f
@ -45,7 +45,7 @@ namespace osu.Desktop.Beatmaps.IO
|
||||
return File.OpenRead(Path.Combine(BasePath, name));
|
||||
}
|
||||
|
||||
public override Metadata ReadMetadata()
|
||||
public override BeatmapMetadata ReadMetadata()
|
||||
{
|
||||
return FirstMap.Metadata;
|
||||
}
}
|
||||
|
@ -1,16 +1,12 @@
|
||||
using System;
|
||||
using SQLite;
|
||||
|
||||
namespace osu.Game.Database
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
public class Beatmap
|
||||
public class BaseDifficulty
|
||||
{
|
||||
[PrimaryKey]
|
||||
[PrimaryKey, AutoIncrement]
|
||||
public int ID { get; set; }
|
||||
[NotNull, Indexed]
|
||||
public int BeatmapSetID { get; set; }
|
||||
[Indexed]
|
||||
public int BeatmapMetadataID { get; set; }
|
||||
public float DrainRate { get; set; }
|
||||
public float CircleSize { get; set; }
|
||||
public float OverallDifficulty { get; set; }
|
||||
@ -18,4 +14,5 @@ namespace osu.Game.Database
|
||||
public float SliderMultiplier { get; set; }
|
||||
public float SliderTickRate { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,17 +5,27 @@ using System.Collections.Generic;
|
||||
using osu.Game.Beatmaps.Objects;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using osu.Game.Users;
|
||||
using SQLite;
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
public class Beatmap
|
||||
{
|
||||
public int BeatmapID;
|
||||
|
||||
public List<HitObject> HitObjects;
|
||||
public List<ControlPoint> ControlPoints;
|
||||
|
||||
public string Version;
|
||||
public Metadata Metadata;
|
||||
[PrimaryKey]
|
||||
public int BeatmapID { get; set; }
|
||||
[NotNull, Indexed]
|
||||
public int BeatmapSetID { get; set; }
|
||||
[Indexed]
|
||||
public int BeatmapMetadataID { get; set; }
|
||||
public int BaseDifficultyID { get; set; }
|
||||
[Ignore]
|
||||
public List<HitObject> HitObjects { get; set; }
|
||||
[Ignore]
|
||||
public List<ControlPoint> ControlPoints { get; set; }
|
||||
[Ignore]
|
||||
public BeatmapMetadata Metadata { get; set; }
|
||||
[Ignore]
|
||||
public BaseDifficulty BaseDifficulty { get; set; }
|
||||
public string Version { get; set; }
|
||||
}
|
||||
}
|
@ -2,11 +2,15 @@
|
||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Game.GameModes.Play;
|
||||
using SQLite;
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
public class Metadata
|
||||
public class BeatmapMetadata
|
||||
{
|
||||
[PrimaryKey]
|
||||
public int ID { get; set; }
|
||||
|
||||
public int BeatmapSetID { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string TitleUnicode { get; set; }
|
@ -3,6 +3,7 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Users;
|
||||
using SQLite;
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
@ -11,12 +12,15 @@ namespace osu.Game.Beatmaps
|
||||
/// </summary>
|
||||
public class BeatmapSet
|
||||
{
|
||||
public int BeatmapSetID;
|
||||
|
||||
[PrimaryKey]
|
||||
public int BeatmapSetID { get; set; }
|
||||
[NotNull, Indexed]
|
||||
public int BeatmapMetadataID { get; set; }
|
||||
[Ignore]
|
||||
public List<Beatmap> Beatmaps { get; protected set; }
|
||||
|
||||
public Metadata Metadata;
|
||||
|
||||
public User Creator;
|
||||
[Ignore]
|
||||
public BeatmapMetadata Metadata { get; set; }
|
||||
[Ignore]
|
||||
public User Creator { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ namespace osu.Game.Beatmaps.IO
|
||||
/// <summary>
|
||||
/// Reads the beatmap metadata from this archive.
|
||||
/// </summary>
|
||||
public abstract Metadata ReadMetadata();
|
||||
public abstract BeatmapMetadata ReadMetadata();
|
||||
/// <summary>
|
||||
/// Gets a list of beatmap file names.
|
||||
/// </summary>
|
||||
|
@ -53,7 +53,7 @@ namespace osu.Game.Beatmaps.IO
|
||||
return entry.OpenReader();
|
||||
}
|
||||
|
||||
public override Metadata ReadMetadata()
|
||||
public override BeatmapMetadata ReadMetadata()
|
||||
{
|
||||
return FirstMap.Metadata;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using osu.Framework.OS;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Formats;
|
||||
using osu.Game.Beatmaps.IO;
|
||||
using SQLite;
|
||||
@ -52,7 +53,7 @@ namespace osu.Game.Database
|
||||
var beatmap = decoder.Decode(stream);
|
||||
maps.Add(new Beatmap
|
||||
{
|
||||
ID = beatmap.BeatmapID,
|
||||
BeatmapID = beatmap.BeatmapID,
|
||||
BeatmapSetID = metadata.BeatmapSetID,
|
||||
// TODO: Import more things
|
||||
});
|
||||
|
@ -1,23 +0,0 @@
|
||||
using System;
|
||||
using osu.Game.GameModes.Play;
|
||||
using SQLite;
|
||||
|
||||
namespace osu.Game.Database
|
||||
{
|
||||
public class BeatmapMetadata
|
||||
{
|
||||
[PrimaryKey]
|
||||
public int ID { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string TitleUnicode { get; set; }
|
||||
public string Artist { get; set; }
|
||||
public string ArtistUnicode { get; set; }
|
||||
public string Author { get; set; }
|
||||
public string Source { get; set; }
|
||||
public string Tags { get; set; }
|
||||
public PlayMode Mode { get; set; }
|
||||
public int PreviewTime { get; set; }
|
||||
public string AudioFile { get; set; }
|
||||
public string BackgroundFile { get; set; }
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
using System;
|
||||
using SQLite;
|
||||
|
||||
namespace osu.Game.Database
|
||||
{
|
||||
public class BeatmapSet
|
||||
{
|
||||
[PrimaryKey]
|
||||
public int BeatmapSetID { get; set; }
|
||||
[NotNull, Indexed]
|
||||
public int BeatmapMetadataID { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Beatmaps\Beatmap.cs" />
|
||||
<Compile Include="Beatmaps\BeatmapSet.cs" />
|
||||
<Compile Include="Beatmaps\Metadata.cs" />
|
||||
<Compile Include="Beatmaps\BeatmapMetadata.cs" />
|
||||
<Compile Include="Beatmaps\Objects\HitObject.cs" />
|
||||
<Compile Include="Beatmaps\Objects\Catch\CatchBaseHit.cs" />
|
||||
<Compile Include="Beatmaps\Objects\Catch\Droplet.cs" />
|
||||
@ -164,13 +164,11 @@
|
||||
<Compile Include="Users\User.cs" />
|
||||
<Compile Include="VolumeControl.cs" />
|
||||
<Compile Include="Database\BeatmapDatabase.cs" />
|
||||
<Compile Include="Database\BeatmapSet.cs" />
|
||||
<Compile Include="Database\BeatmapMetadata.cs" />
|
||||
<Compile Include="Database\Beatmap.cs" />
|
||||
<Compile Include="Beatmaps\IO\ArchiveReader.cs" />
|
||||
<Compile Include="Beatmaps\Formats\BeatmapDecoder.cs" />
|
||||
<Compile Include="Beatmaps\Formats\OsuLegacyDecoder.cs" />
|
||||
<Compile Include="Beatmaps\IO\OszArchiveReader.cs" />
|
||||
<Compile Include="Beatmaps\BaseDifficulty.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\osu-framework\osu.Framework\osu.Framework.csproj">
|
||||
|
Loading…
Reference in New Issue
Block a user