1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 00:42:55 +08:00

Merge branch 'master' into leaderboards

This commit is contained in:
Seth 2017-03-14 10:07:33 -03:00 committed by GitHub
commit 21a9996225
72 changed files with 370 additions and 554 deletions

@ -1 +1 @@
Subproject commit a50dd75b114da963c75e6a5314099d99140035b8
Subproject commit 4834d27107198b9dc2f0e073be484cf0b92e0416

@ -1 +1 @@
Subproject commit 39657fc6066ea3a141ac71cabf67ec9ebf24975c
Subproject commit 4f9ed4e703777ede98737c7e2af31efa4694c395

View File

@ -21,16 +21,4 @@ Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/maste
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="DeltaCompressionDotNet.MsDelta" publicKeyToken="46b2138a390abf55" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@ -198,7 +198,7 @@ namespace osu.Desktop.Deploy
write($"- Creating release {version}...", ConsoleColor.Yellow);
var req = new JsonWebRequest<GitHubRelease>($"{GitHubApiEndpoint}")
{
Method = HttpMethod.POST
Method = HttpMethod.POST,
};
req.AddRaw(JsonConvert.SerializeObject(new GitHubRelease
{
@ -215,6 +215,7 @@ namespace osu.Desktop.Deploy
var upload = new WebRequest(assetUploadUrl, Path.GetFileName(a))
{
Method = HttpMethod.POST,
Timeout = 240000,
ContentType = "application/octet-stream",
};
@ -261,7 +262,7 @@ namespace osu.Desktop.Deploy
if (!File.Exists(Path.Combine(ReleasesFolder, nupkgDistroFilename(lastRelease.Name))))
{
write("Last verion's package not found locally.", ConsoleColor.Red);
write("Last version's package not found locally.", ConsoleColor.Red);
requireDownload = true;
}
else
@ -282,6 +283,8 @@ namespace osu.Desktop.Deploy
foreach (var a in assets)
{
if (a.Name.EndsWith(".exe")) continue;
write($"- Downloading {a.Name}...", ConsoleColor.Yellow);
new FileWebRequest(Path.Combine(ReleasesFolder, a.Name), $"{GitHubApiEndpoint}/assets/{a.Id}").AuthenticatedBlockingPerform();
}
@ -337,6 +340,7 @@ namespace osu.Desktop.Deploy
WorkingDirectory = solutionPath,
CreateNoWindow = true,
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
WindowStyle = ProcessWindowStyle.Hidden
};
@ -345,6 +349,7 @@ namespace osu.Desktop.Deploy
if (p == null) return false;
string output = p.StandardOutput.ReadToEnd();
output += p.StandardError.ReadToEnd();
if (p.ExitCode == 0) return true;

View File

@ -104,7 +104,9 @@
<None Include="..\osu.licenseheader">
<Link>osu.licenseheader</Link>
</None>
<None Include="App.config" />
<None Include="App.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>

View File

@ -1,16 +0,0 @@
<?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
-->
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@ -100,7 +100,6 @@
<None Include="..\osu.licenseheader">
<Link>osu.licenseheader</Link>
</None>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>

View File

@ -8,6 +8,8 @@ using osu.Framework.MathUtils;
using osu.Framework.Screens.Testing;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.IO;
using osu.Game.Database;
using osu.Game.Modes.Catch.UI;
using osu.Game.Modes.Mania.UI;
using osu.Game.Modes.Objects;
@ -41,10 +43,19 @@ namespace osu.Desktop.VisualTests.Tests
time += RNG.Next(50, 500);
}
Beatmap beatmap = new Beatmap
WorkingBeatmap beatmap = new TestWorkingBeatmap(new Beatmap
{
HitObjects = objects
};
HitObjects = objects,
BeatmapInfo = new BeatmapInfo
{
Metadata = new BeatmapMetadata
{
Artist = @"Unknown",
Title = @"Sample Beatmap",
Author = @"peppy",
}
}
});
Add(new Drawable[]
{
@ -83,5 +94,16 @@ namespace osu.Desktop.VisualTests.Tests
}
});
}
private class TestWorkingBeatmap : WorkingBeatmap
{
public TestWorkingBeatmap(Beatmap beatmap)
: base(beatmap.BeatmapInfo, beatmap.BeatmapInfo.BeatmapSet)
{
Beatmap = beatmap;
}
protected override ArchiveReader GetReader() => null;
}
}
}

View File

@ -110,7 +110,7 @@ namespace osu.Desktop.VisualTests.Tests
Beatmap = beatmap;
}
protected override BeatmapArchiveReader GetReader() => null;
protected override ArchiveReader GetReader() => null;
}
}
}

View File

@ -1,12 +1,13 @@
// 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 osu.Framework.Input.Handlers;
using osu.Game.Beatmaps;
using osu.Game.Modes;
using osu.Game.Modes.Mods;
using osu.Game.Modes.Osu.Mods;
using osu.Game.Screens.Play;
using System;
using System.IO;
namespace osu.Desktop.VisualTests.Tests
{
@ -22,9 +23,9 @@ namespace osu.Desktop.VisualTests.Tests
protected override Player CreatePlayer(WorkingBeatmap beatmap)
{
var player = base.CreatePlayer(beatmap);
player.ReplayInputHandler = Ruleset.GetRuleset(beatmap.PlayMode).CreateAutoplayScore(beatmap.Beatmap)?.Replay?.GetInputHandler();
return player;
beatmap.Mods.Value = new Mod[] { new OsuModAutoplay() };
return base.CreatePlayer(beatmap);
}
}
}

View File

@ -1,16 +0,0 @@
<?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
-->
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@ -23,6 +23,7 @@
<SignAssembly>false</SignAssembly>
<TargetZone>LocalIntranet</TargetZone>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
@ -114,7 +115,6 @@
<None Include="..\osu.licenseheader">
<Link>osu.licenseheader</Link>
</None>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="OpenTK.dll.config" />
</ItemGroup>

View File

@ -13,7 +13,7 @@ namespace osu.Desktop.Beatmaps.IO
/// <summary>
/// Reads an extracted legacy beatmap from disk.
/// </summary>
public class LegacyFilesystemReader : BeatmapArchiveReader
public class LegacyFilesystemReader : ArchiveReader
{
public static void Register() => AddReader<LegacyFilesystemReader>((storage, path) => Directory.Exists(path));

View File

@ -12,7 +12,6 @@ using System.Drawing;
using System.IO;
using System.Threading.Tasks;
using osu.Game.Screens.Menu;
using osu.Game.Beatmaps.IO;
namespace osu.Desktop
{
@ -31,9 +30,9 @@ namespace osu.Desktop
base.LoadComplete();
versionManager.LoadAsync(this);
ModeChanged += m =>
ScreenChanged += s =>
{
if (!versionManager.IsAlive && m is Intro)
if (!versionManager.IsAlive && s is Intro)
Add(versionManager);
};
}
@ -58,7 +57,7 @@ namespace osu.Desktop
var dropData = (object[])e.Data.GetData(DataFormats.FileDrop);
var filePaths = dropData.Select(f => f.ToString()).ToArray();
if (filePaths.All(f => Path.GetExtension(f) == BeatmapArchiveReader.OSZ_EXTENSION))
if (filePaths.All(f => Path.GetExtension(f) == @".osz"))
Task.Run(() => BeatmapDatabase.Import(filePaths));
else if (filePaths.All(f => Path.GetExtension(f) == @".osr"))
Task.Run(() =>
@ -68,7 +67,7 @@ namespace osu.Desktop
});
}
private static readonly string[] allowed_extensions = { BeatmapArchiveReader.OSZ_EXTENSION, @".osr" };
private static readonly string[] allowed_extensions = { @".osz", @".osr" };
private void dragEnter(DragEventArgs e)
{

View File

@ -1,20 +0,0 @@
<?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
-->
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="DeltaCompressionDotNet.MsDelta" publicKeyToken="46b2138a390abf55" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@ -23,6 +23,7 @@
<SignAssembly>false</SignAssembly>
<TargetZone>LocalIntranet</TargetZone>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
@ -153,7 +154,6 @@
<None Include="..\osu.licenseheader">
<Link>osu.licenseheader</Link>
</None>
<None Include="app.config" />
<None Include="osu!.res" />
<None Include="packages.config" />
<None Include="Properties\app.manifest" />

View File

@ -4,7 +4,9 @@
using OpenTK.Input;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Modes.Catch.Mods;
using osu.Game.Modes.Catch.UI;
using osu.Game.Modes.Mods;
using osu.Game.Modes.Objects;
using osu.Game.Modes.UI;
using osu.Game.Screens.Play;
@ -14,7 +16,7 @@ namespace osu.Game.Modes.Catch
{
public class CatchRuleset : Ruleset
{
public override HitRenderer CreateHitRendererWith(Beatmap beatmap) => new CatchHitRenderer(beatmap);
public override HitRenderer CreateHitRendererWith(WorkingBeatmap beatmap) => new CatchHitRenderer(beatmap);
public override IEnumerable<Mod> GetModsFor(ModType type)
{

View File

@ -1,7 +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
namespace osu.Game.Modes.Catch
using osu.Game.Modes.Mods;
namespace osu.Game.Modes.Catch.Mods
{
public class CatchModNoFail : ModNoFail
{

View File

@ -1,40 +0,0 @@
// 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 osu.Game.Modes.Objects;
using osu.Game.Modes.Osu.Objects;
using osu.Game.Beatmaps;
namespace osu.Game.Modes.Catch.Objects
{
internal class CatchConverter : HitObjectConverter<CatchBaseHit>
{
public override List<CatchBaseHit> Convert(Beatmap beatmap)
{
List<CatchBaseHit> output = new List<CatchBaseHit>();
foreach (HitObject i in beatmap.HitObjects)
{
CatchBaseHit h = i as CatchBaseHit;
if (h == null)
{
OsuHitObject o = i as OsuHitObject;
if (o == null) throw new HitObjectConvertException(@"Catch", i);
h = new Fruit
{
StartTime = o.StartTime,
Position = o.Position.X,
};
}
output.Add(h);
}
return output;
}
}
}

View File

@ -11,7 +11,7 @@ namespace osu.Game.Modes.Catch.UI
{
public class CatchHitRenderer : HitRenderer<CatchBaseHit>
{
public CatchHitRenderer(Beatmap beatmap)
public CatchHitRenderer(WorkingBeatmap beatmap)
: base(beatmap)
{
}

View File

@ -50,7 +50,6 @@
<Compile Include="Beatmaps\CatchBeatmapConverter.cs" />
<Compile Include="CatchDifficultyCalculator.cs" />
<Compile Include="Objects\CatchBaseHit.cs" />
<Compile Include="Objects\CatchConverter.cs" />
<Compile Include="Objects\Drawable\DrawableFruit.cs" />
<Compile Include="Objects\Droplet.cs" />
<Compile Include="Objects\Fruit.cs" />
@ -58,7 +57,7 @@
<Compile Include="UI\CatchHitRenderer.cs" />
<Compile Include="UI\CatchPlayfield.cs" />
<Compile Include="CatchRuleset.cs" />
<Compile Include="CatchMod.cs" />
<Compile Include="Mods\CatchMod.cs" />
</ItemGroup>
<ItemGroup>
<None Include="..\osu.licenseheader">

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;
using osu.Game.Modes.Mania.Objects;
using System.Collections.Generic;

View File

@ -3,7 +3,9 @@
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Modes.Mania.Mods;
using osu.Game.Modes.Mania.UI;
using osu.Game.Modes.Mods;
using osu.Game.Modes.Objects;
using osu.Game.Modes.UI;
using osu.Game.Screens.Play;
@ -13,7 +15,7 @@ namespace osu.Game.Modes.Mania
{
public class ManiaRuleset : Ruleset
{
public override HitRenderer CreateHitRendererWith(Beatmap beatmap) => new ManiaHitRenderer(beatmap);
public override HitRenderer CreateHitRendererWith(WorkingBeatmap beatmap) => new ManiaHitRenderer(beatmap);
public override IEnumerable<Mod> GetModsFor(ModType type)
{

View File

@ -1,10 +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.Game.Graphics;
using osu.Game.Modes.Mods;
using System;
namespace osu.Game.Modes.Mania
namespace osu.Game.Modes.Mania.Mods
{
public class ManiaModNoFail : ModNoFail
{

View File

@ -1,48 +0,0 @@
// 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 osu.Game.Modes.Objects;
using osu.Game.Modes.Osu.Objects;
using osu.Game.Beatmaps;
namespace osu.Game.Modes.Mania.Objects
{
internal class ManiaConverter : HitObjectConverter<ManiaBaseHit>
{
private readonly int columns;
public ManiaConverter(int columns)
{
this.columns = columns;
}
public override List<ManiaBaseHit> Convert(Beatmap beatmap)
{
List<ManiaBaseHit> output = new List<ManiaBaseHit>();
foreach (HitObject i in beatmap.HitObjects)
{
ManiaBaseHit h = i as ManiaBaseHit;
if (h == null)
{
OsuHitObject o = i as OsuHitObject;
if (o == null) throw new HitObjectConvertException(@"Mania", i);
h = new Note
{
StartTime = o.StartTime,
Column = (int)Math.Round(o.Position.X / 512 * columns)
};
}
output.Add(h);
}
return output;
}
}
}

View File

@ -13,7 +13,7 @@ namespace osu.Game.Modes.Mania.UI
{
private readonly int columns;
public ManiaHitRenderer(Beatmap beatmap, int columns = 5)
public ManiaHitRenderer(WorkingBeatmap beatmap, int columns = 5)
: base(beatmap)
{
this.columns = columns;

View File

@ -1,16 +0,0 @@
<?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
-->
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@ -52,13 +52,12 @@
<Compile Include="Objects\Drawable\DrawableNote.cs" />
<Compile Include="Objects\HoldNote.cs" />
<Compile Include="Objects\ManiaBaseHit.cs" />
<Compile Include="Objects\ManiaConverter.cs" />
<Compile Include="Objects\Note.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UI\ManiaHitRenderer.cs" />
<Compile Include="UI\ManiaPlayfield.cs" />
<Compile Include="ManiaRuleset.cs" />
<Compile Include="ManiaMod.cs" />
<Compile Include="Mods\ManiaMod.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\osu-framework\osu.Framework\osu.Framework.csproj">
@ -82,7 +81,6 @@
<None Include="..\osu.licenseheader">
<Link>osu.licenseheader</Link>
</None>
<None Include="app.config" />
<None Include="OpenTK.dll.config" />
<None Include="packages.config" />
</ItemGroup>

View File

@ -1,11 +1,14 @@
// 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;
using osu.Game.Graphics;
using osu.Game.Modes.Mods;
using osu.Game.Modes.Osu.Objects;
using System;
using System.Linq;
using osu.Game.Graphics;
namespace osu.Game.Modes.Osu
namespace osu.Game.Modes.Osu.Mods
{
public class OsuModNoFail : ModNoFail
{
@ -85,9 +88,14 @@ namespace osu.Game.Modes.Osu
public override Type[] IncompatibleMods => new[] { typeof(OsuModSpunOut), typeof(ModRelax), typeof(ModSuddenDeath), typeof(ModNoFail), typeof(ModAutoplay) };
}
public class OsuModAutoplay : ModAutoplay
public class OsuModAutoplay : ModAutoplay<OsuHitObject>
{
public override Type[] IncompatibleMods => base.IncompatibleMods.Concat(new[] { typeof(OsuModAutopilot) }).ToArray();
protected override Score CreateReplayScore(Beatmap<OsuHitObject> beatmap) => new Score
{
Replay = new OsuAutoReplay(beatmap)
};
}
public class OsuModTarget : Mod

View File

@ -1,14 +1,14 @@
// 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 OpenTK;
using osu.Framework.Graphics.Transforms;
using osu.Framework.MathUtils;
using osu.Game.Beatmaps;
using osu.Game.Modes.Osu.Objects;
using OpenTK;
using System;
using osu.Framework.Graphics.Transforms;
using osu.Game.Modes.Osu.Objects.Drawables;
using osu.Framework.MathUtils;
using System;
using System.Collections.Generic;
using System.Diagnostics;
namespace osu.Game.Modes.Osu
@ -19,9 +19,9 @@ namespace osu.Game.Modes.Osu
private const float spin_radius = 50;
private Beatmap beatmap;
private Beatmap<OsuHitObject> beatmap;
public OsuAutoReplay(Beatmap beatmap)
public OsuAutoReplay(Beatmap<OsuHitObject> beatmap)
{
this.beatmap = beatmap;
@ -86,7 +86,7 @@ namespace osu.Game.Modes.Osu
for (int i = 0; i < beatmap.HitObjects.Count; i++)
{
OsuHitObject h = (OsuHitObject)beatmap.HitObjects[i];
OsuHitObject h = beatmap.HitObjects[i];
//if (h.EndTime < InputManager.ReplayStartTime)
//{
@ -98,7 +98,7 @@ namespace osu.Game.Modes.Osu
if (DelayedMovements && i > 0)
{
OsuHitObject last = (OsuHitObject)beatmap.HitObjects[i - 1];
OsuHitObject last = beatmap.HitObjects[i - 1];
//Make the cursor stay at a hitObject as long as possible (mainly for autopilot).
if (h.StartTime - h.HitWindowFor(OsuScoreResult.Miss) > last.EndTime + h.HitWindowFor(OsuScoreResult.Hit50) + 50)

View File

@ -0,0 +1,56 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Input;
using osu.Game.Configuration;
using osu.Game.Screens.Play;
using OpenTK.Input;
using KeyboardState = osu.Framework.Input.KeyboardState;
using MouseState = osu.Framework.Input.MouseState;
namespace osu.Game.Modes.Osu
{
public class OsuKeyConversionInputManager : KeyConversionInputManager
{
private bool leftViaKeyboard;
private bool rightViaKeyboard;
private Bindable<bool> mouseDisabled;
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
mouseDisabled = config.GetBindable<bool>(OsuConfig.MouseDisableButtons);
}
protected override void TransformState(InputState state)
{
base.TransformState(state);
var mouse = state.Mouse as MouseState;
var keyboard = state.Keyboard as KeyboardState;
if (keyboard != null)
{
leftViaKeyboard = keyboard.Keys.Contains(Key.Z);
rightViaKeyboard = keyboard.Keys.Contains(Key.X);
}
if (mouse != null)
{
if (mouseDisabled.Value)
{
mouse.PressedButtons.Remove(MouseButton.Left);
mouse.PressedButtons.Remove(MouseButton.Right);
}
if (leftViaKeyboard)
mouse.PressedButtons.Add(MouseButton.Left);
if (rightViaKeyboard)
mouse.PressedButtons.Add(MouseButton.Right);
}
}
}
}

View File

@ -4,7 +4,9 @@
using OpenTK.Input;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Modes.Mods;
using osu.Game.Modes.Objects;
using osu.Game.Modes.Osu.Mods;
using osu.Game.Modes.Osu.Objects;
using osu.Game.Modes.Osu.UI;
using osu.Game.Modes.UI;
@ -16,7 +18,7 @@ namespace osu.Game.Modes.Osu
{
public class OsuRuleset : Ruleset
{
public override HitRenderer CreateHitRendererWith(Beatmap beatmap) => new OsuHitRenderer(beatmap);
public override HitRenderer CreateHitRendererWith(WorkingBeatmap beatmap) => new OsuHitRenderer(beatmap);
public override IEnumerable<BeatmapStatistic> GetBeatmapStatistics(WorkingBeatmap beatmap) => new[]
{
@ -100,13 +102,6 @@ namespace osu.Game.Modes.Osu
public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap) => new OsuDifficultyCalculator(beatmap);
public override Score CreateAutoplayScore(Beatmap beatmap)
{
var score = CreateScoreProcessor().GetScore();
score.Replay = new OsuAutoReplay(beatmap);
return score;
}
protected override PlayMode PlayMode => PlayMode.Osu;
public override string Description => "osu!";

View File

@ -7,12 +7,13 @@ using osu.Game.Modes.Osu.Beatmaps;
using osu.Game.Modes.Osu.Objects;
using osu.Game.Modes.Osu.Objects.Drawables;
using osu.Game.Modes.UI;
using osu.Game.Screens.Play;
namespace osu.Game.Modes.Osu.UI
{
public class OsuHitRenderer : HitRenderer<OsuHitObject>
{
public OsuHitRenderer(Beatmap beatmap)
public OsuHitRenderer(WorkingBeatmap beatmap)
: base(beatmap)
{
}
@ -21,6 +22,8 @@ namespace osu.Game.Modes.Osu.UI
protected override Playfield<OsuHitObject> CreatePlayfield() => new OsuPlayfield();
protected override KeyConversionInputManager CreateKeyConversionInputManager() => new OsuKeyConversionInputManager();
protected override DrawableHitObject<OsuHitObject> GetVisualRepresentation(OsuHitObject h)
{
var circle = h as HitCircle;

View File

@ -1,16 +0,0 @@
<?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
-->
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /></startup></configuration>

View File

@ -73,6 +73,7 @@
<Compile Include="Objects\SliderTick.cs" />
<Compile Include="OsuAutoReplay.cs" />
<Compile Include="OsuDifficultyCalculator.cs" />
<Compile Include="OsuKeyConversionInputManager.cs" />
<Compile Include="OsuScore.cs" />
<Compile Include="OsuScoreProcessor.cs" />
<Compile Include="UI\OsuHitRenderer.cs" />
@ -84,7 +85,7 @@
<Compile Include="Objects\Slider.cs" />
<Compile Include="Objects\Spinner.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="OsuMod.cs" />
<Compile Include="Mods\OsuMod.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\osu-framework\osu.Framework\osu.Framework.csproj">
@ -100,7 +101,6 @@
<None Include="..\osu.licenseheader">
<Link>osu.licenseheader</Link>
</None>
<None Include="app.config" />
<None Include="OpenTK.dll.config" />
<None Include="packages.config" />
</ItemGroup>

View File

@ -1,7 +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
namespace osu.Game.Modes.Taiko
using osu.Game.Modes.Mods;
namespace osu.Game.Modes.Taiko.Mods
{
public class TaikoModNoFail : ModNoFail
{

View File

@ -1,39 +0,0 @@
// 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 osu.Game.Modes.Objects;
using osu.Game.Modes.Osu.Objects;
using osu.Game.Beatmaps;
namespace osu.Game.Modes.Taiko.Objects
{
internal class TaikoConverter : HitObjectConverter<TaikoBaseHit>
{
public override List<TaikoBaseHit> Convert(Beatmap beatmap)
{
List<TaikoBaseHit> output = new List<TaikoBaseHit>();
foreach (HitObject i in beatmap.HitObjects)
{
TaikoBaseHit h = i as TaikoBaseHit;
if (h == null)
{
OsuHitObject o = i as OsuHitObject;
if (o == null) throw new HitObjectConvertException(@"Taiko", i);
h = new TaikoBaseHit
{
StartTime = o.StartTime,
};
}
output.Add(h);
}
return output;
}
}
}

View File

@ -4,7 +4,9 @@
using OpenTK.Input;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Modes.Mods;
using osu.Game.Modes.Objects;
using osu.Game.Modes.Taiko.Mods;
using osu.Game.Modes.Taiko.UI;
using osu.Game.Modes.UI;
using osu.Game.Screens.Play;
@ -14,7 +16,7 @@ namespace osu.Game.Modes.Taiko
{
public class TaikoRuleset : Ruleset
{
public override HitRenderer CreateHitRendererWith(Beatmap beatmap) => new TaikoHitRenderer(beatmap);
public override HitRenderer CreateHitRendererWith(WorkingBeatmap beatmap) => new TaikoHitRenderer(beatmap);
public override IEnumerable<Mod> GetModsFor(ModType type)
{

View File

@ -11,7 +11,7 @@ namespace osu.Game.Modes.Taiko.UI
{
public class TaikoHitRenderer : HitRenderer<TaikoBaseHit>
{
public TaikoHitRenderer(Beatmap beatmap)
public TaikoHitRenderer(WorkingBeatmap beatmap)
: base(beatmap)
{
}

View File

@ -51,12 +51,11 @@
<Compile Include="TaikoDifficultyCalculator.cs" />
<Compile Include="Objects\Drawable\DrawableTaikoHit.cs" />
<Compile Include="Objects\TaikoBaseHit.cs" />
<Compile Include="Objects\TaikoConverter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UI\TaikoHitRenderer.cs" />
<Compile Include="UI\TaikoPlayfield.cs" />
<Compile Include="TaikoRuleset.cs" />
<Compile Include="TaikoMod.cs" />
<Compile Include="Mods\TaikoMod.cs" />
</ItemGroup>
<ItemGroup>
<None Include="..\osu.licenseheader">

View File

@ -17,7 +17,6 @@ using osu.Game.Modes.Catch;
using osu.Game.Modes.Mania;
using osu.Game.Modes.Osu;
using osu.Game.Modes.Taiko;
using osu.Game.Beatmaps.IO;
namespace osu.Game.Tests.Beatmaps.IO
{
@ -107,7 +106,7 @@ namespace osu.Game.Tests.Beatmaps.IO
private string prepareTempCopy(string path)
{
var temp = Path.GetTempPath() + Guid.NewGuid() + BeatmapArchiveReader.OSZ_EXTENSION;
var temp = Path.GetTempFileName();
return new FileInfo(path).CopyTo(temp, true).FullName;
}

View File

@ -1,16 +0,0 @@
<?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
-->
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@ -52,7 +52,6 @@
<None Include="..\osu.licenseheader">
<Link>osu.licenseheader</Link>
</None>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="OpenTK.dll.config" />
</ItemGroup>

View File

@ -6,22 +6,23 @@ using System.Collections.Generic;
using System.IO;
using osu.Framework.IO.Stores;
using osu.Framework.Platform;
using osu.Game.Database;
namespace osu.Game.IO
namespace osu.Game.Beatmaps.IO
{
public abstract class ArchiveReader : IDisposable, IResourceStore<byte[]>
{
protected class Reader
private class Reader
{
public Func<Storage, string, bool> Test { get; set; }
public Type Type { get; set; }
}
protected static List<Reader> Readers { get; } = new List<Reader>();
private static List<Reader> readers { get; } = new List<Reader>();
public static ArchiveReader GetReader(Storage storage, string path)
{
foreach (var reader in Readers)
foreach (var reader in readers)
{
if (reader.Test(storage, path))
return (ArchiveReader)Activator.CreateInstance(reader.Type, storage.GetStream(path));
@ -31,9 +32,24 @@ namespace osu.Game.IO
protected static void AddReader<T>(Func<Storage, string, bool> test) where T : ArchiveReader
{
Readers.Add(new Reader { Test = test, Type = typeof(T) });
readers.Add(new Reader { Test = test, Type = typeof(T) });
}
/// <summary>
/// Reads the beatmap metadata from this archive.
/// </summary>
public abstract BeatmapMetadata ReadMetadata();
/// <summary>
/// Gets a list of beatmap file names.
/// </summary>
public string[] BeatmapFilenames { get; protected set; }
/// <summary>
/// The storyboard filename. Null if no storyboard is present.
/// </summary>
public string StoryboardFilename { get; protected set; }
/// <summary>
/// Opens a stream for reading a specific file from this archive.
/// </summary>

View File

@ -1,44 +0,0 @@
// 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.Logging;
using osu.Framework.Platform;
using osu.Game.Database;
using osu.Game.IO;
namespace osu.Game.Beatmaps.IO
{
public abstract class BeatmapArchiveReader : ArchiveReader
{
public const string OSZ_EXTENSION = @".osz";
public static BeatmapArchiveReader GetBeatmapArchiveReader(Storage storage, string path)
{
try
{
return (BeatmapArchiveReader)GetReader(storage, path);
}
catch (InvalidCastException e)
{
Logger.Error(e, "A tricky " + $@"{nameof(ArchiveReader)}" + " instance passed the test to be a " + $@"{nameof(BeatmapArchiveReader)}" + ", but it's really not");
throw;
}
}
/// <summary>
/// Reads the beatmap metadata from this archive.
/// </summary>
public abstract BeatmapMetadata ReadMetadata();
/// <summary>
/// Gets a list of beatmap file names.
/// </summary>
public string[] BeatmapFilenames { get; protected set; }
/// <summary>
/// The storyboard filename. Null if no storyboard is present.
/// </summary>
public string StoryboardFilename { get; protected set; }
}
}

View File

@ -9,14 +9,14 @@ using osu.Game.Database;
namespace osu.Game.Beatmaps.IO
{
public sealed class OszArchiveReader : BeatmapArchiveReader
public sealed class OszArchiveReader : ArchiveReader
{
public static void Register()
{
AddReader<OszArchiveReader>((storage, path) =>
{
using (var stream = storage.GetStream(path))
return Path.GetExtension(path) == OSZ_EXTENSION && ZipFile.IsZipFile(stream, false);
return ZipFile.IsZipFile(stream, false);
});
OsuLegacyDecoder.Register();
}

View File

@ -1,9 +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.IO;
using osu.Framework.Audio.Track;
using osu.Framework.Configuration;
using osu.Framework.Graphics.Textures;
@ -11,6 +8,10 @@ using osu.Game.Beatmaps.Formats;
using osu.Game.Beatmaps.IO;
using osu.Game.Database;
using osu.Game.Modes;
using osu.Game.Modes.Mods;
using System;
using System.Collections.Generic;
using System.IO;
namespace osu.Game.Beatmaps
{
@ -32,7 +33,7 @@ namespace osu.Game.Beatmaps
public readonly bool WithStoryboard;
protected abstract BeatmapArchiveReader GetReader();
protected abstract ArchiveReader GetReader();
protected WorkingBeatmap(BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo, bool withStoryboard = false)
{
@ -100,7 +101,7 @@ namespace osu.Game.Beatmaps
set { lock (beatmapLock) beatmap = value; }
}
private BeatmapArchiveReader trackReader;
private ArchiveReader trackReader;
private Track track;
private object trackLock = new object();
public Track Track

View File

@ -177,7 +177,7 @@ namespace osu.Game.Database
BeatmapMetadata metadata;
using (var reader = BeatmapArchiveReader.GetBeatmapArchiveReader(storage, path))
using (var reader = ArchiveReader.GetReader(storage, path))
metadata = reader.ReadMetadata();
if (File.Exists(path)) // Not always the case, i.e. for LegacyFilesystemReader
@ -186,7 +186,7 @@ namespace osu.Game.Database
{
hash = input.GetMd5Hash();
input.Seek(0, SeekOrigin.Begin);
path = Path.Combine(@"beatmaps", hash.Remove(1), hash.Remove(2), hash + BeatmapArchiveReader.OSZ_EXTENSION);
path = Path.Combine(@"beatmaps", hash.Remove(1), hash.Remove(2), hash);
if (!storage.Exists(path))
using (var output = storage.GetStream(path, FileAccess.Write))
input.CopyTo(output);
@ -216,7 +216,7 @@ namespace osu.Game.Database
Metadata = metadata
};
using (var archive = BeatmapArchiveReader.GetBeatmapArchiveReader(storage, path))
using (var archive = ArchiveReader.GetReader(storage, path))
{
string[] mapNames = archive.BeatmapFilenames;
foreach (var name in mapNames)
@ -268,12 +268,12 @@ namespace osu.Game.Database
BeatmapSetRemoved?.Invoke(beatmapSet);
}
public BeatmapArchiveReader GetReader(BeatmapSetInfo beatmapSet)
public ArchiveReader GetReader(BeatmapSetInfo beatmapSet)
{
if (string.IsNullOrEmpty(beatmapSet.Path))
return null;
return BeatmapArchiveReader.GetBeatmapArchiveReader(storage, beatmapSet.Path);
return ArchiveReader.GetReader(storage, beatmapSet.Path);
}
public BeatmapSetInfo GetBeatmapSet(int id)
@ -354,7 +354,7 @@ namespace osu.Game.Database
this.database = database;
}
protected override BeatmapArchiveReader GetReader() => database?.GetReader(BeatmapSetInfo);
protected override ArchiveReader GetReader() => database?.GetReader(BeatmapSetInfo);
}
}
}

View File

@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Input;
using osu.Framework.MathUtils;
using osu.Game.Input.Handlers;
@ -95,24 +96,17 @@ namespace osu.Game.Modes
public override List<InputState> GetPendingStates()
{
var buttons = new HashSet<MouseButton>();
if (CurrentFrame?.MouseLeft ?? false)
buttons.Add(MouseButton.Left);
if (CurrentFrame?.MouseRight ?? false)
buttons.Add(MouseButton.Right);
return new List<InputState>
{
new InputState
{
Mouse = new ReplayMouseState(
ToScreenSpace(position ?? Vector2.Zero),
new List<MouseState.ButtonState>
{
new MouseState.ButtonState(MouseButton.Left)
{
State = CurrentFrame?.MouseLeft ?? false
},
new MouseState.ButtonState(MouseButton.Right)
{
State = CurrentFrame?.MouseRight ?? false
},
}
),
Mouse = new ReplayMouseState(ToScreenSpace(position ?? Vector2.Zero), buttons),
Keyboard = new ReplayKeyboardState(new List<Key>())
}
};
@ -171,10 +165,10 @@ namespace osu.Game.Modes
private class ReplayMouseState : MouseState
{
public ReplayMouseState(Vector2 position, List<ButtonState> list)
public ReplayMouseState(Vector2 position, IEnumerable<MouseButton> list)
{
Position = position;
ButtonStates = list;
list.ForEach(b => PressedButtons.Add(b));
}
}

View File

@ -0,0 +1,23 @@
// 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.Modes.Objects;
using osu.Game.Modes.UI;
namespace osu.Game.Modes.Mods
{
/// <summary>
/// An interface for mods that are applied to a HitRenderer.
/// </summary>
/// <typeparam name="TObject">The type of HitObject the HitRenderer contains.</typeparam>
public interface IApplicableMod<TObject>
where TObject : HitObject
{
/// <summary>
/// Applies the mod to a HitRenderer.
/// </summary>
/// <param name="hitRenderer">The HitRenderer to apply the mod to.</param>
void Apply(HitRenderer<TObject> hitRenderer);
}
}

View File

@ -1,11 +1,13 @@
// 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.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Screens.Play;
using osu.Game.Modes.Objects;
using osu.Game.Modes.UI;
using System;
namespace osu.Game.Modes
namespace osu.Game.Modes.Mods
{
/// <summary>
/// The base class for gameplay modifiers.
@ -41,12 +43,6 @@ namespace osu.Game.Modes
/// The mods this mod cannot be enabled with.
/// </summary>
public virtual Type[] IncompatibleMods => new Type[] { };
/// <summary>
/// Direct access to the Player before load has run.
/// </summary>
/// <param name="player"></param>
public virtual void PlayerLoading(Player player) { }
}
public class MultiMod : Mod
@ -151,11 +147,16 @@ namespace osu.Game.Modes
public override string Description => "Watch a perfect automated play through the song";
public override double ScoreMultiplier => 0;
public override Type[] IncompatibleMods => new[] { typeof(ModRelax), typeof(ModSuddenDeath), typeof(ModNoFail) };
}
public override void PlayerLoading(Player player)
public abstract class ModAutoplay<T> : ModAutoplay, IApplicableMod<T>
where T : HitObject
{
protected abstract Score CreateReplayScore(Beatmap<T> beatmap);
public void Apply(HitRenderer<T> hitRenderer)
{
base.PlayerLoading(player);
player.ReplayInputHandler = Ruleset.GetRuleset(player.Beatmap.PlayMode).CreateAutoplayScore(player.Beatmap.Beatmap)?.Replay?.GetInputHandler();
hitRenderer.InputManager.ReplayInputHandler = CreateReplayScore(hitRenderer.Beatmap)?.Replay?.GetInputHandler();
}
}
@ -170,11 +171,4 @@ namespace osu.Game.Modes
public override string Name => "Cinema";
public override FontAwesome Icon => FontAwesome.fa_osu_mod_cinema;
}
public enum ModType
{
DifficultyReduction,
DifficultyIncrease,
Special,
}
}

View File

@ -0,0 +1,12 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
namespace osu.Game.Modes.Mods
{
public enum ModType
{
DifficultyReduction,
DifficultyIncrease,
Special,
}
}

View File

@ -1,25 +0,0 @@
// 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;
using System;
using System.Collections.Generic;
namespace osu.Game.Modes.Objects
{
public abstract class HitObjectConverter<T>
where T : HitObject
{
public abstract List<T> Convert(Beatmap beatmap);
}
public class HitObjectConvertException : Exception
{
public HitObject Input { get; }
public HitObjectConvertException(string modeName, HitObject input)
: base($@"Can't convert from {input.GetType().Name} to {modeName} HitObject!")
{
Input = input;
}
}
}

View File

@ -3,6 +3,7 @@
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Modes.Mods;
using osu.Game.Modes.Objects;
using osu.Game.Modes.UI;
using osu.Game.Screens.Play;
@ -31,7 +32,7 @@ namespace osu.Game.Modes
public abstract ScoreProcessor CreateScoreProcessor(int hitObjectCount = 0);
public abstract HitRenderer CreateHitRendererWith(Beatmap beatmap);
public abstract HitRenderer CreateHitRendererWith(WorkingBeatmap beatmap);
public abstract HitObjectParser CreateHitObjectParser();
@ -47,8 +48,6 @@ namespace osu.Game.Modes
public abstract IEnumerable<KeyCounter> CreateGameplayKeys();
public virtual Score CreateAutoplayScore(Beatmap beatmap) => null;
public static Ruleset GetRuleset(PlayMode mode)
{
Type type;

View File

@ -1,11 +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 OpenTK;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps;
using osu.Game.Modes.Mods;
using osu.Game.Modes.Objects;
using osu.Game.Modes.Objects.Drawables;
using osu.Game.Screens.Play;
@ -22,10 +22,13 @@ namespace osu.Game.Modes.UI
internal readonly PlayerInputManager InputManager = new PlayerInputManager();
/// <summary>
/// A function to convert coordinates from gamefield to screen space.
/// </summary>
public abstract Func<Vector2, Vector2> MapPlayfieldToScreenSpace { get; }
protected readonly KeyConversionInputManager KeyConversionInputManager;
protected HitRenderer()
{
KeyConversionInputManager = CreateKeyConversionInputManager();
KeyConversionInputManager.RelativeSizeAxes = Axes.Both;
}
/// <summary>
/// Whether all the HitObjects have been judged.
@ -39,45 +42,48 @@ namespace osu.Game.Modes.UI
if (AllObjectsJudged)
OnAllJudged?.Invoke();
}
protected virtual KeyConversionInputManager CreateKeyConversionInputManager() => new KeyConversionInputManager();
}
public abstract class HitRenderer<TObject> : HitRenderer
where TObject : HitObject
{
public override Func<Vector2, Vector2> MapPlayfieldToScreenSpace => Playfield.ScaledContent.ToScreenSpace;
public IEnumerable<DrawableHitObject> DrawableObjects => Playfield.HitObjects.Children;
public Beatmap<TObject> Beatmap;
protected override Container<Drawable> Content => content;
protected override bool AllObjectsJudged => Playfield.HitObjects.Children.All(h => h.Judgement.Result.HasValue);
protected Playfield<TObject> Playfield;
protected Beatmap<TObject> Beatmap;
private Container content;
protected HitRenderer(Beatmap beatmap)
protected HitRenderer(WorkingBeatmap beatmap)
{
Beatmap = CreateBeatmapConverter().Convert(beatmap);
Beatmap = CreateBeatmapConverter().Convert(beatmap.Beatmap);
applyMods(beatmap.Mods.Value);
RelativeSizeAxes = Axes.Both;
KeyConversionInputManager.Add(Playfield = CreatePlayfield());
InputManager.Add(content = new Container
{
RelativeSizeAxes = Axes.Both,
Children = new[]
{
Playfield = CreatePlayfield(),
}
Children = new[] { KeyConversionInputManager }
});
AddInternal(InputManager);
}
[BackgroundDependencyLoader]
private void load()
{
loadObjects();
if (InputManager?.ReplayInputHandler != null)
InputManager.ReplayInputHandler.ToScreenSpace = Playfield.ScaledContent.ToScreenSpace;
}
private void loadObjects()
@ -97,6 +103,15 @@ namespace osu.Game.Modes.UI
Playfield.PostProcess();
}
private void applyMods(IEnumerable<Mod> mods)
{
if (mods == null)
return;
foreach (var mod in mods.OfType<IApplicableMod<TObject>>())
mod.Apply(this);
}
private void onJudgement(DrawableHitObject<TObject> o, JudgementInfo j) => TriggerOnJudgement(j);
protected abstract DrawableHitObject<TObject> GetVisualRepresentation(TObject h);

View File

@ -258,13 +258,13 @@ namespace osu.Game
return false;
}
public event Action<Screen> ModeChanged;
public event Action<Screen> ScreenChanged;
private Container mainContent;
private Container overlayContent;
private void modeChanged(Screen newScreen)
private void screenChanged(Screen newScreen)
{
//central game mode change logic.
if ((newScreen as OsuScreen)?.ShowOverlays != true)
@ -281,7 +281,7 @@ namespace osu.Game
if (newScreen is MainMenu)
Cursor.FadeIn(100);
ModeChanged?.Invoke(newScreen);
ScreenChanged?.Invoke(newScreen);
if (newScreen == null)
Exit();
@ -315,12 +315,12 @@ namespace osu.Game
newScreen.ModePushed += screenAdded;
newScreen.Exited += screenRemoved;
modeChanged(newScreen);
screenChanged(newScreen);
}
private void screenRemoved(Screen newScreen)
{
modeChanged(newScreen);
screenChanged(newScreen);
}
}
}

View File

@ -4,7 +4,7 @@
using OpenTK.Input;
using osu.Framework.Allocation;
using osu.Game.Graphics;
using osu.Game.Modes;
using osu.Game.Modes.Mods;
namespace osu.Game.Overlays.Mods
{

View File

@ -4,7 +4,7 @@
using OpenTK.Input;
using osu.Framework.Allocation;
using osu.Game.Graphics;
using osu.Game.Modes;
using osu.Game.Modes.Mods;
namespace osu.Game.Overlays.Mods
{

View File

@ -4,7 +4,7 @@
using OpenTK.Input;
using osu.Framework.Allocation;
using osu.Game.Graphics;
using osu.Game.Modes;
using osu.Game.Modes.Mods;
namespace osu.Game.Overlays.Mods
{

View File

@ -1,8 +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.Linq;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Input;
@ -15,8 +13,10 @@ using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transforms;
using osu.Framework.Input;
using osu.Game.Graphics.Sprites;
using osu.Game.Modes;
using osu.Game.Modes.Mods;
using osu.Game.Modes.UI;
using System;
using System.Linq;
namespace osu.Game.Overlays.Mods
{

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;
using OpenTK.Graphics;
using OpenTK.Input;
@ -10,7 +9,8 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Input;
using osu.Game.Graphics.Sprites;
using osu.Game.Modes;
using osu.Game.Modes.Mods;
using System;
namespace osu.Game.Overlays.Mods
{

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 System;
using System.Collections.Generic;
using System.Linq;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
@ -13,11 +11,14 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transforms;
using osu.Framework.Allocation;
using osu.Game.Graphics;
using osu.Game.Graphics.Backgrounds;
using osu.Game.Graphics.Sprites;
using osu.Game.Modes;
using osu.Game.Modes.Mods;
using System;
using System.Collections.Generic;
using System.Linq;
namespace osu.Game.Overlays.Mods
{

View File

@ -210,7 +210,7 @@ namespace osu.Game.Overlays
}
}
};
this.beatmaps = beatmaps;
trackManager = osuGame.Audio.Track;
preferUnicode = config.GetBindable<bool>(OsuConfig.ShowUnicode);
@ -247,6 +247,8 @@ namespace osu.Game.Overlays
if (current.Track.HasCompleted && !current.Track.Looping) next();
}
else
playButton.Icon = FontAwesome.fa_play_circle_o;
}
private void preferUnicode_changed(object sender, EventArgs e)
@ -337,12 +339,16 @@ namespace osu.Game.Overlays
Task.Run(() =>
{
if (beatmap?.Beatmap == null)
//todo: we may need to display some default text here (currently in the constructor).
return;
BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata;
title.Text = unicodeString(metadata.Title, metadata.TitleUnicode);
artist.Text = unicodeString(metadata.Artist, metadata.ArtistUnicode);
{
title.Text = @"Nothing to play";
artist.Text = @"Nothing to play";
}
else
{
BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata;
title.Text = unicodeString(metadata.Title, metadata.TitleUnicode);
artist.Text = unicodeString(metadata.Artist, metadata.ArtistUnicode);
}
});
MusicControllerBackground newBackground;

View File

@ -0,0 +1,16 @@
// 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;
namespace osu.Game.Screens.Play
{
/// <summary>
/// An InputManager primarily used to map keys to new functions.
/// By default this does nothing; override TransformState to make alterations.
/// </summary>
public class KeyConversionInputManager : PassThroughInputManager
{
}
}

View File

@ -10,11 +10,25 @@ namespace osu.Game.Screens.Play
public class KeyCounterMouse : KeyCounter
{
public MouseButton Button { get; }
public KeyCounterMouse(MouseButton button) : base(button.ToString())
public KeyCounterMouse(MouseButton button) : base(getStringRepresentation(button))
{
Button = button;
}
private static string getStringRepresentation(MouseButton button)
{
switch (button)
{
default:
return button.ToString();
case MouseButton.Left:
return @"M1";
case MouseButton.Right:
return @"M2";
}
}
public override bool Contains(Vector2 screenSpacePos) => true;
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)

View File

@ -7,7 +7,6 @@ using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Track;
using osu.Framework.Configuration;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Transforms;
@ -69,8 +68,6 @@ namespace osu.Game.Screens.Play
return;
}
Beatmap.Mods.Value.ForEach(m => m.PlayerLoading(this));
dimLevel = config.GetBindable<int>(OsuConfig.DimLevel);
mouseWheelDisabled = config.GetBindable<bool>(OsuConfig.MouseDisableWheel);
@ -128,13 +125,10 @@ namespace osu.Game.Screens.Play
OnQuit = Exit
};
hitRenderer = ruleset.CreateHitRendererWith(beatmap);
hitRenderer = ruleset.CreateHitRendererWith(Beatmap);
if (ReplayInputHandler != null)
{
ReplayInputHandler.ToScreenSpace = hitRenderer.MapPlayfieldToScreenSpace;
hitRenderer.InputManager.ReplayInputHandler = ReplayInputHandler;
}
hudOverlay.BindHitRenderer(hitRenderer);
@ -305,7 +299,8 @@ namespace osu.Game.Screens.Play
{
if (pauseOverlay == null) return false;
if (ReplayInputHandler != null) return false;
if (hitRenderer.InputManager.ReplayInputHandler != null)
return false;
if (pauseOverlay.State != Visibility.Visible && !canPause) return true;

View File

@ -1,25 +1,14 @@
// 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.Configuration;
using osu.Framework.Input;
using osu.Game.Configuration;
using System.Linq;
using osu.Framework.Timing;
using osu.Game.Input.Handlers;
using OpenTK.Input;
using KeyboardState = osu.Framework.Input.KeyboardState;
using MouseState = osu.Framework.Input.MouseState;
namespace osu.Game.Screens.Play
{
public class PlayerInputManager : PassThroughInputManager
{
private bool leftViaKeyboard;
private bool rightViaKeyboard;
private Bindable<bool> mouseDisabled;
private ManualClock clock = new ManualClock();
private IFrameBasedClock parentClock;
@ -47,40 +36,6 @@ namespace osu.Game.Screens.Play
Clock = new FramedClock(clock);
}
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
mouseDisabled = config.GetBindable<bool>(OsuConfig.MouseDisableButtons);
}
protected override void TransformState(InputState state)
{
base.TransformState(state);
var mouse = state.Mouse as MouseState;
var keyboard = state.Keyboard as KeyboardState;
if (keyboard != null)
{
leftViaKeyboard = keyboard.Keys.Contains(Key.Z);
rightViaKeyboard = keyboard.Keys.Contains(Key.X);
}
if (mouse != null)
{
if (mouseDisabled.Value)
{
mouse.ButtonStates.Find(s => s.Button == MouseButton.Left).State = false;
mouse.ButtonStates.Find(s => s.Button == MouseButton.Right).State = false;
}
if (leftViaKeyboard)
mouse.ButtonStates.Find(s => s.Button == MouseButton.Left).State = true;
if (rightViaKeyboard)
mouse.ButtonStates.Find(s => s.Button == MouseButton.Right).State = true;
}
}
protected override void Update()
{
base.Update();

View File

@ -16,7 +16,6 @@ using osu.Game.Database;
using osu.Framework.Graphics.Colour;
using osu.Game.Beatmaps.Drawables;
using System.Linq;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.MathUtils;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
@ -56,8 +55,15 @@ namespace osu.Game.Screens.Select
public void UpdateBeatmap(WorkingBeatmap beatmap)
{
if (beatmap?.BeatmapInfo == null)
{
FadeOut(250);
beatmapInfoContainer?.FadeOut(250);
beatmapInfoContainer?.Expire();
beatmapInfoContainer = null;
return;
}
FadeIn(250);
var lastContainer = beatmapInfoContainer;
float newDepth = lastContainer?.Depth + 1 ?? 0;
@ -84,7 +90,7 @@ namespace osu.Game.Screens.Select
}));
//get statistics fromt he current ruleset.
Ruleset.GetRuleset(beatmap.BeatmapInfo.Mode).GetBeatmapStatistics(beatmap).ForEach(s => labels.Add(new InfoLabel(s)));
labels.AddRange(Ruleset.GetRuleset(beatmap.BeatmapInfo.Mode).GetBeatmapStatistics(beatmap).Select(s => new InfoLabel(s)));
}
(beatmapInfoContainer = new BufferedContainer
@ -191,7 +197,7 @@ namespace osu.Game.Screens.Select
private string getBPMRange(Beatmap beatmap)
{
double bpmMax = beatmap.BPMMaximum;
double bpmMax = beatmap.BPMMaximum;
double bpmMin = beatmap.BPMMinimum;
if (Precision.AlmostEquals(bpmMin, bpmMax)) return Math.Round(bpmMin) + "bpm";

View File

@ -57,6 +57,7 @@ namespace osu.Game.Screens.Select
public void RemoveGroup(BeatmapGroup group)
{
groups.Remove(group);
panels.Remove(group.Header);
foreach (var p in group.BeatmapPanels)
panels.Remove(p);

View File

@ -327,8 +327,7 @@ namespace osu.Game.Screens.Select
backgroundModeBeatmap.FadeTo(1, 250);
}
if (beatmap != null)
beatmapInfoWedge.UpdateBeatmap(beatmap);
beatmapInfoWedge.UpdateBeatmap(beatmap);
}
/// <summary>
@ -338,11 +337,11 @@ namespace osu.Game.Screens.Select
{
base.OnBeatmapChanged(beatmap);
beatmap.Mods.BindTo(modSelect.SelectedMods);
beatmap?.Mods.BindTo(modSelect.SelectedMods);
//todo: change background in selectionChanged instead; support per-difficulty backgrounds.
changeBackground(beatmap);
carousel.SelectBeatmap(beatmap.BeatmapInfo);
carousel.SelectBeatmap(beatmap?.BeatmapInfo);
}
/// <summary>

View File

@ -1,16 +0,0 @@
<?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
-->
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@ -91,6 +91,8 @@
<Compile Include="IO\Legacy\SerializationWriter.cs" />
<Compile Include="IPC\ScoreIPCChannel.cs" />
<Compile Include="Modes\LegacyReplay.cs" />
<Compile Include="Modes\Mods\IApplicableMod.cs" />
<Compile Include="Modes\Mods\ModType.cs" />
<Compile Include="Modes\Objects\Drawables\IDrawableHitObjectWithProxiedApproach.cs" />
<Compile Include="Modes\Objects\HitObjectParser.cs" />
<Compile Include="Modes\Objects\NullHitObjectParser.cs" />
@ -114,7 +116,6 @@
<Compile Include="Beatmaps\Drawables\Panel.cs" />
<Compile Include="Modes\Objects\Drawables\DrawableHitObject.cs" />
<Compile Include="Modes\Objects\HitObject.cs" />
<Compile Include="Modes\Objects\HitObjectConverter.cs" />
<Compile Include="Beatmaps\Samples\HitSampleInfo.cs" />
<Compile Include="Beatmaps\Samples\SampleBank.cs" />
<Compile Include="Beatmaps\Samples\SampleInfo.cs" />
@ -168,6 +169,7 @@
<Compile Include="Screens\Multiplayer\Match.cs" />
<Compile Include="Screens\Multiplayer\MatchCreate.cs" />
<Compile Include="Screens\Play\FailDialog.cs" />
<Compile Include="Screens\Play\KeyConversionInputManager.cs" />
<Compile Include="Screens\Play\PlayerInputManager.cs" />
<Compile Include="Screens\Play\PlayerLoader.cs" />
<Compile Include="Screens\Play\SkipButton.cs" />
@ -238,7 +240,7 @@
<Compile Include="Users\User.cs" />
<Compile Include="Graphics\UserInterface\Volume\VolumeControl.cs" />
<Compile Include="Database\BeatmapDatabase.cs" />
<Compile Include="Beatmaps\IO\BeatmapArchiveReader.cs" />
<Compile Include="Beatmaps\IO\ArchiveReader.cs" />
<Compile Include="Beatmaps\Formats\BeatmapDecoder.cs" />
<Compile Include="Beatmaps\Formats\OsuLegacyDecoder.cs" />
<Compile Include="Beatmaps\IO\OszArchiveReader.cs" />
@ -305,7 +307,7 @@
<Compile Include="Screens\Play\Pause\RetryButton.cs" />
<Compile Include="Screens\Play\Pause\QuitButton.cs" />
<Compile Include="Overlays\Mods\ModSelectOverlay.cs" />
<Compile Include="Modes\Mod.cs" />
<Compile Include="Modes\Mods\Mod.cs" />
<Compile Include="Overlays\Mods\ModButton.cs" />
<Compile Include="Modes\UI\ModIcon.cs" />
<Compile Include="Overlays\Mods\ModSection.cs" />
@ -326,12 +328,10 @@
<Compile Include="Screens\Select\Options\BeatmapOptionsEditButton.cs" />
<Compile Include="Screens\Select\Options\BeatmapOptionsOverlay.cs" />
<Compile Include="Screens\Select\Options\BeatmapOptionsRemoveFromUnplayedButton.cs" />
<Compile Include="Screens\Select\Leaderboards\Leaderboard.cs" />
<Compile Include="Screens\Select\Leaderboards\LeaderboardScore.cs" />
<Compile Include="Graphics\UserInterface\IHasDrawableRepresentation.cs" />
<Compile Include="Users\Region.cs" />
<Compile Include="Users\Badge.cs" />
<Compile Include="IO\ArchiveReader.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(SolutionDir)\osu-framework\osu.Framework\osu.Framework.csproj">
@ -347,7 +347,6 @@
<None Include="..\osu.licenseheader">
<Link>osu.licenseheader</Link>
</None>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />