mirror of
https://github.com/ppy/osu
synced 2025-01-19 12:30:50 +00:00
Merge pull request #640 from smoogipooo/remove-playmode
Remove PlayMode enum and make Rulesets modular
This commit is contained in:
commit
1df3189e5d
@ -4,11 +4,6 @@
|
||||
using NUnit.Framework;
|
||||
using osu.Desktop.VisualTests;
|
||||
using osu.Framework.Desktop.Platform;
|
||||
using osu.Game.Modes;
|
||||
using osu.Game.Modes.Catch;
|
||||
using osu.Game.Modes.Mania;
|
||||
using osu.Game.Modes.Osu;
|
||||
using osu.Game.Modes.Taiko;
|
||||
|
||||
namespace osu.Desktop.Tests
|
||||
{
|
||||
@ -20,11 +15,6 @@ namespace osu.Desktop.Tests
|
||||
{
|
||||
using (var host = new HeadlessGameHost())
|
||||
{
|
||||
Ruleset.Register(new OsuRuleset());
|
||||
Ruleset.Register(new TaikoRuleset());
|
||||
Ruleset.Register(new ManiaRuleset());
|
||||
Ruleset.Register(new CatchRuleset());
|
||||
|
||||
host.Run(new AutomatedVisualTestGame());
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,6 @@
|
||||
using System;
|
||||
using osu.Framework.Desktop;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Modes;
|
||||
using osu.Game.Modes.Catch;
|
||||
using osu.Game.Modes.Mania;
|
||||
using osu.Game.Modes.Osu;
|
||||
using osu.Game.Modes.Taiko;
|
||||
|
||||
namespace osu.Desktop.VisualTests
|
||||
{
|
||||
@ -21,11 +16,6 @@ namespace osu.Desktop.VisualTests
|
||||
|
||||
using (GameHost host = Host.GetSuitableHost(@"osu"))
|
||||
{
|
||||
Ruleset.Register(new OsuRuleset());
|
||||
Ruleset.Register(new TaikoRuleset());
|
||||
Ruleset.Register(new ManiaRuleset());
|
||||
Ruleset.Register(new CatchRuleset());
|
||||
|
||||
if (benchmark)
|
||||
host.Run(new AutomatedVisualTestGame());
|
||||
else
|
||||
|
@ -17,13 +17,22 @@ using osu.Game.Modes.Osu.UI;
|
||||
using osu.Game.Modes.Taiko.UI;
|
||||
using System.Collections.Generic;
|
||||
using osu.Desktop.VisualTests.Beatmaps;
|
||||
using osu.Framework.Allocation;
|
||||
|
||||
namespace osu.Desktop.VisualTests.Tests
|
||||
{
|
||||
internal class TestCaseGamefield : TestCase
|
||||
{
|
||||
private RulesetDatabase rulesets;
|
||||
|
||||
public override string Description => @"Showing hitobjects and what not.";
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(RulesetDatabase rulesets)
|
||||
{
|
||||
this.rulesets = rulesets;
|
||||
}
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
@ -49,6 +58,7 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
BeatmapInfo = new BeatmapInfo
|
||||
{
|
||||
Difficulty = new BeatmapDifficulty(),
|
||||
Ruleset = rulesets.Query<RulesetInfo>().First(),
|
||||
Metadata = new BeatmapMetadata
|
||||
{
|
||||
Artist = @"Unknown",
|
||||
|
@ -1,10 +1,11 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Overlays.Mods;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Modes;
|
||||
using osu.Game.Database;
|
||||
|
||||
namespace osu.Desktop.VisualTests.Tests
|
||||
{
|
||||
@ -13,6 +14,13 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
public override string Description => @"Tests the mod select overlay";
|
||||
|
||||
private ModSelectOverlay modSelect;
|
||||
private RulesetDatabase rulesets;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(RulesetDatabase rulesets)
|
||||
{
|
||||
this.rulesets = rulesets;
|
||||
}
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
@ -26,10 +34,9 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
});
|
||||
|
||||
AddStep("Toggle", modSelect.ToggleVisibility);
|
||||
AddStep("osu!", () => modSelect.PlayMode.Value = PlayMode.Osu);
|
||||
AddStep("osu!taiko", () => modSelect.PlayMode.Value = PlayMode.Taiko);
|
||||
AddStep("osu!catch", () => modSelect.PlayMode.Value = PlayMode.Catch);
|
||||
AddStep("osu!mania", () => modSelect.PlayMode.Value = PlayMode.Mania);
|
||||
|
||||
foreach (var ruleset in rulesets.AllRulesets)
|
||||
AddStep(ruleset.CreateInstance().Description, () => modSelect.Ruleset.Value = ruleset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ using osu.Desktop.VisualTests.Platform;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Modes;
|
||||
using osu.Game.Screens.Select;
|
||||
using osu.Game.Screens.Select.Filter;
|
||||
|
||||
@ -20,13 +19,19 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
|
||||
public override string Description => @"with fake data";
|
||||
|
||||
private RulesetDatabase rulesets;
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
if (db == null)
|
||||
{
|
||||
storage = new TestStorage(@"TestCasePlaySongSelect");
|
||||
db = new BeatmapDatabase(storage);
|
||||
|
||||
var backingDatabase = storage.GetDatabase(@"client");
|
||||
|
||||
rulesets = new RulesetDatabase(storage, backingDatabase);
|
||||
db = new BeatmapDatabase(storage, backingDatabase, rulesets);
|
||||
|
||||
var sets = new List<BeatmapSetInfo>();
|
||||
|
||||
@ -72,7 +77,7 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
new BeatmapInfo
|
||||
{
|
||||
OnlineBeatmapID = 1234 + i,
|
||||
Mode = PlayMode.Osu,
|
||||
Ruleset = rulesets.Query<RulesetInfo>().First(),
|
||||
Path = "normal.osu",
|
||||
Version = "Normal",
|
||||
Difficulty = new BeatmapDifficulty
|
||||
@ -83,7 +88,7 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
new BeatmapInfo
|
||||
{
|
||||
OnlineBeatmapID = 1235 + i,
|
||||
Mode = PlayMode.Osu,
|
||||
Ruleset = rulesets.Query<RulesetInfo>().First(),
|
||||
Path = "hard.osu",
|
||||
Version = "Hard",
|
||||
Difficulty = new BeatmapDifficulty
|
||||
@ -94,7 +99,7 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
new BeatmapInfo
|
||||
{
|
||||
OnlineBeatmapID = 1236 + i,
|
||||
Mode = PlayMode.Osu,
|
||||
Ruleset = rulesets.Query<RulesetInfo>().First(),
|
||||
Path = "insane.osu",
|
||||
Version = "Insane",
|
||||
Difficulty = new BeatmapDifficulty
|
||||
|
@ -9,7 +9,6 @@ using osu.Game.Beatmaps;
|
||||
using OpenTK;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Modes;
|
||||
using osu.Game.Modes.Objects;
|
||||
using osu.Game.Modes.Osu.Objects;
|
||||
using osu.Game.Screens.Play;
|
||||
@ -22,12 +21,14 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
{
|
||||
protected Player Player;
|
||||
private BeatmapDatabase db;
|
||||
private RulesetDatabase rulesets;
|
||||
|
||||
public override string Description => @"Showing everything to play the game.";
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(BeatmapDatabase db)
|
||||
private void load(BeatmapDatabase db, RulesetDatabase rulesets)
|
||||
{
|
||||
this.rulesets = rulesets;
|
||||
this.db = db;
|
||||
}
|
||||
|
||||
@ -37,7 +38,7 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
|
||||
WorkingBeatmap beatmap = null;
|
||||
|
||||
var beatmapInfo = db.Query<BeatmapInfo>().FirstOrDefault(b => b.Mode == PlayMode.Osu);
|
||||
var beatmapInfo = db.Query<BeatmapInfo>().FirstOrDefault(b => b.RulesetID == 0);
|
||||
if (beatmapInfo != null)
|
||||
beatmap = db.GetWorkingBeatmap(beatmapInfo);
|
||||
|
||||
@ -65,6 +66,7 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
BeatmapInfo = new BeatmapInfo
|
||||
{
|
||||
Difficulty = new BeatmapDifficulty(),
|
||||
Ruleset = rulesets.Query<RulesetInfo>().First(),
|
||||
Metadata = new BeatmapMetadata
|
||||
{
|
||||
Artist = @"Unknown",
|
||||
|
@ -7,11 +7,6 @@ using osu.Desktop.Beatmaps.IO;
|
||||
using osu.Framework.Desktop;
|
||||
using osu.Framework.Desktop.Platform;
|
||||
using osu.Game.IPC;
|
||||
using osu.Game.Modes;
|
||||
using osu.Game.Modes.Catch;
|
||||
using osu.Game.Modes.Mania;
|
||||
using osu.Game.Modes.Osu;
|
||||
using osu.Game.Modes.Taiko;
|
||||
|
||||
namespace osu.Desktop
|
||||
{
|
||||
@ -41,11 +36,6 @@ namespace osu.Desktop
|
||||
}
|
||||
else
|
||||
{
|
||||
Ruleset.Register(new OsuRuleset());
|
||||
Ruleset.Register(new TaikoRuleset());
|
||||
Ruleset.Register(new ManiaRuleset());
|
||||
Ruleset.Register(new CatchRuleset());
|
||||
|
||||
host.Run(new OsuGameDesktop(args));
|
||||
}
|
||||
return 0;
|
||||
|
@ -76,8 +76,6 @@ namespace osu.Game.Modes.Catch
|
||||
}
|
||||
}
|
||||
|
||||
protected override PlayMode PlayMode => PlayMode.Catch;
|
||||
|
||||
public override string Description => "osu!catch";
|
||||
|
||||
public override FontAwesome Icon => FontAwesome.fa_osu_fruits_o;
|
||||
@ -92,5 +90,7 @@ namespace osu.Game.Modes.Catch
|
||||
public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap) => new CatchDifficultyCalculator(beatmap);
|
||||
|
||||
public override ScoreProcessor CreateScoreProcessor() => new CatchScoreProcessor();
|
||||
|
||||
public override int LegacyID => 2;
|
||||
}
|
||||
}
|
||||
|
@ -96,8 +96,6 @@ namespace osu.Game.Modes.Mania
|
||||
}
|
||||
}
|
||||
|
||||
protected override PlayMode PlayMode => PlayMode.Mania;
|
||||
|
||||
public override string Description => "osu!mania";
|
||||
|
||||
public override FontAwesome Icon => FontAwesome.fa_osu_mania_o;
|
||||
@ -107,5 +105,7 @@ namespace osu.Game.Modes.Mania
|
||||
public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap) => new ManiaDifficultyCalculator(beatmap);
|
||||
|
||||
public override ScoreProcessor CreateScoreProcessor() => new ManiaScoreProcessor();
|
||||
|
||||
public override int LegacyID => 3;
|
||||
}
|
||||
}
|
||||
|
@ -99,8 +99,6 @@ namespace osu.Game.Modes.Osu
|
||||
|
||||
public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap) => new OsuDifficultyCalculator(beatmap);
|
||||
|
||||
protected override PlayMode PlayMode => PlayMode.Osu;
|
||||
|
||||
public override string Description => "osu!";
|
||||
|
||||
public override IEnumerable<KeyCounter> CreateGameplayKeys() => new KeyCounter[]
|
||||
@ -112,5 +110,7 @@ namespace osu.Game.Modes.Osu
|
||||
};
|
||||
|
||||
public override ScoreProcessor CreateScoreProcessor() => new OsuScoreProcessor();
|
||||
|
||||
public override int LegacyID => 0;
|
||||
}
|
||||
}
|
||||
|
@ -76,8 +76,6 @@ namespace osu.Game.Modes.Taiko
|
||||
}
|
||||
}
|
||||
|
||||
protected override PlayMode PlayMode => PlayMode.Taiko;
|
||||
|
||||
public override string Description => "osu!taiko";
|
||||
|
||||
public override FontAwesome Icon => FontAwesome.fa_osu_taiko_o;
|
||||
@ -93,5 +91,7 @@ namespace osu.Game.Modes.Taiko
|
||||
public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap) => new TaikoDifficultyCalculator(beatmap);
|
||||
|
||||
public override ScoreProcessor CreateScoreProcessor() => new TaikoScoreProcessor();
|
||||
|
||||
public override int LegacyID => 1;
|
||||
}
|
||||
}
|
||||
|
@ -6,9 +6,7 @@ using NUnit.Framework;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Game.Beatmaps.Formats;
|
||||
using osu.Game.Modes;
|
||||
using osu.Game.Tests.Resources;
|
||||
using osu.Game.Modes.Osu;
|
||||
using osu.Game.Modes.Objects.Legacy;
|
||||
using System.Linq;
|
||||
using osu.Game.Audio;
|
||||
@ -22,7 +20,6 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
||||
public void SetUp()
|
||||
{
|
||||
OsuLegacyDecoder.Register();
|
||||
Ruleset.Register(new OsuRuleset());
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -58,7 +55,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
||||
Assert.AreEqual(false, beatmapInfo.Countdown);
|
||||
Assert.AreEqual(0.7f, beatmapInfo.StackLeniency);
|
||||
Assert.AreEqual(false, beatmapInfo.SpecialStyle);
|
||||
Assert.AreEqual(PlayMode.Osu, beatmapInfo.Mode);
|
||||
Assert.IsTrue(beatmapInfo.RulesetID == 0);
|
||||
Assert.AreEqual(false, beatmapInfo.LetterboxInBreaks);
|
||||
Assert.AreEqual(false, beatmapInfo.WidescreenStoryboard);
|
||||
}
|
||||
|
@ -12,11 +12,6 @@ using osu.Framework.Desktop.Platform;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.IPC;
|
||||
using osu.Game.Modes;
|
||||
using osu.Game.Modes.Catch;
|
||||
using osu.Game.Modes.Mania;
|
||||
using osu.Game.Modes.Osu;
|
||||
using osu.Game.Modes.Taiko;
|
||||
|
||||
namespace osu.Game.Tests.Beatmaps.IO
|
||||
{
|
||||
@ -25,15 +20,6 @@ namespace osu.Game.Tests.Beatmaps.IO
|
||||
{
|
||||
private const string osz_path = @"../../../osu-resources/osu.Game.Resources/Beatmaps/241526 Soleily - Renatus.osz";
|
||||
|
||||
[OneTimeSetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
Ruleset.Register(new OsuRuleset());
|
||||
Ruleset.Register(new TaikoRuleset());
|
||||
Ruleset.Register(new ManiaRuleset());
|
||||
Ruleset.Register(new CatchRuleset());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestImportWhenClosed()
|
||||
{
|
||||
@ -119,6 +105,7 @@ namespace osu.Game.Tests.Beatmaps.IO
|
||||
Thread.Sleep(1);
|
||||
|
||||
//reset beatmap database (sqlite and storage backing)
|
||||
osu.Dependencies.Get<RulesetDatabase>().Reset();
|
||||
osu.Dependencies.Get<BeatmapDatabase>().Reset();
|
||||
|
||||
return osu;
|
||||
@ -166,8 +153,16 @@ namespace osu.Game.Tests.Beatmaps.IO
|
||||
|
||||
Assert.IsTrue(set.Beatmaps.Count > 0);
|
||||
|
||||
var beatmap = osu.Dependencies.Get<BeatmapDatabase>().GetWorkingBeatmap(set.Beatmaps.First(b => b.Mode == PlayMode.Osu))?.Beatmap;
|
||||
var beatmap = osu.Dependencies.Get<BeatmapDatabase>().GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 0))?.Beatmap;
|
||||
Assert.IsTrue(beatmap?.HitObjects.Count > 0);
|
||||
|
||||
beatmap = osu.Dependencies.Get<BeatmapDatabase>().GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 1))?.Beatmap;
|
||||
Assert.IsTrue(beatmap?.HitObjects.Count > 0);
|
||||
|
||||
beatmap = osu.Dependencies.Get<BeatmapDatabase>().GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 2))?.Beatmap;
|
||||
Assert.IsTrue(beatmap?.HitObjects.Count > 0);
|
||||
|
||||
beatmap = osu.Dependencies.Get<BeatmapDatabase>().GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 3))?.Beatmap;
|
||||
Assert.IsTrue(beatmap?.HitObjects.Count > 0);
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,6 @@
|
||||
using System.IO;
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Beatmaps.IO;
|
||||
using osu.Game.Modes;
|
||||
using osu.Game.Modes.Osu;
|
||||
using osu.Game.Tests.Resources;
|
||||
using osu.Game.Beatmaps.Formats;
|
||||
using osu.Game.Database;
|
||||
@ -19,7 +17,6 @@ namespace osu.Game.Tests.Beatmaps.IO
|
||||
public void SetUp()
|
||||
{
|
||||
OszArchiveReader.Register();
|
||||
Ruleset.Register(new OsuRuleset());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -4,7 +4,6 @@
|
||||
using OpenTK.Graphics;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Modes;
|
||||
using osu.Game.Modes.Objects;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@ -50,12 +49,6 @@ namespace osu.Game.Beatmaps
|
||||
/// </summary>
|
||||
public class Beatmap : Beatmap<HitObject>
|
||||
{
|
||||
/// <summary>
|
||||
/// Calculates the star difficulty for this Beatmap.
|
||||
/// </summary>
|
||||
/// <returns>The star difficulty.</returns>
|
||||
public double CalculateStarDifficulty() => Ruleset.GetRuleset(BeatmapInfo.Mode).CreateDifficultyCalculator(this).Calculate();
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new beatmap.
|
||||
/// </summary>
|
||||
|
@ -6,7 +6,6 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Modes;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
@ -45,7 +44,7 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
Origin = Anchor.Centre,
|
||||
TextSize = Size.X,
|
||||
Colour = Color4.White,
|
||||
Icon = Ruleset.GetRuleset(beatmap.Mode).Icon
|
||||
Icon = beatmap.Ruleset.CreateInstance().Icon
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ using System.IO;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Game.Beatmaps.Events;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using osu.Game.Modes;
|
||||
using osu.Game.Modes.Objects;
|
||||
using osu.Game.Beatmaps.Legacy;
|
||||
|
||||
@ -84,7 +83,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
beatmap.BeatmapInfo.StackLeniency = float.Parse(val, NumberFormatInfo.InvariantInfo);
|
||||
break;
|
||||
case @"Mode":
|
||||
beatmap.BeatmapInfo.Mode = (PlayMode)int.Parse(val);
|
||||
beatmap.BeatmapInfo.RulesetID = int.Parse(val);
|
||||
break;
|
||||
case @"LetterboxInBreaks":
|
||||
beatmap.BeatmapInfo.LetterboxInBreaks = int.Parse(val) == 1;
|
||||
|
@ -5,7 +5,6 @@ using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Modes;
|
||||
using osu.Game.Modes.Mods;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -18,14 +17,6 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
public readonly BeatmapSetInfo BeatmapSetInfo;
|
||||
|
||||
/// <summary>
|
||||
/// A play mode that is preferred for this beatmap. PlayMode will become this mode where conversion is feasible,
|
||||
/// or otherwise to the beatmap's default.
|
||||
/// </summary>
|
||||
public PlayMode? PreferredPlayMode;
|
||||
|
||||
public PlayMode PlayMode => Beatmap?.BeatmapInfo?.Mode > PlayMode.Osu ? Beatmap.BeatmapInfo.Mode : PreferredPlayMode ?? PlayMode.Osu;
|
||||
|
||||
public readonly Bindable<IEnumerable<Mod>> Mods = new Bindable<IEnumerable<Mod>>();
|
||||
|
||||
public readonly bool WithStoryboard;
|
||||
|
@ -4,7 +4,6 @@
|
||||
using System;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Modes;
|
||||
|
||||
namespace osu.Game.Configuration
|
||||
{
|
||||
@ -17,7 +16,7 @@ namespace osu.Game.Configuration
|
||||
Set(OsuConfig.Username, string.Empty);
|
||||
Set(OsuConfig.Token, string.Empty);
|
||||
|
||||
Set(OsuConfig.PlayMode, PlayMode.Osu);
|
||||
Set(OsuConfig.Ruleset, 0, 0, int.MaxValue);
|
||||
|
||||
Set(OsuConfig.AudioDevice, string.Empty);
|
||||
Set(OsuConfig.SavePassword, false);
|
||||
@ -196,7 +195,7 @@ namespace osu.Game.Configuration
|
||||
public enum OsuConfig
|
||||
{
|
||||
// New osu:
|
||||
PlayMode,
|
||||
Ruleset,
|
||||
Token,
|
||||
// Imported from old osu:
|
||||
BeatmapDirectory,
|
||||
|
@ -5,7 +5,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Platform;
|
||||
@ -18,37 +17,21 @@ using SQLiteNetExtensions.Extensions;
|
||||
|
||||
namespace osu.Game.Database
|
||||
{
|
||||
public class BeatmapDatabase
|
||||
public class BeatmapDatabase : Database
|
||||
{
|
||||
private SQLiteConnection connection { get; }
|
||||
private readonly Storage storage;
|
||||
private readonly RulesetDatabase rulesets;
|
||||
|
||||
public event Action<BeatmapSetInfo> BeatmapSetAdded;
|
||||
public event Action<BeatmapSetInfo> BeatmapSetRemoved;
|
||||
|
||||
// ReSharper disable once NotAccessedField.Local (we should keep a reference to this so it is not finalised)
|
||||
private BeatmapIPCChannel ipc;
|
||||
|
||||
public BeatmapDatabase(Storage storage, IIpcHost importHost = null)
|
||||
public BeatmapDatabase(Storage storage, SQLiteConnection connection, RulesetDatabase rulesets, IIpcHost importHost = null) : base(storage, connection)
|
||||
{
|
||||
this.storage = storage;
|
||||
|
||||
this.rulesets = rulesets;
|
||||
if (importHost != null)
|
||||
ipc = new BeatmapIPCChannel(importHost, this);
|
||||
|
||||
if (connection == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
connection = prepareConnection();
|
||||
deletePending();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Error(e, @"Failed to initialise the beatmap database! Trying again with a clean database...");
|
||||
storage.DeleteDatabase(@"beatmaps");
|
||||
connection = prepareConnection();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void deletePending()
|
||||
@ -57,20 +40,20 @@ namespace osu.Game.Database
|
||||
{
|
||||
try
|
||||
{
|
||||
storage.Delete(b.Path);
|
||||
Storage.Delete(b.Path);
|
||||
|
||||
GetChildren(b, true);
|
||||
|
||||
foreach (var i in b.Beatmaps)
|
||||
{
|
||||
if (i.Metadata != null) connection.Delete(i.Metadata);
|
||||
if (i.Difficulty != null) connection.Delete(i.Difficulty);
|
||||
if (i.Metadata != null) Connection.Delete(i.Metadata);
|
||||
if (i.Difficulty != null) Connection.Delete(i.Difficulty);
|
||||
|
||||
connection.Delete(i);
|
||||
Connection.Delete(i);
|
||||
}
|
||||
|
||||
if (b.Metadata != null) connection.Delete(b.Metadata);
|
||||
connection.Delete(b);
|
||||
if (b.Metadata != null) Connection.Delete(b.Metadata);
|
||||
Connection.Delete(b);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -80,42 +63,41 @@ namespace osu.Game.Database
|
||||
|
||||
//this is required because sqlite migrations don't work, initially inserting nulls into this field.
|
||||
//see https://github.com/praeclarum/sqlite-net/issues/326
|
||||
connection.Query<BeatmapSetInfo>("UPDATE BeatmapSetInfo SET DeletePending = 0 WHERE DeletePending IS NULL");
|
||||
Connection.Query<BeatmapSetInfo>("UPDATE BeatmapSetInfo SET DeletePending = 0 WHERE DeletePending IS NULL");
|
||||
}
|
||||
|
||||
private SQLiteConnection prepareConnection()
|
||||
protected override void Prepare(bool reset = false)
|
||||
{
|
||||
var conn = storage.GetDatabase(@"beatmaps");
|
||||
Connection.CreateTable<BeatmapMetadata>();
|
||||
Connection.CreateTable<BeatmapDifficulty>();
|
||||
Connection.CreateTable<BeatmapSetInfo>();
|
||||
Connection.CreateTable<BeatmapInfo>();
|
||||
|
||||
try
|
||||
if (reset)
|
||||
{
|
||||
conn.CreateTable<BeatmapMetadata>();
|
||||
conn.CreateTable<BeatmapDifficulty>();
|
||||
conn.CreateTable<BeatmapSetInfo>();
|
||||
conn.CreateTable<BeatmapInfo>();
|
||||
}
|
||||
catch
|
||||
{
|
||||
conn.Close();
|
||||
throw;
|
||||
Storage.DeleteDatabase(@"beatmaps");
|
||||
|
||||
foreach (var setInfo in Query<BeatmapSetInfo>())
|
||||
{
|
||||
if (Storage.Exists(setInfo.Path))
|
||||
Storage.Delete(setInfo.Path);
|
||||
}
|
||||
|
||||
Connection.DeleteAll<BeatmapMetadata>();
|
||||
Connection.DeleteAll<BeatmapDifficulty>();
|
||||
Connection.DeleteAll<BeatmapSetInfo>();
|
||||
Connection.DeleteAll<BeatmapInfo>();
|
||||
}
|
||||
|
||||
return conn;
|
||||
deletePending();
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
foreach (var setInfo in Query<BeatmapSetInfo>())
|
||||
{
|
||||
if (storage.Exists(setInfo.Path))
|
||||
storage.Delete(setInfo.Path);
|
||||
}
|
||||
|
||||
connection.DeleteAll<BeatmapMetadata>();
|
||||
connection.DeleteAll<BeatmapDifficulty>();
|
||||
connection.DeleteAll<BeatmapSetInfo>();
|
||||
connection.DeleteAll<BeatmapInfo>();
|
||||
}
|
||||
protected override Type[] ValidTypes => new[] {
|
||||
typeof(BeatmapSetInfo),
|
||||
typeof(BeatmapInfo),
|
||||
typeof(BeatmapMetadata),
|
||||
typeof(BeatmapDifficulty),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Import multiple <see cref="BeatmapSetInfo"/> from <paramref name="paths"/>.
|
||||
@ -174,7 +156,7 @@ namespace osu.Game.Database
|
||||
|
||||
BeatmapMetadata metadata;
|
||||
|
||||
using (var reader = ArchiveReader.GetReader(storage, path))
|
||||
using (var reader = ArchiveReader.GetReader(Storage, path))
|
||||
{
|
||||
using (var stream = new StreamReader(reader.GetStream(reader.BeatmapFilenames[0])))
|
||||
metadata = BeatmapDecoder.GetDecoder(stream).Decode(stream).Metadata;
|
||||
@ -182,18 +164,18 @@ namespace osu.Game.Database
|
||||
|
||||
if (File.Exists(path)) // Not always the case, i.e. for LegacyFilesystemReader
|
||||
{
|
||||
using (var input = storage.GetStream(path))
|
||||
using (var input = Storage.GetStream(path))
|
||||
{
|
||||
hash = input.GetMd5Hash();
|
||||
input.Seek(0, SeekOrigin.Begin);
|
||||
path = Path.Combine(@"beatmaps", hash.Remove(1), hash.Remove(2), hash);
|
||||
if (!storage.Exists(path))
|
||||
using (var output = storage.GetStream(path, FileAccess.Write))
|
||||
if (!Storage.Exists(path))
|
||||
using (var output = Storage.GetStream(path, FileAccess.Write))
|
||||
input.CopyTo(output);
|
||||
}
|
||||
}
|
||||
|
||||
var existing = connection.Table<BeatmapSetInfo>().FirstOrDefault(b => b.Hash == hash);
|
||||
var existing = Connection.Table<BeatmapSetInfo>().FirstOrDefault(b => b.Hash == hash);
|
||||
|
||||
if (existing != null)
|
||||
{
|
||||
@ -216,7 +198,7 @@ namespace osu.Game.Database
|
||||
Metadata = metadata
|
||||
};
|
||||
|
||||
using (var archive = ArchiveReader.GetReader(storage, path))
|
||||
using (var archive = ArchiveReader.GetReader(Storage, path))
|
||||
{
|
||||
string[] mapNames = archive.BeatmapFilenames;
|
||||
foreach (var name in mapNames)
|
||||
@ -236,7 +218,9 @@ namespace osu.Game.Database
|
||||
// TODO: Diff beatmap metadata with set metadata and leave it here if necessary
|
||||
beatmap.BeatmapInfo.Metadata = null;
|
||||
|
||||
beatmap.BeatmapInfo.StarDifficulty = beatmap.CalculateStarDifficulty();
|
||||
// TODO: this should be done in a better place once we actually need to dynamically update it.
|
||||
beatmap.BeatmapInfo.Ruleset = rulesets.Query<RulesetInfo>().FirstOrDefault(r => r.ID == beatmap.BeatmapInfo.RulesetID);
|
||||
beatmap.BeatmapInfo.StarDifficulty = rulesets.Query<RulesetInfo>().FirstOrDefault(r => r.ID == beatmap.BeatmapInfo.RulesetID)?.CreateInstance()?.CreateDifficultyCalculator(beatmap).Calculate() ?? 0;
|
||||
|
||||
beatmapSet.Beatmaps.Add(beatmap.BeatmapInfo);
|
||||
}
|
||||
@ -248,17 +232,17 @@ namespace osu.Game.Database
|
||||
|
||||
public void Import(IEnumerable<BeatmapSetInfo> beatmapSets)
|
||||
{
|
||||
lock (connection)
|
||||
lock (Connection)
|
||||
{
|
||||
connection.BeginTransaction();
|
||||
Connection.BeginTransaction();
|
||||
|
||||
foreach (var s in beatmapSets)
|
||||
{
|
||||
connection.InsertWithChildren(s, true);
|
||||
Connection.InsertOrReplaceWithChildren(s, true);
|
||||
BeatmapSetAdded?.Invoke(s);
|
||||
}
|
||||
|
||||
connection.Commit();
|
||||
Connection.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
@ -275,7 +259,7 @@ namespace osu.Game.Database
|
||||
if (string.IsNullOrEmpty(beatmapSet.Path))
|
||||
return null;
|
||||
|
||||
return ArchiveReader.GetReader(storage, beatmapSet.Path);
|
||||
return ArchiveReader.GetReader(Storage, beatmapSet.Path);
|
||||
}
|
||||
|
||||
public BeatmapSetInfo GetBeatmapSet(int id)
|
||||
@ -287,12 +271,14 @@ namespace osu.Game.Database
|
||||
{
|
||||
var beatmapSetInfo = Query<BeatmapSetInfo>().FirstOrDefault(s => s.ID == beatmapInfo.BeatmapSetInfoID);
|
||||
|
||||
//we need metadata
|
||||
GetChildren(beatmapSetInfo);
|
||||
|
||||
if (beatmapSetInfo == null)
|
||||
throw new InvalidOperationException($@"Beatmap set {beatmapInfo.BeatmapSetInfoID} is not in the local database.");
|
||||
|
||||
//we need metadata
|
||||
GetChildren(beatmapSetInfo);
|
||||
//we also need a ruleset
|
||||
GetChildren(beatmapInfo);
|
||||
|
||||
if (beatmapInfo.Metadata == null)
|
||||
beatmapInfo.Metadata = beatmapSetInfo.Metadata;
|
||||
|
||||
@ -303,47 +289,6 @@ namespace osu.Game.Database
|
||||
return working;
|
||||
}
|
||||
|
||||
public TableQuery<T> Query<T>() where T : class
|
||||
{
|
||||
return connection.Table<T>();
|
||||
}
|
||||
|
||||
public T GetWithChildren<T>(object id) where T : class
|
||||
{
|
||||
return connection.GetWithChildren<T>(id);
|
||||
}
|
||||
|
||||
public List<T> GetAllWithChildren<T>(Expression<Func<T, bool>> filter = null, bool recursive = true)
|
||||
where T : class
|
||||
{
|
||||
return connection.GetAllWithChildren(filter, recursive);
|
||||
}
|
||||
|
||||
public T GetChildren<T>(T item, bool recursive = false)
|
||||
{
|
||||
if (item == null) return default(T);
|
||||
|
||||
connection.GetChildren(item, recursive);
|
||||
return item;
|
||||
}
|
||||
|
||||
private readonly Type[] validTypes = {
|
||||
typeof(BeatmapSetInfo),
|
||||
typeof(BeatmapInfo),
|
||||
typeof(BeatmapMetadata),
|
||||
typeof(BeatmapDifficulty),
|
||||
};
|
||||
|
||||
public void Update<T>(T record, bool cascade = true) where T : class
|
||||
{
|
||||
if (validTypes.All(t => t != typeof(T)))
|
||||
throw new ArgumentException("Must be a type managed by BeatmapDatabase", nameof(T));
|
||||
if (cascade)
|
||||
connection.UpdateWithChildren(record);
|
||||
else
|
||||
connection.Update(record);
|
||||
}
|
||||
|
||||
public bool Exists(BeatmapSetInfo beatmapSet) => storage.Exists(beatmapSet.Path);
|
||||
public bool Exists(BeatmapSetInfo beatmapSet) => Storage.Exists(beatmapSet.Path);
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using osu.Game.IO.Serialization;
|
||||
using osu.Game.Modes;
|
||||
using SQLite.Net.Attributes;
|
||||
using SQLiteNetExtensions.Attributes;
|
||||
using System;
|
||||
@ -54,7 +53,13 @@ namespace osu.Game.Database
|
||||
public bool Countdown { get; set; }
|
||||
public float StackLeniency { get; set; }
|
||||
public bool SpecialStyle { get; set; }
|
||||
public PlayMode Mode { get; set; }
|
||||
|
||||
[ForeignKey(typeof(RulesetInfo))]
|
||||
public int RulesetID { get; set; }
|
||||
|
||||
[OneToOne(CascadeOperations = CascadeOperation.All)]
|
||||
public RulesetInfo Ruleset { get; set; }
|
||||
|
||||
public bool LetterboxInBreaks { get; set; }
|
||||
public bool WidescreenStoryboard { get; set; }
|
||||
|
||||
|
@ -26,6 +26,7 @@ namespace osu.Game.Database
|
||||
|
||||
public double MaxStarDifficulty => Beatmaps.Max(b => b.StarDifficulty);
|
||||
|
||||
[Indexed]
|
||||
public bool DeletePending { get; set; }
|
||||
|
||||
public string Hash { get; set; }
|
||||
|
82
osu.Game/Database/Database.cs
Normal file
82
osu.Game/Database/Database.cs
Normal file
@ -0,0 +1,82 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Platform;
|
||||
using SQLite.Net;
|
||||
using SQLiteNetExtensions.Extensions;
|
||||
|
||||
namespace osu.Game.Database
|
||||
{
|
||||
public abstract class Database
|
||||
{
|
||||
protected SQLiteConnection Connection { get; }
|
||||
protected Storage Storage { get; }
|
||||
|
||||
protected Database(Storage storage, SQLiteConnection connection)
|
||||
{
|
||||
Storage = storage;
|
||||
Connection = connection;
|
||||
|
||||
try
|
||||
{
|
||||
Prepare();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Error(e, $@"Failed to initialise the {GetType()}! Trying again with a clean database...");
|
||||
Prepare(true);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prepare this database for use.
|
||||
/// </summary>
|
||||
protected abstract void Prepare(bool reset = false);
|
||||
|
||||
/// <summary>
|
||||
/// Reset this database to a default state. Undo all changes to database and storage backings.
|
||||
/// </summary>
|
||||
public void Reset() => Prepare(true);
|
||||
|
||||
public TableQuery<T> Query<T>() where T : class
|
||||
{
|
||||
return Connection.Table<T>();
|
||||
}
|
||||
|
||||
public T GetWithChildren<T>(object id) where T : class
|
||||
{
|
||||
return Connection.GetWithChildren<T>(id);
|
||||
}
|
||||
|
||||
public List<T> GetAllWithChildren<T>(Expression<Func<T, bool>> filter = null, bool recursive = true)
|
||||
where T : class
|
||||
{
|
||||
return Connection.GetAllWithChildren(filter, recursive);
|
||||
}
|
||||
|
||||
public T GetChildren<T>(T item, bool recursive = false)
|
||||
{
|
||||
if (item == null) return default(T);
|
||||
|
||||
Connection.GetChildren(item, recursive);
|
||||
return item;
|
||||
}
|
||||
|
||||
protected abstract Type[] ValidTypes { get; }
|
||||
|
||||
public void Update<T>(T record, bool cascade = true) where T : class
|
||||
{
|
||||
if (ValidTypes.All(t => t != typeof(T)))
|
||||
throw new ArgumentException("Must be a type managed by BeatmapDatabase", nameof(T));
|
||||
if (cascade)
|
||||
Connection.UpdateWithChildren(record);
|
||||
else
|
||||
Connection.Update(record);
|
||||
}
|
||||
}
|
||||
}
|
103
osu.Game/Database/RulesetDatabase.cs
Normal file
103
osu.Game/Database/RulesetDatabase.cs
Normal file
@ -0,0 +1,103 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Modes;
|
||||
using SQLite.Net;
|
||||
|
||||
namespace osu.Game.Database
|
||||
{
|
||||
/// <summary>
|
||||
/// Todo: All of this needs to be moved to a RulesetDatabase.
|
||||
/// </summary>
|
||||
public class RulesetDatabase : Database
|
||||
{
|
||||
public IEnumerable<RulesetInfo> AllRulesets => Query<RulesetInfo>().Where(r => r.Available);
|
||||
|
||||
public RulesetDatabase(Storage storage, SQLiteConnection connection)
|
||||
: base(storage, connection)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Prepare(bool reset = false)
|
||||
{
|
||||
Connection.CreateTable<RulesetInfo>();
|
||||
|
||||
if (reset)
|
||||
{
|
||||
Connection.DeleteAll<RulesetInfo>();
|
||||
}
|
||||
|
||||
List<Ruleset> instances = new List<Ruleset>();
|
||||
|
||||
foreach (string file in Directory.GetFiles(Environment.CurrentDirectory, @"osu.Game.Modes.*.dll"))
|
||||
{
|
||||
try
|
||||
{
|
||||
var assembly = Assembly.LoadFile(file);
|
||||
var rulesets = assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(Ruleset)));
|
||||
|
||||
if (rulesets.Count() != 1)
|
||||
continue;
|
||||
|
||||
foreach (Type rulesetType in rulesets)
|
||||
instances.Add((Ruleset)Activator.CreateInstance(rulesetType));
|
||||
}
|
||||
catch (Exception) { }
|
||||
}
|
||||
|
||||
Connection.BeginTransaction();
|
||||
|
||||
//add all legacy modes in correct order
|
||||
foreach (var r in instances.Where(r => r.LegacyID >= 0).OrderBy(r => r.LegacyID))
|
||||
{
|
||||
Connection.InsertOrReplace(createRulesetInfo(r));
|
||||
}
|
||||
|
||||
//add any other modes
|
||||
foreach (var r in instances.Where(r => r.LegacyID < 0))
|
||||
{
|
||||
var us = createRulesetInfo(r);
|
||||
|
||||
var existing = Query<RulesetInfo>().FirstOrDefault(ri => ri.InstantiationInfo == us.InstantiationInfo);
|
||||
|
||||
if (existing == null)
|
||||
Connection.Insert(us);
|
||||
}
|
||||
|
||||
//perform a consistency check
|
||||
foreach (var r in Query<RulesetInfo>())
|
||||
{
|
||||
try
|
||||
{
|
||||
r.CreateInstance();
|
||||
r.Available = true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
r.Available = false;
|
||||
}
|
||||
|
||||
Connection.Update(r);
|
||||
}
|
||||
|
||||
Connection.Commit();
|
||||
}
|
||||
|
||||
private RulesetInfo createRulesetInfo(Ruleset ruleset) => new RulesetInfo
|
||||
{
|
||||
Name = ruleset.Description,
|
||||
InstantiationInfo = ruleset.GetType().AssemblyQualifiedName,
|
||||
ID = ruleset.LegacyID
|
||||
};
|
||||
|
||||
protected override Type[] ValidTypes => new[] { typeof(RulesetInfo) };
|
||||
|
||||
public RulesetInfo GetRuleset(int id) => Query<RulesetInfo>().First(r => r.ID == id);
|
||||
}
|
||||
}
|
26
osu.Game/Database/RulesetInfo.cs
Normal file
26
osu.Game/Database/RulesetInfo.cs
Normal file
@ -0,0 +1,26 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using osu.Game.Modes;
|
||||
using SQLite.Net.Attributes;
|
||||
|
||||
namespace osu.Game.Database
|
||||
{
|
||||
public class RulesetInfo
|
||||
{
|
||||
[PrimaryKey, AutoIncrement]
|
||||
public int? ID { get; set; }
|
||||
|
||||
[Indexed(Unique = true)]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Indexed(Unique = true)]
|
||||
public string InstantiationInfo { get; set; }
|
||||
|
||||
[Indexed]
|
||||
public bool Available { get; set; }
|
||||
|
||||
public Ruleset CreateInstance() => (Ruleset)Activator.CreateInstance(Type.GetType(InstantiationInfo));
|
||||
}
|
||||
}
|
@ -7,26 +7,29 @@ using System.Linq;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.IO.Legacy;
|
||||
using osu.Game.IPC;
|
||||
using osu.Game.Modes;
|
||||
using osu.Game.Modes.Scoring;
|
||||
using SharpCompress.Compressors.LZMA;
|
||||
using SQLite.Net;
|
||||
|
||||
namespace osu.Game.Database
|
||||
{
|
||||
public class ScoreDatabase
|
||||
public class ScoreDatabase : Database
|
||||
{
|
||||
private readonly Storage storage;
|
||||
|
||||
private readonly BeatmapDatabase beatmaps;
|
||||
private readonly RulesetDatabase rulesets;
|
||||
|
||||
private const string replay_folder = @"replays";
|
||||
|
||||
// ReSharper disable once NotAccessedField.Local (we should keep a reference to this so it is not finalised)
|
||||
private ScoreIPCChannel ipc;
|
||||
|
||||
public ScoreDatabase(Storage storage, IIpcHost importHost = null, BeatmapDatabase beatmaps = null)
|
||||
public ScoreDatabase(Storage storage, SQLiteConnection connection, IIpcHost importHost = null, BeatmapDatabase beatmaps = null, RulesetDatabase rulesets = null) : base(storage, connection)
|
||||
{
|
||||
this.storage = storage;
|
||||
this.beatmaps = beatmaps;
|
||||
this.rulesets = rulesets;
|
||||
|
||||
if (importHost != null)
|
||||
ipc = new ScoreIPCChannel(importHost, this);
|
||||
@ -39,7 +42,7 @@ namespace osu.Game.Database
|
||||
using (Stream s = storage.GetStream(Path.Combine(replay_folder, replayFilename)))
|
||||
using (SerializationReader sr = new SerializationReader(s))
|
||||
{
|
||||
var ruleset = Ruleset.GetRuleset((PlayMode)sr.ReadByte());
|
||||
var ruleset = rulesets.GetRuleset(sr.ReadByte()).CreateInstance();
|
||||
score = ruleset.CreateScoreProcessor().CreateScore();
|
||||
|
||||
/* score.Pass = true;*/
|
||||
@ -107,5 +110,11 @@ namespace osu.Game.Database
|
||||
|
||||
return score;
|
||||
}
|
||||
|
||||
protected override void Prepare(bool reset = false)
|
||||
{
|
||||
}
|
||||
|
||||
protected override Type[] ValidTypes => new[] { typeof(Score) };
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,14 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Game.Graphics;
|
||||
|
||||
namespace osu.Game.Modes
|
||||
{
|
||||
public enum PlayMode
|
||||
public class BeatmapStatistic
|
||||
{
|
||||
Osu = 0,
|
||||
Taiko = 1,
|
||||
Catch = 2,
|
||||
Mania = 3
|
||||
public FontAwesome Icon;
|
||||
public string Content;
|
||||
public string Name;
|
||||
}
|
||||
}
|
||||
}
|
@ -6,26 +6,13 @@ using osu.Game.Graphics;
|
||||
using osu.Game.Modes.Mods;
|
||||
using osu.Game.Modes.UI;
|
||||
using osu.Game.Screens.Play;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Modes.Scoring;
|
||||
|
||||
namespace osu.Game.Modes
|
||||
{
|
||||
public class BeatmapStatistic
|
||||
{
|
||||
public FontAwesome Icon;
|
||||
public string Content;
|
||||
public string Name;
|
||||
}
|
||||
|
||||
public abstract class Ruleset
|
||||
{
|
||||
private static readonly ConcurrentDictionary<PlayMode, Type> available_rulesets = new ConcurrentDictionary<PlayMode, Type>();
|
||||
|
||||
public static IEnumerable<PlayMode> PlayModes => available_rulesets.Keys;
|
||||
|
||||
public virtual IEnumerable<BeatmapStatistic> GetBeatmapStatistics(WorkingBeatmap beatmap) => new BeatmapStatistic[] { };
|
||||
|
||||
public abstract IEnumerable<Mod> GetModsFor(ModType type);
|
||||
@ -36,25 +23,15 @@ namespace osu.Game.Modes
|
||||
|
||||
public abstract ScoreProcessor CreateScoreProcessor();
|
||||
|
||||
public static void Register(Ruleset ruleset) => available_rulesets.TryAdd(ruleset.PlayMode, ruleset.GetType());
|
||||
|
||||
protected abstract PlayMode PlayMode { get; }
|
||||
|
||||
public virtual FontAwesome Icon => FontAwesome.fa_question_circle;
|
||||
|
||||
public abstract string Description { get; }
|
||||
|
||||
public abstract IEnumerable<KeyCounter> CreateGameplayKeys();
|
||||
|
||||
public static Ruleset GetRuleset(PlayMode mode)
|
||||
{
|
||||
Type type;
|
||||
|
||||
if (!available_rulesets.TryGetValue(mode, out type))
|
||||
return null;
|
||||
|
||||
return Activator.CreateInstance(type) as Ruleset;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Do not override this unless you are a legacy mode.
|
||||
/// </summary>
|
||||
public virtual int LegacyID => -1;
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,6 @@ using osu.Framework.Logging;
|
||||
using osu.Game.Graphics.UserInterface.Volume;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Modes;
|
||||
using osu.Game.Overlays.Toolbar;
|
||||
using osu.Game.Screens;
|
||||
using osu.Game.Screens.Menu;
|
||||
@ -24,6 +23,7 @@ using System.Linq;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Modes.Scoring;
|
||||
using osu.Game.Overlays.Notifications;
|
||||
@ -58,7 +58,8 @@ namespace osu.Game
|
||||
|
||||
private VolumeControl volume;
|
||||
|
||||
public Bindable<PlayMode> PlayMode;
|
||||
private Bindable<int> configRuleset;
|
||||
public Bindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
|
||||
|
||||
private readonly string[] args;
|
||||
|
||||
@ -88,7 +89,9 @@ namespace osu.Game
|
||||
|
||||
Dependencies.Cache(this);
|
||||
|
||||
PlayMode = LocalConfig.GetBindable<PlayMode>(OsuConfig.PlayMode);
|
||||
configRuleset = LocalConfig.GetBindable<int>(OsuConfig.Ruleset);
|
||||
Ruleset.Value = RulesetDatabase.GetRuleset(configRuleset.Value);
|
||||
Ruleset.ValueChanged += r => configRuleset.Value = r.ID ?? 0;
|
||||
}
|
||||
|
||||
private ScheduledDelegate scoreLoad;
|
||||
@ -199,11 +202,11 @@ namespace osu.Game
|
||||
{
|
||||
Depth = -3,
|
||||
OnHome = delegate { intro?.ChildScreen?.MakeCurrent(); },
|
||||
OnPlayModeChange = m => PlayMode.Value = m,
|
||||
OnRulesetChange = r => Ruleset.Value = r,
|
||||
}, t =>
|
||||
{
|
||||
PlayMode.ValueChanged += delegate { Toolbar.SetGameMode(PlayMode.Value); };
|
||||
PlayMode.TriggerChange();
|
||||
Ruleset.ValueChanged += delegate { Toolbar.SetGameMode(Ruleset.Value); };
|
||||
Ruleset.TriggerChange();
|
||||
overlayContent.Add(Toolbar);
|
||||
});
|
||||
|
||||
|
@ -18,6 +18,7 @@ using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Cursor;
|
||||
using osu.Game.Graphics.Processing;
|
||||
using osu.Game.Online.API;
|
||||
using SQLite.Net;
|
||||
|
||||
namespace osu.Game
|
||||
{
|
||||
@ -27,6 +28,8 @@ namespace osu.Game
|
||||
|
||||
protected BeatmapDatabase BeatmapDatabase;
|
||||
|
||||
protected RulesetDatabase RulesetDatabase;
|
||||
|
||||
protected ScoreDatabase ScoreDatabase;
|
||||
|
||||
protected override string MainResourceFile => @"osu.Game.Resources.dll";
|
||||
@ -80,8 +83,12 @@ namespace osu.Game
|
||||
{
|
||||
Dependencies.Cache(this);
|
||||
Dependencies.Cache(LocalConfig);
|
||||
Dependencies.Cache(BeatmapDatabase = new BeatmapDatabase(Host.Storage, Host));
|
||||
Dependencies.Cache(ScoreDatabase = new ScoreDatabase(Host.Storage, Host, BeatmapDatabase));
|
||||
|
||||
SQLiteConnection connection = Host.Storage.GetDatabase(@"client");
|
||||
|
||||
Dependencies.Cache(RulesetDatabase = new RulesetDatabase(Host.Storage, connection));
|
||||
Dependencies.Cache(BeatmapDatabase = new BeatmapDatabase(Host.Storage, connection, RulesetDatabase, Host));
|
||||
Dependencies.Cache(ScoreDatabase = new ScoreDatabase(Host.Storage, connection, Host, BeatmapDatabase));
|
||||
Dependencies.Cache(new OsuColour());
|
||||
|
||||
//this completely overrides the framework default. will need to change once we make a proper FontStore.
|
||||
|
@ -13,11 +13,11 @@ using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Backgrounds;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Modes;
|
||||
using osu.Game.Modes.Mods;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Game.Database;
|
||||
|
||||
namespace osu.Game.Overlays.Mods
|
||||
{
|
||||
@ -37,26 +37,30 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
public readonly Bindable<IEnumerable<Mod>> SelectedMods = new Bindable<IEnumerable<Mod>>();
|
||||
|
||||
public readonly Bindable<PlayMode> PlayMode = new Bindable<PlayMode>();
|
||||
public readonly Bindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
|
||||
|
||||
private void modeChanged(PlayMode newMode)
|
||||
private void rulesetChanged(RulesetInfo newRuleset)
|
||||
{
|
||||
var ruleset = Ruleset.GetRuleset(newMode);
|
||||
var instance = newRuleset.CreateInstance();
|
||||
|
||||
foreach (ModSection section in modSectionsContainer.Children)
|
||||
section.Buttons = ruleset.GetModsFor(section.ModType).Select(m => new ModButton(m)).ToArray();
|
||||
section.Buttons = instance.GetModsFor(section.ModType).Select(m => new ModButton(m)).ToArray();
|
||||
refreshSelectedMods();
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(permitNulls: true)]
|
||||
private void load(OsuColour colours, OsuGame osu)
|
||||
private void load(OsuColour colours, OsuGame osu, RulesetDatabase rulesets)
|
||||
{
|
||||
lowMultiplierColour = colours.Red;
|
||||
highMultiplierColour = colours.Green;
|
||||
|
||||
if (osu != null)
|
||||
PlayMode.BindTo(osu.PlayMode);
|
||||
PlayMode.ValueChanged += modeChanged;
|
||||
PlayMode.TriggerChange();
|
||||
Ruleset.BindTo(osu.Ruleset);
|
||||
else
|
||||
Ruleset.Value = rulesets.AllRulesets.First();
|
||||
|
||||
Ruleset.ValueChanged += rulesetChanged;
|
||||
Ruleset.TriggerChange();
|
||||
}
|
||||
|
||||
protected override void PopOut()
|
||||
|
@ -1,15 +1,14 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Modes;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
@ -18,7 +17,7 @@ namespace osu.Game.Overlays.Options
|
||||
public class OptionsFooter : FillFlowContainer
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuGameBase game, OsuColour colours)
|
||||
private void load(OsuGameBase game, OsuColour colours, RulesetDatabase rulesets)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
@ -27,13 +26,15 @@ namespace osu.Game.Overlays.Options
|
||||
|
||||
var modes = new List<Drawable>();
|
||||
|
||||
foreach (PlayMode m in Enum.GetValues(typeof(PlayMode)))
|
||||
foreach (var ruleset in rulesets.AllRulesets)
|
||||
{
|
||||
modes.Add(new TextAwesome
|
||||
{
|
||||
Icon = Ruleset.GetRuleset(m).Icon,
|
||||
Icon = ruleset.CreateInstance().Icon,
|
||||
Colour = Color4.Gray,
|
||||
TextSize = 20
|
||||
});
|
||||
}
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
|
@ -8,8 +8,8 @@ using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Modes;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Overlays.Toolbar
|
||||
@ -20,7 +20,7 @@ namespace osu.Game.Overlays.Toolbar
|
||||
public const float TOOLTIP_HEIGHT = 30;
|
||||
|
||||
public Action OnHome;
|
||||
public Action<PlayMode> OnPlayModeChange;
|
||||
public Action<RulesetInfo> OnRulesetChange;
|
||||
|
||||
private readonly ToolbarModeSelector modeSelector;
|
||||
private readonly ToolbarUserArea userArea;
|
||||
@ -55,9 +55,9 @@ namespace osu.Game.Overlays.Toolbar
|
||||
},
|
||||
modeSelector = new ToolbarModeSelector
|
||||
{
|
||||
OnPlayModeChange = mode =>
|
||||
OnRulesetChange = mode =>
|
||||
{
|
||||
OnPlayModeChange?.Invoke(mode);
|
||||
OnRulesetChange?.Invoke(mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -129,7 +129,7 @@ namespace osu.Game.Overlays.Toolbar
|
||||
}
|
||||
}
|
||||
|
||||
public void SetGameMode(PlayMode mode) => modeSelector.SetGameMode(mode);
|
||||
public void SetGameMode(RulesetInfo ruleset) => modeSelector.SetGameMode(ruleset);
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
|
@ -2,23 +2,26 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Modes;
|
||||
using osu.Game.Database;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays.Toolbar
|
||||
{
|
||||
public class ToolbarModeButton : ToolbarButton
|
||||
{
|
||||
private PlayMode mode;
|
||||
public PlayMode Mode
|
||||
private RulesetInfo ruleset;
|
||||
public RulesetInfo Ruleset
|
||||
{
|
||||
get { return mode; }
|
||||
get { return ruleset; }
|
||||
set
|
||||
{
|
||||
mode = value;
|
||||
TooltipMain = Ruleset.GetRuleset(mode).Description;
|
||||
TooltipSub = $"Play some {Ruleset.GetRuleset(mode).Description}";
|
||||
Icon = Ruleset.GetRuleset(mode).Icon;
|
||||
ruleset = value;
|
||||
|
||||
var rInstance = ruleset.CreateInstance();
|
||||
|
||||
TooltipMain = rInstance.Description;
|
||||
TooltipSub = $"Play some {rInstance.Description}";
|
||||
Icon = rInstance.Icon;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,12 +3,13 @@
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Caching;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Modes;
|
||||
using osu.Game.Database;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
@ -22,7 +23,7 @@ namespace osu.Game.Overlays.Toolbar
|
||||
private readonly Drawable modeButtonLine;
|
||||
private ToolbarModeButton activeButton;
|
||||
|
||||
public Action<PlayMode> OnPlayModeChange;
|
||||
public Action<RulesetInfo> OnRulesetChange;
|
||||
|
||||
public ToolbarModeSelector()
|
||||
{
|
||||
@ -62,16 +63,20 @@ namespace osu.Game.Overlays.Toolbar
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
foreach (PlayMode m in Ruleset.PlayModes)
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(RulesetDatabase rulesets)
|
||||
{
|
||||
foreach (var ruleset in rulesets.AllRulesets)
|
||||
{
|
||||
modeButtons.Add(new ToolbarModeButton
|
||||
{
|
||||
Mode = m,
|
||||
Ruleset = ruleset,
|
||||
Action = delegate
|
||||
{
|
||||
SetGameMode(m);
|
||||
OnPlayModeChange?.Invoke(m);
|
||||
SetGameMode(ruleset);
|
||||
OnRulesetChange?.Invoke(ruleset);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -84,11 +89,11 @@ namespace osu.Game.Overlays.Toolbar
|
||||
Size = new Vector2(modeButtons.DrawSize.X, 1);
|
||||
}
|
||||
|
||||
public void SetGameMode(PlayMode mode)
|
||||
public void SetGameMode(RulesetInfo ruleset)
|
||||
{
|
||||
foreach (ToolbarModeButton m in modeButtons.Children.Cast<ToolbarModeButton>())
|
||||
{
|
||||
bool isActive = m.Mode == mode;
|
||||
bool isActive = m.Ruleset.ID == ruleset.ID;
|
||||
m.Active = isActive;
|
||||
if (isActive)
|
||||
activeButton = m;
|
||||
|
@ -63,13 +63,6 @@ namespace osu.Game.Screens.Play
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuConfigManager config)
|
||||
{
|
||||
if (Beatmap.Beatmap.BeatmapInfo?.Mode > PlayMode.Taiko)
|
||||
{
|
||||
//we only support osu! mode for now because the hitobject parsing is crappy and needs a refactor.
|
||||
Exit();
|
||||
return;
|
||||
}
|
||||
|
||||
dimLevel = config.GetBindable<int>(OsuConfig.DimLevel);
|
||||
mouseWheelDisabled = config.GetBindable<bool>(OsuConfig.MouseDisableWheel);
|
||||
|
||||
@ -109,7 +102,10 @@ namespace osu.Game.Screens.Play
|
||||
sourceClock.Reset();
|
||||
});
|
||||
|
||||
ruleset = Ruleset.GetRuleset(Beatmap.PlayMode);
|
||||
ruleset = Beatmap.BeatmapInfo.Ruleset.CreateInstance();
|
||||
|
||||
// Todo: This should be done as early as possible, and should check if the hit renderer
|
||||
// can actually convert the hit objects... Somehow...
|
||||
HitRenderer = ruleset.CreateHitRendererWith(Beatmap);
|
||||
|
||||
scoreProcessor = HitRenderer.CreateScoreProcessor();
|
||||
|
@ -145,7 +145,7 @@ namespace osu.Game.Screens.Select
|
||||
}
|
||||
}
|
||||
|
||||
int startIndex = groups.IndexOf(selectedGroup);
|
||||
int startIndex = Math.Max(0, groups.IndexOf(selectedGroup));
|
||||
int index = startIndex;
|
||||
|
||||
do
|
||||
@ -221,7 +221,12 @@ namespace osu.Game.Screens.Select
|
||||
private BeatmapGroup createGroup(BeatmapSetInfo beatmapSet)
|
||||
{
|
||||
database.GetChildren(beatmapSet);
|
||||
beatmapSet.Beatmaps.ForEach(b => { if (b.Metadata == null) b.Metadata = beatmapSet.Metadata; });
|
||||
beatmapSet.Beatmaps.ForEach(b =>
|
||||
{
|
||||
database.GetChildren(b);
|
||||
if (b.Metadata == null)
|
||||
b.Metadata = beatmapSet.Metadata;
|
||||
});
|
||||
|
||||
return new BeatmapGroup(beatmapSet, database)
|
||||
{
|
||||
|
@ -102,7 +102,7 @@ namespace osu.Game.Screens.Select
|
||||
}));
|
||||
|
||||
//get statistics fromt he current ruleset.
|
||||
labels.AddRange(Ruleset.GetRuleset(beatmap.BeatmapInfo.Mode).GetBeatmapStatistics(beatmap).Select(s => new InfoLabel(s)));
|
||||
labels.AddRange(beatmap.BeatmapInfo.Ruleset.CreateInstance().GetBeatmapStatistics(beatmap).Select(s => new InfoLabel(s)));
|
||||
}
|
||||
|
||||
AlwaysPresent = true;
|
||||
|
@ -16,7 +16,7 @@ using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Screens.Select.Filter;
|
||||
using Container = osu.Framework.Graphics.Containers.Container;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Modes;
|
||||
using osu.Game.Database;
|
||||
|
||||
namespace osu.Game.Screens.Select
|
||||
{
|
||||
@ -61,7 +61,7 @@ namespace osu.Game.Screens.Select
|
||||
Group = group,
|
||||
Sort = sort,
|
||||
SearchText = searchTextBox.Text,
|
||||
Mode = playMode
|
||||
Ruleset = ruleset
|
||||
};
|
||||
|
||||
public Action Exit;
|
||||
@ -163,16 +163,17 @@ namespace osu.Game.Screens.Select
|
||||
searchTextBox.HoldFocus = true;
|
||||
}
|
||||
|
||||
private readonly Bindable<PlayMode> playMode = new Bindable<PlayMode>();
|
||||
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
|
||||
|
||||
[BackgroundDependencyLoader(permitNulls:true)]
|
||||
private void load(OsuColour colours, OsuGame osu)
|
||||
{
|
||||
sortTabs.AccentColour = colours.GreenLight;
|
||||
|
||||
if (osu != null) playMode.BindTo(osu.PlayMode);
|
||||
playMode.ValueChanged += val => FilterChanged?.Invoke(CreateCriteria());
|
||||
playMode.TriggerChange();
|
||||
if (osu != null)
|
||||
ruleset.BindTo(osu.Ruleset);
|
||||
ruleset.ValueChanged += val => FilterChanged?.Invoke(CreateCriteria());
|
||||
ruleset.TriggerChange();
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true;
|
||||
|
@ -5,7 +5,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Modes;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Screens.Select.Filter;
|
||||
|
||||
namespace osu.Game.Screens.Select
|
||||
@ -15,7 +15,7 @@ namespace osu.Game.Screens.Select
|
||||
public GroupMode Group;
|
||||
public SortMode Sort;
|
||||
public string SearchText;
|
||||
public PlayMode Mode;
|
||||
public RulesetInfo Ruleset;
|
||||
|
||||
public void Filter(List<BeatmapGroup> groups)
|
||||
{
|
||||
@ -23,7 +23,7 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
var set = g.BeatmapSet;
|
||||
|
||||
bool hasCurrentMode = set.Beatmaps.Any(bm => bm.Mode == Mode);
|
||||
bool hasCurrentMode = set.Beatmaps.Any(bm => bm.RulesetID == (Ruleset?.ID ?? 0));
|
||||
|
||||
bool match = hasCurrentMode;
|
||||
|
||||
|
@ -20,7 +20,6 @@ using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Modes;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Screens.Backgrounds;
|
||||
using osu.Game.Screens.Select.Options;
|
||||
@ -29,7 +28,7 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
public abstract class SongSelect : OsuScreen
|
||||
{
|
||||
private readonly Bindable<PlayMode> playMode = new Bindable<PlayMode>();
|
||||
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
|
||||
private BeatmapDatabase database;
|
||||
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
|
||||
|
||||
@ -170,8 +169,8 @@ namespace osu.Game.Screens.Select
|
||||
if (database == null)
|
||||
database = beatmaps;
|
||||
|
||||
playMode.ValueChanged += val => { if (Beatmap != null) Beatmap.PreferredPlayMode = val; };
|
||||
if (osu != null) playMode.BindTo(osu.PlayMode);
|
||||
if (osu != null)
|
||||
ruleset.BindTo(osu.Ruleset);
|
||||
|
||||
database.BeatmapSetAdded += onBeatmapSetAdded;
|
||||
database.BeatmapSetRemoved += onBeatmapSetRemoved;
|
||||
@ -200,7 +199,6 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
if (Beatmap == null) return;
|
||||
|
||||
Beatmap.PreferredPlayMode = playMode.Value;
|
||||
OnSelected();
|
||||
}
|
||||
|
||||
|
@ -78,6 +78,8 @@
|
||||
<Compile Include="Beatmaps\Timing\TimeSignatures.cs" />
|
||||
<Compile Include="Beatmaps\Timing\TimingInfo.cs" />
|
||||
<Compile Include="Database\BeatmapMetrics.cs" />
|
||||
<Compile Include="Database\Database.cs" />
|
||||
<Compile Include="Database\RulesetInfo.cs" />
|
||||
<Compile Include="Database\ScoreDatabase.cs" />
|
||||
<Compile Include="Graphics\Backgrounds\Triangles.cs" />
|
||||
<Compile Include="Graphics\Cursor\CursorTrail.cs" />
|
||||
@ -101,6 +103,7 @@
|
||||
<Compile Include="IO\Legacy\SerializationWriter.cs" />
|
||||
<Compile Include="IO\Serialization\IJsonSerializable.cs" />
|
||||
<Compile Include="IPC\ScoreIPCChannel.cs" />
|
||||
<Compile Include="Modes\BeatmapStatistic.cs" />
|
||||
<Compile Include="Modes\Replays\Replay.cs" />
|
||||
<Compile Include="Modes\Judgements\DrawableJudgement.cs" />
|
||||
<Compile Include="Modes\Judgements\IPartialJudgement.cs" />
|
||||
@ -132,6 +135,7 @@
|
||||
<Compile Include="Modes\Objects\Legacy\LegacyHitObjectType.cs" />
|
||||
<Compile Include="Modes\Replays\ReplayButtonState.cs" />
|
||||
<Compile Include="Modes\Replays\ReplayFrame.cs" />
|
||||
<Compile Include="Database\RulesetDatabase.cs" />
|
||||
<Compile Include="Modes\Scoring\Score.cs" />
|
||||
<Compile Include="Modes\Scoring\ScoreProcessor.cs" />
|
||||
<Compile Include="Modes\UI\HealthDisplay.cs" />
|
||||
@ -217,7 +221,6 @@
|
||||
<Compile Include="Beatmaps\Drawables\BeatmapPanel.cs" />
|
||||
<Compile Include="Screens\Play\Player.cs" />
|
||||
<Compile Include="Screens\Charts\ChartListing.cs" />
|
||||
<Compile Include="Modes\PlayMode.cs" />
|
||||
<Compile Include="Modes\Ruleset.cs" />
|
||||
<Compile Include="Screens\Ranking\Results.cs" />
|
||||
<Compile Include="Screens\Direct\OnlineListing.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user