Skip to content

Commit

Permalink
Merge branch 'master' into catch-improve-info-on-selected
Browse files Browse the repository at this point in the history
  • Loading branch information
bdach committed Nov 21, 2024
2 parents 2138729 + 2c0140f commit 0e4d078
Show file tree
Hide file tree
Showing 127 changed files with 2,644 additions and 1,809 deletions.
2 changes: 1 addition & 1 deletion osu.Android.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Framework.Android" Version="2024.1115.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2024.1118.0" />
</ItemGroup>
<PropertyGroup>
<!-- Fody does not handle Android build well, and warns when unchanged.
Expand Down
45 changes: 45 additions & 0 deletions osu.Game.Rulesets.Mania/Edit/EditorColumn.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using osu.Framework.Graphics;
using osu.Game.Rulesets.Mania.Objects.Drawables;
using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.Objects.Drawables;

namespace osu.Game.Rulesets.Mania.Edit
{
public partial class EditorColumn : Column
{
public EditorColumn(int index, bool isSpecial)
: base(index, isSpecial)
{
}

protected override void OnNewDrawableHitObject(DrawableHitObject drawableHitObject)
{
base.OnNewDrawableHitObject(drawableHitObject);
drawableHitObject.ApplyCustomUpdateState += (dho, state) =>
{
switch (dho)
{
// hold note heads are exempt from what follows due to the "freezing" mechanic
// which already ensures they'll never fade away on their own.
case DrawableHoldNoteHead:
break;

// mania features instantaneous hitobject fade-outs.
// this means that without manual intervention stopping the clock at the precise time of hitting the object
// means the object will fade out.
// this is anti-user in editor contexts, as the user is expecting to continue the see the note on the receptor line.
// therefore, apply a crude workaround to prevent it from going away.
default:
{
if (state == ArmedState.Hit)
dho.FadeTo(1).Delay(1).FadeOut().Expire();
break;
}
}
};
}
}
}
18 changes: 18 additions & 0 deletions osu.Game.Rulesets.Mania/Edit/EditorStage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.Mania.UI;

namespace osu.Game.Rulesets.Mania.Edit
{
public partial class EditorStage : Stage
{
public EditorStage(int firstColumnIndex, StageDefinition definition, ref ManiaAction columnStartAction)
: base(firstColumnIndex, definition, ref columnStartAction)
{
}

protected override Column CreateColumn(int index, bool isSpecial) => new EditorColumn(index, isSpecial);
}
}
3 changes: 3 additions & 0 deletions osu.Game.Rulesets.Mania/Edit/ManiaEditorPlayfield.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@ public ManiaEditorPlayfield(List<StageDefinition> stages)
: base(stages)
{
}

protected override Stage CreateStage(int firstColumnIndex, StageDefinition stageDefinition, ref ManiaAction columnAction)
=> new EditorStage(firstColumnIndex, stageDefinition, ref columnAction);
}
}
6 changes: 5 additions & 1 deletion osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using osu.Framework.Graphics.Containers;
using System;
using System.Collections.Generic;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Primitives;
using osu.Game.Rulesets.Mania.Beatmaps;
Expand Down Expand Up @@ -71,7 +72,7 @@ public ManiaPlayfield(List<StageDefinition> stageDefinitions)

for (int i = 0; i < stageDefinitions.Count; i++)
{
var newStage = new Stage(firstColumnIndex, stageDefinitions[i], ref columnAction);
var newStage = CreateStage(firstColumnIndex, stageDefinitions[i], ref columnAction);

playfieldGrid.Content[0][i] = newStage;

Expand All @@ -82,6 +83,9 @@ public ManiaPlayfield(List<StageDefinition> stageDefinitions)
}
}

[Pure]
protected virtual Stage CreateStage(int firstColumnIndex, StageDefinition stageDefinition, ref ManiaAction columnAction) => new Stage(firstColumnIndex, stageDefinition, ref columnAction);

public override void Add(HitObject hitObject) => getStageByColumn(((ManiaHitObject)hitObject).Column).Add(hitObject);

public override bool Remove(HitObject hitObject) => getStageByColumn(((ManiaHitObject)hitObject).Column).Remove(hitObject);
Expand Down
16 changes: 11 additions & 5 deletions osu.Game.Rulesets.Mania/UI/Stage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
Expand Down Expand Up @@ -134,12 +135,14 @@ public Stage(int firstColumnIndex, StageDefinition definition, ref ManiaAction c
{
bool isSpecial = definition.IsSpecialColumn(i);

var column = new Column(firstColumnIndex + i, isSpecial)
var action = columnStartAction;
columnStartAction++;
var column = CreateColumn(firstColumnIndex + i, isSpecial).With(c =>
{
RelativeSizeAxes = Axes.Both,
Width = 1,
Action = { Value = columnStartAction++ }
};
c.RelativeSizeAxes = Axes.Both;
c.Width = 1;
c.Action.Value = action;
});

topLevelContainer.Add(column.TopLevelContainer.CreateProxy());
columnBackgrounds.Add(column.BackgroundContainer.CreateProxy());
Expand All @@ -154,6 +157,9 @@ public Stage(int firstColumnIndex, StageDefinition definition, ref ManiaAction c
RegisterPool<BarLine, DrawableBarLine>(50, 200);
}

[Pure]
protected virtual Column CreateColumn(int index, bool isSpecial) => new Column(index, isSpecial);

[BackgroundDependencyLoader]
private void load(ISkinSource skin)
{
Expand Down
43 changes: 43 additions & 0 deletions osu.Game.Tests/Beatmaps/IO/LegacyBeatmapExporterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
// See the LICENCE file in the repository root for full licence text.

using System.IO;
using System.Text;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Extensions;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Database;
using osu.Game.IO.Archives;
using osu.Game.Tests.Resources;
using osu.Game.Tests.Visual;
using MemoryStream = System.IO.MemoryStream;
Expand Down Expand Up @@ -48,6 +50,47 @@ public void TestObjectsSnappedAfterTruncatingExport()
AddAssert("hit object is snapped", () => beatmap.Beatmap.HitObjects[0].StartTime, () => Is.EqualTo(28519).Within(0.001));
}

[Test]
public void TestExportStability()
{
IWorkingBeatmap beatmap = null!;
MemoryStream firstExport = null!;
MemoryStream secondExport = null!;

// Ensure importer encoding is correct
AddStep("import beatmap", () => beatmap = importBeatmapFromArchives(@"legacy-export-stability-test.olz"));
AddStep("export once", () =>
{
firstExport = new MemoryStream();

new LegacyBeatmapExporter(LocalStorage)
.ExportToStream((BeatmapSetInfo)beatmap.BeatmapInfo.BeatmapSet!, firstExport, null);
});

AddStep("import beatmap again", () => beatmap = importBeatmapFromStream(firstExport));
AddStep("export again", () =>
{
secondExport = new MemoryStream();

new LegacyBeatmapExporter(LocalStorage)
.ExportToStream((BeatmapSetInfo)beatmap.BeatmapInfo.BeatmapSet!, secondExport, null);
});

const string osu_filename = @"legacy export - stability test (spaceman_atlas) [].osu";

AddAssert("exports are identical",
() => getStringContentsOf(osu_filename, firstExport.GetBuffer()),
() => Is.EqualTo(getStringContentsOf(osu_filename, secondExport.GetBuffer())));

string getStringContentsOf(string filename, byte[] archiveBytes)
{
using var memoryStream = new MemoryStream(archiveBytes);
using var archiveReader = new ZipArchiveReader(memoryStream);
byte[] fileContent = archiveReader.GetStream(filename).ReadAllBytesToArray();
return Encoding.UTF8.GetString(fileContent);
}
}

private IWorkingBeatmap importBeatmapFromStream(Stream stream)
{
var imported = beatmaps.Import(new ImportTask(stream, "filename.osz")).GetResultSafely();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void TestPlayingUsersUpdatedOnJoin()
var newRoom = new Room();
newRoom.CopyFrom(SelectedRoom.Value);

newRoom.RoomID.Value = null;
newRoom.RoomID = null;
MultiplayerClient.RoomSetupAction = room =>
{
room.State = MultiplayerRoomState.Playing;
Expand Down
Binary file not shown.
36 changes: 18 additions & 18 deletions osu.Game.Tests/Visual/DailyChallenge/TestSceneDailyChallenge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@ public void TestDailyChallenge()
{
var room = new Room
{
RoomID = { Value = 1234 },
Name = { Value = "Daily Challenge: June 4, 2024" },
RoomID = 1234,
Name = "Daily Challenge: June 4, 2024",
Playlist =
{
[
new PlaylistItem(TestResources.CreateTestBeatmapSetInfo().Beatmaps.First())
{
RequiredMods = [new APIMod(new OsuModTraceable())],
AllowedMods = [new APIMod(new OsuModDoubleTime())]
}
},
EndDate = { Value = DateTimeOffset.Now.AddHours(12) },
Category = { Value = RoomCategory.DailyChallenge }
],
EndDate = DateTimeOffset.Now.AddHours(12),
Category = RoomCategory.DailyChallenge
};

AddStep("add room", () => API.Perform(new CreateRoomRequest(room)));
Expand All @@ -62,18 +62,18 @@ public void TestNotifications()
{
var room = new Room
{
RoomID = { Value = 1234 },
Name = { Value = "Daily Challenge: June 4, 2024" },
RoomID = 1234,
Name = "Daily Challenge: June 4, 2024",
Playlist =
{
[
new PlaylistItem(TestResources.CreateTestBeatmapSetInfo().Beatmaps.First())
{
RequiredMods = [new APIMod(new OsuModTraceable())],
AllowedMods = [new APIMod(new OsuModDoubleTime())]
}
},
EndDate = { Value = DateTimeOffset.Now.AddHours(12) },
Category = { Value = RoomCategory.DailyChallenge }
],
EndDate = DateTimeOffset.Now.AddHours(12),
Category = RoomCategory.DailyChallenge
};

AddStep("add room", () => API.Perform(new CreateRoomRequest(room)));
Expand All @@ -91,18 +91,18 @@ public void TestConclusionNotificationDoesNotFireOnDisconnect()
{
var room = new Room
{
RoomID = { Value = 1234 },
Name = { Value = "Daily Challenge: June 4, 2024" },
RoomID = 1234,
Name = "Daily Challenge: June 4, 2024",
Playlist =
{
[
new PlaylistItem(TestResources.CreateTestBeatmapSetInfo().Beatmaps.First())
{
RequiredMods = [new APIMod(new OsuModTraceable())],
AllowedMods = [new APIMod(new OsuModDoubleTime())]
}
},
EndDate = { Value = DateTimeOffset.Now.AddHours(12) },
Category = { Value = RoomCategory.DailyChallenge }
],
EndDate = DateTimeOffset.Now.AddHours(12),
Category = RoomCategory.DailyChallenge
};

AddStep("add room", () => API.Perform(new CreateRoomRequest(room)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ public partial class TestSceneDailyChallengeCarousel : OsuTestScene

private readonly Bindable<Room> room = new Bindable<Room>(new Room());

protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) => new CachedModelDependencyContainer<Room>(base.CreateChildDependencies(parent))
{
Model = { BindTarget = room }
};

[Test]
public void TestBasicAppearance()
{
Expand Down Expand Up @@ -98,7 +93,7 @@ public void TestIntegration()
Origin = Anchor.Centre,
Children = new Drawable[]
{
new DailyChallengeTimeRemainingRing(),
new DailyChallengeTimeRemainingRing(room.Value),
breakdown = new DailyChallengeScoreBreakdown(),
}
}
Expand All @@ -125,8 +120,8 @@ public void TestIntegration()
AddSliderStep("update time remaining", 0f, 1f, 0f, progress =>
{
var startedTimeAgo = TimeSpan.FromHours(24) * progress;
room.Value.StartDate.Value = DateTimeOffset.Now - startedTimeAgo;
room.Value.EndDate.Value = room.Value.StartDate.Value.Value.AddDays(1);
room.Value.StartDate = DateTimeOffset.Now - startedTimeAgo;
room.Value.EndDate = room.Value.StartDate.Value.AddDays(1);
});
AddStep("add normal score", () =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,19 @@ private void startChallenge(int roomId)
{
API.Perform(new CreateRoomRequest(room = new Room
{
RoomID = { Value = roomId },
Name = { Value = "Daily Challenge: June 4, 2024" },
RoomID = roomId,
Name = "Daily Challenge: June 4, 2024",
Playlist =
{
[
new PlaylistItem(CreateAPIBeatmap(new OsuRuleset().RulesetInfo))
{
RequiredMods = [new APIMod(new OsuModTraceable())],
AllowedMods = [new APIMod(new OsuModDoubleTime())]
}
},
StartDate = { Value = DateTimeOffset.Now },
EndDate = { Value = DateTimeOffset.Now.AddHours(24) },
Category = { Value = RoomCategory.DailyChallenge }
],
StartDate = DateTimeOffset.Now,
EndDate = DateTimeOffset.Now.AddHours(24),
Category = RoomCategory.DailyChallenge
}));
});
AddStep("signal client", () => metadataClient.DailyChallengeUpdated(new DailyChallengeInfo { RoomID = roomId }));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void TestBasicBehaviour()
return false;
};
});
AddStep("create leaderboard", () => Child = leaderboard = new DailyChallengeLeaderboard(new Room { RoomID = { Value = 1 } }, new PlaylistItem(Beatmap.Value.BeatmapInfo))
AddStep("create leaderboard", () => Child = leaderboard = new DailyChallengeLeaderboard(new Room { RoomID = 1 }, new PlaylistItem(Beatmap.Value.BeatmapInfo))
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Expand Down Expand Up @@ -86,7 +86,7 @@ public void TestLoadingBehaviour()
return false;
};
});
AddStep("create leaderboard", () => Child = leaderboard = new DailyChallengeLeaderboard(new Room { RoomID = { Value = 1 } }, new PlaylistItem(Beatmap.Value.BeatmapInfo))
AddStep("create leaderboard", () => Child = leaderboard = new DailyChallengeLeaderboard(new Room { RoomID = 1 }, new PlaylistItem(Beatmap.Value.BeatmapInfo))
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Expand Down
Loading

0 comments on commit 0e4d078

Please sign in to comment.