mirror of
https://github.com/ppy/osu.git
synced 2025-01-29 02:52:54 +08:00
Merge branch 'master' into diffcalc/refactor-strain-logic
This commit is contained in:
commit
5bf0889379
@ -77,5 +77,11 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
AddStep("start clock again", Clock.Start);
|
||||
AddAssert("clock looped to start", () => Clock.IsRunning && Clock.CurrentTime < 500);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
Beatmap.Disabled = false;
|
||||
base.Dispose(isDisposing);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
79
osu.Game.Tests/Visual/Editing/TestSceneEditorSeeking.cs
Normal file
79
osu.Game.Tests/Visual/Editing/TestSceneEditorSeeking.cs
Normal file
@ -0,0 +1,79 @@
|
||||
// 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.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Editing
|
||||
{
|
||||
public class TestSceneEditorSeeking : EditorTestScene
|
||||
{
|
||||
protected override Ruleset CreateEditorRuleset() => new OsuRuleset();
|
||||
|
||||
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
|
||||
{
|
||||
var beatmap = base.CreateBeatmap(ruleset);
|
||||
|
||||
beatmap.BeatmapInfo.BeatDivisor = 1;
|
||||
|
||||
beatmap.ControlPointInfo = new ControlPointInfo();
|
||||
beatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = 1000 });
|
||||
beatmap.ControlPointInfo.Add(2000, new TimingControlPoint { BeatLength = 500 });
|
||||
|
||||
return beatmap;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSnappedSeeking()
|
||||
{
|
||||
AddStep("seek to 0", () => EditorClock.Seek(0));
|
||||
AddAssert("time is 0", () => EditorClock.CurrentTime == 0);
|
||||
|
||||
pressAndCheckTime(Key.Right, 1000);
|
||||
pressAndCheckTime(Key.Right, 2000);
|
||||
pressAndCheckTime(Key.Right, 2500);
|
||||
pressAndCheckTime(Key.Right, 3000);
|
||||
|
||||
pressAndCheckTime(Key.Left, 2500);
|
||||
pressAndCheckTime(Key.Left, 2000);
|
||||
pressAndCheckTime(Key.Left, 1000);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSnappedSeekingAfterControlPointChange()
|
||||
{
|
||||
AddStep("seek to 0", () => EditorClock.Seek(0));
|
||||
AddAssert("time is 0", () => EditorClock.CurrentTime == 0);
|
||||
|
||||
pressAndCheckTime(Key.Right, 1000);
|
||||
pressAndCheckTime(Key.Right, 2000);
|
||||
pressAndCheckTime(Key.Right, 2500);
|
||||
pressAndCheckTime(Key.Right, 3000);
|
||||
|
||||
AddStep("remove 2nd timing point", () =>
|
||||
{
|
||||
EditorBeatmap.BeginChange();
|
||||
var group = EditorBeatmap.ControlPointInfo.GroupAt(2000);
|
||||
EditorBeatmap.ControlPointInfo.RemoveGroup(group);
|
||||
EditorBeatmap.EndChange();
|
||||
});
|
||||
|
||||
pressAndCheckTime(Key.Left, 2000);
|
||||
pressAndCheckTime(Key.Left, 1000);
|
||||
|
||||
pressAndCheckTime(Key.Right, 2000);
|
||||
pressAndCheckTime(Key.Right, 3000);
|
||||
}
|
||||
|
||||
private void pressAndCheckTime(Key key, double expectedTime)
|
||||
{
|
||||
AddStep($"press {key}", () => InputManager.Key(key));
|
||||
AddUntilStep($"time is {expectedTime}", () => Precision.AlmostEquals(expectedTime, EditorClock.CurrentTime, 1));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +1,13 @@
|
||||
// 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.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Tournament.Components;
|
||||
using osu.Game.Tournament.Screens.Gameplay;
|
||||
using osu.Game.Tournament.Screens.Gameplay.Components;
|
||||
|
||||
namespace osu.Game.Tournament.Tests.Screens
|
||||
{
|
||||
@ -18,5 +22,24 @@ namespace osu.Game.Tournament.Tests.Screens
|
||||
Add(new GameplayScreen());
|
||||
Add(chat);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestWarmup()
|
||||
{
|
||||
checkScoreVisibility(false);
|
||||
|
||||
toggleWarmup();
|
||||
checkScoreVisibility(true);
|
||||
|
||||
toggleWarmup();
|
||||
checkScoreVisibility(false);
|
||||
}
|
||||
|
||||
private void checkScoreVisibility(bool visible)
|
||||
=> AddUntilStep($"scores {(visible ? "shown" : "hidden")}",
|
||||
() => this.ChildrenOfType<TeamScore>().All(score => score.Alpha == (visible ? 1 : 0)));
|
||||
|
||||
private void toggleWarmup()
|
||||
=> AddStep("toggle warmup", () => this.ChildrenOfType<TourneyButton>().First().Click());
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Tests.Visual;
|
||||
using osu.Game.Tournament.IO;
|
||||
using osu.Game.Tournament.IPC;
|
||||
using osu.Game.Tournament.Models;
|
||||
using osu.Game.Users;
|
||||
@ -28,7 +29,7 @@ namespace osu.Game.Tournament.Tests
|
||||
protected MatchIPCInfo IPCInfo { get; private set; } = new MatchIPCInfo();
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(Storage storage)
|
||||
private void load(TournamentStorage storage)
|
||||
{
|
||||
Ladder.Ruleset.Value ??= rulesetStore.AvailableRulesets.First();
|
||||
|
||||
|
@ -27,17 +27,16 @@ namespace osu.Game.Tournament.Models
|
||||
|
||||
private const string config_path = "stable.json";
|
||||
|
||||
private readonly Storage storage;
|
||||
private readonly Storage configStorage;
|
||||
|
||||
public StableInfo(Storage storage)
|
||||
public StableInfo(TournamentStorage storage)
|
||||
{
|
||||
TournamentStorage tStorage = (TournamentStorage)storage;
|
||||
this.storage = tStorage.AllTournaments;
|
||||
configStorage = storage.AllTournaments;
|
||||
|
||||
if (!storage.Exists(config_path))
|
||||
if (!configStorage.Exists(config_path))
|
||||
return;
|
||||
|
||||
using (Stream stream = storage.GetStream(config_path, FileAccess.Read, FileMode.Open))
|
||||
using (Stream stream = configStorage.GetStream(config_path, FileAccess.Read, FileMode.Open))
|
||||
using (var sr = new StreamReader(stream))
|
||||
{
|
||||
JsonConvert.PopulateObject(sr.ReadToEnd(), this);
|
||||
@ -46,7 +45,7 @@ namespace osu.Game.Tournament.Models
|
||||
|
||||
public void SaveChanges()
|
||||
{
|
||||
using (var stream = storage.GetStream(config_path, FileAccess.Write, FileMode.Create))
|
||||
using (var stream = configStorage.GetStream(config_path, FileAccess.Write, FileMode.Create))
|
||||
using (var sw = new StreamWriter(stream))
|
||||
{
|
||||
sw.Write(JsonConvert.SerializeObject(this,
|
||||
|
@ -95,7 +95,11 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components
|
||||
Origin = Anchor.TopRight,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
updateDisplay();
|
||||
}
|
||||
|
||||
|
@ -14,9 +14,21 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components
|
||||
{
|
||||
private readonly TeamScore score;
|
||||
|
||||
private bool showScore;
|
||||
|
||||
public bool ShowScore
|
||||
{
|
||||
set => score.FadeTo(value ? 1 : 0, 200);
|
||||
get => showScore;
|
||||
set
|
||||
{
|
||||
if (showScore == value)
|
||||
return;
|
||||
|
||||
showScore = value;
|
||||
|
||||
if (IsLoaded)
|
||||
updateDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
public TeamDisplay(TournamentTeam team, TeamColour colour, Bindable<int?> currentTeamScore, int pointsToWin)
|
||||
@ -92,5 +104,18 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
updateDisplay();
|
||||
FinishTransforms(true);
|
||||
}
|
||||
|
||||
private void updateDisplay()
|
||||
{
|
||||
score.FadeTo(ShowScore ? 1 : 0, 200);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -391,7 +391,7 @@ namespace osu.Game.Online.Leaderboards
|
||||
if (score.Mods.Length > 0 && modsContainer.Any(s => s.IsHovered) && songSelect != null)
|
||||
items.Add(new OsuMenuItem("Use these mods", MenuItemType.Highlighted, () => songSelect.Mods.Value = score.Mods));
|
||||
|
||||
if (score.Files.Count > 0)
|
||||
if (score.Files?.Count > 0)
|
||||
items.Add(new OsuMenuItem("Export", MenuItemType.Standard, () => scoreManager.Export(score)));
|
||||
|
||||
if (score.ID != 0)
|
||||
|
@ -122,22 +122,6 @@ namespace osu.Game.Screens.Edit
|
||||
return;
|
||||
}
|
||||
|
||||
beatDivisor.Value = loadableBeatmap.BeatmapInfo.BeatDivisor;
|
||||
beatDivisor.BindValueChanged(divisor => loadableBeatmap.BeatmapInfo.BeatDivisor = divisor.NewValue);
|
||||
|
||||
// Todo: should probably be done at a DrawableRuleset level to share logic with Player.
|
||||
clock = new EditorClock(loadableBeatmap, beatDivisor) { IsCoupled = false };
|
||||
|
||||
UpdateClockSource();
|
||||
|
||||
dependencies.CacheAs(clock);
|
||||
AddInternal(clock);
|
||||
|
||||
clock.SeekingOrStopped.BindValueChanged(_ => updateSampleDisabledState());
|
||||
|
||||
// todo: remove caching of this and consume via editorBeatmap?
|
||||
dependencies.Cache(beatDivisor);
|
||||
|
||||
try
|
||||
{
|
||||
playableBeatmap = loadableBeatmap.GetPlayableBeatmap(loadableBeatmap.BeatmapInfo.Ruleset);
|
||||
@ -154,6 +138,22 @@ namespace osu.Game.Screens.Edit
|
||||
return;
|
||||
}
|
||||
|
||||
beatDivisor.Value = playableBeatmap.BeatmapInfo.BeatDivisor;
|
||||
beatDivisor.BindValueChanged(divisor => playableBeatmap.BeatmapInfo.BeatDivisor = divisor.NewValue);
|
||||
|
||||
// Todo: should probably be done at a DrawableRuleset level to share logic with Player.
|
||||
clock = new EditorClock(playableBeatmap, beatDivisor) { IsCoupled = false };
|
||||
|
||||
UpdateClockSource();
|
||||
|
||||
dependencies.CacheAs(clock);
|
||||
AddInternal(clock);
|
||||
|
||||
clock.SeekingOrStopped.BindValueChanged(_ => updateSampleDisabledState());
|
||||
|
||||
// todo: remove caching of this and consume via editorBeatmap?
|
||||
dependencies.Cache(beatDivisor);
|
||||
|
||||
AddInternal(editorBeatmap = new EditorBeatmap(playableBeatmap, loadableBeatmap.Skin));
|
||||
dependencies.CacheAs(editorBeatmap);
|
||||
changeHandler = new EditorChangeHandler(editorBeatmap);
|
||||
|
@ -42,12 +42,12 @@ namespace osu.Game.Screens.Edit
|
||||
/// </summary>
|
||||
public bool IsSeeking { get; private set; }
|
||||
|
||||
public EditorClock(WorkingBeatmap beatmap, BindableBeatDivisor beatDivisor)
|
||||
: this(beatmap.Beatmap.ControlPointInfo, beatmap.Track.Length, beatDivisor)
|
||||
public EditorClock(IBeatmap beatmap, BindableBeatDivisor beatDivisor)
|
||||
: this(beatmap.ControlPointInfo, beatDivisor)
|
||||
{
|
||||
}
|
||||
|
||||
public EditorClock(ControlPointInfo controlPointInfo, double trackLength, BindableBeatDivisor beatDivisor)
|
||||
public EditorClock(ControlPointInfo controlPointInfo, BindableBeatDivisor beatDivisor)
|
||||
{
|
||||
this.beatDivisor = beatDivisor;
|
||||
|
||||
@ -57,7 +57,7 @@ namespace osu.Game.Screens.Edit
|
||||
}
|
||||
|
||||
public EditorClock()
|
||||
: this(new ControlPointInfo(), 1000, new BindableBeatDivisor())
|
||||
: this(new ControlPointInfo(), new BindableBeatDivisor())
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
protected EditorClockTestScene()
|
||||
{
|
||||
Clock = new EditorClock(new ControlPointInfo(), 5000, BeatDivisor) { IsCoupled = false };
|
||||
Clock = new EditorClock(new ControlPointInfo(), BeatDivisor) { IsCoupled = false };
|
||||
}
|
||||
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||
|
Loading…
Reference in New Issue
Block a user