Merge master with conflicts resolved

This commit is contained in:
Andrei Zavatski 2020-11-11 01:37:01 +03:00
commit 6c428d8b11
11 changed files with 71 additions and 44 deletions

View File

@ -2,9 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using osu.Game.Overlays.Profile.Sections.Historical;
using osu.Game.Overlays.Profile;
using osu.Framework.Graphics;
using osu.Game.Overlays;
using osu.Framework.Allocation;
@ -14,12 +12,6 @@ namespace osu.Game.Tests.Visual.Online
{
public class TestSceneUserHistoryGraph : OsuTestScene
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(UserHistoryGraph),
typeof(UserGraph<,>),
};
[Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Pink);

View File

@ -32,6 +32,11 @@ namespace osu.Game.Overlays.BeatmapListing
/// </summary>
public Action SearchStarted;
/// <summary>
/// Any time the search text box receives key events (even while masked).
/// </summary>
public Action TypingStarted;
/// <summary>
/// True when pagination has reached the end of available results.
/// </summary>
@ -82,7 +87,10 @@ namespace osu.Game.Overlays.BeatmapListing
Radius = 3,
Offset = new Vector2(0f, 1f),
},
Child = searchControl = new BeatmapListingSearchControl(),
Child = searchControl = new BeatmapListingSearchControl
{
TypingStarted = () => TypingStarted?.Invoke()
}
},
new Container
{

View File

@ -1,12 +1,14 @@
// 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 osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osuTK;
using osu.Framework.Bindables;
using osu.Framework.Input.Events;
using osu.Game.Beatmaps.Drawables;
using osu.Game.Beatmaps;
using osu.Game.Graphics.Containers;
@ -19,6 +21,11 @@ namespace osu.Game.Overlays.BeatmapListing
{
public class BeatmapListingSearchControl : CompositeDrawable
{
/// <summary>
/// Any time the text box receives key events (even while masked).
/// </summary>
public Action TypingStarted;
public Bindable<string> Query => textBox.Current;
public Bindable<RulesetInfo> Ruleset => modeFilter.Current;
@ -102,6 +109,7 @@ namespace osu.Game.Overlays.BeatmapListing
textBox = new BeatmapSearchTextBox
{
RelativeSizeAxes = Axes.X,
TypingStarted = () => TypingStarted?.Invoke(),
},
new ReverseChildIDFillFlowContainer<Drawable>
{
@ -138,12 +146,26 @@ namespace osu.Game.Overlays.BeatmapListing
private class BeatmapSearchTextBox : SearchTextBox
{
/// <summary>
/// Any time the text box receives key events (even while masked).
/// </summary>
public Action TypingStarted;
protected override Color4 SelectionColour => Color4.Gray;
public BeatmapSearchTextBox()
{
PlaceholderText = @"type in keywords...";
}
protected override bool OnKeyDown(KeyDownEvent e)
{
if (!base.OnKeyDown(e))
return false;
TypingStarted?.Invoke();
return true;
}
}
}
}

View File

@ -68,6 +68,7 @@ namespace osu.Game.Overlays
Header,
filterControl = new BeatmapListingFilterControl
{
TypingStarted = onTypingStarted,
SearchStarted = onSearchStarted,
SearchFinished = onSearchFinished,
},
@ -102,6 +103,12 @@ namespace osu.Game.Overlays
};
}
private void onTypingStarted()
{
// temporary until the textbox/header is updated to always stay on screen.
resultScrollContainer.ScrollToStart();
}
protected override void OnFocus(FocusEvent e)
{
base.OnFocus(e);

View File

@ -85,6 +85,8 @@ namespace osu.Game.Overlays.Mods
protected override bool OnKeyDown(KeyDownEvent e)
{
if (e.ControlPressed) return false;
if (ToggleKeys != null)
{
var index = Array.IndexOf(ToggleKeys, e.Key);

View File

@ -41,7 +41,6 @@ namespace osu.Game.Overlays.Profile.Header.Components
private void updateStatistics(UserStatistics statistics)
{
int[] userRanks = statistics?.RankHistory?.Data;
Data = userRanks?.Select((x, index) => new KeyValuePair<int, int>(index, x)).Where(x => x.Value != 0).ToArray();
}

View File

@ -29,7 +29,7 @@ namespace osu.Game.Overlays.Profile
private readonly UserLineGraph graph;
private KeyValuePair<TKey, TValue>[] data;
private int dataIndex;
private int hoveredIndex = -1;
protected UserGraph()
{
@ -39,7 +39,7 @@ namespace osu.Game.Overlays.Profile
Alpha = 0
});
graph.OnBallMove += i => dataIndex = i;
graph.OnBallMove += i => hoveredIndex = i;
}
[BackgroundDependencyLoader]
@ -48,11 +48,13 @@ namespace osu.Game.Overlays.Profile
graph.LineColour = colours.Yellow;
}
private float lastHoverPosition;
protected override bool OnHover(HoverEvent e)
{
if (data?.Length > 1)
{
graph.UpdateBallPosition(e.MousePosition.X);
graph.UpdateBallPosition(lastHoverPosition = e.MousePosition.X);
graph.ShowBar();
return true;
@ -71,9 +73,7 @@ namespace osu.Game.Overlays.Profile
protected override void OnHoverLost(HoverLostEvent e)
{
if (data?.Length > 1)
graph.HideBar();
graph.HideBar();
base.OnHoverLost(e);
}
@ -92,11 +92,16 @@ namespace osu.Game.Overlays.Profile
private void redrawGraph()
{
hoveredIndex = -1;
if (data?.Length > 1)
{
graph.DefaultValueCount = data.Length;
graph.Values = data.Select(pair => GetDataPointHeight(pair.Value)).ToArray();
ShowGraph();
if (IsHovered)
graph.UpdateBallPosition(lastHoverPosition);
return;
}
@ -120,13 +125,11 @@ namespace osu.Game.Overlays.Profile
{
get
{
if (data?.Length > 1)
{
var (key, value) = data[dataIndex];
return GetTooltipContent(key, value);
}
if (data == null || hoveredIndex == -1)
return null;
return null;
var (key, value) = data[hoveredIndex];
return GetTooltipContent(key, value);
}
}
@ -194,7 +197,7 @@ namespace osu.Game.Overlays.Profile
public void HideBar() => bar.FadeOut(FADE_DURATION);
private int calculateIndex(float mouseXPosition) => (int)MathF.Round(mouseXPosition / DrawWidth * (DefaultValueCount - 1));
private int calculateIndex(float mouseXPosition) => (int)Math.Clamp(MathF.Round(mouseXPosition / DrawWidth * (DefaultValueCount - 1)), 0, DefaultValueCount - 1);
private Vector2 calculateBallPosition(int index)
{

View File

@ -290,7 +290,7 @@ namespace osu.Game.Rulesets.Scoring
/// </summary>
public virtual void PopulateScore(ScoreInfo score)
{
score.TotalScore = (long)Math.Round(TotalScore.Value);
score.TotalScore = (long)Math.Round(GetStandardisedScore());
score.Combo = Combo.Value;
score.MaxCombo = HighestCombo.Value;
score.Accuracy = Math.Round(Accuracy.Value, 4);

View File

@ -295,21 +295,15 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// <returns>Whether a selection was performed.</returns>
private bool beginClickSelection(MouseButtonEvent e)
{
Debug.Assert(!clickSelectionBegan);
bool selectedPerformed = true;
foreach (SelectionBlueprint blueprint in SelectionBlueprints.AliveChildren)
{
if (blueprint.IsHovered)
{
selectedPerformed &= SelectionHandler.HandleSelectionRequested(blueprint, e.CurrentState);
clickSelectionBegan = true;
break;
}
if (!blueprint.IsHovered) continue;
if (SelectionHandler.HandleSelectionRequested(blueprint, e))
return clickSelectionBegan = true;
}
return selectedPerformed;
return false;
}
/// <summary>

View File

@ -14,7 +14,7 @@ using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.States;
using osu.Framework.Input.Events;
using osu.Game.Audio;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
@ -218,17 +218,17 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// Handle a blueprint requesting selection.
/// </summary>
/// <param name="blueprint">The blueprint.</param>
/// <param name="state">The input state at the point of selection.</param>
/// <param name="e">The mouse event responsible for selection.</param>
/// <returns>Whether a selection was performed.</returns>
internal bool HandleSelectionRequested(SelectionBlueprint blueprint, InputState state)
internal bool HandleSelectionRequested(SelectionBlueprint blueprint, MouseButtonEvent e)
{
if (state.Keyboard.ShiftPressed && state.Mouse.IsPressed(MouseButton.Right))
if (e.ShiftPressed && e.Button == MouseButton.Right)
{
handleQuickDeletion(blueprint);
return false;
}
if (state.Keyboard.ControlPressed && state.Mouse.IsPressed(MouseButton.Left))
if (e.ControlPressed && e.Button == MouseButton.Left)
blueprint.ToggleSelection();
else
ensureSelected(blueprint);

View File

@ -115,11 +115,11 @@ namespace osu.Game.Storyboards.Drawables
[BackgroundDependencyLoader]
private void load(TextureStore textureStore, Storyboard storyboard)
{
for (int frame = 0; frame < Animation.FrameCount; frame++)
for (int frameIndex = 0; frameIndex < Animation.FrameCount; frameIndex++)
{
string framePath = Animation.Path.Replace(".", frame + ".");
AddFrame(storyboard.CreateSpriteFromResourcePath(framePath, textureStore), Animation.FrameDelay);
string framePath = Animation.Path.Replace(".", frameIndex + ".");
Drawable frame = storyboard.CreateSpriteFromResourcePath(framePath, textureStore) ?? Empty();
AddFrame(frame, Animation.FrameDelay);
}
Animation.ApplyTransforms(this);