Automatic gameplay cursor size

This commit is contained in:
EVAST9919
2017-05-13 03:46:37 +03:00
parent 08f980ccae
commit ca6df533bd
3 changed files with 22 additions and 2 deletions

View File

@ -50,6 +50,7 @@ namespace osu.Game.Configuration
Set(OsuConfig.MenuCursorSize, 1.0, 0.5f, 2); Set(OsuConfig.MenuCursorSize, 1.0, 0.5f, 2);
Set(OsuConfig.GameplayCursorSize, 1.0, 0.5f, 2); Set(OsuConfig.GameplayCursorSize, 1.0, 0.5f, 2);
Set(OsuConfig.AutoCursorSize, false);
Set(OsuConfig.MouseDisableButtons, false); Set(OsuConfig.MouseDisableButtons, false);
Set(OsuConfig.MouseDisableWheel, false); Set(OsuConfig.MouseDisableWheel, false);
@ -86,6 +87,7 @@ namespace osu.Game.Configuration
Token, Token,
MenuCursorSize, MenuCursorSize,
GameplayCursorSize, GameplayCursorSize,
AutoCursorSize,
DimLevel, DimLevel,
KeyOverlay, KeyOverlay,
ShowInterface, ShowInterface,

View File

@ -42,6 +42,9 @@ namespace osu.Game.Graphics.Cursor
{ {
private Container cursorContainer; private Container cursorContainer;
private Bindable<double> cursorScale; private Bindable<double> cursorScale;
private Bindable<bool> autoCursorScale;
private const int scaling_factor = 5;
public OsuCursor() public OsuCursor()
{ {
@ -49,8 +52,8 @@ namespace osu.Game.Graphics.Cursor
Size = new Vector2(42); Size = new Vector2(42);
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader(permitNulls:true)]
private void load(OsuConfigManager config) private void load(OsuConfigManager config, OsuGame game)
{ {
Children = new Drawable[] Children = new Drawable[]
{ {
@ -117,6 +120,16 @@ namespace osu.Game.Graphics.Cursor
cursorScale = config.GetBindable<double>(OsuConfig.GameplayCursorSize); cursorScale = config.GetBindable<double>(OsuConfig.GameplayCursorSize);
cursorScale.ValueChanged += newScale => cursorContainer.Scale = new Vector2((float)cursorScale); cursorScale.ValueChanged += newScale => cursorContainer.Scale = new Vector2((float)cursorScale);
cursorScale.TriggerChange(); cursorScale.TriggerChange();
autoCursorScale = config.GetBindable<bool>(OsuConfig.AutoCursorSize);
autoCursorScale.ValueChanged += newScale =>
{
if (newScale)
cursorContainer.Scale *= scaling_factor / (game?.Beatmap?.Value.Beatmap.BeatmapInfo.Difficulty.CircleSize ?? scaling_factor);
else
cursorScale.TriggerChange();
};
autoCursorScale.TriggerChange();
} }
} }
} }

View File

@ -31,6 +31,11 @@ namespace osu.Game.Overlays.Options.Sections
LabelText = "Gameplay cursor size", LabelText = "Gameplay cursor size",
Bindable = config.GetBindable<double>(OsuConfig.GameplayCursorSize) Bindable = config.GetBindable<double>(OsuConfig.GameplayCursorSize)
}, },
new OptionCheckbox
{
LabelText = "Automatic gameplay cursor size",
Bindable = config.GetBindable<bool>(OsuConfig.AutoCursorSize)
},
}; };
} }