Merge branch 'master' into simplify-user-graph-tooltips

This commit is contained in:
Dean Herbert
2021-09-01 17:04:21 +09:00
committed by GitHub
27 changed files with 448 additions and 204 deletions

View File

@ -0,0 +1,100 @@
// 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 System.Globalization;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Graphics.UserInterfaceV2;
using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Setup;
using osuTK.Input;
namespace osu.Game.Tests.Visual.Editing
{
public class TestSceneDesignSection : OsuManualInputManagerTestScene
{
private TestDesignSection designSection;
private EditorBeatmap editorBeatmap { get; set; }
[SetUpSteps]
public void SetUp()
{
AddStep("create blank beatmap", () => editorBeatmap = new EditorBeatmap(new Beatmap()));
AddStep("create section", () => Child = new DependencyProvidingContainer
{
RelativeSizeAxes = Axes.Both,
CachedDependencies = new (Type, object)[]
{
(typeof(EditorBeatmap), editorBeatmap)
},
Child = designSection = new TestDesignSection()
});
}
[Test]
public void TestCountdownOff()
{
AddStep("turn countdown off", () => designSection.EnableCountdown.Current.Value = false);
AddAssert("beatmap has correct type", () => editorBeatmap.BeatmapInfo.Countdown == CountdownType.None);
AddUntilStep("other controls hidden", () => !designSection.CountdownSettings.IsPresent);
}
[Test]
public void TestCountdownOn()
{
AddStep("turn countdown on", () => designSection.EnableCountdown.Current.Value = true);
AddAssert("beatmap has correct type", () => editorBeatmap.BeatmapInfo.Countdown == CountdownType.Normal);
AddUntilStep("other controls shown", () => designSection.CountdownSettings.IsPresent);
AddStep("change countdown speed", () => designSection.CountdownSpeed.Current.Value = CountdownType.DoubleSpeed);
AddAssert("beatmap has correct type", () => editorBeatmap.BeatmapInfo.Countdown == CountdownType.DoubleSpeed);
AddUntilStep("other controls still shown", () => designSection.CountdownSettings.IsPresent);
}
[Test]
public void TestCountdownOffset()
{
AddStep("turn countdown on", () => designSection.EnableCountdown.Current.Value = true);
AddAssert("beatmap has correct type", () => editorBeatmap.BeatmapInfo.Countdown == CountdownType.Normal);
checkOffsetAfter("1", 1);
checkOffsetAfter(string.Empty, 0);
checkOffsetAfter("123", 123);
checkOffsetAfter("0", 0);
}
private void checkOffsetAfter(string userInput, int expectedFinalValue)
{
AddStep("click text box", () =>
{
var textBox = designSection.CountdownOffset.ChildrenOfType<TextBox>().Single();
InputManager.MoveMouseTo(textBox);
InputManager.Click(MouseButton.Left);
});
AddStep("set offset text", () => designSection.CountdownOffset.Current.Value = userInput);
AddStep("commit text", () => InputManager.Key(Key.Enter));
AddAssert($"displayed value is {expectedFinalValue}", () => designSection.CountdownOffset.Current.Value == expectedFinalValue.ToString(CultureInfo.InvariantCulture));
AddAssert($"beatmap value is {expectedFinalValue}", () => editorBeatmap.BeatmapInfo.CountdownOffset == expectedFinalValue);
}
private class TestDesignSection : DesignSection
{
public new LabelledSwitchButton EnableCountdown => base.EnableCountdown;
public new FillFlowContainer CountdownSettings => base.CountdownSettings;
public new LabelledEnumDropdown<CountdownType> CountdownSpeed => base.CountdownSpeed;
public new LabelledNumberBox CountdownOffset => base.CountdownOffset;
}
}
}

View File

@ -323,6 +323,71 @@ namespace osu.Game.Tests.Visual.Navigation
AddWaitStep("wait two frames", 2); AddWaitStep("wait two frames", 2);
} }
[Test]
public void TestOverlayClosing()
{
// use now playing overlay for "overlay -> background" drag case
// since most overlays use a scroll container that absorbs on mouse down
NowPlayingOverlay nowPlayingOverlay = null;
AddStep("enter menu", () => InputManager.Key(Key.Enter));
AddStep("get and press now playing hotkey", () =>
{
nowPlayingOverlay = Game.ChildrenOfType<NowPlayingOverlay>().Single();
InputManager.Key(Key.F6);
});
// drag tests
// background -> toolbar
AddStep("move cursor to background", () => InputManager.MoveMouseTo(Game.ScreenSpaceDrawQuad.BottomRight));
AddStep("press left mouse button", () => InputManager.PressButton(MouseButton.Left));
AddStep("move cursor to toolbar", () => InputManager.MoveMouseTo(Game.Toolbar.ScreenSpaceDrawQuad.Centre));
AddStep("release left mouse button", () => InputManager.ReleaseButton(MouseButton.Left));
AddAssert("now playing is hidden", () => nowPlayingOverlay.State.Value == Visibility.Hidden);
AddStep("press now playing hotkey", () => InputManager.Key(Key.F6));
// toolbar -> background
AddStep("press left mouse button", () => InputManager.PressButton(MouseButton.Left));
AddStep("move cursor to background", () => InputManager.MoveMouseTo(Game.ScreenSpaceDrawQuad.BottomRight));
AddStep("release left mouse button", () => InputManager.ReleaseButton(MouseButton.Left));
AddAssert("now playing is still visible", () => nowPlayingOverlay.State.Value == Visibility.Visible);
// background -> overlay
AddStep("press left mouse button", () => InputManager.PressButton(MouseButton.Left));
AddStep("move cursor to now playing overlay", () => InputManager.MoveMouseTo(nowPlayingOverlay.ScreenSpaceDrawQuad.Centre));
AddStep("release left mouse button", () => InputManager.ReleaseButton(MouseButton.Left));
AddAssert("now playing is still visible", () => nowPlayingOverlay.State.Value == Visibility.Visible);
// overlay -> background
AddStep("press left mouse button", () => InputManager.PressButton(MouseButton.Left));
AddStep("move cursor to background", () => InputManager.MoveMouseTo(Game.ScreenSpaceDrawQuad.BottomRight));
AddStep("release left mouse button", () => InputManager.ReleaseButton(MouseButton.Left));
AddAssert("now playing is still visible", () => nowPlayingOverlay.State.Value == Visibility.Visible);
// background -> background
AddStep("press left mouse button", () => InputManager.PressButton(MouseButton.Left));
AddStep("move cursor to left", () => InputManager.MoveMouseTo(Game.ScreenSpaceDrawQuad.BottomLeft));
AddStep("release left mouse button", () => InputManager.ReleaseButton(MouseButton.Left));
AddAssert("now playing is hidden", () => nowPlayingOverlay.State.Value == Visibility.Hidden);
AddStep("press now playing hotkey", () => InputManager.Key(Key.F6));
// click tests
// toolbar
AddStep("move cursor to toolbar", () => InputManager.MoveMouseTo(Game.Toolbar.ScreenSpaceDrawQuad.Centre));
AddStep("click left mouse button", () => InputManager.Click(MouseButton.Left));
AddAssert("now playing is still visible", () => nowPlayingOverlay.State.Value == Visibility.Visible);
// background
AddStep("move cursor to background", () => InputManager.MoveMouseTo(Game.ScreenSpaceDrawQuad.BottomRight));
AddStep("click left mouse button", () => InputManager.Click(MouseButton.Left));
AddAssert("now playing is hidden", () => nowPlayingOverlay.State.Value == Visibility.Hidden);
}
private void pushEscape() => private void pushEscape() =>
AddStep("Press escape", () => InputManager.Key(Key.Escape)); AddStep("Press escape", () => InputManager.Key(Key.Escape));

View File

@ -0,0 +1,25 @@
// 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 NUnit.Framework;
using osu.Framework.Graphics;
using osu.Game.Screens.Menu;
namespace osu.Game.Tests.Visual.UserInterface
{
public class TestSceneOsuLogo : OsuTestScene
{
[Test]
public void TestBasic()
{
AddStep("Add logo", () =>
{
Child = new OsuLogo
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
};
});
}
}
}

View File

@ -10,7 +10,6 @@ using Newtonsoft.Json;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.IO.Serialization;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Scoring; using osu.Game.Scoring;
@ -18,7 +17,7 @@ namespace osu.Game.Beatmaps
{ {
[ExcludeFromDynamicCompile] [ExcludeFromDynamicCompile]
[Serializable] [Serializable]
public class BeatmapInfo : IEquatable<BeatmapInfo>, IJsonSerializable, IHasPrimaryKey public class BeatmapInfo : IEquatable<BeatmapInfo>, IHasPrimaryKey
{ {
public int ID { get; set; } public int ID { get; set; }

View File

@ -153,6 +153,11 @@ namespace osu.Game.Beatmaps
if (!storage.Exists(cache_database_name)) if (!storage.Exists(cache_database_name))
return false; return false;
if (string.IsNullOrEmpty(beatmap.MD5Hash)
&& string.IsNullOrEmpty(beatmap.Path)
&& beatmap.OnlineBeatmapID == null)
return false;
try try
{ {
using (var db = new SqliteConnection(storage.GetDatabaseConnectionString("online"))) using (var db = new SqliteConnection(storage.GetDatabaseConnectionString("online")))

View File

@ -1,6 +1,8 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using System.ComponentModel;
namespace osu.Game.Beatmaps namespace osu.Game.Beatmaps
{ {
/// <summary> /// <summary>
@ -9,8 +11,14 @@ namespace osu.Game.Beatmaps
public enum CountdownType public enum CountdownType
{ {
None = 0, None = 0,
[Description("Normal")]
Normal = 1, Normal = 1,
[Description("Half speed")]
HalfSpeed = 2, HalfSpeed = 2,
[Description("Double speed")]
DoubleSpeed = 3 DoubleSpeed = 3
} }
} }

View File

@ -16,7 +16,6 @@ using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
using osuTK; using osuTK;
@ -24,7 +23,7 @@ using osuTK.Graphics;
namespace osu.Game.Beatmaps.Drawables namespace osu.Game.Beatmaps.Drawables
{ {
public class DifficultyIcon : CompositeDrawable, IHasCustomTooltip public class DifficultyIcon : CompositeDrawable, IHasCustomTooltip<DifficultyIconTooltipContent>
{ {
private readonly Container iconContainer; private readonly Container iconContainer;
@ -127,9 +126,9 @@ namespace osu.Game.Beatmaps.Drawables
difficultyBindable.BindValueChanged(difficulty => background.Colour = colours.ForStarDifficulty(difficulty.NewValue.Stars)); difficultyBindable.BindValueChanged(difficulty => background.Colour = colours.ForStarDifficulty(difficulty.NewValue.Stars));
} }
public ITooltip GetCustomTooltip() => new DifficultyIconTooltip(); ITooltip<DifficultyIconTooltipContent> IHasCustomTooltip<DifficultyIconTooltipContent>.GetCustomTooltip() => new DifficultyIconTooltip();
public object TooltipContent => shouldShowTooltip ? new DifficultyIconTooltipContent(beatmap, difficultyBindable) : null; DifficultyIconTooltipContent IHasCustomTooltip<DifficultyIconTooltipContent>.TooltipContent => shouldShowTooltip ? new DifficultyIconTooltipContent(beatmap, difficultyBindable) : null;
private class DifficultyRetriever : Component private class DifficultyRetriever : Component
{ {
@ -173,113 +172,5 @@ namespace osu.Game.Beatmaps.Drawables
difficultyCancellation?.Cancel(); difficultyCancellation?.Cancel();
} }
} }
private class DifficultyIconTooltipContent
{
public readonly BeatmapInfo Beatmap;
public readonly IBindable<StarDifficulty> Difficulty;
public DifficultyIconTooltipContent(BeatmapInfo beatmap, IBindable<StarDifficulty> difficulty)
{
Beatmap = beatmap;
Difficulty = difficulty;
}
}
private class DifficultyIconTooltip : VisibilityContainer, ITooltip
{
private readonly OsuSpriteText difficultyName, starRating;
private readonly Box background;
private readonly FillFlowContainer difficultyFlow;
public DifficultyIconTooltip()
{
AutoSizeAxes = Axes.Both;
Masking = true;
CornerRadius = 5;
Children = new Drawable[]
{
background = new Box
{
RelativeSizeAxes = Axes.Both
},
new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
AutoSizeDuration = 200,
AutoSizeEasing = Easing.OutQuint,
Direction = FillDirection.Vertical,
Padding = new MarginPadding(10),
Children = new Drawable[]
{
difficultyName = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Font = OsuFont.GetFont(size: 16, weight: FontWeight.Bold),
},
difficultyFlow = new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Direction = FillDirection.Horizontal,
Children = new Drawable[]
{
starRating = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Font = OsuFont.GetFont(size: 16, weight: FontWeight.Regular),
},
new SpriteIcon
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Margin = new MarginPadding { Left = 4 },
Icon = FontAwesome.Solid.Star,
Size = new Vector2(12),
},
}
}
}
}
};
}
[Resolved]
private OsuColour colours { get; set; }
[BackgroundDependencyLoader]
private void load()
{
background.Colour = colours.Gray3;
}
private readonly IBindable<StarDifficulty> starDifficulty = new Bindable<StarDifficulty>();
public void SetContent(object content)
{
if (!(content is DifficultyIconTooltipContent iconContent))
return;
difficultyName.Text = iconContent.Beatmap.Version;
starDifficulty.UnbindAll();
starDifficulty.BindTo(iconContent.Difficulty);
starDifficulty.BindValueChanged(difficulty =>
{
starRating.Text = $"{difficulty.NewValue.Stars:0.##}";
difficultyFlow.Colour = colours.ForStarDifficulty(difficulty.NewValue.Stars);
}, true);
}
public void Move(Vector2 pos) => Position = pos;
protected override void PopIn() => this.FadeIn(200, Easing.OutQuint);
protected override void PopOut() => this.FadeOut(200, Easing.OutQuint);
}
} }
} }

View File

@ -0,0 +1,121 @@
// 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 osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osuTK;
namespace osu.Game.Beatmaps.Drawables
{
internal class DifficultyIconTooltip : VisibilityContainer, ITooltip<DifficultyIconTooltipContent>
{
private readonly OsuSpriteText difficultyName, starRating;
private readonly Box background;
private readonly FillFlowContainer difficultyFlow;
public DifficultyIconTooltip()
{
AutoSizeAxes = Axes.Both;
Masking = true;
CornerRadius = 5;
Children = new Drawable[]
{
background = new Box
{
RelativeSizeAxes = Axes.Both
},
new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
AutoSizeDuration = 200,
AutoSizeEasing = Easing.OutQuint,
Direction = FillDirection.Vertical,
Padding = new MarginPadding(10),
Children = new Drawable[]
{
difficultyName = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Font = OsuFont.GetFont(size: 16, weight: FontWeight.Bold),
},
difficultyFlow = new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Direction = FillDirection.Horizontal,
Children = new Drawable[]
{
starRating = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Font = OsuFont.GetFont(size: 16, weight: FontWeight.Regular),
},
new SpriteIcon
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Margin = new MarginPadding { Left = 4 },
Icon = FontAwesome.Solid.Star,
Size = new Vector2(12),
},
}
}
}
}
};
}
[Resolved]
private OsuColour colours { get; set; }
[BackgroundDependencyLoader]
private void load()
{
background.Colour = colours.Gray3;
}
private readonly IBindable<StarDifficulty> starDifficulty = new Bindable<StarDifficulty>();
public void SetContent(DifficultyIconTooltipContent content)
{
difficultyName.Text = content.Beatmap.Version;
starDifficulty.UnbindAll();
starDifficulty.BindTo(content.Difficulty);
starDifficulty.BindValueChanged(difficulty =>
{
starRating.Text = $"{difficulty.NewValue.Stars:0.##}";
difficultyFlow.Colour = colours.ForStarDifficulty(difficulty.NewValue.Stars);
}, true);
}
public void Move(Vector2 pos) => Position = pos;
protected override void PopIn() => this.FadeIn(200, Easing.OutQuint);
protected override void PopOut() => this.FadeOut(200, Easing.OutQuint);
}
internal class DifficultyIconTooltipContent
{
public readonly BeatmapInfo Beatmap;
public readonly IBindable<StarDifficulty> Difficulty;
public DifficultyIconTooltipContent(BeatmapInfo beatmap, IBindable<StarDifficulty> difficulty)
{
Beatmap = beatmap;
Difficulty = difficulty;
}
}
}

View File

@ -4,12 +4,11 @@
using System.Collections.Generic; using System.Collections.Generic;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Beatmaps.Timing; using osu.Game.Beatmaps.Timing;
using osu.Game.IO.Serialization;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
namespace osu.Game.Beatmaps namespace osu.Game.Beatmaps
{ {
public interface IBeatmap : IJsonSerializable public interface IBeatmap
{ {
/// <summary> /// <summary>
/// This beatmap's info. /// This beatmap's info.

View File

@ -153,7 +153,7 @@ namespace osu.Game.Graphics.Backgrounds
TriangleParticle newParticle = parts[i]; TriangleParticle newParticle = parts[i];
// Scale moved distance by the size of the triangle. Smaller triangles should move more slowly. // Scale moved distance by the size of the triangle. Smaller triangles should move more slowly.
newParticle.Position.Y += parts[i].Scale * movedDistance; newParticle.Position.Y += Math.Max(0.5f, parts[i].Scale) * movedDistance;
newParticle.Colour.A = adjustedAlpha; newParticle.Colour.A = adjustedAlpha;
parts[i] = newParticle; parts[i] = newParticle;

View File

@ -10,7 +10,7 @@ using osu.Game.Utils;
namespace osu.Game.Graphics namespace osu.Game.Graphics
{ {
public class DrawableDate : OsuSpriteText, IHasCustomTooltip public class DrawableDate : OsuSpriteText, IHasCustomTooltip<DateTimeOffset>
{ {
private DateTimeOffset date; private DateTimeOffset date;
@ -75,8 +75,8 @@ namespace osu.Game.Graphics
private void updateTime() => Text = Format(); private void updateTime() => Text = Format();
public ITooltip GetCustomTooltip() => new DateTooltip(); public ITooltip<DateTimeOffset> GetCustomTooltip() => new DateTooltip();
public object TooltipContent => Date; public DateTimeOffset TooltipContent => Date;
} }
} }

View File

@ -0,0 +1,12 @@
// 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 osu.Game.Graphics.UserInterface;
namespace osu.Game.Graphics.UserInterfaceV2
{
public class LabelledNumberBox : LabelledTextBox
{
protected override OsuTextBox CreateTextBox() => new OsuNumberBox();
}
}

View File

@ -7,21 +7,14 @@ using osu.Framework.IO.Serialization;
namespace osu.Game.IO.Serialization namespace osu.Game.IO.Serialization
{ {
public interface IJsonSerializable
{
}
public static class JsonSerializableExtensions public static class JsonSerializableExtensions
{ {
public static string Serialize(this IJsonSerializable obj) => JsonConvert.SerializeObject(obj, CreateGlobalSettings()); public static string Serialize(this object obj) => JsonConvert.SerializeObject(obj, CreateGlobalSettings());
public static T Deserialize<T>(this string objString) => JsonConvert.DeserializeObject<T>(objString, CreateGlobalSettings()); public static T Deserialize<T>(this string objString) => JsonConvert.DeserializeObject<T>(objString, CreateGlobalSettings());
public static void DeserializeInto<T>(this string objString, T target) => JsonConvert.PopulateObject(objString, target, CreateGlobalSettings()); public static void DeserializeInto<T>(this string objString, T target) => JsonConvert.PopulateObject(objString, target, CreateGlobalSettings());
/// <summary>
/// Creates the default <see cref="JsonSerializerSettings"/> that should be used for all <see cref="IJsonSerializable"/>s.
/// </summary>
public static JsonSerializerSettings CreateGlobalSettings() => new JsonSerializerSettings public static JsonSerializerSettings CreateGlobalSettings() => new JsonSerializerSettings
{ {
ReferenceLoopHandling = ReferenceLoopHandling.Ignore, ReferenceLoopHandling = ReferenceLoopHandling.Ignore,

View File

@ -104,6 +104,8 @@ namespace osu.Game
protected Container ScreenOffsetContainer { get; private set; } protected Container ScreenOffsetContainer { get; private set; }
private Container overlayOffsetContainer;
[Resolved] [Resolved]
private FrameworkConfigManager frameworkConfig { get; set; } private FrameworkConfigManager frameworkConfig { get; set; }
@ -120,7 +122,7 @@ namespace osu.Game
public virtual StableStorage GetStorageForStableInstall() => null; public virtual StableStorage GetStorageForStableInstall() => null;
public float ToolbarOffset => (Toolbar?.Position.Y ?? 0) + (Toolbar?.DrawHeight ?? 0); private float toolbarOffset => (Toolbar?.Position.Y ?? 0) + (Toolbar?.DrawHeight ?? 0);
private IdleTracker idleTracker; private IdleTracker idleTracker;
@ -158,7 +160,7 @@ namespace osu.Game
private readonly string[] args; private readonly string[] args;
private readonly List<OverlayContainer> overlays = new List<OverlayContainer>(); private readonly List<OsuFocusedOverlayContainer> focusedOverlays = new List<OsuFocusedOverlayContainer>();
private readonly List<OverlayContainer> visibleBlockingOverlays = new List<OverlayContainer>(); private readonly List<OverlayContainer> visibleBlockingOverlays = new List<OverlayContainer>();
@ -193,7 +195,7 @@ namespace osu.Game
/// <param name="hideToolbar">Whether the toolbar should also be hidden.</param> /// <param name="hideToolbar">Whether the toolbar should also be hidden.</param>
public void CloseAllOverlays(bool hideToolbar = true) public void CloseAllOverlays(bool hideToolbar = true)
{ {
foreach (var overlay in overlays) foreach (var overlay in focusedOverlays)
overlay.Hide(); overlay.Hide();
if (hideToolbar) Toolbar.Hide(); if (hideToolbar) Toolbar.Hide();
@ -692,9 +694,16 @@ namespace osu.Game
}, },
} }
}, },
overlayOffsetContainer = new Container
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
overlayContent = new Container { RelativeSizeAxes = Axes.Both }, overlayContent = new Container { RelativeSizeAxes = Axes.Both },
rightFloatingOverlayContent = new Container { RelativeSizeAxes = Axes.Both }, rightFloatingOverlayContent = new Container { RelativeSizeAxes = Axes.Both },
leftFloatingOverlayContent = new Container { RelativeSizeAxes = Axes.Both }, leftFloatingOverlayContent = new Container { RelativeSizeAxes = Axes.Both },
}
},
topMostOverlayContent = new Container { RelativeSizeAxes = Axes.Both }, topMostOverlayContent = new Container { RelativeSizeAxes = Axes.Both },
idleTracker, idleTracker,
new ConfineMouseTracker() new ConfineMouseTracker()
@ -731,7 +740,6 @@ namespace osu.Game
loadComponentSingleFile(Notifications.With(d => loadComponentSingleFile(Notifications.With(d =>
{ {
d.GetToolbarHeight = () => ToolbarOffset;
d.Anchor = Anchor.TopRight; d.Anchor = Anchor.TopRight;
d.Origin = Anchor.TopRight; d.Origin = Anchor.TopRight;
}), rightFloatingOverlayContent.Add, true); }), rightFloatingOverlayContent.Add, true);
@ -757,7 +765,7 @@ namespace osu.Game
loadComponentSingleFile(channelManager = new ChannelManager(), AddInternal, true); loadComponentSingleFile(channelManager = new ChannelManager(), AddInternal, true);
loadComponentSingleFile(chatOverlay = new ChatOverlay(), overlayContent.Add, true); loadComponentSingleFile(chatOverlay = new ChatOverlay(), overlayContent.Add, true);
loadComponentSingleFile(new MessageNotifier(), AddInternal, true); loadComponentSingleFile(new MessageNotifier(), AddInternal, true);
loadComponentSingleFile(Settings = new SettingsOverlay { GetToolbarHeight = () => ToolbarOffset }, leftFloatingOverlayContent.Add, true); loadComponentSingleFile(Settings = new SettingsOverlay(), leftFloatingOverlayContent.Add, true);
var changelogOverlay = loadComponentSingleFile(new ChangelogOverlay(), overlayContent.Add, true); var changelogOverlay = loadComponentSingleFile(new ChangelogOverlay(), overlayContent.Add, true);
loadComponentSingleFile(userProfile = new UserProfileOverlay(), overlayContent.Add, true); loadComponentSingleFile(userProfile = new UserProfileOverlay(), overlayContent.Add, true);
loadComponentSingleFile(beatmapSetOverlay = new BeatmapSetOverlay(), overlayContent.Add, true); loadComponentSingleFile(beatmapSetOverlay = new BeatmapSetOverlay(), overlayContent.Add, true);
@ -766,14 +774,12 @@ namespace osu.Game
loadComponentSingleFile(new LoginOverlay loadComponentSingleFile(new LoginOverlay
{ {
GetToolbarHeight = () => ToolbarOffset,
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
Origin = Anchor.TopRight, Origin = Anchor.TopRight,
}, rightFloatingOverlayContent.Add, true); }, rightFloatingOverlayContent.Add, true);
loadComponentSingleFile(new NowPlayingOverlay loadComponentSingleFile(new NowPlayingOverlay
{ {
GetToolbarHeight = () => ToolbarOffset,
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
Origin = Anchor.TopRight, Origin = Anchor.TopRight,
}, rightFloatingOverlayContent.Add, true); }, rightFloatingOverlayContent.Add, true);
@ -904,8 +910,8 @@ namespace osu.Game
if (cache) if (cache)
dependencies.CacheAs(component); dependencies.CacheAs(component);
if (component is OverlayContainer overlay) if (component is OsuFocusedOverlayContainer overlay)
overlays.Add(overlay); focusedOverlays.Add(overlay);
// schedule is here to ensure that all component loads are done after LoadComplete is run (and thus all dependencies are cached). // schedule is here to ensure that all component loads are done after LoadComplete is run (and thus all dependencies are cached).
// with some better organisation of LoadComplete to do construction and dependency caching in one step, followed by calls to loadComponentSingleFile, // with some better organisation of LoadComplete to do construction and dependency caching in one step, followed by calls to loadComponentSingleFile,
@ -1013,8 +1019,8 @@ namespace osu.Game
{ {
base.UpdateAfterChildren(); base.UpdateAfterChildren();
ScreenOffsetContainer.Padding = new MarginPadding { Top = ToolbarOffset }; ScreenOffsetContainer.Padding = new MarginPadding { Top = toolbarOffset };
overlayContent.Padding = new MarginPadding { Top = ToolbarOffset }; overlayOffsetContainer.Padding = new MarginPadding { Top = toolbarOffset };
var horizontalOffset = 0f; var horizontalOffset = 0f;

View File

@ -140,12 +140,8 @@ namespace osu.Game.Overlays.Dashboard.Home.News
} }
} }
private class Date : CompositeDrawable, IHasCustomTooltip private class Date : CompositeDrawable, IHasCustomTooltip<DateTimeOffset>
{ {
public ITooltip GetCustomTooltip() => new DateTooltip();
public object TooltipContent => date;
private readonly DateTimeOffset date; private readonly DateTimeOffset date;
public Date(DateTimeOffset date) public Date(DateTimeOffset date)
@ -190,6 +186,10 @@ namespace osu.Game.Overlays.Dashboard.Home.News
} }
}; };
} }
ITooltip<DateTimeOffset> IHasCustomTooltip<DateTimeOffset>.GetCustomTooltip() => new DateTooltip();
DateTimeOffset IHasCustomTooltip<DateTimeOffset>.TooltipContent => date;
} }
} }
} }

View File

@ -67,12 +67,8 @@ namespace osu.Game.Overlays.Dashboard.Home.News
}; };
} }
private class Date : CompositeDrawable, IHasCustomTooltip private class Date : CompositeDrawable, IHasCustomTooltip<DateTimeOffset>
{ {
public ITooltip GetCustomTooltip() => new DateTooltip();
public object TooltipContent => date;
private readonly DateTimeOffset date; private readonly DateTimeOffset date;
public Date(DateTimeOffset date) public Date(DateTimeOffset date)
@ -110,6 +106,10 @@ namespace osu.Game.Overlays.Dashboard.Home.News
t.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Regular); t.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Regular);
}); });
} }
ITooltip<DateTimeOffset> IHasCustomTooltip<DateTimeOffset>.GetCustomTooltip() => new DateTooltip();
DateTimeOffset IHasCustomTooltip<DateTimeOffset>.TooltipContent => date;
} }
} }
} }

View File

@ -10,7 +10,6 @@ using osuTK.Graphics;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Cursor; using osu.Game.Graphics.Cursor;
using System;
namespace osu.Game.Overlays namespace osu.Game.Overlays
{ {
@ -20,11 +19,6 @@ namespace osu.Game.Overlays
private const float transition_time = 400; private const float transition_time = 400;
/// <summary>
/// Provide a source for the toolbar height.
/// </summary>
public Func<float> GetToolbarHeight;
public LoginOverlay() public LoginOverlay()
{ {
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
@ -94,12 +88,5 @@ namespace osu.Game.Overlays
settingsSection.Bounding = false; settingsSection.Bounding = false;
this.FadeOut(transition_time); this.FadeOut(transition_time);
} }
protected override void UpdateAfterChildren()
{
base.UpdateAfterChildren();
Padding = new MarginPadding { Top = GetToolbarHeight?.Invoke() ?? 0 };
}
} }
} }

View File

@ -123,12 +123,8 @@ namespace osu.Game.Overlays.News
main.AddText(post.Author, t => t.Font = OsuFont.GetFont(size: 12, weight: FontWeight.SemiBold)); main.AddText(post.Author, t => t.Font = OsuFont.GetFont(size: 12, weight: FontWeight.SemiBold));
} }
private class DateContainer : CircularContainer, IHasCustomTooltip private class DateContainer : CircularContainer, IHasCustomTooltip<DateTimeOffset>
{ {
public ITooltip GetCustomTooltip() => new DateTooltip();
public object TooltipContent => date;
private readonly DateTimeOffset date; private readonly DateTimeOffset date;
public DateContainer(DateTimeOffset date) public DateContainer(DateTimeOffset date)
@ -162,6 +158,10 @@ namespace osu.Game.Overlays.News
} }
protected override bool OnClick(ClickEvent e) => true; // Protects the NewsCard from clicks while hovering DateContainer protected override bool OnClick(ClickEvent e) => true; // Protects the NewsCard from clicks while hovering DateContainer
ITooltip<DateTimeOffset> IHasCustomTooltip<DateTimeOffset>.GetCustomTooltip() => new DateTooltip();
DateTimeOffset IHasCustomTooltip<DateTimeOffset>.TooltipContent => date;
} }
} }
} }

View File

@ -8,7 +8,6 @@ using osu.Framework.Graphics.Containers;
using osu.Game.Overlays.Notifications; using osu.Game.Overlays.Notifications;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using System;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Localisation; using osu.Framework.Localisation;
@ -30,11 +29,6 @@ namespace osu.Game.Overlays
private FlowContainer<NotificationSection> sections; private FlowContainer<NotificationSection> sections;
/// <summary>
/// Provide a source for the toolbar height.
/// </summary>
public Func<float> GetToolbarHeight;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
@ -168,12 +162,5 @@ namespace osu.Game.Overlays
updateCounts(); updateCounts();
} }
protected override void UpdateAfterChildren()
{
base.UpdateAfterChildren();
Padding = new MarginPadding { Top = GetToolbarHeight?.Invoke() ?? 0 };
}
} }
} }

View File

@ -55,11 +55,6 @@ namespace osu.Game.Overlays
protected override string PopInSampleName => "UI/now-playing-pop-in"; protected override string PopInSampleName => "UI/now-playing-pop-in";
protected override string PopOutSampleName => "UI/now-playing-pop-out"; protected override string PopOutSampleName => "UI/now-playing-pop-out";
/// <summary>
/// Provide a source for the toolbar height.
/// </summary>
public Func<float> GetToolbarHeight;
[Resolved] [Resolved]
private MusicController musicController { get; set; } private MusicController musicController { get; set; }
@ -246,7 +241,6 @@ namespace osu.Game.Overlays
base.UpdateAfterChildren(); base.UpdateAfterChildren();
Height = dragContainer.Height; Height = dragContainer.Height;
dragContainer.Padding = new MarginPadding { Top = GetToolbarHeight?.Invoke() ?? 0 };
} }
protected override void Update() protected override void Update()

View File

@ -54,11 +54,6 @@ namespace osu.Game.Overlays
protected override string PopInSampleName => "UI/settings-pop-in"; protected override string PopInSampleName => "UI/settings-pop-in";
/// <summary>
/// Provide a source for the toolbar height.
/// </summary>
public Func<float> GetToolbarHeight;
private readonly bool showSidebar; private readonly bool showSidebar;
private LoadingLayer loading; private LoadingLayer loading;
@ -193,7 +188,6 @@ namespace osu.Game.Overlays
base.UpdateAfterChildren(); base.UpdateAfterChildren();
ContentContainer.Margin = new MarginPadding { Left = Sidebar?.DrawWidth ?? 0 }; ContentContainer.Margin = new MarginPadding { Left = Sidebar?.DrawWidth ?? 0 };
Padding = new MarginPadding { Top = GetToolbarHeight?.Invoke() ?? 0 };
} }
private const double fade_in_duration = 1000; private const double fade_in_duration = 1000;

View File

@ -18,7 +18,7 @@ using osu.Game.Input.Bindings;
namespace osu.Game.Overlays.Toolbar namespace osu.Game.Overlays.Toolbar
{ {
public class Toolbar : VisibilityContainer, IKeyBindingHandler<GlobalAction> public class Toolbar : OverlayContainer, IKeyBindingHandler<GlobalAction>
{ {
public const float HEIGHT = 40; public const float HEIGHT = 40;
public const float TOOLTIP_HEIGHT = 30; public const float TOOLTIP_HEIGHT = 30;
@ -41,6 +41,8 @@ namespace osu.Game.Overlays.Toolbar
// Toolbar and its components need keyboard input even when hidden. // Toolbar and its components need keyboard input even when hidden.
public override bool PropagateNonPositionalInputSubTree => true; public override bool PropagateNonPositionalInputSubTree => true;
protected override bool BlockScrollInput => false;
public Toolbar() public Toolbar()
{ {
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;

View File

@ -11,7 +11,6 @@ using osu.Framework.Extensions.TypeExtensions;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.IO.Serialization;
using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI;
using osu.Game.Utils; using osu.Game.Utils;
@ -21,7 +20,7 @@ namespace osu.Game.Rulesets.Mods
/// The base class for gameplay modifiers. /// The base class for gameplay modifiers.
/// </summary> /// </summary>
[ExcludeFromDynamicCompile] [ExcludeFromDynamicCompile]
public abstract class Mod : IMod, IEquatable<Mod>, IJsonSerializable, IDeepCloneable<Mod> public abstract class Mod : IMod, IEquatable<Mod>, IDeepCloneable<Mod>
{ {
/// <summary> /// <summary>
/// The name of this mod. /// The name of this mod.

View File

@ -3,14 +3,13 @@
using System; using System;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
using osu.Game.IO.Serialization;
namespace osu.Game.Rulesets.Timing namespace osu.Game.Rulesets.Timing
{ {
/// <summary> /// <summary>
/// A control point which adds an aggregated multiplier based on the provided <see cref="TimingPoint"/>'s BeatLength and <see cref="DifficultyPoint"/>'s SpeedMultiplier. /// A control point which adds an aggregated multiplier based on the provided <see cref="TimingPoint"/>'s BeatLength and <see cref="DifficultyPoint"/>'s SpeedMultiplier.
/// </summary> /// </summary>
public class MultiplierControlPoint : IJsonSerializable, IComparable<MultiplierControlPoint> public class MultiplierControlPoint : IComparable<MultiplierControlPoint>
{ {
/// <summary> /// <summary>
/// The time in milliseconds at which this <see cref="MultiplierControlPoint"/> starts. /// The time in milliseconds at which this <see cref="MultiplierControlPoint"/> starts.

View File

@ -4,13 +4,12 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Newtonsoft.Json; using Newtonsoft.Json;
using osu.Game.IO.Serialization;
using osu.Game.IO.Serialization.Converters; using osu.Game.IO.Serialization.Converters;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
namespace osu.Game.Screens.Edit namespace osu.Game.Screens.Edit
{ {
public class ClipboardContent : IJsonSerializable public class ClipboardContent
{ {
[JsonConverter(typeof(TypedListConverter<HitObject>))] [JsonConverter(typeof(TypedListConverter<HitObject>))]
public IList<HitObject> HitObjects; public IList<HitObject> HitObjects;

View File

@ -1,14 +1,27 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using System;
using System.Globalization;
using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Game.Beatmaps;
using osu.Game.Graphics.UserInterfaceV2; using osu.Game.Graphics.UserInterfaceV2;
using osuTK;
namespace osu.Game.Screens.Edit.Setup namespace osu.Game.Screens.Edit.Setup
{ {
internal class DesignSection : SetupSection internal class DesignSection : SetupSection
{ {
protected LabelledSwitchButton EnableCountdown;
protected FillFlowContainer CountdownSettings;
protected LabelledEnumDropdown<CountdownType> CountdownSpeed;
protected LabelledNumberBox CountdownOffset;
private LabelledSwitchButton widescreenSupport; private LabelledSwitchButton widescreenSupport;
private LabelledSwitchButton epilepsyWarning; private LabelledSwitchButton epilepsyWarning;
private LabelledSwitchButton letterboxDuringBreaks; private LabelledSwitchButton letterboxDuringBreaks;
@ -20,6 +33,35 @@ namespace osu.Game.Screens.Edit.Setup
{ {
Children = new[] Children = new[]
{ {
EnableCountdown = new LabelledSwitchButton
{
Label = "Enable countdown",
Current = { Value = Beatmap.BeatmapInfo.Countdown != CountdownType.None },
Description = "If enabled, an \"Are you ready? 3, 2, 1, GO!\" countdown will be inserted at the beginning of the beatmap, assuming there is enough time to do so."
},
CountdownSettings = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Spacing = new Vector2(10),
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
CountdownSpeed = new LabelledEnumDropdown<CountdownType>
{
Label = "Countdown speed",
Current = { Value = Beatmap.BeatmapInfo.Countdown != CountdownType.None ? Beatmap.BeatmapInfo.Countdown : CountdownType.Normal },
Items = Enum.GetValues(typeof(CountdownType)).Cast<CountdownType>().Where(type => type != CountdownType.None)
},
CountdownOffset = new LabelledNumberBox
{
Label = "Countdown offset",
Current = { Value = Beatmap.BeatmapInfo.CountdownOffset.ToString() },
Description = "If the countdown sounds off-time, use this to make it appear one or more beats early.",
}
}
},
Empty(),
widescreenSupport = new LabelledSwitchButton widescreenSupport = new LabelledSwitchButton
{ {
Label = "Widescreen support", Label = "Widescreen support",
@ -45,13 +87,31 @@ namespace osu.Game.Screens.Edit.Setup
{ {
base.LoadComplete(); base.LoadComplete();
EnableCountdown.Current.BindValueChanged(_ => updateCountdownSettingsVisibility(), true);
EnableCountdown.Current.BindValueChanged(_ => updateBeatmap());
CountdownSpeed.Current.BindValueChanged(_ => updateBeatmap());
CountdownOffset.OnCommit += (_, __) => onOffsetCommitted();
widescreenSupport.Current.BindValueChanged(_ => updateBeatmap()); widescreenSupport.Current.BindValueChanged(_ => updateBeatmap());
epilepsyWarning.Current.BindValueChanged(_ => updateBeatmap()); epilepsyWarning.Current.BindValueChanged(_ => updateBeatmap());
letterboxDuringBreaks.Current.BindValueChanged(_ => updateBeatmap()); letterboxDuringBreaks.Current.BindValueChanged(_ => updateBeatmap());
} }
private void updateCountdownSettingsVisibility() => CountdownSettings.FadeTo(EnableCountdown.Current.Value ? 1 : 0);
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);
}
private void updateBeatmap() private void updateBeatmap()
{ {
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;
Beatmap.BeatmapInfo.WidescreenStoryboard = widescreenSupport.Current.Value; Beatmap.BeatmapInfo.WidescreenStoryboard = widescreenSupport.Current.Value;
Beatmap.BeatmapInfo.EpilepsyWarning = epilepsyWarning.Current.Value; Beatmap.BeatmapInfo.EpilepsyWarning = epilepsyWarning.Current.Value;
Beatmap.BeatmapInfo.LetterboxInBreaks = letterboxDuringBreaks.Current.Value; Beatmap.BeatmapInfo.LetterboxInBreaks = letterboxDuringBreaks.Current.Value;

View File

@ -8,7 +8,6 @@ using Newtonsoft.Json;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Extensions; using osu.Game.Extensions;
using osu.Game.IO.Serialization;
using osu.Game.Skinning; using osu.Game.Skinning;
using osuTK; using osuTK;
@ -18,7 +17,7 @@ namespace osu.Game.Screens.Play.HUD
/// Serialised information governing custom changes to an <see cref="ISkinnableDrawable"/>. /// Serialised information governing custom changes to an <see cref="ISkinnableDrawable"/>.
/// </summary> /// </summary>
[Serializable] [Serializable]
public class SkinnableInfo : IJsonSerializable public class SkinnableInfo
{ {
public Type Type { get; set; } public Type Type { get; set; }