mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 09:02:58 +08:00
+BeatmapOnlineInfo, +OnlineWorkingBeatmap, minor cleanups, panel beatmap backgrounds
This commit is contained in:
parent
3b8cadd4df
commit
e1c4c36122
@ -39,32 +39,165 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
|
||||
private void newBeatmaps()
|
||||
{
|
||||
var setInfo = new BeatmapSetInfo
|
||||
var ruleset = rulesets.GetRuleset(0);
|
||||
|
||||
direct.BeatmapSets = new BeatmapSetInfo[]
|
||||
{
|
||||
Metadata = new BeatmapMetadata
|
||||
new BeatmapSetInfo
|
||||
{
|
||||
Title = @"Platina",
|
||||
Artist = @"Maaya Sakamoto",
|
||||
Author = @"TicClick",
|
||||
Source = @"Cardcaptor Sakura",
|
||||
Metadata = new BeatmapMetadata
|
||||
{
|
||||
Title = @"OrVid",
|
||||
Artist = @"An",
|
||||
Author = @"RLC",
|
||||
Source = @"",
|
||||
},
|
||||
Beatmaps = new List<BeatmapInfo>
|
||||
{
|
||||
new BeatmapInfo
|
||||
{
|
||||
Ruleset = ruleset,
|
||||
StarDifficulty = 5.35f,
|
||||
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,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Beatmaps = new List<BeatmapInfo>(),
|
||||
};
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
setInfo.Beatmaps.Add(new BeatmapInfo
|
||||
new BeatmapSetInfo
|
||||
{
|
||||
Ruleset = rulesets.GetRuleset(i),
|
||||
StarDifficulty = i + 1,
|
||||
});
|
||||
}
|
||||
|
||||
var s = new List<BeatmapSetInfo>();
|
||||
for (int i = 0; i < 10; i++)
|
||||
s.Add(setInfo);
|
||||
|
||||
direct.BeatmapSets = s;
|
||||
Metadata = new BeatmapMetadata
|
||||
{
|
||||
Title = @"tiny lamp",
|
||||
Artist = @"fhana",
|
||||
Author = @"Sotarks",
|
||||
Source = @"ぎんぎつね",
|
||||
},
|
||||
Beatmaps = new List<BeatmapInfo>
|
||||
{
|
||||
new BeatmapInfo
|
||||
{
|
||||
Ruleset = ruleset,
|
||||
StarDifficulty = 5.81f,
|
||||
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,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
new BeatmapSetInfo
|
||||
{
|
||||
Metadata = new BeatmapMetadata
|
||||
{
|
||||
Title = @"At Gwanghwamun",
|
||||
Artist = @"KYUHYUN",
|
||||
Author = @"Cerulean Veyron",
|
||||
Source = @"",
|
||||
},
|
||||
Beatmaps = new List<BeatmapInfo>
|
||||
{
|
||||
new BeatmapInfo
|
||||
{
|
||||
Ruleset = ruleset,
|
||||
StarDifficulty = 0.9f,
|
||||
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
|
||||
{
|
||||
Ruleset = ruleset,
|
||||
StarDifficulty = 1.1f,
|
||||
},
|
||||
new BeatmapInfo
|
||||
{
|
||||
Ruleset = ruleset,
|
||||
StarDifficulty = 2.02f,
|
||||
},
|
||||
new BeatmapInfo
|
||||
{
|
||||
Ruleset = ruleset,
|
||||
StarDifficulty = 3.49f,
|
||||
},
|
||||
},
|
||||
},
|
||||
new BeatmapSetInfo
|
||||
{
|
||||
Metadata = new BeatmapMetadata
|
||||
{
|
||||
Title = @"RHAPSODY OF BLUE SKY",
|
||||
Artist = @"fhana",
|
||||
Author = @"[Kamiya]",
|
||||
Source = @"小林さんちのメイドラゴン",
|
||||
},
|
||||
Beatmaps = new List<BeatmapInfo>
|
||||
{
|
||||
new BeatmapInfo
|
||||
{
|
||||
Ruleset = ruleset,
|
||||
StarDifficulty = 1.26f,
|
||||
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
|
||||
{
|
||||
Ruleset = ruleset,
|
||||
StarDifficulty = 2.01f,
|
||||
},
|
||||
new BeatmapInfo
|
||||
{
|
||||
Ruleset = ruleset,
|
||||
StarDifficulty = 2.87f,
|
||||
},
|
||||
new BeatmapInfo
|
||||
{
|
||||
Ruleset = ruleset,
|
||||
StarDifficulty = 3.76f,
|
||||
},
|
||||
new BeatmapInfo
|
||||
{
|
||||
Ruleset = ruleset,
|
||||
StarDifficulty = 3.93f,
|
||||
},
|
||||
new BeatmapInfo
|
||||
{
|
||||
Ruleset = ruleset,
|
||||
StarDifficulty = 4.37f,
|
||||
},
|
||||
new BeatmapInfo
|
||||
{
|
||||
Ruleset = ruleset,
|
||||
StarDifficulty = 5.13f,
|
||||
},
|
||||
new BeatmapInfo
|
||||
{
|
||||
Ruleset = ruleset,
|
||||
StarDifficulty = 5.42f,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,9 @@ namespace osu.Game.Database
|
||||
[Ignore]
|
||||
public BeatmapMetrics Metrics { get; set; }
|
||||
|
||||
[Ignore]
|
||||
public BeatmapOnlineInfo OnlineInfo { get; set; }
|
||||
|
||||
public string Path { get; set; }
|
||||
|
||||
[JsonProperty("file_md5")]
|
||||
|
38
osu.Game/Database/BeatmapOnlineInfo.cs
Normal file
38
osu.Game/Database/BeatmapOnlineInfo.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 info retrieved for non-local viewing.
|
||||
/// </summary>
|
||||
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>
|
||||
/// The amount of plays this beatmap 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; }
|
||||
}
|
||||
}
|
37
osu.Game/Database/OnlineWorkingBeatmap.cs
Normal file
37
osu.Game/Database/OnlineWorkingBeatmap.cs
Normal file
@ -0,0 +1,37 @@
|
||||
// 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 TextureStore textures;
|
||||
private 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);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
// 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.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
@ -9,8 +9,8 @@ using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
@ -37,7 +37,7 @@ namespace osu.Game.Overlays.Direct
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours, LocalisationEngine localisation)
|
||||
private void load(OsuColour colours, LocalisationEngine localisation, TextureStore textures)
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
@ -46,9 +46,13 @@ namespace osu.Game.Overlays.Direct
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
},
|
||||
new Sprite
|
||||
new Container
|
||||
{
|
||||
FillMode = FillMode.Fill,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new[]
|
||||
{
|
||||
GetBackground(textures),
|
||||
},
|
||||
},
|
||||
new Box
|
||||
{
|
||||
@ -126,18 +130,27 @@ namespace osu.Game.Overlays.Direct
|
||||
},
|
||||
},
|
||||
},
|
||||
new OsuSpriteText
|
||||
new Container
|
||||
{
|
||||
Text = $@"from {SetInfo.Metadata.Source}",
|
||||
TextSize = 14,
|
||||
Shadow = false,
|
||||
Colour = colours.Gray5,
|
||||
AutoSizeAxes = Axes.X,
|
||||
Height = 14,
|
||||
Children = new[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = $@"from {SetInfo.Metadata.Source}",
|
||||
TextSize = 14,
|
||||
Shadow = false,
|
||||
Colour = colours.Gray5,
|
||||
Alpha = SetInfo.Metadata.Source == @"" ? 0 : 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.X,
|
||||
Height = 20,
|
||||
Margin = new MarginPadding { Top = vertical_padding, Bottom = vertical_padding },
|
||||
Margin = new MarginPadding { Top = vertical_padding, Bottom = vertical_padding },
|
||||
Children = DifficultyIcons,
|
||||
},
|
||||
},
|
||||
@ -155,11 +168,11 @@ namespace osu.Game.Overlays.Direct
|
||||
Margin = new MarginPadding { Top = vertical_padding, Right = vertical_padding },
|
||||
Children = new[]
|
||||
{
|
||||
new Statistic(FontAwesome.fa_play_circle)
|
||||
new Statistic(FontAwesome.fa_play_circle, SetInfo.Beatmaps.FirstOrDefault()?.OnlineInfo.PlayCount ?? 0)
|
||||
{
|
||||
Margin = new MarginPadding { Right = 1 },
|
||||
},
|
||||
new Statistic(FontAwesome.fa_heart),
|
||||
new Statistic(FontAwesome.fa_heart, SetInfo.Beatmaps.FirstOrDefault()?.OnlineInfo.FavouriteCount ?? 0),
|
||||
},
|
||||
},
|
||||
};
|
||||
|
@ -13,6 +13,8 @@ using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Database;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using System.Linq;
|
||||
|
||||
namespace osu.Game.Overlays.Direct
|
||||
{
|
||||
@ -38,7 +40,7 @@ namespace osu.Game.Overlays.Direct
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(LocalisationEngine localisation)
|
||||
private void load(LocalisationEngine localisation, TextureStore textures)
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
@ -47,9 +49,13 @@ namespace osu.Game.Overlays.Direct
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
},
|
||||
new Sprite
|
||||
new Container
|
||||
{
|
||||
FillMode = FillMode.Fill,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new[]
|
||||
{
|
||||
GetBackground(textures),
|
||||
},
|
||||
},
|
||||
new Box
|
||||
{
|
||||
@ -97,11 +103,11 @@ namespace osu.Game.Overlays.Direct
|
||||
Margin = new MarginPadding { Right = (height - vertical_padding * 2) + vertical_padding },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Statistic(FontAwesome.fa_play_circle)
|
||||
new Statistic(FontAwesome.fa_play_circle, SetInfo.Beatmaps.FirstOrDefault()?.OnlineInfo.PlayCount ?? 0)
|
||||
{
|
||||
Margin = new MarginPadding { Right = 1 },
|
||||
},
|
||||
new Statistic(FontAwesome.fa_heart),
|
||||
new Statistic(FontAwesome.fa_heart, SetInfo.Beatmaps.FirstOrDefault()?.OnlineInfo.FavouriteCount ?? 0),
|
||||
new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
@ -129,6 +135,7 @@ namespace osu.Game.Overlays.Direct
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
TextSize = 14,
|
||||
Alpha = SetInfo.Metadata.Source == @"" ? 0 : 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -2,10 +2,12 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenTK;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Graphics;
|
||||
@ -30,7 +32,14 @@ namespace osu.Game.Overlays.Direct
|
||||
}
|
||||
}
|
||||
|
||||
//todo: Direct panel backgrounds
|
||||
protected Drawable GetBackground(TextureStore textures)
|
||||
{
|
||||
return new AsyncLoadWrapper(new Sprite
|
||||
{
|
||||
FillMode = FillMode.Fill,
|
||||
Texture = new OnlineWorkingBeatmap(SetInfo.Beatmaps.FirstOrDefault(), textures, null).Background,
|
||||
}) { RelativeSizeAxes = Axes.Both };
|
||||
}
|
||||
|
||||
public DirectPanel(BeatmapSetInfo setInfo)
|
||||
{
|
||||
|
@ -29,7 +29,7 @@ namespace osu.Game.Overlays
|
||||
var p = new List<DirectPanel>();
|
||||
|
||||
foreach (BeatmapSetInfo b in value)
|
||||
p.Add(new DirectGridPanel(b) { Width = 400 });
|
||||
p.Add(new DirectListPanel(b));
|
||||
|
||||
panels.Children = p;
|
||||
}
|
||||
|
@ -436,6 +436,8 @@
|
||||
<Compile Include="Overlays\Direct\DirectPanel.cs" />
|
||||
<Compile Include="Overlays\Direct\DirectGridPanel.cs" />
|
||||
<Compile Include="Overlays\Direct\DirectListPanel.cs" />
|
||||
<Compile Include="Database\OnlineWorkingBeatmap.cs" />
|
||||
<Compile Include="Database\BeatmapOnlineInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="$(SolutionDir)\osu-framework\osu.Framework\osu.Framework.csproj">
|
||||
|
Loading…
Reference in New Issue
Block a user