1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-09 04:17:25 +08:00
osu-lazer/osu.Game/Overlays/Options/Sections/Graphics/LayoutOptions.cs
Dean Herbert 153951d3dd Add OptionItem class
Allow for centalised logic for all option UI controls.
2017-05-04 23:07:48 +09:00

68 lines
2.3 KiB
C#

// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.Options.Sections.Graphics
{
public class LayoutOptions : OptionsSubsection
{
protected override string Header => "Layout";
private OptionSlider<double> letterboxPositionX;
private OptionSlider<double> letterboxPositionY;
private Bindable<bool> letterboxing;
[BackgroundDependencyLoader]
private void load(FrameworkConfigManager config)
{
letterboxing = config.GetBindable<bool>(FrameworkConfig.Letterboxing);
Children = new Drawable[]
{
new OptionEnumDropdown<WindowMode>
{
LabelText = "Screen mode",
Bindable = config.GetBindable<WindowMode>(FrameworkConfig.WindowMode),
},
new OptionCheckbox
{
LabelText = "Letterboxing",
Bindable = letterboxing,
},
letterboxPositionX = new OptionSlider<double>
{
LabelText = "Horizontal position",
Bindable = config.GetBindable<double>(FrameworkConfig.LetterboxPositionX)
},
letterboxPositionY = new OptionSlider<double>
{
LabelText = "Vertical position",
Bindable = config.GetBindable<double>(FrameworkConfig.LetterboxPositionY)
},
};
letterboxing.ValueChanged += visibilityChanged;
letterboxing.TriggerChange();
}
private void visibilityChanged(bool newVisibility)
{
if (newVisibility)
{
letterboxPositionX.Show();
letterboxPositionY.Show();
}
else
{
letterboxPositionX.Hide();
letterboxPositionY.Hide();
}
}
}
}