1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 16:07:25 +08:00

Merge remote-tracking branch 'upstream/master' into bugfix-nofail-scoreprocessor

This commit is contained in:
Jacob Odgård Tørring 2017-10-24 08:05:31 +02:00
commit 86419e0ded
38 changed files with 390 additions and 167 deletions

@ -1 +1 @@
Subproject commit 383a8da7bc45af498288b4b72c72a048a0996e74
Subproject commit ecc5e3189e8229d36095882b9a7a0efc95402be9

View File

@ -7,7 +7,6 @@ using System.Configuration;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using Newtonsoft.Json;
using osu.Framework.IO.Network;
using FileWebRequest = osu.Framework.IO.Network.FileWebRequest;
@ -391,8 +390,8 @@ namespace osu.Desktop.Deploy
public static void AuthenticatedBlockingPerform(this WebRequest r)
{
r.AddHeader("Authorization", $"token {GitHubAccessToken}");
r.BlockingPerform();
r.Headers.Add("Authorization", $"token {GitHubAccessToken}");
r.Perform();
}
}
@ -402,12 +401,7 @@ namespace osu.Desktop.Deploy
{
}
protected override HttpWebRequest CreateWebRequest(string requestString = null)
{
var req = base.CreateWebRequest(requestString);
req.Accept = "application/octet-stream";
return req;
}
protected override string Accept => "application/octet-stream";
}
internal class ReleaseLine

View File

@ -12,15 +12,12 @@ using osu.Desktop.Overlays;
using osu.Framework.Graphics.Containers;
using osu.Framework.Platform;
using osu.Game;
using osu.Game.Screens.Menu;
using OpenTK.Input;
namespace osu.Desktop
{
internal class OsuGameDesktop : OsuGame
{
private VersionManager versionManager;
public OsuGameDesktop(string[] args = null)
: base(args)
{
@ -82,16 +79,11 @@ namespace osu.Desktop
{
base.LoadComplete();
LoadComponentAsync(versionManager = new VersionManager { Depth = int.MinValue });
ScreenChanged += s =>
LoadComponentAsync(new VersionManager { Depth = int.MinValue }, v =>
{
if (s is Intro && s.ChildScreen == null)
{
Add(versionManager);
versionManager.State = Visibility.Visible;
}
};
Add(v);
v.State = Visibility.Visible;
});
}
public override void SetHost(GameHost host)

View File

@ -12,8 +12,32 @@
<bindingRedirect oldVersion="0.0.0.0-0.18.1.0" newVersion="0.18.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0"/>
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Security.Cryptography.Algorithms" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.IO.FileSystem" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.IO.Compression" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.IO.FileSystem.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Security.Cryptography.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Xml.XPath.XDocument" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>

View File

@ -133,30 +133,42 @@
</Reference>
<Reference Include="mscorlib" />
<Reference Include="NuGet.Squirrel, Version=3.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\squirrel.windows.1.7.8\lib\Net45\NuGet.Squirrel.dll</HintPath>
<HintPath>$(SolutionDir)\packages\squirrel.windows.1.7.8\lib\Net45\NuGet.Squirrel.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="OpenTK, Version=3.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
<HintPath>..\packages\OpenTK.3.0.0-git00009\lib\net20\OpenTK.dll</HintPath>
<HintPath>$(SolutionDir)\packages\OpenTK.3.0.0-git00009\lib\net20\OpenTK.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="SharpCompress, Version=0.18.1.0, Culture=neutral, PublicKeyToken=afb0a02973931d96, processorArchitecture=MSIL">
<HintPath>..\packages\SharpCompress.0.18.1\lib\net45\SharpCompress.dll</HintPath>
<HintPath>$(SolutionDir)\packages\SharpCompress.0.18.1\lib\net45\SharpCompress.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Splat, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>$(SolutionDir)\packages\Splat.2.0.0\lib\Net45\Splat.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="SQLitePCLRaw.batteries_green, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a84b7dcfb1391f7f, processorArchitecture=MSIL">
<HintPath>$(SolutionDir)\packages\SQLitePCLRaw.bundle_green.1.1.8\lib\net45\SQLitePCLRaw.batteries_green.dll</HintPath>
</Reference>
<Reference Include="SQLitePCLRaw.batteries_v2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=8226ea5df37bcae9, processorArchitecture=MSIL">
<HintPath>$(SolutionDir)\packages\SQLitePCLRaw.bundle_green.1.1.8\lib\net45\SQLitePCLRaw.batteries_v2.dll</HintPath>
</Reference>
<Reference Include="SQLitePCLRaw.core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1488e028ca7ab535, processorArchitecture=MSIL">
<HintPath>$(SolutionDir)\packages\SQLitePCLRaw.core.1.1.8\lib\net45\SQLitePCLRaw.core.dll</HintPath>
</Reference>
<Reference Include="SQLitePCLRaw.provider.e_sqlite3, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9c301db686d0bd12, processorArchitecture=MSIL">
<HintPath>$(SolutionDir)\packages\SQLitePCLRaw.provider.e_sqlite3.net45.1.1.8\lib\net45\SQLitePCLRaw.provider.e_sqlite3.dll</HintPath>
</Reference>
<Reference Include="Squirrel, Version=1.7.8.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\squirrel.windows.1.7.8\lib\Net45\Squirrel.dll</HintPath>
<HintPath>$(SolutionDir)\packages\squirrel.windows.1.7.8\lib\Net45\Squirrel.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51">
<HintPath>../packages/System.ValueTuple.4.4.0/lib/net461/System.ValueTuple.dll</HintPath>
<HintPath>$(SolutionDir)\packages\System.ValueTuple.4.4.0\lib\net461\System.ValueTuple.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Windows.Forms" />
@ -262,4 +274,15 @@
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
<Import Project="$(SolutionDir)\packages\SQLitePCLRaw.lib.e_sqlite3.linux.1.1.8\build\net35\SQLitePCLRaw.lib.e_sqlite3.linux.targets" Condition="Exists('$(SolutionDir)\packages\SQLitePCLRaw.lib.e_sqlite3.linux.1.1.8\build\net35\SQLitePCLRaw.lib.e_sqlite3.linux.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\packages\SQLitePCLRaw.lib.e_sqlite3.linux.1.1.8\build\net35\SQLitePCLRaw.lib.e_sqlite3.linux.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\packages\SQLitePCLRaw.lib.e_sqlite3.linux.1.1.8\build\net35\SQLitePCLRaw.lib.e_sqlite3.linux.targets'))" />
<Error Condition="!Exists('$(SolutionDir)\packages\SQLitePCLRaw.lib.e_sqlite3.osx.1.1.8\build\net35\SQLitePCLRaw.lib.e_sqlite3.osx.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\packages\SQLitePCLRaw.lib.e_sqlite3.osx.1.1.8\build\net35\SQLitePCLRaw.lib.e_sqlite3.osx.targets'))" />
<Error Condition="!Exists('$(SolutionDir)\packages\SQLitePCLRaw.lib.e_sqlite3.v110_xp.1.1.8\build\net35\SQLitePCLRaw.lib.e_sqlite3.v110_xp.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\packages\SQLitePCLRaw.lib.e_sqlite3.v110_xp.1.1.8\build\net35\SQLitePCLRaw.lib.e_sqlite3.v110_xp.targets'))" />
</Target>
<Import Project="$(SolutionDir)\packages\SQLitePCLRaw.lib.e_sqlite3.osx.1.1.8\build\net35\SQLitePCLRaw.lib.e_sqlite3.osx.targets" Condition="Exists('$(SolutionDir)\packages\SQLitePCLRaw.lib.e_sqlite3.osx.1.1.8\build\net35\SQLitePCLRaw.lib.e_sqlite3.osx.targets')" />
<Import Project="$(SolutionDir)\packages\SQLitePCLRaw.lib.e_sqlite3.v110_xp.1.1.8\build\net35\SQLitePCLRaw.lib.e_sqlite3.v110_xp.targets" Condition="Exists('$(SolutionDir)\packages\SQLitePCLRaw.lib.e_sqlite3.v110_xp.1.1.8\build\net35\SQLitePCLRaw.lib.e_sqlite3.v110_xp.targets')" />
</Project>

View File

@ -1,14 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
-->
<packages>
<package id="DeltaCompressionDotNet" version="1.1.0" targetFramework="net45" />
<package id="Mono.Cecil" version="0.9.6.4" targetFramework="net45" />
<package id="OpenTK" version="3.0.0-git00009" targetFramework="net461" />
<package id="SharpCompress" version="0.18.1" targetFramework="net461" />
<package id="Splat" version="2.0.0" targetFramework="net45" />
<package id="squirrel.windows" version="1.7.8" targetFramework="net461" />
<package id="System.ValueTuple" version="4.4.0" targetFramework="net461" />
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
-->
<packages>
<package id="DeltaCompressionDotNet" version="1.1.0" targetFramework="net45" />
<package id="Mono.Cecil" version="0.9.6.4" targetFramework="net45" />
<package id="OpenTK" version="3.0.0-git00009" targetFramework="net461" />
<package id="SharpCompress" version="0.18.1" targetFramework="net461" />
<package id="Splat" version="2.0.0" targetFramework="net45" />
<package id="SQLitePCLRaw.bundle_green" version="1.1.8" targetFramework="net461" />
<package id="SQLitePCLRaw.core" version="1.1.8" targetFramework="net461" />
<package id="SQLitePCLRaw.lib.e_sqlite3.linux" version="1.1.8" targetFramework="net461" />
<package id="SQLitePCLRaw.lib.e_sqlite3.osx" version="1.1.8" targetFramework="net461" />
<package id="SQLitePCLRaw.lib.e_sqlite3.v110_xp" version="1.1.8" targetFramework="net461" />
<package id="SQLitePCLRaw.provider.e_sqlite3.net45" version="1.1.8" targetFramework="net461" />
<package id="squirrel.windows" version="1.7.8" targetFramework="net461" />
<package id="System.ValueTuple" version="4.4.0" targetFramework="net461" />
</packages>

View File

@ -20,7 +20,7 @@ namespace osu.Game.Tests.Beatmaps.IO
{
private const string osz_path = @"../../../osu-resources/osu.Game.Resources/Beatmaps/241526 Soleily - Renatus.osz";
//[Test]
[Test]
public void TestImportWhenClosed()
{
//unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
@ -40,14 +40,16 @@ namespace osu.Game.Tests.Beatmaps.IO
}
}
//[Test]
[Test]
[NonParallelizable]
[Ignore("Binding IPC on Appveyor isn't working (port in use). Need to figure out why")]
public void TestImportOverIPC()
{
using (HeadlessGameHost host = new HeadlessGameHost("host", true))
using (HeadlessGameHost client = new HeadlessGameHost("client", true))
{
Assert.IsTrue(host.IsPrimaryInstance);
Assert.IsTrue(!client.IsPrimaryInstance);
Assert.IsFalse(client.IsPrimaryInstance);
var osu = loadOsu(host);
@ -65,7 +67,7 @@ namespace osu.Game.Tests.Beatmaps.IO
}
}
//[Test]
[Test]
public void TestImportWhenFileOpen()
{
using (HeadlessGameHost host = new HeadlessGameHost("TestImportWhenFileOpen"))

View File

@ -4,10 +4,9 @@
using System;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.MathUtils;
using osu.Framework.Graphics.Cursor;
using osu.Game.Graphics;
using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.Tests.Visual
{
@ -19,29 +18,37 @@ namespace osu.Game.Tests.Visual
{
FillFlowContainer flow;
Add(flow = new FillFlowContainer
Add(new ScrollContainer
{
RelativeSizeAxes = Axes.Both,
Size = new Vector2(0.5f),
Anchor = Anchor.Centre,
Origin = Anchor.Centre
Child = flow = new FillFlowContainer
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Full,
},
});
int i = 50;
foreach (FontAwesome fa in Enum.GetValues(typeof(FontAwesome)))
flow.Add(new Icon(fa));
}
private class Icon : Container, IHasTooltip
{
public string TooltipText { get; }
public Icon(FontAwesome fa)
{
flow.Add(new SpriteIcon
TooltipText = fa.ToString();
AutoSizeAxes = Axes.Both;
Child = new SpriteIcon
{
Icon = fa,
Size = new Vector2(60),
Colour = new Color4(
Math.Max(0.5f, RNG.NextSingle()),
Math.Max(0.5f, RNG.NextSingle()),
Math.Max(0.5f, RNG.NextSingle()),
1)
});
if (i-- == 0) break;
};
}
}
}

View File

@ -184,7 +184,7 @@ namespace osu.Game.Beatmaps
{
var context = importContext.Value;
using (var transaction = context.Database.BeginTransaction())
using (var transaction = context.BeginTransaction())
{
// create local stores so we can isolate and thread safely, and share a context/transaction.
var iFiles = new FileStore(() => context, storage);
@ -198,7 +198,7 @@ namespace osu.Game.Beatmaps
context.SaveChanges();
}
transaction.Commit();
context.SaveChanges(transaction);
return set;
}
}
@ -295,7 +295,7 @@ namespace osu.Game.Beatmaps
{
var context = importContext.Value;
using (var transaction = context.Database.BeginTransaction())
using (var transaction = context.BeginTransaction())
{
context.ChangeTracker.AutoDetectChangesEnabled = false;
@ -313,9 +313,7 @@ namespace osu.Game.Beatmaps
}
context.ChangeTracker.AutoDetectChangesEnabled = true;
context.SaveChanges();
transaction.Commit();
context.SaveChanges(transaction);
}
}
}

View File

@ -35,7 +35,8 @@ namespace osu.Game.Beatmaps.Drawables
new ConstrainedIconContainer
{
RelativeSizeAxes = Axes.Both,
Icon = beatmap.Ruleset.CreateInstance().CreateIcon()
// the null coalesce here is only present to make unit tests work (ruleset dlls aren't copied correctly for testing at the moment)
Icon = beatmap.Ruleset?.CreateInstance().CreateIcon() ?? new SpriteIcon { Icon = FontAwesome.fa_question_circle_o }
}
};
}

View File

@ -2,6 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Threading;
using osu.Framework.Logging;
using osu.Framework.Platform;
@ -11,12 +12,26 @@ namespace osu.Game.Database
{
protected readonly Storage Storage;
protected readonly Func<OsuDbContext> GetContext;
/// <summary>
/// Create a new <see cref="OsuDbContext"/> instance (separate from the shared context via <see cref="GetContext"/> for performing isolated operations.
/// </summary>
protected readonly Func<OsuDbContext> CreateContext;
protected DatabaseBackedStore(Func<OsuDbContext> getContext, Storage storage = null)
private readonly ThreadLocal<OsuDbContext> queryContext;
/// <summary>
/// Retrieve a shared context for performing lookups (or write operations on the update thread, for now).
/// </summary>
protected OsuDbContext GetContext() => queryContext.Value;
protected DatabaseBackedStore(Func<OsuDbContext> createContext, Storage storage = null)
{
CreateContext = createContext;
// todo: while this seems to work quite well, we need to consider that contexts could enter a state where they are never cleaned up.
queryContext = new ThreadLocal<OsuDbContext>(CreateContext);
Storage = storage;
GetContext = getContext;
try
{

View File

@ -3,6 +3,7 @@
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.Extensions.Logging;
using osu.Framework.Logging;
@ -23,6 +24,7 @@ namespace osu.Game.Database
public DbSet<DatabasedKeyBinding> DatabasedKeyBinding { get; set; }
public DbSet<FileInfo> FileInfo { get; set; }
public DbSet<RulesetInfo> RulesetInfo { get; set; }
private readonly string connectionString;
private static readonly Lazy<OsuDbLoggerFactory> logger = new Lazy<OsuDbLoggerFactory>(() => new OsuDbLoggerFactory());
@ -52,8 +54,6 @@ namespace osu.Game.Database
{
this.connectionString = connectionString;
Database.SetCommandTimeout(new TimeSpan(TimeSpan.TicksPerSecond * 10));
var connection = Database.GetDbConnection();
connection.Open();
using (var cmd = connection.CreateCommand())
@ -70,7 +70,7 @@ namespace osu.Game.Database
// this is required for the time being due to the way we are querying in places like BeatmapStore.
// if we ever move to having consumers file their own .Includes, or get eager loading support, this could be re-enabled.
.ConfigureWarnings(warnings => warnings.Ignore(CoreEventId.IncludeIgnoredWarning))
.UseSqlite(connectionString)
.UseSqlite(connectionString, sqliteOptions => sqliteOptions.CommandTimeout(10))
.UseLoggerFactory(logger.Value);
}
@ -95,6 +95,19 @@ namespace osu.Game.Database
modelBuilder.Entity<BeatmapInfo>().HasOne(b => b.BaseDifficulty);
}
public IDbContextTransaction BeginTransaction()
{
// return Database.BeginTransaction();
return null;
}
public new int SaveChanges(IDbContextTransaction transaction = null)
{
var ret = base.SaveChanges();
transaction?.Commit();
return ret;
}
private class OsuDbLoggerFactory : ILoggerFactory
{
#region Disposal
@ -153,7 +166,7 @@ namespace osu.Game.Database
public bool IsEnabled(LogLevel logLevel)
{
#if DEBUG
#if DEBUG_DATABASE
return logLevel > LogLevel.Debug;
#else
return logLevel > LogLevel.Information;

View File

@ -22,7 +22,7 @@ namespace osu.Game.IO
public Storage Storage => base.Storage;
public FileStore(Func<OsuDbContext> getContext, Storage storage) : base(getContext, storage.GetStorageForDirectory(@"files"))
public FileStore(Func<OsuDbContext> createContext, Storage storage) : base(createContext, storage.GetStorageForDirectory(@"files"))
{
Store = new StorageBackedResourceStore(Storage);
}

View File

@ -17,8 +17,8 @@ namespace osu.Game.Input
{
public event Action KeyBindingChanged;
public KeyBindingStore(Func<OsuDbContext> getContext, RulesetStore rulesets, Storage storage = null)
: base(getContext, storage)
public KeyBindingStore(Func<OsuDbContext> createContext, RulesetStore rulesets, Storage storage = null)
: base(createContext, storage)
{
foreach (var info in rulesets.AvailableRulesets)
{
@ -38,13 +38,14 @@ namespace osu.Game.Input
private void insertDefaults(IEnumerable<KeyBinding> defaults, int? rulesetId = null, int? variant = null)
{
using (var context = GetContext())
using (var transaction = context.Database.BeginTransaction())
var context = GetContext();
using (var transaction = context.BeginTransaction())
{
// compare counts in database vs defaults
foreach (var group in defaults.GroupBy(k => k.Action))
{
int count = query(context, rulesetId, variant).Count(k => (int)k.Action == (int)group.Key);
int count = Query(rulesetId, variant).Count(k => (int)k.Action == (int)group.Key);
int aimCount = group.Count();
if (aimCount <= count)
@ -61,8 +62,7 @@ namespace osu.Game.Input
});
}
context.SaveChanges();
transaction.Commit();
context.SaveChanges(transaction);
}
}
@ -72,10 +72,8 @@ namespace osu.Game.Input
/// <param name="rulesetId">The ruleset's internal ID.</param>
/// <param name="variant">An optional variant.</param>
/// <returns></returns>
public IEnumerable<KeyBinding> Query(int? rulesetId = null, int? variant = null) => query(GetContext(), rulesetId, variant);
private IEnumerable<KeyBinding> query(OsuDbContext context, int? rulesetId = null, int? variant = null) =>
context.DatabasedKeyBinding.Where(b => b.RulesetID == rulesetId && b.Variant == variant);
public IEnumerable<KeyBinding> Query(int? rulesetId = null, int? variant = null) =>
GetContext().DatabasedKeyBinding.Where(b => b.RulesetID == rulesetId && b.Variant == variant);
public void Update(KeyBinding keyBinding)
{

View File

@ -106,7 +106,7 @@ namespace osu.Game.Online.API
return;
if (!WebRequest.Aborted) //could have been aborted by a Cancel() call
WebRequest.BlockingPerform();
WebRequest.Perform();
if (checkAndProcessFailure())
return;

View File

@ -37,7 +37,7 @@ namespace osu.Game.Online.API
{
try
{
req.BlockingPerform();
req.Perform();
}
catch
{
@ -61,7 +61,7 @@ namespace osu.Game.Online.API
ClientSecret = clientSecret
})
{
req.BlockingPerform();
req.Perform();
Token = req.ResponseObject;
return true;

View File

@ -157,40 +157,49 @@ namespace osu.Game
BeatmapManager.PostNotification = n => notificationOverlay?.Post(n);
BeatmapManager.GetStableStorage = GetStorageForStableInstall;
AddRange(new Drawable[] {
AddRange(new Drawable[]
{
new VolumeControlReceptor
{
RelativeSizeAxes = Axes.Both,
ActionRequested = action => volume.Adjust(action)
},
mainContent = new Container
{
RelativeSizeAxes = Axes.Both,
},
volume = new VolumeControl(),
overlayContent = new Container { RelativeSizeAxes = Axes.Both },
new OnScreenDisplay(),
mainContent = new Container { RelativeSizeAxes = Axes.Both },
overlayContent = new Container { RelativeSizeAxes = Axes.Both, Depth = float.MinValue },
});
LoadComponentAsync(screenStack = new Loader(), d =>
loadComponentSingleFile(screenStack = new Loader(), d =>
{
screenStack.ModePushed += screenAdded;
screenStack.Exited += screenRemoved;
mainContent.Add(screenStack);
});
loadComponentSingleFile(Toolbar = new Toolbar
{
Depth = -5,
OnHome = delegate
{
hideAllOverlays();
intro?.ChildScreen?.MakeCurrent();
},
}, overlayContent.Add);
loadComponentSingleFile(volume = new VolumeControl(), AddInternal);
loadComponentSingleFile(new OnScreenDisplay(), AddInternal);
//overlay elements
LoadComponentAsync(direct = new DirectOverlay { Depth = -1 }, mainContent.Add);
LoadComponentAsync(social = new SocialOverlay { Depth = -1 }, mainContent.Add);
LoadComponentAsync(chat = new ChatOverlay { Depth = -1 }, mainContent.Add);
LoadComponentAsync(settings = new MainSettings
loadComponentSingleFile(direct = new DirectOverlay { Depth = -1 }, mainContent.Add);
loadComponentSingleFile(social = new SocialOverlay { Depth = -1 }, mainContent.Add);
loadComponentSingleFile(chat = new ChatOverlay { Depth = -1 }, mainContent.Add);
loadComponentSingleFile(settings = new MainSettings
{
GetToolbarHeight = () => ToolbarOffset,
Depth = -1
}, overlayContent.Add);
LoadComponentAsync(userProfile = new UserProfileOverlay { Depth = -2 }, mainContent.Add);
LoadComponentAsync(beatmapSetOverlay = new BeatmapSetOverlay { Depth = -3 }, mainContent.Add);
LoadComponentAsync(musicController = new MusicController
loadComponentSingleFile(userProfile = new UserProfileOverlay { Depth = -2 }, mainContent.Add);
loadComponentSingleFile(beatmapSetOverlay = new BeatmapSetOverlay { Depth = -3 }, mainContent.Add);
loadComponentSingleFile(musicController = new MusicController
{
Depth = -4,
Position = new Vector2(0, Toolbar.HEIGHT),
@ -198,16 +207,16 @@ namespace osu.Game
Origin = Anchor.TopRight,
}, overlayContent.Add);
LoadComponentAsync(notificationOverlay = new NotificationOverlay
loadComponentSingleFile(notificationOverlay = new NotificationOverlay
{
Depth = -4,
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
}, overlayContent.Add);
LoadComponentAsync(dialogOverlay = new DialogOverlay
loadComponentSingleFile(dialogOverlay = new DialogOverlay
{
Depth = -5,
Depth = -6,
}, overlayContent.Add);
Logger.NewEntry += entry =>
@ -246,16 +255,6 @@ namespace osu.Game
};
}
LoadComponentAsync(Toolbar = new Toolbar
{
Depth = -4,
OnHome = delegate
{
hideAllOverlays();
intro?.ChildScreen?.MakeCurrent();
},
}, overlayContent.Add);
settings.StateChanged += delegate
{
switch (settings.State)
@ -272,6 +271,17 @@ namespace osu.Game
Cursor.State = Visibility.Hidden;
}
private Task asyncLoadStream;
private void loadComponentSingleFile<T>(T d, Action<T> add)
where T : Drawable
{
// schedule is here to ensure that all component loads are done after LoadComplete is run (and thus all dependencies are cached).
// with some better organisation of LoadComplete to do construction and dependency caching in one step, followed by calls to loadComponentSingleFile,
// we could avoid the need for scheduling altogether.
Schedule(() => { asyncLoadStream = asyncLoadStream?.ContinueWith(t => LoadComponentAsync(d, add).Wait()) ?? LoadComponentAsync(d, add); });
}
public bool OnPressed(GlobalAction action)
{
if (intro == null) return false;

View File

@ -28,6 +28,7 @@ namespace osu.Game.Overlays.KeyBinding
this.variant = variant;
FlowContent.Spacing = new Vector2(0, 1);
FlowContent.Padding = new MarginPadding { Left = SettingsOverlay.CONTENT_MARGINS, Right = SettingsOverlay.CONTENT_MARGINS };
}
[BackgroundDependencyLoader]

View File

@ -20,11 +20,11 @@ namespace osu.Game.Overlays.Settings.Sections.Audio
new SettingsSlider<double, OffsetSlider>
{
LabelText = "Audio Offset",
Bindable = config.GetBindable<double>(OsuSetting.AudioOffset)
Bindable = config.GetBindable<double>(OsuSetting.AudioOffset),
KeyboardStep = 100f
},
new OsuButton
new SettingsButton
{
RelativeSizeAxes = Axes.X,
Text = "Offset wizard"
}
};

View File

@ -16,9 +16,9 @@ namespace osu.Game.Overlays.Settings.Sections.Audio
{
Children = new Drawable[]
{
new SettingsSlider<double> { LabelText = "Master", Bindable = audio.Volume },
new SettingsSlider<double> { LabelText = "Effect", Bindable = audio.VolumeSample },
new SettingsSlider<double> { LabelText = "Music", Bindable = audio.VolumeTrack },
new SettingsSlider<double> { LabelText = "Master", Bindable = audio.Volume, KeyboardStep = 0.1f },
new SettingsSlider<double> { LabelText = "Effect", Bindable = audio.VolumeSample, KeyboardStep = 0.1f },
new SettingsSlider<double> { LabelText = "Music", Bindable = audio.VolumeTrack, KeyboardStep = 0.1f },
};
}
}

View File

@ -6,7 +6,6 @@ using System.Runtime;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.Settings.Sections.Debug
{
@ -24,9 +23,8 @@ namespace osu.Game.Overlays.Settings.Sections.Debug
LabelText = "Active mode",
Bindable = config.GetBindable<GCLatencyMode>(DebugSetting.ActiveGCMode)
},
new OsuButton
new SettingsButton
{
RelativeSizeAxes = Axes.X,
Text = "Force garbage collection",
Action = GC.Collect
},

View File

@ -19,7 +19,8 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
new SettingsSlider<double>
{
LabelText = "Background dim",
Bindable = config.GetBindable<double>(OsuSetting.DimLevel)
Bindable = config.GetBindable<double>(OsuSetting.DimLevel),
KeyboardStep = 0.1f
},
new SettingsCheckbox
{

View File

@ -20,12 +20,14 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
new SettingsSlider<double, StarSlider>
{
LabelText = "Display beatmaps from",
Bindable = config.GetBindable<double>(OsuSetting.DisplayStarsMinimum)
Bindable = config.GetBindable<double>(OsuSetting.DisplayStarsMinimum),
KeyboardStep = 1f
},
new SettingsSlider<double, StarSlider>
{
LabelText = "up to",
Bindable = config.GetBindable<double>(OsuSetting.DisplayStarsMaximum)
Bindable = config.GetBindable<double>(OsuSetting.DisplayStarsMaximum),
KeyboardStep = 1f
},
new SettingsEnumDropdown<SelectionRandomType>
{

View File

@ -230,15 +230,13 @@ namespace osu.Game.Overlays.Settings.Sections.General
LabelText = "Stay logged in",
Bindable = config.GetBindable<bool>(OsuSetting.SavePassword),
},
new OsuButton
new SettingsButton
{
RelativeSizeAxes = Axes.X,
Text = "Sign in",
Action = performLogin
},
new OsuButton
new SettingsButton
{
RelativeSizeAxes = Axes.X,
Text = "Register new account",
//Action = registerLink
}

View File

@ -5,7 +5,6 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Platform;
using osu.Game.Configuration;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.Settings.Sections.General
{
@ -23,9 +22,8 @@ namespace osu.Game.Overlays.Settings.Sections.General
LabelText = "Release stream",
Bindable = config.GetBindable<ReleaseStream>(OsuSetting.ReleaseStream),
},
new OsuButton
new SettingsButton
{
RelativeSizeAxes = Axes.X,
Text = "Open osu! folder",
Action = storage.OpenInNativeExplorer,
}

View File

@ -49,12 +49,14 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
new SettingsSlider<double>
{
LabelText = "Horizontal position",
Bindable = config.GetBindable<double>(FrameworkSetting.LetterboxPositionX)
Bindable = config.GetBindable<double>(FrameworkSetting.LetterboxPositionX),
KeyboardStep = 0.1f
},
new SettingsSlider<double>
{
LabelText = "Vertical position",
Bindable = config.GetBindable<double>(FrameworkSetting.LetterboxPositionY)
Bindable = config.GetBindable<double>(FrameworkSetting.LetterboxPositionY),
KeyboardStep = 0.1f
},
}
},

View File

@ -2,7 +2,6 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.Settings.Sections.Input
{
@ -14,9 +13,8 @@ namespace osu.Game.Overlays.Settings.Sections.Input
{
Children = new Drawable[]
{
new OsuButton
new SettingsButton
{
RelativeSizeAxes = Axes.X,
Text = "Key Configuration",
Action = keyConfig.ToggleVisibility
},

View File

@ -1,6 +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.Linq;
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
@ -22,9 +23,8 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
{
Children = new Drawable[]
{
importButton = new OsuButton
importButton = new SettingsButton
{
RelativeSizeAxes = Axes.X,
Text = "Import beatmaps from stable",
Action = () =>
{
@ -32,9 +32,8 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
Task.Run(() => beatmaps.ImportFromStable()).ContinueWith(t => Schedule(() => importButton.Enabled.Value = true));
}
},
deleteButton = new OsuButton
deleteButton = new SettingsButton
{
RelativeSizeAxes = Axes.X,
Text = "Delete ALL beatmaps",
Action = () =>
{
@ -42,16 +41,15 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
Task.Run(() => beatmaps.DeleteAll()).ContinueWith(t => Schedule(() => deleteButton.Enabled.Value = true));
}
},
restoreButton = new OsuButton
restoreButton = new SettingsButton
{
RelativeSizeAxes = Axes.X,
Text = "Restore all hidden difficulties",
Action = () =>
{
restoreButton.Enabled.Value = false;
Task.Run(() =>
{
foreach (var b in beatmaps.QueryBeatmaps(b => b.Hidden))
foreach (var b in beatmaps.QueryBeatmaps(b => b.Hidden).ToList())
beatmaps.Restore(b);
}).ContinueWith(t => Schedule(() => restoreButton.Enabled.Value = true));
}

View File

@ -24,12 +24,14 @@ namespace osu.Game.Overlays.Settings.Sections
new SettingsSlider<double, SizeSlider>
{
LabelText = "Menu cursor size",
Bindable = config.GetBindable<double>(OsuSetting.MenuCursorSize)
Bindable = config.GetBindable<double>(OsuSetting.MenuCursorSize),
KeyboardStep = 0.1f
},
new SettingsSlider<double, SizeSlider>
{
LabelText = "Gameplay cursor size",
Bindable = config.GetBindable<double>(OsuSetting.GameplayCursorSize)
Bindable = config.GetBindable<double>(OsuSetting.GameplayCursorSize),
KeyboardStep = 0.1f
},
new SettingsCheckbox
{

View File

@ -0,0 +1,17 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.Settings
{
public class SettingsButton : OsuButton
{
public SettingsButton()
{
RelativeSizeAxes = Axes.X;
Padding = new MarginPadding { Left = SettingsOverlay.CONTENT_MARGINS, Right = SettingsOverlay.CONTENT_MARGINS };
}
}
}

View File

@ -2,17 +2,24 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using osu.Framework.Allocation;
using OpenTK.Graphics;
using osu.Framework.Configuration;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Overlays.Settings
{
public abstract class SettingsItem<T> : FillFlowContainer, IFilterable
public abstract class SettingsItem<T> : Container, IFilterable
{
protected abstract Drawable CreateControl();
@ -20,8 +27,28 @@ namespace osu.Game.Overlays.Settings
private IHasCurrentValue<T> controlWithCurrent => Control as IHasCurrentValue<T>;
protected override Container<Drawable> Content => FlowContent;
protected readonly FillFlowContainer FlowContent;
private SpriteText text;
private readonly RestoreDefaultValueButton<T> restoreDefaultValueButton = new RestoreDefaultValueButton<T>();
public bool ShowsDefaultIndicator = true;
private Color4? restoreDefaultValueColour;
public Color4 RestoreDefaultValueColour
{
get { return restoreDefaultValueColour ?? Color4.White; }
set
{
restoreDefaultValueColour = value;
restoreDefaultValueButton?.SetButtonColour(RestoreDefaultValueColour);
}
}
public virtual string LabelText
{
get { return text?.Text ?? string.Empty; }
@ -51,6 +78,11 @@ namespace osu.Game.Overlays.Settings
{
bindable = value;
controlWithCurrent?.Current.BindTo(bindable);
if (ShowsDefaultIndicator)
{
restoreDefaultValueButton.Bindable.BindTo(bindable);
restoreDefaultValueButton.Bindable.TriggerChange();
}
}
}
@ -69,13 +101,94 @@ namespace osu.Game.Overlays.Settings
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Padding = new MarginPadding { Right = 5 };
Padding = new MarginPadding { Right = SettingsOverlay.CONTENT_MARGINS };
FlowContent = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Padding = new MarginPadding { Left = SettingsOverlay.CONTENT_MARGINS, Right = 5 },
};
if ((Control = CreateControl()) != null)
{
if (controlWithCurrent != null)
controlWithCurrent.Current.DisabledChanged += disabled => { Colour = disabled ? Color4.Gray : Color4.White; };
Add(Control);
FlowContent.Add(Control);
}
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
AddInternal(FlowContent);
if (restoreDefaultValueButton != null)
{
if (!restoreDefaultValueColour.HasValue)
restoreDefaultValueColour = colours.Yellow;
restoreDefaultValueButton.SetButtonColour(RestoreDefaultValueColour);
AddInternal(restoreDefaultValueButton);
}
}
private class RestoreDefaultValueButton<T> : Box, IHasTooltip
{
internal readonly Bindable<T> Bindable = new Bindable<T>();
private Color4 buttonColour;
private bool hovering;
public RestoreDefaultValueButton()
{
Bindable.ValueChanged += value => UpdateState();
Bindable.DisabledChanged += disabled => UpdateState();
RelativeSizeAxes = Axes.Y;
Width = SettingsOverlay.CONTENT_MARGINS;
Alpha = 0f;
}
public string TooltipText => "Revert to default";
public override bool HandleInput => true;
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true;
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) => true;
protected override bool OnClick(InputState state)
{
if (!Bindable.Disabled)
Bindable.SetDefault();
return true;
}
protected override bool OnHover(InputState state)
{
hovering = true;
UpdateState();
return true;
}
protected override void OnHoverLost(InputState state)
{
hovering = false;
UpdateState();
}
internal void SetButtonColour(Color4 buttonColour)
{
this.buttonColour = buttonColour;
UpdateState();
}
internal void UpdateState()
{
var colour = Bindable.Disabled ? Color4.Gray : buttonColour;
this.FadeTo(Bindable.IsDefault ? 0f : hovering && !Bindable.Disabled ? 1f : 0.5f, 200, Easing.OutQuint);
this.FadeColour(ColourInfo.GradientHorizontal(colour.Opacity(0.8f), colour.Opacity(0)), 200, Easing.OutQuint);
}
}
}

View File

@ -69,8 +69,6 @@ namespace osu.Game.Overlays.Settings
Padding = new MarginPadding
{
Top = 20 + border_size,
Left = SettingsOverlay.CONTENT_MARGINS,
Right = SettingsOverlay.CONTENT_MARGINS,
Bottom = 10,
},
RelativeSizeAxes = Axes.X,
@ -81,7 +79,8 @@ namespace osu.Game.Overlays.Settings
{
TextSize = header_size,
Text = Header,
Colour = colours.Yellow
Colour = colours.Yellow,
Margin = new MarginPadding { Left = SettingsOverlay.CONTENT_MARGINS, Right = SettingsOverlay.CONTENT_MARGINS }
},
FlowContent
}

View File

@ -2,6 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics.UserInterface;
@ -22,5 +23,15 @@ namespace osu.Game.Overlays.Settings
Margin = new MarginPadding { Top = 5, Bottom = 5 },
RelativeSizeAxes = Axes.X
};
public float KeyboardStep;
[BackgroundDependencyLoader]
private void load()
{
var slider = Control as U;
if (slider != null)
slider.KeyboardStep = KeyboardStep;
}
}
}

View File

@ -52,7 +52,7 @@ namespace osu.Game.Overlays.Settings
new OsuSpriteText
{
Text = Header.ToUpper(),
Margin = new MarginPadding { Bottom = 10 },
Margin = new MarginPadding { Bottom = 10, Left = SettingsOverlay.CONTENT_MARGINS, Right = SettingsOverlay.CONTENT_MARGINS },
Font = @"Exo2.0-Black",
},
FlowContent

View File

@ -1,6 +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 osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
@ -11,11 +12,12 @@ namespace osu.Game.Overlays.Toolbar
internal class ToolbarUserArea : Container
{
public LoginOverlay LoginOverlay;
private readonly ToolbarUserButton button;
private ToolbarUserButton button;
public override RectangleF BoundingBox => button.BoundingBox;
public ToolbarUserArea()
[BackgroundDependencyLoader]
private void load()
{
RelativeSizeAxes = Axes.Y;
AutoSizeAxes = Axes.X;
@ -36,4 +38,4 @@ namespace osu.Game.Overlays.Toolbar
};
}
}
}
}

View File

@ -19,7 +19,8 @@ namespace osu.Game.Screens.Play.ReplaySettings
new ReplaySliderBar<double>
{
LabelText = "Playback speed",
Bindable = config.GetBindable<double>(OsuSetting.PlaybackSpeed)
Bindable = config.GetBindable<double>(OsuSetting.PlaybackSpeed),
KeyboardStep = 0.5f
}
};
}

View File

@ -13,11 +13,9 @@ namespace osu.Game.Tests.Visual
{
using (var host = new HeadlessGameHost($"test-{Guid.NewGuid()}", realtime: false))
{
host.Storage.DeleteDirectory(string.Empty);
host.Run(new OsuTestCaseTestRunner(this));
}
// clean up after each run
//storage.DeleteDirectory(string.Empty);
}
public class OsuTestCaseTestRunner : OsuGameBase

View File

@ -289,6 +289,7 @@
<Compile Include="Migrations\OsuDbContextModelSnapshot.cs" />
<Compile Include="Online\API\Requests\GetBeatmapSetRequest.cs" />
<Compile Include="Online\API\Requests\GetBeatmapSetsResponse.cs" />
<Compile Include="Overlays\Settings\SettingsButton.cs" />
<Compile Include="Screens\Edit\Screens\Compose\Timeline\BeatmapWaveformGraph.cs" />
<Compile Include="Beatmaps\Drawables\DifficultyColouredContainer.cs" />
<Compile Include="Beatmaps\Drawables\DifficultyIcon.cs" />