From 74fa33669323d9970b3cb1685203325306f9ef71 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 26 Apr 2017 14:25:46 +0900 Subject: [PATCH 01/29] Update vscode launch/task configuration. Adds debug/release launching. Cleans up much. Also updates tasks.json schema to 2.0.0 which supports multiple commands. Can't use until https://github.com/Microsoft/vscode/issues/22250 is fixed. --- .vscode/launch.json | 40 +++++++++++++++-------- .vscode/tasks.json | 77 ++++++++++++++++++++++----------------------- 2 files changed, 65 insertions(+), 52 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 0e07b0a067..b3b86da42f 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -2,46 +2,60 @@ "version": "0.2.0", "configurations": [ { - "name": "Launch VisualTests", + "name": "VisualTests (debug)", "windows": { "type": "clr" }, "type": "mono", "request": "launch", "program": "${workspaceRoot}/osu.Desktop.VisualTests/bin/Debug/osu!.exe", - "args": [], "cwd": "${workspaceRoot}", - "preLaunchTask": "build", + "preLaunchTask": "Build (Debug)", "runtimeExecutable": null, "env": {}, "console": "internalConsole" }, { - "name": "Launch Desktop", + "name": "VisualTests (release)", + "windows": { + "type": "clr" + }, + "type": "mono", + "request": "launch", + "program": "${workspaceRoot}/osu.Desktop.VisualTests/bin/Release/osu!.exe", + "cwd": "${workspaceRoot}", + "preLaunchTask": "Build (Release)", + "runtimeExecutable": null, + "env": {}, + "console": "internalConsole" + }, + { + "name": "osu! (debug)", "windows": { "type": "clr" }, "type": "mono", "request": "launch", "program": "${workspaceRoot}/osu.Desktop/bin/Debug/osu!.exe", - "args": [], "cwd": "${workspaceRoot}", - "preLaunchTask": "build", + "preLaunchTask": "Build (Debug)", "runtimeExecutable": null, "env": {}, "console": "internalConsole" }, { - "name": "Attach", + "name": "osu! (release)", "windows": { - "type": "clr", - "request": "attach", - "processName": "osu!" + "type": "clr" }, "type": "mono", - "request": "attach", - "address": "localhost", - "port": 55555 + "request": "launch", + "program": "${workspaceRoot}/osu.Desktop/bin/Release/osu!.exe", + "cwd": "${workspaceRoot}", + "preLaunchTask": "Build (Release)", + "runtimeExecutable": null, + "env": {}, + "console": "internalConsole" } ] } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 5eaeaa9899..f285ebde67 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,51 +1,50 @@ { // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format - "version": "0.1.0", - "taskSelector": "/t:", + "version": "2.0.0", + "problemMatcher": "$msCompile", + "isShellCommand": true, + "command": "msbuild", + "suppressTaskName": true, + "showOutput": "silent", + "args": [ + "/property:GenerateFullPaths=true", + "/property:DebugType=portable" + ], + "windows": { + "args": [ + "/property:GenerateFullPaths=true", + "/property:DebugType=portable", + "/m" //parallel compiling support. doesn't work well with mono atm + ] + }, "tasks": [ { - "taskName": "build", - "isShellCommand": true, - "showOutput": "silent", - "command": "msbuild", - "args": [ - "/property:GenerateFullPaths=true", - "/property:DebugType=portable" - ], - "windows": { - "args": [ - "/property:GenerateFullPaths=true", - "/property:DebugType=portable", - "/m" //parallel compiling support. doesn't work well with mono atm - ] - }, - // Use the standard MS compiler pattern to detect errors, warnings and infos - "problemMatcher": "$msCompile", + "taskName": "Build (Debug)", "isBuildCommand": true }, { - "taskName": "rebuild", - "isShellCommand": true, - "showOutput": "silent", - "command": "msbuild", + "taskName": "Build (Release)", "args": [ - // Ask msbuild to generate full paths for file names. - "/property:GenerateFullPaths=true", - "/property:DebugType=portable", - "/target:Clean,Build" - ], - "windows": { - "args": [ - "/property:GenerateFullPaths=true", - "/property:DebugType=portable", - "/target:Clean,Build", - "/m" //parallel compiling support. doesn't work well with mono atm - ] - }, - // Use the standard MS compiler pattern to detect errors, warnings and infos - "problemMatcher": "$msCompile", - "isBuildCommand": true + "/property:Configuration=Release" + ] + }, + { + "taskName": "Clean All", + "dependsOn": ["Clean (Debug)", "Clean (Release)"] + }, + { + "taskName": "Clean (Debug)", + "args": [ + "/target:Clean" + ] + }, + { + "taskName": "Clean (Release)", + "args": [ + "/target:Clean", + "/property:Configuration=Release" + ] } ] } \ No newline at end of file From 00a8dbbacfa3d1bd1a40379e388c8f5e2f0af2ec Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Tue, 2 May 2017 21:36:55 +0300 Subject: [PATCH 02/29] Added ModType for each mode --- osu.Game.Rulesets.Mania/Mods/ManiaMod.cs | 1 + osu.Game/Rulesets/Mods/Mod.cs | 5 +++++ osu.Game/Rulesets/Mods/ModDoubleTime.cs | 1 + osu.Game/Rulesets/Mods/ModEasy.cs | 1 + osu.Game/Rulesets/Mods/ModFlashlight.cs | 1 + osu.Game/Rulesets/Mods/ModHalfTime.cs | 1 + osu.Game/Rulesets/Mods/ModHardRock.cs | 1 + osu.Game/Rulesets/Mods/ModHidden.cs | 1 + osu.Game/Rulesets/Mods/ModNoFail.cs | 1 + osu.Game/Rulesets/Mods/ModSuddenDeath.cs | 1 + 10 files changed, 14 insertions(+) diff --git a/osu.Game.Rulesets.Mania/Mods/ManiaMod.cs b/osu.Game.Rulesets.Mania/Mods/ManiaMod.cs index 68458caeac..b402d3a010 100644 --- a/osu.Game.Rulesets.Mania/Mods/ManiaMod.cs +++ b/osu.Game.Rulesets.Mania/Mods/ManiaMod.cs @@ -64,6 +64,7 @@ namespace osu.Game.Rulesets.Mania.Mods { public override string Name => "FadeIn"; public override FontAwesome Icon => FontAwesome.fa_osu_mod_hidden; + public override ModType Type => ModType.DifficultyIncrease; public override double ScoreMultiplier => 1; public override bool Ranked => true; public override Type[] IncompatibleMods => new[] { typeof(ModFlashlight) }; diff --git a/osu.Game/Rulesets/Mods/Mod.cs b/osu.Game/Rulesets/Mods/Mod.cs index a2846c1d2f..c00847b7d8 100644 --- a/osu.Game/Rulesets/Mods/Mod.cs +++ b/osu.Game/Rulesets/Mods/Mod.cs @@ -21,6 +21,11 @@ namespace osu.Game.Rulesets.Mods /// public virtual FontAwesome Icon => FontAwesome.fa_question; + /// + /// The type of this mod. + /// + public virtual ModType Type => ModType.Special; + /// /// The user readable description of this mod. /// diff --git a/osu.Game/Rulesets/Mods/ModDoubleTime.cs b/osu.Game/Rulesets/Mods/ModDoubleTime.cs index 377a4c2180..1aab56a9fc 100644 --- a/osu.Game/Rulesets/Mods/ModDoubleTime.cs +++ b/osu.Game/Rulesets/Mods/ModDoubleTime.cs @@ -11,6 +11,7 @@ namespace osu.Game.Rulesets.Mods { public override string Name => "Double Time"; public override FontAwesome Icon => FontAwesome.fa_osu_mod_doubletime; + public override ModType Type => ModType.DifficultyIncrease; public override string Description => "Zoooooooooom"; public override bool Ranked => true; public override Type[] IncompatibleMods => new[] { typeof(ModHalfTime) }; diff --git a/osu.Game/Rulesets/Mods/ModEasy.cs b/osu.Game/Rulesets/Mods/ModEasy.cs index bef3f04af3..8eef9c70d6 100644 --- a/osu.Game/Rulesets/Mods/ModEasy.cs +++ b/osu.Game/Rulesets/Mods/ModEasy.cs @@ -10,6 +10,7 @@ namespace osu.Game.Rulesets.Mods { public override string Name => "Easy"; public override FontAwesome Icon => FontAwesome.fa_osu_mod_easy; + public override ModType Type => ModType.DifficultyReduction; public override string Description => "Reduces overall difficulty - larger circles, more forgiving HP drain, less accuracy required."; public override double ScoreMultiplier => 0.5; public override bool Ranked => true; diff --git a/osu.Game/Rulesets/Mods/ModFlashlight.cs b/osu.Game/Rulesets/Mods/ModFlashlight.cs index 63c534dc7d..b5ad859172 100644 --- a/osu.Game/Rulesets/Mods/ModFlashlight.cs +++ b/osu.Game/Rulesets/Mods/ModFlashlight.cs @@ -9,6 +9,7 @@ namespace osu.Game.Rulesets.Mods { public override string Name => "Flashlight"; public override FontAwesome Icon => FontAwesome.fa_osu_mod_flashlight; + public override ModType Type => ModType.DifficultyIncrease; public override string Description => "Restricted view area."; public override bool Ranked => true; } diff --git a/osu.Game/Rulesets/Mods/ModHalfTime.cs b/osu.Game/Rulesets/Mods/ModHalfTime.cs index 235fc7ad76..207a6ec2a1 100644 --- a/osu.Game/Rulesets/Mods/ModHalfTime.cs +++ b/osu.Game/Rulesets/Mods/ModHalfTime.cs @@ -11,6 +11,7 @@ namespace osu.Game.Rulesets.Mods { public override string Name => "Half Time"; public override FontAwesome Icon => FontAwesome.fa_osu_mod_halftime; + public override ModType Type => ModType.DifficultyReduction; public override string Description => "Less zoom"; public override bool Ranked => true; public override Type[] IncompatibleMods => new[] { typeof(ModDoubleTime) }; diff --git a/osu.Game/Rulesets/Mods/ModHardRock.cs b/osu.Game/Rulesets/Mods/ModHardRock.cs index b729b5ae15..2516c02526 100644 --- a/osu.Game/Rulesets/Mods/ModHardRock.cs +++ b/osu.Game/Rulesets/Mods/ModHardRock.cs @@ -10,6 +10,7 @@ namespace osu.Game.Rulesets.Mods { public override string Name => "Hard Rock"; public override FontAwesome Icon => FontAwesome.fa_osu_mod_hardrock; + public override ModType Type => ModType.DifficultyIncrease; public override string Description => "Everything just got a bit harder..."; public override Type[] IncompatibleMods => new[] { typeof(ModEasy) }; } diff --git a/osu.Game/Rulesets/Mods/ModHidden.cs b/osu.Game/Rulesets/Mods/ModHidden.cs index 12c788ce54..89b9b3b62d 100644 --- a/osu.Game/Rulesets/Mods/ModHidden.cs +++ b/osu.Game/Rulesets/Mods/ModHidden.cs @@ -9,6 +9,7 @@ namespace osu.Game.Rulesets.Mods { public override string Name => "Hidden"; public override FontAwesome Icon => FontAwesome.fa_osu_mod_hidden; + public override ModType Type => ModType.DifficultyIncrease; public override bool Ranked => true; } } \ No newline at end of file diff --git a/osu.Game/Rulesets/Mods/ModNoFail.cs b/osu.Game/Rulesets/Mods/ModNoFail.cs index 0c8726bbc1..613e1e1d4d 100644 --- a/osu.Game/Rulesets/Mods/ModNoFail.cs +++ b/osu.Game/Rulesets/Mods/ModNoFail.cs @@ -10,6 +10,7 @@ namespace osu.Game.Rulesets.Mods { public override string Name => "NoFail"; public override FontAwesome Icon => FontAwesome.fa_osu_mod_nofail; + public override ModType Type => ModType.DifficultyReduction; public override string Description => "You can't fail, no matter what."; public override double ScoreMultiplier => 0.5; public override bool Ranked => true; diff --git a/osu.Game/Rulesets/Mods/ModSuddenDeath.cs b/osu.Game/Rulesets/Mods/ModSuddenDeath.cs index a7dcbbc9ed..2bf0278046 100644 --- a/osu.Game/Rulesets/Mods/ModSuddenDeath.cs +++ b/osu.Game/Rulesets/Mods/ModSuddenDeath.cs @@ -10,6 +10,7 @@ namespace osu.Game.Rulesets.Mods { public override string Name => "Sudden Death"; public override FontAwesome Icon => FontAwesome.fa_osu_mod_suddendeath; + public override ModType Type => ModType.DifficultyIncrease; public override string Description => "Miss a note and fail."; public override double ScoreMultiplier => 1; public override bool Ranked => true; From 7e1efcc20bcb2b55eb632809158d8f6e36944111 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Tue, 2 May 2017 22:34:07 +0300 Subject: [PATCH 03/29] Added ModsContainer --- osu.Game/Rulesets/UI/HudOverlay.cs | 3 + osu.Game/Rulesets/UI/StandardHudOverlay.cs | 10 ++- osu.Game/Screens/Play/ModsContainer.cs | 88 ++++++++++++++++++++++ osu.Game/Screens/Play/Player.cs | 4 + osu.Game/osu.Game.csproj | 1 + 5 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 osu.Game/Screens/Play/ModsContainer.cs diff --git a/osu.Game/Rulesets/UI/HudOverlay.cs b/osu.Game/Rulesets/UI/HudOverlay.cs index 47cf157732..9bd900da4b 100644 --- a/osu.Game/Rulesets/UI/HudOverlay.cs +++ b/osu.Game/Rulesets/UI/HudOverlay.cs @@ -27,6 +27,7 @@ namespace osu.Game.Rulesets.UI public readonly RollingCounter AccuracyCounter; public readonly HealthDisplay HealthDisplay; public readonly SongProgress Progress; + public readonly ModsContainer ModsContainer; private Bindable showKeyCounter; private Bindable showHud; @@ -39,6 +40,7 @@ namespace osu.Game.Rulesets.UI protected abstract ScoreCounter CreateScoreCounter(); protected abstract HealthDisplay CreateHealthDisplay(); protected abstract SongProgress CreateProgress(); + protected abstract ModsContainer CreateModsContainer(); protected HudOverlay() { @@ -56,6 +58,7 @@ namespace osu.Game.Rulesets.UI AccuracyCounter = CreateAccuracyCounter(), HealthDisplay = CreateHealthDisplay(), Progress = CreateProgress(), + ModsContainer = CreateModsContainer(), } }); } diff --git a/osu.Game/Rulesets/UI/StandardHudOverlay.cs b/osu.Game/Rulesets/UI/StandardHudOverlay.cs index c68e29f98a..a51a1ba434 100644 --- a/osu.Game/Rulesets/UI/StandardHudOverlay.cs +++ b/osu.Game/Rulesets/UI/StandardHudOverlay.cs @@ -64,7 +64,15 @@ namespace osu.Game.Rulesets.UI RelativeSizeAxes = Axes.X, }; - [BackgroundDependencyLoader] + protected override ModsContainer CreateModsContainer() => new ModsContainer + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + AutoSizeAxes = Axes.Both, + Position = new Vector2(0, 30), + }; + + [BackgroundDependencyLoader] private void load(OsuColour colours) { ComboCounter.AccentColour = colours.BlueLighter; diff --git a/osu.Game/Screens/Play/ModsContainer.cs b/osu.Game/Screens/Play/ModsContainer.cs new file mode 100644 index 0000000000..6ee7292dae --- /dev/null +++ b/osu.Game/Screens/Play/ModsContainer.cs @@ -0,0 +1,88 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics.Containers; +using osu.Game.Rulesets.Mods; +using osu.Game.Rulesets.UI; +using osu.Framework.Graphics; +using OpenTK.Graphics; +using osu.Game.Graphics; +using osu.Framework.Allocation; +using osu.Game.Graphics.Sprites; + +namespace osu.Game.Screens.Play +{ + public class ModsContainer : Container + { + private readonly FillFlowContainer iconsContainer; + + private bool showMods; + public bool ShowMods + { + get { return showMods; } + set + { + if (showMods == value) return; + + showMods = value; + } + } + + public ModsContainer() + { + Children = new Drawable[] + { + iconsContainer = new FillFlowContainer + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + }, + new OsuSpriteText + { + Anchor = Anchor.BottomCentre, + Origin = Anchor.TopCentre, + Text = @"/UNRANKED/", + Font = @"Venera", + TextSize = 15, + } + }; + } + + public void Add(Mod mod) + { + iconsContainer.Add(new ModIcon + { + AutoSizeAxes = Axes.Both, + Icon = mod.Icon, + Colour = selectColour(mod), + IconSize = 60, + }); + } + + private Color4 selectColour(Mod mod) + { + switch (mod.Type) + { + case ModType.DifficultyIncrease: + return OsuColour.FromHex(@"ffcc22"); + case ModType.DifficultyReduction: + return OsuColour.FromHex(@"88b300"); + case ModType.Special: + return OsuColour.FromHex(@"66ccff"); + + default: return Color4.White; + } + } + + [BackgroundDependencyLoader] + private void load() + { + if (ShowMods) + Show(); + else + Hide(); + } + } +} diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 37b4cf5b45..948594235f 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -169,6 +169,10 @@ namespace osu.Game.Screens.Play hudOverlay.Progress.AllowSeeking = HitRenderer.HasReplayLoaded; hudOverlay.Progress.OnSeek = pos => decoupledClock.Seek(pos); + hudOverlay.ModsContainer.ShowMods = HitRenderer.HasReplayLoaded; + foreach (var mod in Beatmap.Mods.Value) + hudOverlay.ModsContainer.Add(mod); + //bind HitRenderer to ScoreProcessor and ourselves (for a pass situation) HitRenderer.OnAllJudged += onCompletion; diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 2a1195135a..d637660ea9 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -227,6 +227,7 @@ + From 37c31339819849a870bd9e449aa8db021d049357 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Tue, 2 May 2017 22:46:18 +0300 Subject: [PATCH 04/29] Fixes --- osu.Game/Rulesets/UI/StandardHudOverlay.cs | 2 +- osu.Game/Screens/Play/ModsContainer.cs | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/osu.Game/Rulesets/UI/StandardHudOverlay.cs b/osu.Game/Rulesets/UI/StandardHudOverlay.cs index a51a1ba434..8d4496ad93 100644 --- a/osu.Game/Rulesets/UI/StandardHudOverlay.cs +++ b/osu.Game/Rulesets/UI/StandardHudOverlay.cs @@ -69,7 +69,7 @@ namespace osu.Game.Rulesets.UI Anchor = Anchor.TopRight, Origin = Anchor.TopRight, AutoSizeAxes = Axes.Both, - Position = new Vector2(0, 30), + Position = new Vector2(0, 25), }; [BackgroundDependencyLoader] diff --git a/osu.Game/Screens/Play/ModsContainer.cs b/osu.Game/Screens/Play/ModsContainer.cs index 6ee7292dae..514d174212 100644 --- a/osu.Game/Screens/Play/ModsContainer.cs +++ b/osu.Game/Screens/Play/ModsContainer.cs @@ -20,12 +20,7 @@ namespace osu.Game.Screens.Play public bool ShowMods { get { return showMods; } - set - { - if (showMods == value) return; - - showMods = value; - } + set { showMods = value; } } public ModsContainer() @@ -34,8 +29,8 @@ namespace osu.Game.Screens.Play { iconsContainer = new FillFlowContainer { - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, }, From a955f9cbfd894bd464e28267cd69ab05e4c53d66 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Tue, 2 May 2017 22:59:36 +0300 Subject: [PATCH 05/29] Simplify hiding logic --- osu.Game/Screens/Play/ModsContainer.cs | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/osu.Game/Screens/Play/ModsContainer.cs b/osu.Game/Screens/Play/ModsContainer.cs index 514d174212..3ae3e0b119 100644 --- a/osu.Game/Screens/Play/ModsContainer.cs +++ b/osu.Game/Screens/Play/ModsContainer.cs @@ -16,11 +16,9 @@ namespace osu.Game.Screens.Play { private readonly FillFlowContainer iconsContainer; - private bool showMods; public bool ShowMods { - get { return showMods; } - set { showMods = value; } + set { if (!value) Hide(); } } public ModsContainer() @@ -70,14 +68,5 @@ namespace osu.Game.Screens.Play default: return Color4.White; } } - - [BackgroundDependencyLoader] - private void load() - { - if (ShowMods) - Show(); - else - Hide(); - } } } From 2e30a69b67777a731d8f3d94302f8ce7dc99de38 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Tue, 2 May 2017 23:04:36 +0300 Subject: [PATCH 06/29] removed using --- osu.Game/Screens/Play/ModsContainer.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Screens/Play/ModsContainer.cs b/osu.Game/Screens/Play/ModsContainer.cs index 3ae3e0b119..8569bc6db6 100644 --- a/osu.Game/Screens/Play/ModsContainer.cs +++ b/osu.Game/Screens/Play/ModsContainer.cs @@ -7,7 +7,6 @@ using osu.Game.Rulesets.UI; using osu.Framework.Graphics; using OpenTK.Graphics; using osu.Game.Graphics; -using osu.Framework.Allocation; using osu.Game.Graphics.Sprites; namespace osu.Game.Screens.Play From 6ea3629c9a5da836636081ac9e9672372d3a9279 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Wed, 3 May 2017 08:23:52 +0300 Subject: [PATCH 07/29] Adjust the size --- osu.Game/Screens/Play/ModsContainer.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Play/ModsContainer.cs b/osu.Game/Screens/Play/ModsContainer.cs index 8569bc6db6..280759485f 100644 --- a/osu.Game/Screens/Play/ModsContainer.cs +++ b/osu.Game/Screens/Play/ModsContainer.cs @@ -8,6 +8,7 @@ using osu.Framework.Graphics; using OpenTK.Graphics; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using OpenTK; namespace osu.Game.Screens.Play { @@ -30,14 +31,15 @@ namespace osu.Game.Screens.Play Origin = Anchor.TopCentre, AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, + Spacing = new Vector2(5,0), }, new OsuSpriteText { Anchor = Anchor.BottomCentre, Origin = Anchor.TopCentre, - Text = @"/UNRANKED/", + Text = @"/ UNRANKED /", Font = @"Venera", - TextSize = 15, + TextSize = 12, } }; } @@ -49,7 +51,7 @@ namespace osu.Game.Screens.Play AutoSizeAxes = Axes.Both, Icon = mod.Icon, Colour = selectColour(mod), - IconSize = 60, + Scale = new Vector2((float)0.7), }); } From 898d9495ff8fa4f5f37be1c46f15d103718b620c Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Wed, 3 May 2017 08:27:47 +0300 Subject: [PATCH 08/29] line fix --- osu.Game/Rulesets/UI/StandardHudOverlay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/UI/StandardHudOverlay.cs b/osu.Game/Rulesets/UI/StandardHudOverlay.cs index 8d4496ad93..709f8ef395 100644 --- a/osu.Game/Rulesets/UI/StandardHudOverlay.cs +++ b/osu.Game/Rulesets/UI/StandardHudOverlay.cs @@ -72,7 +72,7 @@ namespace osu.Game.Rulesets.UI Position = new Vector2(0, 25), }; - [BackgroundDependencyLoader] + [BackgroundDependencyLoader] private void load(OsuColour colours) { ComboCounter.AccentColour = colours.BlueLighter; From e7a8619f01241b83d8cf783c8cf9669fa91f70a1 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Wed, 3 May 2017 09:48:10 +0300 Subject: [PATCH 09/29] ModIcon refactor --- osu.Game/Overlays/Mods/AssistedSection.cs | 1 - .../Mods/DifficultyIncreaseSection.cs | 1 - .../Mods/DifficultyReductionSection.cs | 1 - osu.Game/Overlays/Mods/ModButton.cs | 20 +---- osu.Game/Overlays/Mods/ModSection.cs | 20 ----- osu.Game/Rulesets/UI/ModIcon.cs | 75 +++++++++++-------- osu.Game/Screens/Play/ModsContainer.cs | 27 ++----- 7 files changed, 54 insertions(+), 91 deletions(-) diff --git a/osu.Game/Overlays/Mods/AssistedSection.cs b/osu.Game/Overlays/Mods/AssistedSection.cs index b4263fa309..b3cbb410e4 100644 --- a/osu.Game/Overlays/Mods/AssistedSection.cs +++ b/osu.Game/Overlays/Mods/AssistedSection.cs @@ -16,7 +16,6 @@ namespace osu.Game.Overlays.Mods [BackgroundDependencyLoader] private void load(OsuColour colours) { - ButtonColour = colours.Blue; SelectedColour = colours.BlueLight; } diff --git a/osu.Game/Overlays/Mods/DifficultyIncreaseSection.cs b/osu.Game/Overlays/Mods/DifficultyIncreaseSection.cs index 0a293416dc..fc759eb7d9 100644 --- a/osu.Game/Overlays/Mods/DifficultyIncreaseSection.cs +++ b/osu.Game/Overlays/Mods/DifficultyIncreaseSection.cs @@ -16,7 +16,6 @@ namespace osu.Game.Overlays.Mods [BackgroundDependencyLoader] private void load(OsuColour colours) { - ButtonColour = colours.Yellow; SelectedColour = colours.YellowLight; } diff --git a/osu.Game/Overlays/Mods/DifficultyReductionSection.cs b/osu.Game/Overlays/Mods/DifficultyReductionSection.cs index 3a373e6f09..dd3b5965f3 100644 --- a/osu.Game/Overlays/Mods/DifficultyReductionSection.cs +++ b/osu.Game/Overlays/Mods/DifficultyReductionSection.cs @@ -16,7 +16,6 @@ namespace osu.Game.Overlays.Mods [BackgroundDependencyLoader] private void load(OsuColour colours) { - ButtonColour = colours.Green; SelectedColour = colours.GreenLight; } diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs index f380c19d8a..409207dd55 100644 --- a/osu.Game/Overlays/Mods/ModButton.cs +++ b/osu.Game/Overlays/Mods/ModButton.cs @@ -71,10 +71,6 @@ namespace osu.Game.Overlays.Mods { if (value == buttonColour) return; buttonColour = value; - foreach (ModIcon icon in iconsContainer.Children) - { - icon.Colour = value; - } } } @@ -180,41 +176,33 @@ namespace osu.Game.Overlays.Mods { iconsContainer.Add(new[] { - new ModIcon + new ModIcon(Mods[0]) { Origin = Anchor.Centre, Anchor = Anchor.Centre, AutoSizeAxes = Axes.Both, Position = new Vector2(1.5f), - Colour = ButtonColour }, - foregroundIcon = new ModIcon + foregroundIcon = new ModIcon(Mods[0]) { Origin = Anchor.Centre, Anchor = Anchor.Centre, AutoSizeAxes = Axes.Both, Position = new Vector2(-1.5f), - Colour = ButtonColour }, }); } else { - iconsContainer.Add(foregroundIcon = new ModIcon + iconsContainer.Add(foregroundIcon = new ModIcon(Mod) { Origin = Anchor.Centre, Anchor = Anchor.Centre, AutoSizeAxes = Axes.Both, - Colour = ButtonColour }); } - } - protected override void LoadComplete() - { - base.LoadComplete(); - foreach (ModIcon icon in iconsContainer.Children) - icon.Colour = ButtonColour; + buttonColour = foregroundIcon.Colour; } public ModButton(Mod m) diff --git a/osu.Game/Overlays/Mods/ModSection.cs b/osu.Game/Overlays/Mods/ModSection.cs index c2af12f49e..b70323fb63 100644 --- a/osu.Game/Overlays/Mods/ModSection.cs +++ b/osu.Game/Overlays/Mods/ModSection.cs @@ -50,7 +50,6 @@ namespace osu.Game.Overlays.Mods foreach (ModButton button in value) { - button.ButtonColour = ButtonColour; button.SelectedColour = selectedColour; button.Action = Action; } @@ -59,25 +58,6 @@ namespace osu.Game.Overlays.Mods } } - private Color4 buttonsBolour = Color4.White; - public Color4 ButtonColour - { - get - { - return buttonsBolour; - } - set - { - if (value == buttonsBolour) return; - buttonsBolour = value; - - foreach (ModButton button in buttons) - { - button.ButtonColour = value; - } - } - } - private Color4 selectedColour = Color4.White; public Color4 SelectedColour { diff --git a/osu.Game/Rulesets/UI/ModIcon.cs b/osu.Game/Rulesets/UI/ModIcon.cs index 8301796c1f..127f1483b8 100644 --- a/osu.Game/Rulesets/UI/ModIcon.cs +++ b/osu.Game/Rulesets/UI/ModIcon.cs @@ -5,6 +5,7 @@ using OpenTK.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics; +using osu.Game.Rulesets.Mods; namespace osu.Game.Rulesets.UI { @@ -29,25 +30,42 @@ namespace osu.Game.Rulesets.UI public new Color4 Colour { - get - { - return background.Colour; - } - set - { - background.Colour = value; - } + get { return background?.Colour ?? Color4.Transparent; } + set { background.Colour = value; } } public FontAwesome Icon { - get + get { return modIcon.Icon; } + set { modIcon.Icon = value; } + } + + public ModIcon(Mod m) + { + if(m!= null) { - return modIcon.Icon; - } - set - { - modIcon.Icon = value; + Children = new Drawable[] + { + background = new TextAwesome + { + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Icon = FontAwesome.fa_osu_mod_bg, + Colour = selectColour(m), + Shadow = true, + TextSize = 20 + }, + modIcon = new TextAwesome + { + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Colour = OsuColour.Gray(84), + TextSize = 20, + Icon = m.Icon, + }, + }; + + reapplySize(); } } @@ -57,28 +75,19 @@ namespace osu.Game.Rulesets.UI modIcon.TextSize = iconSize - 35; } - public ModIcon() + private Color4 selectColour(Mod mod) { - Children = new Drawable[] + switch (mod.Type) { - background = new TextAwesome - { - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - Icon = FontAwesome.fa_osu_mod_bg, - Shadow = true, - TextSize = 20 - }, - modIcon = new TextAwesome - { - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - Colour = OsuColour.Gray(84), - TextSize = 20 - }, - }; + case ModType.DifficultyIncrease: + return OsuColour.FromHex(@"ffcc22"); + case ModType.DifficultyReduction: + return OsuColour.FromHex(@"88b300"); + case ModType.Special: + return OsuColour.FromHex(@"66ccff"); - reapplySize(); + default: return Color4.White; + } } } } \ No newline at end of file diff --git a/osu.Game/Screens/Play/ModsContainer.cs b/osu.Game/Screens/Play/ModsContainer.cs index 280759485f..ddb24bfb31 100644 --- a/osu.Game/Screens/Play/ModsContainer.cs +++ b/osu.Game/Screens/Play/ModsContainer.cs @@ -16,9 +16,15 @@ namespace osu.Game.Screens.Play { private readonly FillFlowContainer iconsContainer; + private bool showMods; public bool ShowMods { - set { if (!value) Hide(); } + set + { + showMods = value; + if (!showMods) Hide(); + } + get { return ShowMods; } } public ModsContainer() @@ -46,28 +52,11 @@ namespace osu.Game.Screens.Play public void Add(Mod mod) { - iconsContainer.Add(new ModIcon + iconsContainer.Add(new ModIcon(mod) { AutoSizeAxes = Axes.Both, - Icon = mod.Icon, - Colour = selectColour(mod), Scale = new Vector2((float)0.7), }); } - - private Color4 selectColour(Mod mod) - { - switch (mod.Type) - { - case ModType.DifficultyIncrease: - return OsuColour.FromHex(@"ffcc22"); - case ModType.DifficultyReduction: - return OsuColour.FromHex(@"88b300"); - case ModType.Special: - return OsuColour.FromHex(@"66ccff"); - - default: return Color4.White; - } - } } } From 9e35eb8d978be13c4664d378967fe7443ddbd744 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Wed, 3 May 2017 13:53:45 +0300 Subject: [PATCH 10/29] Fixes --- osu.Game/Rulesets/UI/ModIcon.cs | 47 ++++++++++++-------------- osu.Game/Screens/Play/ModsContainer.cs | 2 -- 2 files changed, 22 insertions(+), 27 deletions(-) diff --git a/osu.Game/Rulesets/UI/ModIcon.cs b/osu.Game/Rulesets/UI/ModIcon.cs index 127f1483b8..710ea22a5b 100644 --- a/osu.Game/Rulesets/UI/ModIcon.cs +++ b/osu.Game/Rulesets/UI/ModIcon.cs @@ -30,7 +30,7 @@ namespace osu.Game.Rulesets.UI public new Color4 Colour { - get { return background?.Colour ?? Color4.Transparent; } + get { return background.Colour; } set { background.Colour = value; } } @@ -42,31 +42,28 @@ namespace osu.Game.Rulesets.UI public ModIcon(Mod m) { - if(m!= null) + Children = new Drawable[] { - Children = new Drawable[] + background = new TextAwesome { - background = new TextAwesome - { - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - Icon = FontAwesome.fa_osu_mod_bg, - Colour = selectColour(m), - Shadow = true, - TextSize = 20 - }, - modIcon = new TextAwesome - { - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - Colour = OsuColour.Gray(84), - TextSize = 20, - Icon = m.Icon, - }, - }; + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Icon = FontAwesome.fa_osu_mod_bg, + Colour = pickColour(m), + Shadow = true, + TextSize = 20 + }, + modIcon = new TextAwesome + { + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Colour = OsuColour.Gray(84), + TextSize = 20, + Icon = m?.Icon ?? FontAwesome.fa_question, + }, + }; - reapplySize(); - } + reapplySize(); } private void reapplySize() @@ -75,9 +72,9 @@ namespace osu.Game.Rulesets.UI modIcon.TextSize = iconSize - 35; } - private Color4 selectColour(Mod mod) + private Color4 pickColour(Mod mod) { - switch (mod.Type) + switch (mod?.Type) { case ModType.DifficultyIncrease: return OsuColour.FromHex(@"ffcc22"); diff --git a/osu.Game/Screens/Play/ModsContainer.cs b/osu.Game/Screens/Play/ModsContainer.cs index ddb24bfb31..26f0edcf10 100644 --- a/osu.Game/Screens/Play/ModsContainer.cs +++ b/osu.Game/Screens/Play/ModsContainer.cs @@ -5,8 +5,6 @@ using osu.Framework.Graphics.Containers; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.UI; using osu.Framework.Graphics; -using OpenTK.Graphics; -using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using OpenTK; From 5f2f1d2763aabd079ed6ba9392e3820f2b27c837 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Wed, 3 May 2017 14:01:43 +0300 Subject: [PATCH 11/29] CI fixes --- osu.Game/Overlays/Mods/ModButton.cs | 11 ++--------- osu.Game/Screens/Play/ModsContainer.cs | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs index 409207dd55..e3d26cba06 100644 --- a/osu.Game/Overlays/Mods/ModButton.cs +++ b/osu.Game/Overlays/Mods/ModButton.cs @@ -63,15 +63,8 @@ namespace osu.Game.Overlays.Mods private Color4 buttonColour; public Color4 ButtonColour { - get - { - return buttonColour; - } - set - { - if (value == buttonColour) return; - buttonColour = value; - } + get { return buttonColour; } + set { buttonColour = value; } } private Color4 selectedColour; diff --git a/osu.Game/Screens/Play/ModsContainer.cs b/osu.Game/Screens/Play/ModsContainer.cs index 26f0edcf10..4e23853c3d 100644 --- a/osu.Game/Screens/Play/ModsContainer.cs +++ b/osu.Game/Screens/Play/ModsContainer.cs @@ -22,7 +22,7 @@ namespace osu.Game.Screens.Play showMods = value; if (!showMods) Hide(); } - get { return ShowMods; } + get { return showMods; } } public ModsContainer() From 6063231e40258ab399bbd7fc8765903b8ed9209d Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Wed, 3 May 2017 16:58:10 +0300 Subject: [PATCH 12/29] float value fix --- osu.Game/Screens/Play/ModsContainer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/ModsContainer.cs b/osu.Game/Screens/Play/ModsContainer.cs index 4e23853c3d..204ed95873 100644 --- a/osu.Game/Screens/Play/ModsContainer.cs +++ b/osu.Game/Screens/Play/ModsContainer.cs @@ -53,7 +53,7 @@ namespace osu.Game.Screens.Play iconsContainer.Add(new ModIcon(mod) { AutoSizeAxes = Axes.Both, - Scale = new Vector2((float)0.7), + Scale = new Vector2(0.7f), }); } } From 008ff9d2f92eb97204038bb3f764e4c48d6d6c86 Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Wed, 3 May 2017 18:33:42 +0200 Subject: [PATCH 13/29] InputResample CursorTrail --- osu.Game/Graphics/Cursor/CursorTrail.cs | 26 ++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/osu.Game/Graphics/Cursor/CursorTrail.cs b/osu.Game/Graphics/Cursor/CursorTrail.cs index 09d1b99d13..362a235bca 100644 --- a/osu.Game/Graphics/Cursor/CursorTrail.cs +++ b/osu.Game/Graphics/Cursor/CursorTrail.cs @@ -39,6 +39,8 @@ namespace osu.Game.Graphics.Cursor private Vector2? lastPosition; + private InputResampler resampler = new InputResampler(); + protected override DrawNode CreateDrawNode() => new TrailDrawNode(); protected override void ApplyDrawNode(DrawNode node) @@ -116,22 +118,24 @@ namespace osu.Game.Graphics.Cursor if (lastPosition == null) { lastPosition = state.Mouse.NativeState.Position; + resampler.AddPosition(lastPosition.Value); return base.OnMouseMove(state); } Vector2 pos1 = lastPosition.Value; - Vector2 pos2 = state.Mouse.NativeState.Position; - - Vector2 diff = pos2 - pos1; - float distance = diff.Length; - Vector2 direction = diff / distance; - - float interval = size.X / 2 * 0.9f; - - for (float d = interval; d < distance; d += interval) + foreach (Vector2 pos2 in resampler.AddPosition(state.Mouse.NativeState.Position)) { - lastPosition = pos1 + direction * d; - addPosition(lastPosition.Value); + Vector2 diff = pos2 - pos1; + float distance = diff.Length; + Vector2 direction = diff / distance; + + float interval = size.X / 2 * 0.9f; + + for (float d = interval; d < distance; d += interval) + { + lastPosition = pos1 + direction * d; + addPosition(lastPosition.Value); + } } return base.OnMouseMove(state); From 063b606a123b11eff13bacdf8fb8fb2b450df8e1 Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Wed, 3 May 2017 18:48:17 +0200 Subject: [PATCH 14/29] Fix readonly warning --- osu.Game/Graphics/Cursor/CursorTrail.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Graphics/Cursor/CursorTrail.cs b/osu.Game/Graphics/Cursor/CursorTrail.cs index 362a235bca..1c640b64d0 100644 --- a/osu.Game/Graphics/Cursor/CursorTrail.cs +++ b/osu.Game/Graphics/Cursor/CursorTrail.cs @@ -39,7 +39,7 @@ namespace osu.Game.Graphics.Cursor private Vector2? lastPosition; - private InputResampler resampler = new InputResampler(); + private readonly InputResampler resampler = new InputResampler(); protected override DrawNode CreateDrawNode() => new TrailDrawNode(); From 57c423241669ff9f6c3856bc5c4c229f64949ef2 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Thu, 4 May 2017 11:58:37 +0300 Subject: [PATCH 15/29] Added testcase --- .../Tests/TestCaseIngameModsContainer.cs | 67 +++++++++++++++++++ .../osu.Desktop.VisualTests.csproj | 1 + osu.Game/Screens/Play/ModsContainer.cs | 5 ++ 3 files changed, 73 insertions(+) create mode 100644 osu.Desktop.VisualTests/Tests/TestCaseIngameModsContainer.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseIngameModsContainer.cs b/osu.Desktop.VisualTests/Tests/TestCaseIngameModsContainer.cs new file mode 100644 index 0000000000..3b2135fcbd --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCaseIngameModsContainer.cs @@ -0,0 +1,67 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Testing; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Colour; +using osu.Framework.Graphics.Sprites; +using osu.Game.Screens.Menu; +using OpenTK.Graphics; +using osu.Game.Screens.Play; +using osu.Framework.Allocation; +using osu.Game.Overlays.Mods; +using osu.Game.Database; +using osu.Game.Rulesets.Mods; +using OpenTK; + +namespace osu.Desktop.VisualTests.Tests +{ + internal class TestCaseIngameModsContainer : TestCase + { + public override string Description => @"Ingame mods visualization"; + + private ModSelectOverlay modSelect; + private ModsContainer modsContainer; + private RulesetDatabase rulesets; + + [BackgroundDependencyLoader] + private void load(RulesetDatabase rulesets) + { + this.rulesets = rulesets; + } + + public override void Reset() + { + base.Reset(); + + Add(modSelect = new ModSelectOverlay + { + RelativeSizeAxes = Axes.X, + Origin = Anchor.BottomCentre, + Anchor = Anchor.BottomCentre, + }); + + Add(modsContainer = new ModsContainer + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + AutoSizeAxes = Axes.Both, + Position = new Vector2(0, 25), + }); + + modSelect.SelectedMods.ValueChanged += SelectedMods_ValueChanged; + modSelect.SelectedMods.TriggerChange(); + + AddStep("ToggleModSelect", modSelect.ToggleVisibility); + foreach (var ruleset in rulesets.AllRulesets) + AddStep(ruleset.CreateInstance().Description, () => modSelect.Ruleset.Value = ruleset); + } + + private void SelectedMods_ValueChanged(System.Collections.Generic.IEnumerable newValue) + { + modsContainer.Clear(); + foreach (Mod mod in modSelect.SelectedMods.Value) + modsContainer.Add(mod); + } + } +} diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index 135e4596c7..58d8d50ed1 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -190,6 +190,7 @@ + diff --git a/osu.Game/Screens/Play/ModsContainer.cs b/osu.Game/Screens/Play/ModsContainer.cs index 204ed95873..5806a12ac9 100644 --- a/osu.Game/Screens/Play/ModsContainer.cs +++ b/osu.Game/Screens/Play/ModsContainer.cs @@ -56,5 +56,10 @@ namespace osu.Game.Screens.Play Scale = new Vector2(0.7f), }); } + + public void Clear() + { + iconsContainer.Clear(); + } } } From 475eb6fe5f14c10d722209e42413a31bf7b41a7f Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Thu, 4 May 2017 17:29:52 +0300 Subject: [PATCH 16/29] Cleanup --- .../Tests/TestCaseIngameModsContainer.cs | 31 +--------------- .../Tests/TestCaseModSelectOverlay.cs | 2 +- osu.Game/Rulesets/UI/ModIcon.cs | 8 ++-- osu.Game/Screens/Play/ModsContainer.cs | 37 ++++++++++++------- osu.Game/Screens/Play/Player.cs | 3 +- 5 files changed, 31 insertions(+), 50 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseIngameModsContainer.cs b/osu.Desktop.VisualTests/Tests/TestCaseIngameModsContainer.cs index 3b2135fcbd..e9b8df2d1b 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseIngameModsContainer.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseIngameModsContainer.cs @@ -16,31 +16,16 @@ using OpenTK; namespace osu.Desktop.VisualTests.Tests { - internal class TestCaseIngameModsContainer : TestCase + internal class TestCaseIngameModsContainer : TestCaseModSelectOverlay { public override string Description => @"Ingame mods visualization"; - private ModSelectOverlay modSelect; private ModsContainer modsContainer; - private RulesetDatabase rulesets; - - [BackgroundDependencyLoader] - private void load(RulesetDatabase rulesets) - { - this.rulesets = rulesets; - } public override void Reset() { base.Reset(); - Add(modSelect = new ModSelectOverlay - { - RelativeSizeAxes = Axes.X, - Origin = Anchor.BottomCentre, - Anchor = Anchor.BottomCentre, - }); - Add(modsContainer = new ModsContainer { Anchor = Anchor.TopRight, @@ -49,19 +34,7 @@ namespace osu.Desktop.VisualTests.Tests Position = new Vector2(0, 25), }); - modSelect.SelectedMods.ValueChanged += SelectedMods_ValueChanged; - modSelect.SelectedMods.TriggerChange(); - - AddStep("ToggleModSelect", modSelect.ToggleVisibility); - foreach (var ruleset in rulesets.AllRulesets) - AddStep(ruleset.CreateInstance().Description, () => modSelect.Ruleset.Value = ruleset); - } - - private void SelectedMods_ValueChanged(System.Collections.Generic.IEnumerable newValue) - { - modsContainer.Clear(); - foreach (Mod mod in modSelect.SelectedMods.Value) - modsContainer.Add(mod); + modsContainer.Mods.BindTo(modSelect.SelectedMods); } } } diff --git a/osu.Desktop.VisualTests/Tests/TestCaseModSelectOverlay.cs b/osu.Desktop.VisualTests/Tests/TestCaseModSelectOverlay.cs index d1c137191f..0f85a8ab76 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseModSelectOverlay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseModSelectOverlay.cs @@ -13,7 +13,7 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Tests the mod select overlay"; - private ModSelectOverlay modSelect; + protected ModSelectOverlay modSelect; private RulesetDatabase rulesets; [BackgroundDependencyLoader] diff --git a/osu.Game/Rulesets/UI/ModIcon.cs b/osu.Game/Rulesets/UI/ModIcon.cs index 710ea22a5b..19efdb0175 100644 --- a/osu.Game/Rulesets/UI/ModIcon.cs +++ b/osu.Game/Rulesets/UI/ModIcon.cs @@ -40,7 +40,7 @@ namespace osu.Game.Rulesets.UI set { modIcon.Icon = value; } } - public ModIcon(Mod m) + public ModIcon(Mod mod) { Children = new Drawable[] { @@ -49,7 +49,7 @@ namespace osu.Game.Rulesets.UI Origin = Anchor.Centre, Anchor = Anchor.Centre, Icon = FontAwesome.fa_osu_mod_bg, - Colour = pickColour(m), + Colour = getBackgroundColourFromMod(mod), Shadow = true, TextSize = 20 }, @@ -59,7 +59,7 @@ namespace osu.Game.Rulesets.UI Anchor = Anchor.Centre, Colour = OsuColour.Gray(84), TextSize = 20, - Icon = m?.Icon ?? FontAwesome.fa_question, + Icon = (mod != null) ? mod.Icon : FontAwesome.fa_question, }, }; @@ -72,7 +72,7 @@ namespace osu.Game.Rulesets.UI modIcon.TextSize = iconSize - 35; } - private Color4 pickColour(Mod mod) + private Color4 getBackgroundColourFromMod(Mod mod) { switch (mod?.Type) { diff --git a/osu.Game/Screens/Play/ModsContainer.cs b/osu.Game/Screens/Play/ModsContainer.cs index 5806a12ac9..2fed50c9ce 100644 --- a/osu.Game/Screens/Play/ModsContainer.cs +++ b/osu.Game/Screens/Play/ModsContainer.cs @@ -7,6 +7,8 @@ using osu.Game.Rulesets.UI; using osu.Framework.Graphics; using osu.Game.Graphics.Sprites; using OpenTK; +using System.Collections.Generic; +using osu.Framework.Configuration; namespace osu.Game.Screens.Play { @@ -14,15 +16,23 @@ namespace osu.Game.Screens.Play { private readonly FillFlowContainer iconsContainer; + public readonly Bindable> Mods = new Bindable>(); + private bool showMods; public bool ShowMods { + get + { + return showMods; + } set { showMods = value; - if (!showMods) Hide(); + if (!showMods) + Hide(); + else + Show(); } - get { return showMods; } } public ModsContainer() @@ -46,20 +56,19 @@ namespace osu.Game.Screens.Play TextSize = 12, } }; - } - public void Add(Mod mod) - { - iconsContainer.Add(new ModIcon(mod) + Mods.ValueChanged += mods => { - AutoSizeAxes = Axes.Both, - Scale = new Vector2(0.7f), - }); - } - - public void Clear() - { - iconsContainer.Clear(); + iconsContainer.Clear(); + foreach (Mod mod in mods) + { + iconsContainer.Add(new ModIcon(mod) + { + AutoSizeAxes = Axes.Both, + Scale = new Vector2(0.7f), + }); + } + }; } } } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 948594235f..783533e8cd 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -170,8 +170,7 @@ namespace osu.Game.Screens.Play hudOverlay.Progress.OnSeek = pos => decoupledClock.Seek(pos); hudOverlay.ModsContainer.ShowMods = HitRenderer.HasReplayLoaded; - foreach (var mod in Beatmap.Mods.Value) - hudOverlay.ModsContainer.Add(mod); + hudOverlay.ModsContainer.Mods.BindTo(Beatmap.Mods); //bind HitRenderer to ScoreProcessor and ourselves (for a pass situation) HitRenderer.OnAllJudged += onCompletion; From 95f6c999bdbb56ae4daf9d489c088eb7ee30e3de Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Thu, 4 May 2017 17:59:01 +0300 Subject: [PATCH 17/29] Adjust scale and CI fixes --- .../Tests/TestCaseIngameModsContainer.cs | 15 +++------------ .../Tests/TestCaseModSelectOverlay.cs | 8 ++++---- osu.Game/Screens/Play/ModsContainer.cs | 6 +++--- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseIngameModsContainer.cs b/osu.Desktop.VisualTests/Tests/TestCaseIngameModsContainer.cs index e9b8df2d1b..c90be74bd7 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseIngameModsContainer.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseIngameModsContainer.cs @@ -1,18 +1,9 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using osu.Framework.Testing; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Colour; -using osu.Framework.Graphics.Sprites; -using osu.Game.Screens.Menu; -using OpenTK.Graphics; -using osu.Game.Screens.Play; -using osu.Framework.Allocation; -using osu.Game.Overlays.Mods; -using osu.Game.Database; -using osu.Game.Rulesets.Mods; using OpenTK; +using osu.Framework.Graphics; +using osu.Game.Screens.Play; namespace osu.Desktop.VisualTests.Tests { @@ -34,7 +25,7 @@ namespace osu.Desktop.VisualTests.Tests Position = new Vector2(0, 25), }); - modsContainer.Mods.BindTo(modSelect.SelectedMods); + modsContainer.Mods.BindTo(ModSelect.SelectedMods); } } } diff --git a/osu.Desktop.VisualTests/Tests/TestCaseModSelectOverlay.cs b/osu.Desktop.VisualTests/Tests/TestCaseModSelectOverlay.cs index 0f85a8ab76..5c1750679a 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseModSelectOverlay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseModSelectOverlay.cs @@ -13,7 +13,7 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Tests the mod select overlay"; - protected ModSelectOverlay modSelect; + protected ModSelectOverlay ModSelect; private RulesetDatabase rulesets; [BackgroundDependencyLoader] @@ -26,17 +26,17 @@ namespace osu.Desktop.VisualTests.Tests { base.Reset(); - Add(modSelect = new ModSelectOverlay + Add(ModSelect = new ModSelectOverlay { RelativeSizeAxes = Axes.X, Origin = Anchor.BottomCentre, Anchor = Anchor.BottomCentre, }); - AddStep("Toggle", modSelect.ToggleVisibility); + AddStep("Toggle", ModSelect.ToggleVisibility); foreach (var ruleset in rulesets.AllRulesets) - AddStep(ruleset.CreateInstance().Description, () => modSelect.Ruleset.Value = ruleset); + AddStep(ruleset.CreateInstance().Description, () => ModSelect.Ruleset.Value = ruleset); } } } diff --git a/osu.Game/Screens/Play/ModsContainer.cs b/osu.Game/Screens/Play/ModsContainer.cs index 2fed50c9ce..f5d48fef69 100644 --- a/osu.Game/Screens/Play/ModsContainer.cs +++ b/osu.Game/Screens/Play/ModsContainer.cs @@ -14,8 +14,6 @@ namespace osu.Game.Screens.Play { public class ModsContainer : Container { - private readonly FillFlowContainer iconsContainer; - public readonly Bindable> Mods = new Bindable>(); private bool showMods; @@ -37,6 +35,8 @@ namespace osu.Game.Screens.Play public ModsContainer() { + FillFlowContainer iconsContainer; + Children = new Drawable[] { iconsContainer = new FillFlowContainer @@ -65,7 +65,7 @@ namespace osu.Game.Screens.Play iconsContainer.Add(new ModIcon(mod) { AutoSizeAxes = Axes.Both, - Scale = new Vector2(0.7f), + Scale = new Vector2(0.65f), }); } }; From 6298b3effd26679001f34c5fb4290cdefee76b5f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 5 May 2017 12:16:41 +0900 Subject: [PATCH 18/29] Refactor ModSection and ModIcon to avoid null mods. --- osu.Game/Overlays/Mods/ModButton.cs | 18 +++---- osu.Game/Overlays/Mods/ModButtonEmpty.cs | 23 +++++++++ osu.Game/Overlays/Mods/ModSection.cs | 55 +++++++++++++--------- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 13 ++--- osu.Game/Rulesets/UI/ModIcon.cs | 9 ++-- osu.Game/osu.Game.csproj | 1 + 6 files changed, 76 insertions(+), 43 deletions(-) create mode 100644 osu.Game/Overlays/Mods/ModButtonEmpty.cs diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs index e3d26cba06..b07bb7d2fb 100644 --- a/osu.Game/Overlays/Mods/ModButton.cs +++ b/osu.Game/Overlays/Mods/ModButton.cs @@ -19,7 +19,11 @@ using System.Linq; namespace osu.Game.Overlays.Mods { - public class ModButton : FillFlowContainer + + /// + /// Represents a clickable button which can cycle through one of more mods. + /// + public class ModButton : ModButtonEmpty { private ModIcon foregroundIcon { get; set; } private readonly SpriteText text; @@ -116,7 +120,7 @@ namespace osu.Game.Overlays.Mods // the mods from Mod, only multiple if Mod is a MultiMod - public Mod SelectedMod => Mods.ElementAtOrDefault(selectedIndex); + public override Mod SelectedMod => Mods.ElementAtOrDefault(selectedIndex); [BackgroundDependencyLoader] private void load(AudioManager audio) @@ -198,13 +202,8 @@ namespace osu.Game.Overlays.Mods buttonColour = foregroundIcon.Colour; } - public ModButton(Mod m) + public ModButton(Mod mod) { - Direction = FillDirection.Vertical; - Spacing = new Vector2(0f, -5f); - Size = new Vector2(100f); - AlwaysPresent = true; - Children = new Drawable[] { new Container @@ -224,13 +223,14 @@ namespace osu.Game.Overlays.Mods }, text = new OsuSpriteText { + Y = 75, Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, TextSize = 18, }, }; - Mod = m; + Mod = mod; } } } diff --git a/osu.Game/Overlays/Mods/ModButtonEmpty.cs b/osu.Game/Overlays/Mods/ModButtonEmpty.cs new file mode 100644 index 0000000000..638c2a0e47 --- /dev/null +++ b/osu.Game/Overlays/Mods/ModButtonEmpty.cs @@ -0,0 +1,23 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using osu.Framework.Graphics.Containers; +using osu.Game.Rulesets.Mods; + +namespace osu.Game.Overlays.Mods +{ + /// + /// A mod button used exclusively for providing an empty space the size of a mod button. + /// + public class ModButtonEmpty : Container + { + public virtual Mod SelectedMod => null; + + public ModButtonEmpty() + { + Size = new Vector2(100f); + AlwaysPresent = true; + } + } +} diff --git a/osu.Game/Overlays/Mods/ModSection.cs b/osu.Game/Overlays/Mods/ModSection.cs index b70323fb63..40bd1e8b07 100644 --- a/osu.Game/Overlays/Mods/ModSection.cs +++ b/osu.Game/Overlays/Mods/ModSection.cs @@ -11,6 +11,8 @@ using osu.Framework.Input; using osu.Game.Graphics.Sprites; using osu.Game.Rulesets.Mods; using System; +using System.Linq; +using System.Collections.Generic; namespace osu.Game.Overlays.Mods { @@ -18,7 +20,7 @@ namespace osu.Game.Overlays.Mods { private readonly OsuSpriteText headerLabel; - public FillFlowContainer ButtonsContainer { get; } + public FillFlowContainer ButtonsContainer { get; } public Action Action; protected abstract Key[] ToggleKeys { get; } @@ -36,28 +38,31 @@ namespace osu.Game.Overlays.Mods } } - private ModButton[] buttons = { }; - public ModButton[] Buttons + public IEnumerable SelectedMods => buttons.Select(b => b.SelectedMod).Where(m => m != null); + + public IEnumerable Mods { - get - { - return buttons; - } set { - if (value == buttons) return; - buttons = value; - - foreach (ModButton button in value) + var modContainers = value.Select(m => { - button.SelectedColour = selectedColour; - button.Action = Action; - } + if (m == null) + return new ModButtonEmpty(); + else + return new ModButton(m) + { + SelectedColour = selectedColour, + Action = Action, + }; + }).ToArray(); - ButtonsContainer.Children = value; + ButtonsContainer.Children = modContainers; + buttons = modContainers.OfType().ToArray(); } } + private ModButton[] buttons = { }; + private Color4 selectedColour = Color4.White; public Color4 SelectedColour { @@ -71,17 +76,15 @@ namespace osu.Game.Overlays.Mods selectedColour = value; foreach (ModButton button in buttons) - { button.SelectedColour = value; - } } } protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { var index = Array.IndexOf(ToggleKeys, args.Key); - if (index > -1 && index < Buttons.Length) - Buttons[index].SelectNext(); + if (index > -1 && index < buttons.Length) + buttons[index].SelectNext(); return base.OnKeyDown(state, args); } @@ -89,8 +92,18 @@ namespace osu.Game.Overlays.Mods public void DeselectAll() { foreach (ModButton button in buttons) - { button.Deselect(); + } + + public void DeselectTypes(Type[] modTypes) + { + foreach (var button in buttons) + { + Mod selected = button.SelectedMod; + if (selected == null) continue; + foreach (Type type in modTypes) + if (type.IsInstanceOfType(selected)) + button.Deselect(); } } @@ -107,7 +120,7 @@ namespace osu.Game.Overlays.Mods Position = new Vector2(0f, 0f), Font = @"Exo2.0-Bold" }, - ButtonsContainer = new FillFlowContainer + ButtonsContainer = new FillFlowContainer { AutoSizeAxes = Axes.Both, Origin = Anchor.BottomLeft, diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index dadfb808f7..2840ffd1e4 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -44,7 +44,7 @@ namespace osu.Game.Overlays.Mods var instance = newRuleset.CreateInstance(); foreach (ModSection section in modSectionsContainer.Children) - section.Buttons = instance.GetModsFor(section.ModType).Select(m => new ModButton(m)).ToArray(); + section.Mods = instance.GetModsFor(section.ModType); refreshSelectedMods(); } @@ -103,14 +103,7 @@ namespace osu.Game.Overlays.Mods { if (modTypes.Length == 0) return; foreach (ModSection section in modSectionsContainer.Children) - foreach (ModButton button in section.Buttons) - { - Mod selected = button.SelectedMod; - if (selected == null) continue; - foreach (Type type in modTypes) - if (type.IsInstanceOfType(selected)) - button.Deselect(); - } + section.DeselectTypes(modTypes); } private void modButtonPressed(Mod selectedMod) @@ -122,7 +115,7 @@ namespace osu.Game.Overlays.Mods private void refreshSelectedMods() { - SelectedMods.Value = modSectionsContainer.Children.SelectMany(s => s.Buttons.Select(x => x.SelectedMod).Where(x => x != null)).ToArray(); + SelectedMods.Value = modSectionsContainer.Children.SelectMany(s => s.SelectedMods).ToArray(); double multiplier = 1.0; bool ranked = true; diff --git a/osu.Game/Rulesets/UI/ModIcon.cs b/osu.Game/Rulesets/UI/ModIcon.cs index 19efdb0175..497c71f0d5 100644 --- a/osu.Game/Rulesets/UI/ModIcon.cs +++ b/osu.Game/Rulesets/UI/ModIcon.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.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -42,6 +43,8 @@ namespace osu.Game.Rulesets.UI public ModIcon(Mod mod) { + if (mod == null) throw new ArgumentNullException(nameof(mod)); + Children = new Drawable[] { background = new TextAwesome @@ -59,7 +62,7 @@ namespace osu.Game.Rulesets.UI Anchor = Anchor.Centre, Colour = OsuColour.Gray(84), TextSize = 20, - Icon = (mod != null) ? mod.Icon : FontAwesome.fa_question, + Icon = mod.Icon }, }; @@ -74,7 +77,7 @@ namespace osu.Game.Rulesets.UI private Color4 getBackgroundColourFromMod(Mod mod) { - switch (mod?.Type) + switch (mod.Type) { case ModType.DifficultyIncrease: return OsuColour.FromHex(@"ffcc22"); @@ -87,4 +90,4 @@ namespace osu.Game.Rulesets.UI } } } -} \ No newline at end of file +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 98f9a8a52b..c06ba0b1ea 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -391,6 +391,7 @@ + From c9ba1ac4f6998921aa2e70223113cddcf1a18fff Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 5 May 2017 13:00:05 +0900 Subject: [PATCH 19/29] Adjust namespaces. Also adds transition, uses IHasCurrentValue, combines Mod TestCases and more. --- .../Tests/TestCaseIngameModsContainer.cs | 31 ------ ...aseModSelectOverlay.cs => TestCaseMods.cs} | 27 ++++- .../Tests/TestCaseScoreCounter.cs | 2 +- .../osu.Desktop.VisualTests.csproj | 3 +- .../UI => Screens/Play/HUD}/ComboCounter.cs | 2 +- .../Play/HUD}/ComboResultCounter.cs | 4 +- .../UI => Screens/Play/HUD}/HealthDisplay.cs | 2 +- osu.Game/Screens/Play/HUD/ModDisplay.cs | 105 ++++++++++++++++++ .../Play/HUD}/StandardComboCounter.cs | 2 +- .../Play/HUD}/StandardHealthDisplay.cs | 8 +- .../Play/HUDOverlay.cs} | 21 ++-- osu.Game/Screens/Play/ModsContainer.cs | 74 ------------ osu.Game/Screens/Play/Player.cs | 8 +- .../UI => Screens/Play}/StandardHudOverlay.cs | 12 +- osu.Game/osu.Game.csproj | 16 +-- osu.sln.DotSettings | 1 + 16 files changed, 167 insertions(+), 151 deletions(-) delete mode 100644 osu.Desktop.VisualTests/Tests/TestCaseIngameModsContainer.cs rename osu.Desktop.VisualTests/Tests/{TestCaseModSelectOverlay.cs => TestCaseMods.cs} (54%) rename osu.Game/{Rulesets/UI => Screens/Play/HUD}/ComboCounter.cs (96%) rename osu.Game/{Rulesets/UI => Screens/Play/HUD}/ComboResultCounter.cs (95%) rename osu.Game/{Rulesets/UI => Screens/Play/HUD}/HealthDisplay.cs (91%) create mode 100644 osu.Game/Screens/Play/HUD/ModDisplay.cs rename osu.Game/{Rulesets/UI => Screens/Play/HUD}/StandardComboCounter.cs (96%) rename osu.Game/{Rulesets/UI => Screens/Play/HUD}/StandardHealthDisplay.cs (96%) rename osu.Game/{Rulesets/UI/HudOverlay.cs => Screens/Play/HUDOverlay.cs} (90%) delete mode 100644 osu.Game/Screens/Play/ModsContainer.cs rename osu.Game/{Rulesets/UI => Screens/Play}/StandardHudOverlay.cs (89%) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseIngameModsContainer.cs b/osu.Desktop.VisualTests/Tests/TestCaseIngameModsContainer.cs deleted file mode 100644 index c90be74bd7..0000000000 --- a/osu.Desktop.VisualTests/Tests/TestCaseIngameModsContainer.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using OpenTK; -using osu.Framework.Graphics; -using osu.Game.Screens.Play; - -namespace osu.Desktop.VisualTests.Tests -{ - internal class TestCaseIngameModsContainer : TestCaseModSelectOverlay - { - public override string Description => @"Ingame mods visualization"; - - private ModsContainer modsContainer; - - public override void Reset() - { - base.Reset(); - - Add(modsContainer = new ModsContainer - { - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - AutoSizeAxes = Axes.Both, - Position = new Vector2(0, 25), - }); - - modsContainer.Mods.BindTo(ModSelect.SelectedMods); - } - } -} diff --git a/osu.Desktop.VisualTests/Tests/TestCaseModSelectOverlay.cs b/osu.Desktop.VisualTests/Tests/TestCaseMods.cs similarity index 54% rename from osu.Desktop.VisualTests/Tests/TestCaseModSelectOverlay.cs rename to osu.Desktop.VisualTests/Tests/TestCaseMods.cs index 5c1750679a..3f3a9d82f5 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseModSelectOverlay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseMods.cs @@ -6,16 +6,21 @@ using osu.Framework.Graphics; using osu.Game.Overlays.Mods; using osu.Framework.Testing; using osu.Game.Database; +using osu.Game.Screens.Play.HUD; +using OpenTK; namespace osu.Desktop.VisualTests.Tests { - internal class TestCaseModSelectOverlay : TestCase + internal class TestCaseMods : TestCase { - public override string Description => @"Tests the mod select overlay"; + public override string Description => @"Mod select overlay and in-game display"; + + private ModSelectOverlay modSelect; + private ModDisplay modDisplay; - protected ModSelectOverlay ModSelect; private RulesetDatabase rulesets; + [BackgroundDependencyLoader] private void load(RulesetDatabase rulesets) { @@ -26,17 +31,27 @@ namespace osu.Desktop.VisualTests.Tests { base.Reset(); - Add(ModSelect = new ModSelectOverlay + Add(modSelect = new ModSelectOverlay { RelativeSizeAxes = Axes.X, Origin = Anchor.BottomCentre, Anchor = Anchor.BottomCentre, }); - AddStep("Toggle", ModSelect.ToggleVisibility); + Add(modDisplay = new ModDisplay + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + AutoSizeAxes = Axes.Both, + Position = new Vector2(0, 25), + }); + + modDisplay.Current.BindTo(modSelect.SelectedMods); + + AddStep("Toggle", modSelect.ToggleVisibility); foreach (var ruleset in rulesets.AllRulesets) - AddStep(ruleset.CreateInstance().Description, () => ModSelect.Ruleset.Value = ruleset); + AddStep(ruleset.CreateInstance().Description, () => modSelect.Ruleset.Value = ruleset); } } } diff --git a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs index d8dac63980..cfa66f12ed 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs @@ -8,7 +8,7 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.MathUtils; using osu.Framework.Testing; using osu.Game.Graphics.UserInterface; -using osu.Game.Rulesets.UI; +using osu.Game.Screens.Play.HUD; namespace osu.Desktop.VisualTests.Tests { diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index a9e1e27402..107072b3ea 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -190,7 +190,6 @@ - @@ -213,7 +212,7 @@ - + diff --git a/osu.Game/Rulesets/UI/ComboCounter.cs b/osu.Game/Screens/Play/HUD/ComboCounter.cs similarity index 96% rename from osu.Game/Rulesets/UI/ComboCounter.cs rename to osu.Game/Screens/Play/HUD/ComboCounter.cs index d21059cbdb..a130bc2eab 100644 --- a/osu.Game/Rulesets/UI/ComboCounter.cs +++ b/osu.Game/Screens/Play/HUD/ComboCounter.cs @@ -10,7 +10,7 @@ using osu.Framework.Graphics.Transforms; using osu.Framework.MathUtils; using osu.Game.Graphics.Sprites; -namespace osu.Game.Rulesets.UI +namespace osu.Game.Screens.Play.HUD { public abstract class ComboCounter : Container { diff --git a/osu.Game/Rulesets/UI/ComboResultCounter.cs b/osu.Game/Screens/Play/HUD/ComboResultCounter.cs similarity index 95% rename from osu.Game/Rulesets/UI/ComboResultCounter.cs rename to osu.Game/Screens/Play/HUD/ComboResultCounter.cs index 4b19b2c1ff..a1a166f944 100644 --- a/osu.Game/Rulesets/UI/ComboResultCounter.cs +++ b/osu.Game/Screens/Play/HUD/ComboResultCounter.cs @@ -1,13 +1,13 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using osu.Framework.Graphics; using osu.Framework.Graphics.Transforms; using osu.Framework.MathUtils; using osu.Game.Graphics.UserInterface; -using System; -namespace osu.Game.Rulesets.UI +namespace osu.Game.Screens.Play.HUD { /// /// Used to display combo with a roll-up animation in results screen. diff --git a/osu.Game/Rulesets/UI/HealthDisplay.cs b/osu.Game/Screens/Play/HUD/HealthDisplay.cs similarity index 91% rename from osu.Game/Rulesets/UI/HealthDisplay.cs rename to osu.Game/Screens/Play/HUD/HealthDisplay.cs index 5c6b9d2fe3..a146172085 100644 --- a/osu.Game/Rulesets/UI/HealthDisplay.cs +++ b/osu.Game/Screens/Play/HUD/HealthDisplay.cs @@ -4,7 +4,7 @@ using osu.Framework.Configuration; using osu.Framework.Graphics.Containers; -namespace osu.Game.Rulesets.UI +namespace osu.Game.Screens.Play.HUD { public abstract class HealthDisplay : Container { diff --git a/osu.Game/Screens/Play/HUD/ModDisplay.cs b/osu.Game/Screens/Play/HUD/ModDisplay.cs new file mode 100644 index 0000000000..ece160e284 --- /dev/null +++ b/osu.Game/Screens/Play/HUD/ModDisplay.cs @@ -0,0 +1,105 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Collections.Generic; +using System.Linq; +using osu.Framework.Configuration; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Primitives; +using osu.Framework.Graphics.UserInterface; +using osu.Game.Graphics.Sprites; +using osu.Game.Rulesets.Mods; +using osu.Game.Rulesets.UI; +using OpenTK; + +namespace osu.Game.Screens.Play.HUD +{ + public class ModDisplay : Container, IHasCurrentValue> + { + private readonly Bindable> mods = new Bindable>(); + + private bool showMods; + public bool ShowMods + { + get + { + return showMods; + } + set + { + showMods = value; + if (!showMods) + Hide(); + else + Show(); + } + } + + public Bindable> Current => mods; + + private readonly FillFlowContainer iconsContainer; + + public ModDisplay() + { + Children = new Drawable[] + { + iconsContainer = new IconFlow + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Margin = new MarginPadding { Left = 10, Right = 10 }, + }, + new OsuSpriteText + { + Anchor = Anchor.BottomCentre, + Origin = Anchor.TopCentre, + Text = @"/ UNRANKED /", + Font = @"Venera", + TextSize = 12, + } + }; + + mods.ValueChanged += mods => + { + iconsContainer.Clear(); + foreach (Mod mod in mods) + { + iconsContainer.Add(new ModIcon(mod) + { + AutoSizeAxes = Axes.Both, + Scale = new Vector2(0.6f), + + }); + } + + if (IsLoaded) + appearTransform(); + }; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + appearTransform(); + } + + private void appearTransform() + { + iconsContainer.Flush(); + iconsContainer.FadeInFromZero(1000, EasingTypes.OutQuint); + iconsContainer.TransformSpacingTo(new Vector2(5, 0)); + using (iconsContainer.BeginDelayedSequence(1200)) + iconsContainer.TransformSpacingTo(new Vector2(-25, 0), 500, EasingTypes.OutQuint); + } + + private class IconFlow : FillFlowContainer + { + // just reverses the depth of flow contents. + protected override IComparer DepthComparer => new ReverseCreationOrderDepthComparer(); + protected override IEnumerable FlowingChildren => base.FlowingChildren.Reverse(); + } + } +} diff --git a/osu.Game/Rulesets/UI/StandardComboCounter.cs b/osu.Game/Screens/Play/HUD/StandardComboCounter.cs similarity index 96% rename from osu.Game/Rulesets/UI/StandardComboCounter.cs rename to osu.Game/Screens/Play/HUD/StandardComboCounter.cs index ad05c83839..525e52d207 100644 --- a/osu.Game/Rulesets/UI/StandardComboCounter.cs +++ b/osu.Game/Screens/Play/HUD/StandardComboCounter.cs @@ -3,7 +3,7 @@ using OpenTK; -namespace osu.Game.Rulesets.UI +namespace osu.Game.Screens.Play.HUD { /// /// Uses the 'x' symbol and has a pop-out effect while rolling over. diff --git a/osu.Game/Rulesets/UI/StandardHealthDisplay.cs b/osu.Game/Screens/Play/HUD/StandardHealthDisplay.cs similarity index 96% rename from osu.Game/Rulesets/UI/StandardHealthDisplay.cs rename to osu.Game/Screens/Play/HUD/StandardHealthDisplay.cs index 3d9a5489dc..7ba5dfe1b7 100644 --- a/osu.Game/Rulesets/UI/StandardHealthDisplay.cs +++ b/osu.Game/Screens/Play/HUD/StandardHealthDisplay.cs @@ -1,8 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK; -using OpenTK.Graphics; +using System; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -10,9 +9,10 @@ using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Objects.Drawables; -using System; +using OpenTK; +using OpenTK.Graphics; -namespace osu.Game.Rulesets.UI +namespace osu.Game.Screens.Play.HUD { public class StandardHealthDisplay : HealthDisplay, IHasAccentColour { diff --git a/osu.Game/Rulesets/UI/HudOverlay.cs b/osu.Game/Screens/Play/HUDOverlay.cs similarity index 90% rename from osu.Game/Rulesets/UI/HudOverlay.cs rename to osu.Game/Screens/Play/HUDOverlay.cs index 9bd900da4b..a9580df811 100644 --- a/osu.Game/Rulesets/UI/HudOverlay.cs +++ b/osu.Game/Screens/Play/HUDOverlay.cs @@ -5,18 +5,19 @@ using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Input; using osu.Game.Configuration; using osu.Game.Graphics.UserInterface; -using osu.Game.Screens.Play; -using osu.Game.Rulesets.Scoring; -using osu.Framework.Input; -using OpenTK.Input; using osu.Game.Overlays; using osu.Game.Overlays.Notifications; +using osu.Game.Rulesets.Scoring; +using osu.Game.Rulesets.UI; +using osu.Game.Screens.Play.HUD; +using OpenTK.Input; -namespace osu.Game.Rulesets.UI +namespace osu.Game.Screens.Play { - public abstract class HudOverlay : Container + public abstract class HUDOverlay : Container { private const int duration = 100; @@ -27,7 +28,7 @@ namespace osu.Game.Rulesets.UI public readonly RollingCounter AccuracyCounter; public readonly HealthDisplay HealthDisplay; public readonly SongProgress Progress; - public readonly ModsContainer ModsContainer; + public readonly ModDisplay ModDisplay; private Bindable showKeyCounter; private Bindable showHud; @@ -40,9 +41,9 @@ namespace osu.Game.Rulesets.UI protected abstract ScoreCounter CreateScoreCounter(); protected abstract HealthDisplay CreateHealthDisplay(); protected abstract SongProgress CreateProgress(); - protected abstract ModsContainer CreateModsContainer(); + protected abstract ModDisplay CreateModsContainer(); - protected HudOverlay() + protected HUDOverlay() { RelativeSizeAxes = Axes.Both; @@ -58,7 +59,7 @@ namespace osu.Game.Rulesets.UI AccuracyCounter = CreateAccuracyCounter(), HealthDisplay = CreateHealthDisplay(), Progress = CreateProgress(), - ModsContainer = CreateModsContainer(), + ModDisplay = CreateModsContainer(), } }); } diff --git a/osu.Game/Screens/Play/ModsContainer.cs b/osu.Game/Screens/Play/ModsContainer.cs deleted file mode 100644 index f5d48fef69..0000000000 --- a/osu.Game/Screens/Play/ModsContainer.cs +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Framework.Graphics.Containers; -using osu.Game.Rulesets.Mods; -using osu.Game.Rulesets.UI; -using osu.Framework.Graphics; -using osu.Game.Graphics.Sprites; -using OpenTK; -using System.Collections.Generic; -using osu.Framework.Configuration; - -namespace osu.Game.Screens.Play -{ - public class ModsContainer : Container - { - public readonly Bindable> Mods = new Bindable>(); - - private bool showMods; - public bool ShowMods - { - get - { - return showMods; - } - set - { - showMods = value; - if (!showMods) - Hide(); - else - Show(); - } - } - - public ModsContainer() - { - FillFlowContainer iconsContainer; - - Children = new Drawable[] - { - iconsContainer = new FillFlowContainer - { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Spacing = new Vector2(5,0), - }, - new OsuSpriteText - { - Anchor = Anchor.BottomCentre, - Origin = Anchor.TopCentre, - Text = @"/ UNRANKED /", - Font = @"Venera", - TextSize = 12, - } - }; - - Mods.ValueChanged += mods => - { - iconsContainer.Clear(); - foreach (Mod mod in mods) - { - iconsContainer.Add(new ModIcon(mod) - { - AutoSizeAxes = Axes.Both, - Scale = new Vector2(0.65f), - }); - } - }; - } - } -} diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 783533e8cd..1ebd269cf5 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -72,7 +72,7 @@ namespace osu.Game.Screens.Play private Container hitRendererContainer; - private HudOverlay hudOverlay; + private HUDOverlay hudOverlay; private PauseOverlay pauseOverlay; private FailOverlay failOverlay; @@ -154,7 +154,7 @@ namespace osu.Game.Screens.Play scoreProcessor = HitRenderer.CreateScoreProcessor(); - hudOverlay = new StandardHudOverlay() + hudOverlay = new StandardHUDOverlay() { Anchor = Anchor.Centre, Origin = Anchor.Centre @@ -169,8 +169,8 @@ namespace osu.Game.Screens.Play hudOverlay.Progress.AllowSeeking = HitRenderer.HasReplayLoaded; hudOverlay.Progress.OnSeek = pos => decoupledClock.Seek(pos); - hudOverlay.ModsContainer.ShowMods = HitRenderer.HasReplayLoaded; - hudOverlay.ModsContainer.Mods.BindTo(Beatmap.Mods); + hudOverlay.ModDisplay.ShowMods = HitRenderer.HasReplayLoaded; + hudOverlay.ModDisplay.Current.BindTo(Beatmap.Mods); //bind HitRenderer to ScoreProcessor and ourselves (for a pass situation) HitRenderer.OnAllJudged += onCompletion; diff --git a/osu.Game/Rulesets/UI/StandardHudOverlay.cs b/osu.Game/Screens/Play/StandardHudOverlay.cs similarity index 89% rename from osu.Game/Rulesets/UI/StandardHudOverlay.cs rename to osu.Game/Screens/Play/StandardHudOverlay.cs index 709f8ef395..41f9ee1394 100644 --- a/osu.Game/Rulesets/UI/StandardHudOverlay.cs +++ b/osu.Game/Screens/Play/StandardHudOverlay.cs @@ -1,18 +1,18 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Primitives; using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; using osu.Game.Rulesets.Scoring; -using osu.Game.Screens.Play; +using osu.Game.Screens.Play.HUD; +using OpenTK; -namespace osu.Game.Rulesets.UI +namespace osu.Game.Screens.Play { - public class StandardHudOverlay : HudOverlay + public class StandardHUDOverlay : HUDOverlay { protected override RollingCounter CreateAccuracyCounter() => new PercentageCounter { @@ -64,12 +64,12 @@ namespace osu.Game.Rulesets.UI RelativeSizeAxes = Axes.X, }; - protected override ModsContainer CreateModsContainer() => new ModsContainer + protected override ModDisplay CreateModsContainer() => new ModDisplay { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, AutoSizeAxes = Axes.Both, - Position = new Vector2(0, 25), + Margin = new MarginPadding { Top = 20, Right = 10 }, }; [BackgroundDependencyLoader] diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index c06ba0b1ea..80c88d7a00 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -178,10 +178,9 @@ - - - - + + + @@ -228,8 +227,9 @@ - + + @@ -255,7 +255,7 @@ - + @@ -280,8 +280,8 @@ - - + + diff --git a/osu.sln.DotSettings b/osu.sln.DotSettings index bc2c347d0c..03d9e34805 100644 --- a/osu.sln.DotSettings +++ b/osu.sln.DotSettings @@ -182,6 +182,7 @@ GL GLSL HID + HUD ID IP IPC From b547dd6893571aabb50cda450328535eb3e0ee82 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 5 May 2017 13:06:54 +0900 Subject: [PATCH 20/29] CI Fixes. --- osu.Game/Screens/Play/HUD/ModDisplay.cs | 2 +- .../Play/{StandardHudOverlay.cs => StandardHUDOverlay.cs} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename osu.Game/Screens/Play/{StandardHudOverlay.cs => StandardHUDOverlay.cs} (100%) diff --git a/osu.Game/Screens/Play/HUD/ModDisplay.cs b/osu.Game/Screens/Play/HUD/ModDisplay.cs index ece160e284..6135106cf7 100644 --- a/osu.Game/Screens/Play/HUD/ModDisplay.cs +++ b/osu.Game/Screens/Play/HUD/ModDisplay.cs @@ -71,7 +71,7 @@ namespace osu.Game.Screens.Play.HUD { AutoSizeAxes = Axes.Both, Scale = new Vector2(0.6f), - + }); } diff --git a/osu.Game/Screens/Play/StandardHudOverlay.cs b/osu.Game/Screens/Play/StandardHUDOverlay.cs similarity index 100% rename from osu.Game/Screens/Play/StandardHudOverlay.cs rename to osu.Game/Screens/Play/StandardHUDOverlay.cs From 9c4f813da1d06a47107e9b497394e65abb0ea20f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 5 May 2017 13:14:44 +0900 Subject: [PATCH 21/29] Remove unnecessary hide/show logic. Also change the way the overlay appears when actually playing. --- osu.Game/Screens/Play/HUD/ModDisplay.cs | 17 ----------------- osu.Game/Screens/Play/Player.cs | 5 ++++- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/ModDisplay.cs b/osu.Game/Screens/Play/HUD/ModDisplay.cs index 6135106cf7..a5d6bea1a5 100644 --- a/osu.Game/Screens/Play/HUD/ModDisplay.cs +++ b/osu.Game/Screens/Play/HUD/ModDisplay.cs @@ -19,23 +19,6 @@ namespace osu.Game.Screens.Play.HUD { private readonly Bindable> mods = new Bindable>(); - private bool showMods; - public bool ShowMods - { - get - { - return showMods; - } - set - { - showMods = value; - if (!showMods) - Hide(); - else - Show(); - } - } - public Bindable> Current => mods; private readonly FillFlowContainer iconsContainer; diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 1ebd269cf5..22aa4d62c1 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -169,7 +169,6 @@ namespace osu.Game.Screens.Play hudOverlay.Progress.AllowSeeking = HitRenderer.HasReplayLoaded; hudOverlay.Progress.OnSeek = pos => decoupledClock.Seek(pos); - hudOverlay.ModDisplay.ShowMods = HitRenderer.HasReplayLoaded; hudOverlay.ModDisplay.Current.BindTo(Beatmap.Mods); //bind HitRenderer to ScoreProcessor and ourselves (for a pass situation) @@ -357,6 +356,10 @@ namespace osu.Game.Screens.Play hitRendererContainer.Alpha = 0; hitRendererContainer.FadeIn(750, EasingTypes.OutQuint); + + if (!HitRenderer.HasReplayLoaded) + using (hudOverlay.ModDisplay.BeginDelayedSequence(2000)) + hudOverlay.ModDisplay.FadeOut(200); } protected override void OnSuspending(Screen next) From 44f06e542321df9b274b95915468cd5473961ac2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 5 May 2017 13:17:36 +0900 Subject: [PATCH 22/29] Add hover expand support. --- osu.Game/Screens/Play/HUD/ModDisplay.cs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/ModDisplay.cs b/osu.Game/Screens/Play/HUD/ModDisplay.cs index a5d6bea1a5..1b67d8dc66 100644 --- a/osu.Game/Screens/Play/HUD/ModDisplay.cs +++ b/osu.Game/Screens/Play/HUD/ModDisplay.cs @@ -12,6 +12,7 @@ using osu.Game.Graphics.Sprites; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.UI; using OpenTK; +using osu.Framework.Input; namespace osu.Game.Screens.Play.HUD { @@ -73,9 +74,25 @@ namespace osu.Game.Screens.Play.HUD { iconsContainer.Flush(); iconsContainer.FadeInFromZero(1000, EasingTypes.OutQuint); - iconsContainer.TransformSpacingTo(new Vector2(5, 0)); + expand(); using (iconsContainer.BeginDelayedSequence(1200)) - iconsContainer.TransformSpacingTo(new Vector2(-25, 0), 500, EasingTypes.OutQuint); + contract(); + } + + private void expand() => iconsContainer.TransformSpacingTo(new Vector2(5, 0), 500, EasingTypes.OutQuint); + + private void contract() => iconsContainer.TransformSpacingTo(new Vector2(-25, 0), 500, EasingTypes.OutQuint); + + protected override bool OnHover(InputState state) + { + expand(); + return base.OnHover(state); + } + + protected override void OnHoverLost(InputState state) + { + contract(); + base.OnHoverLost(state); } private class IconFlow : FillFlowContainer From 4b385ded26218e0ee3459cd50d33d9ef2a067e11 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 5 May 2017 13:22:10 +0900 Subject: [PATCH 23/29] Tidy up ModIcon. --- osu.Game/Rulesets/UI/ModIcon.cs | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/osu.Game/Rulesets/UI/ModIcon.cs b/osu.Game/Rulesets/UI/ModIcon.cs index 497c71f0d5..8bd852f2c0 100644 --- a/osu.Game/Rulesets/UI/ModIcon.cs +++ b/osu.Game/Rulesets/UI/ModIcon.cs @@ -15,19 +15,7 @@ namespace osu.Game.Rulesets.UI private readonly TextAwesome modIcon; private readonly TextAwesome background; - private float iconSize = 80; - public float IconSize - { - get - { - return iconSize; - } - set - { - iconSize = value; - reapplySize(); - } - } + private const float icon_size = 80; public new Color4 Colour { @@ -71,8 +59,8 @@ namespace osu.Game.Rulesets.UI private void reapplySize() { - background.TextSize = iconSize; - modIcon.TextSize = iconSize - 35; + background.TextSize = icon_size; + modIcon.TextSize = icon_size - 35; } private Color4 getBackgroundColourFromMod(Mod mod) From 5aecc3d76103617ae15aeea0c624d55ac37c979e Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Fri, 5 May 2017 17:44:51 +0200 Subject: [PATCH 24/29] Made cursortrail work with multiple positions --- osu.Game/Graphics/Cursor/CursorTrail.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Graphics/Cursor/CursorTrail.cs b/osu.Game/Graphics/Cursor/CursorTrail.cs index 1c640b64d0..7022e98978 100644 --- a/osu.Game/Graphics/Cursor/CursorTrail.cs +++ b/osu.Game/Graphics/Cursor/CursorTrail.cs @@ -122,9 +122,9 @@ namespace osu.Game.Graphics.Cursor return base.OnMouseMove(state); } - Vector2 pos1 = lastPosition.Value; foreach (Vector2 pos2 in resampler.AddPosition(state.Mouse.NativeState.Position)) { + Vector2 pos1 = lastPosition.Value; Vector2 diff = pos2 - pos1; float distance = diff.Length; Vector2 direction = diff / distance; From fbf05f12fc24522c2db333d0ac6e67b2238029c3 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Mon, 8 May 2017 10:11:45 +0900 Subject: [PATCH 25/29] Use controlWithCurrent as per comment. --- osu.Game/Overlays/Options/OptionItem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Options/OptionItem.cs b/osu.Game/Overlays/Options/OptionItem.cs index c09eba7f11..2124796089 100644 --- a/osu.Game/Overlays/Options/OptionItem.cs +++ b/osu.Game/Overlays/Options/OptionItem.cs @@ -50,7 +50,7 @@ namespace osu.Game.Overlays.Options set { bindable = value; - (Control as IHasCurrentValue)?.Current.BindTo(bindable); + controlWithCurrent?.Current.BindTo(bindable); } } From 2f4fad9d416ad0620b35f37ca59bf41559c22e38 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 8 May 2017 11:33:22 +0900 Subject: [PATCH 26/29] Refactor colour selection. --- osu.Game/Overlays/Mods/ModButton.cs | 10 +---- osu.Game/Rulesets/UI/ModIcon.cs | 68 +++++++++++++++++++---------- 2 files changed, 46 insertions(+), 32 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs index b07bb7d2fb..ce70144bc3 100644 --- a/osu.Game/Overlays/Mods/ModButton.cs +++ b/osu.Game/Overlays/Mods/ModButton.cs @@ -55,7 +55,7 @@ namespace osu.Game.Overlays.Mods iconsContainer.RotateTo(Selected ? 5f : 0f, 300, EasingTypes.OutElastic); iconsContainer.ScaleTo(Selected ? 1.1f : 1f, 300, EasingTypes.OutElastic); - foregroundIcon.Colour = Selected ? SelectedColour : ButtonColour; + foregroundIcon.Highlighted = Selected; if (mod != null) displayMod(SelectedMod ?? Mods[0]); @@ -64,12 +64,6 @@ namespace osu.Game.Overlays.Mods public bool Selected => selectedIndex != -1; - private Color4 buttonColour; - public Color4 ButtonColour - { - get { return buttonColour; } - set { buttonColour = value; } - } private Color4 selectedColour; public Color4 SelectedColour @@ -198,8 +192,6 @@ namespace osu.Game.Overlays.Mods AutoSizeAxes = Axes.Both, }); } - - buttonColour = foregroundIcon.Colour; } public ModButton(Mod mod) diff --git a/osu.Game/Rulesets/UI/ModIcon.cs b/osu.Game/Rulesets/UI/ModIcon.cs index 8bd852f2c0..957ffc18e4 100644 --- a/osu.Game/Rulesets/UI/ModIcon.cs +++ b/osu.Game/Rulesets/UI/ModIcon.cs @@ -3,6 +3,7 @@ using System; using OpenTK.Graphics; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics; @@ -17,65 +18,86 @@ namespace osu.Game.Rulesets.UI private const float icon_size = 80; - public new Color4 Colour - { - get { return background.Colour; } - set { background.Colour = value; } - } - public FontAwesome Icon { get { return modIcon.Icon; } set { modIcon.Icon = value; } } + private ModType type; + public ModIcon(Mod mod) { if (mod == null) throw new ArgumentNullException(nameof(mod)); + type = mod.Type; + Children = new Drawable[] { background = new TextAwesome { Origin = Anchor.Centre, Anchor = Anchor.Centre, + TextSize = icon_size, Icon = FontAwesome.fa_osu_mod_bg, - Colour = getBackgroundColourFromMod(mod), Shadow = true, - TextSize = 20 }, modIcon = new TextAwesome { Origin = Anchor.Centre, Anchor = Anchor.Centre, Colour = OsuColour.Gray(84), - TextSize = 20, + TextSize = icon_size - 35, Icon = mod.Icon }, }; - - reapplySize(); } - private void reapplySize() - { - background.TextSize = icon_size; - modIcon.TextSize = icon_size - 35; - } + private Color4 backgroundColour; + private Color4 highlightedColour; - private Color4 getBackgroundColourFromMod(Mod mod) + [BackgroundDependencyLoader] + private void load(OsuColour colours) { - switch (mod.Type) + switch (type) { + default: case ModType.DifficultyIncrease: - return OsuColour.FromHex(@"ffcc22"); + backgroundColour = colours.Yellow; + highlightedColour = colours.YellowLight; + break; case ModType.DifficultyReduction: - return OsuColour.FromHex(@"88b300"); + backgroundColour = colours.Green; + highlightedColour = colours.GreenLight; + break; case ModType.Special: - return OsuColour.FromHex(@"66ccff"); - - default: return Color4.White; + backgroundColour = colours.Blue; + highlightedColour = colours.BlueLight; + break; } + + applyStyle(); + } + + private bool highlighted; + + public bool Highlighted + { + get + { + return highlighted; + } + + set + { + highlighted = value; + applyStyle(); + } + } + + private void applyStyle() + { + background.Colour = highlighted ? highlightedColour : backgroundColour; } } } From 10910cfcef699659e158017f952410e22b1dc44b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 8 May 2017 11:47:06 +0900 Subject: [PATCH 27/29] Make field readonly. --- osu.Game/Rulesets/UI/ModIcon.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/UI/ModIcon.cs b/osu.Game/Rulesets/UI/ModIcon.cs index 957ffc18e4..b23028098f 100644 --- a/osu.Game/Rulesets/UI/ModIcon.cs +++ b/osu.Game/Rulesets/UI/ModIcon.cs @@ -24,7 +24,7 @@ namespace osu.Game.Rulesets.UI set { modIcon.Icon = value; } } - private ModType type; + private readonly ModType type; public ModIcon(Mod mod) { From 48368779ab65e0793c854926727708b585477cd1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 8 May 2017 11:48:40 +0900 Subject: [PATCH 28/29] Avoid polluting Player with HUD-specific code. --- osu.Game/Screens/Play/HUDOverlay.cs | 5 +++++ osu.Game/Screens/Play/Player.cs | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Play/HUDOverlay.cs b/osu.Game/Screens/Play/HUDOverlay.cs index a9580df811..12e2cb197e 100644 --- a/osu.Game/Screens/Play/HUDOverlay.cs +++ b/osu.Game/Screens/Play/HUDOverlay.cs @@ -109,6 +109,11 @@ namespace osu.Game.Screens.Play public virtual void BindHitRenderer(HitRenderer hitRenderer) { hitRenderer.InputManager.Add(KeyCounter.GetReceptor()); + + // in the case a replay isn't loaded, we want some elements to only appear briefly. + if (!hitRenderer.HasReplayLoaded) + using (ModDisplay.BeginDelayedSequence(2000)) + ModDisplay.FadeOut(200); } protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 22aa4d62c1..534a224855 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -356,10 +356,6 @@ namespace osu.Game.Screens.Play hitRendererContainer.Alpha = 0; hitRendererContainer.FadeIn(750, EasingTypes.OutQuint); - - if (!HitRenderer.HasReplayLoaded) - using (hudOverlay.ModDisplay.BeginDelayedSequence(2000)) - hudOverlay.ModDisplay.FadeOut(200); } protected override void OnSuspending(Screen next) From 9f1f9266341458438fdcf9ce80aeeb3eec4c8de6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 8 May 2017 12:05:48 +0900 Subject: [PATCH 29/29] Add non-null assurance. --- osu.Game/Graphics/Cursor/CursorTrail.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game/Graphics/Cursor/CursorTrail.cs b/osu.Game/Graphics/Cursor/CursorTrail.cs index 7022e98978..1bc1dea04f 100644 --- a/osu.Game/Graphics/Cursor/CursorTrail.cs +++ b/osu.Game/Graphics/Cursor/CursorTrail.cs @@ -14,6 +14,7 @@ using OpenTK.Graphics.ES30; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Colour; using osu.Framework.Timing; +using System.Diagnostics; namespace osu.Game.Graphics.Cursor { @@ -124,6 +125,8 @@ namespace osu.Game.Graphics.Cursor foreach (Vector2 pos2 in resampler.AddPosition(state.Mouse.NativeState.Position)) { + Trace.Assert(lastPosition.HasValue); + Vector2 pos1 = lastPosition.Value; Vector2 diff = pos2 - pos1; float distance = diff.Length;