mirror of
https://github.com/ppy/osu
synced 2024-12-29 02:12:43 +00:00
Merge branch 'master' into realm-move-data-migration-to-context-factory
This commit is contained in:
commit
c4b5a07f4b
@ -142,7 +142,7 @@ namespace osu.Game.Tests.Scores.IO
|
||||
var scoreManager = osu.Dependencies.Get<ScoreManager>();
|
||||
|
||||
beatmapManager.Delete(beatmapManager.QueryBeatmapSet(s => s.Beatmaps.Any(b => b.ID == imported.BeatmapInfo.ID)));
|
||||
Assert.That(scoreManager.Query(s => s.ID == imported.ID).DeletePending, Is.EqualTo(true));
|
||||
Assert.That(scoreManager.Query(s => s.Equals(imported)).DeletePending, Is.EqualTo(true));
|
||||
|
||||
var secondImport = await LoadScoreIntoOsu(osu, imported);
|
||||
Assert.That(secondImport, Is.Null);
|
||||
|
@ -39,7 +39,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
|
||||
PlaylistItem playlistItem = new PlaylistItem
|
||||
{
|
||||
BeatmapID = beatmapInfo.ID,
|
||||
BeatmapID = beatmapInfo.OnlineID ?? -1,
|
||||
};
|
||||
|
||||
Stack.Push(screen = new MultiplayerResultsScreen(score, 1, playlistItem));
|
||||
|
@ -43,7 +43,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
|
||||
PlaylistItem playlistItem = new PlaylistItem
|
||||
{
|
||||
BeatmapID = beatmapInfo.ID,
|
||||
BeatmapID = beatmapInfo.OnlineID ?? -1,
|
||||
};
|
||||
|
||||
SortedDictionary<int, BindableInt> teamScores = new SortedDictionary<int, BindableInt>
|
||||
|
@ -141,7 +141,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
|
||||
AddUntilStep("wait for song select", () => Game.ScreenStack.CurrentScreen is Screens.Select.SongSelect);
|
||||
AddUntilStep("correct beatmap displayed", () => Game.Beatmap.Value.BeatmapSetInfo.MatchesOnlineID(getImport()));
|
||||
AddAssert("correct ruleset selected", () => Game.Ruleset.Value.ID == getImport().Beatmaps.First().Ruleset.ID);
|
||||
AddAssert("correct ruleset selected", () => Game.Ruleset.Value.Equals(getImport().Beatmaps.First().Ruleset));
|
||||
}
|
||||
|
||||
private void presentSecondDifficultyAndConfirm(Func<BeatmapSetInfo> getImport, int importedID)
|
||||
@ -151,7 +151,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
|
||||
AddUntilStep("wait for song select", () => Game.ScreenStack.CurrentScreen is Screens.Select.SongSelect);
|
||||
AddUntilStep("correct beatmap displayed", () => Game.Beatmap.Value.BeatmapInfo.OnlineID == importedID * 2048);
|
||||
AddAssert("correct ruleset selected", () => Game.Ruleset.Value.ID == getImport().Beatmaps.First().Ruleset.ID);
|
||||
AddAssert("correct ruleset selected", () => Game.Ruleset.Value.Equals(getImport().Beatmaps.First().Ruleset));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -155,15 +155,15 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
case ScorePresentType.Results:
|
||||
AddUntilStep("wait for results", () => lastWaitedScreen != Game.ScreenStack.CurrentScreen && Game.ScreenStack.CurrentScreen is ResultsScreen);
|
||||
AddStep("store last waited screen", () => lastWaitedScreen = Game.ScreenStack.CurrentScreen);
|
||||
AddUntilStep("correct score displayed", () => ((ResultsScreen)Game.ScreenStack.CurrentScreen).Score.ID == getImport().ID);
|
||||
AddAssert("correct ruleset selected", () => Game.Ruleset.Value.ID == getImport().Ruleset.ID);
|
||||
AddUntilStep("correct score displayed", () => ((ResultsScreen)Game.ScreenStack.CurrentScreen).Score.Equals(getImport()));
|
||||
AddAssert("correct ruleset selected", () => Game.Ruleset.Value.Equals(getImport().Ruleset));
|
||||
break;
|
||||
|
||||
case ScorePresentType.Gameplay:
|
||||
AddUntilStep("wait for player loader", () => lastWaitedScreen != Game.ScreenStack.CurrentScreen && Game.ScreenStack.CurrentScreen is ReplayPlayerLoader);
|
||||
AddStep("store last waited screen", () => lastWaitedScreen = Game.ScreenStack.CurrentScreen);
|
||||
AddUntilStep("correct score displayed", () => ((ReplayPlayerLoader)Game.ScreenStack.CurrentScreen).Score.ID == getImport().ID);
|
||||
AddAssert("correct ruleset selected", () => Game.Ruleset.Value.ID == getImport().Ruleset.ID);
|
||||
AddUntilStep("correct score displayed", () => ((ReplayPlayerLoader)Game.ScreenStack.CurrentScreen).Score.Equals(getImport()));
|
||||
AddAssert("correct ruleset selected", () => Game.Ruleset.Value.Equals(getImport().Ruleset));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -340,8 +340,8 @@ namespace osu.Game.Beatmaps
|
||||
}
|
||||
|
||||
public bool Equals(DifficultyCacheLookup other)
|
||||
=> BeatmapInfo.ID == other.BeatmapInfo.ID
|
||||
&& Ruleset.ID == other.Ruleset.ID
|
||||
=> BeatmapInfo.Equals(other.BeatmapInfo)
|
||||
&& Ruleset.Equals(other.Ruleset)
|
||||
&& OrderedMods.SequenceEqual(other.OrderedMods);
|
||||
|
||||
public override int GetHashCode()
|
||||
|
@ -208,7 +208,7 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
using (ContextFactory.GetForWrite())
|
||||
{
|
||||
beatmapInfo = setInfo.Beatmaps.Single(b => b.ID == beatmapInfo.ID);
|
||||
beatmapInfo = setInfo.Beatmaps.Single(b => b.Equals(beatmapInfo));
|
||||
|
||||
var metadata = beatmapInfo.Metadata ?? setInfo.Metadata;
|
||||
|
||||
|
@ -117,7 +117,7 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
Spacing = new Vector2(1, 0);
|
||||
Direction = FillDirection.Horizontal;
|
||||
|
||||
var icon = rulesets.GetRuleset(rulesetId)?.CreateInstance()?.CreateIcon() ?? new SpriteIcon { Icon = FontAwesome.Regular.QuestionCircle };
|
||||
var icon = rulesets.GetRuleset(rulesetId)?.CreateInstance().CreateIcon() ?? new SpriteIcon { Icon = FontAwesome.Regular.QuestionCircle };
|
||||
Add(icon.With(i =>
|
||||
{
|
||||
i.Size = new Vector2(14);
|
||||
|
@ -65,7 +65,7 @@ namespace osu.Game.Beatmaps
|
||||
{
|
||||
lock (workingCache)
|
||||
{
|
||||
var working = workingCache.FirstOrDefault(w => w.BeatmapInfo?.ID == info.ID);
|
||||
var working = workingCache.FirstOrDefault(w => info.Equals(w.BeatmapInfo));
|
||||
|
||||
if (working != null)
|
||||
{
|
||||
@ -89,7 +89,7 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
lock (workingCache)
|
||||
{
|
||||
var working = workingCache.FirstOrDefault(w => w.BeatmapInfo?.ID == beatmapInfo.ID);
|
||||
var working = workingCache.FirstOrDefault(w => beatmapInfo.Equals(w.BeatmapInfo));
|
||||
|
||||
if (working != null)
|
||||
return working;
|
||||
|
@ -321,7 +321,6 @@ namespace osu.Game.Database
|
||||
break;
|
||||
|
||||
case 11:
|
||||
|
||||
string keyBindingClassName = getMappedOrOriginalName(typeof(RealmKeyBinding));
|
||||
|
||||
var oldKeyBindings = migration.OldRealm.DynamicApi.All(keyBindingClassName);
|
||||
|
@ -60,5 +60,27 @@ namespace osu.Game.Models
|
||||
InstantiationInfo = InstantiationInfo,
|
||||
Available = Available
|
||||
};
|
||||
|
||||
public Ruleset CreateInstance()
|
||||
{
|
||||
if (!Available)
|
||||
throw new RulesetLoadException(@"Ruleset not available");
|
||||
|
||||
var type = Type.GetType(InstantiationInfo);
|
||||
|
||||
if (type == null)
|
||||
throw new RulesetLoadException(@"Type lookup failure");
|
||||
|
||||
var ruleset = Activator.CreateInstance(type) as Ruleset;
|
||||
|
||||
if (ruleset == null)
|
||||
throw new RulesetLoadException(@"Instantiation failure");
|
||||
|
||||
// overwrite the pre-populated RulesetInfo with a potentially database attached copy.
|
||||
// TODO: figure if we still want/need this after switching to realm.
|
||||
// ruleset.RulesetInfo = this;
|
||||
|
||||
return ruleset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ namespace osu.Game
|
||||
SkinManager.ItemRemoved += item => Schedule(() =>
|
||||
{
|
||||
// check the removed skin is not the current user choice. if it is, switch back to default.
|
||||
if (item.ID == SkinManager.CurrentSkinInfo.Value.ID)
|
||||
if (item.Equals(SkinManager.CurrentSkinInfo.Value))
|
||||
SkinManager.CurrentSkinInfo.Value = SkinInfo.Default;
|
||||
});
|
||||
|
||||
|
@ -114,7 +114,7 @@ namespace osu.Game.Overlays.Music
|
||||
|
||||
private void itemSelected(BeatmapSetInfo set)
|
||||
{
|
||||
if (set.ID == (beatmap.Value?.BeatmapSetInfo?.ID ?? -1))
|
||||
if (set.Equals((beatmap.Value?.BeatmapSetInfo)))
|
||||
{
|
||||
beatmap.Value?.Track.Seek(0);
|
||||
return;
|
||||
|
@ -111,7 +111,7 @@ namespace osu.Game.Overlays
|
||||
beatmapSets.Add(set);
|
||||
});
|
||||
|
||||
private void beatmapRemoved(BeatmapSetInfo set) => Schedule(() => beatmapSets.RemoveAll(s => s.ID == set.ID));
|
||||
private void beatmapRemoved(BeatmapSetInfo set) => Schedule(() => beatmapSets.RemoveAll(s => s.Equals(set)));
|
||||
|
||||
private ScheduledDelegate seekDelegate;
|
||||
|
||||
@ -228,7 +228,7 @@ namespace osu.Game.Overlays
|
||||
|
||||
queuedDirection = TrackChangeDirection.Prev;
|
||||
|
||||
var playable = BeatmapSets.TakeWhile(i => i.ID != current.BeatmapSetInfo.ID).LastOrDefault() ?? BeatmapSets.LastOrDefault();
|
||||
var playable = BeatmapSets.TakeWhile(i => !i.Equals(current.BeatmapSetInfo)).LastOrDefault() ?? BeatmapSets.LastOrDefault();
|
||||
|
||||
if (playable != null)
|
||||
{
|
||||
@ -259,7 +259,7 @@ namespace osu.Game.Overlays
|
||||
|
||||
queuedDirection = TrackChangeDirection.Next;
|
||||
|
||||
var playable = BeatmapSets.SkipWhile(i => i.ID != current.BeatmapSetInfo.ID).ElementAtOrDefault(1) ?? BeatmapSets.FirstOrDefault();
|
||||
var playable = BeatmapSets.SkipWhile(i => !i.Equals(current.BeatmapSetInfo)).ElementAtOrDefault(1) ?? BeatmapSets.FirstOrDefault();
|
||||
|
||||
if (playable != null)
|
||||
{
|
||||
@ -309,8 +309,8 @@ namespace osu.Game.Overlays
|
||||
else
|
||||
{
|
||||
// figure out the best direction based on order in playlist.
|
||||
int last = BeatmapSets.TakeWhile(b => b.ID != current.BeatmapSetInfo?.ID).Count();
|
||||
int next = newWorking == null ? -1 : BeatmapSets.TakeWhile(b => b.ID != newWorking.BeatmapSetInfo?.ID).Count();
|
||||
int last = BeatmapSets.TakeWhile(b => !b.Equals(current.BeatmapSetInfo)).Count();
|
||||
int next = newWorking == null ? -1 : BeatmapSets.TakeWhile(b => !b.Equals(newWorking.BeatmapSetInfo)).Count();
|
||||
|
||||
direction = last > next ? TrackChangeDirection.Prev : TrackChangeDirection.Next;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
||||
public void SetDefaultRuleset(RulesetInfo ruleset)
|
||||
{
|
||||
foreach (var tabItem in TabContainer)
|
||||
((ProfileRulesetTabItem)tabItem).IsDefault = ((ProfileRulesetTabItem)tabItem).Value.ID == ruleset.ID;
|
||||
((ProfileRulesetTabItem)tabItem).IsDefault = ((ProfileRulesetTabItem)tabItem).Value.Equals(ruleset);
|
||||
}
|
||||
|
||||
protected override TabItem<RulesetInfo> CreateTabItem(RulesetInfo value) => new ProfileRulesetTabItem(value);
|
||||
|
@ -11,7 +11,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
{
|
||||
public class RulesetBindingsSection : SettingsSection
|
||||
{
|
||||
public override Drawable CreateIcon() => ruleset?.CreateInstance()?.CreateIcon() ?? new SpriteIcon
|
||||
public override Drawable CreateIcon() => ruleset?.CreateInstance().CreateIcon() ?? new SpriteIcon
|
||||
{
|
||||
Icon = OsuIcon.Hot
|
||||
};
|
||||
|
@ -132,7 +132,7 @@ namespace osu.Game.Overlays.Settings.Sections
|
||||
skinDropdown.Items = newDropdownItems;
|
||||
}
|
||||
|
||||
private void itemRemoved(SkinInfo item) => Schedule(() => skinDropdown.Items = skinDropdown.Items.Where(i => i.ID != item.ID).ToArray());
|
||||
private void itemRemoved(SkinInfo item) => Schedule(() => skinDropdown.Items = skinDropdown.Items.Where(i => !i.Equals(item)).ToArray());
|
||||
|
||||
private void sortUserSkins(List<SkinInfo> skinsList)
|
||||
{
|
||||
|
@ -1,7 +1,6 @@
|
||||
// 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.Game.Database;
|
||||
|
||||
#nullable enable
|
||||
@ -28,20 +27,6 @@ namespace osu.Game.Rulesets
|
||||
/// </summary>
|
||||
string InstantiationInfo { get; }
|
||||
|
||||
Ruleset? CreateInstance()
|
||||
{
|
||||
var type = Type.GetType(InstantiationInfo);
|
||||
|
||||
if (type == null)
|
||||
return null;
|
||||
|
||||
var ruleset = Activator.CreateInstance(type) as Ruleset;
|
||||
|
||||
// overwrite the pre-populated RulesetInfo with a potentially database attached copy.
|
||||
// TODO: figure if we still want/need this after switching to realm.
|
||||
// ruleset.RulesetInfo = this;
|
||||
|
||||
return ruleset;
|
||||
}
|
||||
Ruleset CreateInstance();
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Framework.Testing;
|
||||
|
||||
namespace osu.Game.Rulesets
|
||||
@ -26,9 +25,18 @@ namespace osu.Game.Rulesets
|
||||
// TODO: this should probably be moved to RulesetStore.
|
||||
public Ruleset CreateInstance()
|
||||
{
|
||||
if (!Available) return null;
|
||||
if (!Available)
|
||||
throw new RulesetLoadException(@"Ruleset not available");
|
||||
|
||||
var ruleset = (Ruleset)Activator.CreateInstance(Type.GetType(InstantiationInfo).AsNonNull());
|
||||
var type = Type.GetType(InstantiationInfo);
|
||||
|
||||
if (type == null)
|
||||
throw new RulesetLoadException(@"Type lookup failure");
|
||||
|
||||
var ruleset = Activator.CreateInstance(type) as Ruleset;
|
||||
|
||||
if (ruleset == null)
|
||||
throw new RulesetLoadException(@"Instantiation failure");
|
||||
|
||||
// overwrite the pre-populated RulesetInfo with a potentially database attached copy.
|
||||
ruleset.RulesetInfo = this;
|
||||
|
@ -33,7 +33,7 @@ namespace osu.Game.Screens.Edit.Setup
|
||||
new DesignSection(),
|
||||
};
|
||||
|
||||
var rulesetSpecificSection = beatmap.BeatmapInfo.Ruleset?.CreateInstance()?.CreateEditorSetupSection();
|
||||
var rulesetSpecificSection = beatmap.BeatmapInfo.Ruleset?.CreateInstance().CreateEditorSetupSection();
|
||||
if (rulesetSpecificSection != null)
|
||||
sectionsEnumerable.Add(rulesetSpecificSection);
|
||||
|
||||
|
@ -43,7 +43,7 @@ namespace osu.Game.Screens.Edit.Verify
|
||||
private void load(OverlayColourProvider colours)
|
||||
{
|
||||
generalVerifier = new BeatmapVerifier();
|
||||
rulesetVerifier = beatmap.BeatmapInfo.Ruleset?.CreateInstance()?.CreateBeatmapVerifier();
|
||||
rulesetVerifier = beatmap.BeatmapInfo.Ruleset?.CreateInstance().CreateBeatmapVerifier();
|
||||
|
||||
context = new BeatmapVerifierContext(beatmap, workingBeatmap.Value, verify.InterpretedDifficulty.Value);
|
||||
verify.InterpretedDifficulty.BindValueChanged(difficulty => context.InterpretedDifficulty = difficulty.NewValue);
|
||||
|
@ -186,7 +186,7 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
public void RemoveBeatmapSet(BeatmapSetInfo beatmapSet) => Schedule(() =>
|
||||
{
|
||||
var existingSet = beatmapSets.FirstOrDefault(b => b.BeatmapSet.ID == beatmapSet.ID);
|
||||
var existingSet = beatmapSets.FirstOrDefault(b => b.BeatmapSet.Equals(beatmapSet));
|
||||
|
||||
if (existingSet == null)
|
||||
return;
|
||||
@ -198,7 +198,7 @@ namespace osu.Game.Screens.Select
|
||||
public void UpdateBeatmapSet(BeatmapSetInfo beatmapSet) => Schedule(() =>
|
||||
{
|
||||
int? previouslySelectedID = null;
|
||||
CarouselBeatmapSet existingSet = beatmapSets.FirstOrDefault(b => b.BeatmapSet.ID == beatmapSet.ID);
|
||||
CarouselBeatmapSet existingSet = beatmapSets.FirstOrDefault(b => b.BeatmapSet.Equals(beatmapSet));
|
||||
|
||||
// If the selected beatmap is about to be removed, store its ID so it can be re-selected if required
|
||||
if (existingSet?.State?.Value == CarouselItemState.Selected)
|
||||
|
@ -282,9 +282,6 @@ namespace osu.Game.Stores
|
||||
{
|
||||
var rulesetInstance = ((IRulesetInfo)beatmap.Ruleset).CreateInstance();
|
||||
|
||||
if (rulesetInstance == null)
|
||||
return;
|
||||
|
||||
decoded.BeatmapInfo.Ruleset = rulesetInstance.RulesetInfo;
|
||||
|
||||
// TODO: this should be done in a better place once we actually need to dynamically update it.
|
||||
|
Loading…
Reference in New Issue
Block a user