mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 09:02:55 +08:00
Merge branch 'master' into ios-signalr-use-json
This commit is contained in:
commit
0f1d72e073
@ -52,6 +52,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.1202.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2021.127.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2021.128.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@ -24,16 +24,13 @@
|
||||
<ProjectReference Include="..\osu.Game.Rulesets.Taiko\osu.Game.Rulesets.Taiko.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Label="Package References">
|
||||
<PackageReference Include="Microsoft.NETCore.Targets" Version="5.0.0" />
|
||||
<PackageReference Include="System.IO.Packaging" Version="5.0.0" />
|
||||
<PackageReference Include="ppy.squirrel.windows" Version="1.9.0.5" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.2.6" />
|
||||
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
|
||||
<PackageReference Include="DiscordRichPresence" Version="1.0.169" />
|
||||
<!-- .NET 3.1 SDK seems to cause issues with a runtime specification. This will likely be resolved in .NET 5. -->
|
||||
<PackageReference Include="System.IO.FileSystem.Primitives" Version="4.3.0" />
|
||||
<PackageReference Include="System.Runtime.Handles" Version="4.3.0" />
|
||||
<PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Label="Resources">
|
||||
<EmbeddedResource Include="lazer.ico" />
|
||||
|
@ -7,7 +7,6 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Dapper;
|
||||
using Microsoft.Data.Sqlite;
|
||||
using osu.Framework.Development;
|
||||
using osu.Framework.IO.Network;
|
||||
@ -154,23 +153,34 @@ namespace osu.Game.Beatmaps
|
||||
{
|
||||
using (var db = new SqliteConnection(storage.GetDatabaseConnectionString("online")))
|
||||
{
|
||||
var found = db.QuerySingleOrDefault<CachedOnlineBeatmapLookup>(
|
||||
"SELECT * FROM osu_beatmaps WHERE checksum = @MD5Hash OR beatmap_id = @OnlineBeatmapID OR filename = @Path", beatmap);
|
||||
db.Open();
|
||||
|
||||
if (found != null)
|
||||
using (var cmd = db.CreateCommand())
|
||||
{
|
||||
var status = (BeatmapSetOnlineStatus)found.approved;
|
||||
cmd.CommandText = "SELECT beatmapset_id, beatmap_id, approved FROM osu_beatmaps WHERE checksum = @MD5Hash OR beatmap_id = @OnlineBeatmapID OR filename = @Path";
|
||||
|
||||
cmd.Parameters.Add(new SqliteParameter("@MD5Hash", beatmap.MD5Hash));
|
||||
cmd.Parameters.Add(new SqliteParameter("@OnlineBeatmapID", beatmap.OnlineBeatmapID));
|
||||
cmd.Parameters.Add(new SqliteParameter("@Path", beatmap.Path));
|
||||
|
||||
using (var reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
{
|
||||
var status = (BeatmapSetOnlineStatus)reader.GetByte(2);
|
||||
|
||||
beatmap.Status = status;
|
||||
beatmap.BeatmapSet.Status = status;
|
||||
beatmap.BeatmapSet.OnlineBeatmapSetID = found.beatmapset_id;
|
||||
beatmap.OnlineBeatmapID = found.beatmap_id;
|
||||
beatmap.BeatmapSet.OnlineBeatmapSetID = reader.GetInt32(0);
|
||||
beatmap.OnlineBeatmapID = reader.GetInt32(1);
|
||||
|
||||
LogForModel(set, $"Cached local retrieval for {beatmap}.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogForModel(set, $"Cached local retrieval for {beatmap} failed with {ex}.");
|
||||
|
@ -12,7 +12,7 @@ using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osuTK;
|
||||
using Humanizer;
|
||||
using osu.Game.Utils;
|
||||
using osu.Framework.Extensions.EnumExtensions;
|
||||
|
||||
namespace osu.Game.Overlays.BeatmapListing
|
||||
{
|
||||
@ -80,7 +80,7 @@ namespace osu.Game.Overlays.BeatmapListing
|
||||
|
||||
if (typeof(T).IsEnum)
|
||||
{
|
||||
foreach (var val in OrderAttributeUtils.GetValuesInOrder<T>())
|
||||
foreach (var val in EnumExtensions.GetValuesInOrder<T>())
|
||||
AddItem(val);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Game.Utils;
|
||||
using osu.Framework.Utils;
|
||||
|
||||
namespace osu.Game.Overlays.BeatmapListing
|
||||
{
|
||||
|
@ -7,6 +7,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Extensions.EnumExtensions;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
@ -15,7 +16,6 @@ using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Users.Drawables;
|
||||
using osu.Game.Utils;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -105,7 +105,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
|
||||
var ruleset = scores.First().Ruleset.CreateInstance();
|
||||
|
||||
foreach (var result in OrderAttributeUtils.GetValuesInOrder<HitResult>())
|
||||
foreach (var result in EnumExtensions.GetValuesInOrder<HitResult>())
|
||||
{
|
||||
if (!allScoreStatistics.Contains(result))
|
||||
continue;
|
||||
|
@ -24,9 +24,9 @@ using osu.Game.Skinning;
|
||||
using osu.Game.Users;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Extensions.EnumExtensions;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Screens.Ranking.Statistics;
|
||||
using osu.Game.Utils;
|
||||
|
||||
namespace osu.Game.Rulesets
|
||||
{
|
||||
@ -272,7 +272,7 @@ namespace osu.Game.Rulesets
|
||||
var validResults = GetValidHitResults();
|
||||
|
||||
// enumerate over ordered list to guarantee return order is stable.
|
||||
foreach (var result in OrderAttributeUtils.GetValuesInOrder<HitResult>())
|
||||
foreach (var result in EnumExtensions.GetValuesInOrder<HitResult>())
|
||||
{
|
||||
switch (result)
|
||||
{
|
||||
@ -298,7 +298,7 @@ namespace osu.Game.Rulesets
|
||||
/// <remarks>
|
||||
/// <see cref="HitResult.Miss"/> is implicitly included. Special types like <see cref="HitResult.IgnoreHit"/> are ignored even when specified.
|
||||
/// </remarks>
|
||||
protected virtual IEnumerable<HitResult> GetValidHitResults() => OrderAttributeUtils.GetValuesInOrder<HitResult>();
|
||||
protected virtual IEnumerable<HitResult> GetValidHitResults() => EnumExtensions.GetValuesInOrder<HitResult>();
|
||||
|
||||
/// <summary>
|
||||
/// Get a display friendly name for the specified result type.
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using osu.Game.Utils;
|
||||
using osu.Framework.Utils;
|
||||
|
||||
namespace osu.Game.Rulesets.Scoring
|
||||
{
|
||||
|
@ -1,52 +0,0 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace osu.Game.Utils
|
||||
{
|
||||
public static class OrderAttributeUtils
|
||||
{
|
||||
/// <summary>
|
||||
/// Get values of an enum in order. Supports custom ordering via <see cref="OrderAttribute"/>.
|
||||
/// </summary>
|
||||
public static IEnumerable<T> GetValuesInOrder<T>()
|
||||
{
|
||||
var type = typeof(T);
|
||||
|
||||
if (!type.IsEnum)
|
||||
throw new InvalidOperationException("T must be an enum");
|
||||
|
||||
IEnumerable<T> items = (T[])Enum.GetValues(type);
|
||||
|
||||
if (Attribute.GetCustomAttribute(type, typeof(HasOrderedElementsAttribute)) == null)
|
||||
return items;
|
||||
|
||||
return items.OrderBy(i =>
|
||||
{
|
||||
if (type.GetField(i.ToString()).GetCustomAttributes(typeof(OrderAttribute), false).FirstOrDefault() is OrderAttribute attr)
|
||||
return attr.Order;
|
||||
|
||||
throw new ArgumentException($"Not all values of {nameof(T)} have {nameof(OrderAttribute)} specified.");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class OrderAttribute : Attribute
|
||||
{
|
||||
public readonly int Order;
|
||||
|
||||
public OrderAttribute(int order)
|
||||
{
|
||||
Order = order;
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Enum)]
|
||||
public class HasOrderedElementsAttribute : Attribute
|
||||
{
|
||||
}
|
||||
}
|
@ -18,7 +18,6 @@
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup Label="Package References">
|
||||
<PackageReference Include="Dapper" Version="2.0.78" />
|
||||
<PackageReference Include="DiffPlex" Version="1.6.3" />
|
||||
<PackageReference Include="Humanizer" Version="2.8.26" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="3.1.10" />
|
||||
@ -26,8 +25,9 @@
|
||||
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson" Version="3.1.10" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
||||
<PackageReference Include="Microsoft.NETCore.Targets" Version="3.1.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2021.127.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2021.128.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.1202.0" />
|
||||
<PackageReference Include="Sentry" Version="2.1.8" />
|
||||
<PackageReference Include="SharpCompress" Version="0.26.0" />
|
||||
|
@ -70,7 +70,7 @@
|
||||
<Reference Include="System.Net.Http" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Label="Package References">
|
||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2021.127.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2021.128.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.1202.0" />
|
||||
</ItemGroup>
|
||||
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net5.0 / net6.0) -->
|
||||
@ -88,7 +88,7 @@
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2021.127.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2021.128.0" />
|
||||
<PackageReference Include="SharpCompress" Version="0.26.0" />
|
||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
||||
|
Loading…
Reference in New Issue
Block a user