osu/osu.Game/Screens/Play/SaveFailedScoreButton.cs
cdwcgt f2eb7e0551
Use better design and fix some problem
Let saveReplay async but still void
Make failed score's rank = F
2022-06-21 19:06:38 +08:00

46 lines
1.2 KiB
C#

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online;
namespace osu.Game.Screens.Play
{
public class SaveFailedScoreButton : DownloadButton
{
public Action? OnSave;
[BackgroundDependencyLoader]
private void load()
{
State.BindValueChanged(updateTooltip, true);
Action = saveScore;
}
private void saveScore()
{
if (State.Value != DownloadState.LocallyAvailable)
OnSave?.Invoke();
State.Value = DownloadState.LocallyAvailable;
}
private void updateTooltip(ValueChangedEvent<DownloadState> state)
{
switch (state.NewValue)
{
case DownloadState.LocallyAvailable:
TooltipText = @"Score saved";
break;
default:
TooltipText = @"Save score";
break;
}
}
}
}