Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replay loading via drag-drop huzzah! #436

Merged
merged 39 commits into from
Mar 7, 2017
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
58ae9e8
Basic partial replay support.
peppy Feb 28, 2017
b6e7e05
wankoz
peppy Mar 1, 2017
8040d6a
Fix CursorTrail corruption by resetting on load.
peppy Mar 2, 2017
4bd85fe
Fix audio disposal issues and share more code between visualtests.
peppy Mar 2, 2017
9e1383f
Merge remote-tracking branch 'upstream/master' into replay
peppy Mar 4, 2017
adb6f01
Create class hierarchy for Score/Replay storage.
peppy Mar 4, 2017
b294386
Remove misleading beatmap import method.
peppy Mar 4, 2017
aa9d856
Change IPC to make sense.
peppy Mar 4, 2017
a8deb4f
Fix WaveOverlayContainer always being visible.
peppy Mar 4, 2017
95e2e2b
Replay loading via drag-drop huzzah!
peppy Mar 4, 2017
a5d0440
Cancel previous load attempts before starting a new score load.
peppy Mar 4, 2017
7a6a614
Don't show pause menu when watching replays.
peppy Mar 4, 2017
4e4408c
Merge branch 'master' into replay
peppy Mar 5, 2017
7afcac3
Move PreferredPlayMode to WorkingBeatmap.
peppy Mar 5, 2017
1c5b918
Add osu! autoplay generation.
peppy Mar 5, 2017
5494541
Remove unnecessary usings.
peppy Mar 6, 2017
5b4424d
CreateAutoplayReplay -> CreateAutoplayScore.
peppy Mar 6, 2017
81cc27e
Fix typo.
peppy Mar 6, 2017
cb002ce
General refactoring of OsuAutoReplay.
peppy Mar 6, 2017
56922b6
Refactor sliders to have more central position/progress calculations.
peppy Mar 6, 2017
910d9cc
Add proper slider following support to OsuAutoReplay.
peppy Mar 6, 2017
20fcb88
Move constants to base OsuHitObject representation.
peppy Mar 6, 2017
faf07ab
Use generics everywhere.
peppy Mar 6, 2017
3b0445a
Improve comment for PreferredPlayMode and allow null.
peppy Mar 6, 2017
1b03998
Improve comment of SetFrameFromTime.
peppy Mar 6, 2017
809828f
Improve NextFrame.
peppy Mar 6, 2017
4118be6
Remove unnecessary bounds check.
peppy Mar 6, 2017
652d18a
Update second usage of comment.
peppy Mar 6, 2017
1ea21da
Fix PlayMode regression.
peppy Mar 6, 2017
76ef8c1
Add bindable mods and autoplay support.
peppy Mar 6, 2017
ff51af9
Fail on drag drop operations with mixed files.
peppy Mar 6, 2017
2de25c2
Make Mods IEnumerable.
peppy Mar 6, 2017
610de4a
Only show replay cursor when replay input is present.
peppy Mar 6, 2017
fc6bd38
Fix remaining usage of hit window constants.
peppy Mar 6, 2017
12c316a
Fix int truncation.
peppy Mar 7, 2017
bc74f45
Merge branch 'master' into replay
smoogipoo Mar 7, 2017
4430255
Merge remote-tracking branch 'upstream/master' into replay
peppy Mar 7, 2017
5cbcf7a
Fix error-level inspections.
peppy Mar 7, 2017
bff1179
Merge branch 'master' into replay
peppy Mar 7, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions osu.Desktop.VisualTests/Tests/TestCasePlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,28 @@ namespace osu.Desktop.VisualTests.Tests
{
class TestCasePlayer : TestCase
{
private WorkingBeatmap beatmap;
protected Player Player;
private BeatmapDatabase db;


public override string Description => @"Showing everything to play the game.";

[BackgroundDependencyLoader]
private void load(BeatmapDatabase db)
{
var beatmapInfo = db.Query<BeatmapInfo>().Where(b => b.Mode == PlayMode.Osu).FirstOrDefault();
if (beatmapInfo != null)
beatmap = db.GetWorkingBeatmap(beatmapInfo);
this.db = db;
}

public override void Reset()
{
base.Reset();

WorkingBeatmap beatmap = null;

var beatmapInfo = db.Query<BeatmapInfo>().Where(b => b.Mode == PlayMode.Osu).FirstOrDefault();
if (beatmapInfo != null)
beatmap = db.GetWorkingBeatmap(beatmapInfo);

if (beatmap?.Track == null)
{
var objects = new List<HitObject>();
Expand Down Expand Up @@ -81,14 +87,18 @@ public override void Reset()
Colour = Color4.Black,
});

Add(new PlayerLoader(new Player
Add(new PlayerLoader(Player = CreatePlayer(beatmap))
{
PreferredPlayMode = PlayMode.Osu,
Beatmap = beatmap
})
});
}

protected virtual Player CreatePlayer(WorkingBeatmap beatmap)
{
return new Player
{
Beatmap = beatmap
});
};
}

class TestWorkingBeatmap : WorkingBeatmap
Expand Down
60 changes: 60 additions & 0 deletions osu.Desktop.VisualTests/Tests/TestCaseReplay.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// 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.IO;
using System.Text;
using osu.Framework.Allocation;
using osu.Framework.Screens.Testing;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Formats;
using OpenTK;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input;
using osu.Framework.Input.Handlers;
using osu.Framework.MathUtils;
using osu.Framework.Platform;
using osu.Game.Beatmaps.IO;
using osu.Game.Database;
using osu.Game.Input.Handlers;
using osu.Game.IO.Legacy;
using osu.Game.Modes;
using osu.Game.Modes.Objects;
using osu.Game.Modes.Osu.Objects;
using osu.Game.Screens.Play;
using OpenTK.Graphics;
using OpenTK.Input;
using SharpCompress.Archives.SevenZip;
using SharpCompress.Compressors.LZMA;
using SharpCompress.Readers;
using KeyboardState = osu.Framework.Input.KeyboardState;
using MouseState = osu.Framework.Input.MouseState;

This comment was marked as off-topic.

This comment was marked as off-topic.


namespace osu.Desktop.VisualTests.Tests
{
class TestCaseReplay : TestCasePlayer
{
private WorkingBeatmap beatmap;

private InputHandler replay;

private Func<Stream> getReplayStream;
private ScoreDatabase scoreDatabase;

public override string Description => @"Testing replay playback.";

[BackgroundDependencyLoader]
private void load(Storage storage)
{
scoreDatabase = new ScoreDatabase(storage);
}

protected override Player CreatePlayer(WorkingBeatmap beatmap)
{
var player = base.CreatePlayer(beatmap);
player.ReplayInputHandler = Ruleset.GetRuleset(beatmap.PlayMode).CreateAutoplayReplay(beatmap.Beatmap)?.Replay?.GetInputHandler();
return player;
}
}
}
5 changes: 5 additions & 0 deletions osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@
<HintPath>$(SolutionDir)\packages\ppy.OpenTK.2.0.50727.1340\lib\net45\OpenTK.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="SharpCompress, Version=0.15.1.0, Culture=neutral, PublicKeyToken=afb0a02973931d96, processorArchitecture=MSIL">
<HintPath>..\packages\SharpCompress.0.15.1\lib\net45\SharpCompress.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="SQLite.Net, Version=3.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(SolutionDir)\packages\SQLite.Net.Core-PCL.3.1.1\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.dll</HintPath>
Expand Down Expand Up @@ -187,6 +191,7 @@
<Compile Include="Tests\TestCaseHitObjects.cs" />
<Compile Include="Tests\TestCaseKeyCounter.cs" />
<Compile Include="Tests\TestCaseMenuButtonSystem.cs" />
<Compile Include="Tests\TestCaseReplay.cs" />
<Compile Include="Tests\TestCaseScoreCounter.cs" />
<Compile Include="Tests\TestCaseTextAwesome.cs" />
<Compile Include="Tests\TestCasePlaySongSelect.cs" />
Expand Down
1 change: 1 addition & 0 deletions osu.Desktop.VisualTests/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/maste
<packages>
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net45" />
<package id="ppy.OpenTK" version="2.0.50727.1340" targetFramework="net45" />
<package id="SharpCompress" version="0.15.1" targetFramework="net45" />
<package id="SQLite.Net.Core-PCL" version="3.1.1" targetFramework="net45" />
<package id="SQLite.Net-PCL" version="3.1.1" targetFramework="net45" />
<package id="SQLiteNetExtensions" version="1.3.0" targetFramework="net45" />
Expand Down
20 changes: 16 additions & 4 deletions osu.Desktop/OsuGameDesktop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
using osu.Desktop.Overlays;
using System.Reflection;
using System.Drawing;
using System.IO;
using System.Threading.Tasks;
using osu.Game.Screens.Menu;

namespace osu.Desktop
Expand Down Expand Up @@ -54,19 +56,29 @@ public override void SetHost(GameHost host)
private void dragDrop(DragEventArgs e)
{
// 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 dropData = (object[])e.Data.GetData(DataFormats.FileDrop);
var filePaths = dropData.Select(f => f.ToString()).ToArray();
ImportBeatmapsAsync(filePaths);

if (filePaths.All(f => Path.GetExtension(f) == @".osz"))
Task.Run(() => BeatmapDatabase.Import(filePaths));

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

else if (filePaths.All(f => Path.GetExtension(f) == @".osr"))
Task.Run(() =>
{
var score = ScoreDatabase.ReadReplayFile(filePaths.First());
Schedule(() => LoadScore(score));
});
}

static readonly string[] allowed_extensions = { @".osz", @".osr" };

private void dragEnter(DragEventArgs e)
{
// dragDrop will only be executed if e.Effect gets set to something other that None in this method.
bool isFile = e.Data.GetDataPresent(DataFormats.FileDrop);
if (isFile)
{
var paths = (e.Data.GetData(DataFormats.FileDrop) as object[]).Select(f => f.ToString()).ToArray();
if (paths.Any(p => !p.EndsWith(".osz")))
var paths = ((object[])e.Data.GetData(DataFormats.FileDrop)).Select(f => f.ToString()).ToArray();
if (paths.Any(p => !allowed_extensions.Any(ext => p.EndsWith(ext))))
e.Effect = DragDropEffects.None;
else
e.Effect = DragDropEffects.Copy;
Expand Down
2 changes: 1 addition & 1 deletion osu.Desktop/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static int Main(string[] args)
{
if (!host.IsPrimaryInstance)
{
var importer = new BeatmapImporter(host);
var importer = new BeatmapIPCChannel(host);
// Restore the cwd so relative paths given at the command line work correctly
Directory.SetCurrentDirectory(cwd);
foreach (var file in args)
Expand Down
4 changes: 2 additions & 2 deletions osu.Desktop/osu.Desktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@
<HintPath>$(SolutionDir)\packages\DeltaCompressionDotNet.1.1.0\lib\net20\DeltaCompressionDotNet.PatchApi.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="ICSharpCode.SharpZipLib, Version=0.86.0.518, Culture=neutral, processorArchitecture=MSIL">
<HintPath>$(SolutionDir)\packages\squirrel.windows.1.5.2\lib\Net45\ICSharpCode.SharpZipLib.dll</HintPath>
<Reference Include="ICSharpCode.SharpZipLib, Version=0.86.0.518, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
<HintPath>..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Mono.Cecil, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
Expand Down
1 change: 1 addition & 0 deletions osu.Desktop/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/maste
<package id="DeltaCompressionDotNet" version="1.1.0" targetFramework="net45" />
<package id="Microsoft.Net.Http" version="2.2.29" targetFramework="net45" />
<package id="Mono.Cecil" version="0.9.6.4" targetFramework="net45" />
<package id="SharpZipLib" version="0.86.0" targetFramework="net45" />
<package id="Splat" version="2.0.0" targetFramework="net45" />
<package id="squirrel.windows" version="1.5.2" targetFramework="net45" />
</packages>
7 changes: 6 additions & 1 deletion osu.Game.Modes.Catch/CatchRuleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE

using System.Collections.Generic;
using osu.Framework.Input;
using osu.Game.Graphics;
using osu.Game.Modes.Catch.UI;
using osu.Game.Modes.Objects;
Expand All @@ -15,7 +16,11 @@ public class CatchRuleset : Ruleset
{
public override ScoreOverlay CreateScoreOverlay() => new OsuScoreOverlay();

public override HitRenderer CreateHitRendererWith(Beatmap beatmap) => new CatchHitRenderer { Beatmap = beatmap };
public override HitRenderer CreateHitRendererWith(Beatmap beatmap, InputManager input = null) => new CatchHitRenderer
{
Beatmap = beatmap,
InputManager = input,
};

public override IEnumerable<Mod> GetModsFor(ModType type)
{
Expand Down
7 changes: 6 additions & 1 deletion osu.Game.Modes.Mania/ManiaRuleset.cs
Original file line number Diff line number Diff line change
@@ -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.Input;
using System.Collections.Generic;
using osu.Game.Graphics;
using osu.Game.Modes.Mania.UI;
Expand All @@ -15,7 +16,11 @@ public class ManiaRuleset : Ruleset
{
public override ScoreOverlay CreateScoreOverlay() => new OsuScoreOverlay();

public override HitRenderer CreateHitRendererWith(Beatmap beatmap) => new ManiaHitRenderer { Beatmap = beatmap };
public override HitRenderer CreateHitRendererWith(Beatmap beatmap, InputManager input = null) => new ManiaHitRenderer
{
Beatmap = beatmap,
InputManager = input,
};

public override IEnumerable<Mod> GetModsFor(ModType type)
{
Expand Down
19 changes: 11 additions & 8 deletions osu.Game.Modes.Osu/Objects/Drawables/DrawableHitCircle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,18 @@ public DrawableHitCircle(OsuHitObject h) : base(h)
Size = circle.DrawSize;
}

double hit50 = 150;
double hit100 = 80;
double hit300 = 30;
//todo: these aren't constants.

This comment was marked as off-topic.

public const double HITTABLE_RANGE = 300;
public const double HIT_WINDOW_50 = 150;
public const double HIT_WINDOW_100 = 80;
public const double HIT_WINDOW_300 = 30;
public const double CIRCLE_RADIUS = 64;

protected override void CheckJudgement(bool userTriggered)
{
if (!userTriggered)
{
if (Judgement.TimeOffset > hit50)
if (Judgement.TimeOffset > HIT_WINDOW_50)
Judgement.Result = HitResult.Miss;
return;
}
Expand All @@ -86,15 +89,15 @@ protected override void CheckJudgement(bool userTriggered)

OsuJudgementInfo osuJudgement = Judgement as OsuJudgementInfo;

if (hitOffset < hit50)
if (hitOffset < HIT_WINDOW_50)
{
Judgement.Result = HitResult.Hit;

if (hitOffset < hit300)
if (hitOffset < HIT_WINDOW_300)
osuJudgement.Score = OsuScoreResult.Hit300;
else if (hitOffset < hit100)
else if (hitOffset < HIT_WINDOW_100)
osuJudgement.Score = OsuScoreResult.Hit100;
else if (hitOffset < hit50)
else if (hitOffset < HIT_WINDOW_50)
osuJudgement.Score = OsuScoreResult.Hit50;
}
else
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Modes.Osu/Objects/Drawables/Pieces/CirclePiece.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class CirclePiece : Container

public CirclePiece()
{
Size = new Vector2(128);
Size = new Vector2((float)DrawableHitCircle.CIRCLE_RADIUS * 2);

This comment was marked as off-topic.

Masking = true;
CornerRadius = Size.X / 2;

Expand Down
Loading