Merge remote-tracking branch 'upstream/master' into visible-playfield-boundary

This commit is contained in:
Yao Chung Hu
2020-09-05 01:50:13 -05:00
618 changed files with 13091 additions and 5027 deletions

View File

@ -64,6 +64,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
DragBox = CreateDragBox(select),
selectionHandler,
SelectionBlueprints = CreateSelectionBlueprintContainer(),
selectionHandler.CreateProxy(),
DragBox.CreateProxy().With(p => p.Depth = float.MinValue)
});
@ -121,14 +122,19 @@ namespace osu.Game.Screens.Edit.Compose.Components
return e.Button == MouseButton.Left;
}
private SelectionBlueprint clickedBlueprint;
protected override bool OnClick(ClickEvent e)
{
if (e.Button == MouseButton.Right)
return false;
// store for double-click handling
clickedBlueprint = selectionHandler.SelectedBlueprints.FirstOrDefault(b => b.IsHovered);
// Deselection should only occur if no selected blueprints are hovered
// A special case for when a blueprint was selected via this click is added since OnClick() may occur outside the hitobject and should not trigger deselection
if (endClickSelection() || selectionHandler.SelectedBlueprints.Any(b => b.IsHovered))
if (endClickSelection() || clickedBlueprint != null)
return true;
deselectAll();
@ -140,9 +146,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
if (e.Button == MouseButton.Right)
return false;
SelectionBlueprint clickedBlueprint = selectionHandler.SelectedBlueprints.FirstOrDefault(b => b.IsHovered);
if (clickedBlueprint == null)
// ensure the blueprint which was hovered for the first click is still the hovered blueprint.
if (clickedBlueprint == null || selectionHandler.SelectedBlueprints.FirstOrDefault(b => b.IsHovered) != clickedBlueprint)
return false;
editorClock?.SeekTo(clickedBlueprint.HitObject.StartTime);

View File

@ -15,6 +15,7 @@ using osu.Framework.Input.Bindings;
using osu.Framework.Input.States;
using osu.Game.Audio;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects;
@ -35,7 +36,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
public IEnumerable<HitObject> SelectedHitObjects => selectedBlueprints.Select(b => b.HitObject);
private Drawable outline;
private Drawable content;
private OsuSpriteText selectionDetailsText;
[Resolved(CanBeNull = true)]
protected EditorBeatmap EditorBeatmap { get; private set; }
@ -55,16 +58,42 @@ namespace osu.Game.Screens.Edit.Compose.Components
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
InternalChild = outline = new Container
InternalChild = content = new Container
{
Masking = true,
BorderThickness = BORDER_RADIUS,
BorderColour = colours.Yellow,
Child = new Box
Children = new Drawable[]
{
RelativeSizeAxes = Axes.Both,
AlwaysPresent = true,
Alpha = 0
new Container
{
RelativeSizeAxes = Axes.Both,
Masking = true,
BorderThickness = BORDER_RADIUS,
BorderColour = colours.YellowDark,
Child = new Box
{
RelativeSizeAxes = Axes.Both,
AlwaysPresent = true,
Alpha = 0
}
},
new Container
{
Name = "info text",
AutoSizeAxes = Axes.Both,
Children = new Drawable[]
{
new Box
{
Colour = colours.YellowDark,
RelativeSizeAxes = Axes.Both,
},
selectionDetailsText = new OsuSpriteText
{
Padding = new MarginPadding(2),
Colour = colours.Gray0,
Font = OsuFont.Default.With(size: 11)
}
}
}
}
};
}
@ -131,9 +160,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
selectedBlueprints.Remove(blueprint);
EditorBeatmap.SelectedHitObjects.Remove(blueprint.HitObject);
// We don't want to update visibility if > 0, since we may be deselecting blueprints during drag-selection
if (selectedBlueprints.Count == 0)
UpdateVisibility();
UpdateVisibility();
}
/// <summary>
@ -179,7 +206,11 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// </summary>
internal void UpdateVisibility()
{
if (selectedBlueprints.Count > 0)
int count = selectedBlueprints.Count;
selectionDetailsText.Text = count > 0 ? count.ToString() : string.Empty;
if (count > 0)
Show();
else
Hide();
@ -205,8 +236,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
topLeft -= new Vector2(5);
bottomRight += new Vector2(5);
outline.Size = bottomRight - topLeft;
outline.Position = topLeft;
content.Size = bottomRight - topLeft;
content.Position = topLeft;
}
#endregion

View File

@ -26,6 +26,28 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
[Resolved]
private EditorClock editorClock { get; set; }
/// <summary>
/// The timeline's scroll position in the last frame.
/// </summary>
private float lastScrollPosition;
/// <summary>
/// The track time in the last frame.
/// </summary>
private double lastTrackTime;
/// <summary>
/// Whether the user is currently dragging the timeline.
/// </summary>
private bool handlingDragInput;
/// <summary>
/// Whether the track was playing before a user drag event.
/// </summary>
private bool trackWasPlaying;
private Track track;
public Timeline()
{
ZoomDuration = 200;
@ -59,6 +81,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
waveform.Waveform = b.NewValue.Waveform;
track = b.NewValue.Track;
// todo: i don't think this is safe, the track may not be loaded yet.
if (track.Length > 0)
{
MaxZoom = getZoomLevelForVisibleMilliseconds(500);
@ -68,29 +91,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
}, true);
}
private float getZoomLevelForVisibleMilliseconds(double milliseconds) => (float)(track.Length / milliseconds);
/// <summary>
/// The timeline's scroll position in the last frame.
/// </summary>
private float lastScrollPosition;
/// <summary>
/// The track time in the last frame.
/// </summary>
private double lastTrackTime;
/// <summary>
/// Whether the user is currently dragging the timeline.
/// </summary>
private bool handlingDragInput;
/// <summary>
/// Whether the track was playing before a user drag event.
/// </summary>
private bool trackWasPlaying;
private Track track;
private float getZoomLevelForVisibleMilliseconds(double milliseconds) => Math.Max(1, (float)(track.Length / milliseconds));
protected override void Update()
{