diff --git a/osu.Game.Rulesets.Mania/Configuration/ManiaConfigManager.cs b/osu.Game.Rulesets.Mania/Configuration/ManiaConfigManager.cs index 3167d8300d..a4de360870 100644 --- a/osu.Game.Rulesets.Mania/Configuration/ManiaConfigManager.cs +++ b/osu.Game.Rulesets.Mania/Configuration/ManiaConfigManager.cs @@ -9,8 +9,8 @@ namespace osu.Game.Rulesets.Mania.Configuration { public class ManiaConfigManager : RulesetConfigManager { - public ManiaConfigManager(RulesetInfo ruleset, SettingsStore settings) - : base(ruleset, settings) + public ManiaConfigManager(SettingsStore settings, RulesetInfo ruleset, int variant) + : base(settings, ruleset, variant) { } diff --git a/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs b/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs index f517d6b041..436d5c1ea6 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs @@ -80,11 +80,9 @@ namespace osu.Game.Rulesets.Mania.UI public override ScoreProcessor CreateScoreProcessor() => new ManiaScoreProcessor(this); - public override PassThroughInputManager CreateInputManager() - { - var variantType = Mods.OfType().FirstOrDefault()?.PlayfieldType ?? PlayfieldType.Single; - return new ManiaInputManager(Ruleset.RulesetInfo, (int)variantType + Beatmap.TotalColumns); - } + public override int Variant => (int)(Mods.OfType().FirstOrDefault()?.PlayfieldType ?? PlayfieldType.Single) + Beatmap.TotalColumns; + + public override PassThroughInputManager CreateInputManager() => new ManiaInputManager(Ruleset.RulesetInfo, Variant); protected override BeatmapConverter CreateBeatmapConverter() => new ManiaBeatmapConverter(IsForCurrentRuleset, WorkingBeatmap.Beatmap); @@ -107,6 +105,6 @@ namespace osu.Game.Rulesets.Mania.UI protected override FramedReplayInputHandler CreateReplayInputHandler(Replay replay) => new ManiaFramedReplayInputHandler(replay, this); - protected override IRulesetConfigManager CreateConfig(Ruleset ruleset, SettingsStore settings) => new ManiaConfigManager(Ruleset.RulesetInfo, settings); + protected override IRulesetConfigManager CreateConfig(Ruleset ruleset, SettingsStore settings) => new ManiaConfigManager(settings, Ruleset.RulesetInfo, Variant); } } diff --git a/osu.Game/Configuration/DatabasedConfigManager.cs b/osu.Game/Configuration/DatabasedConfigManager.cs index f982490523..5505f3d31b 100644 --- a/osu.Game/Configuration/DatabasedConfigManager.cs +++ b/osu.Game/Configuration/DatabasedConfigManager.cs @@ -17,12 +17,12 @@ namespace osu.Game.Configuration private readonly RulesetInfo ruleset; - protected DatabasedConfigManager(SettingsStore settings, RulesetInfo ruleset = null) + protected DatabasedConfigManager(SettingsStore settings, RulesetInfo ruleset = null, int variant = 0) { this.settings = settings; this.ruleset = ruleset; - databasedSettings = settings.Query(ruleset?.ID); + databasedSettings = settings.Query(ruleset?.ID, variant); InitialiseDefaults(); } diff --git a/osu.Game/Configuration/DatabasedSetting.cs b/osu.Game/Configuration/DatabasedSetting.cs index c284c10872..7c2f65c854 100644 --- a/osu.Game/Configuration/DatabasedSetting.cs +++ b/osu.Game/Configuration/DatabasedSetting.cs @@ -14,6 +14,8 @@ namespace osu.Game.Configuration public int? RulesetID { get; set; } + public int? Variant { get; set; } + [Column("Key")] public int IntKey { diff --git a/osu.Game/Configuration/SettingsStore.cs b/osu.Game/Configuration/SettingsStore.cs index 6bb186604f..536b4f5786 100644 --- a/osu.Game/Configuration/SettingsStore.cs +++ b/osu.Game/Configuration/SettingsStore.cs @@ -23,8 +23,8 @@ namespace osu.Game.Configuration /// The ruleset's internal ID. /// An optional variant. /// - public List Query(int? rulesetId = null) => - GetContext().DatabasedSetting.Where(b => b.RulesetID == rulesetId).ToList(); + public List Query(int? rulesetId = null, int? variant = null) => + GetContext().DatabasedSetting.Where(b => b.RulesetID == rulesetId && b.Variant == variant).ToList(); public void Update(DatabasedSetting setting) { diff --git a/osu.Game/Database/OsuDbContext.cs b/osu.Game/Database/OsuDbContext.cs index be0b4f3543..0fa1f238a9 100644 --- a/osu.Game/Database/OsuDbContext.cs +++ b/osu.Game/Database/OsuDbContext.cs @@ -91,7 +91,7 @@ namespace osu.Game.Database modelBuilder.Entity().HasIndex(b => new { b.RulesetID, b.Variant }); modelBuilder.Entity().HasIndex(b => b.IntAction); - modelBuilder.Entity().HasIndex(b => b.RulesetID); + modelBuilder.Entity().HasIndex(b => new { b.RulesetID, b.Variant }); modelBuilder.Entity().HasIndex(b => b.Hash).IsUnique(); modelBuilder.Entity().HasIndex(b => b.ReferenceCount); diff --git a/osu.Game/Migrations/20180124024000_AddSettings.Designer.cs b/osu.Game/Migrations/20180125143340_Settings.Designer.cs similarity index 94% rename from osu.Game/Migrations/20180124024000_AddSettings.Designer.cs rename to osu.Game/Migrations/20180125143340_Settings.Designer.cs index 5bbf382f7f..8e045abc6f 100644 --- a/osu.Game/Migrations/20180124024000_AddSettings.Designer.cs +++ b/osu.Game/Migrations/20180125143340_Settings.Designer.cs @@ -10,8 +10,8 @@ using System; namespace osu.Game.Migrations { [DbContext(typeof(OsuDbContext))] - [Migration("20180124024000_AddSettings")] - partial class AddSettings + [Migration("20180125143340_Settings")] + partial class Settings { protected override void BuildTargetModel(ModelBuilder modelBuilder) { @@ -202,14 +202,16 @@ namespace osu.Game.Migrations b.Property("IntKey") .HasColumnName("Key"); - b.Property("IntValue") + b.Property("RulesetID"); + + b.Property("StringValue") .HasColumnName("Value"); - b.Property("RulesetID"); + b.Property("Variant"); b.HasKey("ID"); - b.HasIndex("RulesetID"); + b.HasIndex("RulesetID", "Variant"); b.ToTable("Settings"); }); diff --git a/osu.Game/Migrations/20180124024000_AddSettings.cs b/osu.Game/Migrations/20180125143340_Settings.cs similarity index 80% rename from osu.Game/Migrations/20180124024000_AddSettings.cs rename to osu.Game/Migrations/20180125143340_Settings.cs index 63cacc0645..86a6b2dc5e 100644 --- a/osu.Game/Migrations/20180124024000_AddSettings.cs +++ b/osu.Game/Migrations/20180125143340_Settings.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; namespace osu.Game.Migrations { - public partial class AddSettings : Migration + public partial class Settings : Migration { protected override void Up(MigrationBuilder migrationBuilder) { @@ -19,8 +19,9 @@ namespace osu.Game.Migrations ID = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Key = table.Column(type: "INTEGER", nullable: false), - Value = table.Column(type: "INTEGER", nullable: false), - RulesetID = table.Column(type: "INTEGER", nullable: true) + RulesetID = table.Column(type: "INTEGER", nullable: true), + Value = table.Column(type: "TEXT", nullable: true), + Variant = table.Column(type: "INTEGER", nullable: true) }, constraints: table => { @@ -33,9 +34,9 @@ namespace osu.Game.Migrations columns: new[] { "RulesetID", "Variant" }); migrationBuilder.CreateIndex( - name: "IX_Settings_RulesetID", + name: "IX_Settings_RulesetID_Variant", table: "Settings", - column: "RulesetID"); + columns: new[] { "RulesetID", "Variant" }); } protected override void Down(MigrationBuilder migrationBuilder) diff --git a/osu.Game/Migrations/OsuDbContextModelSnapshot.cs b/osu.Game/Migrations/OsuDbContextModelSnapshot.cs index 37e2aee3a0..157125102f 100644 --- a/osu.Game/Migrations/OsuDbContextModelSnapshot.cs +++ b/osu.Game/Migrations/OsuDbContextModelSnapshot.cs @@ -201,14 +201,16 @@ namespace osu.Game.Migrations b.Property("IntKey") .HasColumnName("Key"); - b.Property("IntValue") + b.Property("RulesetID"); + + b.Property("StringValue") .HasColumnName("Value"); - b.Property("RulesetID"); + b.Property("Variant"); b.HasKey("ID"); - b.HasIndex("RulesetID"); + b.HasIndex("RulesetID", "Variant"); b.ToTable("Settings"); }); diff --git a/osu.Game/Rulesets/Configuration/RulesetConfigManager.cs b/osu.Game/Rulesets/Configuration/RulesetConfigManager.cs index 4f9fbe9830..9f244f6267 100644 --- a/osu.Game/Rulesets/Configuration/RulesetConfigManager.cs +++ b/osu.Game/Rulesets/Configuration/RulesetConfigManager.cs @@ -8,7 +8,7 @@ namespace osu.Game.Rulesets.Configuration public abstract class RulesetConfigManager : DatabasedConfigManager, IRulesetConfigManager where T : struct { - protected RulesetConfigManager(RulesetInfo ruleset, SettingsStore settings) : base(settings, ruleset) + protected RulesetConfigManager(SettingsStore settings, RulesetInfo ruleset, int variant) : base(settings, ruleset, variant) { } } diff --git a/osu.Game/Rulesets/UI/RulesetContainer.cs b/osu.Game/Rulesets/UI/RulesetContainer.cs index 08498d48c6..8f72644b28 100644 --- a/osu.Game/Rulesets/UI/RulesetContainer.cs +++ b/osu.Game/Rulesets/UI/RulesetContainer.cs @@ -38,6 +38,11 @@ namespace osu.Game.Rulesets.UI /// public bool AspectAdjust = true; + /// + /// The selected variant. + /// + public virtual int Variant => 0; + /// /// The input manager for this RulesetContainer. /// diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 2a09521727..7f88f65a24 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -272,9 +272,9 @@ - - - 20180124024000_AddSettings.cs + + + 20180125143340_Settings.cs