osu/osu.Game/Configuration/OsuConfigManager.cs

272 lines
9.4 KiB
C#
Raw Normal View History

2019-01-25 10:17:48 +00:00
// 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.
2018-04-13 09:19:50 +00:00
using System;
using System.Diagnostics;
using osu.Framework.Bindables;
2018-04-13 09:19:50 +00:00
using osu.Framework.Configuration;
2018-05-02 10:37:47 +00:00
using osu.Framework.Configuration.Tracking;
2019-01-04 05:18:29 +00:00
using osu.Framework.Extensions;
2018-04-13 09:19:50 +00:00
using osu.Framework.Platform;
using osu.Framework.Testing;
using osu.Game.Input;
using osu.Game.Input.Bindings;
2018-04-13 09:19:50 +00:00
using osu.Game.Overlays;
using osu.Game.Rulesets.Scoring;
2018-04-13 09:19:50 +00:00
using osu.Game.Screens.Select;
using osu.Game.Screens.Select.Filter;
2018-04-13 09:19:50 +00:00
namespace osu.Game.Configuration
{
[ExcludeFromDynamicCompile]
2018-04-13 09:19:50 +00:00
public class OsuConfigManager : IniConfigManager<OsuSetting>
{
protected override void InitialiseDefaults()
{
// UI/selection defaults
Set(OsuSetting.Ruleset, 0, 0, int.MaxValue);
Set(OsuSetting.Skin, 0, -1, int.MaxValue);
2018-04-13 09:19:50 +00:00
2020-02-12 10:52:47 +00:00
Set(OsuSetting.BeatmapDetailTab, PlayBeatmapDetailArea.TabType.Details);
Set(OsuSetting.BeatmapDetailModsFilter, false);
2018-04-13 09:19:50 +00:00
Set(OsuSetting.ShowConvertedBeatmaps, true);
Set(OsuSetting.DisplayStarsMinimum, 0.0, 0, 10, 0.1);
2020-01-24 10:12:56 +00:00
Set(OsuSetting.DisplayStarsMaximum, 10.1, 0, 10.1, 0.1);
2018-04-13 09:19:50 +00:00
Set(OsuSetting.SongSelectGroupingMode, GroupMode.All);
Set(OsuSetting.SongSelectSortingMode, SortMode.Title);
2018-04-13 09:19:50 +00:00
Set(OsuSetting.RandomSelectAlgorithm, RandomSelectAlgorithm.RandomPermutation);
2019-09-02 22:50:52 +00:00
Set(OsuSetting.ChatDisplayHeight, ChatOverlay.DEFAULT_HEIGHT, 0.2f, 1f);
2018-04-13 09:19:50 +00:00
// Online settings
Set(OsuSetting.Username, string.Empty);
Set(OsuSetting.Token, string.Empty);
Set(OsuSetting.AutomaticallyDownloadWhenSpectating, false);
Set(OsuSetting.SavePassword, false).ValueChanged += enabled =>
2018-04-13 09:19:50 +00:00
{
if (enabled.NewValue) Set(OsuSetting.SaveUsername, true);
2018-04-13 09:19:50 +00:00
};
Set(OsuSetting.SaveUsername, true).ValueChanged += enabled =>
2018-04-13 09:19:50 +00:00
{
if (!enabled.NewValue) Set(OsuSetting.SavePassword, false);
2018-04-13 09:19:50 +00:00
};
2018-11-01 20:52:07 +00:00
Set(OsuSetting.ExternalLinkWarning, true);
2020-04-11 11:08:16 +00:00
Set(OsuSetting.PreferNoVideo, false);
2018-04-13 09:19:50 +00:00
// Audio
Set(OsuSetting.VolumeInactive, 0.25, 0, 1, 0.01);
Set(OsuSetting.MenuVoice, true);
Set(OsuSetting.MenuMusic, true);
Set(OsuSetting.AudioOffset, 0, -500.0, 500.0, 1);
// Input
2019-09-02 22:28:51 +00:00
Set(OsuSetting.MenuCursorSize, 1.0f, 0.5f, 2f, 0.01f);
Set(OsuSetting.GameplayCursorSize, 1.0f, 0.1f, 2f, 0.01f);
2018-04-13 09:19:50 +00:00
Set(OsuSetting.AutoCursorSize, false);
Set(OsuSetting.MouseDisableButtons, false);
Set(OsuSetting.MouseDisableWheel, false);
Set(OsuSetting.ConfineMouseMode, OsuConfineMouseMode.DuringGameplay);
2018-04-13 09:19:50 +00:00
// Graphics
Set(OsuSetting.ShowFpsDisplay, false);
Set(OsuSetting.ShowStoryboard, true);
2018-04-25 07:15:23 +00:00
Set(OsuSetting.BeatmapSkins, true);
Set(OsuSetting.BeatmapHitsounds, true);
2018-04-13 09:19:50 +00:00
Set(OsuSetting.CursorRotation, true);
Set(OsuSetting.MenuParallax, true);
// Gameplay
Set(OsuSetting.DimLevel, 0.8, 0, 1, 0.01);
2018-04-13 09:19:50 +00:00
Set(OsuSetting.BlurLevel, 0, 0, 1, 0.01);
Set(OsuSetting.LightenDuringBreaks, true);
2018-04-13 09:19:50 +00:00
2019-09-17 17:16:57 +00:00
Set(OsuSetting.HitLighting, true);
2018-04-13 09:19:50 +00:00
2020-10-20 05:19:15 +00:00
Set(OsuSetting.HUDVisibilityMode, HUDVisibilityMode.Always);
2019-07-05 06:52:44 +00:00
Set(OsuSetting.ShowProgressGraph, true);
Set(OsuSetting.ShowHealthDisplayWhenCantFail, true);
Set(OsuSetting.FadePlayfieldWhenHealthLow, true);
2018-04-13 09:19:50 +00:00
Set(OsuSetting.KeyOverlay, false);
Set(OsuSetting.PositionalHitSounds, true);
Set(OsuSetting.AlwaysPlayFirstComboBreak, true);
2019-08-19 19:04:27 +00:00
Set(OsuSetting.ScoreMeter, ScoreMeterType.HitErrorBoth);
2018-04-13 09:19:50 +00:00
Set(OsuSetting.FloatingComments, false);
Set(OsuSetting.ScoreDisplayMode, ScoringMode.Standardised);
Set(OsuSetting.IncreaseFirstObjectVisibility, true);
Set(OsuSetting.GameplayDisableWinKey, true);
2018-04-13 09:19:50 +00:00
// Update
Set(OsuSetting.ReleaseStream, ReleaseStream.Lazer);
Set(OsuSetting.Version, string.Empty);
Set(OsuSetting.ScreenshotFormat, ScreenshotFormat.Jpg);
Set(OsuSetting.ScreenshotCaptureMenuCursor, false);
2018-04-18 10:26:54 +00:00
Set(OsuSetting.SongSelectRightMouseScroll, false);
2019-01-04 04:29:37 +00:00
Set(OsuSetting.Scaling, ScalingMode.Off);
Set(OsuSetting.ScalingSizeX, 0.8f, 0.2f, 1f);
Set(OsuSetting.ScalingSizeY, 0.8f, 0.2f, 1f);
Set(OsuSetting.ScalingPositionX, 0.5f, 0f, 1f);
Set(OsuSetting.ScalingPositionY, 0.5f, 0f, 1f);
Set(OsuSetting.UIScale, 1f, 0.8f, 1.6f, 0.01f);
2019-08-09 11:05:28 +00:00
2019-10-02 04:26:46 +00:00
Set(OsuSetting.UIHoldActivationDelay, 200f, 0f, 500f, 50f);
2019-08-09 11:05:28 +00:00
Set(OsuSetting.IntroSequence, IntroSequence.Triangles);
2019-09-24 09:42:06 +00:00
2019-11-21 17:38:31 +00:00
Set(OsuSetting.MenuBackgroundSource, BackgroundSource.Skin);
Set(OsuSetting.SeasonalBackgroundMode, SeasonalBackgroundMode.Sometimes);
Set(OsuSetting.EditorWaveformOpacity, 1f);
2018-04-13 09:19:50 +00:00
}
2019-01-04 05:18:29 +00:00
public OsuConfigManager(Storage storage)
: base(storage)
2018-04-13 09:19:50 +00:00
{
Migrate();
}
public void Migrate()
{
// arrives as 2020.123.0
var rawVersion = Get<string>(OsuSetting.Version);
if (rawVersion.Length < 6)
return;
var pieces = rawVersion.Split('.');
// on a fresh install or when coming from a non-release build, execution will end here.
// we don't want to run migrations in such cases.
if (!int.TryParse(pieces[0], out int year)) return;
if (!int.TryParse(pieces[1], out int monthDay)) return;
int combined = (year * 10000) + monthDay;
if (combined < 20200305)
{
// the maximum value of this setting was changed.
// if we don't manually increase this, it causes song select to filter out beatmaps the user expects to see.
var maxStars = (BindableDouble)GetOriginalBindable<double>(OsuSetting.DisplayStarsMaximum);
if (maxStars.Value == 10)
maxStars.Value = maxStars.MaxValue;
}
2018-04-13 09:19:50 +00:00
}
2018-05-02 10:37:47 +00:00
public override TrackedSettings CreateTrackedSettings()
2019-01-04 06:34:32 +00:00
{
// these need to be assigned in normal game startup scenarios.
Debug.Assert(LookupKeyBindings != null);
Debug.Assert(LookupSkinName != null);
return new TrackedSettings
{
new TrackedSetting<bool>(OsuSetting.MouseDisableButtons, v => new SettingDescription(!v, "gameplay mouse buttons", v ? "disabled" : "enabled", LookupKeyBindings(GlobalAction.ToggleGameplayMouseButtons))),
2020-11-30 01:59:02 +00:00
new TrackedSetting<HUDVisibilityMode>(OsuSetting.HUDVisibilityMode, m => new SettingDescription(m, "HUD Visibility", m.GetDescription(), $"cycle: {LookupKeyBindings(GlobalAction.ToggleInGameInterface)} quick view: {LookupKeyBindings(GlobalAction.HoldForHUD)}")),
new TrackedSetting<ScalingMode>(OsuSetting.Scaling, m => new SettingDescription(m, "scaling", m.GetDescription())),
new TrackedSetting<int>(OsuSetting.Skin, m =>
{
string skinName = LookupSkinName(m) ?? string.Empty;
2020-11-11 04:05:03 +00:00
return new SettingDescription(skinName, "skin", skinName, $"random: {LookupKeyBindings(GlobalAction.RandomSkin)}");
})
};
}
public Func<int, string> LookupSkinName { private get; set; }
2020-11-24 04:43:46 +00:00
public Func<GlobalAction, string> LookupKeyBindings { get; set; }
2018-04-13 09:19:50 +00:00
}
public enum OsuSetting
{
Ruleset,
Token,
MenuCursorSize,
GameplayCursorSize,
AutoCursorSize,
DimLevel,
BlurLevel,
LightenDuringBreaks,
2018-04-13 09:19:50 +00:00
ShowStoryboard,
KeyOverlay,
PositionalHitSounds,
AlwaysPlayFirstComboBreak,
ScoreMeter,
2018-04-13 09:19:50 +00:00
FloatingComments,
HUDVisibilityMode,
2019-07-05 06:52:44 +00:00
ShowProgressGraph,
ShowHealthDisplayWhenCantFail,
FadePlayfieldWhenHealthLow,
2018-04-13 09:19:50 +00:00
MouseDisableButtons,
MouseDisableWheel,
ConfineMouseMode,
2018-04-13 09:19:50 +00:00
AudioOffset,
VolumeInactive,
MenuMusic,
MenuVoice,
CursorRotation,
MenuParallax,
BeatmapDetailTab,
BeatmapDetailModsFilter,
2018-04-13 09:19:50 +00:00
Username,
ReleaseStream,
SavePassword,
SaveUsername,
DisplayStarsMinimum,
DisplayStarsMaximum,
SongSelectGroupingMode,
SongSelectSortingMode,
2018-04-13 09:19:50 +00:00
RandomSelectAlgorithm,
ShowFpsDisplay,
ChatDisplayHeight,
Version,
ShowConvertedBeatmaps,
Skin,
ScreenshotFormat,
ScreenshotCaptureMenuCursor,
2018-04-20 15:17:57 +00:00
SongSelectRightMouseScroll,
2018-04-25 07:15:23 +00:00
BeatmapSkins,
BeatmapHitsounds,
IncreaseFirstObjectVisibility,
ScoreDisplayMode,
2019-01-04 04:29:37 +00:00
ExternalLinkWarning,
2020-04-11 11:08:16 +00:00
PreferNoVideo,
2019-01-04 04:29:37 +00:00
Scaling,
ScalingPositionX,
ScalingPositionY,
ScalingSizeX,
ScalingSizeY,
2019-08-09 11:05:28 +00:00
UIScale,
IntroSequence,
UIHoldActivationDelay,
2019-09-24 09:42:06 +00:00
HitLighting,
MenuBackgroundSource,
2020-08-01 17:44:30 +00:00
GameplayDisableWinKey,
SeasonalBackgroundMode,
EditorWaveformOpacity,
AutomaticallyDownloadWhenSpectating,
2018-04-13 09:19:50 +00:00
}
}