This commit is contained in:
DrabWeb 2017-02-25 21:22:47 -04:00
commit a009268370
142 changed files with 363 additions and 561 deletions

@ -1 +1 @@
Subproject commit 56535b834cf2329e5abc8ecf698d19ece9ef7b07
Subproject commit 06f9c47ef5d007b39faf8169170d16ece672b981

View File

@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following

View File

@ -2,20 +2,9 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.Desktop.Platform;
using osu.Framework.Screens.Testing;
using osu.Game;
using osu.Game.Modes;
using osu.Game.Modes.Catch;
using osu.Game.Modes.Mania;
using osu.Game.Modes.Osu;
using osu.Game.Modes.Taiko;
namespace osu.Desktop.VisualTests
{

View File

@ -3,7 +3,6 @@
using System;
using osu.Framework.Desktop;
using osu.Framework.Desktop.Platform;
using osu.Framework.Platform;
using osu.Game.Modes;
using osu.Game.Modes.Catch;

View File

@ -1,22 +1,9 @@
// 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.Diagnostics;
using System.Linq;
using osu.Framework;
using osu.Framework.Screens.Testing;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Threading;
using osu.Game;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Online.Chat;
using OpenTK;
using osu.Framework.Allocation;
using osu.Game.Online.Chat.Drawables;
using osu.Game.Overlays;
namespace osu.Desktop.VisualTests.Tests

View File

@ -7,15 +7,11 @@ using osu.Framework.Graphics;
using osu.Framework.MathUtils;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Modes.Catch;
using osu.Game.Modes.Catch.UI;
using osu.Game.Modes.Mania;
using osu.Game.Modes.Mania.UI;
using osu.Game.Modes.Objects;
using osu.Game.Modes.Osu;
using osu.Game.Modes.Osu.Objects;
using osu.Game.Modes.Osu.UI;
using osu.Game.Modes.Taiko;
using osu.Game.Modes.Taiko.UI;
using OpenTK;

View File

@ -2,21 +2,17 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using osu.Framework;
using osu.Framework.Screens.Testing;
using osu.Framework.Graphics;
using osu.Framework.Timing;
using OpenTK;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Game.Modes.Objects;
using osu.Game.Modes.Objects.Drawables;
using osu.Game.Modes.Osu.Objects;
using osu.Game.Modes.Osu.Objects.Drawables;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Modes;
using OpenTK.Graphics;
namespace osu.Desktop.VisualTests.Tests

View File

@ -3,9 +3,7 @@
using osu.Framework.Screens.Testing;
using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterface;
using OpenTK.Input;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Configuration;
using OpenTK;

View File

@ -5,11 +5,9 @@ using System.Collections.Generic;
using osu.Framework.Graphics;
using osu.Framework.Screens.Testing;
using osu.Framework.MathUtils;
using osu.Framework.Timing;
using osu.Game.Overlays;
using System.Linq;
using osu.Game.Overlays.Notifications;
using osu.Game.Screens.Backgrounds;
namespace osu.Desktop.VisualTests.Tests
{

View File

@ -2,11 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Screens.Testing;
using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterface;
using OpenTK.Input;
using osu.Game.Overlays;
using osu.Framework.Graphics.Containers;
namespace osu.Desktop.VisualTests.Tests
{

View File

@ -1,16 +1,9 @@
// 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;
using OpenTK.Graphics;
using osu.Framework.Logging;
using osu.Framework.Graphics;
using osu.Game.Overlays.Pause;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Colour;
using osu.Framework.Screens.Testing;
using osu.Framework.Graphics.UserInterface;
namespace osu.Desktop.VisualTests.Tests
{

View File

@ -4,12 +4,11 @@
using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Screens.Testing;
using osu.Framework.MathUtils;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Formats;
using OpenTK;
using osu.Framework.Graphics.Sprites;
using osu.Game.Beatmaps.IO;
using osu.Game.Database;
using osu.Game.Modes;
using osu.Game.Modes.Objects;
@ -74,7 +73,7 @@ namespace osu.Desktop.VisualTests.Tests
decoder.Process(b);
beatmap = new WorkingBeatmap(b);
beatmap = new TestWorkingBeatmap(b);
}
Add(new Box
@ -92,5 +91,16 @@ namespace osu.Desktop.VisualTests.Tests
Beatmap = beatmap
});
}
class TestWorkingBeatmap : WorkingBeatmap
{
public TestWorkingBeatmap(Beatmap beatmap)
: base(beatmap.BeatmapInfo, beatmap.BeatmapInfo.BeatmapSet)
{
Beatmap = beatmap;
}
protected override ArchiveReader GetReader() => null;
}
}
}

View File

@ -7,17 +7,11 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.MathUtils;
using osu.Game.Graphics.UserInterface;
using osu.Game.Modes;
using osu.Game.Modes.Catch;
using osu.Game.Modes.Catch.UI;
using osu.Game.Modes.Mania;
using osu.Game.Modes.Mania.UI;
using osu.Game.Modes.Osu;
using osu.Game.Modes.Osu.UI;
using osu.Game.Modes.Taiko;
using osu.Game.Modes.Taiko.UI;
using osu.Game.Modes.UI;
using osu.Game.Screens.Play;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Graphics.Primitives;
@ -164,7 +158,7 @@ namespace osu.Desktop.VisualTests.Tests
AddButton(@"Alter stars", delegate
{
stars.Count = RNG.NextSingle() * (stars.MaxStars + 1);
stars.Count = RNG.NextSingle() * (stars.StarCount + 1);
starsLabel.Text = stars.Count.ToString("0.00");
});

View File

@ -2,12 +2,8 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Screens.Testing;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Screens.Menu;
using osu.Game.Screens.Play;
using OpenTK.Graphics;
namespace osu.Desktop.VisualTests.Tests
{

View File

@ -1,16 +1,8 @@
// 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;
using osu.Framework.Screens.Testing;
using osu.Framework.Graphics.Cursor;
using osu.Game.Database;
using osu.Game;
using osu.Framework.Desktop.Platform;
using System.Reflection;
using System.IO;
using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Game.Screens.Backgrounds;
namespace osu.Desktop.VisualTests
@ -21,7 +13,7 @@ namespace osu.Desktop.VisualTests
{
base.LoadComplete();
(new BackgroundScreenDefault() { Depth = 10 }).Preload(this, AddInternal);
(new BackgroundScreenDefault() { Depth = 10 }).LoadAsync(this, AddInternal);
// Have to construct this here, rather than in the constructor, because
// we depend on some dependencies to be loaded within OsuGameBase.load().

View File

@ -1,9 +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;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using osu.Game.Beatmaps.Formats;
using osu.Game.Beatmaps.IO;

View File

@ -2,15 +2,10 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using osu.Framework.Platform;
using osu.Framework.Desktop.Platform;
using osu.Game.Database;
using osu.Desktop.Overlays;
using System.Reflection;
using System.Drawing;
@ -34,7 +29,7 @@ namespace osu.Desktop
{
base.LoadComplete();
versionManager.Preload(this);
versionManager.LoadAsync(this);
ModeChanged += m =>
{
if (!versionManager.IsAlive && m is Intro)
@ -61,7 +56,7 @@ namespace osu.Desktop
// this method will only be executed if e.Effect in dragEnter gets set to something other that None.
var dropData = e.Data.GetData(DataFormats.FileDrop) as object[];
var filePaths = dropData.Select(f => f.ToString()).ToArray();
ImportBeatmaps(filePaths);
ImportBeatmapsAsync(filePaths);
}
private void dragEnter(DragEventArgs e)

View File

@ -2,7 +2,6 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.ComponentModel;
using System.Diagnostics;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
@ -19,7 +18,6 @@ using osu.Game.Graphics;
using OpenTK;
using OpenTK.Graphics;
using System.Net.Http;
using osu.Framework.Logging;
namespace osu.Desktop.Overlays
{
@ -104,7 +102,7 @@ namespace osu.Desktop.Overlays
};
if (IsDeployedBuild)
updateChecker();
checkForUpdateAsync();
}
protected override void LoadComplete()
@ -119,7 +117,7 @@ namespace osu.Desktop.Overlays
updateManager?.Dispose();
}
private async void updateChecker(bool useDeltaPatching = true, UpdateProgressNotification notification = null)
private async void checkForUpdateAsync(bool useDeltaPatching = true, UpdateProgressNotification notification = null)
{
//should we schedule a retry on completion of this check?
bool scheduleRetry = true;
@ -165,7 +163,7 @@ namespace osu.Desktop.Overlays
{
//could fail if deltas are unavailable for full update path (https://github.com/Squirrel/Squirrel.Windows/issues/959)
//try again without deltas.
updateChecker(false, notification);
checkForUpdateAsync(false, notification);
scheduleRetry = false;
}
}
@ -180,7 +178,7 @@ namespace osu.Desktop.Overlays
if (scheduleRetry)
{
//check again in 30 minutes.
Scheduler.AddDelayed(() => updateChecker(), 60000 * 30);
Scheduler.AddDelayed(() => checkForUpdateAsync(), 60000 * 30);
if (notification != null)
notification.State = ProgressNotificationState.Cancelled;
}

View File

@ -35,7 +35,7 @@ namespace osu.Desktop
foreach (var file in args)
{
Console.WriteLine(@"Importing {0}", file);
if (!importer.Import(Path.GetFullPath(file)).Wait(3000))
if (!importer.ImportAsync(Path.GetFullPath(file)).Wait(3000))
throw new TimeoutException(@"IPC took too long to send");
}
}

View File

@ -2,7 +2,6 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following

View File

@ -19,7 +19,7 @@ namespace osu.Game.Modes.Catch
protected override HitObjectConverter<CatchBaseHit> Converter => new CatchConverter();
protected override double ComputeDifficulty(Dictionary<String, String> categoryDifficulty)
protected override double CalculateInternal(Dictionary<String, String> categoryDifficulty)
{
return 0;
}

View File

@ -7,7 +7,6 @@ using osu.Game.Modes.Objects;
using osu.Game.Modes.Osu.UI;
using osu.Game.Modes.UI;
using osu.Game.Beatmaps;
using System;
namespace osu.Game.Modes.Catch
{

View File

@ -2,7 +2,6 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following

View File

@ -22,7 +22,7 @@ namespace osu.Game.Modes.Mania
protected override HitObjectConverter<ManiaBaseHit> Converter => new ManiaConverter(columns);
protected override double ComputeDifficulty(Dictionary<String, String> categoryDifficulty)
protected override double CalculateInternal(Dictionary<String, String> categoryDifficulty)
{
return 0;
}

View File

@ -7,7 +7,6 @@ using osu.Game.Modes.Objects;
using osu.Game.Modes.Osu.UI;
using osu.Game.Modes.UI;
using osu.Game.Beatmaps;
using System;
namespace osu.Game.Modes.Mania
{

View File

@ -2,7 +2,6 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following

View File

@ -1,14 +1,11 @@
// 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;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Framework.Input;
using OpenTK;
namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
{

View File

@ -1,14 +1,11 @@
// 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.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces

View File

@ -1,11 +1,9 @@
// 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.Sprites;
using osu.Framework.Graphics.Textures;
using OpenTK;
using OpenTK.Graphics;

View File

@ -6,7 +6,6 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transformations;
using osu.Framework.Input;
using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces

View File

@ -1,14 +1,8 @@
// 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;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces

View File

@ -10,7 +10,6 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transformations;
using osu.Framework.Input;
using osu.Framework.Logging;
using osu.Game.Graphics;
using OpenTK;
using OpenTK.Graphics;

View File

@ -1,7 +1,6 @@
// 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;
using osu.Game.Graphics.Backgrounds;
namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces

View File

@ -1,7 +1,6 @@
// 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;
namespace osu.Game.Modes.Osu.Objects
{

View File

@ -2,7 +2,6 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Game.Beatmaps.Samples;
using osu.Game.Modes.Objects;
using OpenTK;
using osu.Game.Beatmaps;

View File

@ -4,9 +4,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using osu.Game.Beatmaps.Samples;
using osu.Game.Modes.Objects;
using OpenTK;

View File

@ -29,26 +29,21 @@ namespace osu.Game.Modes.Osu.Objects
case CurveTypes.Linear:
return subControlPoints;
case CurveTypes.PerfectCurve:
// If we have a different amount than 3 control points, use bezier for perfect curves.
if (ControlPoints.Count != 3)
return new BezierApproximator(subControlPoints).CreateBezier();
else
{
Debug.Assert(subControlPoints.Count == 3);
//we can only use CircularArc iff we have exactly three control points and no dissection.
if (ControlPoints.Count != 3 || subControlPoints.Count != 3)
break;
// Here we have exactly 3 control points. Attempt to fit a circular arc.
List<Vector2> subpath = new CircularArcApproximator(subControlPoints[0], subControlPoints[1], subControlPoints[2]).CreateArc();
// Here we have exactly 3 control points. Attempt to fit a circular arc.
List<Vector2> subpath = new CircularArcApproximator(subControlPoints[0], subControlPoints[1], subControlPoints[2]).CreateArc();
if (subpath.Count == 0)
// For some reason a circular arc could not be fit to the 3 given points. Fall back
// to a numerically stable bezier approximation.
subpath = new BezierApproximator(subControlPoints).CreateBezier();
// If for some reason a circular arc could not be fit to the 3 given points, fall back to a numerically stable bezier approximation.
if (subpath.Count == 0)
break;
return subpath;
}
default:
return new BezierApproximator(subControlPoints).CreateBezier();
return subpath;
}
return new BezierApproximator(subControlPoints).CreateBezier();
}
private void calculatePath()
@ -181,7 +176,7 @@ namespace osu.Game.Modes.Osu.Objects
path.Clear();
int i = 0;
for (; i < calculatedPath.Count && cumulativeLength[i] < d0; ++i);
for (; i < calculatedPath.Count && cumulativeLength[i] < d0; ++i) ;
path.Add(interpolateVertices(i, d0) + Offset);

View File

@ -1,6 +1,4 @@
using OpenTK;
namespace osu.Game.Modes.Osu.Objects
namespace osu.Game.Modes.Osu.Objects
{
public class SliderTick : OsuHitObject
{

View File

@ -1,7 +1,6 @@
// 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.Game.Beatmaps;
namespace osu.Game.Modes.Osu.Objects
{

View File

@ -34,7 +34,7 @@ namespace osu.Game.Modes.Osu
((Slider)h).Curve.Calculate();
}
protected override double ComputeDifficulty(Dictionary<String, String> categoryDifficulty)
protected override double CalculateInternal(Dictionary<String, String> categoryDifficulty)
{
// Fill our custom DifficultyHitObject class, that carries additional information
DifficultyHitObjects.Clear();

View File

@ -1,11 +1,6 @@
// 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;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace osu.Game.Modes.Osu
{

View File

@ -2,7 +2,6 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following

View File

@ -3,7 +3,6 @@
using osu.Game.Modes.UI;
using OpenTK;
using osu.Framework.Graphics.Primitives;
namespace osu.Game.Modes.Osu.UI
{

View File

@ -2,7 +2,6 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following

View File

@ -19,7 +19,7 @@ namespace osu.Game.Modes.Taiko
protected override HitObjectConverter<TaikoBaseHit> Converter => new TaikoConverter();
protected override double ComputeDifficulty(Dictionary<String, String> categoryDifficulty)
protected override double CalculateInternal(Dictionary<String, String> categoryDifficulty)
{
return 0;
}

View File

@ -1,7 +1,6 @@
// 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;
using osu.Game.Graphics;
using osu.Game.Modes.Objects;
using osu.Game.Modes.Osu.UI;

View File

@ -3,7 +3,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using NUnit.Framework;
@ -16,7 +15,6 @@ using osu.Game.Modes.Catch;
using osu.Game.Modes.Mania;
using osu.Game.Modes.Osu;
using osu.Game.Modes.Taiko;
using osu.Game.Screens.Play;
namespace osu.Game.Tests.Beatmaps.IO
{
@ -58,10 +56,10 @@ namespace osu.Game.Tests.Beatmaps.IO
var osu = loadOsu(host);
var importer = new BeatmapImporter(client);
if (!importer.Import(osz_path).Wait(1000))
if (!importer.ImportAsync(osz_path).Wait(1000))
Assert.Fail(@"IPC took too long to send");
ensureLoaded(osu, 10000);
ensureLoaded(osu);
}
}
@ -79,23 +77,23 @@ namespace osu.Game.Tests.Beatmaps.IO
return osu;
}
private void ensureLoaded(OsuGameBase osu, int timeout = 100)
private void ensureLoaded(OsuGameBase osu, int timeout = 10000)
{
IEnumerable<BeatmapSetInfo> resultSets = null;
Action waitAction = () =>
{
while ((resultSets = osu.Dependencies.Get<BeatmapDatabase>()
.Query<BeatmapSetInfo>().Where(s => s.OnlineBeatmapSetID == 241526)).Count() != 1)
Thread.Sleep(1);
.Query<BeatmapSetInfo>().Where(s => s.OnlineBeatmapSetID == 241526)).Count() == 0)
Thread.Sleep(50);
};
Assert.IsTrue(waitAction.BeginInvoke(null, null).AsyncWaitHandle.WaitOne(timeout),
@"BeatmapSet did not import to the database");
$@"BeatmapSet did not import to the database in allocated time.");
//ensure we were stored to beatmap database backing...
Assert.IsTrue(resultSets.Count() == 1);
Assert.IsTrue(resultSets.Count() == 1, $@"Incorrect result count found ({resultSets.Count()} but should be 1).");
IEnumerable<BeatmapInfo> resultBeatmaps = null;
@ -104,23 +102,24 @@ namespace osu.Game.Tests.Beatmaps.IO
{
while ((resultBeatmaps = osu.Dependencies.Get<BeatmapDatabase>()
.Query<BeatmapInfo>().Where(s => s.OnlineBeatmapSetID == 241526 && s.BaseDifficultyID > 0)).Count() != 12)
Thread.Sleep(1);
Thread.Sleep(50);
};
Assert.IsTrue(waitAction.BeginInvoke(null, null).AsyncWaitHandle.WaitOne(timeout),
@"Beatmaps did not import to the database");
@"Beatmaps did not import to the database in allocated time");
//fetch children and check we can load from the post-storage path...
var set = osu.Dependencies.Get<BeatmapDatabase>().GetChildren(resultSets.First());
Assert.IsTrue(set.Beatmaps.Count == resultBeatmaps.Count());
Assert.IsTrue(set.Beatmaps.Count == resultBeatmaps.Count(),
$@"Incorrect database beatmap count post-import ({resultBeatmaps.Count()} but should be {set.Beatmaps.Count}).");
foreach (BeatmapInfo b in resultBeatmaps)
Assert.IsTrue(set.Beatmaps.Any(c => c.OnlineBeatmapID == b.OnlineBeatmapID));
Assert.IsTrue(set.Beatmaps.Count > 0);
var beatmap = osu.Dependencies.Get<BeatmapDatabase>().GetBeatmap(set.Beatmaps.First(b => b.Mode == PlayMode.Osu));
var beatmap = osu.Dependencies.Get<BeatmapDatabase>().GetWorkingBeatmap(set.Beatmaps.First(b => b.Mode == PlayMode.Osu))?.Beatmap;
Assert.IsTrue(beatmap.HitObjects.Count > 0);
}

View File

@ -1,7 +1,6 @@
// 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;
using System.IO;
using NUnit.Framework;
using osu.Game.Beatmaps.IO;

View File

@ -7,6 +7,7 @@ using OpenTK.Graphics;
using osu.Game.Beatmaps.Timing;
using osu.Game.Database;
using osu.Game.Modes.Objects;
using osu.Game.Modes;
namespace osu.Game.Beatmaps
{
@ -57,5 +58,7 @@ namespace osu.Game.Beatmaps
return timingPoint ?? ControlPoint.Default;
}
public double CalculateStarDifficulty() => Ruleset.GetRuleset(BeatmapInfo.Mode).CreateDifficultyCalculator(this).Calculate();
}
}

View File

@ -14,7 +14,7 @@ namespace osu.Game.Beatmaps
protected double TimeRate = 1;
protected abstract double ComputeDifficulty(Dictionary<String, String> categoryDifficulty);
protected abstract double CalculateInternal(Dictionary<String, String> categoryDifficulty);
private void loadTiming()
{
@ -23,10 +23,10 @@ namespace osu.Game.Beatmaps
TimeRate = audioRate / 100.0;
}
public double GetDifficulty(Dictionary<string, string> categoryDifficulty = null)
public double Calculate(Dictionary<string, string> categoryDifficulty = null)
{
loadTiming();
double difficulty = ComputeDifficulty(categoryDifficulty);
double difficulty = CalculateInternal(categoryDifficulty);
return difficulty;
}
}

View File

@ -6,7 +6,6 @@ using System.Collections.Generic;
using System.Linq;
using osu.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Transformations;
using osu.Game.Database;
namespace osu.Game.Beatmaps.Drawables
@ -60,16 +59,21 @@ namespace osu.Game.Beatmaps.Drawables
}
}
public BeatmapGroup(WorkingBeatmap beatmap)
public BeatmapGroup(BeatmapSetInfo beatmapSet, BeatmapDatabase database)
{
BeatmapSet = beatmapSet;
WorkingBeatmap beatmap = database.GetWorkingBeatmap(BeatmapSet.Beatmaps.FirstOrDefault());
foreach (var b in BeatmapSet.Beatmaps)
b.StarDifficulty = (float)database.GetWorkingBeatmap(b).Beatmap.CalculateStarDifficulty();
Header = new BeatmapSetHeader(beatmap)
{
GainedSelection = headerGainedSelection,
RelativeSizeAxes = Axes.X,
};
BeatmapSet = beatmap.BeatmapSetInfo;
BeatmapPanels = beatmap.BeatmapSetInfo.Beatmaps.Select(b => new BeatmapPanel(b)
BeatmapSet.Beatmaps = BeatmapSet.Beatmaps.OrderBy(b => b.StarDifficulty).ToList();
BeatmapPanels = BeatmapSet.Beatmaps.Select(b => new BeatmapPanel(b)
{
Alpha = 0,
GainedSelection = panelGainedSelection,

View File

@ -26,6 +26,7 @@ namespace osu.Game.Beatmaps.Drawables
public Action<BeatmapPanel> GainedSelection;
public Action<BeatmapPanel> StartRequested;
private Triangles triangles;
private StarCounter starCounter;
protected override void Selected()
{
@ -56,6 +57,14 @@ namespace osu.Game.Beatmaps.Drawables
return base.OnClick(state);
}
protected override void ApplyState(PanelSelectedState last = PanelSelectedState.Hidden)
{
base.ApplyState(last);
if (last == PanelSelectedState.Hidden && State != last)
starCounter.ReplayAnimation();
}
public BeatmapPanel(BeatmapInfo beatmap)
{
Beatmap = beatmap;
@ -92,7 +101,6 @@ namespace osu.Game.Beatmaps.Drawables
new FlowContainer
{
Padding = new MarginPadding { Left = 5 },
Spacing = new Vector2(0, 5),
Direction = FlowDirections.Vertical,
AutoSizeAxes = Axes.Both,
Children = new Drawable[]
@ -130,7 +138,11 @@ namespace osu.Game.Beatmaps.Drawables
},
}
},
new StarCounter { Count = beatmap.StarDifficulty, StarSize = 8 }
starCounter = new StarCounter
{
Count = beatmap.StarDifficulty,
Scale = new Vector2(0.8f),
}
}
}
}

View File

@ -11,7 +11,6 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Sprites;
using osu.Game.Configuration;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using OpenTK;
using OpenTK.Graphics;
@ -162,7 +161,7 @@ namespace osu.Game.Beatmaps.Drawables
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
FillMode = FillMode.Fill,
}.Preload(game, (bg) =>
}.LoadAsync(game, (bg) =>
{
Add(bg);
ForceRedraw();

View File

@ -1,10 +1,8 @@
// 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;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Game.Database;
using osu.Game.Graphics;

View File

@ -50,10 +50,10 @@ namespace osu.Game.Beatmaps.Drawables
protected override void LoadComplete()
{
base.LoadComplete();
applyState();
ApplyState();
}
private void applyState()
protected virtual void ApplyState(PanelSelectedState last = PanelSelectedState.Hidden)
{
switch (state)
{
@ -81,9 +81,10 @@ namespace osu.Game.Beatmaps.Drawables
set
{
if (state == value) return;
state = value;
applyState();
var last = state;
state = value;
ApplyState(last);
}
}

View File

@ -1,7 +1,6 @@
// 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;
namespace osu.Game.Beatmaps.Events
{
public enum EventType

View File

@ -6,7 +6,6 @@ using System.Collections.Generic;
using System.IO;
using osu.Game.Modes.Objects;
using OpenTK.Graphics;
using osu.Game.Graphics;
using osu.Game.Beatmaps.Timing;
using osu.Game.Database;

View File

@ -2,11 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace osu.Game.Beatmaps.Formats
{

View File

@ -2,17 +2,14 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using OpenTK.Graphics;
using osu.Game.Database;
using osu.Game.Beatmaps.Events;
using osu.Game.Beatmaps.Samples;
using osu.Game.Beatmaps.Timing;
using osu.Game.Modes;
using osu.Game.Modes.Objects;
using osu.Game.Screens.Play;
namespace osu.Game.Beatmaps.Formats
{

View File

@ -1,10 +1,8 @@
// 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;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using Ionic.Zip;
using osu.Game.Beatmaps.Formats;
using osu.Game.Database;

View File

@ -5,8 +5,6 @@ namespace osu.Game.Beatmaps.Timing
{
class TimingChange : ControlPoint
{
public double BeatLength;
public TimingChange(double beatLength)
{
BeatLength = beatLength;

View File

@ -11,16 +11,22 @@ using osu.Game.Database;
namespace osu.Game.Beatmaps
{
public class WorkingBeatmap : IDisposable
public abstract class WorkingBeatmap : IDisposable
{
public readonly BeatmapInfo BeatmapInfo;
public readonly BeatmapSetInfo BeatmapSetInfo;
private readonly BeatmapDatabase database;
public readonly bool WithStoryboard;
private ArchiveReader getReader() => database?.GetReader(BeatmapSetInfo);
protected abstract ArchiveReader GetReader();
protected WorkingBeatmap(BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo, bool withStoryboard = false)
{
BeatmapInfo = beatmapInfo;
BeatmapSetInfo = beatmapSetInfo;
WithStoryboard = withStoryboard;
}
private Texture background;
private object backgroundLock = new object();
@ -36,7 +42,7 @@ namespace osu.Game.Beatmaps
try
{
using (var reader = getReader())
using (var reader = GetReader())
background = new TextureStore(new RawTextureLoaderStore(reader), false).Get(BeatmapInfo.Metadata.BackgroundFile);
}
catch { }
@ -59,7 +65,7 @@ namespace osu.Game.Beatmaps
try
{
using (var reader = getReader())
using (var reader = GetReader())
{
BeatmapDecoder decoder;
using (var stream = new StreamReader(reader.GetStream(BeatmapInfo.Path)))
@ -95,7 +101,7 @@ namespace osu.Game.Beatmaps
try
{
//store a reference to the reader as we may continue accessing the stream in the background.
trackReader = getReader();
trackReader = GetReader();
var trackData = trackReader?.GetStream(BeatmapInfo.Metadata.AudioFile);
if (trackData != null)
track = new TrackBass(trackData);
@ -110,21 +116,6 @@ namespace osu.Game.Beatmaps
public bool TrackLoaded => track != null;
public WorkingBeatmap(Beatmap beatmap)
{
this.beatmap = beatmap;
BeatmapInfo = beatmap.BeatmapInfo;
BeatmapSetInfo = beatmap.BeatmapInfo.BeatmapSet;
}
public WorkingBeatmap(BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo, BeatmapDatabase database, bool withStoryboard = false)
{
BeatmapInfo = beatmapInfo;
BeatmapSetInfo = beatmapSetInfo;
this.database = database;
this.WithStoryboard = withStoryboard;
}
private bool isDisposed;
protected virtual void Dispose(bool disposing)

View File

@ -1,7 +1,6 @@
// 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;
namespace osu.Game.Configuration
{
public enum ConfineMouseMode

View File

@ -1,7 +1,6 @@
// 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;
using System.ComponentModel;
namespace osu.Game.Configuration

View File

@ -1,11 +1,10 @@
// 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;
using System.ComponentModel;
namespace osu.Game.Configuration
{
{
public enum RankingType
{
Local,

View File

@ -1,7 +1,6 @@
// 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;
namespace osu.Game.Configuration
{
public enum ReleaseStream

View File

@ -1,7 +1,6 @@
// 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;
namespace osu.Game.Configuration
{
public enum ScoreMeterType

View File

@ -1,7 +1,6 @@
// 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;
using System.ComponentModel;
namespace osu.Game.Configuration

View File

@ -1,7 +1,6 @@
// 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;
using SQLite.Net.Attributes;
namespace osu.Game.Database

View File

@ -2,13 +2,12 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Security.Cryptography;
using osu.Framework.Logging;
using osu.Framework.Platform;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Formats;
@ -24,6 +23,7 @@ namespace osu.Game.Database
private SQLiteConnection connection { get; set; }
private Storage storage;
public event Action<BeatmapSetInfo> BeatmapSetAdded;
public event Action<BeatmapSetInfo> BeatmapSetRemoved;
private BeatmapImporter ipc;
@ -39,16 +39,37 @@ namespace osu.Game.Database
try
{
connection = prepareConnection();
deletePending();
}
catch
catch (Exception e)
{
Console.WriteLine(@"Failed to initialise the beatmap database! Trying again with a clean database...");
Logger.Error(e, @"Failed to initialise the beatmap database! Trying again with a clean database...");
storage.DeleteDatabase(@"beatmaps");
connection = prepareConnection();
}
}
}
private void deletePending()
{
foreach (var b in Query<BeatmapSetInfo>().Where(b => b.DeletePending))
{
try
{
storage.Delete(b.Path);
connection.Delete(b);
}
catch (Exception e)
{
Logger.Error(e, $@"Could not delete beatmap {b.ToString()}");
}
}
//this is required because sqlite migrations don't work, initially inserting nulls into this field.
//see https://github.com/praeclarum/sqlite-net/issues/326
connection.Query<BeatmapSetInfo>("UPDATE BeatmapSetInfo SET DeletePending = 0 WHERE DeletePending IS NULL");
}
private SQLiteConnection prepareConnection()
{
var conn = storage.GetDatabase(@"beatmaps");
@ -98,10 +119,6 @@ namespace osu.Game.Database
using (var reader = ArchiveReader.GetReader(storage, path))
metadata = reader.ReadMetadata();
if (metadata.OnlineBeatmapSetID.HasValue &&
connection.Table<BeatmapSetInfo>().Count(b => b.OnlineBeatmapSetID == metadata.OnlineBeatmapSetID) != 0)
return; // TODO: Update this beatmap instead
if (File.Exists(path)) // Not always the case, i.e. for LegacyFilesystemReader
{
using (var md5 = MD5.Create())
@ -110,10 +127,26 @@ namespace osu.Game.Database
hash = BitConverter.ToString(md5.ComputeHash(input)).Replace("-", "").ToLowerInvariant();
input.Seek(0, SeekOrigin.Begin);
path = Path.Combine(@"beatmaps", hash.Remove(1), hash.Remove(2), hash);
using (var output = storage.GetStream(path, FileAccess.Write))
input.CopyTo(output);
if (!storage.Exists(path))
using (var output = storage.GetStream(path, FileAccess.Write))
input.CopyTo(output);
}
}
var existing = connection.Table<BeatmapSetInfo>().FirstOrDefault(b => b.Hash == hash);
if (existing != null)
{
if (existing.DeletePending)
{
existing.DeletePending = false;
Update(existing, false);
BeatmapSetAdded?.Invoke(existing);
}
return;
}
var beatmapSet = new BeatmapSetInfo
{
OnlineBeatmapSetID = metadata.OnlineBeatmapSetID,
@ -148,15 +181,26 @@ namespace osu.Game.Database
public void Import(IEnumerable<BeatmapSetInfo> beatmapSets)
{
connection.BeginTransaction();
foreach (var s in beatmapSets)
lock (connection)
{
connection.InsertWithChildren(s, true);
BeatmapSetAdded?.Invoke(s);
}
connection.BeginTransaction();
connection.Commit();
foreach (var s in beatmapSets)
{
connection.InsertWithChildren(s, true);
BeatmapSetAdded?.Invoke(s);
}
connection.Commit();
}
}
public void Delete(BeatmapSetInfo beatmapSet)
{
beatmapSet.DeletePending = true;
Update(beatmapSet, false);
BeatmapSetRemoved?.Invoke(beatmapSet);
}
public ArchiveReader GetReader(BeatmapSetInfo beatmapSet)
@ -185,19 +229,13 @@ namespace osu.Game.Database
if (beatmapInfo.Metadata == null)
beatmapInfo.Metadata = beatmapSetInfo.Metadata;
var working = new WorkingBeatmap(beatmapInfo, beatmapSetInfo, this, withStoryboard);
WorkingBeatmap working = new DatabaseWorkingBeatmap(this, beatmapInfo, beatmapSetInfo, withStoryboard);
previous?.TransferTo(working);
return working;
}
public Beatmap GetBeatmap(BeatmapInfo beatmapInfo)
{
using (WorkingBeatmap data = GetWorkingBeatmap(beatmapInfo))
return data.Beatmap;
}
public TableQuery<T> Query<T>() where T : class
{
return connection.Table<T>();
@ -239,5 +277,20 @@ namespace osu.Game.Database
else
connection.Update(record);
}
public bool Exists(BeatmapSetInfo beatmapSet) => storage.Exists(beatmapSet.Path);
private class DatabaseWorkingBeatmap : WorkingBeatmap
{
private readonly BeatmapDatabase database;
public DatabaseWorkingBeatmap(BeatmapDatabase database, BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo, bool withStoryboard = false)
: base(beatmapInfo, beatmapSetInfo, withStoryboard)
{
this.database = database;
}
protected override ArchiveReader GetReader() => database?.GetReader(BeatmapSetInfo);
}
}
}

View File

@ -5,7 +5,6 @@ using System;
using System.Linq;
using osu.Game.Beatmaps.Samples;
using osu.Game.Modes;
using osu.Game.Screens.Play;
using SQLite.Net.Attributes;
using SQLiteNetExtensions.Attributes;
using osu.Game.Beatmaps;
@ -74,7 +73,6 @@ namespace osu.Game.Database
// Metadata
public string Version { get; set; }
//todo: background threaded computation of this
private float starDifficulty = -1;
public float StarDifficulty
{
@ -86,12 +84,6 @@ namespace osu.Game.Database
set { starDifficulty = value; }
}
internal void ComputeDifficulty(BeatmapDatabase database)
{
WorkingBeatmap wb = new WorkingBeatmap(this, BeatmapSet, database);
StarDifficulty = (float)Ruleset.GetRuleset(Mode).CreateDifficultyCalculator(wb.Beatmap).GetDifficulty();
}
public bool Equals(BeatmapInfo other)
{
return ID == other?.ID;

View File

@ -1,8 +1,8 @@
// 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;
using System.Collections.Generic;
using System.ComponentModel;
using SQLite.Net.Attributes;
using SQLiteNetExtensions.Attributes;
@ -24,6 +24,8 @@ namespace osu.Game.Database
[OneToMany(CascadeOperations = CascadeOperation.All)]
public List<BeatmapInfo> Beatmaps { get; set; }
public bool DeletePending { get; set; }
public string Hash { get; set; }
public string Path { get; set; }

View File

@ -1,13 +1,11 @@
// 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;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.Graphics.Backgrounds

View File

@ -5,7 +5,6 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics;
using osu.Framework.Input;
using OpenTK;
using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Transformations;
using osu.Game.Configuration;

View File

@ -2,9 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Diagnostics;
using OpenTK.Graphics;
using osu.Framework.Graphics.Colour;
namespace osu.Game.Graphics
{

View File

@ -2,7 +2,6 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics.Sprites;
using OpenTK;
namespace osu.Game.Graphics
{

View File

@ -4,7 +4,6 @@
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Graphics;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Graphics.UserInterface
{
@ -22,7 +21,7 @@ namespace osu.Game.Graphics.UserInterface
private void load(AudioManager audio, OsuColour colours)
{
ActivationSound = audio.Sample.Get(@"Menu/menuback");
Colour = colours.Pink;
BackgroundColour = colours.Pink;
HoverColour = colours.PinkDark;
}
}

View File

@ -1,7 +1,6 @@
// 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;
using osu.Framework.Graphics.Sprites;
namespace osu.Game.Graphics.UserInterface

View File

@ -1,7 +1,6 @@
// 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;
using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
@ -11,7 +10,6 @@ using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input;
using osu.Game.Graphics.Backgrounds;
using osu.Game.Graphics.Sprites;
using osu.Game.Overlays;
namespace osu.Game.Graphics.UserInterface
{

View File

@ -2,21 +2,16 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transformations;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input;
using osu.Game.Graphics.Sprites;
using osu.Game.Overlays;
using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.Graphics.UserInterface

View File

@ -6,7 +6,6 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using OpenTK.Graphics;

View File

@ -1,11 +1,8 @@
// 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;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using osu.Framework.Graphics.Transformations;
using osu.Framework.Graphics.UserInterface;
using OpenTK;

View File

@ -6,7 +6,6 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using OpenTK.Graphics;

View File

@ -1,15 +1,9 @@
// 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;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Transformations;
using osu.Framework.Timing;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace osu.Game.Graphics.UserInterface
{

View File

@ -4,12 +4,7 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.Transformations;
using osu.Framework.MathUtils;
using osu.Framework.Timing;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace osu.Game.Graphics.UserInterface
{

View File

@ -2,26 +2,19 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK;
using osu.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Transformations;
using osu.Framework.MathUtils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using osu.Framework.Allocation;
namespace osu.Game.Graphics.UserInterface
{
public class StarCounter : Container
{
private readonly Container starContainer;
private readonly List<TextAwesome> stars = new List<TextAwesome>();
private readonly Container<Star> stars;
private double transformStartTime = 0;
private double transformStartTime;
/// <summary>
/// Maximum amount of stars displayed.
@ -29,37 +22,20 @@ namespace osu.Game.Graphics.UserInterface
/// <remarks>
/// This does not limit the counter value, but the amount of stars displayed.
/// </remarks>
public int MaxStars
{
get;
protected set;
}
public int StarCount { get; }
private double animationDelay => 80;
private double scalingDuration => 500;
private double scalingDuration => 1000;
private EasingTypes scalingEasing => EasingTypes.OutElasticHalf;
private float minStarScale => 0.3f;
private float minStarScale => 0.4f;
private double fadingDuration => 100;
private float minStarAlpha => 0.5f;
public float StarSize = 20;
public float StarSpacing = 4;
private const float star_size = 20;
private float star_spacing = 4;
public float VisibleValue
{
get
{
double elapsedTime = Time.Current - transformStartTime;
double expectedElapsedTime = Math.Abs(prevCount - count) * animationDelay;
if (elapsedTime >= expectedElapsedTime)
return count;
return Interpolation.ValueAt(elapsedTime, prevCount, count, 0, expectedElapsedTime);
}
}
private float prevCount;
private float count;
/// <summary>
@ -74,119 +50,121 @@ namespace osu.Game.Graphics.UserInterface
set
{
if (IsLoaded)
{
prevCount = VisibleValue;
transformCount(prevCount, value);
}
if (count == value) return;
if (IsLoaded)
transformCount(value);
count = value;
}
}
/// <summary>
/// Shows a float count as stars (up to 10). Used as star difficulty display.
/// </summary>
public StarCounter() : this(10)
{
AutoSizeAxes = Axes.Both;
}
/// <summary>
/// Shows a float count as stars. Used as star difficulty display.
/// </summary>
/// <param name="maxstars">Maximum amount of stars to display.</param>
public StarCounter(int maxstars)
/// <param name="starCount">Maximum amount of stars to display.</param>
public StarCounter(int starCount = 10)
{
MaxStars = Math.Max(maxstars, 0);
StarCount = Math.Max(starCount, 0);
AutoSizeAxes = Axes.Both;
Children = new Drawable[]
{
starContainer = new Container
stars = new FlowContainer<Star>
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both,
Direction = FlowDirections.Horizontal,
Spacing = new Vector2(star_spacing),
}
};
starContainer.Width = MaxStars * StarSize + Math.Max(MaxStars - 1, 0) * StarSpacing;
starContainer.Height = StarSize;
for (int i = 0; i < MaxStars; i++)
for (int i = 0; i < StarCount; i++)
{
TextAwesome star = new TextAwesome
stars.Add(new Star
{
Icon = FontAwesome.fa_star,
Anchor = Anchor.CentreLeft,
Origin = Anchor.Centre,
TextSize = StarSize,
Scale = new Vector2(minStarScale),
Alpha = minStarAlpha,
Position = new Vector2((StarSize + StarSpacing) * i + (StarSize + StarSpacing) / 2, 0),
};
//todo: user Container<T> once we have it.
stars.Add(star);
starContainer.Add(star);
});
}
}
protected override void LoadComplete()
{
base.LoadComplete();
// Animate initial state from zero.
transformCount(0, Count);
ReplayAnimation();
}
public void ResetCount()
{
Count = 0;
count = 0;
StopAnimation();
}
public void ReplayAnimation()
{
var t = count;
ResetCount();
Count = t;
}
public void StopAnimation()
{
prevCount = count;
transformStartTime = Time.Current;
for (int i = 0; i < MaxStars; i++)
transformStarQuick(i, count);
int i = 0;
foreach (var star in stars.Children)
{
star.ClearTransformations(true);
star.FadeTo(i < count ? 1.0f : minStarAlpha);
star.Icon.ScaleTo(getStarScale(i, count));
i++;
}
}
private float getStarScale(int i, float value)
{
if (value <= i)
return minStarScale;
if (i + 1 <= value)
return 1.0f;
return Interpolation.ValueAt(value, minStarScale, 1.0f, i, i + 1);
return i + 1 <= value ? 1.0f : Interpolation.ValueAt(value, minStarScale, 1.0f, i, i + 1);
}
private void transformStar(int i, float value)
private void transformCount(float newValue)
{
stars[i].FadeTo(i < value ? 1.0f : minStarAlpha, fadingDuration);
stars[i].ScaleTo(getStarScale(i, value), scalingDuration, scalingEasing);
}
private void transformStarQuick(int i, float value)
{
stars[i].FadeTo(i < value ? 1.0f : minStarAlpha);
stars[i].ScaleTo(getStarScale(i, value));
}
private void transformCount(float currentValue, float newValue)
{
for (int i = 0; i < MaxStars; i++)
int i = 0;
foreach (var star in stars.Children)
{
stars[i].ClearTransformations();
if (currentValue <= newValue)
stars[i].Delay(Math.Max(i - currentValue, 0) * animationDelay);
star.ClearTransformations(true);
if (count <= newValue)
star.Delay(Math.Max(i - count, 0) * animationDelay, true);
else
stars[i].Delay(Math.Max(currentValue - 1 - i, 0) * animationDelay);
transformStar(i, newValue);
stars[i].DelayReset();
star.Delay(Math.Max(count - 1 - i, 0) * animationDelay, true);
star.FadeTo(i < newValue ? 1.0f : minStarAlpha, fadingDuration);
star.Icon.ScaleTo(getStarScale(i, newValue), scalingDuration, scalingEasing);
star.DelayReset();
i++;
}
}
class Star : Container
{
public TextAwesome Icon;
public Star()
{
Size = new Vector2(star_size);
Children = new[]
{
Icon = new TextAwesome
{
TextSize = star_size,
Icon = FontAwesome.fa_star,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
}
};
}
transformStartTime = Time.Current;
}
}
}

View File

@ -35,7 +35,7 @@ namespace osu.Game.Graphics.UserInterface
private Container c1;
private Container c2;
public Color4 Colour
public Color4 BackgroundColour
{
set
{

View File

@ -2,8 +2,6 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input;

View File

@ -6,7 +6,6 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input;
using OpenTK.Input;
using OpenTK;
namespace osu.Game.Graphics.UserInterface.Volume
{

View File

@ -1,7 +1,6 @@
// 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;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;

View File

@ -21,13 +21,13 @@ namespace osu.Game.IPC
channel.MessageReceived += messageReceived;
}
public async Task Import(string path)
public async Task ImportAsync(string path)
{
if (beatmaps != null)
beatmaps.Import(path);
else
{
await channel.SendMessage(new BeatmapImportMessage { Path = path });
await channel.SendMessageAsync(new BeatmapImportMessage { Path = path });
}
}
@ -35,7 +35,7 @@ namespace osu.Game.IPC
{
Debug.Assert(beatmaps != null);
Import(msg.Path);
ImportAsync(msg.Path);
}
}

View File

@ -4,12 +4,10 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps.Samples;
using OpenTK;
using Container = osu.Framework.Graphics.Containers.Container;

View File

@ -1,11 +1,6 @@
// 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;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using osu.Framework.Graphics;
namespace osu.Game.Modes.Objects.Drawables

View File

@ -4,7 +4,6 @@
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Samples;
using OpenTK.Graphics;
using osu.Game.Graphics;
namespace osu.Game.Modes.Objects
{

View File

@ -1,11 +1,6 @@
// 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;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace osu.Game.Modes.Objects
{

View File

@ -1,11 +1,6 @@
// 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;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace osu.Game.Modes
{

View File

@ -3,9 +3,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using osu.Framework.Configuration;
using osu.Game.Modes.Objects.Drawables;

View File

@ -1,11 +1,6 @@
// 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;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace osu.Game.Online.API
{

View File

@ -1,7 +1,6 @@
// 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;
using System.Diagnostics;
using osu.Framework.IO.Network;

View File

@ -1,7 +1,6 @@
// 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;
using System.Diagnostics;
using System.Security;
using osu.Framework.Extensions;

Some files were not shown because too many files have changed in this diff Show More