mirror of
https://github.com/ppy/osu
synced 2024-12-14 19:06:07 +00:00
Setup basic test and classes for scale adjustment
This commit is contained in:
parent
9c62c90cfc
commit
2d17219c8f
@ -4,17 +4,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
using osuTK.Graphics;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
@ -32,6 +36,32 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Resolved]
|
||||
private OsuConfigManager config { get; set; }
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
Add(new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Width = 0.3f,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = Color4.Black,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 0.7f,
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Vertical,
|
||||
Children = createSkinSourceComponents(),
|
||||
},
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestComboCounterIncrementing()
|
||||
{
|
||||
@ -74,6 +104,18 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
AddAssert("key counter flow not affected", () => keyCounterFlow.IsPresent);
|
||||
}
|
||||
|
||||
private IReadOnlyList<Drawable> createSkinSourceComponents()
|
||||
{
|
||||
var hudComponents = typeof(SkinnableHUDComponent).Assembly.GetTypes().Where(t => typeof(SkinnableHUDComponent).IsAssignableFrom(t)).ToArray();
|
||||
|
||||
List<Drawable> drawables = new List<Drawable>();
|
||||
|
||||
foreach (var component in hudComponents)
|
||||
drawables.AddRange(component.CreateSettingsControls());
|
||||
|
||||
return drawables;
|
||||
}
|
||||
|
||||
private void createNew(Action<HUDOverlay> action = null)
|
||||
{
|
||||
AddStep("create overlay", () =>
|
||||
|
@ -6,7 +6,7 @@ using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Screens.Play.HUD
|
||||
{
|
||||
public class SkinnableAccuracyCounter : SkinnableDrawable, IAccuracyCounter
|
||||
public class SkinnableAccuracyCounter : SkinnableHUDComponent, IAccuracyCounter
|
||||
{
|
||||
public Bindable<double> Current { get; } = new Bindable<double>();
|
||||
|
||||
|
32
osu.Game/Screens/Play/HUD/SkinnableHUDComponent.cs
Normal file
32
osu.Game/Screens/Play/HUD/SkinnableHUDComponent.cs
Normal file
@ -0,0 +1,32 @@
|
||||
// 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 osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Screens.Play.HUD
|
||||
{
|
||||
/// <summary>
|
||||
/// A skinnable HUD component which can be scaled and repositioned at a skinner/user's will.
|
||||
/// </summary>
|
||||
public abstract class SkinnableHUDComponent : SkinnableDrawable
|
||||
{
|
||||
[SettingSource("Scale", "The scale at which this component should be displayed.")]
|
||||
public BindableNumber<float> SkinScale { get; } = new BindableFloat(1)
|
||||
{
|
||||
Precision = 0.1f,
|
||||
MinValue = 0.1f,
|
||||
MaxValue = 10,
|
||||
Default = 1,
|
||||
Value = 1,
|
||||
};
|
||||
|
||||
protected SkinnableHUDComponent(ISkinComponent component, Func<ISkinComponent, Drawable> defaultImplementation, Func<ISkinSource, bool> allowFallback = null, ConfineMode confineMode = ConfineMode.NoScaling)
|
||||
: base(component, defaultImplementation, allowFallback, confineMode)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -10,7 +10,7 @@ using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Screens.Play.HUD
|
||||
{
|
||||
public class SkinnableScoreCounter : SkinnableDrawable, IScoreCounter
|
||||
public class SkinnableScoreCounter : SkinnableHUDComponent, IScoreCounter
|
||||
{
|
||||
public Bindable<double> Current { get; } = new Bindable<double>();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user