1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-21 03:43:21 +08:00

Fix incorrect initial migration

Also adds variant to settings
This commit is contained in:
Dean Herbert 2018-01-25 23:41:03 +09:00
parent 45e8a2b69b
commit 03154dbc63
12 changed files with 40 additions and 30 deletions

View File

@ -9,8 +9,8 @@ namespace osu.Game.Rulesets.Mania.Configuration
{ {
public class ManiaConfigManager : RulesetConfigManager<ManiaSetting> public class ManiaConfigManager : RulesetConfigManager<ManiaSetting>
{ {
public ManiaConfigManager(RulesetInfo ruleset, SettingsStore settings) public ManiaConfigManager(SettingsStore settings, RulesetInfo ruleset, int variant)
: base(ruleset, settings) : base(settings, ruleset, variant)
{ {
} }

View File

@ -80,11 +80,9 @@ namespace osu.Game.Rulesets.Mania.UI
public override ScoreProcessor CreateScoreProcessor() => new ManiaScoreProcessor(this); public override ScoreProcessor CreateScoreProcessor() => new ManiaScoreProcessor(this);
public override PassThroughInputManager CreateInputManager() public override int Variant => (int)(Mods.OfType<IPlayfieldTypeMod>().FirstOrDefault()?.PlayfieldType ?? PlayfieldType.Single) + Beatmap.TotalColumns;
{
var variantType = Mods.OfType<IPlayfieldTypeMod>().FirstOrDefault()?.PlayfieldType ?? PlayfieldType.Single; public override PassThroughInputManager CreateInputManager() => new ManiaInputManager(Ruleset.RulesetInfo, Variant);
return new ManiaInputManager(Ruleset.RulesetInfo, (int)variantType + Beatmap.TotalColumns);
}
protected override BeatmapConverter<ManiaHitObject> CreateBeatmapConverter() => new ManiaBeatmapConverter(IsForCurrentRuleset, WorkingBeatmap.Beatmap); protected override BeatmapConverter<ManiaHitObject> 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 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);
} }
} }

View File

@ -17,12 +17,12 @@ namespace osu.Game.Configuration
private readonly RulesetInfo ruleset; 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.settings = settings;
this.ruleset = ruleset; this.ruleset = ruleset;
databasedSettings = settings.Query(ruleset?.ID); databasedSettings = settings.Query(ruleset?.ID, variant);
InitialiseDefaults(); InitialiseDefaults();
} }

View File

@ -14,6 +14,8 @@ namespace osu.Game.Configuration
public int? RulesetID { get; set; } public int? RulesetID { get; set; }
public int? Variant { get; set; }
[Column("Key")] [Column("Key")]
public int IntKey public int IntKey
{ {

View File

@ -23,8 +23,8 @@ namespace osu.Game.Configuration
/// <param name="rulesetId">The ruleset's internal ID.</param> /// <param name="rulesetId">The ruleset's internal ID.</param>
/// <param name="variant">An optional variant.</param> /// <param name="variant">An optional variant.</param>
/// <returns></returns> /// <returns></returns>
public List<DatabasedSetting> Query(int? rulesetId = null) => public List<DatabasedSetting> Query(int? rulesetId = null, int? variant = null) =>
GetContext().DatabasedSetting.Where(b => b.RulesetID == rulesetId).ToList(); GetContext().DatabasedSetting.Where(b => b.RulesetID == rulesetId && b.Variant == variant).ToList();
public void Update(DatabasedSetting setting) public void Update(DatabasedSetting setting)
{ {

View File

@ -91,7 +91,7 @@ namespace osu.Game.Database
modelBuilder.Entity<DatabasedKeyBinding>().HasIndex(b => new { b.RulesetID, b.Variant }); modelBuilder.Entity<DatabasedKeyBinding>().HasIndex(b => new { b.RulesetID, b.Variant });
modelBuilder.Entity<DatabasedKeyBinding>().HasIndex(b => b.IntAction); modelBuilder.Entity<DatabasedKeyBinding>().HasIndex(b => b.IntAction);
modelBuilder.Entity<DatabasedSetting>().HasIndex(b => b.RulesetID); modelBuilder.Entity<DatabasedSetting>().HasIndex(b => new { b.RulesetID, b.Variant });
modelBuilder.Entity<FileInfo>().HasIndex(b => b.Hash).IsUnique(); modelBuilder.Entity<FileInfo>().HasIndex(b => b.Hash).IsUnique();
modelBuilder.Entity<FileInfo>().HasIndex(b => b.ReferenceCount); modelBuilder.Entity<FileInfo>().HasIndex(b => b.ReferenceCount);

View File

@ -10,8 +10,8 @@ using System;
namespace osu.Game.Migrations namespace osu.Game.Migrations
{ {
[DbContext(typeof(OsuDbContext))] [DbContext(typeof(OsuDbContext))]
[Migration("20180124024000_AddSettings")] [Migration("20180125143340_Settings")]
partial class AddSettings partial class Settings
{ {
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
{ {
@ -202,14 +202,16 @@ namespace osu.Game.Migrations
b.Property<int>("IntKey") b.Property<int>("IntKey")
.HasColumnName("Key"); .HasColumnName("Key");
b.Property<int>("IntValue") b.Property<int?>("RulesetID");
b.Property<string>("StringValue")
.HasColumnName("Value"); .HasColumnName("Value");
b.Property<int?>("RulesetID"); b.Property<int?>("Variant");
b.HasKey("ID"); b.HasKey("ID");
b.HasIndex("RulesetID"); b.HasIndex("RulesetID", "Variant");
b.ToTable("Settings"); b.ToTable("Settings");
}); });

View File

@ -4,7 +4,7 @@ using System.Collections.Generic;
namespace osu.Game.Migrations namespace osu.Game.Migrations
{ {
public partial class AddSettings : Migration public partial class Settings : Migration
{ {
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
{ {
@ -19,8 +19,9 @@ namespace osu.Game.Migrations
ID = table.Column<int>(type: "INTEGER", nullable: false) ID = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true), .Annotation("Sqlite:Autoincrement", true),
Key = table.Column<int>(type: "INTEGER", nullable: false), Key = table.Column<int>(type: "INTEGER", nullable: false),
Value = table.Column<int>(type: "INTEGER", nullable: false), RulesetID = table.Column<int>(type: "INTEGER", nullable: true),
RulesetID = table.Column<int>(type: "INTEGER", nullable: true) Value = table.Column<string>(type: "TEXT", nullable: true),
Variant = table.Column<int>(type: "INTEGER", nullable: true)
}, },
constraints: table => constraints: table =>
{ {
@ -33,9 +34,9 @@ namespace osu.Game.Migrations
columns: new[] { "RulesetID", "Variant" }); columns: new[] { "RulesetID", "Variant" });
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_Settings_RulesetID", name: "IX_Settings_RulesetID_Variant",
table: "Settings", table: "Settings",
column: "RulesetID"); columns: new[] { "RulesetID", "Variant" });
} }
protected override void Down(MigrationBuilder migrationBuilder) protected override void Down(MigrationBuilder migrationBuilder)

View File

@ -201,14 +201,16 @@ namespace osu.Game.Migrations
b.Property<int>("IntKey") b.Property<int>("IntKey")
.HasColumnName("Key"); .HasColumnName("Key");
b.Property<int>("IntValue") b.Property<int?>("RulesetID");
b.Property<string>("StringValue")
.HasColumnName("Value"); .HasColumnName("Value");
b.Property<int?>("RulesetID"); b.Property<int?>("Variant");
b.HasKey("ID"); b.HasKey("ID");
b.HasIndex("RulesetID"); b.HasIndex("RulesetID", "Variant");
b.ToTable("Settings"); b.ToTable("Settings");
}); });

View File

@ -8,7 +8,7 @@ namespace osu.Game.Rulesets.Configuration
public abstract class RulesetConfigManager<T> : DatabasedConfigManager<T>, IRulesetConfigManager public abstract class RulesetConfigManager<T> : DatabasedConfigManager<T>, IRulesetConfigManager
where T : struct where T : struct
{ {
protected RulesetConfigManager(RulesetInfo ruleset, SettingsStore settings) : base(settings, ruleset) protected RulesetConfigManager(SettingsStore settings, RulesetInfo ruleset, int variant) : base(settings, ruleset, variant)
{ {
} }
} }

View File

@ -38,6 +38,11 @@ namespace osu.Game.Rulesets.UI
/// </summary> /// </summary>
public bool AspectAdjust = true; public bool AspectAdjust = true;
/// <summary>
/// The selected variant.
/// </summary>
public virtual int Variant => 0;
/// <summary> /// <summary>
/// The input manager for this RulesetContainer. /// The input manager for this RulesetContainer.
/// </summary> /// </summary>

View File

@ -272,9 +272,9 @@
<Compile Include="Database\DatabaseContextFactory.cs" /> <Compile Include="Database\DatabaseContextFactory.cs" />
<Compile Include="Database\IHasPrimaryKey.cs" /> <Compile Include="Database\IHasPrimaryKey.cs" />
<Compile Include="Graphics\Textures\LargeTextureStore.cs" /> <Compile Include="Graphics\Textures\LargeTextureStore.cs" />
<Compile Include="Migrations\20180124024000_AddSettings.cs" /> <Compile Include="Migrations\20180125143340_Settings.cs" />
<Compile Include="Migrations\20180124024000_AddSettings.designer.cs"> <Compile Include="Migrations\20180125143340_Settings.designer.cs">
<DependentUpon>20180124024000_AddSettings.cs</DependentUpon> <DependentUpon>20180125143340_Settings.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Overlays\Profile\SupporterIcon.cs" /> <Compile Include="Overlays\Profile\SupporterIcon.cs" />
<Compile Include="Online\API\Requests\GetFriendsRequest.cs" /> <Compile Include="Online\API\Requests\GetFriendsRequest.cs" />