mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 16:03:01 +08:00
Make BeatmapOnlineInfo and BeatmapSetOnlineInfo separate classes, -OnlineWorkingBeatmap
This commit is contained in:
parent
e67a00f1f6
commit
ab32e962ca
@ -48,6 +48,13 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
Author = @"RLC",
|
Author = @"RLC",
|
||||||
Source = @"",
|
Source = @"",
|
||||||
},
|
},
|
||||||
|
OnlineInfo = new BeatmapSetOnlineInfo
|
||||||
|
{
|
||||||
|
Covers = new[] { @"https://assets.ppy.sh//beatmaps/578332/covers/cover.jpg?1494591390" },
|
||||||
|
Preview = @"https://b.ppy.sh/preview/578332.mp3",
|
||||||
|
PlayCount = 97,
|
||||||
|
FavouriteCount = 72,
|
||||||
|
},
|
||||||
Beatmaps = new List<BeatmapInfo>
|
Beatmaps = new List<BeatmapInfo>
|
||||||
{
|
{
|
||||||
new BeatmapInfo
|
new BeatmapInfo
|
||||||
@ -55,13 +62,6 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
Ruleset = ruleset,
|
Ruleset = ruleset,
|
||||||
StarDifficulty = 5.35f,
|
StarDifficulty = 5.35f,
|
||||||
Metadata = new BeatmapMetadata(),
|
Metadata = new BeatmapMetadata(),
|
||||||
OnlineInfo = new BeatmapOnlineInfo
|
|
||||||
{
|
|
||||||
Covers = new[] { @"https://assets.ppy.sh//beatmaps/578332/covers/cover.jpg?1494591390" },
|
|
||||||
Preview = @"https://b.ppy.sh/preview/578332.mp3",
|
|
||||||
PlayCount = 97,
|
|
||||||
FavouriteCount = 72,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -74,6 +74,13 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
Author = @"Sotarks",
|
Author = @"Sotarks",
|
||||||
Source = @"ぎんぎつね",
|
Source = @"ぎんぎつね",
|
||||||
},
|
},
|
||||||
|
OnlineInfo = new BeatmapSetOnlineInfo
|
||||||
|
{
|
||||||
|
Covers = new[] { @"https://assets.ppy.sh//beatmaps/599627/covers/cover.jpg?1494539318" },
|
||||||
|
Preview = @"https//b.ppy.sh/preview/599627.mp3",
|
||||||
|
PlayCount = 3082,
|
||||||
|
FavouriteCount = 14,
|
||||||
|
},
|
||||||
Beatmaps = new List<BeatmapInfo>
|
Beatmaps = new List<BeatmapInfo>
|
||||||
{
|
{
|
||||||
new BeatmapInfo
|
new BeatmapInfo
|
||||||
@ -81,13 +88,6 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
Ruleset = ruleset,
|
Ruleset = ruleset,
|
||||||
StarDifficulty = 5.81f,
|
StarDifficulty = 5.81f,
|
||||||
Metadata = new BeatmapMetadata(),
|
Metadata = new BeatmapMetadata(),
|
||||||
OnlineInfo = new BeatmapOnlineInfo
|
|
||||||
{
|
|
||||||
Covers = new[] { @"https://assets.ppy.sh//beatmaps/599627/covers/cover.jpg?1494539318" },
|
|
||||||
Preview = @"https//b.ppy.sh/preview/599627.mp3",
|
|
||||||
PlayCount = 3082,
|
|
||||||
FavouriteCount = 14,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -100,6 +100,13 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
Author = @"Cerulean Veyron",
|
Author = @"Cerulean Veyron",
|
||||||
Source = @"",
|
Source = @"",
|
||||||
},
|
},
|
||||||
|
OnlineInfo = new BeatmapSetOnlineInfo
|
||||||
|
{
|
||||||
|
Covers = new[] { @"https://assets.ppy.sh//beatmaps/513268/covers/cover.jpg?1494502863" },
|
||||||
|
Preview = @"https//b.ppy.sh/preview/513268.mp3",
|
||||||
|
PlayCount = 2762,
|
||||||
|
FavouriteCount = 15,
|
||||||
|
},
|
||||||
Beatmaps = new List<BeatmapInfo>
|
Beatmaps = new List<BeatmapInfo>
|
||||||
{
|
{
|
||||||
new BeatmapInfo
|
new BeatmapInfo
|
||||||
@ -107,13 +114,6 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
Ruleset = ruleset,
|
Ruleset = ruleset,
|
||||||
StarDifficulty = 0.9f,
|
StarDifficulty = 0.9f,
|
||||||
Metadata = new BeatmapMetadata(),
|
Metadata = new BeatmapMetadata(),
|
||||||
OnlineInfo = new BeatmapOnlineInfo
|
|
||||||
{
|
|
||||||
Covers = new[] { @"https://assets.ppy.sh//beatmaps/513268/covers/cover.jpg?1494502863" },
|
|
||||||
Preview = @"https//b.ppy.sh/preview/513268.mp3",
|
|
||||||
PlayCount = 2762,
|
|
||||||
FavouriteCount = 15,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
new BeatmapInfo
|
new BeatmapInfo
|
||||||
{
|
{
|
||||||
@ -141,6 +141,13 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
Author = @"[Kamiya]",
|
Author = @"[Kamiya]",
|
||||||
Source = @"小林さんちのメイドラゴン",
|
Source = @"小林さんちのメイドラゴン",
|
||||||
},
|
},
|
||||||
|
OnlineInfo = new BeatmapSetOnlineInfo
|
||||||
|
{
|
||||||
|
Covers = new[] { @"https://assets.ppy.sh//beatmaps/586841/covers/cover.jpg?1494052741" },
|
||||||
|
Preview = @"https//b.ppy.sh/preview/586841.mp3",
|
||||||
|
PlayCount = 62317,
|
||||||
|
FavouriteCount = 161,
|
||||||
|
},
|
||||||
Beatmaps = new List<BeatmapInfo>
|
Beatmaps = new List<BeatmapInfo>
|
||||||
{
|
{
|
||||||
new BeatmapInfo
|
new BeatmapInfo
|
||||||
@ -148,13 +155,6 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
Ruleset = ruleset,
|
Ruleset = ruleset,
|
||||||
StarDifficulty = 1.26f,
|
StarDifficulty = 1.26f,
|
||||||
Metadata = new BeatmapMetadata(),
|
Metadata = new BeatmapMetadata(),
|
||||||
OnlineInfo = new BeatmapOnlineInfo
|
|
||||||
{
|
|
||||||
Covers = new[] { @"https://assets.ppy.sh//beatmaps/586841/covers/cover.jpg?1494052741" },
|
|
||||||
Preview = @"https//b.ppy.sh/preview/586841.mp3",
|
|
||||||
PlayCount = 62317,
|
|
||||||
FavouriteCount = 161,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
new BeatmapInfo
|
new BeatmapInfo
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// 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
|
||||||
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using SQLite.Net.Attributes;
|
using SQLite.Net.Attributes;
|
||||||
|
|
||||||
namespace osu.Game.Database
|
namespace osu.Game.Database
|
||||||
@ -17,7 +18,10 @@ namespace osu.Game.Database
|
|||||||
public string TitleUnicode { get; set; }
|
public string TitleUnicode { get; set; }
|
||||||
public string Artist { get; set; }
|
public string Artist { get; set; }
|
||||||
public string ArtistUnicode { get; set; }
|
public string ArtistUnicode { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty(@"creator")]
|
||||||
public string Author { get; set; }
|
public string Author { get; set; }
|
||||||
|
|
||||||
public string Source { get; set; }
|
public string Source { get; set; }
|
||||||
public string Tags { get; set; }
|
public string Tags { get; set; }
|
||||||
public int PreviewTime { get; set; }
|
public int PreviewTime { get; set; }
|
||||||
|
@ -11,28 +11,16 @@ namespace osu.Game.Database
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class BeatmapOnlineInfo
|
public class BeatmapOnlineInfo
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// The different sizes of cover art for this beatmap: cover, cover@2x, card, card@2x, list, list@2x.
|
|
||||||
/// </summary>
|
|
||||||
[JsonProperty(@"covers")]
|
|
||||||
public IEnumerable<string> Covers { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// A small sample clip of this beatmap's song.
|
|
||||||
/// </summary>
|
|
||||||
[JsonProperty(@"previewUrl")]
|
|
||||||
public string Preview { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The amount of plays this beatmap has.
|
/// The amount of plays this beatmap has.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty(@"play_count")]
|
[JsonProperty(@"playcount")]
|
||||||
public int PlayCount { get; set; }
|
public int PlayCount { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The amount of people who have favourited this map.
|
/// The amount of passes this beatmap has.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty(@"favourite_count")]
|
[JsonProperty(@"passcount")]
|
||||||
public int FavouriteCount { get; set; }
|
public int PassCount { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,9 @@ namespace osu.Game.Database
|
|||||||
[OneToMany(CascadeOperations = CascadeOperation.All)]
|
[OneToMany(CascadeOperations = CascadeOperation.All)]
|
||||||
public List<BeatmapInfo> Beatmaps { get; set; }
|
public List<BeatmapInfo> Beatmaps { get; set; }
|
||||||
|
|
||||||
|
[Ignore]
|
||||||
|
public BeatmapSetOnlineInfo OnlineInfo { get; set; }
|
||||||
|
|
||||||
public double MaxStarDifficulty => Beatmaps.Max(b => b.StarDifficulty);
|
public double MaxStarDifficulty => Beatmaps.Max(b => b.StarDifficulty);
|
||||||
|
|
||||||
[Indexed]
|
[Indexed]
|
||||||
|
38
osu.Game/Database/BeatmapSetOnlineInfo.cs
Normal file
38
osu.Game/Database/BeatmapSetOnlineInfo.cs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace osu.Game.Database
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Beatmap set info retrieved for previewing locally without having the set downloaded.
|
||||||
|
/// </summary>
|
||||||
|
public class BeatmapSetOnlineInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The different sizes of cover art for this beatmap: cover, cover@2x, card, card@2x, list, list@2x.
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty(@"covers")]
|
||||||
|
public IEnumerable<string> Covers { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A small sample clip of this beatmap's song.
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty(@"previewUrl")]
|
||||||
|
public string Preview { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The amount of plays this set has.
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty(@"play_count")]
|
||||||
|
public int PlayCount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The amount of people who have favourited this map.
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty(@"favourite_count")]
|
||||||
|
public int FavouriteCount { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -1,37 +0,0 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
||||||
|
|
||||||
using System.Linq;
|
|
||||||
using osu.Framework.Audio.Track;
|
|
||||||
using osu.Framework.Graphics.Textures;
|
|
||||||
using osu.Game.Beatmaps;
|
|
||||||
|
|
||||||
namespace osu.Game.Database
|
|
||||||
{
|
|
||||||
internal class OnlineWorkingBeatmap : WorkingBeatmap
|
|
||||||
{
|
|
||||||
private readonly TextureStore textures;
|
|
||||||
private readonly TrackManager tracks;
|
|
||||||
|
|
||||||
public OnlineWorkingBeatmap(BeatmapInfo beatmapInfo, TextureStore textures, TrackManager tracks) : base(beatmapInfo)
|
|
||||||
{
|
|
||||||
this.textures = textures;
|
|
||||||
this.tracks = tracks;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override Beatmap GetBeatmap()
|
|
||||||
{
|
|
||||||
return new Beatmap();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override Texture GetBackground()
|
|
||||||
{
|
|
||||||
return textures.Get(BeatmapInfo.OnlineInfo.Covers.FirstOrDefault());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override Track GetTrack()
|
|
||||||
{
|
|
||||||
return tracks.Get(BeatmapInfo.OnlineInfo.Preview);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -180,11 +180,11 @@ namespace osu.Game.Overlays.Direct
|
|||||||
Margin = new MarginPadding { Top = vertical_padding, Right = vertical_padding },
|
Margin = new MarginPadding { Top = vertical_padding, Right = vertical_padding },
|
||||||
Children = new[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
new Statistic(FontAwesome.fa_play_circle, SetInfo.Beatmaps.FirstOrDefault()?.OnlineInfo.PlayCount ?? 0)
|
new Statistic(FontAwesome.fa_play_circle, SetInfo.OnlineInfo?.PlayCount ?? 0)
|
||||||
{
|
{
|
||||||
Margin = new MarginPadding { Right = 1 },
|
Margin = new MarginPadding { Right = 1 },
|
||||||
},
|
},
|
||||||
new Statistic(FontAwesome.fa_heart, SetInfo.Beatmaps.FirstOrDefault()?.OnlineInfo.FavouriteCount ?? 0),
|
new Statistic(FontAwesome.fa_heart, SetInfo.OnlineInfo?.FavouriteCount ?? 0),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -104,11 +104,11 @@ namespace osu.Game.Overlays.Direct
|
|||||||
Margin = new MarginPadding { Right = height - vertical_padding * 2 + vertical_padding },
|
Margin = new MarginPadding { Right = height - vertical_padding * 2 + vertical_padding },
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new Statistic(FontAwesome.fa_play_circle, SetInfo.Beatmaps.FirstOrDefault()?.OnlineInfo.PlayCount ?? 0)
|
new Statistic(FontAwesome.fa_play_circle, SetInfo.OnlineInfo?.PlayCount ?? 0)
|
||||||
{
|
{
|
||||||
Margin = new MarginPadding { Right = 1 },
|
Margin = new MarginPadding { Right = 1 },
|
||||||
},
|
},
|
||||||
new Statistic(FontAwesome.fa_heart, SetInfo.Beatmaps.FirstOrDefault()?.OnlineInfo.FavouriteCount ?? 0),
|
new Statistic(FontAwesome.fa_heart, SetInfo.OnlineInfo?.FavouriteCount ?? 0),
|
||||||
new FillFlowContainer
|
new FillFlowContainer
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
@ -36,7 +37,7 @@ namespace osu.Game.Overlays.Direct
|
|||||||
|
|
||||||
protected Drawable GetBackground(TextureStore textures)
|
protected Drawable GetBackground(TextureStore textures)
|
||||||
{
|
{
|
||||||
return new AsyncLoadWrapper(new BeatmapBackgroundSprite(new OnlineWorkingBeatmap(SetInfo.Beatmaps.FirstOrDefault(), textures, null))
|
return new AsyncLoadWrapper(new BeatmapSetBackgroundSprite(SetInfo)
|
||||||
{
|
{
|
||||||
FillMode = FillMode.Fill,
|
FillMode = FillMode.Fill,
|
||||||
OnLoadComplete = d => d.FadeInFromZero(400, EasingTypes.Out),
|
OnLoadComplete = d => d.FadeInFromZero(400, EasingTypes.Out),
|
||||||
@ -84,5 +85,22 @@ namespace osu.Game.Overlays.Direct
|
|||||||
Value = value;
|
Value = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class BeatmapSetBackgroundSprite : Sprite
|
||||||
|
{
|
||||||
|
private readonly BeatmapSetInfo set;
|
||||||
|
|
||||||
|
public BeatmapSetBackgroundSprite(BeatmapSetInfo set)
|
||||||
|
{
|
||||||
|
this.set = set;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(TextureStore textures)
|
||||||
|
{
|
||||||
|
if (set.OnlineInfo?.Covers.FirstOrDefault() != null)
|
||||||
|
Texture = textures.Get(set.OnlineInfo.Covers.First());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -445,11 +445,11 @@
|
|||||||
<Compile Include="Overlays\Direct\DirectPanel.cs" />
|
<Compile Include="Overlays\Direct\DirectPanel.cs" />
|
||||||
<Compile Include="Overlays\Direct\DirectGridPanel.cs" />
|
<Compile Include="Overlays\Direct\DirectGridPanel.cs" />
|
||||||
<Compile Include="Overlays\Direct\DirectListPanel.cs" />
|
<Compile Include="Overlays\Direct\DirectListPanel.cs" />
|
||||||
<Compile Include="Database\OnlineWorkingBeatmap.cs" />
|
|
||||||
<Compile Include="Database\BeatmapOnlineInfo.cs" />
|
<Compile Include="Database\BeatmapOnlineInfo.cs" />
|
||||||
<Compile Include="Overlays\Direct\SlimEnumDropdown.cs" />
|
<Compile Include="Overlays\Direct\SlimEnumDropdown.cs" />
|
||||||
<Compile Include="Graphics\Containers\ReverseDepthFillFlowContainer.cs" />
|
<Compile Include="Graphics\Containers\ReverseDepthFillFlowContainer.cs" />
|
||||||
<Compile Include="Database\RankStatus.cs" />
|
<Compile Include="Database\RankStatus.cs" />
|
||||||
|
<Compile Include="Database\BeatmapSetOnlineInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\osu-framework\osu.Framework\osu.Framework.csproj">
|
<ProjectReference Include="..\osu-framework\osu.Framework\osu.Framework.csproj">
|
||||||
|
Loading…
Reference in New Issue
Block a user