mirror of
https://github.com/osukey/osukey.git
synced 2025-04-29 02:37:25 +09:00
Removed unnecessary methods, changed tests, and moved LimitedCapacityQueue.cs to a more generic namespace.
This commit is contained in:
parent
a25c94d567
commit
eff6c7be64
@ -6,10 +6,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
||||||
using osu.Game.Rulesets.Difficulty.Skills;
|
using osu.Game.Rulesets.Difficulty.Skills;
|
||||||
using osu.Game.Rulesets.Difficulty.Utils;
|
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Taiko.Difficulty.Preprocessing;
|
using osu.Game.Rulesets.Taiko.Difficulty.Preprocessing;
|
||||||
using osu.Game.Rulesets.Taiko.Objects;
|
using osu.Game.Rulesets.Taiko.Objects;
|
||||||
|
using osu.Game.Utils;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Taiko.Difficulty.Skills
|
namespace osu.Game.Rulesets.Taiko.Difficulty.Skills
|
||||||
{
|
{
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Game.Rulesets.Difficulty.Utils;
|
using osu.Game.Utils;
|
||||||
|
|
||||||
namespace osu.Game.Tests.NonVisual
|
namespace osu.Game.Tests.NonVisual
|
||||||
{
|
{
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using System.Linq;
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
@ -21,8 +18,8 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
|
|
||||||
private int messageCounter;
|
private int messageCounter;
|
||||||
|
|
||||||
private HistoryTextBox box;
|
private HistoryTextBox box = null!;
|
||||||
private OsuSpriteText text;
|
private OsuSpriteText text = null!;
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void SetUp()
|
public void SetUp()
|
||||||
@ -70,7 +67,6 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
public void TestEmptyHistory()
|
public void TestEmptyHistory()
|
||||||
{
|
{
|
||||||
AddStep("Set text", () => box.Text = temp);
|
AddStep("Set text", () => box.Text = temp);
|
||||||
AddAssert("History is empty", () => !box.GetMessageHistory().Any());
|
|
||||||
|
|
||||||
AddStep("Move down", () => InputManager.Key(Key.Down));
|
AddStep("Move down", () => InputManager.Key(Key.Down));
|
||||||
AddAssert("Text is the same", () => box.Text == temp);
|
AddAssert("Text is the same", () => box.Text == temp);
|
||||||
@ -106,16 +102,12 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
{
|
{
|
||||||
addMessages(5);
|
addMessages(5);
|
||||||
AddStep("Set text", () => box.Text = temp);
|
AddStep("Set text", () => box.Text = temp);
|
||||||
AddAssert("History saved as <5-1>", () =>
|
|
||||||
Enumerable.Range(0, 5).Select(number => $"Message {5 - number}").SequenceEqual(box.GetMessageHistory()));
|
|
||||||
|
|
||||||
AddStep("Move down", () => InputManager.Key(Key.Down));
|
AddStep("Move down", () => InputManager.Key(Key.Down));
|
||||||
AddAssert("Text is the same", () => box.Text == temp);
|
AddAssert("Text is the same", () => box.Text == temp);
|
||||||
|
|
||||||
addMessages(2);
|
addMessages(2);
|
||||||
AddStep("Set text", () => box.Text = temp);
|
AddStep("Set text", () => box.Text = temp);
|
||||||
AddAssert("Overrode history to <7-3>", () =>
|
|
||||||
Enumerable.Range(0, 5).Select(number => $"Message {7 - number}").SequenceEqual(box.GetMessageHistory()));
|
|
||||||
|
|
||||||
AddRepeatStep("Move Up", () => InputManager.Key(Key.Up), 5);
|
AddRepeatStep("Move Up", () => InputManager.Key(Key.Up), 5);
|
||||||
AddAssert("Same as 3rd message", () => box.Text == "Message 3");
|
AddAssert("Same as 3rd message", () => box.Text == "Message 3");
|
||||||
@ -130,18 +122,6 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
AddAssert("Same as temp message", () => box.Text == temp);
|
AddAssert("Same as temp message", () => box.Text == temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void TestOverrideFullHistory()
|
|
||||||
{
|
|
||||||
addMessages(5);
|
|
||||||
AddAssert("History saved as <5-1>", () =>
|
|
||||||
Enumerable.Range(0, 5).Select(number => $"Message {5 - number}").SequenceEqual(box.GetMessageHistory()));
|
|
||||||
|
|
||||||
addMessages(6);
|
|
||||||
AddAssert("Overrode history to <11-7>", () =>
|
|
||||||
Enumerable.Range(0, 5).Select(number => $"Message {11 - number}").SequenceEqual(box.GetMessageHistory()));
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestResetIndex()
|
public void TestResetIndex()
|
||||||
{
|
{
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Rulesets.Difficulty.Utils;
|
using osu.Game.Utils;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
|
|
||||||
namespace osu.Game.Graphics.UserInterface
|
namespace osu.Game.Graphics.UserInterface
|
||||||
@ -12,15 +11,6 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
{
|
{
|
||||||
private readonly LimitedCapacityQueue<string> messageHistory;
|
private readonly LimitedCapacityQueue<string> messageHistory;
|
||||||
|
|
||||||
public IEnumerable<string> GetMessageHistory()
|
|
||||||
{
|
|
||||||
if (HistoryCount == 0)
|
|
||||||
yield break;
|
|
||||||
|
|
||||||
for (int i = HistoryCount - 1; i >= 0; i--)
|
|
||||||
yield return messageHistory[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
public int HistoryCount => messageHistory.Count;
|
public int HistoryCount => messageHistory.Count;
|
||||||
|
|
||||||
private int selectedIndex;
|
private int selectedIndex;
|
||||||
@ -28,8 +18,6 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
private string originalMessage = string.Empty;
|
private string originalMessage = string.Empty;
|
||||||
private bool everythingSelected;
|
private bool everythingSelected;
|
||||||
|
|
||||||
public string GetOldMessage(int index) => messageHistory[HistoryCount - index - 1];
|
|
||||||
|
|
||||||
public HistoryTextBox(int capacity = 100)
|
public HistoryTextBox(int capacity = 100)
|
||||||
{
|
{
|
||||||
messageHistory = new LimitedCapacityQueue<string>(capacity);
|
messageHistory = new LimitedCapacityQueue<string>(capacity);
|
||||||
|
@ -7,7 +7,7 @@ using System;
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Difficulty.Utils
|
namespace osu.Game.Utils
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An indexed queue with limited capacity.
|
/// An indexed queue with limited capacity.
|
Loading…
x
Reference in New Issue
Block a user