mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 05:32:54 +08:00
Add initial DB schema and support code
This commit is contained in:
parent
8dadc2b215
commit
2d810f72fa
@ -11,7 +11,7 @@ namespace osu.Desktop
|
||||
public static class Program
|
||||
{
|
||||
[STAThread]
|
||||
public static void Main()
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
BasicGameHost host = Host.GetSuitableHost(@"osu");
|
||||
host.Add(new OsuGame());
|
||||
|
11
osu.Game/Beatmaps/GameMode.cs
Normal file
11
osu.Game/Beatmaps/GameMode.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System;
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
public enum GameMode
|
||||
{
|
||||
Osu = 0,
|
||||
Taiko = 1,
|
||||
CatchTheBeat = 2,
|
||||
OsuMania = 3,
|
||||
}
|
||||
}
|
21
osu.Game/Database/Beatmap.cs
Normal file
21
osu.Game/Database/Beatmap.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using SQLite;
|
||||
|
||||
namespace osu.Game.Database
|
||||
{
|
||||
public class Beatmap
|
||||
{
|
||||
[PrimaryKey]
|
||||
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; }
|
||||
public float ApproachRate { get; set; }
|
||||
public float SliderMultiplier { get; set; }
|
||||
public float SliderTickRate { get; set; }
|
||||
}
|
||||
}
|
21
osu.Game/Database/BeatmapDatabase.cs
Normal file
21
osu.Game/Database/BeatmapDatabase.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using SQLite;
|
||||
|
||||
namespace osu.Game.Database
|
||||
{
|
||||
public class BeatmapDatabase
|
||||
{
|
||||
private static SQLiteConnection Connection { get; set; }
|
||||
|
||||
public BeatmapDatabase()
|
||||
{
|
||||
if (Connection == null)
|
||||
{
|
||||
Connection = new SQLiteConnection("beatmap.db");
|
||||
Connection.CreateTable<BeatmapMetadata>();
|
||||
Connection.CreateTable<BeatmapSet>();
|
||||
Connection.CreateTable<Beatmap>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
23
osu.Game/Database/BeatmapMetadata.cs
Normal file
23
osu.Game/Database/BeatmapMetadata.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using osu.Game.Beatmaps;
|
||||
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 GameMode Mode { get; set; }
|
||||
public int PreviewTime { get; set; }
|
||||
public string AudioFile { get; set; }
|
||||
public string BackgroundFile { get; set; }
|
||||
}
|
||||
}
|
14
osu.Game/Database/BeatmapSet.cs
Normal file
14
osu.Game/Database/BeatmapSet.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using SQLite;
|
||||
|
||||
namespace osu.Game.Database
|
||||
{
|
||||
public class BeatmapSet
|
||||
{
|
||||
[PrimaryKey]
|
||||
public int BeatmapSetID { get; set; }
|
||||
[NotNull, Indexed]
|
||||
public int MetadataID { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.IO.Stores;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Graphics.Cursor;
|
||||
using osu.Game.Graphics.Processing;
|
||||
using osu.Game.Online.API;
|
||||
@ -16,6 +17,7 @@ namespace osu.Game
|
||||
public class OsuGameBase : BaseGame
|
||||
{
|
||||
internal OsuConfigManager Config = new OsuConfigManager();
|
||||
internal BeatmapDatabase Beatmaps = new BeatmapDatabase();
|
||||
|
||||
protected override string MainResourceFile => @"osu.Game.Resources.dll";
|
||||
|
||||
|
@ -43,6 +43,18 @@
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="SQLitePCLRaw.core">
|
||||
<HintPath>..\packages\SQLitePCLRaw.core.1.0.1\lib\net45\SQLitePCLRaw.core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SQLitePCLRaw.provider.e_sqlite3">
|
||||
<HintPath>..\packages\SQLitePCLRaw.provider.e_sqlite3.net45.1.0.1\lib\net45\SQLitePCLRaw.provider.e_sqlite3.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SQLitePCLRaw.batteries_green">
|
||||
<HintPath>..\packages\SQLitePCLRaw.bundle_green.1.0.1\lib\net45\SQLitePCLRaw.batteries_green.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SQLite-net">
|
||||
<HintPath>..\packages\sqlite-net-pcl.1.2.0\lib\portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10\SQLite-net.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Beatmaps\Beatmap.cs" />
|
||||
@ -148,6 +160,11 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<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\GameMode.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\osu-framework\osu.Framework\osu.Framework.csproj">
|
||||
@ -166,6 +183,9 @@
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<Folder Include="Database\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
@ -174,4 +194,7 @@
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<Import Project="..\packages\SQLitePCLRaw.lib.e_sqlite3.v110_xp.1.0.1\build\SQLitePCLRaw.lib.e_sqlite3.v110_xp.targets" Condition="Exists('..\packages\SQLitePCLRaw.lib.e_sqlite3.v110_xp.1.0.1\build\SQLitePCLRaw.lib.e_sqlite3.v110_xp.targets')" />
|
||||
<Import Project="..\packages\SQLitePCLRaw.lib.e_sqlite3.osx.1.0.1\build\SQLitePCLRaw.lib.e_sqlite3.osx.targets" Condition="Exists('..\packages\SQLitePCLRaw.lib.e_sqlite3.osx.1.0.1\build\SQLitePCLRaw.lib.e_sqlite3.osx.targets')" />
|
||||
<Import Project="..\packages\SQLitePCLRaw.lib.e_sqlite3.linux.1.0.1\build\SQLitePCLRaw.lib.e_sqlite3.linux.targets" Condition="Exists('..\packages\SQLitePCLRaw.lib.e_sqlite3.linux.1.0.1\build\SQLitePCLRaw.lib.e_sqlite3.linux.targets')" />
|
||||
</Project>
|
@ -6,4 +6,11 @@ Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/maste
|
||||
<packages>
|
||||
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net45" />
|
||||
<package id="ppy.OpenTK" version="1.1.2225.3" targetFramework="net45" />
|
||||
<package id="sqlite-net-pcl" version="1.2.0" targetFramework="net45" />
|
||||
<package id="SQLitePCLRaw.bundle_green" version="1.0.1" targetFramework="net45" />
|
||||
<package id="SQLitePCLRaw.core" version="1.0.1" targetFramework="net45" />
|
||||
<package id="SQLitePCLRaw.lib.e_sqlite3.linux" version="1.0.1" targetFramework="net45" />
|
||||
<package id="SQLitePCLRaw.lib.e_sqlite3.osx" version="1.0.1" targetFramework="net45" />
|
||||
<package id="SQLitePCLRaw.lib.e_sqlite3.v110_xp" version="1.0.1" targetFramework="net45" />
|
||||
<package id="SQLitePCLRaw.provider.e_sqlite3.net45" version="1.0.1" targetFramework="net45" />
|
||||
</packages>
|
Loading…
Reference in New Issue
Block a user