mirror of
https://github.com/ppy/osu.git
synced 2025-02-22 17:22:58 +08:00
Better default values + don't set Mode from outside.
This commit is contained in:
parent
0333e1a050
commit
4a149c4ab8
@ -8,6 +8,7 @@ using osu.Framework.MathUtils;
|
|||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.Screens.Select;
|
using osu.Game.Screens.Select;
|
||||||
using osu.Game.Screens.Select.Filter;
|
using osu.Game.Screens.Select.Filter;
|
||||||
|
using osu.Game.Modes;
|
||||||
|
|
||||||
namespace osu.Desktop.VisualTests.Tests
|
namespace osu.Desktop.VisualTests.Tests
|
||||||
{
|
{
|
||||||
@ -71,7 +72,7 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
new BeatmapInfo
|
new BeatmapInfo
|
||||||
{
|
{
|
||||||
OnlineBeatmapID = 1234 + i,
|
OnlineBeatmapID = 1234 + i,
|
||||||
Mode = 0,
|
Ruleset = RulesetCollection.GetRuleset(0),
|
||||||
Path = "normal.osu",
|
Path = "normal.osu",
|
||||||
Version = "Normal",
|
Version = "Normal",
|
||||||
Difficulty = new BeatmapDifficulty
|
Difficulty = new BeatmapDifficulty
|
||||||
@ -82,7 +83,7 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
new BeatmapInfo
|
new BeatmapInfo
|
||||||
{
|
{
|
||||||
OnlineBeatmapID = 1235 + i,
|
OnlineBeatmapID = 1235 + i,
|
||||||
Mode = 0,
|
Ruleset = RulesetCollection.GetRuleset(0),
|
||||||
Path = "hard.osu",
|
Path = "hard.osu",
|
||||||
Version = "Hard",
|
Version = "Hard",
|
||||||
Difficulty = new BeatmapDifficulty
|
Difficulty = new BeatmapDifficulty
|
||||||
@ -93,7 +94,7 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
new BeatmapInfo
|
new BeatmapInfo
|
||||||
{
|
{
|
||||||
OnlineBeatmapID = 1236 + i,
|
OnlineBeatmapID = 1236 + i,
|
||||||
Mode = 0,
|
Ruleset = RulesetCollection.GetRuleset(0),
|
||||||
Path = "insane.osu",
|
Path = "insane.osu",
|
||||||
Version = "Insane",
|
Version = "Insane",
|
||||||
Difficulty = new BeatmapDifficulty
|
Difficulty = new BeatmapDifficulty
|
||||||
|
@ -56,7 +56,13 @@ namespace osu.Game.Database
|
|||||||
public bool SpecialStyle { get; set; }
|
public bool SpecialStyle { get; set; }
|
||||||
|
|
||||||
public int Mode { get; set; }
|
public int Mode { get; set; }
|
||||||
public Ruleset Ruleset => RulesetCollection.GetRuleset(Mode);
|
|
||||||
|
[Ignore]
|
||||||
|
public Ruleset Ruleset
|
||||||
|
{
|
||||||
|
get { return RulesetCollection.GetRuleset(Mode); }
|
||||||
|
set { Mode = RulesetCollection.GetId(value); }
|
||||||
|
}
|
||||||
|
|
||||||
public bool LetterboxInBreaks { get; set; }
|
public bool LetterboxInBreaks { get; set; }
|
||||||
public bool WidescreenStoryboard { get; set; }
|
public bool WidescreenStoryboard { get; set; }
|
||||||
|
@ -8,13 +8,16 @@ using System.Linq;
|
|||||||
|
|
||||||
namespace osu.Game.Modes
|
namespace osu.Game.Modes
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Todo: All of this needs to be moved to a RulesetDatabase.
|
||||||
|
/// </summary>
|
||||||
public static class RulesetCollection
|
public static class RulesetCollection
|
||||||
{
|
{
|
||||||
private static readonly ConcurrentDictionary<int, Ruleset> available_rulesets = new ConcurrentDictionary<int, Ruleset>();
|
private static readonly ConcurrentDictionary<int, Ruleset> available_rulesets = new ConcurrentDictionary<int, Ruleset>();
|
||||||
|
|
||||||
public static void Register(Type type)
|
public static void Register(Type type)
|
||||||
{
|
{
|
||||||
Ruleset ruleset = Activator.CreateInstance(type) as Ruleset;
|
var ruleset = Activator.CreateInstance(type) as Ruleset;
|
||||||
|
|
||||||
if (ruleset == null)
|
if (ruleset == null)
|
||||||
return;
|
return;
|
||||||
@ -27,7 +30,7 @@ namespace osu.Game.Modes
|
|||||||
Ruleset ruleset;
|
Ruleset ruleset;
|
||||||
|
|
||||||
if (!available_rulesets.TryGetValue(rulesetId, out ruleset))
|
if (!available_rulesets.TryGetValue(rulesetId, out ruleset))
|
||||||
throw new InvalidOperationException($"Ruleset id {rulesetId} doesn't exist. How did you trigger this?");
|
return null;
|
||||||
|
|
||||||
return ruleset;
|
return ruleset;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
|
|
||||||
public readonly Bindable<IEnumerable<Mod>> SelectedMods = new Bindable<IEnumerable<Mod>>();
|
public readonly Bindable<IEnumerable<Mod>> SelectedMods = new Bindable<IEnumerable<Mod>>();
|
||||||
|
|
||||||
public readonly Bindable<Ruleset> Ruleset = new Bindable<Ruleset>();
|
public readonly Bindable<Ruleset> Ruleset = new Bindable<Ruleset>(RulesetCollection.GetRuleset(0));
|
||||||
|
|
||||||
private void rulesetChanged(Ruleset newRuleset)
|
private void rulesetChanged(Ruleset newRuleset)
|
||||||
{
|
{
|
||||||
|
@ -163,7 +163,7 @@ namespace osu.Game.Screens.Select
|
|||||||
searchTextBox.HoldFocus = true;
|
searchTextBox.HoldFocus = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly Bindable<Ruleset> ruleset = new Bindable<Ruleset>();
|
private readonly Bindable<Ruleset> ruleset = new Bindable<Ruleset>(RulesetCollection.GetRuleset(0));
|
||||||
|
|
||||||
[BackgroundDependencyLoader(permitNulls:true)]
|
[BackgroundDependencyLoader(permitNulls:true)]
|
||||||
private void load(OsuColour colours, OsuGame osu)
|
private void load(OsuColour colours, OsuGame osu)
|
||||||
|
@ -29,7 +29,7 @@ namespace osu.Game.Screens.Select
|
|||||||
{
|
{
|
||||||
public abstract class SongSelect : OsuScreen
|
public abstract class SongSelect : OsuScreen
|
||||||
{
|
{
|
||||||
private readonly Bindable<Ruleset> ruleset = new Bindable<Ruleset>();
|
private readonly Bindable<Ruleset> ruleset = new Bindable<Ruleset>(RulesetCollection.GetRuleset(0));
|
||||||
private BeatmapDatabase database;
|
private BeatmapDatabase database;
|
||||||
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
|
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user