From ca6df533bd128837b49291c3fc917e8e09fc3f88 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Sat, 13 May 2017 03:46:37 +0300 Subject: [PATCH 1/7] Automatic gameplay cursor size --- osu.Game/Configuration/OsuConfigManager.cs | 2 ++ osu.Game/Graphics/Cursor/GameplayCursor.cs | 17 +++++++++++++++-- .../Overlays/Options/Sections/SkinSection.cs | 5 +++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index ba19d8592a..8df054712b 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -50,6 +50,7 @@ namespace osu.Game.Configuration Set(OsuConfig.MenuCursorSize, 1.0, 0.5f, 2); Set(OsuConfig.GameplayCursorSize, 1.0, 0.5f, 2); + Set(OsuConfig.AutoCursorSize, false); Set(OsuConfig.MouseDisableButtons, false); Set(OsuConfig.MouseDisableWheel, false); @@ -86,6 +87,7 @@ namespace osu.Game.Configuration Token, MenuCursorSize, GameplayCursorSize, + AutoCursorSize, DimLevel, KeyOverlay, ShowInterface, diff --git a/osu.Game/Graphics/Cursor/GameplayCursor.cs b/osu.Game/Graphics/Cursor/GameplayCursor.cs index 3f699219a4..1ef2ad5910 100644 --- a/osu.Game/Graphics/Cursor/GameplayCursor.cs +++ b/osu.Game/Graphics/Cursor/GameplayCursor.cs @@ -42,6 +42,9 @@ namespace osu.Game.Graphics.Cursor { private Container cursorContainer; private Bindable cursorScale; + private Bindable autoCursorScale; + + private const int scaling_factor = 5; public OsuCursor() { @@ -49,8 +52,8 @@ namespace osu.Game.Graphics.Cursor Size = new Vector2(42); } - [BackgroundDependencyLoader] - private void load(OsuConfigManager config) + [BackgroundDependencyLoader(permitNulls:true)] + private void load(OsuConfigManager config, OsuGame game) { Children = new Drawable[] { @@ -117,6 +120,16 @@ namespace osu.Game.Graphics.Cursor cursorScale = config.GetBindable(OsuConfig.GameplayCursorSize); cursorScale.ValueChanged += newScale => cursorContainer.Scale = new Vector2((float)cursorScale); cursorScale.TriggerChange(); + + autoCursorScale = config.GetBindable(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(); } } } diff --git a/osu.Game/Overlays/Options/Sections/SkinSection.cs b/osu.Game/Overlays/Options/Sections/SkinSection.cs index b3c225d00c..a3645d03de 100644 --- a/osu.Game/Overlays/Options/Sections/SkinSection.cs +++ b/osu.Game/Overlays/Options/Sections/SkinSection.cs @@ -31,6 +31,11 @@ namespace osu.Game.Overlays.Options.Sections LabelText = "Gameplay cursor size", Bindable = config.GetBindable(OsuConfig.GameplayCursorSize) }, + new OptionCheckbox + { + LabelText = "Automatic gameplay cursor size", + Bindable = config.GetBindable(OsuConfig.AutoCursorSize) + }, }; } From 12dab6f75c93d586e9b715e98ac34836d7a16f92 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Sun, 14 May 2017 07:28:12 +0300 Subject: [PATCH 2/7] iplemented stable-like algorithm --- osu.Game/Graphics/Cursor/GameplayCursor.cs | 29 +++++++++++++--------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/osu.Game/Graphics/Cursor/GameplayCursor.cs b/osu.Game/Graphics/Cursor/GameplayCursor.cs index 1ef2ad5910..ab2f36e45a 100644 --- a/osu.Game/Graphics/Cursor/GameplayCursor.cs +++ b/osu.Game/Graphics/Cursor/GameplayCursor.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; @@ -44,7 +45,11 @@ namespace osu.Game.Graphics.Cursor private Bindable cursorScale; private Bindable autoCursorScale; - private const int scaling_factor = 5; + private float beatmapCircleSize; + private const float default_beatmap_cs = 5f; + + private float autoScaleMultiplier => autoCursorScale ? (float)(1 - (0.7 * (beatmapCircleSize - 4) / 5)) : 1f; + public OsuCursor() { @@ -117,19 +122,19 @@ namespace osu.Game.Graphics.Cursor }, }; - cursorScale = config.GetBindable(OsuConfig.GameplayCursorSize); - cursorScale.ValueChanged += newScale => cursorContainer.Scale = new Vector2((float)cursorScale); - cursorScale.TriggerChange(); + beatmapCircleSize = game?.Beatmap?.Value.Beatmap.BeatmapInfo.Difficulty.CircleSize ?? default_beatmap_cs; + cursorScale = config.GetBindable(OsuConfig.GameplayCursorSize); autoCursorScale = config.GetBindable(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(); + + cursorScale.ValueChanged += newValue => calculateScale(); + autoCursorScale.ValueChanged += newValue => calculateScale(); + cursorScale.TriggerChange(); + } + + private void calculateScale() + { + cursorContainer.Scale = new Vector2(autoScaleMultiplier * (float)cursorScale); } } } From 49f5364e9e4434d72fa417af8d9b4665747cd9f0 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Sun, 14 May 2017 07:35:23 +0300 Subject: [PATCH 3/7] CI fixes --- osu.Game/Graphics/Cursor/GameplayCursor.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Graphics/Cursor/GameplayCursor.cs b/osu.Game/Graphics/Cursor/GameplayCursor.cs index ab2f36e45a..5aa3ae8326 100644 --- a/osu.Game/Graphics/Cursor/GameplayCursor.cs +++ b/osu.Game/Graphics/Cursor/GameplayCursor.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; @@ -48,7 +47,7 @@ namespace osu.Game.Graphics.Cursor private float beatmapCircleSize; private const float default_beatmap_cs = 5f; - private float autoScaleMultiplier => autoCursorScale ? (float)(1 - (0.7 * (beatmapCircleSize - 4) / 5)) : 1f; + private float autoScaleMultiplier => autoCursorScale ? (float)(1 - 0.7 * (beatmapCircleSize - 4) / 5) : 1f; public OsuCursor() From b6460d89c97c7220639230d00ac9151fe9c56f26 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Sun, 14 May 2017 10:26:52 +0300 Subject: [PATCH 4/7] Cleanup --- osu.Game/Graphics/Cursor/GameplayCursor.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/osu.Game/Graphics/Cursor/GameplayCursor.cs b/osu.Game/Graphics/Cursor/GameplayCursor.cs index 5aa3ae8326..24e6f055b8 100644 --- a/osu.Game/Graphics/Cursor/GameplayCursor.cs +++ b/osu.Game/Graphics/Cursor/GameplayCursor.cs @@ -44,9 +44,9 @@ namespace osu.Game.Graphics.Cursor private Bindable cursorScale; private Bindable autoCursorScale; - private float beatmapCircleSize; - private const float default_beatmap_cs = 5f; + private float beatmapCircleSize; + private const int default_circle_size = 5; private float autoScaleMultiplier => autoCursorScale ? (float)(1 - 0.7 * (beatmapCircleSize - 4) / 5) : 1f; @@ -56,8 +56,8 @@ namespace osu.Game.Graphics.Cursor Size = new Vector2(42); } - [BackgroundDependencyLoader(permitNulls:true)] - private void load(OsuConfigManager config, OsuGame game) + [BackgroundDependencyLoader] + private void load(OsuConfigManager config, OsuGameBase game) { Children = new Drawable[] { @@ -121,7 +121,7 @@ namespace osu.Game.Graphics.Cursor }, }; - beatmapCircleSize = game?.Beatmap?.Value.Beatmap.BeatmapInfo.Difficulty.CircleSize ?? default_beatmap_cs; + beatmapCircleSize = game.Beatmap.Value?.Beatmap.BeatmapInfo.Difficulty.CircleSize ?? default_circle_size; cursorScale = config.GetBindable(OsuConfig.GameplayCursorSize); autoCursorScale = config.GetBindable(OsuConfig.AutoCursorSize); @@ -133,7 +133,7 @@ namespace osu.Game.Graphics.Cursor private void calculateScale() { - cursorContainer.Scale = new Vector2(autoScaleMultiplier * (float)cursorScale); + cursorContainer.Scale = new Vector2((float)(autoScaleMultiplier * cursorScale)); } } } From f73076918607487569b5aaf66283fbc0fbc27ed8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 15 May 2017 12:54:56 +0900 Subject: [PATCH 5/7] Rewrite to make better --- osu.Game/Database/BeatmapDifficulty.cs | 13 ++++++--- osu.Game/Graphics/Cursor/GameplayCursor.cs | 32 ++++++++++++++-------- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/osu.Game/Database/BeatmapDifficulty.cs b/osu.Game/Database/BeatmapDifficulty.cs index 7c9f47e7b6..cf1305f705 100644 --- a/osu.Game/Database/BeatmapDifficulty.cs +++ b/osu.Game/Database/BeatmapDifficulty.cs @@ -7,12 +7,17 @@ namespace osu.Game.Database { public class BeatmapDifficulty { + /// + /// The default value used for all difficulty settings except and . + /// + public const float DEFAULT_DIFFICULTY = 5; + [PrimaryKey, AutoIncrement] public int ID { get; set; } - public float DrainRate { get; set; } = 5; - public float CircleSize { get; set; } = 5; - public float OverallDifficulty { get; set; } = 5; - public float ApproachRate { get; set; } = 5; + public float DrainRate { get; set; } = DEFAULT_DIFFICULTY; + public float CircleSize { get; set; } = DEFAULT_DIFFICULTY; + public float OverallDifficulty { get; set; } = DEFAULT_DIFFICULTY; + public float ApproachRate { get; set; } = DEFAULT_DIFFICULTY; public float SliderMultiplier { get; set; } = 1; public float SliderTickRate { get; set; } = 1; diff --git a/osu.Game/Graphics/Cursor/GameplayCursor.cs b/osu.Game/Graphics/Cursor/GameplayCursor.cs index 766371c07d..801fe1d011 100644 --- a/osu.Game/Graphics/Cursor/GameplayCursor.cs +++ b/osu.Game/Graphics/Cursor/GameplayCursor.cs @@ -11,7 +11,9 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Sprites; using osu.Framework.Input; +using osu.Game.Beatmaps; using osu.Game.Configuration; +using osu.Game.Database; namespace osu.Game.Graphics.Cursor { @@ -41,14 +43,10 @@ namespace osu.Game.Graphics.Cursor public class OsuCursor : Container { private Container cursorContainer; + private Bindable cursorScale; private Bindable autoCursorScale; - - - private float beatmapCircleSize; - private const int default_circle_size = 5; - private float autoScaleMultiplier => autoCursorScale ? (float)(1 - 0.7 * (beatmapCircleSize - 4) / 5) : 1f; - + private Bindable beatmap; public OsuCursor() { @@ -121,19 +119,29 @@ namespace osu.Game.Graphics.Cursor }, }; - beatmapCircleSize = game.Beatmap.Value?.Beatmap.BeatmapInfo.Difficulty.CircleSize ?? default_circle_size; + beatmap = game.Beatmap.GetBoundCopy(); + beatmap.ValueChanged += v => calculateScale(); cursorScale = config.GetBindable(OsuSetting.GameplayCursorSize); - autoCursorScale = config.GetBindable(OsuSetting.AutoCursorSize); + cursorScale.ValueChanged += v => calculateScale(); - cursorScale.ValueChanged += newValue => calculateScale(); - autoCursorScale.ValueChanged += newValue => calculateScale(); - cursorScale.TriggerChange(); + autoCursorScale = config.GetBindable(OsuSetting.AutoCursorSize); + autoCursorScale.ValueChanged += v => calculateScale(); + + calculateScale(); } private void calculateScale() { - cursorContainer.Scale = new Vector2((float)(autoScaleMultiplier * cursorScale)); + float scale = (float)cursorScale.Value; + + if (autoCursorScale && beatmap.Value != null) + { + // if we have a beatmap available, let's get its circle size to figure out an automatic cursor scale modifier. + scale *= (float)(1 - 0.7 * (1 + beatmap.Value.BeatmapInfo.Difficulty.CircleSize - BeatmapDifficulty.DEFAULT_DIFFICULTY) / BeatmapDifficulty.DEFAULT_DIFFICULTY); + } + + cursorContainer.Scale = new Vector2(scale); } } } From 1f3039926fb7e1de6d1d56e783531fb92e8839cd Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 15 May 2017 12:57:55 +0900 Subject: [PATCH 6/7] Reword settings text slightly --- osu.Game/Overlays/Settings/Sections/SkinSection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Settings/Sections/SkinSection.cs b/osu.Game/Overlays/Settings/Sections/SkinSection.cs index ddf13e9bbe..4b4426aca8 100644 --- a/osu.Game/Overlays/Settings/Sections/SkinSection.cs +++ b/osu.Game/Overlays/Settings/Sections/SkinSection.cs @@ -33,7 +33,7 @@ namespace osu.Game.Overlays.Settings.Sections }, new SettingsCheckbox { - LabelText = "Automatic gameplay cursor size", + LabelText = "Adjust gameplay cursor size based on current beatmap", Bindable = config.GetBindable(OsuSetting.AutoCursorSize) }, }; From fa889c4340a9295d7862530041b2d0c08aaf315a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 15 May 2017 16:20:02 +0900 Subject: [PATCH 7/7] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index fa44e5a47e..7146c07159 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit fa44e5a47e20956b12e598e85159a1a25b500b3c +Subproject commit 7146c07159d2cf3d07a8d371fa50ef8b200ba038