1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 09:02:58 +08:00

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

View File

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

View File

@ -1,12 +1,14 @@
// 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 osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osuTK; using osuTK;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Input.Events;
using osu.Game.Beatmaps.Drawables; using osu.Game.Beatmaps.Drawables;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
@ -19,6 +21,11 @@ namespace osu.Game.Overlays.BeatmapListing
{ {
public class BeatmapListingSearchControl : CompositeDrawable 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<string> Query => textBox.Current;
public Bindable<RulesetInfo> Ruleset => modeFilter.Current; public Bindable<RulesetInfo> Ruleset => modeFilter.Current;
@ -102,6 +109,7 @@ namespace osu.Game.Overlays.BeatmapListing
textBox = new BeatmapSearchTextBox textBox = new BeatmapSearchTextBox
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
TypingStarted = () => TypingStarted?.Invoke(),
}, },
new ReverseChildIDFillFlowContainer<Drawable> new ReverseChildIDFillFlowContainer<Drawable>
{ {
@ -138,12 +146,26 @@ namespace osu.Game.Overlays.BeatmapListing
private class BeatmapSearchTextBox : SearchTextBox 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; protected override Color4 SelectionColour => Color4.Gray;
public BeatmapSearchTextBox() public BeatmapSearchTextBox()
{ {
PlaceholderText = @"type in keywords..."; 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, Header,
filterControl = new BeatmapListingFilterControl filterControl = new BeatmapListingFilterControl
{ {
TypingStarted = onTypingStarted,
SearchStarted = onSearchStarted, SearchStarted = onSearchStarted,
SearchFinished = onSearchFinished, 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) protected override void OnFocus(FocusEvent e)
{ {
base.OnFocus(e); base.OnFocus(e);

View File

@ -85,6 +85,8 @@ namespace osu.Game.Overlays.Mods
protected override bool OnKeyDown(KeyDownEvent e) protected override bool OnKeyDown(KeyDownEvent e)
{ {
if (e.ControlPressed) return false;
if (ToggleKeys != null) if (ToggleKeys != null)
{ {
var index = Array.IndexOf(ToggleKeys, e.Key); 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) private void updateStatistics(UserStatistics statistics)
{ {
int[] userRanks = statistics?.RankHistory?.Data; int[] userRanks = statistics?.RankHistory?.Data;
Data = userRanks?.Select((x, index) => new KeyValuePair<int, int>(index, x)).Where(x => x.Value != 0).ToArray(); 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 readonly UserLineGraph graph;
private KeyValuePair<TKey, TValue>[] data; private KeyValuePair<TKey, TValue>[] data;
private int dataIndex; private int hoveredIndex = -1;
protected UserGraph() protected UserGraph()
{ {
@ -39,7 +39,7 @@ namespace osu.Game.Overlays.Profile
Alpha = 0 Alpha = 0
}); });
graph.OnBallMove += i => dataIndex = i; graph.OnBallMove += i => hoveredIndex = i;
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
@ -48,11 +48,13 @@ namespace osu.Game.Overlays.Profile
graph.LineColour = colours.Yellow; graph.LineColour = colours.Yellow;
} }
private float lastHoverPosition;
protected override bool OnHover(HoverEvent e) protected override bool OnHover(HoverEvent e)
{ {
if (data?.Length > 1) if (data?.Length > 1)
{ {
graph.UpdateBallPosition(e.MousePosition.X); graph.UpdateBallPosition(lastHoverPosition = e.MousePosition.X);
graph.ShowBar(); graph.ShowBar();
return true; return true;
@ -71,9 +73,7 @@ namespace osu.Game.Overlays.Profile
protected override void OnHoverLost(HoverLostEvent e) protected override void OnHoverLost(HoverLostEvent e)
{ {
if (data?.Length > 1) graph.HideBar();
graph.HideBar();
base.OnHoverLost(e); base.OnHoverLost(e);
} }
@ -92,11 +92,16 @@ namespace osu.Game.Overlays.Profile
private void redrawGraph() private void redrawGraph()
{ {
hoveredIndex = -1;
if (data?.Length > 1) if (data?.Length > 1)
{ {
graph.DefaultValueCount = data.Length; graph.DefaultValueCount = data.Length;
graph.Values = data.Select(pair => GetDataPointHeight(pair.Value)).ToArray(); graph.Values = data.Select(pair => GetDataPointHeight(pair.Value)).ToArray();
ShowGraph(); ShowGraph();
if (IsHovered)
graph.UpdateBallPosition(lastHoverPosition);
return; return;
} }
@ -120,13 +125,11 @@ namespace osu.Game.Overlays.Profile
{ {
get get
{ {
if (data?.Length > 1) if (data == null || hoveredIndex == -1)
{ return null;
var (key, value) = data[dataIndex];
return GetTooltipContent(key, value);
}
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); 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) private Vector2 calculateBallPosition(int index)
{ {

View File

@ -290,7 +290,7 @@ namespace osu.Game.Rulesets.Scoring
/// </summary> /// </summary>
public virtual void PopulateScore(ScoreInfo score) public virtual void PopulateScore(ScoreInfo score)
{ {
score.TotalScore = (long)Math.Round(TotalScore.Value); score.TotalScore = (long)Math.Round(GetStandardisedScore());
score.Combo = Combo.Value; score.Combo = Combo.Value;
score.MaxCombo = HighestCombo.Value; score.MaxCombo = HighestCombo.Value;
score.Accuracy = Math.Round(Accuracy.Value, 4); 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> /// <returns>Whether a selection was performed.</returns>
private bool beginClickSelection(MouseButtonEvent e) private bool beginClickSelection(MouseButtonEvent e)
{ {
Debug.Assert(!clickSelectionBegan);
bool selectedPerformed = true;
foreach (SelectionBlueprint blueprint in SelectionBlueprints.AliveChildren) foreach (SelectionBlueprint blueprint in SelectionBlueprints.AliveChildren)
{ {
if (blueprint.IsHovered) if (!blueprint.IsHovered) continue;
{
selectedPerformed &= SelectionHandler.HandleSelectionRequested(blueprint, e.CurrentState); if (SelectionHandler.HandleSelectionRequested(blueprint, e))
clickSelectionBegan = true; return clickSelectionBegan = true;
break;
}
} }
return selectedPerformed; return false;
} }
/// <summary> /// <summary>

View File

@ -14,7 +14,7 @@ using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Framework.Input.Bindings; using osu.Framework.Input.Bindings;
using osu.Framework.Input.States; using osu.Framework.Input.Events;
using osu.Game.Audio; using osu.Game.Audio;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
@ -218,17 +218,17 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// Handle a blueprint requesting selection. /// Handle a blueprint requesting selection.
/// </summary> /// </summary>
/// <param name="blueprint">The blueprint.</param> /// <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> /// <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); handleQuickDeletion(blueprint);
return false; return false;
} }
if (state.Keyboard.ControlPressed && state.Mouse.IsPressed(MouseButton.Left)) if (e.ControlPressed && e.Button == MouseButton.Left)
blueprint.ToggleSelection(); blueprint.ToggleSelection();
else else
ensureSelected(blueprint); ensureSelected(blueprint);

View File

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