2021-08-22 12:26:53 +00: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 13:53:48 +00:00
|
|
|
using System;
|
|
|
|
using System.Globalization;
|
|
|
|
using System.Linq;
|
2021-08-22 12:26:53 +00:00
|
|
|
using osu.Framework.Allocation;
|
2021-08-22 13:53:48 +00:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2021-08-22 12:26:53 +00:00
|
|
|
using osu.Framework.Localisation;
|
2021-08-22 13:53:48 +00:00
|
|
|
using osu.Game.Beatmaps;
|
2021-08-22 12:26:53 +00:00
|
|
|
using osu.Game.Graphics.UserInterfaceV2;
|
2021-08-22 13:53:48 +00:00
|
|
|
using osuTK;
|
2022-08-10 17:53:20 +00:00
|
|
|
using osu.Game.Localisation;
|
2021-08-22 12:26:53 +00:00
|
|
|
|
|
|
|
namespace osu.Game.Screens.Edit.Setup
|
|
|
|
{
|
|
|
|
internal partial class DesignSection : SetupSection
|
|
|
|
{
|
2023-01-13 23:24:28 +00:00
|
|
|
protected LabelledSwitchButton EnableCountdown = null!;
|
2021-08-31 20:40:58 +00:00
|
|
|
|
2023-01-13 23:24:28 +00:00
|
|
|
protected FillFlowContainer CountdownSettings = null!;
|
|
|
|
protected LabelledEnumDropdown<CountdownType> CountdownSpeed = null!;
|
|
|
|
protected LabelledNumberBox CountdownOffset = null!;
|
2021-08-22 13:53:48 +00:00
|
|
|
|
2023-01-13 23:24:28 +00:00
|
|
|
private LabelledSwitchButton widescreenSupport = null!;
|
|
|
|
private LabelledSwitchButton epilepsyWarning = null!;
|
|
|
|
private LabelledSwitchButton letterboxDuringBreaks = null!;
|
|
|
|
private LabelledSwitchButton samplesMatchPlaybackRate = null!;
|
2021-08-22 12:26:53 +00:00
|
|
|
|
2022-08-15 15:14:16 +00:00
|
|
|
public override LocalisableString Title => EditorSetupStrings.DesignHeader;
|
2021-08-22 12:26:53 +00:00
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
Children = new[]
|
|
|
|
{
|
2021-08-29 16:01:40 +00:00
|
|
|
EnableCountdown = new LabelledSwitchButton
|
2021-08-22 13:53:48 +00:00
|
|
|
{
|
2022-08-15 15:14:16 +00:00
|
|
|
Label = EditorSetupStrings.EnableCountdown,
|
2021-08-22 13:53:48 +00:00
|
|
|
Current = { Value = Beatmap.BeatmapInfo.Countdown != CountdownType.None },
|
2022-08-15 15:14:16 +00:00
|
|
|
Description = EditorSetupStrings.CountdownDescription
|
2021-08-22 13:53:48 +00:00
|
|
|
},
|
2021-08-31 20:40:58 +00:00
|
|
|
CountdownSettings = new FillFlowContainer
|
2021-08-22 13:53:48 +00:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Spacing = new Vector2(10),
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2021-08-29 16:01:40 +00:00
|
|
|
CountdownSpeed = new LabelledEnumDropdown<CountdownType>
|
2021-08-22 13:53:48 +00:00
|
|
|
{
|
2022-08-15 15:14:16 +00:00
|
|
|
Label = EditorSetupStrings.CountdownSpeed,
|
2021-08-22 13:53:48 +00:00
|
|
|
Current = { Value = Beatmap.BeatmapInfo.Countdown != CountdownType.None ? Beatmap.BeatmapInfo.Countdown : CountdownType.Normal },
|
2022-12-26 19:36:39 +00:00
|
|
|
Items = Enum.GetValues<CountdownType>().Where(type => type != CountdownType.None)
|
2021-08-22 13:53:48 +00:00
|
|
|
},
|
2021-08-29 16:01:40 +00:00
|
|
|
CountdownOffset = new LabelledNumberBox
|
2021-08-22 13:53:48 +00:00
|
|
|
{
|
2022-08-15 15:14:16 +00:00
|
|
|
Label = EditorSetupStrings.CountdownOffset,
|
2021-08-22 13:53:48 +00:00
|
|
|
Current = { Value = Beatmap.BeatmapInfo.CountdownOffset.ToString() },
|
2022-08-15 15:14:16 +00:00
|
|
|
Description = EditorSetupStrings.CountdownOffsetDescription,
|
2021-08-22 13:53:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
Empty(),
|
2021-08-22 12:26:53 +00:00
|
|
|
widescreenSupport = new LabelledSwitchButton
|
|
|
|
{
|
2022-08-15 15:14:16 +00:00
|
|
|
Label = EditorSetupStrings.WidescreenSupport,
|
|
|
|
Description = EditorSetupStrings.WidescreenSupportDescription,
|
2021-08-22 12:26:53 +00:00
|
|
|
Current = { Value = Beatmap.BeatmapInfo.WidescreenStoryboard }
|
|
|
|
},
|
|
|
|
epilepsyWarning = new LabelledSwitchButton
|
|
|
|
{
|
2022-08-15 15:14:16 +00:00
|
|
|
Label = EditorSetupStrings.EpilepsyWarning,
|
|
|
|
Description = EditorSetupStrings.EpilepsyWarningDescription,
|
2021-08-22 12:26:53 +00:00
|
|
|
Current = { Value = Beatmap.BeatmapInfo.EpilepsyWarning }
|
|
|
|
},
|
|
|
|
letterboxDuringBreaks = new LabelledSwitchButton
|
|
|
|
{
|
2022-08-15 15:14:16 +00:00
|
|
|
Label = EditorSetupStrings.LetterboxDuringBreaks,
|
|
|
|
Description = EditorSetupStrings.LetterboxDuringBreaksDescription,
|
2021-08-22 12:26:53 +00:00
|
|
|
Current = { Value = Beatmap.BeatmapInfo.LetterboxInBreaks }
|
2021-09-12 14:54:17 +00:00
|
|
|
},
|
|
|
|
samplesMatchPlaybackRate = new LabelledSwitchButton
|
|
|
|
{
|
2022-08-15 15:14:16 +00:00
|
|
|
Label = EditorSetupStrings.SamplesMatchPlaybackRate,
|
|
|
|
Description = EditorSetupStrings.SamplesMatchPlaybackRateDescription,
|
2021-09-12 14:54:17 +00:00
|
|
|
Current = { Value = Beatmap.BeatmapInfo.SamplesMatchPlaybackRate }
|
2021-08-22 12:26:53 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
2021-08-29 16:01:40 +00:00
|
|
|
EnableCountdown.Current.BindValueChanged(_ => updateCountdownSettingsVisibility(), true);
|
2021-08-22 13:53:48 +00:00
|
|
|
|
2021-08-29 16:01:40 +00:00
|
|
|
EnableCountdown.Current.BindValueChanged(_ => updateBeatmap());
|
|
|
|
CountdownSpeed.Current.BindValueChanged(_ => updateBeatmap());
|
2022-06-24 12:25:23 +00:00
|
|
|
CountdownOffset.OnCommit += (_, _) => onOffsetCommitted();
|
2021-08-22 13:53:48 +00:00
|
|
|
|
2021-08-22 12:26:53 +00:00
|
|
|
widescreenSupport.Current.BindValueChanged(_ => updateBeatmap());
|
|
|
|
epilepsyWarning.Current.BindValueChanged(_ => updateBeatmap());
|
|
|
|
letterboxDuringBreaks.Current.BindValueChanged(_ => updateBeatmap());
|
2021-09-12 14:54:17 +00:00
|
|
|
samplesMatchPlaybackRate.Current.BindValueChanged(_ => updateBeatmap());
|
2021-08-22 12:26:53 +00:00
|
|
|
}
|
|
|
|
|
2021-08-31 20:40:58 +00:00
|
|
|
private void updateCountdownSettingsVisibility() => CountdownSettings.FadeTo(EnableCountdown.Current.Value ? 1 : 0);
|
2021-08-22 13:53:48 +00:00
|
|
|
|
2021-08-29 16:01:40 +00: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 12:26:53 +00:00
|
|
|
private void updateBeatmap()
|
|
|
|
{
|
2021-08-29 16:01:40 +00: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 13:53:48 +00:00
|
|
|
|
2021-08-22 12:26:53 +00:00
|
|
|
Beatmap.BeatmapInfo.WidescreenStoryboard = widescreenSupport.Current.Value;
|
|
|
|
Beatmap.BeatmapInfo.EpilepsyWarning = epilepsyWarning.Current.Value;
|
|
|
|
Beatmap.BeatmapInfo.LetterboxInBreaks = letterboxDuringBreaks.Current.Value;
|
2021-09-12 14:54:17 +00:00
|
|
|
Beatmap.BeatmapInfo.SamplesMatchPlaybackRate = samplesMatchPlaybackRate.Current.Value;
|
2022-08-02 07:35:15 +00:00
|
|
|
|
|
|
|
Beatmap.SaveState();
|
2021-08-22 12:26:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|