mirror of
https://github.com/ppy/osu.git
synced 2025-02-08 00:12:57 +08:00
Add initial DB schema and support code
This commit is contained in:
parent
48bd998f46
commit
bf644c2fc6
@ -11,7 +11,7 @@ namespace osu.Desktop
|
|||||||
public static class Program
|
public static class Program
|
||||||
{
|
{
|
||||||
[STAThread]
|
[STAThread]
|
||||||
public static void Main()
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
BasicGameHost host = Host.GetSuitableHost(@"osu");
|
BasicGameHost host = Host.GetSuitableHost(@"osu");
|
||||||
host.Add(new OsuGame());
|
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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -5,6 +5,7 @@ using osu.Framework.Graphics.Cursor;
|
|||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Framework.IO.Stores;
|
using osu.Framework.IO.Stores;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Database;
|
||||||
using osu.Game.Graphics.Cursor;
|
using osu.Game.Graphics.Cursor;
|
||||||
using osu.Game.Graphics.Processing;
|
using osu.Game.Graphics.Processing;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
@ -15,6 +16,7 @@ namespace osu.Game
|
|||||||
public class OsuGameBase : Framework.Game
|
public class OsuGameBase : Framework.Game
|
||||||
{
|
{
|
||||||
internal OsuConfigManager Config = new OsuConfigManager();
|
internal OsuConfigManager Config = new OsuConfigManager();
|
||||||
|
internal BeatmapDatabase Beatmaps = new BeatmapDatabase();
|
||||||
|
|
||||||
protected override string MainResourceFile => @"osu.Game.Resources.dll";
|
protected override string MainResourceFile => @"osu.Game.Resources.dll";
|
||||||
|
|
||||||
|
@ -43,6 +43,18 @@
|
|||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<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>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Beatmaps\Beatmap.cs" />
|
<Compile Include="Beatmaps\Beatmap.cs" />
|
||||||
@ -133,6 +145,11 @@
|
|||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Users\User.cs" />
|
<Compile Include="Users\User.cs" />
|
||||||
<Compile Include="VolumeControl.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>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\osu-framework\osu.Framework\osu.Framework.csproj">
|
<ProjectReference Include="..\osu-framework\osu.Framework\osu.Framework.csproj">
|
||||||
@ -151,6 +168,9 @@
|
|||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup />
|
<ItemGroup />
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Database\" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- 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.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
@ -159,4 +179,7 @@
|
|||||||
<Target Name="AfterBuild">
|
<Target Name="AfterBuild">
|
||||||
</Target>
|
</Target>
|
||||||
-->
|
-->
|
||||||
</Project>
|
<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>
|
||||||
|
@ -1,9 +1,16 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!--
|
<!--
|
||||||
Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
-->
|
-->
|
||||||
<packages>
|
<packages>
|
||||||
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net45" />
|
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net45" />
|
||||||
<package id="ppy.OpenTK" version="1.1.2225.3" targetFramework="net45" />
|
<package id="ppy.OpenTK" version="1.1.2225.3" targetFramework="net45" />
|
||||||
</packages>
|
<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>
|
||||||
|
29
osu.sln
29
osu.sln
@ -61,4 +61,33 @@ Global
|
|||||||
{65DC628F-A640-4111-AB35-3A5652BC1E17} = {7A75DFA2-DE65-4458-98AF-26AF96FFD6DC}
|
{65DC628F-A640-4111-AB35-3A5652BC1E17} = {7A75DFA2-DE65-4458-98AF-26AF96FFD6DC}
|
||||||
{69051C69-12AE-4E7D-A3E6-460D2E282312} = {0D37A2AD-80A4-464F-A1DE-1560B70F1CE3}
|
{69051C69-12AE-4E7D-A3E6-460D2E282312} = {0D37A2AD-80A4-464F-A1DE-1560B70F1CE3}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
|
GlobalSection(MonoDevelopProperties) = preSolution
|
||||||
|
Policies = $0
|
||||||
|
$0.TextStylePolicy = $1
|
||||||
|
$1.EolMarker = Windows
|
||||||
|
$1.inheritsSet = VisualStudio
|
||||||
|
$1.inheritsScope = text/plain
|
||||||
|
$1.scope = text/x-csharp
|
||||||
|
$0.CSharpFormattingPolicy = $2
|
||||||
|
$2.IndentSwitchSection = True
|
||||||
|
$2.NewLinesForBracesInProperties = True
|
||||||
|
$2.NewLinesForBracesInAccessors = True
|
||||||
|
$2.NewLinesForBracesInAnonymousMethods = True
|
||||||
|
$2.NewLinesForBracesInControlBlocks = True
|
||||||
|
$2.NewLinesForBracesInAnonymousTypes = True
|
||||||
|
$2.NewLinesForBracesInObjectCollectionArrayInitializers = True
|
||||||
|
$2.NewLinesForBracesInLambdaExpressionBody = True
|
||||||
|
$2.NewLineForElse = True
|
||||||
|
$2.NewLineForCatch = True
|
||||||
|
$2.NewLineForFinally = True
|
||||||
|
$2.NewLineForMembersInObjectInit = True
|
||||||
|
$2.NewLineForMembersInAnonymousTypes = True
|
||||||
|
$2.NewLineForClausesInQuery = True
|
||||||
|
$2.SpacingAfterMethodDeclarationName = False
|
||||||
|
$2.SpaceAfterMethodCallName = False
|
||||||
|
$2.SpaceBeforeOpenSquareBracket = False
|
||||||
|
$2.inheritsSet = Mono
|
||||||
|
$2.inheritsScope = text/x-csharp
|
||||||
|
$2.scope = text/x-csharp
|
||||||
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
Loading…
Reference in New Issue
Block a user