mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 15:22:55 +08:00
Merge branch 'master' into scroll-to-20
This commit is contained in:
commit
360f26c13d
@ -40,6 +40,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
[SetUp]
|
||||
public void SetUp() => Schedule(() =>
|
||||
{
|
||||
SelectedMods.Value = Array.Empty<Mod>();
|
||||
Children = new Drawable[]
|
||||
{
|
||||
modSelect = new TestModSelectOverlay
|
||||
@ -134,6 +135,8 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
[Test]
|
||||
public void TestExternallySetCustomizedMod()
|
||||
{
|
||||
changeRuleset(0);
|
||||
|
||||
AddStep("set customized mod externally", () => SelectedMods.Value = new[] { new OsuModDoubleTime { SpeedChange = { Value = 1.01 } } });
|
||||
|
||||
AddAssert("ensure button is selected and customized accordingly", () =>
|
||||
|
@ -24,6 +24,10 @@ namespace osu.Game.Graphics.Containers
|
||||
|
||||
private Bindable<bool> parallaxEnabled;
|
||||
|
||||
private const float parallax_duration = 100;
|
||||
|
||||
private bool firstUpdate = true;
|
||||
|
||||
public ParallaxContainer()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
@ -60,17 +64,27 @@ namespace osu.Game.Graphics.Containers
|
||||
input = GetContainingInputManager();
|
||||
}
|
||||
|
||||
private bool firstUpdate = true;
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (parallaxEnabled.Value)
|
||||
{
|
||||
Vector2 offset = (input.CurrentState.Mouse == null ? Vector2.Zero : ToLocalSpace(input.CurrentState.Mouse.Position) - DrawSize / 2) * ParallaxAmount;
|
||||
Vector2 offset = Vector2.Zero;
|
||||
|
||||
const float parallax_duration = 100;
|
||||
if (input.CurrentState.Mouse != null)
|
||||
{
|
||||
var sizeDiv2 = DrawSize / 2;
|
||||
|
||||
Vector2 relativeAmount = ToLocalSpace(input.CurrentState.Mouse.Position) - sizeDiv2;
|
||||
|
||||
const float base_factor = 0.999f;
|
||||
|
||||
relativeAmount.X = (float)(Math.Sign(relativeAmount.X) * Interpolation.Damp(0, 1, base_factor, Math.Abs(relativeAmount.X)));
|
||||
relativeAmount.Y = (float)(Math.Sign(relativeAmount.Y) * Interpolation.Damp(0, 1, base_factor, Math.Abs(relativeAmount.Y)));
|
||||
|
||||
offset = relativeAmount * sizeDiv2 * ParallaxAmount;
|
||||
}
|
||||
|
||||
double elapsed = Math.Clamp(Clock.ElapsedFrameTime, 0, parallax_duration);
|
||||
|
||||
|
@ -339,7 +339,7 @@ namespace osu.Game.Online.Chat
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Joins a channel if it has not already been joined.
|
||||
/// Joins a channel if it has not already been joined. Must be called from the update thread.
|
||||
/// </summary>
|
||||
/// <param name="channel">The channel to join.</param>
|
||||
/// <returns>The joined channel. Note that this may not match the parameter channel as it is a backed object.</returns>
|
||||
@ -399,7 +399,11 @@ namespace osu.Game.Online.Chat
|
||||
return channel;
|
||||
}
|
||||
|
||||
public void LeaveChannel(Channel channel)
|
||||
/// <summary>
|
||||
/// Leave the specified channel. Can be called from any thread.
|
||||
/// </summary>
|
||||
/// <param name="channel">The channel to leave.</param>
|
||||
public void LeaveChannel(Channel channel) => Schedule(() =>
|
||||
{
|
||||
if (channel == null) return;
|
||||
|
||||
@ -413,7 +417,7 @@ namespace osu.Game.Online.Chat
|
||||
api.Queue(new LeaveChannelRequest(channel));
|
||||
channel.Joined.Value = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
private long lastMessageId;
|
||||
|
||||
|
@ -190,13 +190,13 @@ namespace osu.Game.Overlays.Chat
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
updateMessageContent();
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
updateMessageContent();
|
||||
FinishTransforms(true);
|
||||
}
|
||||
|
||||
|
@ -49,9 +49,12 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
Spacing = new Vector2(10, 0),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new AddFriendButton
|
||||
new FollowersButton
|
||||
{
|
||||
User = { BindTarget = User }
|
||||
},
|
||||
new MappingSubscribersButton
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
User = { BindTarget = User }
|
||||
},
|
||||
new MessageUserButton
|
||||
@ -69,7 +72,6 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
Width = UserProfileOverlay.CONTENT_X_MARGIN,
|
||||
Child = new ExpandDetailsButton
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
DetailsVisible = { BindTarget = DetailsVisible }
|
||||
|
@ -1,60 +0,0 @@
|
||||
// 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.Sprites;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Users;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Header.Components
|
||||
{
|
||||
public class AddFriendButton : ProfileHeaderButton
|
||||
{
|
||||
public readonly Bindable<User> User = new Bindable<User>();
|
||||
|
||||
public override string TooltipText => "friends";
|
||||
|
||||
private OsuSpriteText followerText;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Child = new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Padding = new MarginPadding { Right = 10 },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new SpriteIcon
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Icon = FontAwesome.Solid.User,
|
||||
FillMode = FillMode.Fit,
|
||||
Size = new Vector2(50, 14)
|
||||
},
|
||||
followerText = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Font = OsuFont.GetFont(weight: FontWeight.Bold)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// todo: when friending/unfriending is implemented, the APIAccess.Friends list should be updated accordingly.
|
||||
|
||||
User.BindValueChanged(user => updateFollowers(user.NewValue), true);
|
||||
}
|
||||
|
||||
private void updateFollowers(User user) => followerText.Text = user?.FollowerCount.ToString("#,##0");
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
// 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.Sprites;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Header.Components
|
||||
{
|
||||
public class FollowersButton : ProfileHeaderStatisticsButton
|
||||
{
|
||||
public readonly Bindable<User> User = new Bindable<User>();
|
||||
|
||||
public override string TooltipText => "followers";
|
||||
|
||||
protected override IconUsage Icon => FontAwesome.Solid.User;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
// todo: when friending/unfriending is implemented, the APIAccess.Friends list should be updated accordingly.
|
||||
User.BindValueChanged(user => SetValue(user.NewValue?.FollowerCount ?? 0), true);
|
||||
}
|
||||
}
|
||||
}
|
@ -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 osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Header.Components
|
||||
{
|
||||
public class MappingSubscribersButton : ProfileHeaderStatisticsButton
|
||||
{
|
||||
public readonly Bindable<User> User = new Bindable<User>();
|
||||
|
||||
public override string TooltipText => "mapping subscribers";
|
||||
|
||||
protected override IconUsage Icon => FontAwesome.Solid.Bell;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
User.BindValueChanged(user => SetValue(user.NewValue?.MappingFollowerCount ?? 0), true);
|
||||
}
|
||||
}
|
||||
}
|
@ -33,7 +33,6 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
||||
public MessageUserButton()
|
||||
{
|
||||
Content.Alpha = 0;
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
|
||||
Child = new SpriteIcon
|
||||
{
|
||||
|
@ -22,6 +22,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
||||
protected ProfileHeaderButton()
|
||||
{
|
||||
AutoSizeAxes = Axes.X;
|
||||
Height = 40;
|
||||
|
||||
base.Content.Add(new CircularContainer
|
||||
{
|
||||
|
@ -0,0 +1,51 @@
|
||||
// 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.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Header.Components
|
||||
{
|
||||
public abstract class ProfileHeaderStatisticsButton : ProfileHeaderButton
|
||||
{
|
||||
private readonly OsuSpriteText drawableText;
|
||||
|
||||
protected ProfileHeaderStatisticsButton()
|
||||
{
|
||||
Child = new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.X,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new SpriteIcon
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Icon = Icon,
|
||||
FillMode = FillMode.Fit,
|
||||
Size = new Vector2(50, 14)
|
||||
},
|
||||
drawableText = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Margin = new MarginPadding { Right = 10 },
|
||||
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold)
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected abstract IconUsage Icon { get; }
|
||||
|
||||
protected void SetValue(int value) => drawableText.Text = value.ToString("#,##0");
|
||||
}
|
||||
}
|
@ -332,7 +332,7 @@ namespace osu.Game.Rulesets.Edit
|
||||
EditorBeatmap.Add(hitObject);
|
||||
|
||||
if (EditorClock.CurrentTime < hitObject.StartTime)
|
||||
EditorClock.SeekTo(hitObject.StartTime);
|
||||
EditorClock.SeekSmoothlyTo(hitObject.StartTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
|
||||
return;
|
||||
|
||||
float markerPos = Math.Clamp(ToLocalSpace(screenPosition).X, 0, DrawWidth);
|
||||
editorClock.SeekTo(markerPos / DrawWidth * editorClock.TrackLength);
|
||||
editorClock.SeekSmoothlyTo(markerPos / DrawWidth * editorClock.TrackLength);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
if (clickedBlueprint == null || SelectionHandler.SelectedBlueprints.FirstOrDefault(b => b.IsHovered) != clickedBlueprint)
|
||||
return false;
|
||||
|
||||
EditorClock?.SeekTo(clickedBlueprint.HitObject.StartTime);
|
||||
EditorClock?.SeekSmoothlyTo(clickedBlueprint.HitObject.StartTime);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -155,12 +155,14 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
seekTrackToCurrent();
|
||||
else if (!editorClock.IsRunning)
|
||||
{
|
||||
// The track isn't running. There are two cases we have to be wary of:
|
||||
// 1) The user flick-drags on this timeline: We want the track to follow us
|
||||
// 2) The user changes the track time through some other means (scrolling in the editor or overview timeline): We want to follow the track time
|
||||
// The track isn't running. There are three cases we have to be wary of:
|
||||
// 1) The user flick-drags on this timeline and we are applying an interpolated seek on the clock, until interrupted by 2 or 3.
|
||||
// 2) The user changes the track time through some other means (scrolling in the editor or overview timeline; clicking a hitobject etc.). We want the timeline to track the clock's time.
|
||||
// 3) An ongoing seek transform is running from an external seek. We want the timeline to track the clock's time.
|
||||
|
||||
// The simplest way to cover both cases is by checking whether the scroll position has changed and the audio hasn't been changed externally
|
||||
if (Current != lastScrollPosition && editorClock.CurrentTime == lastTrackTime)
|
||||
// The simplest way to cover the first two cases is by checking whether the scroll position has changed and the audio hasn't been changed externally
|
||||
// Checking IsSeeking covers the third case, where the transform may not have been applied yet.
|
||||
if (Current != lastScrollPosition && editorClock.CurrentTime == lastTrackTime && !editorClock.IsSeeking)
|
||||
seekTrackToCurrent();
|
||||
else
|
||||
scrollToTrackTime();
|
||||
|
@ -35,6 +35,11 @@ namespace osu.Game.Screens.Edit
|
||||
|
||||
private readonly Bindable<bool> seekingOrStopped = new Bindable<bool>(true);
|
||||
|
||||
/// <summary>
|
||||
/// Whether a seek is currently in progress. True for the duration of a seek performed via <see cref="SeekSmoothlyTo"/>.
|
||||
/// </summary>
|
||||
public bool IsSeeking { get; private set; }
|
||||
|
||||
public EditorClock(WorkingBeatmap beatmap, BindableBeatDivisor beatDivisor)
|
||||
: this(beatmap.Beatmap.ControlPointInfo, beatmap.Track.Length, beatDivisor)
|
||||
{
|
||||
@ -111,7 +116,7 @@ namespace osu.Game.Screens.Edit
|
||||
|
||||
if (!snapped || ControlPointInfo.TimingPoints.Count == 0)
|
||||
{
|
||||
SeekTo(seekTime);
|
||||
SeekSmoothlyTo(seekTime);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -145,11 +150,11 @@ namespace osu.Game.Screens.Edit
|
||||
|
||||
// Ensure the sought point is within the boundaries
|
||||
seekTime = Math.Clamp(seekTime, 0, TrackLength);
|
||||
SeekTo(seekTime);
|
||||
SeekSmoothlyTo(seekTime);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The current time of this clock, include any active transform seeks performed via <see cref="SeekTo"/>.
|
||||
/// The current time of this clock, include any active transform seeks performed via <see cref="SeekSmoothlyTo"/>.
|
||||
/// </summary>
|
||||
public double CurrentTimeAccurate =>
|
||||
Transforms.OfType<TransformSeek>().FirstOrDefault()?.EndValue ?? CurrentTime;
|
||||
@ -176,12 +181,29 @@ namespace osu.Game.Screens.Edit
|
||||
|
||||
public bool Seek(double position)
|
||||
{
|
||||
seekingOrStopped.Value = true;
|
||||
seekingOrStopped.Value = IsSeeking = true;
|
||||
|
||||
ClearTransforms();
|
||||
return underlyingClock.Seek(position);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Seek smoothly to the provided destination.
|
||||
/// Use <see cref="Seek"/> to perform an immediate seek.
|
||||
/// </summary>
|
||||
/// <param name="seekDestination"></param>
|
||||
public void SeekSmoothlyTo(double seekDestination)
|
||||
{
|
||||
seekingOrStopped.Value = true;
|
||||
|
||||
if (IsRunning)
|
||||
Seek(seekDestination);
|
||||
else
|
||||
{
|
||||
transformSeekTo(seekDestination, transform_time, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetSpeedAdjustments() => underlyingClock.ResetSpeedAdjustments();
|
||||
|
||||
double IAdjustableClock.Rate
|
||||
@ -229,6 +251,8 @@ namespace osu.Game.Screens.Edit
|
||||
{
|
||||
if (seekingOrStopped.Value)
|
||||
{
|
||||
IsSeeking &= Transforms.Any();
|
||||
|
||||
if (track.Value?.IsRunning != true)
|
||||
{
|
||||
// seeking in the editor can happen while the track isn't running.
|
||||
@ -239,20 +263,10 @@ namespace osu.Game.Screens.Edit
|
||||
// we are either running a seek tween or doing an immediate seek.
|
||||
// in the case of an immediate seek the seeking bool will be set to false after one update.
|
||||
// this allows for silencing hit sounds and the likes.
|
||||
seekingOrStopped.Value = Transforms.Any();
|
||||
seekingOrStopped.Value = IsSeeking;
|
||||
}
|
||||
}
|
||||
|
||||
public void SeekTo(double seekDestination)
|
||||
{
|
||||
seekingOrStopped.Value = true;
|
||||
|
||||
if (IsRunning)
|
||||
Seek(seekDestination);
|
||||
else
|
||||
transformSeekTo(seekDestination, transform_time, Easing.OutQuint);
|
||||
}
|
||||
|
||||
private void transformSeekTo(double seek, double duration = 0, Easing easing = Easing.None)
|
||||
=> this.TransformTo(this.PopulateTransform(new TransformSeek(), seek, duration, easing));
|
||||
|
||||
|
@ -206,7 +206,7 @@ namespace osu.Game.Screens.Edit.Timing
|
||||
Action = () =>
|
||||
{
|
||||
selectedGroup.Value = controlGroup;
|
||||
clock.SeekTo(controlGroup.Time);
|
||||
clock.SeekSmoothlyTo(controlGroup.Time);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -38,5 +38,11 @@ namespace osu.Game.Screens.OnlinePlay.Match.Components
|
||||
|
||||
Channel.Value = channelManager?.JoinChannel(new Channel { Id = channelId.Value, Type = ChannelType.Multiplayer, Name = $"#lazermp_{roomId.Value}" });
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
channelManager?.LeaveChannel(Channel.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -126,6 +126,9 @@ namespace osu.Game.Users
|
||||
[JsonProperty(@"follower_count")]
|
||||
public int FollowerCount;
|
||||
|
||||
[JsonProperty(@"mapping_follower_count")]
|
||||
public int MappingFollowerCount;
|
||||
|
||||
[JsonProperty(@"favourite_beatmapset_count")]
|
||||
public int FavouriteBeatmapsetCount;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user