mirror of
https://github.com/osukey/osukey.git
synced 2025-05-30 09:57:21 +09:00
Store and retrieve offset from realm
This commit is contained in:
parent
acf8db13ac
commit
047e801da9
@ -565,6 +565,11 @@ namespace osu.Game.Database
|
|||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 14:
|
||||||
|
foreach (var beatmap in migration.NewRealm.All<BeatmapInfo>())
|
||||||
|
beatmap.UserSettings = new BeatmapUserSettings();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Database;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Play
|
namespace osu.Game.Screens.Play
|
||||||
{
|
{
|
||||||
@ -43,7 +44,7 @@ namespace osu.Game.Screens.Play
|
|||||||
Precision = 0.1,
|
Precision = 0.1,
|
||||||
};
|
};
|
||||||
|
|
||||||
private double totalAppliedOffset => userOffsetClock.RateAdjustedOffset + platformOffsetClock.RateAdjustedOffset;
|
private double totalAppliedOffset => userBeatmapOffsetClock.RateAdjustedOffset + userGlobalOffsetClock.RateAdjustedOffset + platformOffsetClock.RateAdjustedOffset;
|
||||||
|
|
||||||
private readonly BindableDouble pauseFreqAdjust = new BindableDouble(1);
|
private readonly BindableDouble pauseFreqAdjust = new BindableDouble(1);
|
||||||
|
|
||||||
@ -52,7 +53,8 @@ namespace osu.Game.Screens.Play
|
|||||||
private readonly bool startAtGameplayStart;
|
private readonly bool startAtGameplayStart;
|
||||||
private readonly double firstHitObjectTime;
|
private readonly double firstHitObjectTime;
|
||||||
|
|
||||||
private HardwareCorrectionOffsetClock userOffsetClock;
|
private HardwareCorrectionOffsetClock userGlobalOffsetClock;
|
||||||
|
private HardwareCorrectionOffsetClock userBeatmapOffsetClock;
|
||||||
private HardwareCorrectionOffsetClock platformOffsetClock;
|
private HardwareCorrectionOffsetClock platformOffsetClock;
|
||||||
private MasterGameplayClock masterGameplayClock;
|
private MasterGameplayClock masterGameplayClock;
|
||||||
private Bindable<double> userAudioOffset;
|
private Bindable<double> userAudioOffset;
|
||||||
@ -69,10 +71,12 @@ namespace osu.Game.Screens.Play
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuConfigManager config)
|
private void load(OsuConfigManager config, RealmAccess realm)
|
||||||
{
|
{
|
||||||
userAudioOffset = config.GetBindable<double>(OsuSetting.AudioOffset);
|
userAudioOffset = config.GetBindable<double>(OsuSetting.AudioOffset);
|
||||||
userAudioOffset.BindValueChanged(offset => userOffsetClock.Offset = offset.NewValue, true);
|
userAudioOffset.BindValueChanged(offset => userGlobalOffsetClock.Offset = offset.NewValue, true);
|
||||||
|
|
||||||
|
userBeatmapOffsetClock.Offset = realm.Run(r => r.Find<BeatmapInfo>(beatmap.BeatmapInfo.ID).UserSettings?.Offset) ?? 0;
|
||||||
|
|
||||||
// sane default provided by ruleset.
|
// sane default provided by ruleset.
|
||||||
startOffset = gameplayStartTime;
|
startOffset = gameplayStartTime;
|
||||||
@ -161,9 +165,10 @@ namespace osu.Game.Screens.Play
|
|||||||
platformOffsetClock = new HardwareCorrectionOffsetClock(source, pauseFreqAdjust) { Offset = RuntimeInfo.OS == RuntimeInfo.Platform.Windows ? 15 : 0 };
|
platformOffsetClock = new HardwareCorrectionOffsetClock(source, pauseFreqAdjust) { Offset = RuntimeInfo.OS == RuntimeInfo.Platform.Windows ? 15 : 0 };
|
||||||
|
|
||||||
// the final usable gameplay clock with user-set offsets applied.
|
// the final usable gameplay clock with user-set offsets applied.
|
||||||
userOffsetClock = new HardwareCorrectionOffsetClock(platformOffsetClock, pauseFreqAdjust);
|
userGlobalOffsetClock = new HardwareCorrectionOffsetClock(platformOffsetClock, pauseFreqAdjust);
|
||||||
|
userBeatmapOffsetClock = new HardwareCorrectionOffsetClock(userGlobalOffsetClock, pauseFreqAdjust);
|
||||||
|
|
||||||
return masterGameplayClock = new MasterGameplayClock(userOffsetClock);
|
return masterGameplayClock = new MasterGameplayClock(userBeatmapOffsetClock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Database;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Overlays.Settings;
|
using osu.Game.Overlays.Settings;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
@ -60,16 +63,37 @@ namespace osu.Game.Screens.Play.PlayerSettings
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private RealmAccess realm { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private IBindable<WorkingBeatmap> beatmap { get; set; }
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
ReferenceScore.BindValueChanged(scoreChanged, true);
|
ReferenceScore.BindValueChanged(scoreChanged, true);
|
||||||
|
|
||||||
Current.BindValueChanged(offset =>
|
Current.BindValueChanged(currentChanged);
|
||||||
|
Current.Value = realm.Run(r => r.Find<BeatmapInfo>(beatmap.Value.BeatmapInfo.ID).UserSettings?.Offset) ?? 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void currentChanged(ValueChangedEvent<double> offset)
|
||||||
|
{
|
||||||
|
if (useAverageButton != null)
|
||||||
{
|
{
|
||||||
if (useAverageButton != null)
|
useAverageButton.Enabled.Value = offset.NewValue != lastPlayAverage;
|
||||||
{
|
}
|
||||||
useAverageButton.Enabled.Value = offset.NewValue != lastPlayAverage;
|
|
||||||
}
|
realm.Write(r =>
|
||||||
}, true);
|
{
|
||||||
|
var settings = r.Find<BeatmapInfo>(beatmap.Value.BeatmapInfo.ID).UserSettings;
|
||||||
|
|
||||||
|
settings.Offset = offset.NewValue;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void scoreChanged(ValueChangedEvent<ScoreInfo> score)
|
private void scoreChanged(ValueChangedEvent<ScoreInfo> score)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user