1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-19 01:17:19 +08:00

Merge remote-tracking branch 'origin/master' into use-slider-step

This commit is contained in:
Thomas Müller 2017-08-17 08:50:48 +09:00
commit 94d081064d
14 changed files with 257 additions and 108 deletions

View File

@ -27,8 +27,6 @@ namespace osu.Desktop.Overlays
private UpdateManager updateManager;
private NotificationOverlay notificationOverlay;
protected override bool HideOnEscape => false;
public override bool HandleInput => false;
[BackgroundDependencyLoader]

View File

@ -5,7 +5,6 @@ using OpenTK.Graphics;
using OpenTK.Input;
using osu.Framework.Input;
using System;
using System.Linq;
namespace osu.Game.Graphics.UserInterface
{
@ -37,16 +36,18 @@ namespace osu.Game.Graphics.UserInterface
BorderThickness = 0;
}
protected override void OnFocusLost(InputState state)
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
if (state.Keyboard.Keys.Any(key => key == Key.Escape))
if (args.Key == Key.Escape)
{
if (Text.Length > 0)
Text = string.Empty;
else
Exit?.Invoke();
return true;
}
base.OnFocusLost(state);
return base.OnKeyDown(state, args);
}
public override bool RequestsFocus => HoldFocus;

View File

@ -15,8 +15,6 @@ namespace osu.Game.Graphics.UserInterface.Volume
{
private readonly VolumeMeter volumeMeterMaster;
protected override bool HideOnEscape => false;
private void volumeChanged(double newVolume)
{
Show();

View File

@ -6,7 +6,6 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using osu.Framework.Graphics;
using osu.Framework.Input;
using osu.Framework.Input.Bindings;
namespace osu.Game.Input.Bindings
@ -31,23 +30,8 @@ namespace osu.Game.Input.Bindings
new KeyBinding(new[] { Key.LControl, Key.D }, GlobalAction.ToggleDirect),
};
protected override bool PropagateKeyDown(IEnumerable<Drawable> drawables, InputState state, KeyDownEventArgs args)
{
if (handler != null)
drawables = new[] { handler }.Concat(drawables);
// always handle ourselves before all children.
return base.PropagateKeyDown(drawables, state, args);
}
protected override bool PropagateKeyUp(IEnumerable<Drawable> drawables, InputState state, KeyUpEventArgs args)
{
if (handler != null)
drawables = new[] { handler }.Concat(drawables);
// always handle ourselves before all children.
return base.PropagateKeyUp(drawables, state, args);
}
protected override IEnumerable<Drawable> GetKeyboardInputQueue() =>
handler == null ? base.GetKeyboardInputQueue() : new[] { handler }.Concat(base.GetKeyboardInputQueue());
}
public enum GlobalAction

View File

@ -11,7 +11,6 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input;
using osu.Framework.Input.Bindings;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Input;
@ -106,12 +105,6 @@ namespace osu.Game.Overlays.KeyBinding
}
};
reloadBindings();
}
private void reloadBindings()
{
buttons.Clear();
foreach (var b in bindings)
buttons.Add(new KeyButton(b));
}
@ -149,23 +142,50 @@ namespace osu.Game.Overlays.KeyBinding
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
if (HasFocus && !isModifier(args.Key))
switch (args.Key)
{
bindTarget.KeyBinding.KeyCombination = args.Key == Key.Delete ? Key.Unknown : new KeyCombination(state.Keyboard.Keys);
case Key.Escape:
GetContainingInputManager().ChangeFocus(null);
return true;
case Key.Delete:
bindTarget.UpdateKeyCombination(Key.Unknown);
store.Update(bindTarget.KeyBinding);
GetContainingInputManager().ChangeFocus(null);
return true;
}
store.Update(bindTarget.KeyBinding);
GetContainingInputManager().ChangeFocus(null);
if (HasFocus)
{
bindTarget.UpdateKeyCombination(state.Keyboard.Keys.ToArray());
if (!isModifier(args.Key))
finalise();
return true;
}
return base.OnKeyDown(state, args);
}
protected override bool OnKeyUp(InputState state, KeyUpEventArgs args)
{
if (HasFocus)
{
finalise();
return true;
}
return base.OnKeyUp(state, args);
}
private void finalise()
{
store.Update(bindTarget.KeyBinding);
GetContainingInputManager().ChangeFocus(null);
}
protected override void OnFocusLost(InputState state)
{
bindTarget.IsBinding = false;
bindTarget = null;
reloadBindings();
pressAKey.FadeOut(300, Easing.OutQuint);
pressAKey.Padding = new MarginPadding { Bottom = -pressAKey.DrawHeight };
@ -197,19 +217,10 @@ namespace osu.Game.Overlays.KeyBinding
get { return isBinding; }
set
{
if (value == isBinding) return;
isBinding = value;
if (value)
{
box.FadeColour(Color4.White, transition_time, Easing.OutQuint);
Text.FadeColour(Color4.Black, transition_time, Easing.OutQuint);
}
else
{
box.FadeColour(Color4.Black, transition_time, Easing.OutQuint);
Text.FadeColour(Color4.White, transition_time, Easing.OutQuint);
}
updateHoverState();
}
}
@ -261,25 +272,35 @@ namespace osu.Game.Overlays.KeyBinding
protected override bool OnHover(InputState state)
{
if (isBinding)
return false;
box.FadeColour(hoverColour, transition_time, Easing.OutQuint);
Text.FadeColour(Color4.Black, transition_time, Easing.OutQuint);
updateHoverState();
return base.OnHover(state);
}
protected override void OnHoverLost(InputState state)
{
if (isBinding)
return;
box.FadeColour(Color4.Black, transition_time, Easing.OutQuint);
Text.FadeColour(Color4.White, transition_time, Easing.OutQuint);
updateHoverState();
base.OnHoverLost(state);
}
private void updateHoverState()
{
if (isBinding)
{
box.FadeColour(Color4.White, transition_time, Easing.OutQuint);
Text.FadeColour(Color4.Black, transition_time, Easing.OutQuint);
}
else
{
box.FadeColour(IsHovered ? hoverColour : Color4.Black, transition_time, Easing.OutQuint);
Text.FadeColour(IsHovered ? Color4.Black : Color4.White, transition_time, Easing.OutQuint);
}
}
public void UpdateKeyCombination(params Key[] newCombination)
{
KeyBinding.KeyCombination = newCombination;
Text.Text = KeyBinding.KeyCombination.ReadableString();
}
}
}
}

View File

@ -2,14 +2,25 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Overlays.Settings;
using osu.Game.Overlays.Settings.Sections;
using osu.Game.Screens.Ranking;
using OpenTK;
namespace osu.Game.Overlays
{
public class MainSettings : SettingsOverlay
{
private readonly KeyBindingOverlay keyBindingOverlay;
private BackButton backButton;
protected override IEnumerable<SettingsSection> CreateSections() => new SettingsSection[]
{
new GeneralSection(),
@ -17,7 +28,7 @@ namespace osu.Game.Overlays
new GameplaySection(),
new AudioSection(),
new SkinSection(),
new InputSection(),
new InputSection(keyBindingOverlay),
new OnlineSection(),
new MaintenanceSection(),
new DebugSection(),
@ -26,8 +37,138 @@ namespace osu.Game.Overlays
protected override Drawable CreateHeader() => new SettingsHeader("settings", "Change the way osu! behaves");
protected override Drawable CreateFooter() => new SettingsFooter();
public MainSettings() : base(true)
public MainSettings()
: base(true)
{
keyBindingOverlay = new KeyBindingOverlay { Depth = 1 };
keyBindingOverlay.StateChanged += keyBindingOverlay_StateChanged;
}
public override bool AcceptsFocus => keyBindingOverlay.State != Visibility.Visible;
private void keyBindingOverlay_StateChanged(VisibilityContainer container, Visibility visibility)
{
const float hidden_width = 120;
switch (visibility)
{
case Visibility.Visible:
Background.FadeTo(0.9f, 500, Easing.OutQuint);
SectionsContainer.FadeOut(100);
ContentContainer.MoveToX(hidden_width - ContentContainer.DrawWidth, 500, Easing.OutQuint);
backButton.Delay(100).FadeIn(100);
break;
case Visibility.Hidden:
Background.FadeTo(0.6f, 500, Easing.OutQuint);
SectionsContainer.FadeIn(500, Easing.OutQuint);
ContentContainer.MoveToX(0, 500, Easing.OutQuint);
backButton.FadeOut(100);
break;
}
}
protected override void PopOut()
{
base.PopOut();
keyBindingOverlay.State = Visibility.Hidden;
}
[BackgroundDependencyLoader]
private void load()
{
AddInternal(keyBindingOverlay);
AddInternal(backButton = new BackButton
{
Alpha = 0,
Height = 150,
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Action = () => keyBindingOverlay.Hide()
});
}
protected override void UpdateAfterChildren()
{
base.UpdateAfterChildren();
keyBindingOverlay.Margin = new MarginPadding { Left = ContentContainer.Margin.Left + ContentContainer.DrawWidth + ContentContainer.X };
backButton.Margin = new MarginPadding { Left = ContentContainer.Margin.Left };
backButton.Width = ContentContainer.DrawWidth + ContentContainer.X;
}
private class BackButton : OsuClickableContainer
{
private FillFlowContainer flow;
private AspectContainer aspect;
[BackgroundDependencyLoader]
private void load()
{
Children = new Drawable[]
{
aspect = new AspectContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Y,
Children = new Drawable[]
{
flow = new FillFlowContainer
{
Anchor = Anchor.TopCentre,
RelativePositionAxes = Axes.Y,
Y = 0.4f,
AutoSizeAxes = Axes.Both,
Origin = Anchor.Centre,
Direction = FillDirection.Horizontal,
Children = new[]
{
new SpriteIcon { Size = new Vector2(15), Shadow = true, Icon = FontAwesome.fa_chevron_left },
new SpriteIcon { Size = new Vector2(15), Shadow = true, Icon = FontAwesome.fa_chevron_left },
new SpriteIcon { Size = new Vector2(15), Shadow = true, Icon = FontAwesome.fa_chevron_left },
}
},
new OsuSpriteText
{
Anchor = Anchor.TopCentre,
RelativePositionAxes = Axes.Y,
Y = 0.7f,
TextSize = 12,
Font = @"Exo2.0-Bold",
Origin = Anchor.Centre,
Text = @"back",
},
}
}
};
}
protected override bool OnHover(InputState state)
{
flow.TransformSpacingTo(new Vector2(5), 500, Easing.OutQuint);
return base.OnHover(state);
}
protected override void OnHoverLost(InputState state)
{
flow.TransformSpacingTo(new Vector2(0), 500, Easing.OutQuint);
base.OnHoverLost(state);
}
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
{
aspect.ScaleTo(0.75f, 2000, Easing.OutQuint);
return base.OnMouseDown(state, args);
}
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
{
aspect.ScaleTo(1, 1000, Easing.OutElastic);
return base.OnMouseUp(state, args);
}
}
}
}

View File

@ -26,8 +26,11 @@ namespace osu.Game.Overlays.Settings.Sections.Audio
{
base.Dispose(isDisposing);
audio.OnNewDevice -= onDeviceChanged;
audio.OnLostDevice -= onDeviceChanged;
if (audio != null)
{
audio.OnNewDevice -= onDeviceChanged;
audio.OnLostDevice -= onDeviceChanged;
}
}
private void updateItems()

View File

@ -10,14 +10,15 @@ namespace osu.Game.Overlays.Settings.Sections.Input
{
protected override string Header => "Keyboard";
public KeyboardSettings()
public KeyboardSettings(KeyBindingOverlay keyConfig)
{
Children = new Drawable[]
{
new OsuButton
{
RelativeSizeAxes = Axes.X,
Text = "Key Configuration"
Text = "Key Configuration",
Action = () => keyConfig.ToggleVisibility()
},
};
}

View File

@ -12,12 +12,12 @@ namespace osu.Game.Overlays.Settings.Sections
public override string Header => "Input";
public override FontAwesome Icon => FontAwesome.fa_keyboard_o;
public InputSection()
public InputSection(KeyBindingOverlay keyConfig)
{
Children = new Drawable[]
{
new MouseSettings(),
new KeyboardSettings(),
new KeyboardSettings(keyConfig),
};
}
}

View File

@ -29,6 +29,10 @@ namespace osu.Game.Overlays
private const float sidebar_padding = 10;
protected Container<Drawable> ContentContainer;
protected override Container<Drawable> Content => ContentContainer;
private Sidebar sidebar;
private SidebarButton selectedSidebarButton;
@ -40,6 +44,8 @@ namespace osu.Game.Overlays
private readonly bool showSidebar;
protected Box Background;
protected SettingsOverlay(bool showSidebar)
{
this.showSidebar = showSidebar;
@ -52,40 +58,43 @@ namespace osu.Game.Overlays
[BackgroundDependencyLoader(permitNulls: true)]
private void load(OsuGame game)
{
Children = new Drawable[]
InternalChild = ContentContainer = new Container
{
new Box
Width = width,
RelativeSizeAxes = Axes.Y,
Children = new Drawable[]
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
Alpha = 0.6f,
},
SectionsContainer = new SettingsSectionsContainer
{
RelativeSizeAxes = Axes.Y,
Width = width,
Margin = new MarginPadding { Left = SIDEBAR_WIDTH },
ExpandableHeader = CreateHeader(),
FixedHeader = searchTextBox = new SearchTextBox
Background = new Box
{
RelativeSizeAxes = Axes.X,
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Width = 0.95f,
Margin = new MarginPadding
{
Top = 20,
Bottom = 20
},
Exit = Hide,
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
Alpha = 0.6f,
},
Footer = CreateFooter()
},
SectionsContainer = new SettingsSectionsContainer
{
RelativeSizeAxes = Axes.Both,
ExpandableHeader = CreateHeader(),
FixedHeader = searchTextBox = new SearchTextBox
{
RelativeSizeAxes = Axes.X,
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Width = 0.95f,
Margin = new MarginPadding
{
Top = 20,
Bottom = 20
},
Exit = Hide,
},
Footer = CreateFooter()
},
}
};
if (showSidebar)
{
Add(sidebar = new Sidebar { Width = SIDEBAR_WIDTH });
AddInternal(sidebar = new Sidebar { Width = SIDEBAR_WIDTH });
SectionsContainer.SelectedSection.ValueChanged += section =>
{
@ -136,7 +145,7 @@ namespace osu.Game.Overlays
{
base.PopIn();
SectionsContainer.MoveToX(0, TRANSITION_LENGTH, Easing.OutQuint);
ContentContainer.MoveToX(0, TRANSITION_LENGTH, Easing.OutQuint);
sidebar?.MoveToX(0, TRANSITION_LENGTH, Easing.OutQuint);
this.FadeTo(1, TRANSITION_LENGTH / 2);
@ -147,7 +156,7 @@ namespace osu.Game.Overlays
{
base.PopOut();
SectionsContainer.MoveToX(-width, TRANSITION_LENGTH, Easing.OutQuint);
ContentContainer.MoveToX(-width, TRANSITION_LENGTH, Easing.OutQuint);
sidebar?.MoveToX(-SIDEBAR_WIDTH, TRANSITION_LENGTH, Easing.OutQuint);
this.FadeTo(0, TRANSITION_LENGTH / 2);
@ -170,8 +179,8 @@ namespace osu.Game.Overlays
{
base.UpdateAfterChildren();
SectionsContainer.Margin = new MarginPadding { Left = sidebar?.DrawWidth ?? 0 };
SectionsContainer.Padding = new MarginPadding { Top = getToolbarHeight() };
ContentContainer.Margin = new MarginPadding { Left = sidebar?.DrawWidth ?? 0 };
ContentContainer.Padding = new MarginPadding { Top = getToolbarHeight() };
}
protected class SettingsSectionsContainer : SectionsContainer<SettingsSection>

View File

@ -22,8 +22,6 @@ namespace osu.Game.Overlays.Toolbar
private readonly ToolbarUserArea userArea;
protected override bool HideOnEscape => false;
protected override bool BlockPassThroughMouse => false;
private const double transition_time = 500;

View File

@ -22,8 +22,6 @@ namespace osu.Game.Screens.Play
private const int button_height = 70;
private const float background_alpha = 0.75f;
protected override bool HideOnEscape => false;
protected override bool BlockPassThroughKeyboard => true;
public Action OnRetry;
@ -95,7 +93,8 @@ namespace osu.Game.Screens.Play
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Height = button_height,
Action = delegate {
Action = delegate
{
action?.Invoke();
Hide();
}

View File

@ -18,8 +18,6 @@ namespace osu.Game.Screens.Play
{
private const int bottom_bar_height = 5;
protected override bool HideOnEscape => false;
private static readonly Vector2 handle_size = new Vector2(14, 25);
private const float transition_duration = 200;

View File

@ -50,8 +50,6 @@ namespace osu.Game.Screens.Select
AlwaysPresent = true;
}
protected override bool HideOnEscape => false;
protected override bool BlockPassThroughMouse => false;
protected override void PopIn()