1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:17:23 +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 ManiaConfigManager(RulesetInfo ruleset, SettingsStore settings)
: base(ruleset, settings)
public ManiaConfigManager(SettingsStore settings, RulesetInfo ruleset, int variant)
: 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 PassThroughInputManager CreateInputManager()
{
var variantType = Mods.OfType<IPlayfieldTypeMod>().FirstOrDefault()?.PlayfieldType ?? PlayfieldType.Single;
return new ManiaInputManager(Ruleset.RulesetInfo, (int)variantType + Beatmap.TotalColumns);
}
public override int Variant => (int)(Mods.OfType<IPlayfieldTypeMod>().FirstOrDefault()?.PlayfieldType ?? PlayfieldType.Single) + Beatmap.TotalColumns;
public override PassThroughInputManager CreateInputManager() => new ManiaInputManager(Ruleset.RulesetInfo, Variant);
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 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;
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();
}

View File

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

View File

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

View File

@ -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<int>("IntKey")
.HasColumnName("Key");
b.Property<int>("IntValue")
b.Property<int?>("RulesetID");
b.Property<string>("StringValue")
.HasColumnName("Value");
b.Property<int?>("RulesetID");
b.Property<int?>("Variant");
b.HasKey("ID");
b.HasIndex("RulesetID");
b.HasIndex("RulesetID", "Variant");
b.ToTable("Settings");
});

View File

@ -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<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
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 =>
{
@ -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)

View File

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

View File

@ -8,7 +8,7 @@ namespace osu.Game.Rulesets.Configuration
public abstract class RulesetConfigManager<T> : DatabasedConfigManager<T>, 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)
{
}
}

View File

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

View File

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