Use the local user's username when saving a new beatmap

This commit is contained in:
Dean Herbert 2020-09-01 18:56:49 +09:00
parent e337e6b3b0
commit d849f7f2b5
2 changed files with 24 additions and 8 deletions

View File

@ -97,20 +97,24 @@ namespace osu.Game.Beatmaps
public WorkingBeatmap CreateNew(RulesetInfo ruleset)
{
var metadata = new BeatmapMetadata
{
Artist = "artist",
Title = "title",
Author = User.SYSTEM_USER,
};
var set = new BeatmapSetInfo
{
Metadata = new BeatmapMetadata
{
Artist = "unknown",
Title = "unknown",
Author = User.SYSTEM_USER,
},
Metadata = metadata,
Beatmaps = new List<BeatmapInfo>
{
new BeatmapInfo
{
BaseDifficulty = new BeatmapDifficulty(),
Ruleset = ruleset
Ruleset = ruleset,
Metadata = metadata,
Version = "difficulty"
}
}
};

View File

@ -28,6 +28,7 @@ using osu.Framework.Logging;
using osu.Game.Beatmaps;
using osu.Game.Graphics.Cursor;
using osu.Game.Input.Bindings;
using osu.Game.Online.API;
using osu.Game.Rulesets.Edit;
using osu.Game.Screens.Edit.Compose;
using osu.Game.Screens.Edit.Setup;
@ -72,6 +73,9 @@ namespace osu.Game.Screens.Edit
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
=> dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
[Resolved]
private IAPIProvider api { get; set; }
[BackgroundDependencyLoader]
private void load(OsuColour colours, GameHost host)
{
@ -95,6 +99,7 @@ namespace osu.Game.Screens.Edit
{
isNewBeatmap = true;
Beatmap.Value = beatmapManager.CreateNew(Ruleset.Value);
Beatmap.Value.BeatmapSetInfo.Metadata.Author = api.LocalUser.Value;
}
try
@ -408,7 +413,14 @@ namespace osu.Game.Screens.Edit
clock.SeekForward(!clock.IsRunning, amount);
}
private void saveBeatmap() => beatmapManager.Save(playableBeatmap.BeatmapInfo, editorBeatmap);
private void saveBeatmap()
{
// apply any set-level metadata changes.
beatmapManager.Update(playableBeatmap.BeatmapInfo.BeatmapSet);
// save the loaded beatmap's data stream.
beatmapManager.Save(playableBeatmap.BeatmapInfo, editorBeatmap);
}
private void exportBeatmap()
{