Skip to content
Merged

aa #131

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Mania/Edit/DrawableManiaEditorRuleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected override void LoadComplete()

protected override void Update()
{
TargetTimeRange = TimelineTimeRange == null || ShowSpeedChanges.Value ? ComputeScrollTime(Config.Get<double>(ManiaRulesetSetting.ScrollSpeed)) : TimelineTimeRange.Value;
TimeRange.Value = TimelineTimeRange == null || ShowSpeedChanges.Value ? ComputeScrollTime(Config.Get<double>(ManiaRulesetSetting.ScrollSpeed)) : TimelineTimeRange.Value;
base.Update();
}
}
Expand Down
13 changes: 2 additions & 11 deletions osu.Game.Rulesets.Mania/UI/DrawableManiaRuleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Input;
using osu.Framework.Platform;
using osu.Framework.Threading;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Input.Handlers;
Expand Down Expand Up @@ -63,16 +61,11 @@ public partial class DrawableManiaRuleset : DrawableScrollingRuleset<ManiaHitObj

public double TargetTimeRange { get; protected set; }

private double currentTimeRange;

// Stores the current speed adjustment active in gameplay.
private readonly Track speedAdjustmentTrack = new TrackVirtual(0);

private ISkinSource currentSkin = null!;

[Resolved]
private GameHost gameHost { get; set; } = null!;

public DrawableManiaRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod>? mods = null)
: base(ruleset, beatmap, mods)
{
Expand Down Expand Up @@ -119,7 +112,7 @@ private void load(ISkinSource source)
TargetTimeRange = ComputeScrollTime(speed.NewValue);
});

TimeRange.Value = TargetTimeRange = currentTimeRange = ComputeScrollTime(configScrollSpeed.Value);
TimeRange.Value = TargetTimeRange = ComputeScrollTime(configScrollSpeed.Value);

Config.BindWith(ManiaRulesetSetting.MobileLayout, mobileLayout);
mobileLayout.BindValueChanged(_ => updateMobileLayout(), true);
Expand Down Expand Up @@ -179,9 +172,7 @@ private void updateTimeRange()
// This scaling factor preserves the scroll speed as the scroll length varies from changes to the hit position.
float scale = lengthToHitPosition / length_to_default_hit_position;

// we're intentionally using the game host's update clock here to decouple the time range tween from the gameplay clock (which can be arbitrarily paused, or even rewinding)
currentTimeRange = Interpolation.DampContinuously(currentTimeRange, TargetTimeRange, 50, gameHost.UpdateThread.Clock.ElapsedFrameTime);
TimeRange.Value = currentTimeRange * speedAdjustmentTrack.AggregateTempo.Value * speedAdjustmentTrack.AggregateFrequency.Value * scale;
TimeRange.Value = TargetTimeRange * speedAdjustmentTrack.AggregateTempo.Value * speedAdjustmentTrack.AggregateFrequency.Value * scale;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ public void TestScrollSpeedAdjustDuringGameplay()
void checkScrollSpeed(double configValue, double gameplayValue)
{
AddUntilStep($"config value is {configValue}", () => getConfigManager().Get<double>(ManiaRulesetSetting.ScrollSpeed), () => Is.EqualTo(configValue));
AddUntilStep($"gameplay value is {gameplayValue}", () => this.ChildrenOfType<DrawableManiaRuleset>().Single().TargetTimeRange,
AddUntilStep($"gameplay value is {gameplayValue}", () => this.ChildrenOfType<DrawableManiaRuleset>().Single().ScrollingInfo.TimeRange.Value,
() => Is.EqualTo(DrawableManiaRuleset.ComputeScrollTime(gameplayValue)));
}

Expand Down
52 changes: 52 additions & 0 deletions osu.Game.Tests/Visual/RankedPlay/TestSceneBubbleChatHistory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// 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.Online.API.Requests.Responses;
using osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay.Components;

namespace osu.Game.Tests.Visual.RankedPlay
{
public partial class TestSceneBubbleChatHistory : OsuTestScene
{
private RankedPlayChatDisplay.BubbleChatHistory history = null!;

[SetUp]
public void Setup() => Schedule(() =>
{
Child = history = new RankedPlayChatDisplay.BubbleChatHistory
{
Anchor = Anchor.Centre,
Origin = Anchor.BottomCentre,
Width = 300
};
});

[Test]
public void TestPostMessages()
{
int messageId = 1;
AddRepeatStep("post message", () => history.PostMessage(new APIUser { Id = 2 }, $"message {messageId++}"), 20);
}

[Test]
public void TestCollapse()
{
AddStep("set expanded", () => history.Expand());

AddStep("post some messages", () =>
{
for (int i = 0; i < 10; i++)
history.PostMessage(new APIUser { Id = 2 }, $"message {i}");
});

AddWaitStep("wait a bit", 10);
AddStep("set collapsed", () => history.Collapse());
AddWaitStep("wait a bit", 10);
AddStep("set expanded", () => history.Expand());
AddWaitStep("wait a bit", 10);
AddStep("set collapsed", () => history.Collapse());
}
}
}
129 changes: 129 additions & 0 deletions osu.Game.Tests/Visual/RankedPlay/TestSceneRankedPlayChat.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
// 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.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Extensions;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Chat;
using osu.Game.Online.Multiplayer.MatchTypes.RankedPlay;
using osu.Game.Online.Rooms;
using osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay;
using osu.Game.Tests.Visual.Multiplayer;

namespace osu.Game.Tests.Visual.RankedPlay
{
public partial class TestSceneRankedPlayChat : MultiplayerTestScene
{
private ChannelManager channelManager = null!;
private Channel testChannel = null!;
private int messageIdSequence;

protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{
var api = parent.Get<IAPIProvider>();
Add(channelManager = new ChannelManager(api));

var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
dependencies.Cache(channelManager);

return dependencies;
}

[SetUp]
public void SetUp() => Schedule(() =>
{
messageIdSequence = 0;
testChannel = channelManager.JoinChannel(new Channel { Id = 1, Type = ChannelType.Multiplayer });
});

public override void SetUpSteps()
{
base.SetUpSteps();

AddStep("join room", () =>
{
var room = CreateDefaultRoom(MatchType.RankedPlay);
room.ChannelId = 1;
JoinRoom(room);
});

WaitForJoined();

AddStep("join other user", () => MultiplayerClient.AddUser(new APIUser { Id = 2 }));

AddStep("load screen", () => LoadScreen(new RankedPlayScreen(MultiplayerClient.ClientRoom!)));
}

[Test]
public void TestDiscardCardStage()
{
AddStep("set discard phase", () => MultiplayerClient.RankedPlayChangeStage(RankedPlayStage.CardDiscard).WaitSafely());

postLocalUserMessage("this is a message from the local user");
postOpponentMessage("this is a message from the opponent");
}

[Test]
public void TestResultsStage()
{
AddStep("set results state", () => MultiplayerClient.RankedPlayChangeStage(RankedPlayStage.Results, state =>
{
int losingPlayer = state.Users.Keys.First();

foreach (var (id, userInfo) in state.Users)
{
if (id == losingPlayer)
{
userInfo.DamageInfo = new RankedPlayDamageInfo
{
RawDamage = 123_456,
Damage = 123_456,
OldLife = 500_000,
NewLife = 500_000 - 123_456,
};

userInfo.Life = 500_000 - 123_456;
}
else
{
userInfo.DamageInfo = new RankedPlayDamageInfo
{
RawDamage = 0,
Damage = 0,
OldLife = 1_000_000,
NewLife = 1_000_000,
};
}
}
}).WaitSafely());
}

private void postLocalUserMessage(string content)
{
AddStep("add local user message", () => testChannel.AddNewMessages(new Message(messageIdSequence++)
{
Timestamp = DateTimeOffset.Now,
Sender = API.LocalUser.Value,
Content = content
}));
}

private void postOpponentMessage(string content)
{
AddStep("add opponent message", () => testChannel.AddNewMessages(new Message(messageIdSequence++)
{
Timestamp = DateTimeOffset.Now,
Sender = new APIUser
{
Id = 2,
Username = "peppy"
},
Content = content
}));
}
}
}
20 changes: 15 additions & 5 deletions osu.Game/Graphics/Backgrounds/BeatmapBackgroundWithStoryboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public partial class BeatmapBackgroundWithStoryboard : BeatmapBackground

public Action? StoryboardLoaded { get; set; }

public readonly BindableBool ShowStoryboard = new BindableBool(true);

[Resolved(CanBeNull = true)]
private MusicController? musicController { get; set; }

Expand Down Expand Up @@ -75,13 +77,11 @@ public void LoadStoryboard(bool async = true)

void finishLoad(DrawableStoryboard s)
{
if (Beatmap.Storyboard.ReplacesBackground)
Sprite.FadeOut(BackgroundScreen.TRANSITION_LENGTH, Easing.InQuint);

Storyboard.FadeInFromZero(BackgroundScreen.TRANSITION_LENGTH, Easing.OutQuint);
Storyboard.Add(s);

StoryboardLoaded?.Invoke();
updateStoryboardVisibility();
}
}

Expand All @@ -97,8 +97,7 @@ public void UnloadStoryboard()
Storyboard.Clear();

drawableStoryboard = null;

Sprite.Alpha = 1f;
updateStoryboardVisibility();
}

protected override void LoadComplete()
Expand All @@ -108,6 +107,17 @@ protected override void LoadComplete()
musicController.TrackChanged += onTrackChanged;

updateStoryboardClockSource(Beatmap);

ShowStoryboard.BindValueChanged(_ => updateStoryboardVisibility(), true);
}

private void updateStoryboardVisibility()
{
bool showStoryboard = drawableStoryboard != null && ShowStoryboard.Value;
bool showBackground = !showStoryboard || !Beatmap.Storyboard.ReplacesBackground;

Storyboard.FadeTo(showStoryboard ? 1 : 0, BackgroundScreen.TRANSITION_LENGTH, Easing.OutQuint);
Sprite.FadeTo(showBackground ? 1 : 0, BackgroundScreen.TRANSITION_LENGTH, Easing.OutQuint);
}

private void onTrackChanged(WorkingBeatmap newBeatmap, TrackChangeDirection _) => updateStoryboardClockSource(newBeatmap);
Expand Down
Loading
Loading