2019-10-18 16:32:11 +08:00
|
|
|
// 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.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2019-10-18 16:32:11 +08:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Audio.Sample;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2020-07-17 15:54:30 +08:00
|
|
|
using osu.Framework.Graphics.OpenGL.Textures;
|
2019-10-18 16:32:11 +08:00
|
|
|
using osu.Framework.Graphics.Textures;
|
|
|
|
using osu.Framework.Testing;
|
|
|
|
using osu.Game.Audio;
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2020-02-25 18:07:15 +08:00
|
|
|
using osu.Game.Rulesets.Objects.Legacy;
|
2019-10-18 16:32:11 +08:00
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
|
|
|
using osu.Game.Skinning;
|
|
|
|
using osu.Game.Tests.Visual;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Gameplay
|
|
|
|
{
|
|
|
|
[HeadlessTest]
|
|
|
|
public class TestSceneHitObjectAccentColour : OsuTestScene
|
|
|
|
{
|
|
|
|
private Container skinContainer;
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
public void Setup() => Schedule(() => Child = skinContainer = new SkinProvidingContainer(new TestSkin()));
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestChangeComboIndexBeforeLoad()
|
|
|
|
{
|
|
|
|
TestDrawableHitObject hitObject = null;
|
|
|
|
|
|
|
|
AddStep("set combo and add hitobject", () =>
|
|
|
|
{
|
|
|
|
hitObject = new TestDrawableHitObject();
|
|
|
|
hitObject.HitObject.ComboIndex = 1;
|
|
|
|
|
|
|
|
skinContainer.Add(hitObject);
|
|
|
|
});
|
|
|
|
|
|
|
|
AddAssert("combo colour is green", () => hitObject.AccentColour.Value == Color4.Green);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestChangeComboIndexDuringLoad()
|
|
|
|
{
|
|
|
|
TestDrawableHitObject hitObject = null;
|
|
|
|
|
|
|
|
AddStep("add hitobject and set combo", () =>
|
|
|
|
{
|
|
|
|
skinContainer.Add(hitObject = new TestDrawableHitObject());
|
|
|
|
hitObject.HitObject.ComboIndex = 1;
|
|
|
|
});
|
|
|
|
|
|
|
|
AddAssert("combo colour is green", () => hitObject.AccentColour.Value == Color4.Green);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestChangeComboIndexAfterLoad()
|
|
|
|
{
|
|
|
|
TestDrawableHitObject hitObject = null;
|
|
|
|
|
|
|
|
AddStep("add hitobject", () => skinContainer.Add(hitObject = new TestDrawableHitObject()));
|
|
|
|
AddAssert("combo colour is red", () => hitObject.AccentColour.Value == Color4.Red);
|
|
|
|
|
|
|
|
AddStep("change combo", () => hitObject.HitObject.ComboIndex = 1);
|
|
|
|
AddAssert("combo colour is green", () => hitObject.AccentColour.Value == Color4.Green);
|
|
|
|
}
|
|
|
|
|
|
|
|
private class TestDrawableHitObject : DrawableHitObject<TestHitObjectWithCombo>
|
|
|
|
{
|
|
|
|
public TestDrawableHitObject()
|
|
|
|
: base(new TestHitObjectWithCombo())
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-23 12:01:30 +08:00
|
|
|
private class TestHitObjectWithCombo : ConvertHitObject, IHasComboInformation
|
2019-10-18 16:32:11 +08:00
|
|
|
{
|
2020-11-02 03:51:23 +08:00
|
|
|
public bool NewCombo { get; set; }
|
2021-07-20 19:15:43 +08:00
|
|
|
public int ComboOffset => 0;
|
2019-10-18 16:32:11 +08:00
|
|
|
|
|
|
|
public Bindable<int> IndexInCurrentComboBindable { get; } = new Bindable<int>();
|
|
|
|
|
|
|
|
public int IndexInCurrentCombo
|
|
|
|
{
|
|
|
|
get => IndexInCurrentComboBindable.Value;
|
|
|
|
set => IndexInCurrentComboBindable.Value = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Bindable<int> ComboIndexBindable { get; } = new Bindable<int>();
|
|
|
|
|
|
|
|
public int ComboIndex
|
|
|
|
{
|
|
|
|
get => ComboIndexBindable.Value;
|
|
|
|
set => ComboIndexBindable.Value = value;
|
|
|
|
}
|
|
|
|
|
2021-07-22 21:22:42 +08:00
|
|
|
public Bindable<int> ComboIndexWithOffsetsBindable { get; } = new Bindable<int>();
|
|
|
|
|
|
|
|
public int ComboIndexWithOffsets
|
|
|
|
{
|
|
|
|
get => ComboIndexWithOffsetsBindable.Value;
|
|
|
|
set => ComboIndexWithOffsetsBindable.Value = value;
|
|
|
|
}
|
2021-07-20 19:15:43 +08:00
|
|
|
|
2019-10-18 16:32:11 +08:00
|
|
|
public Bindable<bool> LastInComboBindable { get; } = new Bindable<bool>();
|
|
|
|
|
|
|
|
public bool LastInCombo
|
|
|
|
{
|
|
|
|
get => LastInComboBindable.Value;
|
|
|
|
set => LastInComboBindable.Value = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private class TestSkin : ISkin
|
|
|
|
{
|
|
|
|
public readonly List<Color4> ComboColours = new List<Color4>
|
|
|
|
{
|
|
|
|
Color4.Red,
|
|
|
|
Color4.Green
|
|
|
|
};
|
|
|
|
|
|
|
|
public Drawable GetDrawableComponent(ISkinComponent component) => throw new NotImplementedException();
|
|
|
|
|
2020-07-17 15:54:30 +08:00
|
|
|
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => throw new NotImplementedException();
|
2019-10-18 16:32:11 +08:00
|
|
|
|
2021-02-18 17:32:28 +08:00
|
|
|
public ISample GetSample(ISampleInfo sampleInfo) => throw new NotImplementedException();
|
2019-10-18 16:32:11 +08:00
|
|
|
|
|
|
|
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup)
|
|
|
|
{
|
|
|
|
switch (lookup)
|
|
|
|
{
|
2021-05-05 12:11:45 +08:00
|
|
|
case SkinComboColourLookup comboColour:
|
|
|
|
return SkinUtils.As<TValue>(new Bindable<Color4>(ComboColours[comboColour.ColourIndex % ComboColours.Count]));
|
2019-10-18 16:32:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|