Skip to content

Commit

Permalink
Revert "Merge pull request #27909 from frenzibyte/add-sound-to-tab-se…
Browse files Browse the repository at this point in the history
…lection-change-2"

This reverts commit 78fbc28, reversing
changes made to 863da8b.
  • Loading branch information
peppy committed May 21, 2024
1 parent a45b7ab commit f14fa45
Show file tree
Hide file tree
Showing 14 changed files with 41 additions and 134 deletions.
24 changes: 8 additions & 16 deletions osu.Game/Graphics/UserInterface/OsuTabControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
using osuTK;
using osuTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Bindables;
using osu.Framework.Extensions;
using osu.Framework.Extensions.Color4Extensions;
Expand Down Expand Up @@ -145,6 +143,13 @@ protected override void OnHoverLost(HoverLostEvent e)
FadeUnhovered();
}

[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
if (accentColour == default)
AccentColour = colours.Blue;
}

public OsuTabItem(T value)
: base(value)
{
Expand Down Expand Up @@ -191,21 +196,10 @@ public OsuTabItem(T value)
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
},
new HoverSounds(HoverSampleSet.TabSelect)
new HoverClickSounds(HoverSampleSet.TabSelect)
};
}

private Sample selectSample;

[BackgroundDependencyLoader]
private void load(OsuColour colours, AudioManager audio)
{
if (accentColour == default)
AccentColour = colours.Blue;

selectSample = audio.Samples.Get(@"UI/tabselect-select");
}

protected override void OnActivated()
{
Text.Font = Text.Font.With(weight: FontWeight.Bold);
Expand All @@ -217,8 +211,6 @@ protected override void OnDeactivated()
Text.Font = Text.Font.With(weight: FontWeight.Medium);
FadeUnhovered();
}

protected override void OnActivatedByUser() => selectSample.Play();
}
}
}
14 changes: 1 addition & 13 deletions osu.Game/Graphics/UserInterface/PageTabControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
using osuTK;
using osuTK.Graphics;
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.Shapes;
Expand Down Expand Up @@ -55,8 +53,6 @@ public Color4 AccentColour
}
}

private Sample selectSample = null!;

public PageTabItem(T value)
: base(value)
{
Expand All @@ -82,18 +78,12 @@ public PageTabItem(T value)
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
},
new HoverSounds(HoverSampleSet.TabSelect)
new HoverClickSounds(HoverSampleSet.TabSelect)
};

Active.BindValueChanged(active => Text.Font = Text.Font.With(Typeface.Torus, weight: active.NewValue ? FontWeight.Bold : FontWeight.Medium), true);
}

[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
selectSample = audio.Samples.Get(@"UI/tabselect-select");
}

protected virtual LocalisableString CreateText() => (Value as Enum)?.GetLocalisableDescription() ?? Value.ToString();

protected override bool OnHover(HoverEvent e)
Expand Down Expand Up @@ -122,8 +112,6 @@ private void slideInactive()
protected override void OnActivated() => slideActive();

protected override void OnDeactivated() => slideInactive();

protected override void OnActivatedByUser() => selectSample.Play();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

using System;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
Expand Down Expand Up @@ -49,15 +47,13 @@ private partial class TabItem : TabItem<BeatmapCardSize>
[Resolved]
private OverlayColourProvider colourProvider { get; set; }

private Sample selectSample = null!;

public TabItem(BeatmapCardSize value)
: base(value)
{
}

[BackgroundDependencyLoader]
private void load(AudioManager audio)
private void load()
{
AutoSizeAxes = Axes.Both;
Masking = true;
Expand All @@ -83,10 +79,8 @@ private void load(AudioManager audio)
Icon = getIconForCardSize(Value)
}
},
new HoverSounds(HoverSampleSet.TabSelect)
new HoverClickSounds(HoverSampleSet.TabSelect)
};

selectSample = audio.Samples.Get(@"UI/tabselect-select");
}

private static IconUsage getIconForCardSize(BeatmapCardSize cardSize)
Expand Down Expand Up @@ -117,8 +111,6 @@ protected override void OnActivated()
updateState();
}

protected override void OnActivatedByUser() => selectSample.Play();

protected override void OnDeactivated()
{
if (IsLoaded)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,7 @@ protected override void UpdateState()
protected override bool OnClick(ClickEvent e)
{
base.OnClick(e);

// this tab item implementation is not managed by a TabControl,
// therefore we have to manually update Active state and play select sound when this tab item is clicked.
Active.Toggle();
SelectSample.Play();
return true;
}
}
Expand Down
12 changes: 2 additions & 10 deletions osu.Game/Overlays/BeatmapListing/FilterTabItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

using System;
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.UserInterface;
Expand All @@ -26,15 +24,13 @@ public partial class FilterTabItem<T> : TabItem<T>

private OsuSpriteText text;

protected Sample SelectSample { get; private set; } = null!;

public FilterTabItem(T value)
: base(value)
{
}

[BackgroundDependencyLoader]
private void load(AudioManager audio)
private void load()
{
AutoSizeAxes = Axes.Both;
AddRangeInternal(new Drawable[]
Expand All @@ -44,12 +40,10 @@ private void load(AudioManager audio)
Font = OsuFont.GetFont(size: 13, weight: FontWeight.Regular),
Text = LabelFor(Value)
},
new HoverSounds(HoverSampleSet.TabSelect)
new HoverClickSounds(HoverSampleSet.TabSelect)
});

Enabled.Value = true;

SelectSample = audio.Samples.Get(@"UI/tabselect-select");
}

protected override void LoadComplete()
Expand Down Expand Up @@ -77,8 +71,6 @@ protected override void OnHoverLost(HoverLostEvent e)

protected override void OnDeactivated() => UpdateState();

protected override void OnActivatedByUser() => SelectSample.Play();

/// <summary>
/// Returns the label text to be used for the supplied <paramref name="value"/>.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Overlays/BeatmapSet/BeatmapRulesetSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public APIBeatmapSet? BeatmapSet
// propagate value to tab items first to enable only available rulesets.
beatmapSet.Value = value;

Current.Value = TabContainer.TabItems.FirstOrDefault(t => t.Enabled.Value)?.Value;
SelectTab(TabContainer.TabItems.FirstOrDefault(t => t.Enabled.Value));
}
}

Expand Down
14 changes: 1 addition & 13 deletions osu.Game/Overlays/OverlayPanelDisplayStyleControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
using osu.Framework.Input.Events;
using osu.Game.Graphics.UserInterface;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osuTK.Graphics;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Localisation;
Expand Down Expand Up @@ -67,8 +65,6 @@ public IconUsage Icon

private readonly SpriteIcon icon;

private Sample selectSample = null!;

public PanelDisplayTabItem(OverlayPanelDisplayStyle value)
: base(value)
{
Expand All @@ -82,22 +78,14 @@ public PanelDisplayTabItem(OverlayPanelDisplayStyle value)
RelativeSizeAxes = Axes.Both,
FillMode = FillMode.Fit
},
new HoverSounds(HoverSampleSet.TabSelect)
new HoverClickSounds()
});
}

[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
selectSample = audio.Samples.Get(@"UI/tabselect-select");
}

protected override void OnActivated() => updateState();

protected override void OnDeactivated() => updateState();

protected override void OnActivatedByUser() => selectSample.Play();

protected override bool OnHover(HoverEvent e)
{
updateState();
Expand Down
14 changes: 1 addition & 13 deletions osu.Game/Overlays/OverlayRulesetTabItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
using osuTK.Graphics;
using osuTK;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Localisation;
using osu.Game.Graphics.Containers;
Expand Down Expand Up @@ -41,8 +39,6 @@ protected virtual Color4 AccentColour

public LocalisableString TooltipText => Value.Name;

private Sample selectSample = null!;

public OverlayRulesetTabItem(RulesetInfo value)
: base(value)
{
Expand All @@ -63,18 +59,12 @@ public OverlayRulesetTabItem(RulesetInfo value)
Icon = value.CreateInstance().CreateIcon(),
},
},
new HoverSounds(HoverSampleSet.TabSelect)
new HoverClickSounds()
});

Enabled.Value = true;
}

[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
selectSample = audio.Samples.Get(@"UI/tabselect-select");
}

protected override void LoadComplete()
{
base.LoadComplete();
Expand All @@ -100,8 +90,6 @@ protected override void OnHoverLost(HoverLostEvent e)

protected override void OnDeactivated() => updateState();

protected override void OnActivatedByUser() => selectSample.Play();

private void updateState()
{
AccentColour = Enabled.Value ? getActiveColour() : colourProvider.Foreground1;
Expand Down
12 changes: 2 additions & 10 deletions osu.Game/Overlays/OverlayStreamItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
using osu.Game.Graphics.UserInterface;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics;
using osuTK.Graphics;
Expand Down Expand Up @@ -51,10 +49,8 @@ protected OverlayStreamItem(T value)
Margin = new MarginPadding(PADDING);
}

private Sample selectSample;

[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider, OsuColour colours, AudioManager audio)
private void load(OverlayColourProvider colourProvider, OsuColour colours)
{
AddRange(new Drawable[]
{
Expand Down Expand Up @@ -91,11 +87,9 @@ private void load(OverlayColourProvider colourProvider, OsuColour colours, Audio
CollapsedSize = 2,
Expanded = true
},
new HoverSounds(HoverSampleSet.TabSelect)
new HoverClickSounds()
});

selectSample = audio.Samples.Get(@"UI/tabselect-select");

SelectedItem.BindValueChanged(_ => updateState(), true);
}

Expand All @@ -111,8 +105,6 @@ private void load(OverlayColourProvider colourProvider, OsuColour colours, Audio

protected override void OnDeactivated() => updateState();

protected override void OnActivatedByUser() => selectSample.Play();

protected override bool OnHover(HoverEvent e)
{
updateState();
Expand Down
14 changes: 1 addition & 13 deletions osu.Game/Overlays/OverlayTabControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#nullable disable

using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
Expand Down Expand Up @@ -82,8 +80,6 @@ public Color4 AccentColour
}
}

private Sample selectSample = null!;

public OverlayTabItem(T value)
: base(value)
{
Expand All @@ -105,16 +101,10 @@ public OverlayTabItem(T value)
ExpandedSize = 5f,
CollapsedSize = 0
},
new HoverSounds(HoverSampleSet.TabSelect)
new HoverClickSounds(HoverSampleSet.TabSelect)
};
}

[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
selectSample = audio.Samples.Get(@"UI/tabselect-select");
}

protected override bool OnHover(HoverEvent e)
{
base.OnHover(e);
Expand Down Expand Up @@ -146,8 +136,6 @@ protected override void OnDeactivated()
Text.Font = Text.Font.With(weight: FontWeight.Medium);
}

protected override void OnActivatedByUser() => selectSample.Play();

private void updateState()
{
if (Active.Value)
Expand Down
Loading

0 comments on commit f14fa45

Please sign in to comment.