Merge pull request #1597 from peppy/new-sounds-and-more

Add new UI and menu samples
This commit is contained in:
Dean Herbert 2017-11-27 19:53:37 +09:00 committed by GitHub
commit f54cbc2b2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 330 additions and 206 deletions

@ -1 +1 @@
Subproject commit fe49ccb3c8f8661d653752d225ae1dc183944bb4 Subproject commit d92cec764538da2e7ed95bfb566f6bc81a9667c8

@ -1 +1 @@
Subproject commit 1750ab8f6761ab35592fd46da71fbe0c141bfd93 Subproject commit 4287ee8043fb1419017359bc3a5db5dc06bc643f

View File

@ -22,7 +22,7 @@ namespace osu.Game.Tests.Visual
Add(container = new ExampleContainer()); Add(container = new ExampleContainer());
AddStep(@"Add button", () => container.Add(new OsuButton AddStep(@"Add button", () => container.Add(new TriangleButton
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Text = @"Button", Text = @"Button",

View File

@ -3,6 +3,8 @@
using System; using System;
using osu.Framework; using osu.Framework;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
@ -10,6 +12,7 @@ using osu.Framework.Input;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.MathUtils;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics; using osu.Game.Graphics;
@ -60,11 +63,20 @@ namespace osu.Game.Beatmaps.Drawables
Alpha = 0; Alpha = 0;
} }
private SampleChannel sampleHover;
[BackgroundDependencyLoader]
private void load(AudioManager audio, OsuColour colours)
{
sampleHover = audio.Sample.Get($@"SongSelect/song-ping-variation-{RNG.Next(1, 5)}");
hoverLayer.Colour = colours.Blue.Opacity(0.1f);
}
protected override bool OnHover(InputState state) protected override bool OnHover(InputState state)
{ {
hoverLayer.FadeIn(100, Easing.OutQuint); sampleHover?.Play();
hoverLayer.FadeIn(100, Easing.OutQuint);
return base.OnHover(state); return base.OnHover(state);
} }
@ -74,12 +86,6 @@ namespace osu.Game.Beatmaps.Drawables
base.OnHoverLost(state); base.OnHoverLost(state);
} }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
hoverLayer.Colour = colours.Blue.Opacity(0.1f);
}
public void SetMultiplicativeAlpha(float alpha) public void SetMultiplicativeAlpha(float alpha)
{ {
borderContainer.Alpha = alpha; borderContainer.Alpha = alpha;

View File

@ -2,34 +2,39 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio; using osu.Framework.Graphics;
using osu.Framework.Audio.Sample;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Input; using osu.Game.Graphics.UserInterface;
namespace osu.Game.Graphics.Containers namespace osu.Game.Graphics.Containers
{ {
public class OsuClickableContainer : ClickableContainer public class OsuClickableContainer : ClickableContainer
{ {
protected SampleChannel SampleClick, SampleHover; private readonly HoverSampleSet sampleSet;
private readonly Container content = new Container { RelativeSizeAxes = Axes.Both };
protected override Container<Drawable> Content => content;
public OsuClickableContainer(HoverSampleSet sampleSet = HoverSampleSet.Normal)
{
this.sampleSet = sampleSet;
}
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(AudioManager audio) private void load()
{ {
SampleHover = audio.Sample.Get(@"UI/generic-hover"); if (AutoSizeAxes != Axes.None)
SampleClick = audio.Sample.Get(@"UI/generic-click"); {
} content.RelativeSizeAxes = RelativeSizeAxes;
content.AutoSizeAxes = AutoSizeAxes;
}
protected override bool OnHover(InputState state) InternalChildren = new Drawable[]
{ {
SampleHover?.Play(); content,
return base.OnHover(state); new HoverClickSounds(sampleSet)
} };
protected override bool OnClick(InputState state)
{
SampleClick?.Play();
return base.OnClick(state);
} }
} }
} }

View File

@ -16,8 +16,8 @@ namespace osu.Game.Graphics.Containers
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(AudioManager audio) private void load(AudioManager audio)
{ {
samplePopIn = audio.Sample.Get(@"UI/melodic-5"); samplePopIn = audio.Sample.Get(@"UI/overlay-pop-in");
samplePopOut = audio.Sample.Get(@"UI/melodic-4"); samplePopOut = audio.Sample.Get(@"UI/overlay-pop-out");
StateChanged += onStateChanged; StateChanged += onStateChanged;
} }

View File

@ -0,0 +1,36 @@
// 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.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Extensions;
using osu.Framework.Input;
namespace osu.Game.Graphics.UserInterface
{
/// <summary>
/// Adds hover and click sounds to a drawable.
/// Does not draw anything.
/// </summary>
public class HoverClickSounds : HoverSounds
{
private SampleChannel sampleClick;
public HoverClickSounds(HoverSampleSet sampleSet = HoverSampleSet.Normal) : base(sampleSet)
{
}
protected override bool OnClick(InputState state)
{
sampleClick?.Play();
return base.OnClick(state);
}
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
sampleClick = audio.Sample.Get($@"UI/generic-select{SampleSet.GetDescription()}");
}
}
}

View File

@ -0,0 +1,53 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.ComponentModel;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input;
namespace osu.Game.Graphics.UserInterface
{
/// <summary>
/// Adds hover sounds to a drawable.
/// Does not draw anything.
/// </summary>
public class HoverSounds : CompositeDrawable
{
private SampleChannel sampleHover;
protected readonly HoverSampleSet SampleSet;
public HoverSounds(HoverSampleSet sampleSet = HoverSampleSet.Normal)
{
SampleSet = sampleSet;
RelativeSizeAxes = Axes.Both;
}
protected override bool OnHover(InputState state)
{
sampleHover?.Play();
return base.OnHover(state);
}
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
sampleHover = audio.Sample.Get($@"UI/generic-hover{SampleSet.GetDescription()}");
}
}
public enum HoverSampleSet
{
[Description("")]
Loud,
[Description("-soft")]
Normal,
[Description("-softer")]
Soft
}
}

View File

@ -1,126 +1,18 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input;
using osu.Game.Graphics.Backgrounds;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Graphics.UserInterface namespace osu.Game.Graphics.UserInterface
{ {
public class OsuButton : Button, IFilterable /// <summary>
/// A button with added default sound effects.
/// </summary>
public class OsuButton : Button
{ {
private Box hover;
private SampleChannel sampleClick;
private SampleChannel sampleHover;
protected Triangles Triangles;
public OsuButton() public OsuButton()
{ {
Height = 40; Add(new HoverClickSounds(HoverSampleSet.Loud));
}
protected override SpriteText CreateText() => new OsuSpriteText
{
Depth = -1,
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Font = @"Exo2.0-Bold",
};
public override bool HandleInput => Action != null;
[BackgroundDependencyLoader]
private void load(OsuColour colours, AudioManager audio)
{
if (Action == null)
Colour = OsuColour.Gray(0.5f);
BackgroundColour = colours.BlueDark;
Content.Masking = true;
Content.CornerRadius = 5;
AddRange(new Drawable[]
{
Triangles = new Triangles
{
RelativeSizeAxes = Axes.Both,
ColourDark = colours.BlueDarker,
ColourLight = colours.Blue,
},
hover = new Box
{
RelativeSizeAxes = Axes.Both,
Blending = BlendingMode.Additive,
Colour = Color4.White.Opacity(0.1f),
Alpha = 0,
},
});
sampleClick = audio.Sample.Get(@"UI/generic-click");
sampleHover = audio.Sample.Get(@"UI/generic-hover");
Enabled.ValueChanged += enabled_ValueChanged;
Enabled.TriggerChange();
}
private void enabled_ValueChanged(bool enabled)
{
this.FadeColour(enabled ? Color4.White : Color4.Gray, 200, Easing.OutQuint);
}
protected override bool OnClick(InputState state)
{
sampleClick?.Play();
return base.OnClick(state);
}
protected override bool OnHover(InputState state)
{
sampleHover?.Play();
hover.FadeIn(200);
return base.OnHover(state);
}
protected override void OnHoverLost(InputState state)
{
hover.FadeOut(200);
base.OnHoverLost(state);
}
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
{
Content.ScaleTo(0.9f, 4000, Easing.OutQuint);
return base.OnMouseDown(state, args);
}
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
{
Content.ScaleTo(1, 1000, Easing.OutElastic);
return base.OnMouseUp(state, args);
}
public IEnumerable<string> FilterTerms => new[] { Text };
public bool MatchingFilter
{
set
{
this.FadeTo(value ? 1 : 0);
}
} }
} }
} }

View File

@ -70,7 +70,8 @@ namespace osu.Game.Graphics.UserInterface
Anchor = Anchor.CentreRight, Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight, Origin = Anchor.CentreRight,
Margin = new MarginPadding { Right = 5 }, Margin = new MarginPadding { Right = 5 },
} },
new HoverClickSounds()
}; };
Nub.Current.BindTo(Current); Nub.Current.BindTo(Current);

View File

@ -33,7 +33,6 @@ namespace osu.Game.Graphics.UserInterface
if (accentColour == default(Color4)) if (accentColour == default(Color4))
accentColour = colours.PinkDarker; accentColour = colours.PinkDarker;
updateAccentColour(); updateAccentColour();
} }
private void updateAccentColour() private void updateAccentColour()
@ -137,6 +136,8 @@ namespace osu.Game.Graphics.UserInterface
nonAccentHoverColour = colours.PinkDarker; nonAccentHoverColour = colours.PinkDarker;
nonAccentSelectedColour = Color4.Black.Opacity(0.5f); nonAccentSelectedColour = Color4.Black.Opacity(0.5f);
updateColours(); updateColours();
AddInternal(new HoverClickSounds(HoverSampleSet.Soft));
} }
protected override void UpdateForegroundColour() protected override void UpdateForegroundColour()
@ -183,7 +184,7 @@ namespace osu.Game.Graphics.UserInterface
{ {
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
} },
}; };
} }
} }
@ -237,8 +238,10 @@ namespace osu.Game.Graphics.UserInterface
Origin = Anchor.CentreRight, Origin = Anchor.CentreRight,
Margin = new MarginPadding { Right = 4 }, Margin = new MarginPadding { Right = 4 },
Size = new Vector2(20), Size = new Vector2(20),
} },
}; };
AddInternal(new HoverClickSounds());
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]

View File

@ -72,7 +72,7 @@ namespace osu.Game.Graphics.UserInterface
private void load(AudioManager audio) private void load(AudioManager audio)
{ {
sampleHover = audio.Sample.Get(@"UI/generic-hover"); sampleHover = audio.Sample.Get(@"UI/generic-hover");
sampleClick = audio.Sample.Get(@"UI/generic-click"); sampleClick = audio.Sample.Get(@"UI/generic-select");
BackgroundColour = Color4.Transparent; BackgroundColour = Color4.Transparent;
BackgroundColourHover = OsuColour.FromHex(@"172023"); BackgroundColourHover = OsuColour.FromHex(@"172023");

View File

@ -88,7 +88,8 @@ namespace osu.Game.Graphics.UserInterface
{ {
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,
Expanded = true, Expanded = true,
} },
new HoverClickSounds()
}; };
Current.DisabledChanged += disabled => Current.DisabledChanged += disabled =>

View File

@ -131,7 +131,8 @@ namespace osu.Game.Graphics.UserInterface
Colour = Color4.White, Colour = Color4.White,
Origin = Anchor.BottomLeft, Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
} },
new HoverClickSounds()
}; };
} }

View File

@ -57,6 +57,7 @@ namespace osu.Game.Graphics.UserInterface
Origin = Anchor.BottomLeft, Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
}, },
new HoverClickSounds()
}; };
} }

View File

@ -0,0 +1,108 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input;
using osu.Game.Graphics.Backgrounds;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Graphics.UserInterface
{
/// <summary>
/// A button with moving triangles in the background.
/// </summary>
public class TriangleButton : OsuButton, IFilterable
{
private Box hover;
protected Triangles Triangles;
public TriangleButton()
{
Height = 40;
}
protected override SpriteText CreateText() => new OsuSpriteText
{
Depth = -1,
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Font = @"Exo2.0-Bold",
};
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
BackgroundColour = colours.BlueDark;
Content.Masking = true;
Content.CornerRadius = 5;
AddRange(new Drawable[]
{
Triangles = new Triangles
{
RelativeSizeAxes = Axes.Both,
ColourDark = colours.BlueDarker,
ColourLight = colours.Blue,
},
hover = new Box
{
RelativeSizeAxes = Axes.Both,
Blending = BlendingMode.Additive,
Colour = Color4.White.Opacity(0.1f),
Alpha = 0,
},
});
Enabled.ValueChanged += enabled_ValueChanged;
Enabled.TriggerChange();
}
private void enabled_ValueChanged(bool enabled)
{
this.FadeColour(enabled ? Color4.White : Color4.Gray, 200, Easing.OutQuint);
}
protected override bool OnHover(InputState state)
{
hover.FadeIn(200);
return base.OnHover(state);
}
protected override void OnHoverLost(InputState state)
{
hover.FadeOut(200);
base.OnHoverLost(state);
}
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
{
Content.ScaleTo(0.9f, 4000, Easing.OutQuint);
return base.OnMouseDown(state, args);
}
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
{
Content.ScaleTo(1, 1000, Easing.OutElastic);
return base.OnMouseUp(state, args);
}
public IEnumerable<string> FilterTerms => new[] { Text };
public bool MatchingFilter
{
set
{
this.FadeTo(value ? 1 : 0);
}
}
}
}

View File

@ -222,7 +222,7 @@ namespace osu.Game.Overlays.Chat
} }
private class MessageSender : ClickableContainer, IHasContextMenu private class MessageSender : OsuClickableContainer, IHasContextMenu
{ {
private readonly User sender; private readonly User sender;

View File

@ -17,6 +17,7 @@ using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using System; using System;
using osu.Game.Graphics.Containers;
namespace osu.Game.Overlays.Chat namespace osu.Game.Overlays.Chat
{ {
@ -259,7 +260,7 @@ namespace osu.Game.Overlays.Chat
}; };
} }
public class CloseButton : ClickableContainer public class CloseButton : OsuClickableContainer
{ {
private readonly SpriteIcon icon; private readonly SpriteIcon icon;

View File

@ -55,7 +55,7 @@ namespace osu.Game.Overlays.KeyBinding
} }
} }
public class ResetButton : OsuButton public class ResetButton : TriangleButton
{ {
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)

View File

@ -17,6 +17,7 @@ using osu.Game.Rulesets.UI;
using System; using System;
using System.Linq; using System.Linq;
using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Cursor;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.Mods namespace osu.Game.Overlays.Mods
{ {
@ -148,7 +149,7 @@ namespace osu.Game.Overlays.Mods
// the mods from Mod, only multiple if Mod is a MultiMod // the mods from Mod, only multiple if Mod is a MultiMod
public override Mod SelectedMod => Mods.ElementAtOrDefault(SelectedIndex); public virtual Mod SelectedMod => Mods.ElementAtOrDefault(SelectedIndex);
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(AudioManager audio) private void load(AudioManager audio)
@ -253,6 +254,7 @@ namespace osu.Game.Overlays.Mods
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,
TextSize = 18, TextSize = 18,
}, },
new HoverClickSounds()
}; };
Mod = mod; Mod = mod;

View File

@ -3,7 +3,6 @@
using OpenTK; using OpenTK;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Mods;
namespace osu.Game.Overlays.Mods namespace osu.Game.Overlays.Mods
{ {
@ -12,8 +11,6 @@ namespace osu.Game.Overlays.Mods
/// </summary> /// </summary>
public class ModButtonEmpty : Container public class ModButtonEmpty : Container
{ {
public virtual Mod SelectedMod => null;
public ModButtonEmpty() public ModButtonEmpty()
{ {
Size = new Vector2(100f); Size = new Vector2(100f);

View File

@ -12,9 +12,9 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
{ {
public class GeneralSettings : SettingsSubsection public class GeneralSettings : SettingsSubsection
{ {
private OsuButton importButton; private TriangleButton importButton;
private OsuButton deleteButton; private TriangleButton deleteButton;
private OsuButton restoreButton; private TriangleButton restoreButton;
protected override string Header => "General"; protected override string Header => "General";

View File

@ -6,7 +6,7 @@ using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.Settings namespace osu.Game.Overlays.Settings
{ {
public class SettingsButton : OsuButton public class SettingsButton : TriangleButton
{ {
public SettingsButton() public SettingsButton()
{ {

View File

@ -12,14 +12,14 @@ using osu.Framework.Graphics.Sprites;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.Settings namespace osu.Game.Overlays.Settings
{ {
public class SidebarButton : Container public class SidebarButton : OsuButton
{ {
private readonly SpriteIcon drawableIcon; private readonly SpriteIcon drawableIcon;
private readonly SpriteText headerText; private readonly SpriteText headerText;
private readonly Box backgroundBox;
private readonly Box selectionIndicator; private readonly Box selectionIndicator;
private readonly Container text; private readonly Container text;
public Action<SettingsSection> Action; public Action<SettingsSection> Action;
@ -61,17 +61,14 @@ namespace osu.Game.Overlays.Settings
public SidebarButton() public SidebarButton()
{ {
BackgroundColour = OsuColour.Gray(60);
Background.Alpha = 0;
Height = Sidebar.DEFAULT_WIDTH; Height = Sidebar.DEFAULT_WIDTH;
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
Children = new Drawable[]
AddRange(new Drawable[]
{ {
backgroundBox = new Box
{
RelativeSizeAxes = Axes.Both,
Blending = BlendingMode.Additive,
Colour = OsuColour.Gray(60),
Alpha = 0,
},
text = new Container text = new Container
{ {
Width = Sidebar.DEFAULT_WIDTH, Width = Sidebar.DEFAULT_WIDTH,
@ -101,7 +98,7 @@ namespace osu.Game.Overlays.Settings
Anchor = Anchor.CentreRight, Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight, Origin = Anchor.CentreRight,
} }
}; });
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
@ -113,20 +110,19 @@ namespace osu.Game.Overlays.Settings
protected override bool OnClick(InputState state) protected override bool OnClick(InputState state)
{ {
Action?.Invoke(section); Action?.Invoke(section);
backgroundBox.FlashColour(Color4.White, 400); return base.OnClick(state);
return true;
} }
protected override bool OnHover(InputState state) protected override bool OnHover(InputState state)
{ {
backgroundBox.FadeTo(0.4f, 200); Background.FadeTo(0.4f, 200);
return base.OnHover(state); return base.OnHover(state);
} }
protected override void OnHoverLost(InputState state) protected override void OnHoverLost(InputState state)
{ {
backgroundBox.FadeTo(0, 200); Background.FadeTo(0, 200);
base.OnHoverLost(state); base.OnHoverLost(state);
} }
} }
} }

View File

@ -13,6 +13,7 @@ using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.Toolbar namespace osu.Game.Overlays.Toolbar
{ {
@ -74,7 +75,7 @@ namespace osu.Game.Overlays.Toolbar
private readonly SpriteText tooltip2; private readonly SpriteText tooltip2;
protected FillFlowContainer Flow; protected FillFlowContainer Flow;
public ToolbarButton() public ToolbarButton() : base(HoverSampleSet.Loud)
{ {
Width = WIDTH; Width = WIDTH;
RelativeSizeAxes = Axes.Y; RelativeSizeAxes = Axes.Y;
@ -195,4 +196,4 @@ namespace osu.Game.Overlays.Toolbar
}; };
} }
} }
} }

View File

@ -174,7 +174,7 @@ namespace osu.Game.Screens.Menu
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(AudioManager audio) private void load(AudioManager audio)
{ {
sampleHover = audio.Sample.Get(@"Menu/hover"); sampleHover = audio.Sample.Get(@"Menu/button-hover");
if (!string.IsNullOrEmpty(sampleName)) if (!string.IsNullOrEmpty(sampleName))
sampleClick = audio.Sample.Get($@"Menu/{sampleName}"); sampleClick = audio.Sample.Get($@"Menu/{sampleName}");
} }

View File

@ -117,13 +117,13 @@ namespace osu.Game.Screens.Menu
}, },
}; };
buttonsPlay.Add(new Button(@"solo", @"select-6", FontAwesome.fa_user, new Color4(102, 68, 204, 255), () => OnSolo?.Invoke(), WEDGE_WIDTH, Key.P)); buttonsPlay.Add(new Button(@"solo", @"button-solo-select", FontAwesome.fa_user, new Color4(102, 68, 204, 255), () => OnSolo?.Invoke(), WEDGE_WIDTH, Key.P));
buttonsPlay.Add(new Button(@"multi", @"select-5", FontAwesome.fa_users, new Color4(94, 63, 186, 255), () => OnMulti?.Invoke(), 0, Key.M)); buttonsPlay.Add(new Button(@"multi", @"button-generic-select", FontAwesome.fa_users, new Color4(94, 63, 186, 255), () => OnMulti?.Invoke(), 0, Key.M));
buttonsPlay.Add(new Button(@"chart", @"select-5", FontAwesome.fa_osu_charts, new Color4(80, 53, 160, 255), () => OnChart?.Invoke())); buttonsPlay.Add(new Button(@"chart", @"button-generic-select", FontAwesome.fa_osu_charts, new Color4(80, 53, 160, 255), () => OnChart?.Invoke()));
buttonsTopLevel.Add(new Button(@"play", @"select-1", FontAwesome.fa_osu_logo, new Color4(102, 68, 204, 255), onPlay, WEDGE_WIDTH, Key.P)); buttonsTopLevel.Add(new Button(@"play", @"button-play-select", FontAwesome.fa_osu_logo, new Color4(102, 68, 204, 255), onPlay, WEDGE_WIDTH, Key.P));
buttonsTopLevel.Add(new Button(@"osu!editor", @"select-5", FontAwesome.fa_osu_edit_o, new Color4(238, 170, 0, 255), () => OnEdit?.Invoke(), 0, Key.E)); buttonsTopLevel.Add(new Button(@"osu!editor", @"button-generic-select", FontAwesome.fa_osu_edit_o, new Color4(238, 170, 0, 255), () => OnEdit?.Invoke(), 0, Key.E));
buttonsTopLevel.Add(new Button(@"osu!direct", string.Empty, FontAwesome.fa_osu_chevron_down_o, new Color4(165, 204, 0, 255), () => OnDirect?.Invoke(), 0, Key.D)); buttonsTopLevel.Add(new Button(@"osu!direct", @"button-direct-select", FontAwesome.fa_osu_chevron_down_o, new Color4(165, 204, 0, 255), () => OnDirect?.Invoke(), 0, Key.D));
buttonsTopLevel.Add(new Button(@"exit", string.Empty, FontAwesome.fa_osu_cross_o, new Color4(238, 51, 153, 255), onExit, 0, Key.Q)); buttonsTopLevel.Add(new Button(@"exit", string.Empty, FontAwesome.fa_osu_cross_o, new Color4(238, 51, 153, 255), onExit, 0, Key.Q));
buttonFlow.AddRange(buttonsPlay); buttonFlow.AddRange(buttonsPlay);
@ -134,7 +134,7 @@ namespace osu.Game.Screens.Menu
private void load(AudioManager audio, OsuGame game = null) private void load(AudioManager audio, OsuGame game = null)
{ {
toolbar = game?.Toolbar; toolbar = game?.Toolbar;
sampleBack = audio.Sample.Get(@"Menu/select-4"); sampleBack = audio.Sample.Get(@"Menu/button-back-select");
} }
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
@ -180,19 +180,21 @@ namespace osu.Game.Screens.Menu
State = MenuState.TopLevel; State = MenuState.TopLevel;
} }
private void onOsuLogo() private bool onOsuLogo()
{ {
switch (state) switch (state)
{ {
default:
return true;
case MenuState.Initial: case MenuState.Initial:
State = MenuState.TopLevel; State = MenuState.TopLevel;
return; return true;
case MenuState.TopLevel: case MenuState.TopLevel:
buttonsTopLevel.First().TriggerOnClick(); buttonsTopLevel.First().TriggerOnClick();
return; return false;
case MenuState.Play: case MenuState.Play:
buttonsPlay.First().TriggerOnClick(); buttonsPlay.First().TriggerOnClick();
return; return false;
} }
} }

View File

@ -48,7 +48,10 @@ namespace osu.Game.Screens.Menu
private readonly Triangles triangles; private readonly Triangles triangles;
public Action Action; /// <summary>
/// Return value decides whether the logo should play its own sample for the click action.
/// </summary>
public Func<bool> Action;
public float SizeForFlow => logo == null ? 0 : logo.DrawSize.X * logo.Scale.X * logoBounceContainer.Scale.X * logoHoverContainer.Scale.X * 0.74f; public float SizeForFlow => logo == null ? 0 : logo.DrawSize.X * logo.Scale.X * logoBounceContainer.Scale.X * logoHoverContainer.Scale.X * 0.74f;
@ -248,8 +251,8 @@ namespace osu.Game.Screens.Menu
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(TextureStore textures, AudioManager audio) private void load(TextureStore textures, AudioManager audio)
{ {
sampleClick = audio.Sample.Get(@"Menu/select-2"); sampleClick = audio.Sample.Get(@"Menu/osu-logo-select");
sampleBeat = audio.Sample.Get(@"Menu/heartbeat"); sampleBeat = audio.Sample.Get(@"Menu/osu-logo-heartbeat");
logo.Texture = textures.Get(@"Menu/logo"); logo.Texture = textures.Get(@"Menu/logo");
ripple.Texture = textures.Get(@"Menu/logo"); ripple.Texture = textures.Get(@"Menu/logo");
@ -354,13 +357,12 @@ namespace osu.Game.Screens.Menu
{ {
if (!interactive) return false; if (!interactive) return false;
sampleClick.Play(); if (Action?.Invoke() ?? true)
sampleClick.Play();
flashLayer.ClearTransforms(); flashLayer.ClearTransforms();
flashLayer.Alpha = 0.4f; flashLayer.Alpha = 0.4f;
flashLayer.FadeOut(1500, Easing.OutExpo); flashLayer.FadeOut(1500, Easing.OutExpo);
Action?.Invoke();
return true; return true;
} }

View File

@ -70,7 +70,7 @@ namespace osu.Game.Screens
if (osuGame != null) if (osuGame != null)
Ruleset.BindTo(osuGame.Ruleset); Ruleset.BindTo(osuGame.Ruleset);
sampleExit = audio.Sample.Get(@"UI/melodic-1"); sampleExit = audio.Sample.Get(@"UI/screen-back");
} }
protected override void OnResuming(Screen last) protected override void OnResuming(Screen last)

View File

@ -4,6 +4,8 @@
using System.Linq; using System.Linq;
using OpenTK.Input; using OpenTK.Input;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Input; using osu.Framework.Input;
@ -42,9 +44,13 @@ namespace osu.Game.Screens.Select
beatmapDetails.Leaderboard.ScoreSelected += s => Push(new Results(s)); beatmapDetails.Leaderboard.ScoreSelected += s => Push(new Results(s));
} }
private SampleChannel sampleConfirm;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours, AudioManager audio)
{ {
sampleConfirm = audio.Sample.Get(@"SongSelect/confirm-selection");
Footer.AddButton(@"mods", colours.Yellow, modSelect, Key.F1, float.MaxValue); Footer.AddButton(@"mods", colours.Yellow, modSelect, Key.F1, float.MaxValue);
BeatmapOptions.AddButton(@"Remove", @"from unplayed", FontAwesome.fa_times_circle_o, colours.Purple, null, Key.Number1); BeatmapOptions.AddButton(@"Remove", @"from unplayed", FontAwesome.fa_times_circle_o, colours.Purple, null, Key.Number1);
@ -128,6 +134,8 @@ namespace osu.Game.Screens.Select
Beatmap.Value.Track.Looping = false; Beatmap.Value.Track.Looping = false;
Beatmap.Disabled = true; Beatmap.Disabled = true;
sampleConfirm?.Play();
LoadComponentAsync(player = new PlayerLoader(new Player()), l => Push(player)); LoadComponentAsync(player = new PlayerLoader(new Player()), l => Push(player));
} }
} }

View File

@ -332,7 +332,11 @@ namespace osu.Game.Screens.Select
logo.FadeIn(logo_transition, Easing.OutQuint); logo.FadeIn(logo_transition, Easing.OutQuint);
logo.ScaleTo(0.4f, logo_transition, Easing.OutQuint); logo.ScaleTo(0.4f, logo_transition, Easing.OutQuint);
logo.Action = () => carouselRaisedStart(); logo.Action = () =>
{
carouselRaisedStart();
return false;
};
} }
protected override void LogoExiting(OsuLogo logo) protected override void LogoExiting(OsuLogo logo)

View File

@ -193,21 +193,21 @@ namespace osu.Game.Screens.Tournament
Children = new Drawable[] Children = new Drawable[]
{ {
new OsuButton new TriangleButton
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Text = "Begin random", Text = "Begin random",
Action = teamsContainer.StartScrolling, Action = teamsContainer.StartScrolling,
}, },
new OsuButton new TriangleButton
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Text = "Stop random", Text = "Stop random",
Action = teamsContainer.StopScrolling, Action = teamsContainer.StopScrolling,
}, },
new OsuButton new TriangleButton
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
@ -232,7 +232,7 @@ namespace osu.Game.Screens.Tournament
Children = new Drawable[] Children = new Drawable[]
{ {
new OsuButton new TriangleButton
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,

View File

@ -17,10 +17,11 @@ using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Cursor;
using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Backgrounds;
using osu.Game.Graphics.Containers;
namespace osu.Game.Users namespace osu.Game.Users
{ {
public class UserPanel : ClickableContainer, IHasContextMenu public class UserPanel : OsuClickableContainer, IHasContextMenu
{ {
private readonly User user; private readonly User user;
private const float height = 100; private const float height = 100;

View File

@ -271,6 +271,9 @@
<Compile Include="Beatmaps\Drawables\BeatmapSetHeader.cs" /> <Compile Include="Beatmaps\Drawables\BeatmapSetHeader.cs" />
<Compile Include="Database\DatabaseContextFactory.cs" /> <Compile Include="Database\DatabaseContextFactory.cs" />
<Compile Include="Database\IHasPrimaryKey.cs" /> <Compile Include="Database\IHasPrimaryKey.cs" />
<Compile Include="Graphics\UserInterface\HoverClickSounds.cs" />
<Compile Include="Graphics\UserInterface\HoverSounds.cs" />
<Compile Include="Graphics\UserInterface\OsuButton.cs" />
<Compile Include="Migrations\20171019041408_InitialCreate.cs" /> <Compile Include="Migrations\20171019041408_InitialCreate.cs" />
<Compile Include="Migrations\20171019041408_InitialCreate.Designer.cs"> <Compile Include="Migrations\20171019041408_InitialCreate.Designer.cs">
<DependentUpon>20171019041408_InitialCreate.cs</DependentUpon> <DependentUpon>20171019041408_InitialCreate.cs</DependentUpon>
@ -366,7 +369,7 @@
<Compile Include="Graphics\UserInterface\LoadingAnimation.cs" /> <Compile Include="Graphics\UserInterface\LoadingAnimation.cs" />
<Compile Include="Graphics\UserInterface\MenuItemType.cs" /> <Compile Include="Graphics\UserInterface\MenuItemType.cs" />
<Compile Include="Graphics\UserInterface\Nub.cs" /> <Compile Include="Graphics\UserInterface\Nub.cs" />
<Compile Include="Graphics\UserInterface\OsuButton.cs" /> <Compile Include="Graphics\UserInterface\TriangleButton.cs" />
<Compile Include="Graphics\UserInterface\OsuCheckbox.cs" /> <Compile Include="Graphics\UserInterface\OsuCheckbox.cs" />
<Compile Include="Graphics\UserInterface\OsuContextMenu.cs" /> <Compile Include="Graphics\UserInterface\OsuContextMenu.cs" />
<Compile Include="Graphics\UserInterface\OsuDropdown.cs" /> <Compile Include="Graphics\UserInterface\OsuDropdown.cs" />