mirror of
https://github.com/ppy/osu.git
synced 2024-12-05 10:23:20 +08:00
Compare commits
10 Commits
da74dc9963
...
36c690172f
Author | SHA1 | Date | |
---|---|---|---|
|
36c690172f | ||
|
be05f2a1c2 | ||
|
6ff1dec7b2 | ||
|
e920cfa187 | ||
|
164b809c89 | ||
|
f4e155bfa6 | ||
|
efcdb268d2 | ||
|
c0e8bfb749 | ||
|
cf1d92fdb2 | ||
|
0c074bcc94 |
@ -2,10 +2,13 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Game;
|
using osu.Game;
|
||||||
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Overlays.Notifications;
|
using osu.Game.Overlays.Notifications;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
@ -16,7 +19,7 @@ namespace osu.Desktop.Updater
|
|||||||
{
|
{
|
||||||
public partial class VelopackUpdateManager : Game.Updater.UpdateManager
|
public partial class VelopackUpdateManager : Game.Updater.UpdateManager
|
||||||
{
|
{
|
||||||
private readonly UpdateManager updateManager;
|
private UpdateManager updateManager = null!;
|
||||||
private INotificationOverlay notificationOverlay = null!;
|
private INotificationOverlay notificationOverlay = null!;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
@ -25,22 +28,45 @@ namespace osu.Desktop.Updater
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private ILocalUserPlayInfo? localUserInfo { get; set; }
|
private ILocalUserPlayInfo? localUserInfo { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OsuConfigManager osuConfigManager { get; set; } = null!;
|
||||||
|
|
||||||
private bool isInGameplay => localUserInfo?.PlayingState.Value != LocalUserPlayingState.NotPlaying;
|
private bool isInGameplay => localUserInfo?.PlayingState.Value != LocalUserPlayingState.NotPlaying;
|
||||||
|
|
||||||
private UpdateInfo? pendingUpdate;
|
private UpdateInfo? pendingUpdate;
|
||||||
|
|
||||||
public VelopackUpdateManager()
|
private Bindable<ReleaseStream> releaseStream => osuConfigManager.GetBindable<ReleaseStream>(OsuSetting.ReleaseStream);
|
||||||
{
|
|
||||||
updateManager = new UpdateManager(new GithubSource(@"https://github.com/ppy/osu", null, false), new UpdateOptions
|
|
||||||
{
|
|
||||||
AllowVersionDowngrade = true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(INotificationOverlay notifications)
|
private void load(INotificationOverlay notifications)
|
||||||
{
|
{
|
||||||
notificationOverlay = notifications;
|
notificationOverlay = notifications;
|
||||||
|
|
||||||
|
UpdateOptions options = new UpdateOptions
|
||||||
|
{
|
||||||
|
AllowVersionDowngrade = true,
|
||||||
|
};
|
||||||
|
|
||||||
|
string arch = RuntimeInformation.OSArchitecture.ToString().ToLowerInvariant();
|
||||||
|
|
||||||
|
string platform = Environment.OSVersion.Platform switch
|
||||||
|
{
|
||||||
|
PlatformID.Win32NT => "win",
|
||||||
|
PlatformID.Unix => "linux-" + arch,
|
||||||
|
PlatformID.MacOSX => "osx-" + arch,
|
||||||
|
_ => throw new PlatformNotSupportedException(),
|
||||||
|
};
|
||||||
|
|
||||||
|
if (releaseStream.Value == ReleaseStream.Photon)
|
||||||
|
{
|
||||||
|
options.ExplicitChannel = $"{platform}-photon";
|
||||||
|
// TODO: The logging here is not correct. It should be reading from `VelopackLocator.GetDefault(null).Channel` instead. Should also probably be moved to a more appropriate location.
|
||||||
|
Logger.Log("Using photon channel");
|
||||||
|
}
|
||||||
|
else if (releaseStream.Value == ReleaseStream.Lazer)
|
||||||
|
options.ExplicitChannel = platform;
|
||||||
|
|
||||||
|
updateManager = new UpdateManager(new GithubSource(@"https://github.com/ppy/osu", null, false), options);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task<bool> PerformUpdateCheck() => await checkForUpdateAsync().ConfigureAwait(false);
|
protected override async Task<bool> PerformUpdateCheck() => await checkForUpdateAsync().ConfigureAwait(false);
|
||||||
|
@ -5,25 +5,64 @@ using System;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Audio;
|
||||||
|
using osu.Framework.Extensions;
|
||||||
|
using osu.Framework.Platform;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
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.Rooms;
|
using osu.Game.Online.Rooms;
|
||||||
using osu.Game.Online.Rooms.RoomStatuses;
|
using osu.Game.Online.Rooms.RoomStatuses;
|
||||||
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Rulesets.Osu.Mods;
|
||||||
|
using osu.Game.Scoring;
|
||||||
using osu.Game.Screens.OnlinePlay.Playlists;
|
using osu.Game.Screens.OnlinePlay.Playlists;
|
||||||
|
using osu.Game.Tests.Resources;
|
||||||
using osu.Game.Tests.Visual.OnlinePlay;
|
using osu.Game.Tests.Visual.OnlinePlay;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Playlists
|
namespace osu.Game.Tests.Visual.Playlists
|
||||||
{
|
{
|
||||||
public partial class TestScenePlaylistsRoomSubScreen : OnlinePlayTestScene
|
public partial class TestScenePlaylistsRoomSubScreen : OnlinePlayTestScene
|
||||||
{
|
{
|
||||||
|
private const double track_length = 10000;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private IAPIProvider api { get; set; } = null!;
|
private IAPIProvider api { get; set; } = null!;
|
||||||
|
|
||||||
protected new TestRoomManager RoomManager => (TestRoomManager)base.RoomManager;
|
protected new TestRoomManager RoomManager => (TestRoomManager)base.RoomManager;
|
||||||
|
|
||||||
|
private BeatmapManager beatmaps = null!;
|
||||||
|
private RulesetStore rulesets = null!;
|
||||||
|
private BeatmapSetInfo? importedSet;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(GameHost host, AudioManager audio)
|
||||||
|
{
|
||||||
|
Dependencies.Cache(rulesets = new RealmRulesetStore(Realm));
|
||||||
|
Dependencies.Cache(beatmaps = new BeatmapManager(LocalStorage, Realm, null, audio, Resources, host, Beatmap.Default));
|
||||||
|
Dependencies.Cache(new ScoreManager(rulesets, () => beatmaps, LocalStorage, Realm, API));
|
||||||
|
Dependencies.Cache(Realm);
|
||||||
|
|
||||||
|
beatmaps.Import(TestResources.GetQuickTestBeatmapForImport()).WaitSafely();
|
||||||
|
|
||||||
|
Realm.Write(r =>
|
||||||
|
{
|
||||||
|
foreach (var set in r.All<BeatmapSetInfo>())
|
||||||
|
{
|
||||||
|
foreach (var b in set.Beatmaps)
|
||||||
|
{
|
||||||
|
// These will all have a virtual track length of 1000, see WorkingBeatmap.GetVirtualTrack().
|
||||||
|
b.Length = track_length - 1000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
importedSet = beatmaps.GetAllUsableBeatmapSets().First();
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestStatusUpdateOnEnter()
|
public void TestStatusUpdateOnEnter()
|
||||||
{
|
{
|
||||||
@ -69,5 +108,42 @@ namespace osu.Game.Tests.Visual.Playlists
|
|||||||
AddAssert("close button present", () => roomScreen.ChildrenOfType<DangerousRoundedButton>().Any());
|
AddAssert("close button present", () => roomScreen.ChildrenOfType<DangerousRoundedButton>().Any());
|
||||||
AddUntilStep("wait for close button to disappear", () => !roomScreen.ChildrenOfType<DangerousRoundedButton>().Any());
|
AddUntilStep("wait for close button to disappear", () => !roomScreen.ChildrenOfType<DangerousRoundedButton>().Any());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestCase(120_000, true)] // Definitely enough time.
|
||||||
|
[TestCase(45_000, true)] // Enough time.
|
||||||
|
[TestCase(35_000, false)] // Not enough time to complete beatmap after lenience.
|
||||||
|
[TestCase(20_000, false)] // Not enough time.
|
||||||
|
[TestCase(5_000, false)] // Not enough time to complete beatmap before lenience.
|
||||||
|
[TestCase(37_500, true, 2)] // Enough time to complete beatmap after mods are applied.
|
||||||
|
public void TestReadyButtonEnablementPeriod(int offsetMs, bool enabled, double rate = 1)
|
||||||
|
{
|
||||||
|
Room room = null!;
|
||||||
|
PlaylistsRoomSubScreen roomScreen = null!;
|
||||||
|
|
||||||
|
AddStep("create room", () =>
|
||||||
|
{
|
||||||
|
RoomManager.AddRoom(room = new Room
|
||||||
|
{
|
||||||
|
Name = @"Test Room",
|
||||||
|
Host = api.LocalUser.Value,
|
||||||
|
Category = RoomCategory.Normal,
|
||||||
|
StartDate = DateTimeOffset.Now,
|
||||||
|
EndDate = DateTimeOffset.Now.AddMilliseconds(offsetMs),
|
||||||
|
Playlist =
|
||||||
|
[
|
||||||
|
new PlaylistItem(importedSet!.Beatmaps[0])
|
||||||
|
{
|
||||||
|
RequiredMods = rate == 1
|
||||||
|
? []
|
||||||
|
: [new APIMod(new OsuModDoubleTime { SpeedChange = { Value = rate } })]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("push screen", () => LoadScreen(roomScreen = new PlaylistsRoomSubScreen(room)));
|
||||||
|
AddUntilStep("wait for screen load", () => roomScreen.IsCurrentScreen());
|
||||||
|
AddUntilStep("ready button enabled", () => roomScreen.ChildrenOfType<PlaylistsReadyButton>().SingleOrDefault()?.Enabled.Value, () => Is.EqualTo(enabled));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ namespace osu.Game.Configuration
|
|||||||
public enum ReleaseStream
|
public enum ReleaseStream
|
||||||
{
|
{
|
||||||
Lazer,
|
Lazer,
|
||||||
|
Photon,
|
||||||
//Stable40,
|
//Stable40,
|
||||||
//Beta40,
|
//Beta40,
|
||||||
//Stable
|
//Stable
|
||||||
|
@ -13,6 +13,7 @@ using osu.Framework.Screens;
|
|||||||
using osu.Framework.Statistics;
|
using osu.Framework.Statistics;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Localisation;
|
using osu.Game.Localisation;
|
||||||
|
using osu.Game.Overlays.Dialog;
|
||||||
using osu.Game.Overlays.Notifications;
|
using osu.Game.Overlays.Notifications;
|
||||||
using osu.Game.Overlays.Settings.Sections.Maintenance;
|
using osu.Game.Overlays.Settings.Sections.Maintenance;
|
||||||
using osu.Game.Updater;
|
using osu.Game.Updater;
|
||||||
@ -36,13 +37,40 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private Storage storage { get; set; } = null!;
|
private Storage storage { get; set; } = null!;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private IDialogOverlay dialogOverlay { get; set; } = null!;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuConfigManager config, OsuGame? game)
|
private void load(OsuConfigManager config, OsuGame? game)
|
||||||
{
|
{
|
||||||
|
var releaseStream = config.GetBindable<ReleaseStream>(OsuSetting.ReleaseStream);
|
||||||
Add(new SettingsEnumDropdown<ReleaseStream>
|
Add(new SettingsEnumDropdown<ReleaseStream>
|
||||||
{
|
{
|
||||||
LabelText = GeneralSettingsStrings.ReleaseStream,
|
LabelText = GeneralSettingsStrings.ReleaseStream,
|
||||||
Current = config.GetBindable<ReleaseStream>(OsuSetting.ReleaseStream),
|
Current = releaseStream,
|
||||||
|
});
|
||||||
|
|
||||||
|
bool debounce = false;
|
||||||
|
releaseStream.BindValueChanged(r =>
|
||||||
|
{
|
||||||
|
if (debounce)
|
||||||
|
{
|
||||||
|
debounce = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (game?.RestartAppWhenExited() == true)
|
||||||
|
{
|
||||||
|
game.AttemptExit();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dialogOverlay.Push(new ConfirmDialog("You must restart after changing release streams. Are you sure about this?", () => game?.AttemptExit(), () =>
|
||||||
|
{
|
||||||
|
debounce = true;
|
||||||
|
releaseStream.Value = r.OldValue;
|
||||||
|
}));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (updateManager?.CanCheckForUpdate == true)
|
if (updateManager?.CanCheckForUpdate == true)
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
@ -10,7 +11,9 @@ using osu.Framework.Localisation;
|
|||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Online.Rooms;
|
using osu.Game.Online.Rooms;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Screens.OnlinePlay.Components;
|
using osu.Game.Screens.OnlinePlay.Components;
|
||||||
|
using osu.Game.Utils;
|
||||||
|
|
||||||
namespace osu.Game.Screens.OnlinePlay.Playlists
|
namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||||
{
|
{
|
||||||
@ -19,6 +22,9 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private IBindable<WorkingBeatmap> gameBeatmap { get; set; } = null!;
|
private IBindable<WorkingBeatmap> gameBeatmap { get; set; } = null!;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private IBindable<IReadOnlyList<Mod>> mods { get; set; } = null!;
|
||||||
|
|
||||||
private readonly Room room;
|
private readonly Room room;
|
||||||
|
|
||||||
public PlaylistsReadyButton(Room room)
|
public PlaylistsReadyButton(Room room)
|
||||||
@ -63,14 +69,14 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
|||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
Enabled.Value = hasRemainingAttempts && enoughTimeLeft;
|
Enabled.Value = hasRemainingAttempts && enoughTimeLeft();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override LocalisableString TooltipText
|
public override LocalisableString TooltipText
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (!enoughTimeLeft)
|
if (!enoughTimeLeft())
|
||||||
return "No time left!";
|
return "No time left!";
|
||||||
|
|
||||||
if (!hasRemainingAttempts)
|
if (!hasRemainingAttempts)
|
||||||
@ -80,9 +86,17 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool enoughTimeLeft =>
|
private bool enoughTimeLeft()
|
||||||
// This should probably consider the length of the currently selected item, rather than a constant 30 seconds.
|
{
|
||||||
room.EndDate != null && DateTimeOffset.UtcNow.AddSeconds(30).AddMilliseconds(gameBeatmap.Value.Track.Length) < room.EndDate;
|
double rate = ModUtils.CalculateRateWithMods(mods.Value);
|
||||||
|
|
||||||
|
// We want to avoid users not being able to submit scores if they chose to not skip,
|
||||||
|
// so track length is chosen over playable length.
|
||||||
|
double trackLength = Math.Round(gameBeatmap.Value.Track.Length / rate);
|
||||||
|
|
||||||
|
// Additional 30 second delay added to account for load and/or submit time.
|
||||||
|
return room.EndDate != null && DateTimeOffset.UtcNow.AddSeconds(30).AddMilliseconds(trackLength) < room.EndDate;
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
|
@ -401,7 +401,6 @@ namespace osu.Game.Screens.Select
|
|||||||
if (beatmap == null || bpmLabelContainer == null)
|
if (beatmap == null || bpmLabelContainer == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// this doesn't consider mods which apply variable rates, yet.
|
|
||||||
double rate = ModUtils.CalculateRateWithMods(mods.Value);
|
double rate = ModUtils.CalculateRateWithMods(mods.Value);
|
||||||
|
|
||||||
int bpmMax = FormatUtils.RoundBPM(beatmap.ControlPointInfo.BPMMaximum, rate);
|
int bpmMax = FormatUtils.RoundBPM(beatmap.ControlPointInfo.BPMMaximum, rate);
|
||||||
|
@ -286,6 +286,7 @@ namespace osu.Game.Utils
|
|||||||
{
|
{
|
||||||
double rate = 1;
|
double rate = 1;
|
||||||
|
|
||||||
|
// TODO: This doesn't consider mods which apply variable rates, yet.
|
||||||
foreach (var mod in mods.OfType<IApplicableToRate>())
|
foreach (var mod in mods.OfType<IApplicableToRate>())
|
||||||
rate = mod.ApplyToRate(0, rate);
|
rate = mod.ApplyToRate(0, rate);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user