1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-27 14:12:56 +08:00

Merge branch 'master' into carousel_nullability_disabling_removal

This commit is contained in:
Bartłomiej Dach 2023-01-10 18:39:42 +01:00 committed by GitHub
commit 1eaabb5ca8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
41 changed files with 564 additions and 260 deletions

View File

@ -16,7 +16,7 @@ namespace osu.Game.Rulesets.Taiko.Mods
public void ApplyToDrawableRuleset(DrawableRuleset<TaikoHitObject> drawableRuleset) public void ApplyToDrawableRuleset(DrawableRuleset<TaikoHitObject> drawableRuleset)
{ {
drawableTaikoRuleset = (DrawableTaikoRuleset)drawableRuleset; drawableTaikoRuleset = (DrawableTaikoRuleset)drawableRuleset;
drawableTaikoRuleset.LockPlayfieldAspect.Value = false; drawableTaikoRuleset.LockPlayfieldMaxAspect.Value = false;
var playfield = (TaikoPlayfield)drawableRuleset.Playfield; var playfield = (TaikoPlayfield)drawableRuleset.Playfield;
playfield.ClassicHitTargetPosition.Value = true; playfield.ClassicHitTargetPosition.Value = true;

View File

@ -31,7 +31,7 @@ namespace osu.Game.Rulesets.Taiko.UI
{ {
public new BindableDouble TimeRange => base.TimeRange; public new BindableDouble TimeRange => base.TimeRange;
public readonly BindableBool LockPlayfieldAspect = new BindableBool(true); public readonly BindableBool LockPlayfieldMaxAspect = new BindableBool(true);
protected override ScrollVisualisationMethod VisualisationMethod => ScrollVisualisationMethod.Overlapping; protected override ScrollVisualisationMethod VisualisationMethod => ScrollVisualisationMethod.Overlapping;
@ -78,7 +78,7 @@ namespace osu.Game.Rulesets.Taiko.UI
public override PlayfieldAdjustmentContainer CreatePlayfieldAdjustmentContainer() => new TaikoPlayfieldAdjustmentContainer public override PlayfieldAdjustmentContainer CreatePlayfieldAdjustmentContainer() => new TaikoPlayfieldAdjustmentContainer
{ {
LockPlayfieldAspect = { BindTarget = LockPlayfieldAspect } LockPlayfieldMaxAspect = { BindTarget = LockPlayfieldMaxAspect }
}; };
protected override PassThroughInputManager CreateInputManager() => new TaikoInputManager(Ruleset.RulesetInfo); protected override PassThroughInputManager CreateInputManager() => new TaikoInputManager(Ruleset.RulesetInfo);

View File

@ -13,7 +13,7 @@ namespace osu.Game.Rulesets.Taiko.UI
private const float default_relative_height = TaikoPlayfield.DEFAULT_HEIGHT / 768; private const float default_relative_height = TaikoPlayfield.DEFAULT_HEIGHT / 768;
private const float default_aspect = 16f / 9f; private const float default_aspect = 16f / 9f;
public readonly IBindable<bool> LockPlayfieldAspect = new BindableBool(true); public readonly IBindable<bool> LockPlayfieldMaxAspect = new BindableBool(true);
protected override void Update() protected override void Update()
{ {
@ -21,7 +21,12 @@ namespace osu.Game.Rulesets.Taiko.UI
float height = default_relative_height; float height = default_relative_height;
if (LockPlayfieldAspect.Value) // Players coming from stable expect to be able to change the aspect ratio regardless of the window size.
// We originally wanted to limit this more, but there was considerable pushback from the community.
//
// As a middle-ground, the aspect ratio can still be adjusted in the downwards direction but has a maximum limit.
// This is still a bit weird, because readability changes with window size, but it is what it is.
if (LockPlayfieldMaxAspect.Value && Parent.ChildSize.X / Parent.ChildSize.Y > default_aspect)
height *= Math.Clamp(Parent.ChildSize.X / Parent.ChildSize.Y, 0.4f, 4) / default_aspect; height *= Math.Clamp(Parent.ChildSize.X / Parent.ChildSize.Y, 0.4f, 4) / default_aspect;
Height = height; Height = height;

View File

@ -42,7 +42,9 @@ namespace osu.Game.Tests.Skins
// Covers longest combo counter // Covers longest combo counter
"Archives/modified-default-20221012.osk", "Archives/modified-default-20221012.osk",
// Covers TextElement and BeatmapInfoDrawable // Covers TextElement and BeatmapInfoDrawable
"Archives/modified-default-20221102.osk" "Archives/modified-default-20221102.osk",
// Covers BPM counter.
"Archives/modified-default-20221205.osk"
}; };
/// <summary> /// <summary>

View File

@ -27,6 +27,7 @@ using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Scoring; using osu.Game.Scoring;
using osu.Game.Screens.Menu; using osu.Game.Screens.Menu;
using osu.Game.Screens.OnlinePlay.Lounge; using osu.Game.Screens.OnlinePlay.Lounge;
using osu.Game.Screens.OnlinePlay.Match.Components;
using osu.Game.Screens.OnlinePlay.Playlists; using osu.Game.Screens.OnlinePlay.Playlists;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;
using osu.Game.Screens.Ranking; using osu.Game.Screens.Ranking;
@ -80,7 +81,25 @@ namespace osu.Game.Tests.Visual.Navigation
AddUntilStep("wait for return to playlist screen", () => playlistScreen.CurrentSubScreen is PlaylistsRoomSubScreen); AddUntilStep("wait for return to playlist screen", () => playlistScreen.CurrentSubScreen is PlaylistsRoomSubScreen);
AddStep("go back to song select", () =>
{
InputManager.MoveMouseTo(playlistScreen.ChildrenOfType<PurpleRoundedButton>().Single(b => b.Text == "Edit playlist"));
InputManager.Click(MouseButton.Left);
});
AddUntilStep("wait for song select", () => (playlistScreen.CurrentSubScreen as PlaylistsSongSelect)?.BeatmapSetsLoaded == true);
AddStep("press home button", () =>
{
InputManager.MoveMouseTo(Game.Toolbar.ChildrenOfType<ToolbarHomeButton>().Single());
InputManager.Click(MouseButton.Left);
});
AddAssert("confirmation dialog shown", () => Game.ChildrenOfType<DialogOverlay>().Single().CurrentDialog is not null);
pushEscape(); pushEscape();
pushEscape();
AddAssert("confirmation dialog shown", () => Game.ChildrenOfType<DialogOverlay>().Single().CurrentDialog is not null); AddAssert("confirmation dialog shown", () => Game.ChildrenOfType<DialogOverlay>().Single().CurrentDialog is not null);
AddStep("confirm exit", () => InputManager.Key(Key.Enter)); AddStep("confirm exit", () => InputManager.Key(Key.Enter));

View File

@ -44,6 +44,16 @@ namespace osu.Game.Beatmaps
public Action<(BeatmapSetInfo beatmapSet, bool isBatch)>? ProcessBeatmap { private get; set; } public Action<(BeatmapSetInfo beatmapSet, bool isBatch)>? ProcessBeatmap { private get; set; }
public override bool PauseImports
{
get => base.PauseImports;
set
{
base.PauseImports = value;
beatmapImporter.PauseImports = value;
}
}
public BeatmapManager(Storage storage, RealmAccess realm, IAPIProvider? api, AudioManager audioManager, IResourceStore<byte[]> gameResources, GameHost? host = null, public BeatmapManager(Storage storage, RealmAccess realm, IAPIProvider? api, AudioManager audioManager, IResourceStore<byte[]> gameResources, GameHost? host = null,
WorkingBeatmap? defaultBeatmap = null, BeatmapDifficultyCache? difficultyCache = null, bool performOnlineLookups = false) WorkingBeatmap? defaultBeatmap = null, BeatmapDifficultyCache? difficultyCache = null, bool performOnlineLookups = false)
: base(storage, realm) : base(storage, realm)
@ -458,7 +468,8 @@ namespace osu.Game.Beatmaps
public Task Import(ImportTask[] tasks, ImportParameters parameters = default) => beatmapImporter.Import(tasks, parameters); public Task Import(ImportTask[] tasks, ImportParameters parameters = default) => beatmapImporter.Import(tasks, parameters);
public Task<IEnumerable<Live<BeatmapSetInfo>>> Import(ProgressNotification notification, ImportTask[] tasks, ImportParameters parameters = default) => beatmapImporter.Import(notification, tasks, parameters); public Task<IEnumerable<Live<BeatmapSetInfo>>> Import(ProgressNotification notification, ImportTask[] tasks, ImportParameters parameters = default) =>
beatmapImporter.Import(notification, tasks, parameters);
public Task<Live<BeatmapSetInfo>?> Import(ImportTask task, ImportParameters parameters = default, CancellationToken cancellationToken = default) => public Task<Live<BeatmapSetInfo>?> Import(ImportTask task, ImportParameters parameters = default, CancellationToken cancellationToken = default) =>
beatmapImporter.Import(task, parameters, cancellationToken); beatmapImporter.Import(task, parameters, cancellationToken);

View File

@ -5,16 +5,19 @@ using System;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Online; using osu.Game.Online;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays; using osu.Game.Overlays;
using osu.Game.Localisation;
namespace osu.Game.Beatmaps.Drawables.Cards namespace osu.Game.Beatmaps.Drawables.Cards
{ {
public abstract partial class BeatmapCard : OsuClickableContainer public abstract partial class BeatmapCard : OsuClickableContainer, IHasContextMenu
{ {
public const float TRANSITION_DURATION = 400; public const float TRANSITION_DURATION = 400;
public const float CORNER_RADIUS = 10; public const float CORNER_RADIUS = 10;
@ -96,5 +99,10 @@ namespace osu.Game.Beatmaps.Drawables.Cards
throw new ArgumentOutOfRangeException(nameof(size), size, @"Unsupported card size"); throw new ArgumentOutOfRangeException(nameof(size), size, @"Unsupported card size");
} }
} }
public MenuItem[] ContextMenuItems => new MenuItem[]
{
new OsuMenuItem(ContextMenuStrings.ViewBeatmap, MenuItemType.Highlighted, Action),
};
} }
} }

View File

@ -33,13 +33,15 @@ namespace osu.Game.Database
UserFileStorage = storage.GetStorageForDirectory(@"files"); UserFileStorage = storage.GetStorageForDirectory(@"files");
} }
protected virtual string GetFilename(TModel item) => item.GetDisplayString();
/// <summary> /// <summary>
/// Exports an item to a legacy (.zip based) package. /// Exports an item to a legacy (.zip based) package.
/// </summary> /// </summary>
/// <param name="item">The item to export.</param> /// <param name="item">The item to export.</param>
public void Export(TModel item) public void Export(TModel item)
{ {
string itemFilename = item.GetDisplayString().GetValidFilename(); string itemFilename = GetFilename(item).GetValidFilename();
IEnumerable<string> existingExports = exportStorage.GetFiles("", $"{itemFilename}*{FileExtension}"); IEnumerable<string> existingExports = exportStorage.GetFiles("", $"{itemFilename}*{FileExtension}");

View File

@ -54,14 +54,14 @@ namespace osu.Game.Database
public void UpdateStorage(string stablePath) => cachedStorage = new StableStorage(stablePath, gameHost as DesktopGameHost); public void UpdateStorage(string stablePath) => cachedStorage = new StableStorage(stablePath, gameHost as DesktopGameHost);
public bool CheckHardLinkAvailability() public bool CheckSongsFolderHardLinkAvailability()
{ {
var stableStorage = GetCurrentStableStorage(); var stableStorage = GetCurrentStableStorage();
if (stableStorage == null || gameHost is not DesktopGameHost desktopGameHost) if (stableStorage == null || gameHost is not DesktopGameHost desktopGameHost)
return false; return false;
string testExistingPath = stableStorage.GetFullPath(string.Empty); string testExistingPath = stableStorage.GetSongStorage().GetFullPath(string.Empty);
string testDestinationPath = desktopGameHost.Storage.GetFullPath(string.Empty); string testDestinationPath = desktopGameHost.Storage.GetFullPath(string.Empty);
return HardLinkHelper.CheckAvailability(testDestinationPath, testExistingPath); return HardLinkHelper.CheckAvailability(testDestinationPath, testExistingPath);

View File

@ -20,6 +20,14 @@ namespace osu.Game.Database
{ {
} }
protected override string GetFilename(ScoreInfo score)
{
string scoreString = score.GetDisplayString();
string filename = $"{scoreString} ({score.Date.LocalDateTime:yyyy-MM-dd_HH-mm})";
return filename;
}
public override void ExportModelTo(ScoreInfo model, Stream outputStream) public override void ExportModelTo(ScoreInfo model, Stream outputStream)
{ {
var file = model.Files.SingleOrDefault(); var file = model.Files.SingleOrDefault();

View File

@ -18,6 +18,11 @@ namespace osu.Game.Database
public class ModelManager<TModel> : IModelManager<TModel>, IModelFileManager<TModel, RealmNamedFileUsage> public class ModelManager<TModel> : IModelManager<TModel>, IModelFileManager<TModel, RealmNamedFileUsage>
where TModel : RealmObject, IHasRealmFiles, IHasGuidPrimaryKey, ISoftDelete where TModel : RealmObject, IHasRealmFiles, IHasGuidPrimaryKey, ISoftDelete
{ {
/// <summary>
/// Temporarily pause imports to avoid performance overheads affecting gameplay scenarios.
/// </summary>
public virtual bool PauseImports { get; set; }
protected RealmAccess Realm { get; } protected RealmAccess Realm { get; }
private readonly RealmFileStore realmFileStore; private readonly RealmFileStore realmFileStore;

View File

@ -56,6 +56,11 @@ namespace osu.Game.Database
/// </summary> /// </summary>
private static readonly ThreadedTaskScheduler import_scheduler_batch = new ThreadedTaskScheduler(import_queue_request_concurrency, nameof(RealmArchiveModelImporter<TModel>)); private static readonly ThreadedTaskScheduler import_scheduler_batch = new ThreadedTaskScheduler(import_queue_request_concurrency, nameof(RealmArchiveModelImporter<TModel>));
/// <summary>
/// Temporarily pause imports to avoid performance overheads affecting gameplay scenarios.
/// </summary>
public bool PauseImports { get; set; }
public abstract IEnumerable<string> HandledExtensions { get; } public abstract IEnumerable<string> HandledExtensions { get; }
protected readonly RealmFileStore Files; protected readonly RealmFileStore Files;
@ -149,9 +154,12 @@ namespace osu.Game.Database
} }
else else
{ {
notification.CompletionText = imported.Count == 1 if (tasks.Length > imported.Count)
? $"Imported {imported.First().GetDisplayString()}!" notification.CompletionText = $"Imported {imported.Count} of {tasks.Length} {HumanisedModelName}s.";
: $"Imported {imported.Count} {HumanisedModelName}s!"; else if (imported.Count > 1)
notification.CompletionText = $"Imported {imported.Count} {HumanisedModelName}s!";
else
notification.CompletionText = $"Imported {imported.First().GetDisplayString()}!";
if (imported.Count > 0 && PresentImport != null) if (imported.Count > 0 && PresentImport != null)
{ {
@ -253,7 +261,7 @@ namespace osu.Game.Database
/// <param name="cancellationToken">An optional cancellation token.</param> /// <param name="cancellationToken">An optional cancellation token.</param>
public virtual Live<TModel>? ImportModel(TModel item, ArchiveReader? archive = null, ImportParameters parameters = default, CancellationToken cancellationToken = default) => Realm.Run(realm => public virtual Live<TModel>? ImportModel(TModel item, ArchiveReader? archive = null, ImportParameters parameters = default, CancellationToken cancellationToken = default) => Realm.Run(realm =>
{ {
cancellationToken.ThrowIfCancellationRequested(); pauseIfNecessary(cancellationToken);
TModel? existing; TModel? existing;
@ -551,6 +559,23 @@ namespace osu.Game.Database
/// <returns>Whether to perform deletion.</returns> /// <returns>Whether to perform deletion.</returns>
protected virtual bool ShouldDeleteArchive(string path) => false; protected virtual bool ShouldDeleteArchive(string path) => false;
private void pauseIfNecessary(CancellationToken cancellationToken)
{
if (!PauseImports)
return;
Logger.Log($@"{GetType().Name} is being paused.");
while (PauseImports)
{
cancellationToken.ThrowIfCancellationRequested();
Thread.Sleep(500);
}
cancellationToken.ThrowIfCancellationRequested();
Logger.Log($@"{GetType().Name} is being resumed.");
}
private IEnumerable<string> getIDs(IEnumerable<INamedFile> files) private IEnumerable<string> getIDs(IEnumerable<INamedFile> files)
{ {
foreach (var f in files.OrderBy(f => f.Filename)) foreach (var f in files.OrderBy(f => f.Filename))

View File

@ -4,6 +4,7 @@
#nullable disable #nullable disable
using System; using System;
using System.IO;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using osu.Framework.Allocation; using osu.Framework.Allocation;
@ -117,11 +118,11 @@ namespace osu.Game.Graphics
host.GetClipboard()?.SetImage(image); host.GetClipboard()?.SetImage(image);
string filename = getFilename(); (string filename, var stream) = getWritableStream();
if (filename == null) return; if (filename == null) return;
using (var stream = storage.CreateFileSafely(filename)) using (stream)
{ {
switch (screenshotFormat.Value) switch (screenshotFormat.Value)
{ {
@ -142,7 +143,7 @@ namespace osu.Game.Graphics
notificationOverlay.Post(new SimpleNotification notificationOverlay.Post(new SimpleNotification
{ {
Text = $"{filename} saved!", Text = $"Screenshot {filename} saved!",
Activated = () => Activated = () =>
{ {
storage.PresentFileExternally(filename); storage.PresentFileExternally(filename);
@ -152,23 +153,28 @@ namespace osu.Game.Graphics
} }
}); });
private string getFilename() private static readonly object filename_reservation_lock = new object();
private (string filename, Stream stream) getWritableStream()
{ {
var dt = DateTime.Now; lock (filename_reservation_lock)
string fileExt = screenshotFormat.ToString().ToLowerInvariant();
string withoutIndex = $"osu_{dt:yyyy-MM-dd_HH-mm-ss}.{fileExt}";
if (!storage.Exists(withoutIndex))
return withoutIndex;
for (ulong i = 1; i < ulong.MaxValue; i++)
{ {
string indexedName = $"osu_{dt:yyyy-MM-dd_HH-mm-ss}-{i}.{fileExt}"; var dt = DateTime.Now;
if (!storage.Exists(indexedName)) string fileExt = screenshotFormat.ToString().ToLowerInvariant();
return indexedName;
}
return null; string withoutIndex = $"osu_{dt:yyyy-MM-dd_HH-mm-ss}.{fileExt}";
if (!storage.Exists(withoutIndex))
return (withoutIndex, storage.GetStream(withoutIndex, FileAccess.Write, FileMode.Create));
for (ulong i = 1; i < ulong.MaxValue; i++)
{
string indexedName = $"osu_{dt:yyyy-MM-dd_HH-mm-ss}-{i}.{fileExt}";
if (!storage.Exists(indexedName))
return (indexedName, storage.GetStream(indexedName, FileAccess.Write, FileMode.Create));
}
return (null, null);
}
} }
} }
} }

View File

@ -0,0 +1,24 @@
// 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 osu.Framework.Localisation;
namespace osu.Game.Localisation
{
public static class ContextMenuStrings
{
private const string prefix = @"osu.Game.Resources.Localisation.ContextMenu";
/// <summary>
/// "View profile"
/// </summary>
public static LocalisableString ViewProfile => new TranslatableString(getKey(@"view_profile"), @"View profile");
/// <summary>
/// "View beatmap"
/// </summary>
public static LocalisableString ViewBeatmap => new TranslatableString(getKey(@"view_beatmap"), @"View beatmap");
private static string getKey(string key) => $@"{prefix}:{key}";
}
}

View File

@ -54,11 +54,6 @@ namespace osu.Game.Localisation
/// </summary> /// </summary>
public static LocalisableString RestartAndReOpenRequiredForCompletion => new TranslatableString(getKey(@"restart_and_re_open_required_for_completion"), @"To complete this operation, osu! will close. Please open it again to use the new data location."); public static LocalisableString RestartAndReOpenRequiredForCompletion => new TranslatableString(getKey(@"restart_and_re_open_required_for_completion"), @"To complete this operation, osu! will close. Please open it again to use the new data location.");
/// <summary>
/// "Import beatmaps from stable"
/// </summary>
public static LocalisableString ImportBeatmapsFromStable => new TranslatableString(getKey(@"import_beatmaps_from_stable"), @"Import beatmaps from stable");
/// <summary> /// <summary>
/// "Delete ALL beatmaps" /// "Delete ALL beatmaps"
/// </summary> /// </summary>
@ -69,31 +64,16 @@ namespace osu.Game.Localisation
/// </summary> /// </summary>
public static LocalisableString DeleteAllBeatmapVideos => new TranslatableString(getKey(@"delete_all_beatmap_videos"), @"Delete ALL beatmap videos"); public static LocalisableString DeleteAllBeatmapVideos => new TranslatableString(getKey(@"delete_all_beatmap_videos"), @"Delete ALL beatmap videos");
/// <summary>
/// "Import scores from stable"
/// </summary>
public static LocalisableString ImportScoresFromStable => new TranslatableString(getKey(@"import_scores_from_stable"), @"Import scores from stable");
/// <summary> /// <summary>
/// "Delete ALL scores" /// "Delete ALL scores"
/// </summary> /// </summary>
public static LocalisableString DeleteAllScores => new TranslatableString(getKey(@"delete_all_scores"), @"Delete ALL scores"); public static LocalisableString DeleteAllScores => new TranslatableString(getKey(@"delete_all_scores"), @"Delete ALL scores");
/// <summary>
/// "Import skins from stable"
/// </summary>
public static LocalisableString ImportSkinsFromStable => new TranslatableString(getKey(@"import_skins_from_stable"), @"Import skins from stable");
/// <summary> /// <summary>
/// "Delete ALL skins" /// "Delete ALL skins"
/// </summary> /// </summary>
public static LocalisableString DeleteAllSkins => new TranslatableString(getKey(@"delete_all_skins"), @"Delete ALL skins"); public static LocalisableString DeleteAllSkins => new TranslatableString(getKey(@"delete_all_skins"), @"Delete ALL skins");
/// <summary>
/// "Import collections from stable"
/// </summary>
public static LocalisableString ImportCollectionsFromStable => new TranslatableString(getKey(@"import_collections_from_stable"), @"Import collections from stable");
/// <summary> /// <summary>
/// "Delete ALL collections" /// "Delete ALL collections"
/// </summary> /// </summary>

View File

@ -71,7 +71,6 @@ namespace osu.Game.Online.Chat
private UserLookupCache users { get; set; } private UserLookupCache users { get; set; }
private readonly IBindable<APIState> apiState = new Bindable<APIState>(); private readonly IBindable<APIState> apiState = new Bindable<APIState>();
private bool channelsInitialised;
private ScheduledDelegate scheduledAck; private ScheduledDelegate scheduledAck;
private long? lastSilenceMessageId; private long? lastSilenceMessageId;
@ -95,15 +94,7 @@ namespace osu.Game.Online.Chat
connector.NewMessages += msgs => Schedule(() => addMessages(msgs)); connector.NewMessages += msgs => Schedule(() => addMessages(msgs));
connector.PresenceReceived += () => Schedule(() => connector.PresenceReceived += () => Schedule(initializeChannels);
{
if (!channelsInitialised)
{
channelsInitialised = true;
// we want this to run after the first presence so we can see if the user is in any channels already.
initializeChannels();
}
});
connector.Start(); connector.Start();
@ -335,6 +326,11 @@ namespace osu.Game.Online.Chat
private void initializeChannels() private void initializeChannels()
{ {
// This request is self-retrying until it succeeds.
// To avoid requests piling up when not logged in (ie. API is unavailable) exit early.
if (!api.IsLoggedIn)
return;
var req = new ListChannelsRequest(); var req = new ListChannelsRequest();
bool joinDefaults = JoinedChannels.Count == 0; bool joinDefaults = JoinedChannels.Count == 0;
@ -350,10 +346,11 @@ namespace osu.Game.Online.Chat
joinChannel(ch); joinChannel(ch);
} }
}; };
req.Failure += error => req.Failure += error =>
{ {
Logger.Error(error, "Fetching channel list failed"); Logger.Error(error, "Fetching channel list failed");
initializeChannels(); Scheduler.AddDelayed(initializeChannels, 60000);
}; };
api.Queue(req); api.Queue(req);

View File

@ -307,6 +307,13 @@ namespace osu.Game
// Transfer any runtime changes back to configuration file. // Transfer any runtime changes back to configuration file.
SkinManager.CurrentSkinInfo.ValueChanged += skin => configSkin.Value = skin.NewValue.ID.ToString(); SkinManager.CurrentSkinInfo.ValueChanged += skin => configSkin.Value = skin.NewValue.ID.ToString();
LocalUserPlaying.BindValueChanged(p =>
{
BeatmapManager.PauseImports = p.NewValue;
SkinManager.PauseImports = p.NewValue;
ScoreManager.PauseImports = p.NewValue;
}, true);
IsActive.BindValueChanged(active => updateActiveState(active.NewValue), true); IsActive.BindValueChanged(active => updateActiveState(active.NewValue), true);
Audio.AddAdjustment(AdjustableProperty.Volume, inactiveVolumeFade); Audio.AddAdjustment(AdjustableProperty.Volume, inactiveVolumeFade);

View File

@ -10,7 +10,6 @@ using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Colour;
using osu.Game.Graphics.Cursor;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
@ -91,79 +90,74 @@ namespace osu.Game.Overlays.BeatmapSet
}, },
}, },
}, },
new OsuContextMenuContainer new Container
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Child = new Container Padding = new MarginPadding
{ {
RelativeSizeAxes = Axes.X, Vertical = BeatmapSetOverlay.Y_PADDING,
AutoSizeAxes = Axes.Y, Left = BeatmapSetOverlay.X_PADDING,
Padding = new MarginPadding Right = BeatmapSetOverlay.X_PADDING + BeatmapSetOverlay.RIGHT_WIDTH,
},
Children = new Drawable[]
{
fadeContent = new FillFlowContainer
{ {
Vertical = BeatmapSetOverlay.Y_PADDING, RelativeSizeAxes = Axes.X,
Left = BeatmapSetOverlay.X_PADDING, AutoSizeAxes = Axes.Y,
Right = BeatmapSetOverlay.X_PADDING + BeatmapSetOverlay.RIGHT_WIDTH, Direction = FillDirection.Vertical,
}, Children = new Drawable[]
Children = new Drawable[]
{
fadeContent = new FillFlowContainer
{ {
RelativeSizeAxes = Axes.X, new Container
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Children = new Drawable[]
{ {
new Container RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Child = Picker = new BeatmapPicker(),
},
title = new MetadataFlowContainer(s =>
{
s.Font = OsuFont.GetFont(size: 30, weight: FontWeight.SemiBold, italics: true);
})
{
Margin = new MarginPadding { Top = 15 },
},
artist = new MetadataFlowContainer(s =>
{
s.Font = OsuFont.GetFont(size: 20, weight: FontWeight.Medium, italics: true);
})
{
Margin = new MarginPadding { Bottom = 20 },
},
new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Child = author = new AuthorInfo(),
},
beatmapAvailability = new BeatmapAvailability(),
new Container
{
RelativeSizeAxes = Axes.X,
Height = buttons_height,
Margin = new MarginPadding { Top = 10 },
Children = new Drawable[]
{ {
RelativeSizeAxes = Axes.X, favouriteButton = new FavouriteButton
AutoSizeAxes = Axes.Y,
Child = Picker = new BeatmapPicker(),
},
title = new MetadataFlowContainer(s =>
{
s.Font = OsuFont.GetFont(size: 30, weight: FontWeight.SemiBold, italics: true);
})
{
Margin = new MarginPadding { Top = 15 },
},
artist = new MetadataFlowContainer(s =>
{
s.Font = OsuFont.GetFont(size: 20, weight: FontWeight.Medium, italics: true);
})
{
Margin = new MarginPadding { Bottom = 20 },
},
new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Child = author = new AuthorInfo(),
},
beatmapAvailability = new BeatmapAvailability(),
new Container
{
RelativeSizeAxes = Axes.X,
Height = buttons_height,
Margin = new MarginPadding { Top = 10 },
Children = new Drawable[]
{ {
favouriteButton = new FavouriteButton BeatmapSet = { BindTarget = BeatmapSet }
{
BeatmapSet = { BindTarget = BeatmapSet }
},
downloadButtonsContainer = new FillFlowContainer
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Left = buttons_height + buttons_spacing },
Spacing = new Vector2(buttons_spacing),
},
}, },
}, downloadButtonsContainer = new FillFlowContainer
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Left = buttons_height + buttons_spacing },
Spacing = new Vector2(buttons_spacing),
},
}
}, },
}, },
} },
}, }
}, },
loading = new LoadingSpinner loading = new LoadingSpinner
{ {

View File

@ -17,9 +17,11 @@ using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Localisation;
using osu.Game.Online.API; using osu.Game.Online.API;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Chat; using osu.Game.Online.Chat;
using osu.Game.Resources.Localisation.Web;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
@ -148,11 +150,11 @@ namespace osu.Game.Overlays.Chat
List<MenuItem> items = new List<MenuItem> List<MenuItem> items = new List<MenuItem>
{ {
new OsuMenuItem("View Profile", MenuItemType.Highlighted, openUserProfile) new OsuMenuItem(ContextMenuStrings.ViewProfile, MenuItemType.Highlighted, openUserProfile)
}; };
if (!user.Equals(api.LocalUser.Value)) if (!user.Equals(api.LocalUser.Value))
items.Add(new OsuMenuItem("Start Chat", MenuItemType.Standard, openUserChannel)); items.Add(new OsuMenuItem(UsersStrings.CardSendMessage, MenuItemType.Standard, openUserChannel));
return items.ToArray(); return items.ToArray();
} }

View File

@ -38,7 +38,7 @@ namespace osu.Game.Overlays.Chat.Listing
private Box hoverBox = null!; private Box hoverBox = null!;
private SpriteIcon checkbox = null!; private SpriteIcon checkbox = null!;
private OsuSpriteText channelText = null!; private OsuSpriteText channelText = null!;
private OsuSpriteText topicText = null!; private OsuTextFlowContainer topicText = null!;
private IBindable<bool> channelJoined = null!; private IBindable<bool> channelJoined = null!;
[Resolved] [Resolved]
@ -65,8 +65,8 @@ namespace osu.Game.Overlays.Chat.Listing
Masking = true; Masking = true;
CornerRadius = 5; CornerRadius = 5;
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Content.RelativeSizeAxes = Axes.X;
Height = 20 + (vertical_margin * 2); AutoSizeAxes = Content.AutoSizeAxes = Axes.Y;
Children = new Drawable[] Children = new Drawable[]
{ {
@ -79,14 +79,19 @@ namespace osu.Game.Overlays.Chat.Listing
}, },
new GridContainer new GridContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
ColumnDimensions = new[] ColumnDimensions = new[]
{ {
new Dimension(GridSizeMode.Absolute, 40), new Dimension(GridSizeMode.Absolute, 40),
new Dimension(GridSizeMode.Absolute, 200), new Dimension(GridSizeMode.Absolute, 200),
new Dimension(GridSizeMode.Absolute, 400), new Dimension(maxSize: 400),
new Dimension(GridSizeMode.AutoSize), new Dimension(GridSizeMode.AutoSize),
new Dimension(), new Dimension(GridSizeMode.Absolute, 50), // enough for any 5 digit user count
},
RowDimensions = new[]
{
new Dimension(GridSizeMode.AutoSize, minSize: 20 + (vertical_margin * 2)),
}, },
Content = new[] Content = new[]
{ {
@ -108,12 +113,13 @@ namespace osu.Game.Overlays.Chat.Listing
Font = OsuFont.Torus.With(size: text_size, weight: FontWeight.SemiBold), Font = OsuFont.Torus.With(size: text_size, weight: FontWeight.SemiBold),
Margin = new MarginPadding { Bottom = 2 }, Margin = new MarginPadding { Bottom = 2 },
}, },
topicText = new OsuSpriteText topicText = new OsuTextFlowContainer(t => t.Font = OsuFont.Torus.With(size: text_size))
{ {
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
Text = Channel.Topic, Text = Channel.Topic,
Font = OsuFont.Torus.With(size: text_size),
Margin = new MarginPadding { Bottom = 2 }, Margin = new MarginPadding { Bottom = 2 },
}, },
new SpriteIcon new SpriteIcon

View File

@ -122,8 +122,8 @@ namespace osu.Game.Overlays.FirstRunSetup
stableLocatorTextBox.Current.Value = storage.GetFullPath(string.Empty); stableLocatorTextBox.Current.Value = storage.GetFullPath(string.Empty);
importButton.Enabled.Value = true; importButton.Enabled.Value = true;
bool available = legacyImportManager.CheckHardLinkAvailability(); bool available = legacyImportManager.CheckSongsFolderHardLinkAvailability();
Logger.Log($"Hard link support is {available}"); Logger.Log($"Hard link support for beatmaps is {available}");
if (available) if (available)
{ {

View File

@ -7,6 +7,7 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Cursor;
using osu.Game.Graphics.Cursor;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Online; using osu.Game.Online;
@ -38,20 +39,30 @@ namespace osu.Game.Overlays
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
ScrollbarVisible = false, ScrollbarVisible = false,
Child = new FillFlowContainer Child = new OsuContextMenuContainer
{ {
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Direction = FillDirection.Vertical, AutoSizeAxes = Axes.Y,
Children = new Drawable[] Child = new PopoverContainer
{ {
Header.With(h => h.Depth = float.MinValue), RelativeSizeAxes = Axes.X,
content = new PopoverContainer AutoSizeAxes = Axes.Y,
Child = new FillFlowContainer
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
Header.With(h => h.Depth = float.MinValue),
content = new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y
}
}
} }
} },
} }
}, },
Loading = new LoadingLayer(true) Loading = new LoadingLayer(true)

View File

@ -3,6 +3,7 @@
#nullable disable #nullable disable
using osu.Framework.Development;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation; using osu.Framework.Localisation;
@ -22,11 +23,12 @@ namespace osu.Game.Overlays.Settings.Sections
public DebugSection() public DebugSection()
{ {
Children = new Drawable[] Add(new GeneralSettings());
{
new GeneralSettings(), if (DebugUtils.IsDebugBuild)
new MemorySettings(), Add(new BatchImportSettings());
};
Add(new MemorySettings());
} }
} }
} }

View File

@ -0,0 +1,66 @@
// 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 osu.Framework.Allocation;
using osu.Framework.Localisation;
using osu.Game.Database;
namespace osu.Game.Overlays.Settings.Sections.DebugSettings
{
public partial class BatchImportSettings : SettingsSubsection
{
protected override LocalisableString Header => @"Batch Import";
private SettingsButton importBeatmapsButton = null!;
private SettingsButton importCollectionsButton = null!;
private SettingsButton importScoresButton = null!;
private SettingsButton importSkinsButton = null!;
[BackgroundDependencyLoader]
private void load(LegacyImportManager? legacyImportManager)
{
if (legacyImportManager?.SupportsImportFromStable != true)
return;
AddRange(new[]
{
importBeatmapsButton = new SettingsButton
{
Text = @"Import beatmaps from stable",
Action = () =>
{
importBeatmapsButton.Enabled.Value = false;
legacyImportManager.ImportFromStableAsync(StableContent.Beatmaps).ContinueWith(_ => Schedule(() => importBeatmapsButton.Enabled.Value = true));
}
},
importSkinsButton = new SettingsButton
{
Text = @"Import skins from stable",
Action = () =>
{
importSkinsButton.Enabled.Value = false;
legacyImportManager.ImportFromStableAsync(StableContent.Skins).ContinueWith(_ => Schedule(() => importSkinsButton.Enabled.Value = true));
}
},
importCollectionsButton = new SettingsButton
{
Text = @"Import collections from stable",
Action = () =>
{
importCollectionsButton.Enabled.Value = false;
legacyImportManager.ImportFromStableAsync(StableContent.Collections).ContinueWith(_ => Schedule(() => importCollectionsButton.Enabled.Value = true));
}
},
importScoresButton = new SettingsButton
{
Text = @"Import scores from stable",
Action = () =>
{
importScoresButton.Enabled.Value = false;
legacyImportManager.ImportFromStableAsync(StableContent.Scores).ContinueWith(_ => Schedule(() => importScoresButton.Enabled.Value = true));
}
},
});
}
}
}

View File

@ -6,7 +6,6 @@ using osu.Framework.Allocation;
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.Database;
using osu.Game.Localisation; using osu.Game.Localisation;
namespace osu.Game.Overlays.Settings.Sections.Maintenance namespace osu.Game.Overlays.Settings.Sections.Maintenance
@ -15,28 +14,14 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
{ {
protected override LocalisableString Header => CommonStrings.Beatmaps; protected override LocalisableString Header => CommonStrings.Beatmaps;
private SettingsButton importBeatmapsButton = null!;
private SettingsButton deleteBeatmapsButton = null!; private SettingsButton deleteBeatmapsButton = null!;
private SettingsButton deleteBeatmapVideosButton = null!; private SettingsButton deleteBeatmapVideosButton = null!;
private SettingsButton restoreButton = null!; private SettingsButton restoreButton = null!;
private SettingsButton undeleteButton = null!; private SettingsButton undeleteButton = null!;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(BeatmapManager beatmaps, LegacyImportManager? legacyImportManager, IDialogOverlay? dialogOverlay) private void load(BeatmapManager beatmaps, IDialogOverlay? dialogOverlay)
{ {
if (legacyImportManager?.SupportsImportFromStable == true)
{
Add(importBeatmapsButton = new SettingsButton
{
Text = MaintenanceSettingsStrings.ImportBeatmapsFromStable,
Action = () =>
{
importBeatmapsButton.Enabled.Value = false;
legacyImportManager.ImportFromStableAsync(StableContent.Beatmaps).ContinueWith(_ => Schedule(() => importBeatmapsButton.Enabled.Value = true));
}
});
}
Add(deleteBeatmapsButton = new DangerousSettingsButton Add(deleteBeatmapsButton = new DangerousSettingsButton
{ {
Text = MaintenanceSettingsStrings.DeleteAllBeatmaps, Text = MaintenanceSettingsStrings.DeleteAllBeatmaps,

View File

@ -14,8 +14,6 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
{ {
protected override LocalisableString Header => CommonStrings.Collections; protected override LocalisableString Header => CommonStrings.Collections;
private SettingsButton importCollectionsButton = null!;
[Resolved] [Resolved]
private RealmAccess realm { get; set; } = null!; private RealmAccess realm { get; set; } = null!;
@ -23,21 +21,8 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
private INotificationOverlay? notificationOverlay { get; set; } private INotificationOverlay? notificationOverlay { get; set; }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(LegacyImportManager? legacyImportManager, IDialogOverlay? dialogOverlay) private void load(IDialogOverlay? dialogOverlay)
{ {
if (legacyImportManager?.SupportsImportFromStable == true)
{
Add(importCollectionsButton = new SettingsButton
{
Text = MaintenanceSettingsStrings.ImportCollectionsFromStable,
Action = () =>
{
importCollectionsButton.Enabled.Value = false;
legacyImportManager.ImportFromStableAsync(StableContent.Collections).ContinueWith(_ => Schedule(() => importCollectionsButton.Enabled.Value = true));
}
});
}
Add(new DangerousSettingsButton Add(new DangerousSettingsButton
{ {
Text = MaintenanceSettingsStrings.DeleteAllCollections, Text = MaintenanceSettingsStrings.DeleteAllCollections,

View File

@ -4,7 +4,6 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Game.Database;
using osu.Game.Localisation; using osu.Game.Localisation;
using osu.Game.Scoring; using osu.Game.Scoring;
@ -14,25 +13,11 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
{ {
protected override LocalisableString Header => CommonStrings.Scores; protected override LocalisableString Header => CommonStrings.Scores;
private SettingsButton importScoresButton = null!;
private SettingsButton deleteScoresButton = null!; private SettingsButton deleteScoresButton = null!;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(ScoreManager scores, LegacyImportManager? legacyImportManager, IDialogOverlay? dialogOverlay) private void load(ScoreManager scores, IDialogOverlay? dialogOverlay)
{ {
if (legacyImportManager?.SupportsImportFromStable == true)
{
Add(importScoresButton = new SettingsButton
{
Text = MaintenanceSettingsStrings.ImportScoresFromStable,
Action = () =>
{
importScoresButton.Enabled.Value = false;
legacyImportManager.ImportFromStableAsync(StableContent.Scores).ContinueWith(_ => Schedule(() => importScoresButton.Enabled.Value = true));
}
});
}
Add(deleteScoresButton = new DangerousSettingsButton Add(deleteScoresButton = new DangerousSettingsButton
{ {
Text = MaintenanceSettingsStrings.DeleteAllScores, Text = MaintenanceSettingsStrings.DeleteAllScores,

View File

@ -4,7 +4,6 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Game.Database;
using osu.Game.Localisation; using osu.Game.Localisation;
using osu.Game.Skinning; using osu.Game.Skinning;
@ -14,25 +13,11 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
{ {
protected override LocalisableString Header => CommonStrings.Skins; protected override LocalisableString Header => CommonStrings.Skins;
private SettingsButton importSkinsButton = null!;
private SettingsButton deleteSkinsButton = null!; private SettingsButton deleteSkinsButton = null!;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(SkinManager skins, LegacyImportManager? legacyImportManager, IDialogOverlay? dialogOverlay) private void load(SkinManager skins, IDialogOverlay? dialogOverlay)
{ {
if (legacyImportManager?.SupportsImportFromStable == true)
{
Add(importSkinsButton = new SettingsButton
{
Text = MaintenanceSettingsStrings.ImportSkinsFromStable,
Action = () =>
{
importSkinsButton.Enabled.Value = false;
legacyImportManager.ImportFromStableAsync(StableContent.Skins).ContinueWith(_ => Schedule(() => importSkinsButton.Enabled.Value = true));
}
});
}
Add(deleteSkinsButton = new DangerousSettingsButton Add(deleteSkinsButton = new DangerousSettingsButton
{ {
Text = MaintenanceSettingsStrings.DeleteAllSkins, Text = MaintenanceSettingsStrings.DeleteAllSkins,

View File

@ -46,10 +46,12 @@ namespace osu.Game.Scoring.Legacy
score.ScoreInfo = scoreInfo; score.ScoreInfo = scoreInfo;
int version = sr.ReadInt32(); int version = sr.ReadInt32();
string beatmapHash = sr.ReadString();
workingBeatmap = GetBeatmap(beatmapHash);
workingBeatmap = GetBeatmap(sr.ReadString());
if (workingBeatmap is DummyWorkingBeatmap) if (workingBeatmap is DummyWorkingBeatmap)
throw new BeatmapNotFoundException(); throw new BeatmapNotFoundException(beatmapHash);
scoreInfo.User = new APIUser { Username = sr.ReadString() }; scoreInfo.User = new APIUser { Username = sr.ReadString() };
@ -334,9 +336,11 @@ namespace osu.Game.Scoring.Legacy
public class BeatmapNotFoundException : Exception public class BeatmapNotFoundException : Exception
{ {
public BeatmapNotFoundException() public string Hash { get; }
: base("No corresponding beatmap for the score could be found.")
public BeatmapNotFoundException(string hash)
{ {
Hash = hash;
} }
} }
} }

View File

@ -44,7 +44,9 @@ namespace osu.Game.Scoring
protected override ScoreInfo? CreateModel(ArchiveReader archive) protected override ScoreInfo? CreateModel(ArchiveReader archive)
{ {
using (var stream = archive.GetStream(archive.Filenames.First(f => f.EndsWith(".osr", StringComparison.OrdinalIgnoreCase)))) string name = archive.Filenames.First(f => f.EndsWith(".osr", StringComparison.OrdinalIgnoreCase));
using (var stream = archive.GetStream(name))
{ {
try try
{ {
@ -52,7 +54,7 @@ namespace osu.Game.Scoring
} }
catch (LegacyScoreDecoder.BeatmapNotFoundException e) catch (LegacyScoreDecoder.BeatmapNotFoundException e)
{ {
Logger.Log(e.Message, LoggingTarget.Information, LogLevel.Error); Logger.Log($@"Score '{name}' failed to import: no corresponding beatmap with the hash '{e.Hash}' could be found.", LoggingTarget.Database);
return null; return null;
} }
} }

View File

@ -28,6 +28,16 @@ namespace osu.Game.Scoring
private readonly OsuConfigManager configManager; private readonly OsuConfigManager configManager;
private readonly ScoreImporter scoreImporter; private readonly ScoreImporter scoreImporter;
public override bool PauseImports
{
get => base.PauseImports;
set
{
base.PauseImports = value;
scoreImporter.PauseImports = value;
}
}
public ScoreManager(RulesetStore rulesets, Func<BeatmapManager> beatmaps, Storage storage, RealmAccess realm, IAPIProvider api, public ScoreManager(RulesetStore rulesets, Func<BeatmapManager> beatmaps, Storage storage, RealmAccess realm, IAPIProvider api,
OsuConfigManager configManager = null) OsuConfigManager configManager = null)
: base(storage, realm) : base(storage, realm)

View File

@ -99,6 +99,18 @@ namespace osu.Game.Screens.Backgrounds
} }
} }
/// <summary>
/// Reloads beatmap's background.
/// </summary>
public void RefreshBackground()
{
Schedule(() =>
{
cancellationSource?.Cancel();
LoadComponentAsync(new BeatmapBackground(beatmap), switchBackground, (cancellationSource = new CancellationTokenSource()).Token);
});
}
private void switchBackground(BeatmapBackground b) private void switchBackground(BeatmapBackground b)
{ {
float newDepth = 0; float newDepth = 0;

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System.IO; using System.IO;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
@ -16,25 +14,28 @@ namespace osu.Game.Screens.Edit.Setup
{ {
internal partial class ResourcesSection : SetupSection internal partial class ResourcesSection : SetupSection
{ {
private LabelledFileChooser audioTrackChooser; private LabelledFileChooser audioTrackChooser = null!;
private LabelledFileChooser backgroundChooser; private LabelledFileChooser backgroundChooser = null!;
public override LocalisableString Title => EditorSetupStrings.ResourcesHeader; public override LocalisableString Title => EditorSetupStrings.ResourcesHeader;
[Resolved] [Resolved]
private MusicController music { get; set; } private MusicController music { get; set; } = null!;
[Resolved] [Resolved]
private BeatmapManager beatmaps { get; set; } private BeatmapManager beatmaps { get; set; } = null!;
[Resolved] [Resolved]
private IBindable<WorkingBeatmap> working { get; set; } private IBindable<WorkingBeatmap> working { get; set; } = null!;
[Resolved] [Resolved]
private EditorBeatmap editorBeatmap { get; set; } private EditorBeatmap editorBeatmap { get; set; } = null!;
[Resolved] [Resolved]
private SetupScreenHeader header { get; set; } private Editor? editor { get; set; }
[Resolved]
private SetupScreenHeader header { get; set; } = null!;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
@ -93,6 +94,8 @@ namespace osu.Game.Screens.Edit.Setup
working.Value.Metadata.BackgroundFile = destination.Name; working.Value.Metadata.BackgroundFile = destination.Name;
header.Background.UpdateBackground(); header.Background.UpdateBackground();
editor?.ApplyToBackground(bg => bg.RefreshBackground());
return true; return true;
} }
@ -125,17 +128,17 @@ namespace osu.Game.Screens.Edit.Setup
return true; return true;
} }
private void backgroundChanged(ValueChangedEvent<FileInfo> file) private void backgroundChanged(ValueChangedEvent<FileInfo?> file)
{ {
if (!ChangeBackgroundImage(file.NewValue)) if (file.NewValue == null || !ChangeBackgroundImage(file.NewValue))
backgroundChooser.Current.Value = file.OldValue; backgroundChooser.Current.Value = file.OldValue;
updatePlaceholderText(); updatePlaceholderText();
} }
private void audioTrackChanged(ValueChangedEvent<FileInfo> file) private void audioTrackChanged(ValueChangedEvent<FileInfo?> file)
{ {
if (!ChangeAudioTrack(file.NewValue)) if (file.NewValue == null || !ChangeAudioTrack(file.NewValue))
audioTrackChooser.Current.Value = file.OldValue; audioTrackChooser.Current.Value = file.OldValue;
updatePlaceholderText(); updatePlaceholderText();

View File

@ -151,7 +151,7 @@ namespace osu.Game.Screens.Edit.Timing
if (!displayLocked.Value) if (!displayLocked.Value)
{ {
float trackLength = (float)beatmap.Value.Track.Length; float trackLength = (float)beatmap.Value.Track.Length;
int totalBeatsAvailable = (int)(trackLength / timingPoint.BeatLength); int totalBeatsAvailable = (int)((trackLength - timingPoint.Time) / timingPoint.BeatLength);
Scheduler.AddOnce(showFromBeat, (int)(e.MousePosition.X / DrawWidth * totalBeatsAvailable)); Scheduler.AddOnce(showFromBeat, (int)(e.MousePosition.X / DrawWidth * totalBeatsAvailable));
} }

View File

@ -282,7 +282,7 @@ namespace osu.Game.Screens.Menu
if (beatIndex < 0) return; if (beatIndex < 0) return;
if (IsHovered) if (Action != null && IsHovered)
{ {
this.Delay(early_activation).Schedule(() => this.Delay(early_activation).Schedule(() =>
{ {
@ -361,11 +361,11 @@ namespace osu.Game.Screens.Menu
} }
} }
public override bool HandlePositionalInput => base.HandlePositionalInput && Action != null && Alpha > 0.2f; public override bool HandlePositionalInput => base.HandlePositionalInput && Alpha > 0.2f;
protected override bool OnMouseDown(MouseDownEvent e) protected override bool OnMouseDown(MouseDownEvent e)
{ {
if (e.Button != MouseButton.Left) return false; if (e.Button != MouseButton.Left) return true;
logoBounceContainer.ScaleTo(0.9f, 1000, Easing.Out); logoBounceContainer.ScaleTo(0.9f, 1000, Easing.Out);
return true; return true;
@ -380,18 +380,21 @@ namespace osu.Game.Screens.Menu
protected override bool OnClick(ClickEvent e) protected override bool OnClick(ClickEvent e)
{ {
if (Action?.Invoke() ?? true)
sampleClick.Play();
flashLayer.ClearTransforms(); flashLayer.ClearTransforms();
flashLayer.Alpha = 0.4f; flashLayer.Alpha = 0.4f;
flashLayer.FadeOut(1500, Easing.OutExpo); flashLayer.FadeOut(1500, Easing.OutExpo);
if (Action?.Invoke() == true)
sampleClick.Play();
return true; return true;
} }
protected override bool OnHover(HoverEvent e) protected override bool OnHover(HoverEvent e)
{ {
logoHoverContainer.ScaleTo(1.1f, 500, Easing.OutElastic); if (Action != null)
logoHoverContainer.ScaleTo(1.1f, 500, Easing.OutElastic);
return true; return true;
} }

View File

@ -148,9 +148,14 @@ namespace osu.Game.Screens.OnlinePlay
public override bool OnExiting(ScreenExitEvent e) public override bool OnExiting(ScreenExitEvent e)
{ {
var subScreen = screenStack.CurrentScreen as Drawable; while (screenStack.CurrentScreen != null && screenStack.CurrentScreen is not LoungeSubScreen)
if (subScreen?.IsLoaded == true && screenStack.CurrentScreen.OnExiting(e)) {
return true; var subScreen = (Screen)screenStack.CurrentScreen;
if (subScreen.IsLoaded && subScreen.OnExiting(e))
return true;
subScreen.Exit();
}
RoomManager.PartRoom(); RoomManager.PartRoom();

View File

@ -0,0 +1,98 @@
// 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 osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Skinning;
using osuTK;
namespace osu.Game.Screens.Play.HUD
{
public partial class BPMCounter : RollingCounter<double>, ISkinnableDrawable
{
protected override double RollingDuration => 750;
[Resolved]
private IBindable<WorkingBeatmap> beatmap { get; set; } = null!;
[Resolved]
private IGameplayClock gameplayClock { get; set; } = null!;
[BackgroundDependencyLoader]
private void load(OsuColour colour)
{
Colour = colour.BlueLighter;
Current.Value = DisplayedCount = 0;
}
protected override void Update()
{
base.Update();
//We don't want it going to 0 when we pause. so we block the updates
if (gameplayClock.IsPaused.Value) return;
// We want to check Rate every update to cover windup/down
Current.Value = beatmap.Value.Beatmap.ControlPointInfo.TimingPointAt(gameplayClock.CurrentTime).BPM * gameplayClock.Rate;
}
protected override OsuSpriteText CreateSpriteText()
=> base.CreateSpriteText().With(s => s.Font = s.Font.With(size: 20f, fixedWidth: true));
protected override LocalisableString FormatCount(double count)
{
return $@"{count:0}";
}
protected override IHasText CreateText() => new TextComponent();
private partial class TextComponent : CompositeDrawable, IHasText
{
public LocalisableString Text
{
get => text.Text;
set => text.Text = value;
}
private readonly OsuSpriteText text;
public TextComponent()
{
AutoSizeAxes = Axes.Both;
InternalChild = new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Spacing = new Vector2(2),
Children = new Drawable[]
{
text = new OsuSpriteText
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Font = OsuFont.Numeric.With(size: 16, fixedWidth: true)
},
new OsuSpriteText
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Font = OsuFont.Numeric.With(size: 8),
Text = @"BPM",
Padding = new MarginPadding { Bottom = 2f }, // align baseline better
}
}
};
}
}
public bool UsesFixedAnchor { get; set; }
}
}

View File

@ -33,6 +33,9 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
Precision = 0.1f, Precision = 0.1f,
}; };
[SettingSource("Show colour bars")]
public Bindable<bool> ColourBarVisibility { get; } = new Bindable<bool>(true);
[SettingSource("Show moving average arrow", "Whether an arrow should move beneath the bar showing the average error.")] [SettingSource("Show moving average arrow", "Whether an arrow should move beneath the bar showing the average error.")]
public Bindable<bool> ShowMovingAverage { get; } = new BindableBool(true); public Bindable<bool> ShowMovingAverage { get; } = new BindableBool(true);
@ -108,6 +111,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,
Width = bar_width, Width = bar_width,
RelativeSizeAxes = Axes.Y, RelativeSizeAxes = Axes.Y,
Alpha = 0,
Height = 0.5f, Height = 0.5f,
Scale = new Vector2(1, -1), Scale = new Vector2(1, -1),
}, },
@ -115,6 +119,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,
Alpha = 0,
Width = bar_width, Width = bar_width,
RelativeSizeAxes = Axes.Y, RelativeSizeAxes = Axes.Y,
Height = 0.5f, Height = 0.5f,
@ -178,6 +183,11 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
CentreMarkerStyle.BindValueChanged(style => recreateCentreMarker(style.NewValue), true); CentreMarkerStyle.BindValueChanged(style => recreateCentreMarker(style.NewValue), true);
LabelStyle.BindValueChanged(style => recreateLabels(style.NewValue), true); LabelStyle.BindValueChanged(style => recreateLabels(style.NewValue), true);
ColourBarVisibility.BindValueChanged(visible =>
{
colourBarsEarly.FadeTo(visible.NewValue ? 1 : 0, 500, Easing.OutQuint);
colourBarsLate.FadeTo(visible.NewValue ? 1 : 0, 500, Easing.OutQuint);
}, true);
// delay the appearance animations for only the initial appearance. // delay the appearance animations for only the initial appearance.
using (arrowContainer.BeginDelayedSequence(450)) using (arrowContainer.BeginDelayedSequence(450))

View File

@ -64,6 +64,16 @@ namespace osu.Game.Skinning
private Skin trianglesSkin { get; } private Skin trianglesSkin { get; }
public override bool PauseImports
{
get => base.PauseImports;
set
{
base.PauseImports = value;
skinImporter.PauseImports = value;
}
}
public SkinManager(Storage storage, RealmAccess realm, GameHost host, IResourceStore<byte[]> resources, AudioManager audio, Scheduler scheduler) public SkinManager(Storage storage, RealmAccess realm, GameHost host, IResourceStore<byte[]> resources, AudioManager audio, Scheduler scheduler)
: base(storage, realm) : base(storage, realm)
{ {

View File

@ -1,9 +1,8 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using System.Collections.Generic;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
@ -14,8 +13,11 @@ using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Cursor;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using JetBrains.Annotations; using osu.Game.Online.API;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Chat;
using osu.Game.Resources.Localisation.Web;
using osu.Game.Localisation;
namespace osu.Game.Users namespace osu.Game.Users
{ {
@ -27,11 +29,11 @@ namespace osu.Game.Users
/// Perform an action in addition to showing the user's profile. /// Perform an action in addition to showing the user's profile.
/// This should be used to perform auxiliary tasks and not as a primary action for clicking a user panel (to maintain a consistent UX). /// This should be used to perform auxiliary tasks and not as a primary action for clicking a user panel (to maintain a consistent UX).
/// </summary> /// </summary>
public new Action Action; public new Action? Action;
protected Action ViewProfile { get; private set; } protected Action ViewProfile { get; private set; } = null!;
protected Drawable Background { get; private set; } protected Drawable Background { get; private set; } = null!;
protected UserPanel(APIUser user) protected UserPanel(APIUser user)
: base(HoverSampleSet.Button) : base(HoverSampleSet.Button)
@ -41,14 +43,23 @@ namespace osu.Game.Users
User = user; User = user;
} }
[Resolved(canBeNull: true)] [Resolved]
private UserProfileOverlay profileOverlay { get; set; } private UserProfileOverlay? profileOverlay { get; set; }
[Resolved(canBeNull: true)]
protected OverlayColourProvider ColourProvider { get; private set; }
[Resolved] [Resolved]
protected OsuColour Colours { get; private set; } private IAPIProvider api { get; set; } = null!;
[Resolved]
private ChannelManager? channelManager { get; set; }
[Resolved]
private ChatOverlay? chatOverlay { get; set; }
[Resolved]
protected OverlayColourProvider? ColourProvider { get; private set; }
[Resolved]
protected OsuColour Colours { get; private set; } = null!;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
@ -79,7 +90,6 @@ namespace osu.Game.Users
}; };
} }
[NotNull]
protected abstract Drawable CreateLayout(); protected abstract Drawable CreateLayout();
protected OsuSpriteText CreateUsername() => new OsuSpriteText protected OsuSpriteText CreateUsername() => new OsuSpriteText
@ -89,9 +99,26 @@ namespace osu.Game.Users
Text = User.Username, Text = User.Username,
}; };
public MenuItem[] ContextMenuItems => new MenuItem[] public MenuItem[] ContextMenuItems
{ {
new OsuMenuItem("View Profile", MenuItemType.Highlighted, ViewProfile), get
}; {
List<MenuItem> items = new List<MenuItem>
{
new OsuMenuItem(ContextMenuStrings.ViewProfile, MenuItemType.Highlighted, ViewProfile)
};
if (!User.Equals(api.LocalUser.Value))
{
items.Add(new OsuMenuItem(UsersStrings.CardSendMessage, MenuItemType.Standard, () =>
{
channelManager?.OpenPrivateChannel(User);
chatOverlay?.Show();
}));
}
return items.ToArray();
}
}
} }
} }