1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-19 12:03:21 +08:00

Merge branch 'master' into fix-osu-hd-mod

This commit is contained in:
Bartłomiej Dach 2020-11-11 09:45:45 +01:00 committed by GitHub
commit 2b2f0321fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 92 additions and 22 deletions

View File

@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
@ -54,12 +55,77 @@ namespace osu.Game.Rulesets.Mania.Tests
}
}
[Test]
public void TestHoldNoteMissAfterNextObjectStartTime()
{
var objects = new List<ManiaHitObject>
{
new HoldNote
{
StartTime = 1000,
EndTime = 1010,
},
new HoldNote
{
StartTime = 1020,
EndTime = 1030
}
};
performTest(objects, new List<ReplayFrame>());
addJudgementAssert(objects[0], HitResult.IgnoreHit);
addJudgementAssert(objects[1], HitResult.IgnoreHit);
}
[Test]
public void TestHoldNoteReleasedHitAfterNextObjectStartTime()
{
var objects = new List<ManiaHitObject>
{
new HoldNote
{
StartTime = 1000,
EndTime = 1010,
},
new HoldNote
{
StartTime = 1020,
EndTime = 1030
}
};
var frames = new List<ReplayFrame>
{
new ManiaReplayFrame(1000, ManiaAction.Key1),
new ManiaReplayFrame(1030),
new ManiaReplayFrame(1040, ManiaAction.Key1),
new ManiaReplayFrame(1050)
};
performTest(objects, frames);
addJudgementAssert(objects[0], HitResult.IgnoreHit);
addJudgementAssert("first head", () => ((HoldNote)objects[0]).Head, HitResult.Perfect);
addJudgementAssert("first tail", () => ((HoldNote)objects[0]).Tail, HitResult.Perfect);
addJudgementAssert(objects[1], HitResult.IgnoreHit);
addJudgementAssert("second head", () => ((HoldNote)objects[1]).Head, HitResult.Great);
addJudgementAssert("second tail", () => ((HoldNote)objects[1]).Tail, HitResult.Perfect);
}
private void addJudgementAssert(ManiaHitObject hitObject, HitResult result)
{
AddAssert($"({hitObject.GetType().ReadableName()} @ {hitObject.StartTime}) judgement is {result}",
() => judgementResults.Single(r => r.HitObject == hitObject).Type == result);
}
private void addJudgementAssert(string name, Func<ManiaHitObject> hitObject, HitResult result)
{
AddAssert($"{name} judgement is {result}",
() => judgementResults.Single(r => r.HitObject == hitObject()).Type == result);
}
private void addJudgementOffsetAssert(ManiaHitObject hitObject, double offset)
{
AddAssert($"({hitObject.GetType().ReadableName()} @ {hitObject.StartTime}) judged at {offset}",

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Game.Rulesets.Mania.Objects.Drawables;
@ -44,9 +43,6 @@ namespace osu.Game.Rulesets.Mania.UI
/// <param name="hitObject">The <see cref="HitObject"/> that was hit.</param>
public void HandleHit(DrawableHitObject hitObject)
{
if (!IsHittable(hitObject, hitObject.HitObject.StartTime + hitObject.Result.TimeOffset))
throw new InvalidOperationException($"A {hitObject} was hit before it became hittable!");
foreach (var obj in enumerateHitObjectsUpTo(hitObject.HitObject.StartTime))
{
if (obj.Judged)

View File

@ -189,7 +189,7 @@ namespace osu.Game.Configuration
new TrackedSetting<int>(OsuSetting.Skin, m =>
{
string skinName = LookupSkinName(m) ?? string.Empty;
return new SettingDescription(skinName, "skin", skinName);
return new SettingDescription(skinName, "skin", skinName, $"random: {LookupKeyBindings(GlobalAction.RandomSkin)}");
})
};
}

View File

@ -48,6 +48,8 @@ namespace osu.Game.Input.Bindings
new KeyBinding(InputKey.Space, GlobalAction.Select),
new KeyBinding(InputKey.Enter, GlobalAction.Select),
new KeyBinding(InputKey.KeypadEnter, GlobalAction.Select),
new KeyBinding(new[] { InputKey.Control, InputKey.Shift, InputKey.R }, GlobalAction.RandomSkin),
};
public IEnumerable<KeyBinding> EditorKeyBindings => new[]
@ -191,5 +193,8 @@ namespace osu.Game.Input.Bindings
[Description("Hold for HUD")]
HoldForHUD,
[Description("Random Skin")]
RandomSkin,
}
}

View File

@ -681,7 +681,6 @@ namespace osu.Game
loadComponentSingleFile(new AccountCreationOverlay(), topMostOverlayContent.Add, true);
loadComponentSingleFile(new DialogOverlay(), topMostOverlayContent.Add, true);
loadComponentSingleFile(externalLinkOpener = new ExternalLinkOpener(), topMostOverlayContent.Add);
chatOverlay.State.ValueChanged += state => channelManager.HighPollRate.Value = state.NewValue == Visibility.Visible;
@ -892,6 +891,10 @@ namespace osu.Game
case GlobalAction.ToggleGameplayMouseButtons:
LocalConfig.Set(OsuSetting.MouseDisableButtons, !LocalConfig.Get<bool>(OsuSetting.MouseDisableButtons));
return true;
case GlobalAction.RandomSkin:
SkinManager.SelectRandomSkin();
return true;
}
return false;

View File

@ -9,7 +9,6 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Logging;
using osu.Framework.Utils;
using osu.Game.Configuration;
using osu.Game.Graphics.UserInterface;
using osu.Game.Skinning;
@ -103,7 +102,7 @@ namespace osu.Game.Overlays.Settings.Sections
{
if (skin.NewValue == random_skin_info)
{
randomizeSkin();
skins.SelectRandomSkin();
return;
}
@ -111,20 +110,6 @@ namespace osu.Game.Overlays.Settings.Sections
});
}
private void randomizeSkin()
{
// choose from only user skins, removing the current selection to ensure a new one is chosen.
var randomChoices = skinItems.Where(s => s.ID > 0 && s.ID != configBindable.Value).ToArray();
if (randomChoices.Length == 0)
{
configBindable.Value = SkinInfo.Default.ID;
return;
}
configBindable.Value = randomChoices.ElementAt(RNG.Next(0, randomChoices.Length)).ID;
}
private void updateItems()
{
skinItems = skins.GetAllUsableSkins();

View File

@ -19,6 +19,7 @@ using osu.Framework.Graphics.Textures;
using osu.Framework.IO.Stores;
using osu.Framework.Platform;
using osu.Framework.Testing;
using osu.Framework.Utils;
using osu.Game.Audio;
using osu.Game.Database;
using osu.Game.IO.Archives;
@ -87,6 +88,20 @@ namespace osu.Game.Skinning
/// <returns>A newly allocated list of available <see cref="SkinInfo"/>.</returns>
public List<SkinInfo> GetAllUserSkins() => ModelStore.ConsumableItems.Where(s => !s.DeletePending).ToList();
public void SelectRandomSkin()
{
// choose from only user skins, removing the current selection to ensure a new one is chosen.
var randomChoices = GetAllUsableSkins().Where(s => s.ID > 0 && s.ID != CurrentSkinInfo.Value.ID).ToArray();
if (randomChoices.Length == 0)
{
CurrentSkinInfo.Value = SkinInfo.Default;
return;
}
CurrentSkinInfo.Value = randomChoices.ElementAt(RNG.Next(0, randomChoices.Length));
}
protected override SkinInfo CreateModel(ArchiveReader archive) => new SkinInfo { Name = archive.Name };
private const string unknown_creator_string = "Unknown";