Skip to content

Commit

Permalink
Add backwards migration of catch dash binding
Browse files Browse the repository at this point in the history
  • Loading branch information
bdach committed Oct 17, 2023
1 parent 79a4b98 commit 4cfc95c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions osu.Game/Database/RealmAccess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
using osu.Game.Scoring;
using osu.Game.Scoring.Legacy;
using osu.Game.Skinning;
using osuTK.Input;
using Realms;
using Realms.Exceptions;

Expand Down Expand Up @@ -1036,6 +1037,20 @@ private void applyMigrationsForVersion(Migration migration, ulong targetVersion)

case 35:
{
// catch used `Shift` twice as a default key combination for dash, which generally was bothersome and causes issues elsewhere.
// the duplicate binding logic below had to account for it, it could also break keybinding conflict resolution on revert-to-default.
// as such, detect this situation and fix it before proceeding further.
var catchDashBindings = migration.NewRealm.All<RealmKeyBinding>()
.Where(kb => kb.RulesetName == @"fruits" && kb.ActionInt == 2)
.ToList();

if (catchDashBindings.All(kb => kb.KeyCombination.Equals(new KeyCombination(InputKey.Shift))))
{
Debug.Assert(catchDashBindings.Count == 2);
catchDashBindings.Last().KeyCombination = KeyCombination.FromMouseButton(MouseButton.Left);
}

// with the catch case dealt with, de-duplicate the remaining bindings.
int countCleared = 0;

var globalBindings = migration.NewRealm.All<RealmKeyBinding>().Where(kb => kb.RulesetName == null).ToList();
Expand Down

0 comments on commit 4cfc95c

Please sign in to comment.