1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 16:27:26 +08:00

Merge branch 'master' into alternative-difficulty-bindable

This commit is contained in:
Bartłomiej Dach 2021-08-26 23:07:52 +02:00 committed by GitHub
commit 2ef2af17eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 831 additions and 80 deletions

View File

@ -0,0 +1,64 @@
// 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.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Testing;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Compose;
using osu.Game.Skinning;
using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Mania.Tests.Editor
{
public class TestSceneManiaComposeScreen : EditorClockTestScene
{
[Resolved]
private SkinManager skins { get; set; }
[SetUpSteps]
public void SetUpSteps()
{
AddStep("setup compose screen", () =>
{
var editorBeatmap = new EditorBeatmap(new ManiaBeatmap(new StageDefinition { Columns = 4 }))
{
BeatmapInfo = { Ruleset = new ManiaRuleset().RulesetInfo },
};
Beatmap.Value = CreateWorkingBeatmap(editorBeatmap.PlayableBeatmap);
Child = new DependencyProvidingContainer
{
RelativeSizeAxes = Axes.Both,
CachedDependencies = new (Type, object)[]
{
(typeof(EditorBeatmap), editorBeatmap),
(typeof(IBeatSnapProvider), editorBeatmap),
},
Child = new ComposeScreen { State = { Value = Visibility.Visible } },
};
});
AddUntilStep("wait for composer", () => this.ChildrenOfType<HitObjectComposer>().SingleOrDefault()?.IsLoaded == true);
}
[Test]
public void TestDefaultSkin()
{
AddStep("set default skin", () => skins.CurrentSkinInfo.Value = SkinInfo.Default);
}
[Test]
public void TestLegacySkin()
{
AddStep("set legacy skin", () => skins.CurrentSkinInfo.Value = DefaultLegacySkin.Info);
}
}
}

View File

@ -275,9 +275,8 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
return false;
beginHoldAt(Time.Current - Head.HitObject.StartTime);
Head.UpdateResult();
return true;
return Head.UpdateResult();
}
private void beginHoldAt(double timeOffset)

View File

@ -25,7 +25,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
Origin = Anchor.TopCentre;
}
public void UpdateResult() => base.UpdateResult(true);
public bool UpdateResult() => base.UpdateResult(true);
protected override void UpdateInitialTransforms()
{

View File

@ -4,6 +4,7 @@
#nullable enable
using System;
using System.Diagnostics;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Performance;
using osu.Game.Rulesets.Objects;
@ -20,8 +21,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
{
Start = start;
LifetimeStart = Start.StartTime;
bindEvents();
}
private OsuHitObject? end;
@ -41,31 +40,39 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
}
}
private bool wasBound;
private void bindEvents()
{
UnbindEvents();
if (End == null)
return;
// Note: Positions are bound for instantaneous feedback from positional changes from the editor, before ApplyDefaults() is called on hitobjects.
Start.DefaultsApplied += onDefaultsApplied;
Start.PositionBindable.ValueChanged += onPositionChanged;
if (End != null)
{
End.DefaultsApplied += onDefaultsApplied;
End.PositionBindable.ValueChanged += onPositionChanged;
}
End.DefaultsApplied += onDefaultsApplied;
End.PositionBindable.ValueChanged += onPositionChanged;
wasBound = true;
}
public void UnbindEvents()
{
if (!wasBound)
return;
Debug.Assert(End != null);
Start.DefaultsApplied -= onDefaultsApplied;
Start.PositionBindable.ValueChanged -= onPositionChanged;
if (End != null)
{
End.DefaultsApplied -= onDefaultsApplied;
End.PositionBindable.ValueChanged -= onPositionChanged;
}
End.DefaultsApplied -= onDefaultsApplied;
End.PositionBindable.ValueChanged -= onPositionChanged;
wasBound = false;
}
private void onDefaultsApplied(HitObject obj) => refreshLifetimes();

View File

@ -58,12 +58,13 @@ namespace osu.Game.Tests.Beatmaps.Formats
Assert.AreEqual("03. Renatus - Soleily 192kbps.mp3", metadata.AudioFile);
Assert.AreEqual(0, beatmapInfo.AudioLeadIn);
Assert.AreEqual(164471, metadata.PreviewTime);
Assert.IsFalse(beatmapInfo.Countdown);
Assert.AreEqual(0.7f, beatmapInfo.StackLeniency);
Assert.IsTrue(beatmapInfo.RulesetID == 0);
Assert.IsFalse(beatmapInfo.LetterboxInBreaks);
Assert.IsFalse(beatmapInfo.SpecialStyle);
Assert.IsFalse(beatmapInfo.WidescreenStoryboard);
Assert.AreEqual(CountdownType.None, beatmapInfo.Countdown);
Assert.AreEqual(0, beatmapInfo.CountdownOffset);
}
}

View File

@ -50,12 +50,13 @@ namespace osu.Game.Tests.Beatmaps.Formats
var beatmap = decodeAsJson(normal);
var beatmapInfo = beatmap.BeatmapInfo;
Assert.AreEqual(0, beatmapInfo.AudioLeadIn);
Assert.AreEqual(false, beatmapInfo.Countdown);
Assert.AreEqual(0.7f, beatmapInfo.StackLeniency);
Assert.AreEqual(false, beatmapInfo.SpecialStyle);
Assert.IsTrue(beatmapInfo.RulesetID == 0);
Assert.AreEqual(false, beatmapInfo.LetterboxInBreaks);
Assert.AreEqual(false, beatmapInfo.WidescreenStoryboard);
Assert.AreEqual(CountdownType.None, beatmapInfo.Countdown);
Assert.AreEqual(0, beatmapInfo.CountdownOffset);
}
[Test]

View File

@ -0,0 +1,5 @@
osu file format v14
[General]
Countdown: 2
CountdownOffset: 3

View File

@ -0,0 +1,29 @@
// 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.Testing;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Components.Menus;
namespace osu.Game.Tests.Visual.Editing
{
public class TestSceneEditorScreenModes : EditorTestScene
{
protected override Ruleset CreateEditorRuleset() => new OsuRuleset();
[Test]
public void TestSwitchScreensInstantaneously()
{
AddStep("switch between all screens at once", () =>
{
foreach (var screen in Enum.GetValues(typeof(EditorScreenMode)).Cast<EditorScreenMode>())
Editor.ChildrenOfType<EditorMenuBar>().Single().Mode.Value = screen;
});
}
}
}

View File

@ -83,7 +83,6 @@ namespace osu.Game.Beatmaps
// General
public double AudioLeadIn { get; set; }
public bool Countdown { get; set; } = true;
public float StackLeniency { get; set; } = 0.7f;
public bool SpecialStyle { get; set; }
@ -95,6 +94,13 @@ namespace osu.Game.Beatmaps
public bool WidescreenStoryboard { get; set; }
public bool EpilepsyWarning { get; set; }
public CountdownType Countdown { get; set; } = CountdownType.Normal;
/// <summary>
/// The number of beats to move the countdown backwards (compared to its default location).
/// </summary>
public int CountdownOffset { get; set; }
// Editor
// This bookmarks stuff is necessary because DB doesn't know how to store int[]
[JsonIgnore]

View File

@ -0,0 +1,16 @@
// 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.
namespace osu.Game.Beatmaps
{
/// <summary>
/// The type of countdown shown before the start of gameplay on a given beatmap.
/// </summary>
public enum CountdownType
{
None = 0,
Normal = 1,
HalfSpeed = 2,
DoubleSpeed = 3
}
}

View File

@ -121,10 +121,6 @@ namespace osu.Game.Beatmaps.Formats
metadata.PreviewTime = getOffsetTime(Parsing.ParseInt(pair.Value));
break;
case @"Countdown":
beatmap.BeatmapInfo.Countdown = Parsing.ParseInt(pair.Value) == 1;
break;
case @"SampleSet":
defaultSampleBank = (LegacySampleBank)Enum.Parse(typeof(LegacySampleBank), pair.Value);
break;
@ -176,6 +172,14 @@ namespace osu.Game.Beatmaps.Formats
case @"EpilepsyWarning":
beatmap.BeatmapInfo.EpilepsyWarning = Parsing.ParseInt(pair.Value) == 1;
break;
case @"Countdown":
beatmap.BeatmapInfo.Countdown = (CountdownType)Enum.Parse(typeof(CountdownType), pair.Value);
break;
case @"CountdownOffset":
beatmap.BeatmapInfo.CountdownOffset = Parsing.ParseInt(pair.Value);
break;
}
}

View File

@ -79,8 +79,7 @@ namespace osu.Game.Beatmaps.Formats
if (beatmap.Metadata.AudioFile != null) writer.WriteLine(FormattableString.Invariant($"AudioFilename: {Path.GetFileName(beatmap.Metadata.AudioFile)}"));
writer.WriteLine(FormattableString.Invariant($"AudioLeadIn: {beatmap.BeatmapInfo.AudioLeadIn}"));
writer.WriteLine(FormattableString.Invariant($"PreviewTime: {beatmap.Metadata.PreviewTime}"));
// Todo: Not all countdown types are supported by lazer yet
writer.WriteLine(FormattableString.Invariant($"Countdown: {(beatmap.BeatmapInfo.Countdown ? '1' : '0')}"));
writer.WriteLine(FormattableString.Invariant($"Countdown: {(int)beatmap.BeatmapInfo.Countdown}"));
writer.WriteLine(FormattableString.Invariant($"SampleSet: {toLegacySampleBank(beatmap.ControlPointInfo.SamplePointAt(double.MinValue).SampleBank)}"));
writer.WriteLine(FormattableString.Invariant($"StackLeniency: {beatmap.BeatmapInfo.StackLeniency}"));
writer.WriteLine(FormattableString.Invariant($"Mode: {beatmap.BeatmapInfo.RulesetID}"));
@ -95,8 +94,8 @@ namespace osu.Game.Beatmaps.Formats
// writer.WriteLine(@"SkinPreference:" + b.SkinPreference);
if (beatmap.BeatmapInfo.EpilepsyWarning)
writer.WriteLine(@"EpilepsyWarning: 1");
// if (b.CountdownOffset > 0)
// writer.WriteLine(@"CountdownOffset: " + b.CountdownOffset.ToString());
if (beatmap.BeatmapInfo.CountdownOffset > 0)
writer.WriteLine(FormattableString.Invariant($@"CountdownOffset: {beatmap.BeatmapInfo.CountdownOffset}"));
if (beatmap.BeatmapInfo.RulesetID == 3)
writer.WriteLine(FormattableString.Invariant($"SpecialStyle: {(beatmap.BeatmapInfo.SpecialStyle ? '1' : '0')}"));
writer.WriteLine(FormattableString.Invariant($"WidescreenStoryboard: {(beatmap.BeatmapInfo.WidescreenStoryboard ? '1' : '0')}"));

View File

@ -42,9 +42,24 @@ namespace osu.Game.Input.Handlers
if (!(state is RulesetInputManagerInputState<T> inputState))
throw new InvalidOperationException($"{nameof(ReplayState<T>)} should only be applied to a {nameof(RulesetInputManagerInputState<T>)}");
var lastPressed = inputState.LastReplayState?.PressedActions ?? new List<T>();
var released = lastPressed.Except(PressedActions).ToArray();
var pressed = PressedActions.Except(lastPressed).ToArray();
T[] released = Array.Empty<T>();
T[] pressed = Array.Empty<T>();
var lastPressed = inputState.LastReplayState?.PressedActions;
if (lastPressed == null || lastPressed.Count == 0)
{
pressed = PressedActions.ToArray();
}
else if (PressedActions.Count == 0)
{
released = lastPressed.ToArray();
}
else if (!lastPressed.SequenceEqual(PressedActions))
{
released = lastPressed.Except(PressedActions).ToArray();
pressed = PressedActions.Except(lastPressed).ToArray();
}
inputState.LastReplayState = this;

View File

@ -0,0 +1,513 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using osu.Game.Database;
namespace osu.Game.Migrations
{
[DbContext(typeof(OsuDbContext))]
[Migration("20210824185035_AddCountdownSettings")]
partial class AddCountdownSettings
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.2.6-servicing-10079");
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapDifficulty", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd();
b.Property<float>("ApproachRate");
b.Property<float>("CircleSize");
b.Property<float>("DrainRate");
b.Property<float>("OverallDifficulty");
b.Property<double>("SliderMultiplier");
b.Property<double>("SliderTickRate");
b.HasKey("ID");
b.ToTable("BeatmapDifficulty");
});
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapInfo", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd();
b.Property<double>("AudioLeadIn");
b.Property<double>("BPM");
b.Property<int>("BaseDifficultyID");
b.Property<int>("BeatDivisor");
b.Property<int>("BeatmapSetInfoID");
b.Property<int>("Countdown");
b.Property<int>("CountdownOffset");
b.Property<double>("DistanceSpacing");
b.Property<bool>("EpilepsyWarning");
b.Property<int>("GridSize");
b.Property<string>("Hash");
b.Property<bool>("Hidden");
b.Property<double>("Length");
b.Property<bool>("LetterboxInBreaks");
b.Property<string>("MD5Hash");
b.Property<int?>("MetadataID");
b.Property<int?>("OnlineBeatmapID");
b.Property<string>("Path");
b.Property<int>("RulesetID");
b.Property<bool>("SpecialStyle");
b.Property<float>("StackLeniency");
b.Property<double>("StarDifficulty");
b.Property<int>("Status");
b.Property<string>("StoredBookmarks");
b.Property<double>("TimelineZoom");
b.Property<string>("Version");
b.Property<bool>("WidescreenStoryboard");
b.HasKey("ID");
b.HasIndex("BaseDifficultyID");
b.HasIndex("BeatmapSetInfoID");
b.HasIndex("Hash");
b.HasIndex("MD5Hash");
b.HasIndex("MetadataID");
b.HasIndex("OnlineBeatmapID")
.IsUnique();
b.HasIndex("RulesetID");
b.ToTable("BeatmapInfo");
});
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapMetadata", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd();
b.Property<string>("Artist");
b.Property<string>("ArtistUnicode");
b.Property<string>("AudioFile");
b.Property<int>("AuthorID")
.HasColumnName("AuthorID");
b.Property<string>("AuthorString")
.HasColumnName("Author");
b.Property<string>("BackgroundFile");
b.Property<int>("PreviewTime");
b.Property<string>("Source");
b.Property<string>("Tags");
b.Property<string>("Title");
b.Property<string>("TitleUnicode");
b.HasKey("ID");
b.ToTable("BeatmapMetadata");
});
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetFileInfo", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd();
b.Property<int>("BeatmapSetInfoID");
b.Property<int>("FileInfoID");
b.Property<string>("Filename")
.IsRequired();
b.HasKey("ID");
b.HasIndex("BeatmapSetInfoID");
b.HasIndex("FileInfoID");
b.ToTable("BeatmapSetFileInfo");
});
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetInfo", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd();
b.Property<DateTimeOffset>("DateAdded");
b.Property<bool>("DeletePending");
b.Property<string>("Hash");
b.Property<int?>("MetadataID");
b.Property<int?>("OnlineBeatmapSetID");
b.Property<bool>("Protected");
b.Property<int>("Status");
b.HasKey("ID");
b.HasIndex("DeletePending");
b.HasIndex("Hash")
.IsUnique();
b.HasIndex("MetadataID");
b.HasIndex("OnlineBeatmapSetID")
.IsUnique();
b.ToTable("BeatmapSetInfo");
});
modelBuilder.Entity("osu.Game.Configuration.DatabasedSetting", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd();
b.Property<string>("Key")
.HasColumnName("Key");
b.Property<int?>("RulesetID");
b.Property<int?>("SkinInfoID");
b.Property<string>("StringValue")
.HasColumnName("Value");
b.Property<int?>("Variant");
b.HasKey("ID");
b.HasIndex("SkinInfoID");
b.HasIndex("RulesetID", "Variant");
b.ToTable("Settings");
});
modelBuilder.Entity("osu.Game.IO.FileInfo", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd();
b.Property<string>("Hash");
b.Property<int>("ReferenceCount");
b.HasKey("ID");
b.HasIndex("Hash")
.IsUnique();
b.HasIndex("ReferenceCount");
b.ToTable("FileInfo");
});
modelBuilder.Entity("osu.Game.Input.Bindings.DatabasedKeyBinding", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd();
b.Property<int>("IntAction")
.HasColumnName("Action");
b.Property<string>("KeysString")
.HasColumnName("Keys");
b.Property<int?>("RulesetID");
b.Property<int?>("Variant");
b.HasKey("ID");
b.HasIndex("IntAction");
b.HasIndex("RulesetID", "Variant");
b.ToTable("KeyBinding");
});
modelBuilder.Entity("osu.Game.Rulesets.RulesetInfo", b =>
{
b.Property<int?>("ID")
.ValueGeneratedOnAdd();
b.Property<bool>("Available");
b.Property<string>("InstantiationInfo");
b.Property<string>("Name");
b.Property<string>("ShortName");
b.HasKey("ID");
b.HasIndex("Available");
b.HasIndex("ShortName")
.IsUnique();
b.ToTable("RulesetInfo");
});
modelBuilder.Entity("osu.Game.Scoring.ScoreFileInfo", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd();
b.Property<int>("FileInfoID");
b.Property<string>("Filename")
.IsRequired();
b.Property<int?>("ScoreInfoID");
b.HasKey("ID");
b.HasIndex("FileInfoID");
b.HasIndex("ScoreInfoID");
b.ToTable("ScoreFileInfo");
});
modelBuilder.Entity("osu.Game.Scoring.ScoreInfo", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd();
b.Property<double>("Accuracy")
.HasColumnType("DECIMAL(1,4)");
b.Property<int>("BeatmapInfoID");
b.Property<int>("Combo");
b.Property<DateTimeOffset>("Date");
b.Property<bool>("DeletePending");
b.Property<string>("Hash");
b.Property<int>("MaxCombo");
b.Property<string>("ModsJson")
.HasColumnName("Mods");
b.Property<long?>("OnlineScoreID");
b.Property<double?>("PP");
b.Property<int>("Rank");
b.Property<int>("RulesetID");
b.Property<string>("StatisticsJson")
.HasColumnName("Statistics");
b.Property<long>("TotalScore");
b.Property<int?>("UserID")
.HasColumnName("UserID");
b.Property<string>("UserString")
.HasColumnName("User");
b.HasKey("ID");
b.HasIndex("BeatmapInfoID");
b.HasIndex("OnlineScoreID")
.IsUnique();
b.HasIndex("RulesetID");
b.ToTable("ScoreInfo");
});
modelBuilder.Entity("osu.Game.Skinning.SkinFileInfo", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd();
b.Property<int>("FileInfoID");
b.Property<string>("Filename")
.IsRequired();
b.Property<int>("SkinInfoID");
b.HasKey("ID");
b.HasIndex("FileInfoID");
b.HasIndex("SkinInfoID");
b.ToTable("SkinFileInfo");
});
modelBuilder.Entity("osu.Game.Skinning.SkinInfo", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd();
b.Property<string>("Creator");
b.Property<bool>("DeletePending");
b.Property<string>("Hash");
b.Property<string>("InstantiationInfo");
b.Property<string>("Name");
b.HasKey("ID");
b.HasIndex("DeletePending");
b.HasIndex("Hash")
.IsUnique();
b.ToTable("SkinInfo");
});
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapInfo", b =>
{
b.HasOne("osu.Game.Beatmaps.BeatmapDifficulty", "BaseDifficulty")
.WithMany()
.HasForeignKey("BaseDifficultyID")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("osu.Game.Beatmaps.BeatmapSetInfo", "BeatmapSet")
.WithMany("Beatmaps")
.HasForeignKey("BeatmapSetInfoID")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("osu.Game.Beatmaps.BeatmapMetadata", "Metadata")
.WithMany("Beatmaps")
.HasForeignKey("MetadataID");
b.HasOne("osu.Game.Rulesets.RulesetInfo", "Ruleset")
.WithMany()
.HasForeignKey("RulesetID")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetFileInfo", b =>
{
b.HasOne("osu.Game.Beatmaps.BeatmapSetInfo")
.WithMany("Files")
.HasForeignKey("BeatmapSetInfoID")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("osu.Game.IO.FileInfo", "FileInfo")
.WithMany()
.HasForeignKey("FileInfoID")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetInfo", b =>
{
b.HasOne("osu.Game.Beatmaps.BeatmapMetadata", "Metadata")
.WithMany("BeatmapSets")
.HasForeignKey("MetadataID");
});
modelBuilder.Entity("osu.Game.Configuration.DatabasedSetting", b =>
{
b.HasOne("osu.Game.Skinning.SkinInfo")
.WithMany("Settings")
.HasForeignKey("SkinInfoID");
});
modelBuilder.Entity("osu.Game.Scoring.ScoreFileInfo", b =>
{
b.HasOne("osu.Game.IO.FileInfo", "FileInfo")
.WithMany()
.HasForeignKey("FileInfoID")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("osu.Game.Scoring.ScoreInfo")
.WithMany("Files")
.HasForeignKey("ScoreInfoID");
});
modelBuilder.Entity("osu.Game.Scoring.ScoreInfo", b =>
{
b.HasOne("osu.Game.Beatmaps.BeatmapInfo", "Beatmap")
.WithMany("Scores")
.HasForeignKey("BeatmapInfoID")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("osu.Game.Rulesets.RulesetInfo", "Ruleset")
.WithMany()
.HasForeignKey("RulesetID")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("osu.Game.Skinning.SkinFileInfo", b =>
{
b.HasOne("osu.Game.IO.FileInfo", "FileInfo")
.WithMany()
.HasForeignKey("FileInfoID")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("osu.Game.Skinning.SkinInfo")
.WithMany("Files")
.HasForeignKey("SkinInfoID")
.OnDelete(DeleteBehavior.Cascade);
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,23 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace osu.Game.Migrations
{
public partial class AddCountdownSettings : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "CountdownOffset",
table: "BeatmapInfo",
nullable: false,
defaultValue: 0);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "CountdownOffset",
table: "BeatmapInfo");
}
}
}

View File

@ -53,7 +53,9 @@ namespace osu.Game.Migrations
b.Property<int>("BeatmapSetInfoID");
b.Property<bool>("Countdown");
b.Property<int>("Countdown");
b.Property<int>("CountdownOffset");
b.Property<double>("DistanceSpacing");

View File

@ -33,6 +33,12 @@ namespace osu.Game.Online.Multiplayer
/// </summary>
public event Action? RoomUpdated;
public event Action<MultiplayerRoomUser>? UserJoined;
public event Action<MultiplayerRoomUser>? UserLeft;
public event Action<MultiplayerRoomUser>? UserKicked;
/// <summary>
/// Invoked when the multiplayer server requests the current beatmap to be loaded into play.
/// </summary>
@ -366,11 +372,26 @@ namespace osu.Game.Online.Multiplayer
Room.Users.Add(user);
UserJoined?.Invoke(user);
RoomUpdated?.Invoke();
}, false);
}
Task IMultiplayerClient.UserLeft(MultiplayerRoomUser user)
Task IMultiplayerClient.UserLeft(MultiplayerRoomUser user) =>
handleUserLeft(user, UserLeft);
Task IMultiplayerClient.UserKicked(MultiplayerRoomUser user)
{
if (LocalUser == null)
return Task.CompletedTask;
if (user.Equals(LocalUser))
LeaveRoom();
return handleUserLeft(user, UserKicked);
}
private Task handleUserLeft(MultiplayerRoomUser user, Action<MultiplayerRoomUser>? callback)
{
if (Room == null)
return Task.CompletedTask;
@ -383,24 +404,13 @@ namespace osu.Game.Online.Multiplayer
Room.Users.Remove(user);
PlayingUserIds.Remove(user.UserID);
callback?.Invoke(user);
RoomUpdated?.Invoke();
}, false);
return Task.CompletedTask;
}
Task IMultiplayerClient.UserKicked(MultiplayerRoomUser user)
{
if (LocalUser == null)
return Task.CompletedTask;
if (user.Equals(LocalUser))
LeaveRoom();
// TODO: also inform users of the kick operation.
return ((IMultiplayerClient)this).UserLeft(user);
}
Task IMultiplayerClient.HostChanged(int userId)
{
if (Room == null)

View File

@ -1,8 +1,10 @@
// 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.ComponentModel;
using System.Diagnostics;
using System.Linq;
using osu.Framework.Utils;
namespace osu.Game.Rulesets.Scoring
@ -171,6 +173,11 @@ namespace osu.Game.Rulesets.Scoring
/// </summary>
public static bool IsScorable(this HitResult result) => result >= HitResult.Miss && result < HitResult.IgnoreMiss;
/// <summary>
/// An array of all scorable <see cref="HitResult"/>s.
/// </summary>
public static readonly HitResult[] SCORABLE_TYPES = ((HitResult[])Enum.GetValues(typeof(HitResult))).Where(r => r.IsScorable()).ToArray();
/// <summary>
/// Whether a <see cref="HitResult"/> is valid within a given <see cref="HitResult"/> range.
/// </summary>

View File

@ -339,7 +339,7 @@ namespace osu.Game.Rulesets.Scoring
score.Accuracy = Accuracy.Value;
score.Rank = Rank.Value;
foreach (var result in Enum.GetValues(typeof(HitResult)).OfType<HitResult>().Where(r => r.IsScorable()))
foreach (var result in HitResultExtensions.SCORABLE_TYPES)
score.Statistics[result] = GetStatistic(result);
score.HitEvents = hitEvents;

View File

@ -605,19 +605,14 @@ namespace osu.Game.Screens.Edit
{
var lastScreen = currentScreen;
lastScreen?
.ScaleTo(0.98f, 200, Easing.OutQuint)
.FadeOut(200, Easing.OutQuint);
lastScreen?.Hide();
try
{
if ((currentScreen = screenContainer.SingleOrDefault(s => s.Type == e.NewValue)) != null)
{
screenContainer.ChangeChildDepth(currentScreen, lastScreen?.Depth + 1 ?? 0);
currentScreen
.ScaleTo(1, 200, Easing.OutQuint)
.FadeIn(200, Easing.OutQuint);
currentScreen.Show();
return;
}
@ -650,7 +645,10 @@ namespace osu.Game.Screens.Edit
LoadComponentAsync(currentScreen, newScreen =>
{
if (newScreen == currentScreen)
{
screenContainer.Add(newScreen);
newScreen.Show();
}
});
}
finally

View File

@ -10,7 +10,7 @@ namespace osu.Game.Screens.Edit
/// <summary>
/// TODO: eventually make this inherit Screen and add a local screen stack inside the Editor.
/// </summary>
public abstract class EditorScreen : Container
public abstract class EditorScreen : VisibilityContainer
{
[Resolved]
protected EditorBeatmap EditorBeatmap { get; private set; }
@ -31,13 +31,16 @@ namespace osu.Game.Screens.Edit
InternalChild = content = new Container { RelativeSizeAxes = Axes.Both };
}
protected override void LoadComplete()
protected override void PopIn()
{
base.LoadComplete();
this.ScaleTo(1f, 200, Easing.OutQuint)
.FadeIn(200, Easing.OutQuint);
}
this.FadeTo(0)
.Then()
.FadeTo(1f, 250, Easing.OutQuint);
protected override void PopOut()
{
this.ScaleTo(0.98f, 200, Easing.OutQuint)
.FadeOut(200, Easing.OutQuint);
}
}
}

View File

@ -16,7 +16,7 @@ namespace osu.Game.Screens.Edit
private readonly EditorBeatmapSkin? beatmapSkin;
public EditorSkinProvidingContainer(EditorBeatmap editorBeatmap)
: base(editorBeatmap.PlayableBeatmap.BeatmapInfo.Ruleset.CreateInstance(), editorBeatmap, editorBeatmap.BeatmapSkin)
: base(editorBeatmap.PlayableBeatmap.BeatmapInfo.Ruleset.CreateInstance(), editorBeatmap.PlayableBeatmap, editorBeatmap.BeatmapSkin)
{
beatmapSkin = editorBeatmap.BeatmapSkin;
}

View File

@ -20,9 +20,38 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
base.LoadComplete();
Client.RoomUpdated += OnRoomUpdated;
Client.UserLeft += UserLeft;
Client.UserKicked += UserKicked;
Client.UserJoined += UserJoined;
OnRoomUpdated();
}
/// <summary>
/// Invoked when a user has joined the room.
/// </summary>
/// <param name="user">The user.</param>
protected virtual void UserJoined(MultiplayerRoomUser user)
{
}
/// <summary>
/// Invoked when a user has been kicked from the room (including the local user).
/// </summary>
/// <param name="user">The user.</param>
protected virtual void UserKicked(MultiplayerRoomUser user)
{
}
/// <summary>
/// Invoked when a user has left the room.
/// </summary>
/// <param name="user">The user.</param>
protected virtual void UserLeft(MultiplayerRoomUser user)
{
}
/// <summary>
/// Invoked when any change occurs to the multiplayer room.
/// </summary>
@ -33,7 +62,12 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
protected override void Dispose(bool isDisposing)
{
if (Client != null)
{
Client.UserLeft -= UserLeft;
Client.UserKicked -= UserKicked;
Client.UserJoined -= UserJoined;
Client.RoomUpdated -= OnRoomUpdated;
}
base.Dispose(isDisposing);
}

View File

@ -12,7 +12,6 @@ using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Framework.Threading;
using osu.Framework.Utils;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
@ -37,6 +36,8 @@ namespace osu.Game.Screens.Play
private FadeContainer fadeContainer;
private double displayTime;
private bool isClickable;
[Resolved]
private GameplayClock gameplayClock { get; set; }
@ -101,7 +102,7 @@ namespace osu.Game.Screens.Play
public override void Show()
{
base.Show();
fadeContainer.Show();
fadeContainer.TriggerShow();
}
protected override void LoadComplete()
@ -118,24 +119,27 @@ namespace osu.Game.Screens.Play
button.Action = () => RequestSkip?.Invoke();
displayTime = gameplayClock.CurrentTime;
fadeContainer.TriggerShow();
}
protected override void Update()
{
base.Update();
var progress = fadeOutBeginTime <= displayTime ? 1 : Math.Max(0, 1 - (gameplayClock.CurrentTime - displayTime) / (fadeOutBeginTime - displayTime));
double progress = fadeOutBeginTime <= displayTime ? 1 : Math.Max(0, 1 - (gameplayClock.CurrentTime - displayTime) / (fadeOutBeginTime - displayTime));
remainingTimeBox.Width = (float)Interpolation.Lerp(remainingTimeBox.Width, progress, Math.Clamp(Time.Elapsed / 40, 0, 1));
button.Enabled.Value = progress > 0;
buttonContainer.State.Value = progress > 0 ? Visibility.Visible : Visibility.Hidden;
isClickable = progress > 0;
button.Enabled.Value = isClickable;
buttonContainer.State.Value = isClickable ? Visibility.Visible : Visibility.Hidden;
}
protected override bool OnMouseMove(MouseMoveEvent e)
{
if (!e.HasAnyButtonPressed)
fadeContainer.Show();
if (isClickable && !e.HasAnyButtonPressed)
fadeContainer.TriggerShow();
return base.OnMouseMove(e);
}
@ -164,34 +168,45 @@ namespace osu.Game.Screens.Play
public event Action<Visibility> StateChanged;
private Visibility state;
private ScheduledDelegate scheduledHide;
private double? nextHideTime;
public override bool IsPresent => true;
public void TriggerShow()
{
Show();
if (!IsHovered && !IsDragged)
nextHideTime = Time.Current + 1000;
else
nextHideTime = null;
}
protected override void Update()
{
base.Update();
if (nextHideTime != null && nextHideTime <= Time.Current)
{
Hide();
nextHideTime = null;
}
}
public Visibility State
{
get => state;
set
{
bool stateChanged = value != state;
if (value == state)
return;
state = value;
scheduledHide?.Cancel();
switch (state)
{
case Visibility.Visible:
// we may be triggered to become visible multiple times but we only want to transform once.
if (stateChanged)
this.FadeIn(500, Easing.OutExpo);
if (!IsHovered && !IsDragged)
{
using (BeginDelayedSequence(1000))
scheduledHide = Schedule(Hide);
}
this.FadeIn(500, Easing.OutExpo);
break;
case Visibility.Hidden:
@ -212,7 +227,7 @@ namespace osu.Game.Screens.Play
protected override bool OnMouseDown(MouseDownEvent e)
{
Show();
scheduledHide?.Cancel();
nextHideTime = null;
return true;
}