Initial pass of configuration interface

This commit is contained in:
Dean Herbert
2021-03-15 18:37:46 +09:00
parent 1c865682ae
commit d026c8da85
4 changed files with 194 additions and 42 deletions

View File

@ -1,104 +0,0 @@
// 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 NUnit.Framework;
using OpenTabletDriver.Plugin.Tablet;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Tests.Visual.Settings
{
[TestFixture]
public class TestSceneTabletAreaSelection : OsuTestScene
{
private TabletAreaSelection areaSelection;
[BackgroundDependencyLoader]
private void load()
{
DigitizerIdentifier testTablet = new DigitizerIdentifier
{
// size specifications in millimetres.
Width = 160,
Height = 100,
};
AddRange(new[]
{
areaSelection = new TabletAreaSelection(testTablet)
{
State = { Value = Visibility.Visible }
}
});
}
}
public class TabletAreaSelection : OsuFocusedOverlayContainer
{
private readonly DigitizerIdentifier tablet;
private readonly Container tabletContainer;
private readonly Container usableAreaContainer;
public TabletAreaSelection(DigitizerIdentifier tablet)
{
RelativeSizeAxes = Axes.Both;
this.tablet = tablet;
InternalChildren = new Drawable[]
{
tabletContainer = new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Scale = new Vector2(3),
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.White,
},
usableAreaContainer = new Container
{
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Yellow,
},
new OsuSpriteText
{
Text = "usable area",
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Colour = Color4.Black,
Font = OsuFont.Default.With(size: 12)
}
}
},
}
}
};
}
[BackgroundDependencyLoader]
private void load()
{
// TODO: handle tablet device changes etc.
tabletContainer.Size = new Vector2(tablet.Width, tablet.Height);
usableAreaContainer.Position = new Vector2(10, 30);
usableAreaContainer.Size = new Vector2(80, 60);
}
}
}

View File

@ -0,0 +1,40 @@
// 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.Drawing;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Input.Handlers.Tablet;
using osu.Framework.Platform;
using osu.Game.Overlays.Settings.Sections.Input;
namespace osu.Game.Tests.Visual.Settings
{
[TestFixture]
public class TestSceneTabletSettings : OsuTestScene
{
[BackgroundDependencyLoader]
private void load(GameHost host)
{
var tabletHandler = host.AvailableInputHandlers.OfType<ITabletHandler>().FirstOrDefault();
if (tabletHandler == null)
return;
tabletHandler.AreaOffset.MinValue = new Size(0, 0);
tabletHandler.AreaOffset.MaxValue = new Size(160, 100);
tabletHandler.AreaOffset.Value = new Size(10, 10);
tabletHandler.AreaSize.MinValue = new Size(0, 0);
tabletHandler.AreaSize.MaxValue = new Size(160, 100);
tabletHandler.AreaSize.Value = new Size(100, 80);
AddRange(new Drawable[]
{
new TabletSettings(tabletHandler),
});
}
}
}