1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-16 05:42:54 +08:00

Merge pull request #837 from EVAST9919/fixes

Tidy ups
This commit is contained in:
Dean Herbert 2017-05-23 23:50:44 +09:00 committed by GitHub
commit 7e3caa19fd
3 changed files with 49 additions and 43 deletions

View File

@ -4,6 +4,7 @@
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
namespace osu.Game.Overlays.Settings.Sections.Graphics
{
@ -11,11 +12,12 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
{
protected override string Header => "Layout";
private SettingsSlider<double> letterboxPositionX;
private SettingsSlider<double> letterboxPositionY;
private FillFlowContainer letterboxSettings;
private Bindable<bool> letterboxing;
private const int transition_duration = 400;
[BackgroundDependencyLoader]
private void load(FrameworkConfigManager config)
{
@ -33,34 +35,40 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
LabelText = "Letterboxing",
Bindable = letterboxing,
},
letterboxPositionX = new SettingsSlider<double>
letterboxSettings = new FillFlowContainer
{
LabelText = "Horizontal position",
Bindable = config.GetBindable<double>(FrameworkSetting.LetterboxPositionX)
},
letterboxPositionY = new SettingsSlider<double>
{
LabelText = "Vertical position",
Bindable = config.GetBindable<double>(FrameworkSetting.LetterboxPositionY)
Direction = FillDirection.Vertical,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
AutoSizeDuration = transition_duration,
AutoSizeEasing = EasingTypes.OutQuint,
Masking = true,
Children = new Drawable[]
{
new SettingsSlider<double>
{
LabelText = "Horizontal position",
Bindable = config.GetBindable<double>(FrameworkSetting.LetterboxPositionX)
},
new SettingsSlider<double>
{
LabelText = "Vertical position",
Bindable = config.GetBindable<double>(FrameworkSetting.LetterboxPositionY)
},
}
},
};
letterboxing.ValueChanged += visibilityChanged;
letterboxing.TriggerChange();
}
letterboxing.ValueChanged += isVisible =>
{
letterboxSettings.ClearTransforms();
letterboxSettings.AutoSizeAxes = isVisible ? Axes.Y : Axes.None;
private void visibilityChanged(bool newVisibility)
{
if (newVisibility)
{
letterboxPositionX.Show();
letterboxPositionY.Show();
}
else
{
letterboxPositionX.Hide();
letterboxPositionY.Hide();
}
if(!isVisible)
letterboxSettings.ResizeHeightTo(0, transition_duration, EasingTypes.OutQuint);
};
letterboxing.TriggerChange();
}
}
}

View File

@ -30,7 +30,6 @@ namespace osu.Game.Screens.Play
public readonly SongProgress Progress;
public readonly ModDisplay ModDisplay;
private Bindable<bool> showKeyCounter;
private Bindable<bool> showHud;
private static bool hasShownNotificationOnce;
@ -67,24 +66,8 @@ namespace osu.Game.Screens.Play
[BackgroundDependencyLoader(true)]
private void load(OsuConfigManager config, NotificationManager notificationManager)
{
showKeyCounter = config.GetBindable<bool>(OsuSetting.KeyOverlay);
showKeyCounter.ValueChanged += keyCounterVisibility =>
{
if (keyCounterVisibility)
KeyCounter.FadeIn(duration);
else
KeyCounter.FadeOut(duration);
};
showKeyCounter.TriggerChange();
showHud = config.GetBindable<bool>(OsuSetting.ShowInterface);
showHud.ValueChanged += hudVisibility =>
{
if (hudVisibility)
content.FadeIn(duration);
else
content.FadeOut(duration);
};
showHud.ValueChanged += hudVisibility => content.FadeTo(hudVisibility ? 1 : 0, duration);
showHud.TriggerChange();
if (!showHud && !hasShownNotificationOnce)

View File

@ -6,11 +6,18 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using OpenTK.Graphics;
using osu.Framework.Input;
using osu.Framework.Configuration;
using osu.Framework.Allocation;
using osu.Game.Configuration;
namespace osu.Game.Screens.Play
{
public class KeyCounterCollection : FillFlowContainer<KeyCounter>
{
private const int duration = 100;
private Bindable<bool> showKeyCounter;
public KeyCounterCollection()
{
AlwaysReceiveInput = true;
@ -34,6 +41,14 @@ namespace osu.Game.Screens.Play
counter.ResetCount();
}
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
showKeyCounter = config.GetBindable<bool>(OsuSetting.KeyOverlay);
showKeyCounter.ValueChanged += keyCounterVisibility => FadeTo(keyCounterVisibility ? 1 : 0, duration);
showKeyCounter.TriggerChange();
}
//further: change default values here and in KeyCounter if needed, instead of passing them in every constructor
private bool isCounting;
public bool IsCounting