1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 20:22:55 +08:00

replay menus remembers expanded state

no messing with readonly fields
This commit is contained in:
integer 2022-12-26 22:23:31 +00:00
parent e99be3b4f5
commit a0690e7ffb
3 changed files with 28 additions and 1 deletions

View File

@ -24,12 +24,16 @@ namespace osu.Game.Tests.NonVisual
sessionStatics.SetValue(Static.MutedAudioNotificationShownOnce, true);
sessionStatics.SetValue(Static.LowBatteryNotificationShownOnce, true);
sessionStatics.SetValue(Static.LastHoverSoundPlaybackTime, (double?)1d);
sessionStatics.SetValue(Static.ReplayPlaybackSettingExpanded, false);
sessionStatics.SetValue(Static.ReplayVisualSettingsExpanded, true);
sessionStatics.SetValue(Static.SeasonalBackgrounds, new APISeasonalBackgrounds { EndDate = new DateTimeOffset(2022, 1, 1, 0, 0, 0, TimeSpan.Zero) });
Assert.IsFalse(sessionStatics.GetBindable<bool>(Static.LoginOverlayDisplayed).IsDefault);
Assert.IsFalse(sessionStatics.GetBindable<bool>(Static.MutedAudioNotificationShownOnce).IsDefault);
Assert.IsFalse(sessionStatics.GetBindable<bool>(Static.LowBatteryNotificationShownOnce).IsDefault);
Assert.IsFalse(sessionStatics.GetBindable<double?>(Static.LastHoverSoundPlaybackTime).IsDefault);
Assert.IsFalse(sessionStatics.GetBindable<bool>(Static.ReplayPlaybackSettingExpanded).IsDefault);
Assert.IsFalse(sessionStatics.GetBindable<bool>(Static.ReplayVisualSettingsExpanded).IsDefault);
Assert.IsFalse(sessionStatics.GetBindable<APISeasonalBackgrounds>(Static.SeasonalBackgrounds).IsDefault);
sessionStatics.ResetAfterInactivity();
@ -39,6 +43,8 @@ namespace osu.Game.Tests.NonVisual
Assert.IsTrue(sessionStatics.GetBindable<bool>(Static.LowBatteryNotificationShownOnce).IsDefault);
// some statics should not reset despite inactivity.
Assert.IsFalse(sessionStatics.GetBindable<double?>(Static.LastHoverSoundPlaybackTime).IsDefault);
Assert.IsFalse(sessionStatics.GetBindable<bool>(Static.ReplayPlaybackSettingExpanded).IsDefault);
Assert.IsFalse(sessionStatics.GetBindable<bool>(Static.ReplayVisualSettingsExpanded).IsDefault);
Assert.IsFalse(sessionStatics.GetBindable<APISeasonalBackgrounds>(Static.SeasonalBackgrounds).IsDefault);
}
}

View File

@ -20,6 +20,8 @@ namespace osu.Game.Configuration
SetDefault(Static.MutedAudioNotificationShownOnce, false);
SetDefault(Static.LowBatteryNotificationShownOnce, false);
SetDefault(Static.LastHoverSoundPlaybackTime, (double?)null);
SetDefault(Static.ReplayPlaybackSettingExpanded, true);
SetDefault(Static.ReplayVisualSettingsExpanded, false);
SetDefault<APISeasonalBackgrounds>(Static.SeasonalBackgrounds, null);
}
@ -42,6 +44,8 @@ namespace osu.Game.Configuration
LoginOverlayDisplayed,
MutedAudioNotificationShownOnce,
LowBatteryNotificationShownOnce,
ReplayPlaybackSettingExpanded,
ReplayVisualSettingsExpanded,
/// <summary>
/// Info about seasonal backgrounds available fetched from API - see <see cref="APISeasonalBackgrounds"/>.

View File

@ -3,12 +3,15 @@
#nullable disable
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Events;
using osuTK;
using osu.Game.Screens.Play.PlayerSettings;
using osuTK.Input;
using osu.Game.Configuration;
using osu.Framework.Allocation;
namespace osu.Game.Screens.Play.HUD
{
@ -16,6 +19,10 @@ namespace osu.Game.Screens.Play.HUD
{
private const int fade_duration = 200;
private Bindable<bool> playbackMenuExpanded;
private Bindable<bool> visualMenuExpanded;
public bool ReplayLoaded;
public readonly PlaybackSettings PlaybackSettings;
@ -42,11 +49,21 @@ namespace osu.Game.Screens.Play.HUD
//CollectionSettings = new CollectionSettings(),
//DiscussionSettings = new DiscussionSettings(),
PlaybackSettings = new PlaybackSettings(),
VisualSettings = new VisualSettings { Expanded = { Value = false } }
VisualSettings = new VisualSettings()
}
};
}
[BackgroundDependencyLoader]
private void load(SessionStatics statics)
{
playbackMenuExpanded = statics.GetBindable<bool>(Static.ReplayPlaybackSettingExpanded);
visualMenuExpanded = statics.GetBindable<bool>(Static.ReplayVisualSettingsExpanded);
PlaybackSettings.Expanded.BindTo(playbackMenuExpanded);
VisualSettings.Expanded.BindTo(visualMenuExpanded);
}
protected override void PopIn() => this.FadeIn(fade_duration);
protected override void PopOut() => this.FadeOut(fade_duration);