1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 05:32:54 +08:00

Merge branch 'master' into comment-logged-out

This commit is contained in:
Bartłomiej Dach 2023-06-22 23:19:00 +02:00
commit c06b825d9b
No known key found for this signature in database
18 changed files with 206 additions and 44 deletions

View File

@ -11,7 +11,7 @@
<AndroidManifestMerger>manifestmerger.jar</AndroidManifestMerger>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Framework.Android" Version="2023.618.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2023.620.0" />
</ItemGroup>
<ItemGroup>
<AndroidManifestOverlay Include="$(MSBuildThisFileDirectory)osu.Android\Properties\AndroidManifestOverlay.xml" />

View File

@ -2,7 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.Containers;
using osu.Game.Rulesets.Catch.UI;
using osu.Game.Skinning;
using osuTK;
@ -13,7 +13,7 @@ namespace osu.Game.Rulesets.Catch.Skinning.Legacy
/// <summary>
/// A combo counter implementation that visually behaves almost similar to stable's osu!catch combo counter.
/// </summary>
public partial class LegacyCatchComboCounter : CompositeDrawable, ICatchComboCounter
public partial class LegacyCatchComboCounter : UprightAspectMaintainingContainer, ICatchComboCounter
{
private readonly LegacyRollingCounter counter;

View File

@ -185,7 +185,18 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
AddAssert("Ensure cursor is on a grid line", () =>
{
return grid.ChildrenOfType<CircularProgress>().Any(p => Precision.AlmostEquals(p.ScreenSpaceDrawQuad.TopRight.X, grid.ToScreenSpace(cursor.LastSnappedPosition).X));
return grid.ChildrenOfType<CircularProgress>().Any(ring =>
{
// the grid rings are actually slightly _larger_ than the snapping radii.
// this is done such that the snapping radius falls right in the middle of each grid ring thickness-wise,
// but it does however complicate the following calculations slightly.
// we want to calculate the coordinates of the rightmost point on the grid line, which is in the exact middle of the ring thickness-wise.
// for the X component, we take the entire width of the ring, minus one half of the inner radius (since we want the middle of the line on the right side).
// for the Y component, we just take 0.5f.
var rightMiddleOfGridLine = ring.ToScreenSpace(ring.DrawSize * new Vector2(1 - ring.InnerRadius / 2, 0.5f));
return Precision.AlmostEquals(rightMiddleOfGridLine.X, grid.ToScreenSpace(cursor.LastSnappedPosition).X);
});
});
}

View File

@ -111,6 +111,10 @@ namespace osu.Game.Graphics.UserInterface
protected override bool OnClick(ClickEvent e)
{
// Handle case where a click is triggered via TriggerClick().
if (!IsHovered)
hover.FadeOutFromOne(1600);
hover.FlashColour(FlashColour, 800, Easing.OutQuint);
return base.OnClick(e);
}

View File

@ -119,6 +119,8 @@ namespace osu.Game.Input.Bindings
new KeyBinding(InputKey.MouseMiddle, GlobalAction.PauseGameplay),
new KeyBinding(InputKey.Control, GlobalAction.HoldForHUD),
new KeyBinding(InputKey.Tab, GlobalAction.ToggleChatFocus),
new KeyBinding(InputKey.F1, GlobalAction.SaveReplay),
new KeyBinding(InputKey.F2, GlobalAction.ExportReplay),
};
public IEnumerable<KeyBinding> ReplayKeyBindings => new[]
@ -366,5 +368,11 @@ namespace osu.Game.Input.Bindings
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorCycleNextBeatSnapDivisor))]
EditorCycleNextBeatSnapDivisor,
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.SaveReplay))]
SaveReplay,
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.ExportReplay))]
ExportReplay,
}
}

View File

@ -324,6 +324,16 @@ namespace osu.Game.Localisation
/// </summary>
public static LocalisableString ToggleChatFocus => new TranslatableString(getKey(@"toggle_chat_focus"), @"Toggle chat focus");
/// <summary>
/// "Save replay"
/// </summary>
public static LocalisableString SaveReplay => new TranslatableString(getKey(@"save_replay"), @"Save replay");
/// <summary>
/// "Export replay"
/// </summary>
public static LocalisableString ExportReplay => new TranslatableString(getKey(@"export_replay"), @"Export replay");
private static string getKey(string key) => $@"{prefix}:{key}";
}
}

View File

@ -58,16 +58,18 @@ namespace osu.Game.Overlays.BeatmapSet
private void updateDisplay()
{
bpm.Value = BeatmapSet?.BPM.ToLocalisableString(@"0.##") ?? (LocalisableString)"-";
if (beatmapInfo == null)
{
bpm.Value = "-";
length.Value = string.Empty;
circleCount.Value = string.Empty;
sliderCount.Value = string.Empty;
}
else
{
bpm.Value = beatmapInfo.BPM.ToLocalisableString(@"0.##");
length.Value = TimeSpan.FromMilliseconds(beatmapInfo.Length).ToFormattedDuration();
if (beatmapInfo is not IBeatmapOnlineInfo onlineInfo) return;

View File

@ -316,6 +316,8 @@ namespace osu.Game.Overlays
var queuedTrack = getQueuedTrack();
var lastTrack = CurrentTrack;
lastTrack.Completed -= onTrackCompleted;
CurrentTrack = queuedTrack;
// At this point we may potentially be in an async context from tests. This is extremely dangerous but we have to make do for now.
@ -344,16 +346,12 @@ namespace osu.Game.Overlays
// Important to keep this in its own method to avoid inadvertently capturing unnecessary variables in the callback.
// Can lead to leaks.
var queuedTrack = new DrawableTrack(current.LoadTrack());
queuedTrack.Completed += () => onTrackCompleted(current);
queuedTrack.Completed += onTrackCompleted;
return queuedTrack;
}
private void onTrackCompleted(WorkingBeatmap workingBeatmap)
private void onTrackCompleted()
{
// the source of track completion is the audio thread, so the beatmap may have changed before firing.
if (current != workingBeatmap)
return;
if (!CurrentTrack.Looping && !beatmap.Disabled)
NextTrack();
}

View File

@ -118,7 +118,7 @@ namespace osu.Game.Overlays
private void updateProcessingMode()
{
bool enabled = OverlayActivationMode.Value == OverlayActivation.All || State.Value == Visibility.Visible;
bool enabled = OverlayActivationMode.Value != OverlayActivation.Disabled || State.Value == Visibility.Visible;
notificationsEnabler?.Cancel();

View File

@ -3,11 +3,13 @@
using System.Diagnostics;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Configuration;
using osu.Game.Graphics.Containers;
using osu.Game.Input.Bindings;
using osu.Game.Screens;
@ -45,6 +47,12 @@ namespace osu.Game.Overlays.SkinEditor
RelativeSizeAxes = Axes.Both;
}
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
config.BindWith(OsuSetting.BeatmapSkins, beatmapSkins);
}
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{
switch (e.Action)
@ -62,6 +70,8 @@ namespace osu.Game.Overlays.SkinEditor
protected override void PopIn()
{
globallyDisableBeatmapSkinSetting();
if (skinEditor != null)
{
skinEditor.Show();
@ -87,7 +97,13 @@ namespace osu.Game.Overlays.SkinEditor
});
}
protected override void PopOut() => skinEditor?.Hide();
protected override void PopOut()
{
skinEditor?.Save(false);
skinEditor?.Hide();
globallyReenableBeatmapSkinSetting();
}
protected override void Update()
{
@ -151,8 +167,6 @@ namespace osu.Game.Overlays.SkinEditor
if (skinEditor == null) return;
skinEditor.Save(userTriggered: false);
// ensure the toolbar is re-hidden even if a new screen decides to try and show it.
updateComponentVisibility();
@ -182,5 +196,25 @@ namespace osu.Game.Overlays.SkinEditor
skinEditor = null;
}
}
private readonly Bindable<bool> beatmapSkins = new Bindable<bool>();
private LeasedBindable<bool>? leasedBeatmapSkins;
private void globallyDisableBeatmapSkinSetting()
{
if (beatmapSkins.Disabled)
return;
// The skin editor doesn't work well if beatmap skins are being applied to the player screen.
// To keep things simple, disable the setting game-wide while using the skin editor.
leasedBeatmapSkins = beatmapSkins.BeginLease(true);
leasedBeatmapSkins.Value = false;
}
private void globallyReenableBeatmapSkinSetting()
{
leasedBeatmapSkins?.Return();
leasedBeatmapSkins = null;
}
}
}

View File

@ -86,7 +86,7 @@ namespace osu.Game.Screens.Backgrounds
if (nextBackground == background)
return false;
Logger.Log("🌅 Background change queued");
Logger.Log(@"🌅 Global background change queued");
cancellationTokenSource?.Cancel();
cancellationTokenSource = new CancellationTokenSource();
@ -94,6 +94,7 @@ namespace osu.Game.Screens.Backgrounds
nextTask?.Cancel();
nextTask = Scheduler.AddDelayed(() =>
{
Logger.Log(@"🌅 Global background loading");
LoadComponentAsync(nextBackground, displayNext, cancellationTokenSource.Token);
}, 500);

View File

@ -65,14 +65,15 @@ namespace osu.Game.Screens.Edit.Compose.Components
for (int i = 0; i < requiredCircles; i++)
{
float diameter = (offset + (i + 1) * DistanceBetweenTicks) * 2;
const float thickness = 4;
float diameter = (offset + (i + 1) * DistanceBetweenTicks + thickness / 2) * 2;
AddInternal(new Ring(ReferenceObject, GetColourForIndexFromPlacement(i))
{
Position = StartPosition,
Origin = Anchor.Centre,
Size = new Vector2(diameter),
InnerRadius = 4 * 1f / diameter,
InnerRadius = thickness * 1f / diameter,
});
}
}

View File

@ -49,6 +49,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
[Resolved]
private MultiplayerClient client { get; set; }
[Resolved(canBeNull: true)]
private OsuGame game { get; set; }
private AddItemButton addItemButton;
public MultiplayerMatchSubScreen(Room room)
@ -334,11 +337,13 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
updateCurrentItem();
addItemButton.Alpha = client.IsHost || Room.QueueMode.Value != QueueMode.HostOnly ? 1 : 0;
addItemButton.Alpha = localUserCanAddItem ? 1 : 0;
Scheduler.AddOnce(UpdateMods);
}
private bool localUserCanAddItem => client.IsHost || Room.QueueMode.Value != QueueMode.HostOnly;
private void updateCurrentItem()
{
Debug.Assert(client.Room != null);
@ -403,18 +408,16 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
if (!this.IsCurrentScreen())
return;
if (client.Room == null)
if (!localUserCanAddItem)
return;
if (!client.IsHost)
{
// todo: should handle this when the request queue is implemented.
// if we decide that the presentation should exit the user from the multiplayer game, the PresentBeatmap
// flow may need to change to support an "unable to present" return value.
return;
}
// If there's only one playlist item and we are the host, assume we want to change it. Else add a new one.
PlaylistItem itemToEdit = client.IsHost && Room.Playlist.Count == 1 ? Room.Playlist.Single() : null;
this.Push(new MultiplayerMatchSongSelect(Room, Room.Playlist.Single(item => item.ID == client.Room.Settings.PlaylistItemId)));
OpenSongSelection(itemToEdit);
// Re-run PresentBeatmap now that we've pushed a song select that can handle it.
game?.PresentBeatmap(beatmap.BeatmapSetInfo, b => b.ID == beatmap.BeatmapInfo.ID);
}
protected override void Dispose(bool isDisposing)

View File

@ -8,16 +8,26 @@ using osu.Framework.Bindables;
using osu.Framework.Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Database;
using osu.Game.Scoring;
using osu.Game.Graphics.UserInterface;
using osu.Game.Input.Bindings;
using osu.Game.Online;
using osu.Game.Online.Multiplayer;
using osuTK;
namespace osu.Game.Screens.Play
{
public partial class SaveFailedScoreButton : CompositeDrawable
public partial class SaveFailedScoreButton : CompositeDrawable, IKeyBindingHandler<GlobalAction>
{
[Resolved]
private RealmAccess realm { get; set; } = null!;
[Resolved]
private ScoreManager scoreManager { get; set; } = null!;
private readonly Bindable<DownloadState> state = new Bindable<DownloadState>();
private readonly Func<Task<ScoreInfo>> importFailedScore;
@ -34,7 +44,7 @@ namespace osu.Game.Screens.Play
}
[BackgroundDependencyLoader]
private void load(OsuGame? game, Player? player, RealmAccess realm)
private void load(OsuGame? game, Player? player)
{
InternalChild = button = new DownloadButton
{
@ -54,7 +64,7 @@ namespace osu.Game.Screens.Play
{
importedScore = realm.Run(r => r.Find<ScoreInfo>(t.GetResultSafely().ID)?.Detach());
Schedule(() => state.Value = importedScore != null ? DownloadState.LocallyAvailable : DownloadState.NotDownloaded);
});
}).FireAndForget();
break;
}
}
@ -87,5 +97,43 @@ namespace osu.Game.Screens.Play
}
}, true);
}
#region Export via hotkey logic (also in ReplayDownloadButton)
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{
switch (e.Action)
{
case GlobalAction.SaveReplay:
button.TriggerClick();
return true;
case GlobalAction.ExportReplay:
state.BindValueChanged(exportWhenReady, true);
// start the import via button
if (state.Value != DownloadState.LocallyAvailable)
button.TriggerClick();
return true;
}
return false;
}
public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e)
{
}
private void exportWhenReady(ValueChangedEvent<DownloadState> state)
{
if (state.NewValue != DownloadState.LocallyAvailable) return;
scoreManager.Export(importedScore);
this.state.ValueChanged -= exportWhenReady;
}
#endregion
}
}

View File

@ -1,30 +1,34 @@
// 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.
#nullable disable
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
using osu.Game.Input.Bindings;
using osu.Game.Online;
using osu.Game.Scoring;
using osuTK;
namespace osu.Game.Screens.Ranking
{
public partial class ReplayDownloadButton : CompositeDrawable
public partial class ReplayDownloadButton : CompositeDrawable, IKeyBindingHandler<GlobalAction>
{
public readonly Bindable<ScoreInfo> Score = new Bindable<ScoreInfo>();
protected readonly Bindable<DownloadState> State = new Bindable<DownloadState>();
private DownloadButton button;
private ShakeContainer shakeContainer;
private DownloadButton button = null!;
private ShakeContainer shakeContainer = null!;
private ScoreDownloadTracker downloadTracker;
private ScoreDownloadTracker? downloadTracker;
[Resolved]
private ScoreManager scoreManager { get; set; } = null!;
private ReplayAvailability replayAvailability
{
@ -46,8 +50,8 @@ namespace osu.Game.Screens.Ranking
Size = new Vector2(50, 30);
}
[BackgroundDependencyLoader(true)]
private void load(OsuGame game, ScoreModelDownloader scores)
[BackgroundDependencyLoader]
private void load(OsuGame? game, ScoreModelDownloader scoreDownloader)
{
InternalChild = shakeContainer = new ShakeContainer
{
@ -67,7 +71,7 @@ namespace osu.Game.Screens.Ranking
break;
case DownloadState.NotDownloaded:
scores.Download(Score.Value);
scoreDownloader.Download(Score.Value);
break;
case DownloadState.Importing:
@ -99,6 +103,44 @@ namespace osu.Game.Screens.Ranking
}, true);
}
#region Export via hotkey logic (also in SaveFailedScoreButton)
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{
switch (e.Action)
{
case GlobalAction.SaveReplay:
button.TriggerClick();
return true;
case GlobalAction.ExportReplay:
State.BindValueChanged(exportWhenReady, true);
// start the import via button
if (State.Value != DownloadState.LocallyAvailable)
button.TriggerClick();
return true;
}
return false;
}
public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e)
{
}
private void exportWhenReady(ValueChangedEvent<DownloadState> state)
{
if (state.NewValue != DownloadState.LocallyAvailable) return;
scoreManager.Export(Score.Value);
State.ValueChanged -= exportWhenReady;
}
#endregion
private void updateState()
{
switch (replayAvailability)

View File

@ -160,7 +160,7 @@ namespace osu.Game.Screens.Ranking
if (allowWatchingReplay)
{
buttons.Add(new ReplayDownloadButton(null)
buttons.Add(new ReplayDownloadButton(SelectedScore.Value)
{
Score = { BindTarget = SelectedScore },
Width = 300

View File

@ -36,7 +36,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Realm" Version="10.20.0" />
<PackageReference Include="ppy.osu.Framework" Version="2023.618.0" />
<PackageReference Include="ppy.osu.Framework" Version="2023.620.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2023.605.0" />
<PackageReference Include="Sentry" Version="3.28.1" />
<PackageReference Include="SharpCompress" Version="0.32.2" />

View File

@ -16,6 +16,6 @@
<RuntimeIdentifier>iossimulator-x64</RuntimeIdentifier>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Framework.iOS" Version="2023.618.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2023.620.0" />
</ItemGroup>
</Project>