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

Fix checkbox sounds playing too often (#5731)

Fix checkbox sounds playing too often
This commit is contained in:
Dean Herbert 2019-08-16 20:22:41 +09:00 committed by GitHub
commit 3a4d65ef8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 53 additions and 26 deletions

View File

@ -61,6 +61,6 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.809.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2019.814.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2019.816.0" />
</ItemGroup>
</Project>

View File

@ -72,17 +72,11 @@ namespace osu.Game.Graphics.UserInterface
Current.DisabledChanged += disabled => labelText.Alpha = Nub.Alpha = disabled ? 0.3f : 1;
}
protected override void LoadComplete()
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
base.LoadComplete();
Current.ValueChanged += enabled =>
{
if (enabled.NewValue)
sampleChecked?.Play();
else
sampleUnchecked?.Play();
};
sampleChecked = audio.Samples.Get(@"UI/check-on");
sampleUnchecked = audio.Samples.Get(@"UI/check-off");
}
protected override bool OnHover(HoverEvent e)
@ -99,11 +93,13 @@ namespace osu.Game.Graphics.UserInterface
base.OnHoverLost(e);
}
[BackgroundDependencyLoader]
private void load(AudioManager audio)
protected override void OnUserChange(bool value)
{
sampleChecked = audio.Samples.Get(@"UI/check-on");
sampleUnchecked = audio.Samples.Get(@"UI/check-off");
base.OnUserChange(value);
if (value)
sampleChecked?.Play();
else
sampleUnchecked?.Play();
}
}
}

View File

@ -196,17 +196,30 @@ namespace osu.Game.Overlays.Profile.Header.Components
}
}
public string TooltipText => Statistics.Value?.Ranks.Global == null ? "" : $"#{ranks[dayIndex].Value:#,##0}|{ranked_days - ranks[dayIndex].Key + 1}";
public object TooltipContent
{
get
{
if (Statistics.Value?.Ranks.Global == null)
return null;
var days = ranked_days - ranks[dayIndex].Key + 1;
return new TooltipDisplayContent
{
Rank = $"#{ranks[dayIndex].Value:#,##0}",
Time = days == 0 ? "now" : $"{days} days ago"
};
}
}
public ITooltip GetCustomTooltip() => new RankGraphTooltip();
public class RankGraphTooltip : VisibilityContainer, ITooltip
private class RankGraphTooltip : VisibilityContainer, ITooltip
{
private readonly OsuSpriteText globalRankingText, timeText;
private readonly Box background;
public string TooltipText { get; set; }
public RankGraphTooltip()
{
AutoSizeAxes = Axes.Both;
@ -260,11 +273,14 @@ namespace osu.Game.Overlays.Profile.Header.Components
background.Colour = colours.GreySeafoamDark;
}
public void Refresh()
public bool SetContent(object content)
{
var info = TooltipText.Split('|');
globalRankingText.Text = info[0];
timeText.Text = info[1] == "0" ? "now" : $"{info[1]} days ago";
if (!(content is TooltipDisplayContent info))
return false;
globalRankingText.Text = info.Rank;
timeText.Text = info.Time;
return true;
}
private bool instantMove = true;
@ -280,9 +296,24 @@ namespace osu.Game.Overlays.Profile.Header.Components
this.MoveTo(pos, 200, Easing.OutQuint);
}
public void Refresh()
{
}
public string TooltipText
{
set => throw new InvalidOperationException();
}
protected override void PopIn() => this.FadeIn(200, Easing.OutQuint);
protected override void PopOut() => this.FadeOut(200, Easing.OutQuint);
}
private class TooltipDisplayContent
{
public string Rank;
public string Time;
}
}
}

View File

@ -15,7 +15,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.809.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.814.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.816.0" />
<PackageReference Include="SharpCompress" Version="0.23.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="SharpRaven" Version="2.4.0" />

View File

@ -118,8 +118,8 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.809.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.814.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2019.814.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.816.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2019.816.0" />
<PackageReference Include="SharpCompress" Version="0.22.0" />
<PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="SharpRaven" Version="2.4.0" />