mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 12:57:36 +08:00
Merge branch 'master' into skin-editor-transform-fix
This commit is contained in:
commit
7daab2d45b
@ -1,4 +1,2 @@
|
||||
# Normalize all the line endings
|
||||
32a74f95a5c80a0ed18e693f13a47522099df5c3
|
||||
# Enabled NRT globally
|
||||
f8830c6850128456266c82de83273204f8b74ac0
|
||||
|
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
@ -126,6 +126,12 @@ jobs:
|
||||
with:
|
||||
dotnet-version: "6.0.x"
|
||||
|
||||
# macOS agents recently have empty NuGet config files, resulting in restore failures,
|
||||
# see https://github.com/actions/virtual-environments/issues/5768
|
||||
# Add the global nuget package source manually for now.
|
||||
- name: Setup NuGet.Config
|
||||
run: echo '<configuration><packageSources><add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /></packageSources></configuration>' > ~/.config/NuGet/NuGet.Config
|
||||
|
||||
# Contrary to seemingly any other msbuild, msbuild running on macOS/Mono
|
||||
# cannot accept .sln(f) files as arguments.
|
||||
# Build just the main game for now.
|
||||
|
@ -154,7 +154,7 @@ namespace osu.Desktop.Updater
|
||||
Activated = () =>
|
||||
{
|
||||
updateManager.PrepareUpdateAsync()
|
||||
.ContinueWith(_ => updateManager.Schedule(() => game?.GracefullyExit()));
|
||||
.ContinueWith(_ => updateManager.Schedule(() => game?.AttemptExit()));
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
@ -4,7 +4,6 @@
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
||||
using osu.Game.Rulesets.Osu.Difficulty.Preprocessing;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
@ -33,14 +32,22 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Evaluators
|
||||
// derive strainTime for calculation
|
||||
var osuCurrObj = (OsuDifficultyHitObject)current;
|
||||
var osuPrevObj = current.Index > 0 ? (OsuDifficultyHitObject)current.Previous(0) : null;
|
||||
var osuNextObj = (OsuDifficultyHitObject)current.Next(0);
|
||||
|
||||
double strainTime = osuCurrObj.StrainTime;
|
||||
double greatWindowFull = greatWindow * 2;
|
||||
double speedWindowRatio = strainTime / greatWindowFull;
|
||||
double doubletapness = 1;
|
||||
|
||||
// Aim to nerf cheesy rhythms (Very fast consecutive doubles with large deltatimes between)
|
||||
if (osuPrevObj != null && strainTime < greatWindowFull && osuPrevObj.StrainTime > strainTime)
|
||||
strainTime = Interpolation.Lerp(osuPrevObj.StrainTime, strainTime, speedWindowRatio);
|
||||
// Nerf doubletappable doubles.
|
||||
if (osuNextObj != null)
|
||||
{
|
||||
double currDeltaTime = Math.Max(1, osuCurrObj.DeltaTime);
|
||||
double nextDeltaTime = Math.Max(1, osuNextObj.DeltaTime);
|
||||
double deltaDifference = Math.Abs(nextDeltaTime - currDeltaTime);
|
||||
double speedRatio = currDeltaTime / Math.Max(currDeltaTime, deltaDifference);
|
||||
double windowRatio = Math.Pow(Math.Min(1, currDeltaTime / greatWindowFull), 2);
|
||||
doubletapness = Math.Pow(speedRatio, 1 - windowRatio);
|
||||
}
|
||||
|
||||
// Cap deltatime to the OD 300 hitwindow.
|
||||
// 0.93 is derived from making sure 260bpm OD8 streams aren't nerfed harshly, whilst 0.92 limits the effect of the cap.
|
||||
@ -55,7 +62,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Evaluators
|
||||
double travelDistance = osuPrevObj?.TravelDistance ?? 0;
|
||||
double distance = Math.Min(single_spacing_threshold, travelDistance + osuCurrObj.MinimumJumpDistance);
|
||||
|
||||
return (speedBonus + speedBonus * Math.Pow(distance / single_spacing_threshold, 3.5)) / strainTime;
|
||||
return (speedBonus + speedBonus * Math.Pow(distance / single_spacing_threshold, 3.5)) * doubletapness / strainTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ using System;
|
||||
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu.Difficulty.Evaluators;
|
||||
using osu.Game.Rulesets.Osu.Difficulty.Preprocessing;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Difficulty.Skills
|
||||
{
|
||||
@ -37,7 +38,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills
|
||||
|
||||
protected override double StrainValueAt(DifficultyHitObject current)
|
||||
{
|
||||
currentStrain *= strainDecay(current.DeltaTime);
|
||||
currentStrain *= strainDecay(((OsuDifficultyHitObject)current).StrainTime);
|
||||
currentStrain += SpeedEvaluator.EvaluateDifficultyOf(current, greatWindow) * skillMultiplier;
|
||||
|
||||
currentRhythm = RhythmEvaluator.EvaluateDifficultyOf(current, greatWindow);
|
||||
|
@ -98,11 +98,14 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
using (var zip = ZipArchive.Open(temp))
|
||||
zip.WriteToDirectory(extractedFolder);
|
||||
|
||||
bool success = setup.ChildrenOfType<ResourcesSection>().First().ChangeAudioTrack(Path.Combine(extractedFolder, "03. Renatus - Soleily 192kbps.mp3"));
|
||||
bool success = setup.ChildrenOfType<ResourcesSection>().First().ChangeAudioTrack(new FileInfo(Path.Combine(extractedFolder, "03. Renatus - Soleily 192kbps.mp3")));
|
||||
|
||||
File.Delete(temp);
|
||||
Directory.Delete(extractedFolder, true);
|
||||
|
||||
// ensure audio file is copied to beatmap as "audio.mp3" rather than original filename.
|
||||
Assert.That(Beatmap.Value.Metadata.AudioFile == "audio.mp3");
|
||||
|
||||
return success;
|
||||
});
|
||||
|
||||
|
57
osu.Game.Tests/Visual/Editing/TestSceneEditorNavigation.cs
Normal file
57
osu.Game.Tests/Visual/Editing/TestSceneEditorNavigation.cs
Normal file
@ -0,0 +1,57 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Rulesets.Mania;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.Edit.Components.Timelines.Summary;
|
||||
using osu.Game.Screens.Edit.GameplayTest;
|
||||
using osu.Game.Screens.Select;
|
||||
using osu.Game.Tests.Resources;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Editing
|
||||
{
|
||||
public class TestSceneEditorNavigation : OsuGameTestScene
|
||||
{
|
||||
[Test]
|
||||
public void TestEditorGameplayTestAlwaysUsesOriginalRuleset()
|
||||
{
|
||||
BeatmapSetInfo beatmapSet = null!;
|
||||
|
||||
AddStep("import test beatmap", () => Game.BeatmapManager.Import(TestResources.GetTestBeatmapForImport()).WaitSafely());
|
||||
AddStep("retrieve beatmap", () => beatmapSet = Game.BeatmapManager.QueryBeatmapSet(set => !set.Protected).AsNonNull().Value.Detach());
|
||||
|
||||
AddStep("present beatmap", () => Game.PresentBeatmap(beatmapSet));
|
||||
AddUntilStep("wait for song select",
|
||||
() => Game.Beatmap.Value.BeatmapSetInfo.Equals(beatmapSet)
|
||||
&& Game.ScreenStack.CurrentScreen is PlaySongSelect songSelect
|
||||
&& songSelect.IsLoaded);
|
||||
AddStep("switch ruleset", () => Game.Ruleset.Value = new ManiaRuleset().RulesetInfo);
|
||||
|
||||
AddStep("open editor", () => ((PlaySongSelect)Game.ScreenStack.CurrentScreen).Edit(beatmapSet.Beatmaps.First(beatmap => beatmap.Ruleset.OnlineID == 0)));
|
||||
AddUntilStep("wait for editor open", () => Game.ScreenStack.CurrentScreen is Editor editor && editor.IsLoaded);
|
||||
AddStep("test gameplay", () =>
|
||||
{
|
||||
var testGameplayButton = this.ChildrenOfType<TestGameplayButton>().Single();
|
||||
InputManager.MoveMouseTo(testGameplayButton);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddUntilStep("wait for player", () => Game.ScreenStack.CurrentScreen is EditorPlayer editorPlayer && editorPlayer.IsLoaded);
|
||||
AddAssert("current ruleset is osu!", () => Game.Ruleset.Value.Equals(new OsuRuleset().RulesetInfo));
|
||||
|
||||
AddStep("exit to song select", () => Game.PerformFromScreen(_ => { }, typeof(PlaySongSelect).Yield()));
|
||||
AddUntilStep("wait for song select", () => Game.ScreenStack.CurrentScreen is PlaySongSelect);
|
||||
AddAssert("previous ruleset restored", () => Game.Ruleset.Value.Equals(new ManiaRuleset().RulesetInfo));
|
||||
}
|
||||
}
|
||||
}
|
@ -217,7 +217,11 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
AddStep("import beatmap", () => BeatmapImportHelper.LoadQuickOszIntoOsu(Game).WaitSafely());
|
||||
AddUntilStep("wait for selected", () => !Game.Beatmap.IsDefault);
|
||||
|
||||
AddStep("Click gameplay scene button", () => skinEditor.ChildrenOfType<SkinEditorSceneLibrary.SceneButton>().First(b => b.Text == "Gameplay").TriggerClick());
|
||||
AddStep("Click gameplay scene button", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(skinEditor.ChildrenOfType<SkinEditorSceneLibrary.SceneButton>().First(b => b.Text == "Gameplay"));
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddUntilStep("wait for player", () =>
|
||||
{
|
||||
|
@ -5,7 +5,6 @@
|
||||
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Tests.Visual;
|
||||
using osu.Game.Tournament.Components;
|
||||
using osu.Game.Tournament.Models;
|
||||
@ -26,13 +25,13 @@ namespace osu.Game.Tournament.Tests.Components
|
||||
FullName = { Value = "Australia" },
|
||||
Players =
|
||||
{
|
||||
new APIUser { Username = "ASecretBox" },
|
||||
new APIUser { Username = "Dereban" },
|
||||
new APIUser { Username = "mReKk" },
|
||||
new APIUser { Username = "uyghti" },
|
||||
new APIUser { Username = "Parkes" },
|
||||
new APIUser { Username = "Shiroha" },
|
||||
new APIUser { Username = "Jordan The Bear" },
|
||||
new TournamentUser { Username = "ASecretBox" },
|
||||
new TournamentUser { Username = "Dereban" },
|
||||
new TournamentUser { Username = "mReKk" },
|
||||
new TournamentUser { Username = "uyghti" },
|
||||
new TournamentUser { Username = "Parkes" },
|
||||
new TournamentUser { Username = "Shiroha" },
|
||||
new TournamentUser { Username = "Jordan The Bear" },
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -42,7 +42,7 @@ namespace osu.Game.Tournament.Tests.Components
|
||||
beatmap.Length = 123456;
|
||||
beatmap.BPM = 133;
|
||||
|
||||
songBar.Beatmap = beatmap;
|
||||
songBar.Beatmap = new TournamentBeatmap(beatmap);
|
||||
});
|
||||
AddStep("set mods to HR", () => songBar.Mods = LegacyMods.HardRock);
|
||||
AddStep("set mods to DT", () => songBar.Mods = LegacyMods.DoubleTime);
|
||||
|
@ -10,6 +10,7 @@ using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Tests.Visual;
|
||||
using osu.Game.Tournament.Components;
|
||||
using osu.Game.Tournament.Models;
|
||||
|
||||
namespace osu.Game.Tournament.Tests.Components
|
||||
{
|
||||
@ -32,7 +33,7 @@ namespace osu.Game.Tournament.Tests.Components
|
||||
|
||||
private void success(APIBeatmap beatmap)
|
||||
{
|
||||
Add(new TournamentBeatmapPanel(beatmap)
|
||||
Add(new TournamentBeatmapPanel(new TournamentBeatmap(beatmap))
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre
|
||||
|
@ -27,16 +27,16 @@ namespace osu.Game.Tournament.Tests.Components
|
||||
Colour = "f2ca34"
|
||||
};
|
||||
|
||||
private readonly APIUser redUser = new APIUser
|
||||
private readonly TournamentUser redUser = new TournamentUser
|
||||
{
|
||||
Username = "BanchoBot",
|
||||
Id = 3,
|
||||
OnlineID = 3,
|
||||
};
|
||||
|
||||
private readonly APIUser blueUser = new APIUser
|
||||
private readonly TournamentUser blueUser = new TournamentUser
|
||||
{
|
||||
Username = "Zallius",
|
||||
Id = 4,
|
||||
OnlineID = 4,
|
||||
};
|
||||
|
||||
[Cached]
|
||||
@ -59,11 +59,11 @@ namespace osu.Game.Tournament.Tests.Components
|
||||
{
|
||||
Team1 =
|
||||
{
|
||||
Value = new TournamentTeam { Players = new BindableList<APIUser> { redUser } }
|
||||
Value = new TournamentTeam { Players = new BindableList<TournamentUser> { redUser } }
|
||||
},
|
||||
Team2 =
|
||||
{
|
||||
Value = new TournamentTeam { Players = new BindableList<APIUser> { blueUser } }
|
||||
Value = new TournamentTeam { Players = new BindableList<TournamentUser> { blueUser } }
|
||||
}
|
||||
};
|
||||
|
||||
@ -82,19 +82,19 @@ namespace osu.Game.Tournament.Tests.Components
|
||||
|
||||
AddStep("message from team red", () => testChannel.AddNewMessages(new Message(nextMessageId())
|
||||
{
|
||||
Sender = redUser,
|
||||
Sender = redUser.ToAPIUser(),
|
||||
Content = "I am team red."
|
||||
}));
|
||||
|
||||
AddStep("message from team red", () => testChannel.AddNewMessages(new Message(nextMessageId())
|
||||
{
|
||||
Sender = redUser,
|
||||
Sender = redUser.ToAPIUser(),
|
||||
Content = "I plan to win!"
|
||||
}));
|
||||
|
||||
AddStep("message from team blue", () => testChannel.AddNewMessages(new Message(nextMessageId())
|
||||
{
|
||||
Sender = blueUser,
|
||||
Sender = blueUser.ToAPIUser(),
|
||||
Content = "Not on my watch. Prepare to eat saaaaaaaaaand. Lots and lots of saaaaaaand."
|
||||
}));
|
||||
|
||||
|
@ -11,6 +11,7 @@ using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Tournament.Components;
|
||||
using osu.Game.Tournament.Models;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tournament.Tests.Components
|
||||
@ -53,7 +54,7 @@ namespace osu.Game.Tournament.Tests.Components
|
||||
|
||||
foreach (var mod in mods)
|
||||
{
|
||||
fillFlow.Add(new TournamentBeatmapPanel(beatmap, mod.Acronym)
|
||||
fillFlow.Add(new TournamentBeatmapPanel(new TournamentBeatmap(beatmap), mod.Acronym)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre
|
||||
|
@ -9,14 +9,12 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Tests.Visual;
|
||||
using osu.Game.Tournament.IO;
|
||||
using osu.Game.Tournament.IPC;
|
||||
using osu.Game.Tournament.Models;
|
||||
using osu.Game.Users;
|
||||
using APIUser = osu.Game.Online.API.Requests.Responses.APIUser;
|
||||
|
||||
namespace osu.Game.Tournament.Tests
|
||||
{
|
||||
@ -123,11 +121,11 @@ namespace osu.Game.Tournament.Tests
|
||||
},
|
||||
Players =
|
||||
{
|
||||
new APIUser { Username = "Hello", Statistics = new UserStatistics { GlobalRank = 12 } },
|
||||
new APIUser { Username = "Hello", Statistics = new UserStatistics { GlobalRank = 16 } },
|
||||
new APIUser { Username = "Hello", Statistics = new UserStatistics { GlobalRank = 20 } },
|
||||
new APIUser { Username = "Hello", Statistics = new UserStatistics { GlobalRank = 24 } },
|
||||
new APIUser { Username = "Hello", Statistics = new UserStatistics { GlobalRank = 30 } },
|
||||
new TournamentUser { Username = "Hello", Rank = 12 },
|
||||
new TournamentUser { Username = "Hello", Rank = 16 },
|
||||
new TournamentUser { Username = "Hello", Rank = 20 },
|
||||
new TournamentUser { Username = "Hello", Rank = 24 },
|
||||
new TournamentUser { Username = "Hello", Rank = 30 },
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -140,11 +138,11 @@ namespace osu.Game.Tournament.Tests
|
||||
FullName = { Value = "United States" },
|
||||
Players =
|
||||
{
|
||||
new APIUser { Username = "Hello" },
|
||||
new APIUser { Username = "Hello" },
|
||||
new APIUser { Username = "Hello" },
|
||||
new APIUser { Username = "Hello" },
|
||||
new APIUser { Username = "Hello" },
|
||||
new TournamentUser { Username = "Hello" },
|
||||
new TournamentUser { Username = "Hello" },
|
||||
new TournamentUser { Username = "Hello" },
|
||||
new TournamentUser { Username = "Hello" },
|
||||
new TournamentUser { Username = "Hello" },
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -154,10 +152,10 @@ namespace osu.Game.Tournament.Tests
|
||||
}
|
||||
};
|
||||
|
||||
public static APIBeatmap CreateSampleBeatmap() =>
|
||||
new APIBeatmap
|
||||
public static TournamentBeatmap CreateSampleBeatmap() =>
|
||||
new TournamentBeatmap
|
||||
{
|
||||
BeatmapSet = new APIBeatmapSet
|
||||
Metadata = new BeatmapMetadata
|
||||
{
|
||||
Title = "Test Title",
|
||||
Artist = "Test Artist",
|
||||
|
@ -7,7 +7,6 @@ using System.Linq;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Tournament.Models;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
@ -56,7 +55,7 @@ namespace osu.Game.Tournament.Components
|
||||
},
|
||||
};
|
||||
|
||||
TournamentSpriteText createPlayerText(APIUser p) =>
|
||||
TournamentSpriteText createPlayerText(TournamentUser p) =>
|
||||
new TournamentSpriteText
|
||||
{
|
||||
Text = p.Username,
|
||||
|
@ -14,9 +14,9 @@ using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Legacy;
|
||||
using osu.Game.Extensions;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osu.Game.Tournament.Models;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -24,14 +24,14 @@ namespace osu.Game.Tournament.Components
|
||||
{
|
||||
public class SongBar : CompositeDrawable
|
||||
{
|
||||
private APIBeatmap beatmap;
|
||||
private TournamentBeatmap beatmap;
|
||||
|
||||
public const float HEIGHT = 145 / 2f;
|
||||
|
||||
[Resolved]
|
||||
private IBindable<RulesetInfo> ruleset { get; set; }
|
||||
|
||||
public APIBeatmap Beatmap
|
||||
public TournamentBeatmap Beatmap
|
||||
{
|
||||
set
|
||||
{
|
||||
|
@ -14,7 +14,6 @@ using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Tournament.Models;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -22,7 +21,7 @@ namespace osu.Game.Tournament.Components
|
||||
{
|
||||
public class TournamentBeatmapPanel : CompositeDrawable
|
||||
{
|
||||
public readonly APIBeatmap Beatmap;
|
||||
public readonly TournamentBeatmap Beatmap;
|
||||
|
||||
private readonly string mod;
|
||||
|
||||
@ -31,7 +30,7 @@ namespace osu.Game.Tournament.Components
|
||||
private readonly Bindable<TournamentMatch> currentMatch = new Bindable<TournamentMatch>();
|
||||
private Box flash;
|
||||
|
||||
public TournamentBeatmapPanel(APIBeatmap beatmap, string mod = null)
|
||||
public TournamentBeatmapPanel(TournamentBeatmap beatmap, string mod = null)
|
||||
{
|
||||
if (beatmap == null) throw new ArgumentNullException(nameof(beatmap));
|
||||
|
||||
@ -61,7 +60,7 @@ namespace osu.Game.Tournament.Components
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = OsuColour.Gray(0.5f),
|
||||
OnlineInfo = Beatmap.BeatmapSet,
|
||||
OnlineInfo = Beatmap,
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
|
@ -96,7 +96,7 @@ namespace osu.Game.Tournament.IPC
|
||||
else
|
||||
{
|
||||
beatmapLookupRequest = new GetBeatmapRequest(new APIBeatmap { OnlineID = beatmapId });
|
||||
beatmapLookupRequest.Success += b => Beatmap.Value = b;
|
||||
beatmapLookupRequest.Success += b => Beatmap.Value = new TournamentBeatmap(b);
|
||||
API.Queue(beatmapLookupRequest);
|
||||
}
|
||||
}
|
||||
|
@ -6,13 +6,13 @@
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Beatmaps.Legacy;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Tournament.Models;
|
||||
|
||||
namespace osu.Game.Tournament.IPC
|
||||
{
|
||||
public class MatchIPCInfo : Component
|
||||
{
|
||||
public Bindable<APIBeatmap> Beatmap { get; } = new Bindable<APIBeatmap>();
|
||||
public Bindable<TournamentBeatmap> Beatmap { get; } = new Bindable<TournamentBeatmap>();
|
||||
public Bindable<LegacyMods> Mods { get; } = new Bindable<LegacyMods>();
|
||||
public Bindable<TourneyState> State { get; } = new Bindable<TourneyState>();
|
||||
public Bindable<string> ChatChannel { get; } = new Bindable<string>();
|
||||
|
@ -4,7 +4,6 @@
|
||||
#nullable disable
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
|
||||
namespace osu.Game.Tournament.Models
|
||||
{
|
||||
@ -14,6 +13,6 @@ namespace osu.Game.Tournament.Models
|
||||
public string Mods;
|
||||
|
||||
[JsonProperty("BeatmapInfo")]
|
||||
public APIBeatmap Beatmap;
|
||||
public TournamentBeatmap Beatmap;
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
|
||||
namespace osu.Game.Tournament.Models
|
||||
{
|
||||
@ -14,7 +13,7 @@ namespace osu.Game.Tournament.Models
|
||||
public int ID;
|
||||
|
||||
[JsonProperty("BeatmapInfo")]
|
||||
public APIBeatmap Beatmap;
|
||||
public TournamentBeatmap Beatmap;
|
||||
|
||||
public long Score;
|
||||
|
||||
|
99
osu.Game.Tournament/Models/TournamentBeatmap.cs
Normal file
99
osu.Game.Tournament/Models/TournamentBeatmap.cs
Normal file
@ -0,0 +1,99 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Extensions;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Rulesets;
|
||||
|
||||
namespace osu.Game.Tournament.Models
|
||||
{
|
||||
public class TournamentBeatmap : IBeatmapInfo, IBeatmapSetOnlineInfo
|
||||
{
|
||||
public int OnlineID { get; set; }
|
||||
|
||||
public string DifficultyName { get; set; } = string.Empty;
|
||||
|
||||
public double BPM { get; set; }
|
||||
|
||||
public double Length { get; set; }
|
||||
|
||||
public double StarRating { get; set; }
|
||||
|
||||
public IBeatmapMetadataInfo Metadata { get; set; } = new BeatmapMetadata();
|
||||
|
||||
public IBeatmapDifficultyInfo Difficulty { get; set; } = new BeatmapDifficulty();
|
||||
|
||||
public BeatmapSetOnlineCovers Covers { get; set; }
|
||||
|
||||
public TournamentBeatmap()
|
||||
{
|
||||
}
|
||||
|
||||
public TournamentBeatmap(APIBeatmap beatmap)
|
||||
{
|
||||
OnlineID = beatmap.OnlineID;
|
||||
DifficultyName = beatmap.DifficultyName;
|
||||
BPM = beatmap.BPM;
|
||||
Length = beatmap.Length;
|
||||
StarRating = beatmap.StarRating;
|
||||
Metadata = beatmap.Metadata;
|
||||
Difficulty = beatmap.Difficulty;
|
||||
Covers = beatmap.BeatmapSet.AsNonNull().Covers;
|
||||
}
|
||||
|
||||
public bool Equals(IBeatmapInfo? other) => other is TournamentBeatmap b && this.MatchesOnlineID(b);
|
||||
|
||||
#region IBeatmapInfo/IBeatmapSetOnlineInfo explicit implementation
|
||||
|
||||
IBeatmapSetInfo IBeatmapInfo.BeatmapSet => throw new NotImplementedException();
|
||||
|
||||
string IBeatmapSetOnlineInfo.Preview => throw new NotImplementedException();
|
||||
|
||||
double IBeatmapSetOnlineInfo.BPM => throw new NotImplementedException();
|
||||
|
||||
int IBeatmapSetOnlineInfo.PlayCount => throw new NotImplementedException();
|
||||
|
||||
int IBeatmapSetOnlineInfo.FavouriteCount => throw new NotImplementedException();
|
||||
|
||||
bool IBeatmapSetOnlineInfo.HasFavourited => throw new NotImplementedException();
|
||||
|
||||
BeatmapSetOnlineAvailability IBeatmapSetOnlineInfo.Availability => throw new NotImplementedException();
|
||||
|
||||
BeatmapSetOnlineGenre IBeatmapSetOnlineInfo.Genre => throw new NotImplementedException();
|
||||
|
||||
BeatmapSetOnlineLanguage IBeatmapSetOnlineInfo.Language => throw new NotImplementedException();
|
||||
|
||||
int? IBeatmapSetOnlineInfo.TrackId => throw new NotImplementedException();
|
||||
|
||||
int[] IBeatmapSetOnlineInfo.Ratings => throw new NotImplementedException();
|
||||
|
||||
BeatmapSetHypeStatus IBeatmapSetOnlineInfo.HypeStatus => throw new NotImplementedException();
|
||||
|
||||
BeatmapSetNominationStatus IBeatmapSetOnlineInfo.NominationStatus => throw new NotImplementedException();
|
||||
|
||||
string IBeatmapInfo.Hash => throw new NotImplementedException();
|
||||
|
||||
string IBeatmapInfo.MD5Hash => throw new NotImplementedException();
|
||||
|
||||
IRulesetInfo IBeatmapInfo.Ruleset => throw new NotImplementedException();
|
||||
|
||||
DateTimeOffset IBeatmapSetOnlineInfo.Submitted => throw new NotImplementedException();
|
||||
|
||||
DateTimeOffset? IBeatmapSetOnlineInfo.Ranked => throw new NotImplementedException();
|
||||
|
||||
DateTimeOffset? IBeatmapSetOnlineInfo.LastUpdated => throw new NotImplementedException();
|
||||
|
||||
BeatmapOnlineStatus IBeatmapSetOnlineInfo.Status => throw new NotImplementedException();
|
||||
|
||||
bool IBeatmapSetOnlineInfo.HasExplicitContent => throw new NotImplementedException();
|
||||
|
||||
bool IBeatmapSetOnlineInfo.HasVideo => throw new NotImplementedException();
|
||||
|
||||
bool IBeatmapSetOnlineInfo.HasStoryboard => throw new NotImplementedException();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ using System;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
|
||||
namespace osu.Game.Tournament.Models
|
||||
{
|
||||
@ -38,7 +37,7 @@ namespace osu.Game.Tournament.Models
|
||||
{
|
||||
get
|
||||
{
|
||||
int[] ranks = Players.Select(p => p.Statistics?.GlobalRank)
|
||||
int[] ranks = Players.Select(p => p.Rank)
|
||||
.Where(i => i.HasValue)
|
||||
.Select(i => i.Value)
|
||||
.ToArray();
|
||||
@ -59,7 +58,7 @@ namespace osu.Game.Tournament.Models
|
||||
};
|
||||
|
||||
[JsonProperty]
|
||||
public BindableList<APIUser> Players { get; set; } = new BindableList<APIUser>();
|
||||
public BindableList<TournamentUser> Players { get; set; } = new BindableList<TournamentUser>();
|
||||
|
||||
public TournamentTeam()
|
||||
{
|
||||
|
58
osu.Game.Tournament/Models/TournamentUser.cs
Normal file
58
osu.Game.Tournament/Models/TournamentUser.cs
Normal file
@ -0,0 +1,58 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Tournament.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// A tournament player user, containing simple information about the player.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TournamentUser : IUser
|
||||
{
|
||||
[JsonProperty(@"id")]
|
||||
public int OnlineID { get; set; }
|
||||
|
||||
public string Username { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The player's country.
|
||||
/// </summary>
|
||||
public Country? Country { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The player's global rank, or null if not available.
|
||||
/// </summary>
|
||||
public int? Rank { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A URL to the player's profile cover.
|
||||
/// </summary>
|
||||
public string CoverUrl { get; set; } = string.Empty;
|
||||
|
||||
public APIUser ToAPIUser()
|
||||
{
|
||||
var user = new APIUser
|
||||
{
|
||||
Id = OnlineID,
|
||||
Username = Username,
|
||||
Country = Country,
|
||||
CoverUrl = CoverUrl,
|
||||
};
|
||||
|
||||
user.Statistics = new UserStatistics
|
||||
{
|
||||
User = user,
|
||||
GlobalRank = Rank
|
||||
};
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
bool IUser.IsBot => false;
|
||||
}
|
||||
}
|
@ -7,9 +7,9 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Beatmaps.Legacy;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Tournament.Components;
|
||||
using osu.Game.Tournament.IPC;
|
||||
using osu.Game.Tournament.Models;
|
||||
|
||||
namespace osu.Game.Tournament.Screens
|
||||
{
|
||||
@ -39,7 +39,7 @@ namespace osu.Game.Tournament.Screens
|
||||
SongBar.Mods = mods.NewValue;
|
||||
}
|
||||
|
||||
private void beatmapChanged(ValueChangedEvent<APIBeatmap> beatmap)
|
||||
private void beatmapChanged(ValueChangedEvent<TournamentBeatmap> beatmap)
|
||||
{
|
||||
SongBar.FadeInFromZero(300, Easing.OutQuint);
|
||||
SongBar.Beatmap = beatmap.NewValue;
|
||||
|
@ -239,7 +239,7 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
|
||||
req.Success += res =>
|
||||
{
|
||||
Model.Beatmap = res;
|
||||
Model.Beatmap = new TournamentBeatmap(res);
|
||||
updatePanel();
|
||||
};
|
||||
|
||||
|
@ -241,7 +241,7 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
|
||||
req.Success += res =>
|
||||
{
|
||||
Model.Beatmap = res;
|
||||
Model.Beatmap = new TournamentBeatmap(res);
|
||||
updatePanel();
|
||||
};
|
||||
|
||||
|
@ -15,7 +15,6 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Overlays.Settings;
|
||||
using osu.Game.Tournament.Components;
|
||||
using osu.Game.Tournament.Models;
|
||||
@ -202,14 +201,14 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
|
||||
public void CreateNew()
|
||||
{
|
||||
var user = new APIUser();
|
||||
team.Players.Add(user);
|
||||
flow.Add(new PlayerRow(team, user));
|
||||
var player = new TournamentUser();
|
||||
team.Players.Add(player);
|
||||
flow.Add(new PlayerRow(team, player));
|
||||
}
|
||||
|
||||
public class PlayerRow : CompositeDrawable
|
||||
{
|
||||
private readonly APIUser user;
|
||||
private readonly TournamentUser user;
|
||||
|
||||
[Resolved]
|
||||
protected IAPIProvider API { get; private set; }
|
||||
@ -217,11 +216,11 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
[Resolved]
|
||||
private TournamentGameBase game { get; set; }
|
||||
|
||||
private readonly Bindable<int?> userId = new Bindable<int?>();
|
||||
private readonly Bindable<int?> playerId = new Bindable<int?>();
|
||||
|
||||
private readonly Container drawableContainer;
|
||||
|
||||
public PlayerRow(TournamentTeam team, APIUser user)
|
||||
public PlayerRow(TournamentTeam team, TournamentUser user)
|
||||
{
|
||||
this.user = user;
|
||||
|
||||
@ -254,7 +253,7 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
LabelText = "User ID",
|
||||
RelativeSizeAxes = Axes.None,
|
||||
Width = 200,
|
||||
Current = userId,
|
||||
Current = playerId,
|
||||
},
|
||||
drawableContainer = new Container
|
||||
{
|
||||
@ -281,10 +280,10 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
userId.Value = user.Id;
|
||||
userId.BindValueChanged(id =>
|
||||
playerId.Value = user.OnlineID;
|
||||
playerId.BindValueChanged(id =>
|
||||
{
|
||||
user.Id = id.NewValue ?? 0;
|
||||
user.OnlineID = id.NewValue ?? 0;
|
||||
|
||||
if (id.NewValue != id.OldValue)
|
||||
user.Username = string.Empty;
|
||||
@ -295,13 +294,13 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
return;
|
||||
}
|
||||
|
||||
game.PopulateUser(user, updatePanel, updatePanel);
|
||||
game.PopulatePlayer(user, updatePanel, updatePanel);
|
||||
}, true);
|
||||
}
|
||||
|
||||
private void updatePanel()
|
||||
{
|
||||
drawableContainer.Child = new UserGridPanel(user) { Width = 300 };
|
||||
drawableContainer.Child = new UserGridPanel(user.ToAPIUser()) { Width = 300 };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Tournament.Components;
|
||||
using osu.Game.Tournament.IPC;
|
||||
using osu.Game.Tournament.Models;
|
||||
@ -107,7 +106,7 @@ namespace osu.Game.Tournament.Screens.MapPool
|
||||
ipc.Beatmap.BindValueChanged(beatmapChanged);
|
||||
}
|
||||
|
||||
private void beatmapChanged(ValueChangedEvent<APIBeatmap> beatmap)
|
||||
private void beatmapChanged(ValueChangedEvent<TournamentBeatmap> beatmap)
|
||||
{
|
||||
if (CurrentMatch.Value == null || CurrentMatch.Value.PicksBans.Count(p => p.Type == ChoiceType.Ban) < 2)
|
||||
return;
|
||||
|
@ -27,7 +27,7 @@ namespace osu.Game.Tournament.Screens.Setup
|
||||
dropdown.Items = storage.ListTournaments();
|
||||
dropdown.Current.BindValueChanged(v => Button.Enabled.Value = v.NewValue != startupTournament, true);
|
||||
|
||||
Action = () => game.GracefullyExit();
|
||||
Action = () => game.AttemptExit();
|
||||
folderButton.Action = () => storage.PresentExternally();
|
||||
|
||||
ButtonText = "Close osu!";
|
||||
|
@ -257,7 +257,7 @@ namespace osu.Game.Tournament.Screens.TeamIntro
|
||||
};
|
||||
|
||||
foreach (var p in team.Players)
|
||||
fill.Add(new RowDisplay(p.Username, p.Statistics?.GlobalRank?.ToString("\\##,0") ?? "-"));
|
||||
fill.Add(new RowDisplay(p.Username, p.Rank?.ToString("\\##,0") ?? "-"));
|
||||
}
|
||||
|
||||
internal class RowDisplay : CompositeDrawable
|
||||
|
@ -22,7 +22,6 @@ using osu.Game.Tournament.IO;
|
||||
using osu.Game.Tournament.IPC;
|
||||
using osu.Game.Tournament.Models;
|
||||
using osuTK.Input;
|
||||
using APIUser = osu.Game.Online.API.Requests.Responses.APIUser;
|
||||
|
||||
namespace osu.Game.Tournament
|
||||
{
|
||||
@ -187,9 +186,7 @@ namespace osu.Game.Tournament
|
||||
{
|
||||
var playersRequiringPopulation = ladder.Teams
|
||||
.SelectMany(t => t.Players)
|
||||
.Where(p => string.IsNullOrEmpty(p.Username)
|
||||
|| p.Statistics?.GlobalRank == null
|
||||
|| p.Statistics?.CountryRank == null).ToList();
|
||||
.Where(p => string.IsNullOrEmpty(p.Username) || p.Rank == null).ToList();
|
||||
|
||||
if (playersRequiringPopulation.Count == 0)
|
||||
return false;
|
||||
@ -197,7 +194,7 @@ namespace osu.Game.Tournament
|
||||
for (int i = 0; i < playersRequiringPopulation.Count; i++)
|
||||
{
|
||||
var p = playersRequiringPopulation[i];
|
||||
PopulateUser(p, immediate: true);
|
||||
PopulatePlayer(p, immediate: true);
|
||||
updateLoadProgressMessage($"Populating user stats ({i} / {playersRequiringPopulation.Count})");
|
||||
}
|
||||
|
||||
@ -211,7 +208,7 @@ namespace osu.Game.Tournament
|
||||
{
|
||||
var beatmapsRequiringPopulation = ladder.Rounds
|
||||
.SelectMany(r => r.Beatmaps)
|
||||
.Where(b => string.IsNullOrEmpty(b.Beatmap?.BeatmapSet?.Title) && b.ID > 0).ToList();
|
||||
.Where(b => b.Beatmap?.OnlineID == 0 && b.ID > 0).ToList();
|
||||
|
||||
if (beatmapsRequiringPopulation.Count == 0)
|
||||
return false;
|
||||
@ -222,7 +219,7 @@ namespace osu.Game.Tournament
|
||||
|
||||
var req = new GetBeatmapRequest(new APIBeatmap { OnlineID = b.ID });
|
||||
API.Perform(req);
|
||||
b.Beatmap = req.Response ?? new APIBeatmap();
|
||||
b.Beatmap = new TournamentBeatmap(req.Response ?? new APIBeatmap());
|
||||
|
||||
updateLoadProgressMessage($"Populating round beatmaps ({i} / {beatmapsRequiringPopulation.Count})");
|
||||
}
|
||||
@ -238,7 +235,7 @@ namespace osu.Game.Tournament
|
||||
var beatmapsRequiringPopulation = ladder.Teams
|
||||
.SelectMany(r => r.SeedingResults)
|
||||
.SelectMany(r => r.Beatmaps)
|
||||
.Where(b => string.IsNullOrEmpty(b.Beatmap?.BeatmapSet?.Title) && b.ID > 0).ToList();
|
||||
.Where(b => b.Beatmap?.OnlineID == 0 && b.ID > 0).ToList();
|
||||
|
||||
if (beatmapsRequiringPopulation.Count == 0)
|
||||
return false;
|
||||
@ -249,7 +246,7 @@ namespace osu.Game.Tournament
|
||||
|
||||
var req = new GetBeatmapRequest(new APIBeatmap { OnlineID = b.ID });
|
||||
API.Perform(req);
|
||||
b.Beatmap = req.Response ?? new APIBeatmap();
|
||||
b.Beatmap = new TournamentBeatmap(req.Response ?? new APIBeatmap());
|
||||
|
||||
updateLoadProgressMessage($"Populating seeding beatmaps ({i} / {beatmapsRequiringPopulation.Count})");
|
||||
}
|
||||
@ -259,9 +256,9 @@ namespace osu.Game.Tournament
|
||||
|
||||
private void updateLoadProgressMessage(string s) => Schedule(() => initialisationText.Text = s);
|
||||
|
||||
public void PopulateUser(APIUser user, Action success = null, Action failure = null, bool immediate = false)
|
||||
public void PopulatePlayer(TournamentUser user, Action success = null, Action failure = null, bool immediate = false)
|
||||
{
|
||||
var req = new GetUserRequest(user.Id, ladder.Ruleset.Value);
|
||||
var req = new GetUserRequest(user.OnlineID, ladder.Ruleset.Value);
|
||||
|
||||
if (immediate)
|
||||
{
|
||||
@ -273,7 +270,7 @@ namespace osu.Game.Tournament
|
||||
req.Success += res => { populate(); };
|
||||
req.Failure += _ =>
|
||||
{
|
||||
user.Id = 1;
|
||||
user.OnlineID = 1;
|
||||
failure?.Invoke();
|
||||
};
|
||||
|
||||
@ -287,12 +284,12 @@ namespace osu.Game.Tournament
|
||||
if (res == null)
|
||||
return;
|
||||
|
||||
user.Id = res.Id;
|
||||
user.OnlineID = res.Id;
|
||||
|
||||
user.Username = res.Username;
|
||||
user.Statistics = res.Statistics;
|
||||
user.CoverUrl = res.CoverUrl;
|
||||
user.Country = res.Country;
|
||||
user.Cover = res.Cover;
|
||||
user.Rank = res.Statistics?.GlobalRank;
|
||||
|
||||
success?.Invoke();
|
||||
}
|
||||
|
@ -637,6 +637,12 @@ namespace osu.Game
|
||||
Add(performFromMainMenuTask = new PerformFromMenuRunner(action, validScreens, () => ScreenStack.CurrentScreen));
|
||||
}
|
||||
|
||||
public override void AttemptExit()
|
||||
{
|
||||
// Using PerformFromScreen gives the user a chance to interrupt the exit process if needed.
|
||||
PerformFromScreen(menu => menu.Exit());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wait for the game (and target component) to become loaded and then run an action.
|
||||
/// </summary>
|
||||
|
@ -417,14 +417,15 @@ namespace osu.Game
|
||||
|
||||
/// <summary>
|
||||
/// Use to programatically exit the game as if the user was triggering via alt-f4.
|
||||
/// Will keep persisting until an exit occurs (exit may be blocked multiple times).
|
||||
/// By default, will keep persisting until an exit occurs (exit may be blocked multiple times).
|
||||
/// May be interrupted (see <see cref="OsuGame"/>'s override).
|
||||
/// </summary>
|
||||
public void GracefullyExit()
|
||||
public virtual void AttemptExit()
|
||||
{
|
||||
if (!OnExiting())
|
||||
Exit();
|
||||
else
|
||||
Scheduler.AddDelayed(GracefullyExit, 2000);
|
||||
Scheduler.AddDelayed(AttemptExit, 2000);
|
||||
}
|
||||
|
||||
public bool Migrate(string path)
|
||||
|
@ -56,7 +56,7 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
|
||||
dialogOverlay.Push(new ConfirmDialog("To complete this operation, osu! will close. Please open it again to use the new data location.", () =>
|
||||
{
|
||||
(storage as OsuStorage)?.ChangeDataPath(target.FullName);
|
||||
game.GracefullyExit();
|
||||
game.Exit();
|
||||
}, () => { }));
|
||||
},
|
||||
() => { }));
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
@ -73,6 +74,10 @@ namespace osu.Game.Rulesets.Edit
|
||||
/// <param name="commitStart">Whether this call is committing a value for HitObject.StartTime and continuing with further adjustments.</param>
|
||||
protected void BeginPlacement(bool commitStart = false)
|
||||
{
|
||||
var nearestSampleControlPoint = beatmap.HitObjects.LastOrDefault(h => h.GetEndTime() < HitObject.StartTime)?.SampleControlPoint?.DeepClone() as SampleControlPoint;
|
||||
|
||||
HitObject.SampleControlPoint = nearestSampleControlPoint ?? new SampleControlPoint();
|
||||
|
||||
placementHandler.BeginPlacement(HitObject);
|
||||
if (commitStart)
|
||||
PlacementActive = PlacementState.Active;
|
||||
|
@ -108,13 +108,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
/// </summary>
|
||||
protected virtual bool AllowDeselectionDuringDrag => true;
|
||||
|
||||
/// <remarks>
|
||||
/// Positional input must be received outside the container's bounds,
|
||||
/// in order to handle blueprints which are partially offscreen.
|
||||
/// </remarks>
|
||||
/// <seealso cref="SelectionHandler{T}.ReceivePositionalInputAt"/>
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
|
||||
|
||||
protected override bool OnMouseDown(MouseDownEvent e)
|
||||
{
|
||||
bool selectionPerformed = performMouseDownActions(e);
|
||||
|
@ -39,6 +39,12 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
private PlacementBlueprint currentPlacement;
|
||||
private InputManager inputManager;
|
||||
|
||||
/// <remarks>
|
||||
/// Positional input must be received outside the container's bounds,
|
||||
/// in order to handle composer blueprints which are partially offscreen.
|
||||
/// </remarks>
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
|
||||
|
||||
public ComposeBlueprintContainer(HitObjectComposer composer)
|
||||
: base(composer)
|
||||
{
|
||||
|
@ -21,6 +21,7 @@ using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Input.Bindings;
|
||||
using osu.Game.Resources.Localisation.Web;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Screens.Edit.Compose.Components.Timeline;
|
||||
using osuTK;
|
||||
using osuTK.Input;
|
||||
|
||||
@ -103,7 +104,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
/// Positional input must be received outside the container's bounds,
|
||||
/// in order to handle blueprints which are partially offscreen.
|
||||
/// </remarks>
|
||||
/// <seealso cref="BlueprintContainer{T}.ReceivePositionalInputAt"/>
|
||||
/// <seealso cref="ComposeBlueprintContainer.ReceivePositionalInputAt"/>
|
||||
/// <seealso cref="TimelineBlueprintContainer.ReceivePositionalInputAt"/>
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
|
||||
|
||||
/// <summary>
|
||||
|
@ -35,6 +35,12 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
private Bindable<HitObject> placement;
|
||||
private SelectionBlueprint<HitObject> placementBlueprint;
|
||||
|
||||
/// <remarks>
|
||||
/// Positional input must be received outside the container's bounds,
|
||||
/// in order to handle timeline blueprints which are stacked offscreen.
|
||||
/// </remarks>
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => timeline.ReceivePositionalInputAt(screenSpacePos);
|
||||
|
||||
public TimelineBlueprintContainer(HitObjectComposer composer)
|
||||
: base(composer)
|
||||
{
|
||||
|
@ -65,6 +65,8 @@ namespace osu.Game.Screens.Edit
|
||||
base.LoadComplete();
|
||||
|
||||
// will be restored via lease, see `DisallowExternalBeatmapRulesetChanges`.
|
||||
if (!(Beatmap.Value is DummyWorkingBeatmap))
|
||||
Ruleset.Value = Beatmap.Value.BeatmapInfo.Ruleset;
|
||||
Mods.Value = Array.Empty<Mod>();
|
||||
}
|
||||
|
||||
|
@ -1,92 +0,0 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Graphics.UserInterfaceV2;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Setup
|
||||
{
|
||||
/// <summary>
|
||||
/// A labelled textbox which reveals an inline file chooser when clicked.
|
||||
/// </summary>
|
||||
internal class FileChooserLabelledTextBox : LabelledTextBoxWithPopover, ICanAcceptFiles
|
||||
{
|
||||
private readonly string[] handledExtensions;
|
||||
|
||||
public IEnumerable<string> HandledExtensions => handledExtensions;
|
||||
|
||||
private readonly Bindable<FileInfo?> currentFile = new Bindable<FileInfo?>();
|
||||
|
||||
[Resolved]
|
||||
private OsuGameBase game { get; set; } = null!;
|
||||
|
||||
public FileChooserLabelledTextBox(params string[] handledExtensions)
|
||||
{
|
||||
this.handledExtensions = handledExtensions;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
game.RegisterImportHandler(this);
|
||||
currentFile.BindValueChanged(onFileSelected);
|
||||
}
|
||||
|
||||
private void onFileSelected(ValueChangedEvent<FileInfo?> file)
|
||||
{
|
||||
if (file.NewValue == null)
|
||||
return;
|
||||
|
||||
this.HidePopover();
|
||||
Current.Value = file.NewValue.FullName;
|
||||
}
|
||||
|
||||
Task ICanAcceptFiles.Import(params string[] paths)
|
||||
{
|
||||
Schedule(() => currentFile.Value = new FileInfo(paths.First()));
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
Task ICanAcceptFiles.Import(params ImportTask[] tasks) => throw new NotImplementedException();
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
|
||||
if (game.IsNotNull())
|
||||
game.UnregisterImportHandler(this);
|
||||
}
|
||||
|
||||
public override Popover GetPopover() => new FileChooserPopover(handledExtensions, currentFile);
|
||||
|
||||
private class FileChooserPopover : OsuPopover
|
||||
{
|
||||
public FileChooserPopover(string[] handledExtensions, Bindable<FileInfo?> currentFile)
|
||||
{
|
||||
Child = new Container
|
||||
{
|
||||
Size = new Vector2(600, 400),
|
||||
Child = new OsuFileSelector(currentFile.Value?.DirectoryName, handledExtensions)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
CurrentFile = { BindTarget = currentFile }
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
131
osu.Game/Screens/Edit/Setup/LabelledFileChooser.cs
Normal file
131
osu.Game/Screens/Edit/Setup/LabelledFileChooser.cs
Normal file
@ -0,0 +1,131 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Graphics.UserInterfaceV2;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Setup
|
||||
{
|
||||
/// <summary>
|
||||
/// A labelled drawable displaying file chooser on click, with placeholder text support.
|
||||
/// todo: this should probably not use PopoverTextBox just to display placeholder text, but is the best way for now.
|
||||
/// </summary>
|
||||
internal class LabelledFileChooser : LabelledDrawable<LabelledTextBoxWithPopover.PopoverTextBox>, IHasCurrentValue<FileInfo?>, ICanAcceptFiles, IHasPopover
|
||||
{
|
||||
private readonly string[] handledExtensions;
|
||||
|
||||
public IEnumerable<string> HandledExtensions => handledExtensions;
|
||||
|
||||
[Resolved]
|
||||
private OsuGameBase game { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// The initial path to use when displaying the <see cref="FileChooserPopover"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Uses a <see langword="null"/> value before the first selection is made
|
||||
/// to ensure that the first selection starts at <see cref="GameHost.InitialFileSelectorPath"/>.
|
||||
/// </remarks>
|
||||
private string? initialChooserPath;
|
||||
|
||||
private readonly BindableWithCurrent<FileInfo?> current = new BindableWithCurrent<FileInfo?>();
|
||||
|
||||
public Bindable<FileInfo?> Current
|
||||
{
|
||||
get => current.Current;
|
||||
set => current.Current = value;
|
||||
}
|
||||
|
||||
public LocalisableString Text
|
||||
{
|
||||
get => Component.PlaceholderText;
|
||||
set => Component.PlaceholderText = value;
|
||||
}
|
||||
|
||||
public CompositeDrawable TabbableContentContainer
|
||||
{
|
||||
set => Component.TabbableContentContainer = value;
|
||||
}
|
||||
|
||||
public LabelledFileChooser(params string[] handledExtensions)
|
||||
: base(false)
|
||||
{
|
||||
this.handledExtensions = handledExtensions;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
game.RegisterImportHandler(this);
|
||||
Current.BindValueChanged(onFileSelected);
|
||||
}
|
||||
|
||||
private void onFileSelected(ValueChangedEvent<FileInfo?> file)
|
||||
{
|
||||
if (file.NewValue != null)
|
||||
this.HidePopover();
|
||||
|
||||
initialChooserPath = file.NewValue?.DirectoryName;
|
||||
}
|
||||
|
||||
Task ICanAcceptFiles.Import(params string[] paths)
|
||||
{
|
||||
Schedule(() => Current.Value = new FileInfo(paths.First()));
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
Task ICanAcceptFiles.Import(params ImportTask[] tasks) => throw new NotImplementedException();
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
|
||||
if (game.IsNotNull())
|
||||
game.UnregisterImportHandler(this);
|
||||
}
|
||||
|
||||
protected override LabelledTextBoxWithPopover.PopoverTextBox CreateComponent() => new LabelledTextBoxWithPopover.PopoverTextBox
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
CornerRadius = CORNER_RADIUS,
|
||||
OnFocused = this.ShowPopover,
|
||||
};
|
||||
|
||||
public Popover GetPopover() => new FileChooserPopover(handledExtensions, Current, initialChooserPath);
|
||||
|
||||
private class FileChooserPopover : OsuPopover
|
||||
{
|
||||
public FileChooserPopover(string[] handledExtensions, Bindable<FileInfo?> currentFile, string? chooserPath)
|
||||
{
|
||||
Child = new Container
|
||||
{
|
||||
Size = new Vector2(600, 400),
|
||||
Child = new OsuFileSelector(chooserPath, handledExtensions)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
CurrentFile = { BindTarget = currentFile }
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -10,15 +10,14 @@ using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.UserInterfaceV2;
|
||||
using osu.Game.Overlays;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Setup
|
||||
{
|
||||
internal class ResourcesSection : SetupSection
|
||||
{
|
||||
private LabelledTextBox audioTrackTextBox;
|
||||
private LabelledTextBox backgroundTextBox;
|
||||
private LabelledFileChooser audioTrackChooser;
|
||||
private LabelledFileChooser backgroundChooser;
|
||||
|
||||
public override LocalisableString Title => "Resources";
|
||||
|
||||
@ -42,76 +41,81 @@ namespace osu.Game.Screens.Edit.Setup
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
backgroundTextBox = new FileChooserLabelledTextBox(".jpg", ".jpeg", ".png")
|
||||
backgroundChooser = new LabelledFileChooser(".jpg", ".jpeg", ".png")
|
||||
{
|
||||
Label = "Background",
|
||||
FixedLabelWidth = LABEL_WIDTH,
|
||||
PlaceholderText = "Click to select a background image",
|
||||
Current = { Value = working.Value.Metadata.BackgroundFile },
|
||||
TabbableContentContainer = this
|
||||
},
|
||||
audioTrackTextBox = new FileChooserLabelledTextBox(".mp3", ".ogg")
|
||||
audioTrackChooser = new LabelledFileChooser(".mp3", ".ogg")
|
||||
{
|
||||
Label = "Audio Track",
|
||||
FixedLabelWidth = LABEL_WIDTH,
|
||||
PlaceholderText = "Click to select a track",
|
||||
Current = { Value = working.Value.Metadata.AudioFile },
|
||||
TabbableContentContainer = this
|
||||
},
|
||||
};
|
||||
|
||||
backgroundTextBox.Current.BindValueChanged(backgroundChanged);
|
||||
audioTrackTextBox.Current.BindValueChanged(audioTrackChanged);
|
||||
if (!string.IsNullOrEmpty(working.Value.Metadata.BackgroundFile))
|
||||
backgroundChooser.Current.Value = new FileInfo(working.Value.Metadata.BackgroundFile);
|
||||
|
||||
if (!string.IsNullOrEmpty(working.Value.Metadata.AudioFile))
|
||||
audioTrackChooser.Current.Value = new FileInfo(working.Value.Metadata.AudioFile);
|
||||
|
||||
backgroundChooser.Current.BindValueChanged(backgroundChanged);
|
||||
audioTrackChooser.Current.BindValueChanged(audioTrackChanged);
|
||||
|
||||
updatePlaceholderText();
|
||||
}
|
||||
|
||||
public bool ChangeBackgroundImage(string path)
|
||||
public bool ChangeBackgroundImage(FileInfo source)
|
||||
{
|
||||
var info = new FileInfo(path);
|
||||
|
||||
if (!info.Exists)
|
||||
if (!source.Exists)
|
||||
return false;
|
||||
|
||||
var set = working.Value.BeatmapSetInfo;
|
||||
|
||||
var destination = new FileInfo($@"bg{source.Extension}");
|
||||
|
||||
// remove the previous background for now.
|
||||
// in the future we probably want to check if this is being used elsewhere (other difficulties?)
|
||||
var oldFile = set.Files.FirstOrDefault(f => f.Filename == working.Value.Metadata.BackgroundFile);
|
||||
|
||||
using (var stream = info.OpenRead())
|
||||
using (var stream = source.OpenRead())
|
||||
{
|
||||
if (oldFile != null)
|
||||
beatmaps.DeleteFile(set, oldFile);
|
||||
|
||||
beatmaps.AddFile(set, stream, info.Name);
|
||||
beatmaps.AddFile(set, stream, destination.Name);
|
||||
}
|
||||
|
||||
working.Value.Metadata.BackgroundFile = info.Name;
|
||||
working.Value.Metadata.BackgroundFile = destination.Name;
|
||||
header.Background.UpdateBackground();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool ChangeAudioTrack(string path)
|
||||
public bool ChangeAudioTrack(FileInfo source)
|
||||
{
|
||||
var info = new FileInfo(path);
|
||||
|
||||
if (!info.Exists)
|
||||
if (!source.Exists)
|
||||
return false;
|
||||
|
||||
var set = working.Value.BeatmapSetInfo;
|
||||
|
||||
var destination = new FileInfo($@"audio{source.Extension}");
|
||||
|
||||
// remove the previous audio track for now.
|
||||
// in the future we probably want to check if this is being used elsewhere (other difficulties?)
|
||||
var oldFile = set.Files.FirstOrDefault(f => f.Filename == working.Value.Metadata.AudioFile);
|
||||
|
||||
using (var stream = info.OpenRead())
|
||||
using (var stream = source.OpenRead())
|
||||
{
|
||||
if (oldFile != null)
|
||||
beatmaps.DeleteFile(set, oldFile);
|
||||
beatmaps.AddFile(set, stream, info.Name);
|
||||
|
||||
beatmaps.AddFile(set, stream, destination.Name);
|
||||
}
|
||||
|
||||
working.Value.Metadata.AudioFile = info.Name;
|
||||
working.Value.Metadata.AudioFile = destination.Name;
|
||||
|
||||
music.ReloadCurrentTrack();
|
||||
|
||||
@ -119,16 +123,31 @@ namespace osu.Game.Screens.Edit.Setup
|
||||
return true;
|
||||
}
|
||||
|
||||
private void backgroundChanged(ValueChangedEvent<string> filePath)
|
||||
private void backgroundChanged(ValueChangedEvent<FileInfo> file)
|
||||
{
|
||||
if (!ChangeBackgroundImage(filePath.NewValue))
|
||||
backgroundTextBox.Current.Value = filePath.OldValue;
|
||||
if (!ChangeBackgroundImage(file.NewValue))
|
||||
backgroundChooser.Current.Value = file.OldValue;
|
||||
|
||||
updatePlaceholderText();
|
||||
}
|
||||
|
||||
private void audioTrackChanged(ValueChangedEvent<string> filePath)
|
||||
private void audioTrackChanged(ValueChangedEvent<FileInfo> file)
|
||||
{
|
||||
if (!ChangeAudioTrack(filePath.NewValue))
|
||||
audioTrackTextBox.Current.Value = filePath.OldValue;
|
||||
if (!ChangeAudioTrack(file.NewValue))
|
||||
audioTrackChooser.Current.Value = file.OldValue;
|
||||
|
||||
updatePlaceholderText();
|
||||
}
|
||||
|
||||
private void updatePlaceholderText()
|
||||
{
|
||||
audioTrackChooser.Text = audioTrackChooser.Current.Value == null
|
||||
? "Click to select a track"
|
||||
: "Click to replace the track";
|
||||
|
||||
backgroundChooser.Text = backgroundChooser.Current.Value == null
|
||||
? "Click to select a background image"
|
||||
: "Click to replace the background image";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
@ -14,6 +15,7 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
@ -37,6 +39,9 @@ namespace osu.Game.Screens.Edit.Timing
|
||||
|
||||
private Sample clunk;
|
||||
|
||||
[CanBeNull]
|
||||
private ScheduledDelegate clunkDelegate;
|
||||
|
||||
[Resolved]
|
||||
private OverlayColourProvider overlayColourProvider { get; set; }
|
||||
|
||||
@ -258,6 +263,9 @@ namespace osu.Game.Screens.Edit.Timing
|
||||
}
|
||||
|
||||
isSwinging = false;
|
||||
|
||||
clunkDelegate?.Cancel();
|
||||
clunkDelegate = null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -283,7 +291,7 @@ namespace osu.Game.Screens.Edit.Timing
|
||||
{
|
||||
stick.FlashColour(overlayColourProvider.Content1, beatLength, Easing.OutQuint);
|
||||
|
||||
Schedule(() =>
|
||||
clunkDelegate = Schedule(() =>
|
||||
{
|
||||
if (!EnableClicking)
|
||||
return;
|
||||
|
@ -195,6 +195,8 @@ namespace osu.Game.Screens.Edit.Timing
|
||||
|
||||
private void adjustOffset(double adjust)
|
||||
{
|
||||
bool wasAtStart = editorClock.CurrentTimeAccurate == selectedGroup.Value.Time;
|
||||
|
||||
// VERY TEMPORARY
|
||||
var currentGroupItems = selectedGroup.Value.ControlPoints.ToArray();
|
||||
|
||||
@ -208,7 +210,7 @@ namespace osu.Game.Screens.Edit.Timing
|
||||
// the control point might not necessarily exist yet, if currentGroupItems was empty.
|
||||
selectedGroup.Value = beatmap.ControlPointInfo.GroupAt(newOffset, true);
|
||||
|
||||
if (!editorClock.IsRunning)
|
||||
if (!editorClock.IsRunning && wasAtStart)
|
||||
editorClock.Seek(newOffset);
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
// 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 System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
@ -20,11 +20,16 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
public class MultiplayerMatchSongSelect : OnlinePlaySongSelect
|
||||
{
|
||||
[Resolved]
|
||||
private MultiplayerClient client { get; set; }
|
||||
private MultiplayerClient client { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private OngoingOperationTracker operationTracker { get; set; } = null!;
|
||||
|
||||
private readonly IBindable<bool> operationInProgress = new Bindable<bool>();
|
||||
private readonly long? itemToEdit;
|
||||
|
||||
private LoadingLayer loadingLayer;
|
||||
private LoadingLayer loadingLayer = null!;
|
||||
private IDisposable? selectionOperation;
|
||||
|
||||
/// <summary>
|
||||
/// Construct a new instance of multiplayer song select.
|
||||
@ -33,7 +38,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
/// <param name="itemToEdit">The item to be edited. May be null, in which case a new item will be added to the playlist.</param>
|
||||
/// <param name="beatmap">An optional initial beatmap selection to perform.</param>
|
||||
/// <param name="ruleset">An optional initial ruleset selection to perform.</param>
|
||||
public MultiplayerMatchSongSelect(Room room, long? itemToEdit = null, WorkingBeatmap beatmap = null, RulesetInfo ruleset = null)
|
||||
public MultiplayerMatchSongSelect(Room room, long? itemToEdit = null, WorkingBeatmap? beatmap = null, RulesetInfo? ruleset = null)
|
||||
: base(room)
|
||||
{
|
||||
this.itemToEdit = itemToEdit;
|
||||
@ -54,13 +59,32 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
AddInternal(loadingLayer = new LoadingLayer(true));
|
||||
}
|
||||
|
||||
protected override void SelectItem(PlaylistItem item)
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
operationInProgress.BindTo(operationTracker.InProgress);
|
||||
operationInProgress.BindValueChanged(_ => updateLoadingLayer(), true);
|
||||
}
|
||||
|
||||
private void updateLoadingLayer()
|
||||
{
|
||||
if (operationInProgress.Value)
|
||||
loadingLayer.Show();
|
||||
else
|
||||
loadingLayer.Hide();
|
||||
}
|
||||
|
||||
protected override bool SelectItem(PlaylistItem item)
|
||||
{
|
||||
if (operationInProgress.Value)
|
||||
return false;
|
||||
|
||||
// If the client is already in a room, update via the client.
|
||||
// Otherwise, update the playlist directly in preparation for it to be submitted to the API on match creation.
|
||||
if (client.Room != null)
|
||||
{
|
||||
loadingLayer.Show();
|
||||
selectionOperation = operationTracker.BeginOperation();
|
||||
|
||||
var multiplayerItem = new MultiplayerPlaylistItem
|
||||
{
|
||||
@ -74,18 +98,25 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
|
||||
Task task = itemToEdit != null ? client.EditPlaylistItem(multiplayerItem) : client.AddPlaylistItem(multiplayerItem);
|
||||
|
||||
task.FireAndForget(onSuccess: () => Schedule(() =>
|
||||
task.FireAndForget(onSuccess: () =>
|
||||
{
|
||||
loadingLayer.Hide();
|
||||
selectionOperation.Dispose();
|
||||
|
||||
Schedule(() =>
|
||||
{
|
||||
// If an error or server side trigger occurred this screen may have already exited by external means.
|
||||
if (this.IsCurrentScreen())
|
||||
this.Exit();
|
||||
}), onError: _ => Schedule(() =>
|
||||
});
|
||||
}, onError: _ =>
|
||||
{
|
||||
selectionOperation.Dispose();
|
||||
|
||||
Schedule(() =>
|
||||
{
|
||||
loadingLayer.Hide();
|
||||
Carousel.AllowSelection = true;
|
||||
}));
|
||||
});
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -93,6 +124,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
Playlist.Add(item);
|
||||
this.Exit();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override BeatmapDetailArea CreateBeatmapDetailArea() => new PlayBeatmapDetailArea();
|
||||
|
@ -118,8 +118,6 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
|
||||
protected sealed override bool OnStart()
|
||||
{
|
||||
itemSelected = true;
|
||||
|
||||
var item = new PlaylistItem(Beatmap.Value.BeatmapInfo)
|
||||
{
|
||||
RulesetID = Ruleset.Value.OnlineID,
|
||||
@ -127,15 +125,21 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
AllowedMods = FreeMods.Value.Select(m => new APIMod(m)).ToArray()
|
||||
};
|
||||
|
||||
SelectItem(item);
|
||||
if (SelectItem(item))
|
||||
{
|
||||
itemSelected = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when the user has requested a selection of a beatmap.
|
||||
/// </summary>
|
||||
/// <param name="item">The resultant <see cref="PlaylistItem"/>. This item has not yet been added to the <see cref="Room"/>'s.</param>
|
||||
protected abstract void SelectItem(PlaylistItem item);
|
||||
/// <returns><c>true</c> if a selection occurred.</returns>
|
||||
protected abstract bool SelectItem(PlaylistItem item);
|
||||
|
||||
public override bool OnBackButton()
|
||||
{
|
||||
|
@ -24,7 +24,7 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
CreateNewItem = createNewItem
|
||||
};
|
||||
|
||||
protected override void SelectItem(PlaylistItem item)
|
||||
protected override bool SelectItem(PlaylistItem item)
|
||||
{
|
||||
switch (Playlist.Count)
|
||||
{
|
||||
@ -39,6 +39,7 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
}
|
||||
|
||||
this.Exit();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void createNewItem()
|
||||
|
@ -786,7 +786,17 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
Ruleset.ValueChanged += r => updateSelectedRuleset(r.NewValue);
|
||||
|
||||
decoupledRuleset.ValueChanged += r => Ruleset.Value = r.NewValue;
|
||||
decoupledRuleset.ValueChanged += r =>
|
||||
{
|
||||
bool wasDisabled = Ruleset.Disabled;
|
||||
|
||||
// a sub-screen may have taken a lease on this decoupled ruleset bindable,
|
||||
// which would indirectly propagate to the game-global bindable via the `DisabledChanged` callback below.
|
||||
// to make sure changes sync without crashes, lift the disable for a short while to sync, and then restore the old value.
|
||||
Ruleset.Disabled = false;
|
||||
Ruleset.Value = r.NewValue;
|
||||
Ruleset.Disabled = wasDisabled;
|
||||
};
|
||||
decoupledRuleset.DisabledChanged += r => Ruleset.Disabled = r;
|
||||
|
||||
Beatmap.BindValueChanged(workingBeatmapChanged);
|
||||
|
@ -6,8 +6,10 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics.Cursor;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Screens.Utility.SampleComponents;
|
||||
using osuTK.Input;
|
||||
@ -15,7 +17,7 @@ using osuTK.Input;
|
||||
namespace osu.Game.Screens.Utility
|
||||
{
|
||||
[Cached]
|
||||
public class LatencyArea : CompositeDrawable
|
||||
public class LatencyArea : CompositeDrawable, IProvideCursor
|
||||
{
|
||||
[Resolved]
|
||||
private OverlayColourProvider overlayColourProvider { get; set; } = null!;
|
||||
@ -34,6 +36,10 @@ namespace osu.Game.Screens.Utility
|
||||
|
||||
public readonly Bindable<LatencyVisualMode> VisualMode = new Bindable<LatencyVisualMode>();
|
||||
|
||||
public CursorContainer? Cursor { get; private set; }
|
||||
|
||||
public bool ProvidingUserCursor => IsActiveArea.Value;
|
||||
|
||||
public LatencyArea(Key key, int? targetFrameRate)
|
||||
{
|
||||
this.key = key;
|
||||
@ -85,7 +91,7 @@ namespace osu.Game.Screens.Utility
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
new LatencyCursorContainer
|
||||
Cursor = new LatencyCursorContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
@ -99,7 +105,7 @@ namespace osu.Game.Screens.Utility
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
new LatencyCursorContainer
|
||||
Cursor = new LatencyCursorContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
@ -113,7 +119,7 @@ namespace osu.Game.Screens.Utility
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
new LatencyCursorContainer
|
||||
Cursor = new LatencyCursorContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
|
@ -39,8 +39,6 @@ namespace osu.Game.Screens.Utility
|
||||
|
||||
public override bool HideOverlaysOnEnter => true;
|
||||
|
||||
public override bool CursorVisible => mainArea.Count == 0;
|
||||
|
||||
public override float BackgroundParallaxAmount => 0;
|
||||
|
||||
private readonly LinkFlowContainer explanatoryText;
|
||||
|
@ -1,55 +1,52 @@
|
||||
// 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;
|
||||
#nullable enable
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Input.States;
|
||||
using osu.Game.Overlays;
|
||||
using osuTK;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Screens.Utility.SampleComponents
|
||||
{
|
||||
public class LatencyCursorContainer : LatencySampleComponent
|
||||
public class LatencyCursorContainer : CursorContainer
|
||||
{
|
||||
private Circle cursor = null!;
|
||||
protected override Drawable CreateCursor() => new LatencyCursor();
|
||||
|
||||
[Resolved]
|
||||
private OverlayColourProvider overlayColourProvider { get; set; } = null!;
|
||||
public override bool IsPresent => base.IsPresent || Scheduler.HasPendingTasks;
|
||||
|
||||
public LatencyCursorContainer()
|
||||
{
|
||||
Masking = true;
|
||||
State.Value = Visibility.Hidden;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
InternalChild = cursor = new Circle
|
||||
{
|
||||
Size = new Vector2(40),
|
||||
Origin = Anchor.Centre,
|
||||
Colour = overlayColourProvider.Colour2,
|
||||
};
|
||||
// Scheduling is required to ensure updating of cursor position happens in limited rate.
|
||||
// We can alternatively solve this by a PassThroughInputManager layer inside LatencyArea,
|
||||
// but that would mean including input lag to this test, which may not be desired.
|
||||
Schedule(() => base.OnMouseMove(e));
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override bool OnHover(HoverEvent e) => false;
|
||||
private class LatencyCursor : LatencySampleComponent
|
||||
{
|
||||
public LatencyCursor()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
InternalChild = new Circle { Size = new Vector2(40) };
|
||||
}
|
||||
|
||||
protected override void UpdateAtLimitedRate(InputState inputState)
|
||||
{
|
||||
cursor.Colour = inputState.Mouse.IsPressed(MouseButton.Left) ? overlayColourProvider.Content1 : overlayColourProvider.Colour2;
|
||||
|
||||
if (IsActive.Value)
|
||||
{
|
||||
cursor.Position = ToLocalSpace(inputState.Mouse.Position);
|
||||
cursor.Alpha = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
cursor.Alpha = 0;
|
||||
Colour = inputState.Mouse.IsPressed(MouseButton.Left) ? OverlayColourProvider.Content1 : OverlayColourProvider.Colour2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user