1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-07 19:27:26 +08:00

Merge branch 'master' into replay_keycounter

This commit is contained in:
Dean Herbert 2018-07-24 12:21:51 +02:00 committed by GitHub
commit e7591a9214
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 108 additions and 48 deletions

View File

@ -138,7 +138,7 @@ namespace osu.Game.Rulesets.Mania.UI
internal void OnJudgement(DrawableHitObject judgedObject, Judgement judgement) internal void OnJudgement(DrawableHitObject judgedObject, Judgement judgement)
{ {
if (!judgement.IsHit || !judgedObject.DisplayJudgement) if (!judgement.IsHit || !judgedObject.DisplayJudgement || !DisplayJudgements)
return; return;
explosionContainer.Add(new HitExplosion(judgedObject) explosionContainer.Add(new HitExplosion(judgedObject)

View File

@ -8,7 +8,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Mania.Beatmaps; using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Mania.Configuration; using osu.Game.Rulesets.Mania.Configuration;
@ -74,10 +73,5 @@ namespace osu.Game.Rulesets.Mania.UI
{ {
maniaConfig.BindWith(ManiaSetting.ScrollTime, VisibleTimeRange); maniaConfig.BindWith(ManiaSetting.ScrollTime, VisibleTimeRange);
} }
internal void OnJudgement(DrawableHitObject judgedObject, Judgement judgement)
{
getStageByColumn(((ManiaHitObject)judgedObject.HitObject).Column).OnJudgement(judgedObject, judgement);
}
} }
} }

View File

@ -163,7 +163,7 @@ namespace osu.Game.Rulesets.Mania.UI
internal void OnJudgement(DrawableHitObject judgedObject, Judgement judgement) internal void OnJudgement(DrawableHitObject judgedObject, Judgement judgement)
{ {
if (!judgedObject.DisplayJudgement) if (!judgedObject.DisplayJudgement || !DisplayJudgements)
return; return;
judgements.Clear(); judgements.Clear();

View File

@ -1,12 +0,0 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Rulesets.Osu.UI;
namespace osu.Game.Rulesets.Osu.Edit
{
public class OsuEditPlayfield : OsuPlayfield
{
protected override bool DisplayJudgements => false;
}
}

View File

@ -4,7 +4,6 @@
using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Cursor;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets.Osu.UI; using osu.Game.Rulesets.Osu.UI;
using osu.Game.Rulesets.UI;
using OpenTK; using OpenTK;
namespace osu.Game.Rulesets.Osu.Edit namespace osu.Game.Rulesets.Osu.Edit
@ -16,8 +15,6 @@ namespace osu.Game.Rulesets.Osu.Edit
{ {
} }
protected override Playfield CreatePlayfield() => new OsuEditPlayfield();
protected override Vector2 PlayfieldArea => Vector2.One; protected override Vector2 PlayfieldArea => Vector2.One;
protected override CursorContainer CreateCursor() => null; protected override CursorContainer CreateCursor() => null;

View File

@ -20,8 +20,6 @@ namespace osu.Game.Rulesets.Osu.UI
private readonly JudgementContainer<DrawableOsuJudgement> judgementLayer; private readonly JudgementContainer<DrawableOsuJudgement> judgementLayer;
private readonly ConnectionRenderer<OsuHitObject> connectionLayer; private readonly ConnectionRenderer<OsuHitObject> connectionLayer;
protected virtual bool DisplayJudgements => true;
public static readonly Vector2 BASE_SIZE = new Vector2(512, 384); public static readonly Vector2 BASE_SIZE = new Vector2(512, 384);
public OsuPlayfield() public OsuPlayfield()

View File

@ -226,6 +226,9 @@ namespace osu.Game.Rulesets.Taiko.UI
internal void OnJudgement(DrawableHitObject judgedObject, Judgement judgement) internal void OnJudgement(DrawableHitObject judgedObject, Judgement judgement)
{ {
if (!DisplayJudgements)
return;
if (judgedObject.DisplayJudgement && judgementContainer.FirstOrDefault(j => j.JudgedObject == judgedObject) == null) if (judgedObject.DisplayJudgement && judgementContainer.FirstOrDefault(j => j.JudgedObject == judgedObject) == null)
{ {
judgementContainer.Add(new DrawableTaikoJudgement(judgement, judgedObject) judgementContainer.Add(new DrawableTaikoJudgement(judgement, judgedObject)

View File

@ -214,10 +214,10 @@ namespace osu.Game.Tests.Beatmaps.Formats
} }
[Test] [Test]
public void TestDecodeCustomSamples() public void TestDecodeControlPointCustomSampleBank()
{ {
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false }; var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
using (var resStream = Resource.OpenResource("custom-samples.osu")) using (var resStream = Resource.OpenResource("controlpoint-custom-samplebank.osu"))
using (var stream = new StreamReader(resStream)) using (var stream = new StreamReader(resStream))
{ {
var hitObjects = decoder.Decode(stream).HitObjects; var hitObjects = decoder.Decode(stream).HitObjects;
@ -228,25 +228,42 @@ namespace osu.Game.Tests.Beatmaps.Formats
Assert.AreEqual("normal-hitnormal", getTestableSampleInfo(hitObjects[3]).LookupNames.First()); Assert.AreEqual("normal-hitnormal", getTestableSampleInfo(hitObjects[3]).LookupNames.First());
} }
SampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.SampleControlPoint.ApplyTo(new SampleInfo { Name = "hitnormal" }); SampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.SampleControlPoint.ApplyTo(hitObject.Samples[0]);
} }
[Test] [Test]
public void TestDecodeCustomHitObjectSamples() public void TestDecodeHitObjectCustomSampleBank()
{ {
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false }; var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
using (var resStream = Resource.OpenResource("custom-hitobject-samples.osu")) using (var resStream = Resource.OpenResource("hitobject-custom-samplebank.osu"))
using (var stream = new StreamReader(resStream)) using (var stream = new StreamReader(resStream))
{ {
var hitObjects = decoder.Decode(stream).HitObjects; var hitObjects = decoder.Decode(stream).HitObjects;
Assert.AreEqual("hit_1.wav", hitObjects[0].Samples[0].LookupNames.First()); Assert.AreEqual("normal-hitnormal", getTestableSampleInfo(hitObjects[0]).LookupNames.First());
Assert.AreEqual("hit_2.wav", hitObjects[1].Samples[0].LookupNames.First()); Assert.AreEqual("normal-hitnormal2", getTestableSampleInfo(hitObjects[1]).LookupNames.First());
Assert.AreEqual("normal-hitnormal2", getTestableSampleInfo(hitObjects[2]).LookupNames.First()); Assert.AreEqual("normal-hitnormal3", getTestableSampleInfo(hitObjects[2]).LookupNames.First());
Assert.AreEqual("hit_1.wav", hitObjects[3].Samples[0].LookupNames.First());
} }
SampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.SampleControlPoint.ApplyTo(new SampleInfo { Name = "hitnormal" }); SampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.SampleControlPoint.ApplyTo(hitObject.Samples[0]);
}
[Test]
public void TestDecodeHitObjectFileSamples()
{
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
using (var resStream = Resource.OpenResource("hitobject-file-samples.osu"))
using (var stream = new StreamReader(resStream))
{
var hitObjects = decoder.Decode(stream).HitObjects;
Assert.AreEqual("hit_1.wav", getTestableSampleInfo(hitObjects[0]).LookupNames.First());
Assert.AreEqual("hit_2.wav", getTestableSampleInfo(hitObjects[1]).LookupNames.First());
Assert.AreEqual("normal-hitnormal2", getTestableSampleInfo(hitObjects[2]).LookupNames.First());
Assert.AreEqual("hit_1.wav", getTestableSampleInfo(hitObjects[3]).LookupNames.First());
}
SampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.SampleControlPoint.ApplyTo(hitObject.Samples[0]);
} }
} }
} }

View File

@ -0,0 +1,13 @@
osu file format v14
[General]
SampleSet: Normal
[TimingPoints]
2170,468.75,4,1,0,40,1,0
3107,-100,4,1,2,40,0,0
[HitObjects]
255,193,2170,1,0,0:0:0:0:
256,191,3107,5,0,0:0:0:0:
255,193,4000,1,0,0:0:3:70:

View File

@ -54,6 +54,12 @@ namespace osu.Game.Tests.Visual
public new BeatmapCarousel Carousel => base.Carousel; public new BeatmapCarousel Carousel => base.Carousel;
} }
protected override void Dispose(bool isDisposing)
{
factory.ResetDatabase();
base.Dispose(isDisposing);
}
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {

View File

@ -40,7 +40,6 @@ namespace osu.Game.Beatmaps.ControlPoints
{ {
var newSampleInfo = sampleInfo.Clone(); var newSampleInfo = sampleInfo.Clone();
newSampleInfo.Bank = sampleInfo.Bank ?? SampleBank; newSampleInfo.Bank = sampleInfo.Bank ?? SampleBank;
newSampleInfo.Name = sampleInfo.Name;
newSampleInfo.Volume = sampleInfo.Volume > 0 ? sampleInfo.Volume : SampleVolume; newSampleInfo.Volume = sampleInfo.Volume > 0 ? sampleInfo.Volume : SampleVolume;
return newSampleInfo; return newSampleInfo;
} }

View File

@ -188,7 +188,7 @@ namespace osu.Game.Beatmaps.Formats
{ {
var baseInfo = base.ApplyTo(sampleInfo); var baseInfo = base.ApplyTo(sampleInfo);
if (CustomSampleBank > 1) if (string.IsNullOrEmpty(baseInfo.Suffix) && CustomSampleBank > 1)
baseInfo.Suffix = CustomSampleBank.ToString(); baseInfo.Suffix = CustomSampleBank.ToString();
return baseInfo; return baseInfo;

View File

@ -110,6 +110,13 @@ namespace osu.Game.Rulesets.Edit
toolboxCollection.Items[0].Select(); toolboxCollection.Items[0].Select();
} }
protected override void LoadComplete()
{
base.LoadComplete();
rulesetContainer.Playfield.DisplayJudgements.Value = false;
}
protected override void UpdateAfterChildren() protected override void UpdateAfterChildren()
{ {
base.UpdateAfterChildren(); base.UpdateAfterChildren();

View File

@ -194,8 +194,8 @@ namespace osu.Game.Rulesets.Objects.Legacy
string[] split = str.Split(':'); string[] split = str.Split(':');
var bank = (LegacyBeatmapDecoder.LegacySampleBank)Convert.ToInt32(split[0]); var bank = (LegacyBeatmapDecoder.LegacySampleBank)int.Parse(split[0]);
var addbank = (LegacyBeatmapDecoder.LegacySampleBank)Convert.ToInt32(split[1]); var addbank = (LegacyBeatmapDecoder.LegacySampleBank)int.Parse(split[1]);
string stringBank = bank.ToString().ToLower(); string stringBank = bank.ToString().ToLower();
if (stringBank == @"none") if (stringBank == @"none")
@ -207,6 +207,9 @@ namespace osu.Game.Rulesets.Objects.Legacy
bankInfo.Normal = stringBank; bankInfo.Normal = stringBank;
bankInfo.Add = stringAddBank; bankInfo.Add = stringAddBank;
if (split.Length > 2)
bankInfo.CustomSampleBank = int.Parse(split[2]);
if (split.Length > 3) if (split.Length > 3)
bankInfo.Volume = int.Parse(split[3]); bankInfo.Volume = int.Parse(split[3]);
@ -258,41 +261,45 @@ namespace osu.Game.Rulesets.Objects.Legacy
var soundTypes = new List<SampleInfo> var soundTypes = new List<SampleInfo>
{ {
new SampleInfo new LegacySampleInfo
{ {
Bank = bankInfo.Normal, Bank = bankInfo.Normal,
Name = SampleInfo.HIT_NORMAL, Name = SampleInfo.HIT_NORMAL,
Volume = bankInfo.Volume Volume = bankInfo.Volume,
CustomSampleBank = bankInfo.CustomSampleBank
} }
}; };
if (type.HasFlag(LegacySoundType.Finish)) if (type.HasFlag(LegacySoundType.Finish))
{ {
soundTypes.Add(new SampleInfo soundTypes.Add(new LegacySampleInfo
{ {
Bank = bankInfo.Add, Bank = bankInfo.Add,
Name = SampleInfo.HIT_FINISH, Name = SampleInfo.HIT_FINISH,
Volume = bankInfo.Volume Volume = bankInfo.Volume,
CustomSampleBank = bankInfo.CustomSampleBank
}); });
} }
if (type.HasFlag(LegacySoundType.Whistle)) if (type.HasFlag(LegacySoundType.Whistle))
{ {
soundTypes.Add(new SampleInfo soundTypes.Add(new LegacySampleInfo
{ {
Bank = bankInfo.Add, Bank = bankInfo.Add,
Name = SampleInfo.HIT_WHISTLE, Name = SampleInfo.HIT_WHISTLE,
Volume = bankInfo.Volume Volume = bankInfo.Volume,
CustomSampleBank = bankInfo.CustomSampleBank
}); });
} }
if (type.HasFlag(LegacySoundType.Clap)) if (type.HasFlag(LegacySoundType.Clap))
{ {
soundTypes.Add(new SampleInfo soundTypes.Add(new LegacySampleInfo
{ {
Bank = bankInfo.Add, Bank = bankInfo.Add,
Name = SampleInfo.HIT_CLAP, Name = SampleInfo.HIT_CLAP,
Volume = bankInfo.Volume Volume = bankInfo.Volume,
CustomSampleBank = bankInfo.CustomSampleBank
}); });
} }
@ -307,9 +314,23 @@ namespace osu.Game.Rulesets.Objects.Legacy
public string Add; public string Add;
public int Volume; public int Volume;
public int CustomSampleBank;
public SampleBankInfo Clone() => (SampleBankInfo)MemberwiseClone(); public SampleBankInfo Clone() => (SampleBankInfo)MemberwiseClone();
} }
private class LegacySampleInfo : SampleInfo
{
public int CustomSampleBank
{
set
{
if (value > 1)
Suffix = value.ToString();
}
}
}
private class FileSampleInfo : SampleInfo private class FileSampleInfo : SampleInfo
{ {
public string Filename; public string Filename;

View File

@ -5,6 +5,7 @@ using System.Collections.Generic;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Configuration;
namespace osu.Game.Rulesets.UI namespace osu.Game.Rulesets.UI
{ {
@ -21,6 +22,11 @@ namespace osu.Game.Rulesets.UI
public IReadOnlyList<Playfield> NestedPlayfields => nestedPlayfields; public IReadOnlyList<Playfield> NestedPlayfields => nestedPlayfields;
private List<Playfield> nestedPlayfields; private List<Playfield> nestedPlayfields;
/// <summary>
/// Whether judgements should be displayed by this and and all nested <see cref="Playfield"/>s.
/// </summary>
public readonly BindableBool DisplayJudgements = new BindableBool(true);
/// <summary> /// <summary>
/// A container for keeping track of DrawableHitObjects. /// A container for keeping track of DrawableHitObjects.
/// </summary> /// </summary>
@ -73,6 +79,8 @@ namespace osu.Game.Rulesets.UI
nestedPlayfields = new List<Playfield>(); nestedPlayfields = new List<Playfield>();
nestedPlayfields.Add(otherPlayfield); nestedPlayfields.Add(otherPlayfield);
otherPlayfield.DisplayJudgements.BindTo(DisplayJudgements);
} }
/// <summary> /// <summary>

View File

@ -62,7 +62,16 @@ namespace osu.Game.Tests.Visual
} }
if (localStorage.IsValueCreated) if (localStorage.IsValueCreated)
localStorage.Value.DeleteDirectory("."); {
try
{
localStorage.Value.DeleteDirectory(".");
}
catch
{
// we don't really care if this fails; it will just leave folders lying around from test runs.
}
}
} }
protected override ITestCaseTestRunner CreateRunner() => new OsuTestCaseTestRunner(); protected override ITestCaseTestRunner CreateRunner() => new OsuTestCaseTestRunner();