1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-21 20:33:01 +08:00

Merge branch 'master' into multi-song-select-operation

This commit is contained in:
Bartłomiej Dach 2022-06-18 11:58:13 +02:00 committed by GitHub
commit 5917c70127
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 435 additions and 215 deletions

View File

@ -98,11 +98,14 @@ namespace osu.Game.Tests.Visual.Editing
using (var zip = ZipArchive.Open(temp)) using (var zip = ZipArchive.Open(temp))
zip.WriteToDirectory(extractedFolder); zip.WriteToDirectory(extractedFolder);
bool success = setup.ChildrenOfType<ResourcesSection>().First().ChangeAudioTrack(Path.Combine(extractedFolder, "03. Renatus - Soleily 192kbps.mp3")); bool success = setup.ChildrenOfType<ResourcesSection>().First().ChangeAudioTrack(new FileInfo(Path.Combine(extractedFolder, "03. Renatus - Soleily 192kbps.mp3")));
File.Delete(temp); File.Delete(temp);
Directory.Delete(extractedFolder, true); Directory.Delete(extractedFolder, true);
// ensure audio file is copied to beatmap as "audio.mp3" rather than original filename.
Assert.That(Beatmap.Value.Metadata.AudioFile == "audio.mp3");
return success; return success;
}); });

View File

@ -5,7 +5,6 @@
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Tests.Visual; using osu.Game.Tests.Visual;
using osu.Game.Tournament.Components; using osu.Game.Tournament.Components;
using osu.Game.Tournament.Models; using osu.Game.Tournament.Models;
@ -26,13 +25,13 @@ namespace osu.Game.Tournament.Tests.Components
FullName = { Value = "Australia" }, FullName = { Value = "Australia" },
Players = Players =
{ {
new APIUser { Username = "ASecretBox" }, new TournamentUser { Username = "ASecretBox" },
new APIUser { Username = "Dereban" }, new TournamentUser { Username = "Dereban" },
new APIUser { Username = "mReKk" }, new TournamentUser { Username = "mReKk" },
new APIUser { Username = "uyghti" }, new TournamentUser { Username = "uyghti" },
new APIUser { Username = "Parkes" }, new TournamentUser { Username = "Parkes" },
new APIUser { Username = "Shiroha" }, new TournamentUser { Username = "Shiroha" },
new APIUser { Username = "Jordan The Bear" }, new TournamentUser { Username = "Jordan The Bear" },
} }
}; };

View File

@ -42,7 +42,7 @@ namespace osu.Game.Tournament.Tests.Components
beatmap.Length = 123456; beatmap.Length = 123456;
beatmap.BPM = 133; beatmap.BPM = 133;
songBar.Beatmap = beatmap; songBar.Beatmap = new TournamentBeatmap(beatmap);
}); });
AddStep("set mods to HR", () => songBar.Mods = LegacyMods.HardRock); AddStep("set mods to HR", () => songBar.Mods = LegacyMods.HardRock);
AddStep("set mods to DT", () => songBar.Mods = LegacyMods.DoubleTime); AddStep("set mods to DT", () => songBar.Mods = LegacyMods.DoubleTime);

View File

@ -10,6 +10,7 @@ using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Tests.Visual; using osu.Game.Tests.Visual;
using osu.Game.Tournament.Components; using osu.Game.Tournament.Components;
using osu.Game.Tournament.Models;
namespace osu.Game.Tournament.Tests.Components namespace osu.Game.Tournament.Tests.Components
{ {
@ -32,7 +33,7 @@ namespace osu.Game.Tournament.Tests.Components
private void success(APIBeatmap beatmap) private void success(APIBeatmap beatmap)
{ {
Add(new TournamentBeatmapPanel(beatmap) Add(new TournamentBeatmapPanel(new TournamentBeatmap(beatmap))
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre Origin = Anchor.Centre

View File

@ -27,16 +27,16 @@ namespace osu.Game.Tournament.Tests.Components
Colour = "f2ca34" Colour = "f2ca34"
}; };
private readonly APIUser redUser = new APIUser private readonly TournamentUser redUser = new TournamentUser
{ {
Username = "BanchoBot", Username = "BanchoBot",
Id = 3, OnlineID = 3,
}; };
private readonly APIUser blueUser = new APIUser private readonly TournamentUser blueUser = new TournamentUser
{ {
Username = "Zallius", Username = "Zallius",
Id = 4, OnlineID = 4,
}; };
[Cached] [Cached]
@ -59,11 +59,11 @@ namespace osu.Game.Tournament.Tests.Components
{ {
Team1 = Team1 =
{ {
Value = new TournamentTeam { Players = new BindableList<APIUser> { redUser } } Value = new TournamentTeam { Players = new BindableList<TournamentUser> { redUser } }
}, },
Team2 = Team2 =
{ {
Value = new TournamentTeam { Players = new BindableList<APIUser> { blueUser } } Value = new TournamentTeam { Players = new BindableList<TournamentUser> { blueUser } }
} }
}; };
@ -82,19 +82,19 @@ namespace osu.Game.Tournament.Tests.Components
AddStep("message from team red", () => testChannel.AddNewMessages(new Message(nextMessageId()) AddStep("message from team red", () => testChannel.AddNewMessages(new Message(nextMessageId())
{ {
Sender = redUser, Sender = redUser.ToAPIUser(),
Content = "I am team red." Content = "I am team red."
})); }));
AddStep("message from team red", () => testChannel.AddNewMessages(new Message(nextMessageId()) AddStep("message from team red", () => testChannel.AddNewMessages(new Message(nextMessageId())
{ {
Sender = redUser, Sender = redUser.ToAPIUser(),
Content = "I plan to win!" Content = "I plan to win!"
})); }));
AddStep("message from team blue", () => testChannel.AddNewMessages(new Message(nextMessageId()) AddStep("message from team blue", () => testChannel.AddNewMessages(new Message(nextMessageId())
{ {
Sender = blueUser, Sender = blueUser.ToAPIUser(),
Content = "Not on my watch. Prepare to eat saaaaaaaaaand. Lots and lots of saaaaaaand." Content = "Not on my watch. Prepare to eat saaaaaaaaaand. Lots and lots of saaaaaaand."
})); }));

View File

@ -11,6 +11,7 @@ using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Tournament.Components; using osu.Game.Tournament.Components;
using osu.Game.Tournament.Models;
using osuTK; using osuTK;
namespace osu.Game.Tournament.Tests.Components namespace osu.Game.Tournament.Tests.Components
@ -53,7 +54,7 @@ namespace osu.Game.Tournament.Tests.Components
foreach (var mod in mods) foreach (var mod in mods)
{ {
fillFlow.Add(new TournamentBeatmapPanel(beatmap, mod.Acronym) fillFlow.Add(new TournamentBeatmapPanel(new TournamentBeatmap(beatmap), mod.Acronym)
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre Origin = Anchor.Centre

View File

@ -9,14 +9,12 @@ using osu.Framework.Allocation;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Framework.Utils; using osu.Framework.Utils;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Beatmaps;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Tests.Visual; using osu.Game.Tests.Visual;
using osu.Game.Tournament.IO; using osu.Game.Tournament.IO;
using osu.Game.Tournament.IPC; using osu.Game.Tournament.IPC;
using osu.Game.Tournament.Models; using osu.Game.Tournament.Models;
using osu.Game.Users;
using APIUser = osu.Game.Online.API.Requests.Responses.APIUser;
namespace osu.Game.Tournament.Tests namespace osu.Game.Tournament.Tests
{ {
@ -123,11 +121,11 @@ namespace osu.Game.Tournament.Tests
}, },
Players = Players =
{ {
new APIUser { Username = "Hello", Statistics = new UserStatistics { GlobalRank = 12 } }, new TournamentUser { Username = "Hello", Rank = 12 },
new APIUser { Username = "Hello", Statistics = new UserStatistics { GlobalRank = 16 } }, new TournamentUser { Username = "Hello", Rank = 16 },
new APIUser { Username = "Hello", Statistics = new UserStatistics { GlobalRank = 20 } }, new TournamentUser { Username = "Hello", Rank = 20 },
new APIUser { Username = "Hello", Statistics = new UserStatistics { GlobalRank = 24 } }, new TournamentUser { Username = "Hello", Rank = 24 },
new APIUser { Username = "Hello", Statistics = new UserStatistics { GlobalRank = 30 } }, new TournamentUser { Username = "Hello", Rank = 30 },
} }
} }
}, },
@ -140,11 +138,11 @@ namespace osu.Game.Tournament.Tests
FullName = { Value = "United States" }, FullName = { Value = "United States" },
Players = Players =
{ {
new APIUser { Username = "Hello" }, new TournamentUser { Username = "Hello" },
new APIUser { Username = "Hello" }, new TournamentUser { Username = "Hello" },
new APIUser { Username = "Hello" }, new TournamentUser { Username = "Hello" },
new APIUser { Username = "Hello" }, new TournamentUser { Username = "Hello" },
new APIUser { Username = "Hello" }, new TournamentUser { Username = "Hello" },
} }
} }
}, },
@ -154,10 +152,10 @@ namespace osu.Game.Tournament.Tests
} }
}; };
public static APIBeatmap CreateSampleBeatmap() => public static TournamentBeatmap CreateSampleBeatmap() =>
new APIBeatmap new TournamentBeatmap
{ {
BeatmapSet = new APIBeatmapSet Metadata = new BeatmapMetadata
{ {
Title = "Test Title", Title = "Test Title",
Artist = "Test Artist", Artist = "Test Artist",

View File

@ -7,7 +7,6 @@ using System.Linq;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Tournament.Models; using osu.Game.Tournament.Models;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
@ -56,7 +55,7 @@ namespace osu.Game.Tournament.Components
}, },
}; };
TournamentSpriteText createPlayerText(APIUser p) => TournamentSpriteText createPlayerText(TournamentUser p) =>
new TournamentSpriteText new TournamentSpriteText
{ {
Text = p.Username, Text = p.Username,

View File

@ -14,9 +14,9 @@ using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Legacy; using osu.Game.Beatmaps.Legacy;
using osu.Game.Extensions; using osu.Game.Extensions;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Screens.Menu; using osu.Game.Screens.Menu;
using osu.Game.Tournament.Models;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
@ -24,14 +24,14 @@ namespace osu.Game.Tournament.Components
{ {
public class SongBar : CompositeDrawable public class SongBar : CompositeDrawable
{ {
private APIBeatmap beatmap; private TournamentBeatmap beatmap;
public const float HEIGHT = 145 / 2f; public const float HEIGHT = 145 / 2f;
[Resolved] [Resolved]
private IBindable<RulesetInfo> ruleset { get; set; } private IBindable<RulesetInfo> ruleset { get; set; }
public APIBeatmap Beatmap public TournamentBeatmap Beatmap
{ {
set set
{ {

View File

@ -14,7 +14,6 @@ using osu.Framework.Graphics.Shapes;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Drawables; using osu.Game.Beatmaps.Drawables;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Tournament.Models; using osu.Game.Tournament.Models;
using osuTK.Graphics; using osuTK.Graphics;
@ -22,7 +21,7 @@ namespace osu.Game.Tournament.Components
{ {
public class TournamentBeatmapPanel : CompositeDrawable public class TournamentBeatmapPanel : CompositeDrawable
{ {
public readonly APIBeatmap Beatmap; public readonly TournamentBeatmap Beatmap;
private readonly string mod; private readonly string mod;
@ -31,7 +30,7 @@ namespace osu.Game.Tournament.Components
private readonly Bindable<TournamentMatch> currentMatch = new Bindable<TournamentMatch>(); private readonly Bindable<TournamentMatch> currentMatch = new Bindable<TournamentMatch>();
private Box flash; private Box flash;
public TournamentBeatmapPanel(APIBeatmap beatmap, string mod = null) public TournamentBeatmapPanel(TournamentBeatmap beatmap, string mod = null)
{ {
if (beatmap == null) throw new ArgumentNullException(nameof(beatmap)); if (beatmap == null) throw new ArgumentNullException(nameof(beatmap));
@ -61,7 +60,7 @@ namespace osu.Game.Tournament.Components
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = OsuColour.Gray(0.5f), Colour = OsuColour.Gray(0.5f),
OnlineInfo = Beatmap.BeatmapSet, OnlineInfo = Beatmap,
}, },
new FillFlowContainer new FillFlowContainer
{ {

View File

@ -96,7 +96,7 @@ namespace osu.Game.Tournament.IPC
else else
{ {
beatmapLookupRequest = new GetBeatmapRequest(new APIBeatmap { OnlineID = beatmapId }); beatmapLookupRequest = new GetBeatmapRequest(new APIBeatmap { OnlineID = beatmapId });
beatmapLookupRequest.Success += b => Beatmap.Value = b; beatmapLookupRequest.Success += b => Beatmap.Value = new TournamentBeatmap(b);
API.Queue(beatmapLookupRequest); API.Queue(beatmapLookupRequest);
} }
} }

View File

@ -6,13 +6,13 @@
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Beatmaps.Legacy; using osu.Game.Beatmaps.Legacy;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Tournament.Models;
namespace osu.Game.Tournament.IPC namespace osu.Game.Tournament.IPC
{ {
public class MatchIPCInfo : Component public class MatchIPCInfo : Component
{ {
public Bindable<APIBeatmap> Beatmap { get; } = new Bindable<APIBeatmap>(); public Bindable<TournamentBeatmap> Beatmap { get; } = new Bindable<TournamentBeatmap>();
public Bindable<LegacyMods> Mods { get; } = new Bindable<LegacyMods>(); public Bindable<LegacyMods> Mods { get; } = new Bindable<LegacyMods>();
public Bindable<TourneyState> State { get; } = new Bindable<TourneyState>(); public Bindable<TourneyState> State { get; } = new Bindable<TourneyState>();
public Bindable<string> ChatChannel { get; } = new Bindable<string>(); public Bindable<string> ChatChannel { get; } = new Bindable<string>();

View File

@ -4,7 +4,6 @@
#nullable disable #nullable disable
using Newtonsoft.Json; using Newtonsoft.Json;
using osu.Game.Online.API.Requests.Responses;
namespace osu.Game.Tournament.Models namespace osu.Game.Tournament.Models
{ {
@ -14,6 +13,6 @@ namespace osu.Game.Tournament.Models
public string Mods; public string Mods;
[JsonProperty("BeatmapInfo")] [JsonProperty("BeatmapInfo")]
public APIBeatmap Beatmap; public TournamentBeatmap Beatmap;
} }
} }

View File

@ -5,7 +5,6 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Game.Online.API.Requests.Responses;
namespace osu.Game.Tournament.Models namespace osu.Game.Tournament.Models
{ {
@ -14,7 +13,7 @@ namespace osu.Game.Tournament.Models
public int ID; public int ID;
[JsonProperty("BeatmapInfo")] [JsonProperty("BeatmapInfo")]
public APIBeatmap Beatmap; public TournamentBeatmap Beatmap;
public long Score; public long Score;

View File

@ -0,0 +1,99 @@
// 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 osu.Framework.Extensions.ObjectExtensions;
using osu.Game.Beatmaps;
using osu.Game.Extensions;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Rulesets;
namespace osu.Game.Tournament.Models
{
public class TournamentBeatmap : IBeatmapInfo, IBeatmapSetOnlineInfo
{
public int OnlineID { get; set; }
public string DifficultyName { get; set; } = string.Empty;
public double BPM { get; set; }
public double Length { get; set; }
public double StarRating { get; set; }
public IBeatmapMetadataInfo Metadata { get; set; } = new BeatmapMetadata();
public IBeatmapDifficultyInfo Difficulty { get; set; } = new BeatmapDifficulty();
public BeatmapSetOnlineCovers Covers { get; set; }
public TournamentBeatmap()
{
}
public TournamentBeatmap(APIBeatmap beatmap)
{
OnlineID = beatmap.OnlineID;
DifficultyName = beatmap.DifficultyName;
BPM = beatmap.BPM;
Length = beatmap.Length;
StarRating = beatmap.StarRating;
Metadata = beatmap.Metadata;
Difficulty = beatmap.Difficulty;
Covers = beatmap.BeatmapSet.AsNonNull().Covers;
}
public bool Equals(IBeatmapInfo? other) => other is TournamentBeatmap b && this.MatchesOnlineID(b);
#region IBeatmapInfo/IBeatmapSetOnlineInfo explicit implementation
IBeatmapSetInfo IBeatmapInfo.BeatmapSet => throw new NotImplementedException();
string IBeatmapSetOnlineInfo.Preview => throw new NotImplementedException();
double IBeatmapSetOnlineInfo.BPM => throw new NotImplementedException();
int IBeatmapSetOnlineInfo.PlayCount => throw new NotImplementedException();
int IBeatmapSetOnlineInfo.FavouriteCount => throw new NotImplementedException();
bool IBeatmapSetOnlineInfo.HasFavourited => throw new NotImplementedException();
BeatmapSetOnlineAvailability IBeatmapSetOnlineInfo.Availability => throw new NotImplementedException();
BeatmapSetOnlineGenre IBeatmapSetOnlineInfo.Genre => throw new NotImplementedException();
BeatmapSetOnlineLanguage IBeatmapSetOnlineInfo.Language => throw new NotImplementedException();
int? IBeatmapSetOnlineInfo.TrackId => throw new NotImplementedException();
int[] IBeatmapSetOnlineInfo.Ratings => throw new NotImplementedException();
BeatmapSetHypeStatus IBeatmapSetOnlineInfo.HypeStatus => throw new NotImplementedException();
BeatmapSetNominationStatus IBeatmapSetOnlineInfo.NominationStatus => throw new NotImplementedException();
string IBeatmapInfo.Hash => throw new NotImplementedException();
string IBeatmapInfo.MD5Hash => throw new NotImplementedException();
IRulesetInfo IBeatmapInfo.Ruleset => throw new NotImplementedException();
DateTimeOffset IBeatmapSetOnlineInfo.Submitted => throw new NotImplementedException();
DateTimeOffset? IBeatmapSetOnlineInfo.Ranked => throw new NotImplementedException();
DateTimeOffset? IBeatmapSetOnlineInfo.LastUpdated => throw new NotImplementedException();
BeatmapOnlineStatus IBeatmapSetOnlineInfo.Status => throw new NotImplementedException();
bool IBeatmapSetOnlineInfo.HasExplicitContent => throw new NotImplementedException();
bool IBeatmapSetOnlineInfo.HasVideo => throw new NotImplementedException();
bool IBeatmapSetOnlineInfo.HasStoryboard => throw new NotImplementedException();
#endregion
}
}

View File

@ -7,7 +7,6 @@ using System;
using System.Linq; using System.Linq;
using Newtonsoft.Json; using Newtonsoft.Json;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Game.Online.API.Requests.Responses;
namespace osu.Game.Tournament.Models namespace osu.Game.Tournament.Models
{ {
@ -38,7 +37,7 @@ namespace osu.Game.Tournament.Models
{ {
get get
{ {
int[] ranks = Players.Select(p => p.Statistics?.GlobalRank) int[] ranks = Players.Select(p => p.Rank)
.Where(i => i.HasValue) .Where(i => i.HasValue)
.Select(i => i.Value) .Select(i => i.Value)
.ToArray(); .ToArray();
@ -59,7 +58,7 @@ namespace osu.Game.Tournament.Models
}; };
[JsonProperty] [JsonProperty]
public BindableList<APIUser> Players { get; set; } = new BindableList<APIUser>(); public BindableList<TournamentUser> Players { get; set; } = new BindableList<TournamentUser>();
public TournamentTeam() public TournamentTeam()
{ {

View File

@ -0,0 +1,58 @@
// 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 Newtonsoft.Json;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Users;
namespace osu.Game.Tournament.Models
{
/// <summary>
/// A tournament player user, containing simple information about the player.
/// </summary>
[Serializable]
public class TournamentUser : IUser
{
[JsonProperty(@"id")]
public int OnlineID { get; set; }
public string Username { get; set; } = string.Empty;
/// <summary>
/// The player's country.
/// </summary>
public Country? Country { get; set; }
/// <summary>
/// The player's global rank, or null if not available.
/// </summary>
public int? Rank { get; set; }
/// <summary>
/// A URL to the player's profile cover.
/// </summary>
public string CoverUrl { get; set; } = string.Empty;
public APIUser ToAPIUser()
{
var user = new APIUser
{
Id = OnlineID,
Username = Username,
Country = Country,
CoverUrl = CoverUrl,
};
user.Statistics = new UserStatistics
{
User = user,
GlobalRank = Rank
};
return user;
}
bool IUser.IsBot => false;
}
}

View File

@ -7,9 +7,9 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Beatmaps.Legacy; using osu.Game.Beatmaps.Legacy;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Tournament.Components; using osu.Game.Tournament.Components;
using osu.Game.Tournament.IPC; using osu.Game.Tournament.IPC;
using osu.Game.Tournament.Models;
namespace osu.Game.Tournament.Screens namespace osu.Game.Tournament.Screens
{ {
@ -39,7 +39,7 @@ namespace osu.Game.Tournament.Screens
SongBar.Mods = mods.NewValue; SongBar.Mods = mods.NewValue;
} }
private void beatmapChanged(ValueChangedEvent<APIBeatmap> beatmap) private void beatmapChanged(ValueChangedEvent<TournamentBeatmap> beatmap)
{ {
SongBar.FadeInFromZero(300, Easing.OutQuint); SongBar.FadeInFromZero(300, Easing.OutQuint);
SongBar.Beatmap = beatmap.NewValue; SongBar.Beatmap = beatmap.NewValue;

View File

@ -239,7 +239,7 @@ namespace osu.Game.Tournament.Screens.Editors
req.Success += res => req.Success += res =>
{ {
Model.Beatmap = res; Model.Beatmap = new TournamentBeatmap(res);
updatePanel(); updatePanel();
}; };

View File

@ -241,7 +241,7 @@ namespace osu.Game.Tournament.Screens.Editors
req.Success += res => req.Success += res =>
{ {
Model.Beatmap = res; Model.Beatmap = new TournamentBeatmap(res);
updatePanel(); updatePanel();
}; };

View File

@ -15,7 +15,6 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Online.API; using osu.Game.Online.API;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays.Settings; using osu.Game.Overlays.Settings;
using osu.Game.Tournament.Components; using osu.Game.Tournament.Components;
using osu.Game.Tournament.Models; using osu.Game.Tournament.Models;
@ -202,14 +201,14 @@ namespace osu.Game.Tournament.Screens.Editors
public void CreateNew() public void CreateNew()
{ {
var user = new APIUser(); var player = new TournamentUser();
team.Players.Add(user); team.Players.Add(player);
flow.Add(new PlayerRow(team, user)); flow.Add(new PlayerRow(team, player));
} }
public class PlayerRow : CompositeDrawable public class PlayerRow : CompositeDrawable
{ {
private readonly APIUser user; private readonly TournamentUser user;
[Resolved] [Resolved]
protected IAPIProvider API { get; private set; } protected IAPIProvider API { get; private set; }
@ -217,11 +216,11 @@ namespace osu.Game.Tournament.Screens.Editors
[Resolved] [Resolved]
private TournamentGameBase game { get; set; } private TournamentGameBase game { get; set; }
private readonly Bindable<int?> userId = new Bindable<int?>(); private readonly Bindable<int?> playerId = new Bindable<int?>();
private readonly Container drawableContainer; private readonly Container drawableContainer;
public PlayerRow(TournamentTeam team, APIUser user) public PlayerRow(TournamentTeam team, TournamentUser user)
{ {
this.user = user; this.user = user;
@ -254,7 +253,7 @@ namespace osu.Game.Tournament.Screens.Editors
LabelText = "User ID", LabelText = "User ID",
RelativeSizeAxes = Axes.None, RelativeSizeAxes = Axes.None,
Width = 200, Width = 200,
Current = userId, Current = playerId,
}, },
drawableContainer = new Container drawableContainer = new Container
{ {
@ -281,10 +280,10 @@ namespace osu.Game.Tournament.Screens.Editors
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
userId.Value = user.Id; playerId.Value = user.OnlineID;
userId.BindValueChanged(id => playerId.BindValueChanged(id =>
{ {
user.Id = id.NewValue ?? 0; user.OnlineID = id.NewValue ?? 0;
if (id.NewValue != id.OldValue) if (id.NewValue != id.OldValue)
user.Username = string.Empty; user.Username = string.Empty;
@ -295,13 +294,13 @@ namespace osu.Game.Tournament.Screens.Editors
return; return;
} }
game.PopulateUser(user, updatePanel, updatePanel); game.PopulatePlayer(user, updatePanel, updatePanel);
}, true); }, true);
} }
private void updatePanel() private void updatePanel()
{ {
drawableContainer.Child = new UserGridPanel(user) { Width = 300 }; drawableContainer.Child = new UserGridPanel(user.ToAPIUser()) { Width = 300 };
} }
} }
} }

View File

@ -11,7 +11,6 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Framework.Threading; using osu.Framework.Threading;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Tournament.Components; using osu.Game.Tournament.Components;
using osu.Game.Tournament.IPC; using osu.Game.Tournament.IPC;
using osu.Game.Tournament.Models; using osu.Game.Tournament.Models;
@ -107,7 +106,7 @@ namespace osu.Game.Tournament.Screens.MapPool
ipc.Beatmap.BindValueChanged(beatmapChanged); ipc.Beatmap.BindValueChanged(beatmapChanged);
} }
private void beatmapChanged(ValueChangedEvent<APIBeatmap> beatmap) private void beatmapChanged(ValueChangedEvent<TournamentBeatmap> beatmap)
{ {
if (CurrentMatch.Value == null || CurrentMatch.Value.PicksBans.Count(p => p.Type == ChoiceType.Ban) < 2) if (CurrentMatch.Value == null || CurrentMatch.Value.PicksBans.Count(p => p.Type == ChoiceType.Ban) < 2)
return; return;

View File

@ -257,7 +257,7 @@ namespace osu.Game.Tournament.Screens.TeamIntro
}; };
foreach (var p in team.Players) foreach (var p in team.Players)
fill.Add(new RowDisplay(p.Username, p.Statistics?.GlobalRank?.ToString("\\##,0") ?? "-")); fill.Add(new RowDisplay(p.Username, p.Rank?.ToString("\\##,0") ?? "-"));
} }
internal class RowDisplay : CompositeDrawable internal class RowDisplay : CompositeDrawable

View File

@ -22,7 +22,6 @@ using osu.Game.Tournament.IO;
using osu.Game.Tournament.IPC; using osu.Game.Tournament.IPC;
using osu.Game.Tournament.Models; using osu.Game.Tournament.Models;
using osuTK.Input; using osuTK.Input;
using APIUser = osu.Game.Online.API.Requests.Responses.APIUser;
namespace osu.Game.Tournament namespace osu.Game.Tournament
{ {
@ -187,9 +186,7 @@ namespace osu.Game.Tournament
{ {
var playersRequiringPopulation = ladder.Teams var playersRequiringPopulation = ladder.Teams
.SelectMany(t => t.Players) .SelectMany(t => t.Players)
.Where(p => string.IsNullOrEmpty(p.Username) .Where(p => string.IsNullOrEmpty(p.Username) || p.Rank == null).ToList();
|| p.Statistics?.GlobalRank == null
|| p.Statistics?.CountryRank == null).ToList();
if (playersRequiringPopulation.Count == 0) if (playersRequiringPopulation.Count == 0)
return false; return false;
@ -197,7 +194,7 @@ namespace osu.Game.Tournament
for (int i = 0; i < playersRequiringPopulation.Count; i++) for (int i = 0; i < playersRequiringPopulation.Count; i++)
{ {
var p = playersRequiringPopulation[i]; var p = playersRequiringPopulation[i];
PopulateUser(p, immediate: true); PopulatePlayer(p, immediate: true);
updateLoadProgressMessage($"Populating user stats ({i} / {playersRequiringPopulation.Count})"); updateLoadProgressMessage($"Populating user stats ({i} / {playersRequiringPopulation.Count})");
} }
@ -211,7 +208,7 @@ namespace osu.Game.Tournament
{ {
var beatmapsRequiringPopulation = ladder.Rounds var beatmapsRequiringPopulation = ladder.Rounds
.SelectMany(r => r.Beatmaps) .SelectMany(r => r.Beatmaps)
.Where(b => string.IsNullOrEmpty(b.Beatmap?.BeatmapSet?.Title) && b.ID > 0).ToList(); .Where(b => b.Beatmap?.OnlineID == 0 && b.ID > 0).ToList();
if (beatmapsRequiringPopulation.Count == 0) if (beatmapsRequiringPopulation.Count == 0)
return false; return false;
@ -222,7 +219,7 @@ namespace osu.Game.Tournament
var req = new GetBeatmapRequest(new APIBeatmap { OnlineID = b.ID }); var req = new GetBeatmapRequest(new APIBeatmap { OnlineID = b.ID });
API.Perform(req); API.Perform(req);
b.Beatmap = req.Response ?? new APIBeatmap(); b.Beatmap = new TournamentBeatmap(req.Response ?? new APIBeatmap());
updateLoadProgressMessage($"Populating round beatmaps ({i} / {beatmapsRequiringPopulation.Count})"); updateLoadProgressMessage($"Populating round beatmaps ({i} / {beatmapsRequiringPopulation.Count})");
} }
@ -238,7 +235,7 @@ namespace osu.Game.Tournament
var beatmapsRequiringPopulation = ladder.Teams var beatmapsRequiringPopulation = ladder.Teams
.SelectMany(r => r.SeedingResults) .SelectMany(r => r.SeedingResults)
.SelectMany(r => r.Beatmaps) .SelectMany(r => r.Beatmaps)
.Where(b => string.IsNullOrEmpty(b.Beatmap?.BeatmapSet?.Title) && b.ID > 0).ToList(); .Where(b => b.Beatmap?.OnlineID == 0 && b.ID > 0).ToList();
if (beatmapsRequiringPopulation.Count == 0) if (beatmapsRequiringPopulation.Count == 0)
return false; return false;
@ -249,7 +246,7 @@ namespace osu.Game.Tournament
var req = new GetBeatmapRequest(new APIBeatmap { OnlineID = b.ID }); var req = new GetBeatmapRequest(new APIBeatmap { OnlineID = b.ID });
API.Perform(req); API.Perform(req);
b.Beatmap = req.Response ?? new APIBeatmap(); b.Beatmap = new TournamentBeatmap(req.Response ?? new APIBeatmap());
updateLoadProgressMessage($"Populating seeding beatmaps ({i} / {beatmapsRequiringPopulation.Count})"); updateLoadProgressMessage($"Populating seeding beatmaps ({i} / {beatmapsRequiringPopulation.Count})");
} }
@ -259,9 +256,9 @@ namespace osu.Game.Tournament
private void updateLoadProgressMessage(string s) => Schedule(() => initialisationText.Text = s); private void updateLoadProgressMessage(string s) => Schedule(() => initialisationText.Text = s);
public void PopulateUser(APIUser user, Action success = null, Action failure = null, bool immediate = false) public void PopulatePlayer(TournamentUser user, Action success = null, Action failure = null, bool immediate = false)
{ {
var req = new GetUserRequest(user.Id, ladder.Ruleset.Value); var req = new GetUserRequest(user.OnlineID, ladder.Ruleset.Value);
if (immediate) if (immediate)
{ {
@ -273,7 +270,7 @@ namespace osu.Game.Tournament
req.Success += res => { populate(); }; req.Success += res => { populate(); };
req.Failure += _ => req.Failure += _ =>
{ {
user.Id = 1; user.OnlineID = 1;
failure?.Invoke(); failure?.Invoke();
}; };
@ -287,12 +284,12 @@ namespace osu.Game.Tournament
if (res == null) if (res == null)
return; return;
user.Id = res.Id; user.OnlineID = res.Id;
user.Username = res.Username; user.Username = res.Username;
user.Statistics = res.Statistics; user.CoverUrl = res.CoverUrl;
user.Country = res.Country; user.Country = res.Country;
user.Cover = res.Cover; user.Rank = res.Statistics?.GlobalRank;
success?.Invoke(); success?.Invoke();
} }

View File

@ -3,6 +3,7 @@
#nullable disable #nullable disable
using System.Linq;
using System.Threading; using System.Threading;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
@ -73,6 +74,10 @@ namespace osu.Game.Rulesets.Edit
/// <param name="commitStart">Whether this call is committing a value for HitObject.StartTime and continuing with further adjustments.</param> /// <param name="commitStart">Whether this call is committing a value for HitObject.StartTime and continuing with further adjustments.</param>
protected void BeginPlacement(bool commitStart = false) protected void BeginPlacement(bool commitStart = false)
{ {
var nearestSampleControlPoint = beatmap.HitObjects.LastOrDefault(h => h.GetEndTime() < HitObject.StartTime)?.SampleControlPoint?.DeepClone() as SampleControlPoint;
HitObject.SampleControlPoint = nearestSampleControlPoint ?? new SampleControlPoint();
placementHandler.BeginPlacement(HitObject); placementHandler.BeginPlacement(HitObject);
if (commitStart) if (commitStart)
PlacementActive = PlacementState.Active; PlacementActive = PlacementState.Active;

View File

@ -1,92 +0,0 @@
// 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.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Database;
using osu.Game.Graphics.UserInterfaceV2;
using osuTK;
namespace osu.Game.Screens.Edit.Setup
{
/// <summary>
/// A labelled textbox which reveals an inline file chooser when clicked.
/// </summary>
internal class FileChooserLabelledTextBox : LabelledTextBoxWithPopover, ICanAcceptFiles
{
private readonly string[] handledExtensions;
public IEnumerable<string> HandledExtensions => handledExtensions;
private readonly Bindable<FileInfo?> currentFile = new Bindable<FileInfo?>();
[Resolved]
private OsuGameBase game { get; set; } = null!;
public FileChooserLabelledTextBox(params string[] handledExtensions)
{
this.handledExtensions = handledExtensions;
}
protected override void LoadComplete()
{
base.LoadComplete();
game.RegisterImportHandler(this);
currentFile.BindValueChanged(onFileSelected);
}
private void onFileSelected(ValueChangedEvent<FileInfo?> file)
{
if (file.NewValue == null)
return;
this.HidePopover();
Current.Value = file.NewValue.FullName;
}
Task ICanAcceptFiles.Import(params string[] paths)
{
Schedule(() => currentFile.Value = new FileInfo(paths.First()));
return Task.CompletedTask;
}
Task ICanAcceptFiles.Import(params ImportTask[] tasks) => throw new NotImplementedException();
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
if (game.IsNotNull())
game.UnregisterImportHandler(this);
}
public override Popover GetPopover() => new FileChooserPopover(handledExtensions, currentFile);
private class FileChooserPopover : OsuPopover
{
public FileChooserPopover(string[] handledExtensions, Bindable<FileInfo?> currentFile)
{
Child = new Container
{
Size = new Vector2(600, 400),
Child = new OsuFileSelector(currentFile.Value?.DirectoryName, handledExtensions)
{
RelativeSizeAxes = Axes.Both,
CurrentFile = { BindTarget = currentFile }
},
};
}
}
}
}

View File

@ -0,0 +1,131 @@
// 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.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Localisation;
using osu.Framework.Platform;
using osu.Game.Database;
using osu.Game.Graphics.UserInterfaceV2;
using osuTK;
namespace osu.Game.Screens.Edit.Setup
{
/// <summary>
/// A labelled drawable displaying file chooser on click, with placeholder text support.
/// todo: this should probably not use PopoverTextBox just to display placeholder text, but is the best way for now.
/// </summary>
internal class LabelledFileChooser : LabelledDrawable<LabelledTextBoxWithPopover.PopoverTextBox>, IHasCurrentValue<FileInfo?>, ICanAcceptFiles, IHasPopover
{
private readonly string[] handledExtensions;
public IEnumerable<string> HandledExtensions => handledExtensions;
[Resolved]
private OsuGameBase game { get; set; } = null!;
/// <summary>
/// The initial path to use when displaying the <see cref="FileChooserPopover"/>.
/// </summary>
/// <remarks>
/// Uses a <see langword="null"/> value before the first selection is made
/// to ensure that the first selection starts at <see cref="GameHost.InitialFileSelectorPath"/>.
/// </remarks>
private string? initialChooserPath;
private readonly BindableWithCurrent<FileInfo?> current = new BindableWithCurrent<FileInfo?>();
public Bindable<FileInfo?> Current
{
get => current.Current;
set => current.Current = value;
}
public LocalisableString Text
{
get => Component.PlaceholderText;
set => Component.PlaceholderText = value;
}
public CompositeDrawable TabbableContentContainer
{
set => Component.TabbableContentContainer = value;
}
public LabelledFileChooser(params string[] handledExtensions)
: base(false)
{
this.handledExtensions = handledExtensions;
}
protected override void LoadComplete()
{
base.LoadComplete();
game.RegisterImportHandler(this);
Current.BindValueChanged(onFileSelected);
}
private void onFileSelected(ValueChangedEvent<FileInfo?> file)
{
if (file.NewValue != null)
this.HidePopover();
initialChooserPath = file.NewValue?.DirectoryName;
}
Task ICanAcceptFiles.Import(params string[] paths)
{
Schedule(() => Current.Value = new FileInfo(paths.First()));
return Task.CompletedTask;
}
Task ICanAcceptFiles.Import(params ImportTask[] tasks) => throw new NotImplementedException();
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
if (game.IsNotNull())
game.UnregisterImportHandler(this);
}
protected override LabelledTextBoxWithPopover.PopoverTextBox CreateComponent() => new LabelledTextBoxWithPopover.PopoverTextBox
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.X,
CornerRadius = CORNER_RADIUS,
OnFocused = this.ShowPopover,
};
public Popover GetPopover() => new FileChooserPopover(handledExtensions, Current, initialChooserPath);
private class FileChooserPopover : OsuPopover
{
public FileChooserPopover(string[] handledExtensions, Bindable<FileInfo?> currentFile, string? chooserPath)
{
Child = new Container
{
Size = new Vector2(600, 400),
Child = new OsuFileSelector(chooserPath, handledExtensions)
{
RelativeSizeAxes = Axes.Both,
CurrentFile = { BindTarget = currentFile }
},
};
}
}
}
}

View File

@ -10,15 +10,14 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Graphics.UserInterfaceV2;
using osu.Game.Overlays; using osu.Game.Overlays;
namespace osu.Game.Screens.Edit.Setup namespace osu.Game.Screens.Edit.Setup
{ {
internal class ResourcesSection : SetupSection internal class ResourcesSection : SetupSection
{ {
private LabelledTextBox audioTrackTextBox; private LabelledFileChooser audioTrackChooser;
private LabelledTextBox backgroundTextBox; private LabelledFileChooser backgroundChooser;
public override LocalisableString Title => "Resources"; public override LocalisableString Title => "Resources";
@ -42,76 +41,81 @@ namespace osu.Game.Screens.Edit.Setup
{ {
Children = new Drawable[] Children = new Drawable[]
{ {
backgroundTextBox = new FileChooserLabelledTextBox(".jpg", ".jpeg", ".png") backgroundChooser = new LabelledFileChooser(".jpg", ".jpeg", ".png")
{ {
Label = "Background", Label = "Background",
FixedLabelWidth = LABEL_WIDTH, FixedLabelWidth = LABEL_WIDTH,
PlaceholderText = "Click to select a background image",
Current = { Value = working.Value.Metadata.BackgroundFile },
TabbableContentContainer = this TabbableContentContainer = this
}, },
audioTrackTextBox = new FileChooserLabelledTextBox(".mp3", ".ogg") audioTrackChooser = new LabelledFileChooser(".mp3", ".ogg")
{ {
Label = "Audio Track", Label = "Audio Track",
FixedLabelWidth = LABEL_WIDTH, FixedLabelWidth = LABEL_WIDTH,
PlaceholderText = "Click to select a track",
Current = { Value = working.Value.Metadata.AudioFile },
TabbableContentContainer = this TabbableContentContainer = this
}, },
}; };
backgroundTextBox.Current.BindValueChanged(backgroundChanged); if (!string.IsNullOrEmpty(working.Value.Metadata.BackgroundFile))
audioTrackTextBox.Current.BindValueChanged(audioTrackChanged); backgroundChooser.Current.Value = new FileInfo(working.Value.Metadata.BackgroundFile);
if (!string.IsNullOrEmpty(working.Value.Metadata.AudioFile))
audioTrackChooser.Current.Value = new FileInfo(working.Value.Metadata.AudioFile);
backgroundChooser.Current.BindValueChanged(backgroundChanged);
audioTrackChooser.Current.BindValueChanged(audioTrackChanged);
updatePlaceholderText();
} }
public bool ChangeBackgroundImage(string path) public bool ChangeBackgroundImage(FileInfo source)
{ {
var info = new FileInfo(path); if (!source.Exists)
if (!info.Exists)
return false; return false;
var set = working.Value.BeatmapSetInfo; var set = working.Value.BeatmapSetInfo;
var destination = new FileInfo($@"bg{source.Extension}");
// remove the previous background for now. // remove the previous background for now.
// in the future we probably want to check if this is being used elsewhere (other difficulties?) // in the future we probably want to check if this is being used elsewhere (other difficulties?)
var oldFile = set.Files.FirstOrDefault(f => f.Filename == working.Value.Metadata.BackgroundFile); var oldFile = set.Files.FirstOrDefault(f => f.Filename == working.Value.Metadata.BackgroundFile);
using (var stream = info.OpenRead()) using (var stream = source.OpenRead())
{ {
if (oldFile != null) if (oldFile != null)
beatmaps.DeleteFile(set, oldFile); beatmaps.DeleteFile(set, oldFile);
beatmaps.AddFile(set, stream, info.Name); beatmaps.AddFile(set, stream, destination.Name);
} }
working.Value.Metadata.BackgroundFile = info.Name; working.Value.Metadata.BackgroundFile = destination.Name;
header.Background.UpdateBackground(); header.Background.UpdateBackground();
return true; return true;
} }
public bool ChangeAudioTrack(string path) public bool ChangeAudioTrack(FileInfo source)
{ {
var info = new FileInfo(path); if (!source.Exists)
if (!info.Exists)
return false; return false;
var set = working.Value.BeatmapSetInfo; var set = working.Value.BeatmapSetInfo;
var destination = new FileInfo($@"audio{source.Extension}");
// remove the previous audio track for now. // remove the previous audio track for now.
// in the future we probably want to check if this is being used elsewhere (other difficulties?) // in the future we probably want to check if this is being used elsewhere (other difficulties?)
var oldFile = set.Files.FirstOrDefault(f => f.Filename == working.Value.Metadata.AudioFile); var oldFile = set.Files.FirstOrDefault(f => f.Filename == working.Value.Metadata.AudioFile);
using (var stream = info.OpenRead()) using (var stream = source.OpenRead())
{ {
if (oldFile != null) if (oldFile != null)
beatmaps.DeleteFile(set, oldFile); beatmaps.DeleteFile(set, oldFile);
beatmaps.AddFile(set, stream, info.Name);
beatmaps.AddFile(set, stream, destination.Name);
} }
working.Value.Metadata.AudioFile = info.Name; working.Value.Metadata.AudioFile = destination.Name;
music.ReloadCurrentTrack(); music.ReloadCurrentTrack();
@ -119,16 +123,31 @@ namespace osu.Game.Screens.Edit.Setup
return true; return true;
} }
private void backgroundChanged(ValueChangedEvent<string> filePath) private void backgroundChanged(ValueChangedEvent<FileInfo> file)
{ {
if (!ChangeBackgroundImage(filePath.NewValue)) if (!ChangeBackgroundImage(file.NewValue))
backgroundTextBox.Current.Value = filePath.OldValue; backgroundChooser.Current.Value = file.OldValue;
updatePlaceholderText();
} }
private void audioTrackChanged(ValueChangedEvent<string> filePath) private void audioTrackChanged(ValueChangedEvent<FileInfo> file)
{ {
if (!ChangeAudioTrack(filePath.NewValue)) if (!ChangeAudioTrack(file.NewValue))
audioTrackTextBox.Current.Value = filePath.OldValue; audioTrackChooser.Current.Value = file.OldValue;
updatePlaceholderText();
}
private void updatePlaceholderText()
{
audioTrackChooser.Text = audioTrackChooser.Current.Value == null
? "Click to select a track"
: "Click to replace the track";
backgroundChooser.Text = backgroundChooser.Current.Value == null
? "Click to select a background image"
: "Click to replace the background image";
} }
} }
} }

View File

@ -4,6 +4,7 @@
#nullable disable #nullable disable
using System; using System;
using JetBrains.Annotations;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio; using osu.Framework.Audio;
using osu.Framework.Audio.Sample; using osu.Framework.Audio.Sample;
@ -14,6 +15,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Threading;
using osu.Framework.Timing; using osu.Framework.Timing;
using osu.Framework.Utils; using osu.Framework.Utils;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
@ -37,6 +39,9 @@ namespace osu.Game.Screens.Edit.Timing
private Sample clunk; private Sample clunk;
[CanBeNull]
private ScheduledDelegate clunkDelegate;
[Resolved] [Resolved]
private OverlayColourProvider overlayColourProvider { get; set; } private OverlayColourProvider overlayColourProvider { get; set; }
@ -258,6 +263,9 @@ namespace osu.Game.Screens.Edit.Timing
} }
isSwinging = false; isSwinging = false;
clunkDelegate?.Cancel();
clunkDelegate = null;
} }
} }
@ -283,7 +291,7 @@ namespace osu.Game.Screens.Edit.Timing
{ {
stick.FlashColour(overlayColourProvider.Content1, beatLength, Easing.OutQuint); stick.FlashColour(overlayColourProvider.Content1, beatLength, Easing.OutQuint);
Schedule(() => clunkDelegate = Schedule(() =>
{ {
if (!EnableClicking) if (!EnableClicking)
return; return;