2021-08-22 20:26:53 +08:00
|
|
|
// 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.
|
|
|
|
|
2021-08-22 21:53:48 +08:00
|
|
|
using System;
|
|
|
|
using System.Globalization;
|
|
|
|
using System.Linq;
|
2021-08-22 20:26:53 +08:00
|
|
|
using osu.Framework.Allocation;
|
2021-08-22 21:53:48 +08:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2021-08-22 20:26:53 +08:00
|
|
|
using osu.Framework.Localisation;
|
2021-08-22 21:53:48 +08:00
|
|
|
using osu.Game.Beatmaps;
|
2021-08-22 20:26:53 +08:00
|
|
|
using osu.Game.Graphics.UserInterfaceV2;
|
2021-08-22 21:53:48 +08:00
|
|
|
using osuTK;
|
2022-08-11 01:53:20 +08:00
|
|
|
using osu.Game.Localisation;
|
2021-08-22 20:26:53 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Screens.Edit.Setup
|
|
|
|
{
|
|
|
|
internal partial class DesignSection : SetupSection
|
|
|
|
{
|
2024-08-28 18:17:39 +08:00
|
|
|
protected FormCheckBox EnableCountdown = null!;
|
2021-09-01 04:40:58 +08:00
|
|
|
|
2023-01-14 07:24:28 +08:00
|
|
|
protected FillFlowContainer CountdownSettings = null!;
|
2024-08-28 18:17:39 +08:00
|
|
|
protected FormEnumDropdown<CountdownType> CountdownSpeed = null!;
|
|
|
|
protected FormNumberBox CountdownOffset = null!;
|
2021-08-22 21:53:48 +08:00
|
|
|
|
2024-08-28 18:17:39 +08:00
|
|
|
private FormCheckBox widescreenSupport = null!;
|
|
|
|
private FormCheckBox epilepsyWarning = null!;
|
|
|
|
private FormCheckBox letterboxDuringBreaks = null!;
|
|
|
|
private FormCheckBox samplesMatchPlaybackRate = null!;
|
2021-08-22 20:26:53 +08:00
|
|
|
|
2022-08-15 23:14:16 +08:00
|
|
|
public override LocalisableString Title => EditorSetupStrings.DesignHeader;
|
2021-08-22 20:26:53 +08:00
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
2024-08-28 18:17:39 +08:00
|
|
|
Children = new Drawable[]
|
2021-08-22 20:26:53 +08:00
|
|
|
{
|
2024-08-28 18:17:39 +08:00
|
|
|
EnableCountdown = new FormCheckBox
|
2021-08-22 21:53:48 +08:00
|
|
|
{
|
2024-08-28 18:17:39 +08:00
|
|
|
Caption = EditorSetupStrings.EnableCountdown,
|
|
|
|
HintText = EditorSetupStrings.CountdownDescription,
|
2021-08-22 21:53:48 +08:00
|
|
|
Current = { Value = Beatmap.BeatmapInfo.Countdown != CountdownType.None },
|
|
|
|
},
|
2021-09-01 04:40:58 +08:00
|
|
|
CountdownSettings = new FillFlowContainer
|
2021-08-22 21:53:48 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2024-08-28 18:17:39 +08:00
|
|
|
Spacing = new Vector2(5),
|
2021-08-22 21:53:48 +08:00
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2024-08-28 18:17:39 +08:00
|
|
|
CountdownSpeed = new FormEnumDropdown<CountdownType>
|
2021-08-22 21:53:48 +08:00
|
|
|
{
|
2024-08-28 18:17:39 +08:00
|
|
|
Caption = EditorSetupStrings.CountdownSpeed,
|
2021-08-22 21:53:48 +08:00
|
|
|
Current = { Value = Beatmap.BeatmapInfo.Countdown != CountdownType.None ? Beatmap.BeatmapInfo.Countdown : CountdownType.Normal },
|
2022-12-27 03:36:39 +08:00
|
|
|
Items = Enum.GetValues<CountdownType>().Where(type => type != CountdownType.None)
|
2021-08-22 21:53:48 +08:00
|
|
|
},
|
2024-08-28 18:17:39 +08:00
|
|
|
CountdownOffset = new FormNumberBox
|
2021-08-22 21:53:48 +08:00
|
|
|
{
|
2024-08-28 18:17:39 +08:00
|
|
|
Caption = EditorSetupStrings.CountdownOffset,
|
|
|
|
HintText = EditorSetupStrings.CountdownOffsetDescription,
|
2021-08-22 21:53:48 +08:00
|
|
|
Current = { Value = Beatmap.BeatmapInfo.CountdownOffset.ToString() },
|
2024-08-28 18:17:39 +08:00
|
|
|
TabbableContentContainer = this,
|
2021-08-22 21:53:48 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2024-08-28 18:17:39 +08:00
|
|
|
widescreenSupport = new FormCheckBox
|
2021-08-22 20:26:53 +08:00
|
|
|
{
|
2024-08-28 18:17:39 +08:00
|
|
|
Caption = EditorSetupStrings.WidescreenSupport,
|
|
|
|
HintText = EditorSetupStrings.WidescreenSupportDescription,
|
2021-08-22 20:26:53 +08:00
|
|
|
Current = { Value = Beatmap.BeatmapInfo.WidescreenStoryboard }
|
|
|
|
},
|
2024-08-28 18:17:39 +08:00
|
|
|
epilepsyWarning = new FormCheckBox
|
2021-08-22 20:26:53 +08:00
|
|
|
{
|
2024-08-28 18:17:39 +08:00
|
|
|
Caption = EditorSetupStrings.EpilepsyWarning,
|
|
|
|
HintText = EditorSetupStrings.EpilepsyWarningDescription,
|
2021-08-22 20:26:53 +08:00
|
|
|
Current = { Value = Beatmap.BeatmapInfo.EpilepsyWarning }
|
|
|
|
},
|
2024-08-28 18:17:39 +08:00
|
|
|
letterboxDuringBreaks = new FormCheckBox
|
2021-08-22 20:26:53 +08:00
|
|
|
{
|
2024-08-28 18:17:39 +08:00
|
|
|
Caption = EditorSetupStrings.LetterboxDuringBreaks,
|
|
|
|
HintText = EditorSetupStrings.LetterboxDuringBreaksDescription,
|
2021-08-22 20:26:53 +08:00
|
|
|
Current = { Value = Beatmap.BeatmapInfo.LetterboxInBreaks }
|
2021-09-12 22:54:17 +08:00
|
|
|
},
|
2024-08-28 18:17:39 +08:00
|
|
|
samplesMatchPlaybackRate = new FormCheckBox
|
2021-09-12 22:54:17 +08:00
|
|
|
{
|
2024-08-28 18:17:39 +08:00
|
|
|
Caption = EditorSetupStrings.SamplesMatchPlaybackRate,
|
|
|
|
HintText = EditorSetupStrings.SamplesMatchPlaybackRateDescription,
|
2021-09-12 22:54:17 +08:00
|
|
|
Current = { Value = Beatmap.BeatmapInfo.SamplesMatchPlaybackRate }
|
2021-08-22 20:26:53 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
2021-08-30 00:01:40 +08:00
|
|
|
EnableCountdown.Current.BindValueChanged(_ => updateCountdownSettingsVisibility(), true);
|
2021-08-22 21:53:48 +08:00
|
|
|
|
2021-08-30 00:01:40 +08:00
|
|
|
EnableCountdown.Current.BindValueChanged(_ => updateBeatmap());
|
|
|
|
CountdownSpeed.Current.BindValueChanged(_ => updateBeatmap());
|
2022-06-24 20:25:23 +08:00
|
|
|
CountdownOffset.OnCommit += (_, _) => onOffsetCommitted();
|
2021-08-22 21:53:48 +08:00
|
|
|
|
2021-08-22 20:26:53 +08:00
|
|
|
widescreenSupport.Current.BindValueChanged(_ => updateBeatmap());
|
|
|
|
epilepsyWarning.Current.BindValueChanged(_ => updateBeatmap());
|
|
|
|
letterboxDuringBreaks.Current.BindValueChanged(_ => updateBeatmap());
|
2021-09-12 22:54:17 +08:00
|
|
|
samplesMatchPlaybackRate.Current.BindValueChanged(_ => updateBeatmap());
|
2021-08-22 20:26:53 +08:00
|
|
|
}
|
|
|
|
|
2021-09-01 04:40:58 +08:00
|
|
|
private void updateCountdownSettingsVisibility() => CountdownSettings.FadeTo(EnableCountdown.Current.Value ? 1 : 0);
|
2021-08-22 21:53:48 +08:00
|
|
|
|
2021-08-30 00:01:40 +08:00
|
|
|
private void onOffsetCommitted()
|
|
|
|
{
|
|
|
|
updateBeatmap();
|
|
|
|
// update displayed text to ensure parsed value matches display (i.e. if empty string was provided).
|
|
|
|
CountdownOffset.Current.Value = Beatmap.BeatmapInfo.CountdownOffset.ToString(CultureInfo.InvariantCulture);
|
|
|
|
}
|
|
|
|
|
2021-08-22 20:26:53 +08:00
|
|
|
private void updateBeatmap()
|
|
|
|
{
|
2021-08-30 00:01:40 +08:00
|
|
|
Beatmap.BeatmapInfo.Countdown = EnableCountdown.Current.Value ? CountdownSpeed.Current.Value : CountdownType.None;
|
|
|
|
Beatmap.BeatmapInfo.CountdownOffset = int.TryParse(CountdownOffset.Current.Value, NumberStyles.None, CultureInfo.InvariantCulture, out int offset) ? offset : 0;
|
2021-08-22 21:53:48 +08:00
|
|
|
|
2021-08-22 20:26:53 +08:00
|
|
|
Beatmap.BeatmapInfo.WidescreenStoryboard = widescreenSupport.Current.Value;
|
|
|
|
Beatmap.BeatmapInfo.EpilepsyWarning = epilepsyWarning.Current.Value;
|
|
|
|
Beatmap.BeatmapInfo.LetterboxInBreaks = letterboxDuringBreaks.Current.Value;
|
2021-09-12 22:54:17 +08:00
|
|
|
Beatmap.BeatmapInfo.SamplesMatchPlaybackRate = samplesMatchPlaybackRate.Current.Value;
|
2022-08-02 15:35:15 +08:00
|
|
|
|
|
|
|
Beatmap.SaveState();
|
2021-08-22 20:26:53 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|