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

Merge pull request #14067 from nekodex/select-sfx-changes

Swap 'select' sample variants and add hover+select sounds to more components
This commit is contained in:
Dean Herbert 2021-07-31 20:03:08 +09:00 committed by GitHub
commit 48b95ae250
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 119 additions and 45 deletions

View File

@ -51,7 +51,7 @@
<Reference Include="Java.Interop" /> <Reference Include="Java.Interop" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.722.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2021.730.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2021.728.0" /> <PackageReference Include="ppy.osu.Framework.Android" Version="2021.728.0" />
</ItemGroup> </ItemGroup>
<ItemGroup Label="Transitive Dependencies"> <ItemGroup Label="Transitive Dependencies">

View File

@ -7,6 +7,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Graphics.UserInterface;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
@ -59,33 +60,37 @@ namespace osu.Game.Graphics.Containers
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
InternalChild = new GridContainer InternalChildren = new Drawable[]
{ {
RelativeSizeAxes = Axes.X, new GridContainer
AutoSizeAxes = Axes.Y,
Content = new[]
{ {
new[] RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Content = new[]
{ {
handleContainer = new Container new[]
{ {
Anchor = Anchor.Centre, handleContainer = new Container
Origin = Anchor.Centre,
AutoSizeAxes = Axes.Both,
Padding = new MarginPadding { Horizontal = 5 },
Child = handle = new PlaylistItemHandle
{ {
Size = new Vector2(12), Anchor = Anchor.Centre,
Colour = HandleColour, Origin = Anchor.Centre,
AlwaysPresent = true, AutoSizeAxes = Axes.Both,
Alpha = 0 Padding = new MarginPadding { Horizontal = 5 },
} Child = handle = new PlaylistItemHandle
}, {
CreateContent() Size = new Vector2(12),
} Colour = HandleColour,
AlwaysPresent = true,
Alpha = 0
}
},
CreateContent()
}
},
ColumnDimensions = new[] { new Dimension(GridSizeMode.AutoSize) },
RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }
}, },
ColumnDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }, new HoverClickSounds()
RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }
}; };
} }

View File

@ -20,7 +20,7 @@ namespace osu.Game.Graphics.UserInterface
{ {
Size = TwoLayerButton.SIZE_EXTENDED; Size = TwoLayerButton.SIZE_EXTENDED;
Child = button = new TwoLayerButton Child = button = new TwoLayerButton(HoverSampleSet.Submit)
{ {
Anchor = Anchor.TopLeft, Anchor = Anchor.TopLeft,
Origin = Anchor.TopLeft, Origin = Anchor.TopLeft,

View File

@ -56,6 +56,7 @@ namespace osu.Game.Graphics.UserInterface
private Vector2 hoverSpacing => new Vector2(3f, 0f); private Vector2 hoverSpacing => new Vector2(3f, 0f);
public DialogButton() public DialogButton()
: base(HoverSampleSet.Submit)
{ {
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;

View File

@ -23,14 +23,20 @@ namespace osu.Game.Graphics.UserInterface
[Resolved] [Resolved]
private GameHost host { get; set; } private GameHost host { get; set; }
private readonly SpriteIcon linkIcon;
public ExternalLinkButton(string link = null) public ExternalLinkButton(string link = null)
{ {
Link = link; Link = link;
Size = new Vector2(12); Size = new Vector2(12);
InternalChild = new SpriteIcon InternalChildren = new Drawable[]
{ {
Icon = FontAwesome.Solid.ExternalLinkAlt, linkIcon = new SpriteIcon
RelativeSizeAxes = Axes.Both {
Icon = FontAwesome.Solid.ExternalLinkAlt,
RelativeSizeAxes = Axes.Both
},
new HoverClickSounds(HoverSampleSet.Submit)
}; };
} }
@ -42,13 +48,13 @@ namespace osu.Game.Graphics.UserInterface
protected override bool OnHover(HoverEvent e) protected override bool OnHover(HoverEvent e)
{ {
InternalChild.FadeColour(hoverColour, 500, Easing.OutQuint); linkIcon.FadeColour(hoverColour, 500, Easing.OutQuint);
return base.OnHover(e); return base.OnHover(e);
} }
protected override void OnHoverLost(HoverLostEvent e) protected override void OnHoverLost(HoverLostEvent e)
{ {
InternalChild.FadeColour(Color4.White, 500, Easing.OutQuint); linkIcon.FadeColour(Color4.White, 500, Easing.OutQuint);
base.OnHoverLost(e); base.OnHoverLost(e);
} }

View File

@ -10,8 +10,8 @@ namespace osu.Game.Graphics.UserInterface
[Description("default")] [Description("default")]
Default, Default,
[Description("soft")] [Description("submit")]
Soft, Submit,
[Description("button")] [Description("button")]
Button, Button,

View File

@ -71,7 +71,8 @@ namespace osu.Game.Graphics.UserInterface
} }
} }
public TwoLayerButton() public TwoLayerButton(HoverSampleSet sampleSet = HoverSampleSet.Default)
: base(sampleSet)
{ {
Size = SIZE_RETRACTED; Size = SIZE_RETRACTED;
Shear = shear; Shear = shear;

View File

@ -32,7 +32,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
{ {
Depth = 1 Depth = 1
}, },
new HoverClickSounds(HoverSampleSet.Soft) new HoverClickSounds()
}); });
} }

View File

@ -57,7 +57,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
{ {
Depth = 1 Depth = 1
}, },
new HoverClickSounds(HoverSampleSet.Soft) new HoverClickSounds()
}); });
} }

View File

@ -31,6 +31,7 @@ namespace osu.Game.Online.Chat
protected override HoverSounds CreateHoverSounds(HoverSampleSet sampleSet) => new LinkHoverSounds(sampleSet, Parts); protected override HoverSounds CreateHoverSounds(HoverSampleSet sampleSet) => new LinkHoverSounds(sampleSet, Parts);
public DrawableLinkCompiler(IEnumerable<Drawable> parts) public DrawableLinkCompiler(IEnumerable<Drawable> parts)
: base(HoverSampleSet.Submit)
{ {
Parts = parts.ToList(); Parts = parts.ToList();
} }

View File

@ -50,6 +50,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels
protected Action ViewBeatmap; protected Action ViewBeatmap;
protected BeatmapPanel(BeatmapSetInfo setInfo) protected BeatmapPanel(BeatmapSetInfo setInfo)
: base(HoverSampleSet.Submit)
{ {
Debug.Assert(setInfo.OnlineBeatmapSetID != null); Debug.Assert(setInfo.OnlineBeatmapSetID != null);

View File

@ -3,6 +3,9 @@
using System; using System;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Extensions;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
@ -13,6 +16,7 @@ using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.Chat; using osu.Game.Online.Chat;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
@ -39,6 +43,8 @@ namespace osu.Game.Overlays.Chat.Tabs
protected override Container<Drawable> Content => content; protected override Container<Drawable> Content => content;
private Sample sampleTabSwitched;
public ChannelTabItem(Channel value) public ChannelTabItem(Channel value)
: base(value) : base(value)
{ {
@ -112,6 +118,7 @@ namespace osu.Game.Overlays.Chat.Tabs
}, },
}, },
}, },
new HoverSounds()
}; };
} }
@ -152,11 +159,12 @@ namespace osu.Game.Overlays.Chat.Tabs
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours, AudioManager audio)
{ {
BackgroundActive = colours.ChatBlue; BackgroundActive = colours.ChatBlue;
BackgroundInactive = colours.Gray4; BackgroundInactive = colours.Gray4;
backgroundHover = colours.Gray7; backgroundHover = colours.Gray7;
sampleTabSwitched = audio.Samples.Get($@"UI/{HoverSampleSet.Default.GetDescription()}-select");
highlightBox.Colour = colours.Yellow; highlightBox.Colour = colours.Yellow;
} }
@ -217,7 +225,14 @@ namespace osu.Game.Overlays.Chat.Tabs
Text.Font = Text.Font.With(weight: FontWeight.Medium); Text.Font = Text.Font.With(weight: FontWeight.Medium);
} }
protected override void OnActivated() => updateState(); protected override void OnActivated()
{
if (IsLoaded)
sampleTabSwitched?.Play();
updateState();
}
protected override void OnDeactivated() => updateState(); protected override void OnDeactivated() => updateState();
} }
} }

View File

@ -25,7 +25,7 @@ namespace osu.Game.Overlays.Chat.Tabs
if (value.Type != ChannelType.PM) if (value.Type != ChannelType.PM)
throw new ArgumentException("Argument value needs to have the targettype user!"); throw new ArgumentException("Argument value needs to have the targettype user!");
ClickableAvatar avatar; DrawableAvatar avatar;
AddRange(new Drawable[] AddRange(new Drawable[]
{ {
@ -48,10 +48,9 @@ namespace osu.Game.Overlays.Chat.Tabs
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Masking = true, Masking = true,
Child = new DelayedLoadWrapper(avatar = new ClickableAvatar(value.Users.First()) Child = new DelayedLoadWrapper(avatar = new DrawableAvatar(value.Users.First())
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both
OpenOnClick = false,
}) })
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,

View File

@ -14,6 +14,7 @@ using osu.Framework.Platform;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
namespace osu.Game.Overlays.News namespace osu.Game.Overlays.News
@ -28,6 +29,7 @@ namespace osu.Game.Overlays.News
private TextFlowContainer main; private TextFlowContainer main;
public NewsCard(APINewsPost post) public NewsCard(APINewsPost post)
: base(HoverSampleSet.Submit)
{ {
this.post = post; this.post = post;

View File

@ -15,13 +15,18 @@ using System.Collections.Generic;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using System.Diagnostics; using System.Diagnostics;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.News.Sidebar namespace osu.Game.Overlays.News.Sidebar
{ {
public class MonthSection : CompositeDrawable public class MonthSection : CompositeDrawable
{ {
private const int animation_duration = 250; private const int animation_duration = 250;
private Sample sampleOpen;
private Sample sampleClose;
public readonly BindableBool Expanded = new BindableBool(); public readonly BindableBool Expanded = new BindableBool();
@ -51,6 +56,21 @@ namespace osu.Game.Overlays.News.Sidebar
} }
} }
}; };
Expanded.ValueChanged += expanded =>
{
if (expanded.NewValue)
sampleOpen?.Play();
else
sampleClose?.Play();
};
}
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
sampleOpen = audio.Samples.Get(@"UI/dropdown-open");
sampleClose = audio.Samples.Get(@"UI/dropdown-close");
} }
private class DropdownHeader : OsuClickableContainer private class DropdownHeader : OsuClickableContainer
@ -59,6 +79,8 @@ namespace osu.Game.Overlays.News.Sidebar
private readonly SpriteIcon icon; private readonly SpriteIcon icon;
protected override HoverSounds CreateHoverSounds(HoverSampleSet sampleSet) => new HoverSounds();
public DropdownHeader(int month, int year) public DropdownHeader(int month, int year)
{ {
var date = new DateTime(year, month, 1); var date = new DateTime(year, month, 1);
@ -104,6 +126,7 @@ namespace osu.Game.Overlays.News.Sidebar
private readonly APINewsPost post; private readonly APINewsPost post;
public PostButton(APINewsPost post) public PostButton(APINewsPost post)
: base(HoverSampleSet.Submit)
{ {
this.post = post; this.post = post;

View File

@ -6,6 +6,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.Profile.Sections namespace osu.Game.Overlays.Profile.Sections
{ {
@ -17,6 +18,7 @@ namespace osu.Game.Overlays.Profile.Sections
private readonly BeatmapInfo beatmap; private readonly BeatmapInfo beatmap;
protected BeatmapMetadataContainer(BeatmapInfo beatmap) protected BeatmapMetadataContainer(BeatmapInfo beatmap)
: base(HoverSampleSet.Submit)
{ {
this.beatmap = beatmap; this.beatmap = beatmap;

View File

@ -138,7 +138,8 @@ namespace osu.Game.Overlays.Settings.Sections.Input
}, },
} }
} }
} },
new HoverClickSounds()
}; };
foreach (var b in bindings) foreach (var b in bindings)
@ -458,6 +459,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
Origin = Anchor.Centre, Origin = Anchor.Centre,
Text = keyBinding.KeyCombination.ReadableString(), Text = keyBinding.KeyCombination.ReadableString(),
}, },
new HoverSounds()
}; };
} }

View File

@ -11,7 +11,6 @@ using osu.Framework.Localisation;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays; using osu.Game.Overlays;
using osuTK.Graphics; using osuTK.Graphics;
@ -67,7 +66,6 @@ namespace osu.Game.Screens.Edit
private EditorClock clock { get; set; } private EditorClock clock { get; set; }
public RowBackground(object item) public RowBackground(object item)
: base(HoverSampleSet.Soft)
{ {
Item = item; Item = item;

View File

@ -14,6 +14,7 @@ using osu.Game.Graphics.Sprites;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Screens.Select.Options namespace osu.Game.Screens.Select.Options
{ {
@ -76,6 +77,7 @@ namespace osu.Game.Screens.Select.Options
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => box.ReceivePositionalInputAt(screenSpacePos); public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => box.ReceivePositionalInputAt(screenSpacePos);
public BeatmapOptionsButton() public BeatmapOptionsButton()
: base(HoverSampleSet.Submit)
{ {
Width = width; Width = width;
RelativeSizeAxes = Axes.Y; RelativeSizeAxes = Axes.Y;

View File

@ -8,6 +8,7 @@ using osu.Framework.Graphics.Textures;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Users.Drawables namespace osu.Game.Users.Drawables
{ {
@ -71,6 +72,11 @@ namespace osu.Game.Users.Drawables
{ {
private LocalisableString tooltip = default_tooltip_text; private LocalisableString tooltip = default_tooltip_text;
public ClickableArea()
: base(HoverSampleSet.Submit)
{
}
public override LocalisableString TooltipText public override LocalisableString TooltipText
{ {
get => Enabled.Value ? tooltip : default; get => Enabled.Value ? tooltip : default;

View File

@ -5,6 +5,7 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays; using osu.Game.Overlays;
namespace osu.Game.Users.Drawables namespace osu.Game.Users.Drawables
@ -32,9 +33,17 @@ namespace osu.Game.Users.Drawables
if (country == null && !ShowPlaceholderOnNull) if (country == null && !ShowPlaceholderOnNull)
return null; return null;
return new DrawableFlag(country) return new Container
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
new DrawableFlag(country)
{
RelativeSizeAxes = Axes.Both
},
new HoverClickSounds(HoverSampleSet.Submit)
}
}; };
} }

View File

@ -31,6 +31,7 @@ namespace osu.Game.Users
protected Drawable Background { get; private set; } protected Drawable Background { get; private set; }
protected UserPanel(User user) protected UserPanel(User user)
: base(HoverSampleSet.Submit)
{ {
if (user == null) if (user == null)
throw new ArgumentNullException(nameof(user)); throw new ArgumentNullException(nameof(user));

View File

@ -37,7 +37,7 @@
</PackageReference> </PackageReference>
<PackageReference Include="Realm" Version="10.3.0" /> <PackageReference Include="Realm" Version="10.3.0" />
<PackageReference Include="ppy.osu.Framework" Version="2021.728.0" /> <PackageReference Include="ppy.osu.Framework" Version="2021.728.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.722.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2021.730.0" />
<PackageReference Include="Sentry" Version="3.8.2" /> <PackageReference Include="Sentry" Version="3.8.2" />
<PackageReference Include="SharpCompress" Version="0.28.3" /> <PackageReference Include="SharpCompress" Version="0.28.3" />
<PackageReference Include="NUnit" Version="3.13.2" /> <PackageReference Include="NUnit" Version="3.13.2" />

View File

@ -71,7 +71,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup Label="Package References"> <ItemGroup Label="Package References">
<PackageReference Include="ppy.osu.Framework.iOS" Version="2021.728.0" /> <PackageReference Include="ppy.osu.Framework.iOS" Version="2021.728.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.722.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2021.730.0" />
</ItemGroup> </ItemGroup>
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net5.0 / net6.0) --> <!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net5.0 / net6.0) -->
<PropertyGroup> <PropertyGroup>