From 74fa33669323d9970b3cb1685203325306f9ef71 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 26 Apr 2017 14:25:46 +0900 Subject: [PATCH 001/329] 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 eacf2045f0c1bf5ef817fcfd88f22dd44dc639dc Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Fri, 28 Apr 2017 04:56:34 +0300 Subject: [PATCH 002/329] Initial commit --- osu.Game/Screens/Play/SongProgress.cs | 16 ++++- osu.Game/Screens/Play/SongProgressInfo.cs | 87 +++++++++++++++++++++++ osu.Game/osu.Game.csproj | 1 + 3 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 osu.Game/Screens/Play/SongProgressInfo.cs diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index ed57dad644..db81d22844 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -28,6 +28,7 @@ namespace osu.Game.Screens.Play private readonly SongProgressBar bar; private readonly SongProgressGraph graph; + private readonly SongProgressInfo info; public Action OnSeek; @@ -62,6 +63,14 @@ namespace osu.Game.Screens.Play Children = new Drawable[] { + info = new SongProgressInfo + { + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Y = -(bottom_bar_height + graph_height), + }, graph = new SongProgressGraph { RelativeSizeAxes = Axes.X, @@ -130,10 +139,15 @@ namespace osu.Game.Screens.Play if (objects == null) return; - double progress = ((AudioClock?.CurrentTime ?? Time.Current) - firstHitTime) / lastHitTime; + double currentTime = (AudioClock?.CurrentTime ?? Time.Current); + double progress = (currentTime - firstHitTime) / lastHitTime; bar.UpdatePosition((float)progress); graph.Progress = (int)(graph.ColumnCount * progress); + + info.TimeCurrent = TimeSpan.FromMilliseconds(currentTime).ToString(@"m\:ss"); + info.TimeLeft = TimeSpan.FromMilliseconds(lastHitTime - currentTime).ToString(@"m\:ss"); + info.Progress = ((int)(currentTime / lastHitTime * 100)).ToString(); } } } diff --git a/osu.Game/Screens/Play/SongProgressInfo.cs b/osu.Game/Screens/Play/SongProgressInfo.cs new file mode 100644 index 0000000000..7f32c18957 --- /dev/null +++ b/osu.Game/Screens/Play/SongProgressInfo.cs @@ -0,0 +1,87 @@ +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Primitives; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; + +namespace osu.Game.Screens.Play +{ + public class SongProgressInfo : Container + { + private InfoText timeCurrent; + private InfoText timeLeft; + private InfoText progress; + + private const int margin = 10; + + public string TimeCurrent + { + set + { + timeCurrent.Text = value; + } + } + + public string TimeLeft + { + set + { + timeLeft.Text = @"-" + value; + } + } + public string Progress + { + set + { + progress.Text = value + @"%"; + } + } + + public SongProgressInfo() + { + Children = new Drawable[] + { + timeCurrent = new InfoText + { + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, + Margin = new MarginPadding + { + Left = margin, + }, + }, + progress = new InfoText + { + Origin = Anchor.BottomCentre, + Anchor = Anchor.BottomCentre, + }, + timeLeft = new InfoText + { + Origin = Anchor.BottomRight, + Anchor = Anchor.BottomRight, + Margin = new MarginPadding + { + Right = margin, + } + } + }; + } + + private class InfoText : OsuSpriteText + { + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + Colour = colours.BlueLighter; + Font = @"Venera"; + EdgeEffect = new EdgeEffect + { + Colour = colours.BlueDarker, + Type = EdgeEffectType.Glow, + Radius = 5, + }; + } + } + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index cb491055c4..6d7a1c43cd 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -224,6 +224,7 @@ + From c27909d53c0bb6b5d611b89670bd93e33333204c Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Fri, 28 Apr 2017 05:02:25 +0300 Subject: [PATCH 003/329] CI fixes --- osu.Game/Screens/Play/SongProgress.cs | 2 +- osu.Game/Screens/Play/SongProgressInfo.cs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index db81d22844..4fdc4710ac 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -139,7 +139,7 @@ namespace osu.Game.Screens.Play if (objects == null) return; - double currentTime = (AudioClock?.CurrentTime ?? Time.Current); + double currentTime = AudioClock?.CurrentTime ?? Time.Current; double progress = (currentTime - firstHitTime) / lastHitTime; bar.UpdatePosition((float)progress); diff --git a/osu.Game/Screens/Play/SongProgressInfo.cs b/osu.Game/Screens/Play/SongProgressInfo.cs index 7f32c18957..127a87f3bf 100644 --- a/osu.Game/Screens/Play/SongProgressInfo.cs +++ b/osu.Game/Screens/Play/SongProgressInfo.cs @@ -1,4 +1,7 @@ -using osu.Framework.Allocation; +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; From c4bd21914d3a4908933ece0f7458af2378a77e31 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Fri, 28 Apr 2017 15:37:22 +0300 Subject: [PATCH 004/329] warning fixes --- osu.Game/Screens/Play/SongProgressInfo.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Play/SongProgressInfo.cs b/osu.Game/Screens/Play/SongProgressInfo.cs index 127a87f3bf..fa179d05c1 100644 --- a/osu.Game/Screens/Play/SongProgressInfo.cs +++ b/osu.Game/Screens/Play/SongProgressInfo.cs @@ -12,9 +12,9 @@ namespace osu.Game.Screens.Play { public class SongProgressInfo : Container { - private InfoText timeCurrent; - private InfoText timeLeft; - private InfoText progress; + private readonly InfoText timeCurrent; + private readonly InfoText timeLeft; + private readonly InfoText progress; private const int margin = 10; From f8faea8da28644b5d10c27a06304acfc4b1ffc72 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Fri, 28 Apr 2017 16:02:00 +0300 Subject: [PATCH 005/329] Removed unnecessary nested class --- osu.Game/Screens/Play/SongProgressInfo.cs | 37 +++++++++-------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/osu.Game/Screens/Play/SongProgressInfo.cs b/osu.Game/Screens/Play/SongProgressInfo.cs index fa179d05c1..1a36f1bd42 100644 --- a/osu.Game/Screens/Play/SongProgressInfo.cs +++ b/osu.Game/Screens/Play/SongProgressInfo.cs @@ -12,9 +12,9 @@ namespace osu.Game.Screens.Play { public class SongProgressInfo : Container { - private readonly InfoText timeCurrent; - private readonly InfoText timeLeft; - private readonly InfoText progress; + private OsuSpriteText timeCurrent; + private OsuSpriteText timeLeft; + private OsuSpriteText progress; private const int margin = 10; @@ -41,28 +41,35 @@ namespace osu.Game.Screens.Play } } - public SongProgressInfo() + [BackgroundDependencyLoader] + private void load(OsuColour colours) { Children = new Drawable[] { - timeCurrent = new InfoText + timeCurrent = new OsuSpriteText { Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, + Colour = colours.BlueLighter, + Font = @"Venera", Margin = new MarginPadding { Left = margin, }, }, - progress = new InfoText + progress = new OsuSpriteText { Origin = Anchor.BottomCentre, Anchor = Anchor.BottomCentre, + Colour = colours.BlueLighter, + Font = @"Venera", }, - timeLeft = new InfoText + timeLeft = new OsuSpriteText { Origin = Anchor.BottomRight, Anchor = Anchor.BottomRight, + Colour = colours.BlueLighter, + Font = @"Venera", Margin = new MarginPadding { Right = margin, @@ -70,21 +77,5 @@ namespace osu.Game.Screens.Play } }; } - - private class InfoText : OsuSpriteText - { - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - Colour = colours.BlueLighter; - Font = @"Venera"; - EdgeEffect = new EdgeEffect - { - Colour = colours.BlueDarker, - Type = EdgeEffectType.Glow, - Radius = 5, - }; - } - } } } From 698ae0832f86037150f1987272360464ce2203d9 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Mon, 1 May 2017 07:00:44 +0300 Subject: [PATCH 006/329] Move string formatting inside the class --- osu.Game/Screens/Play/SongProgress.cs | 6 +++--- osu.Game/Screens/Play/SongProgressInfo.cs | 26 ++++------------------- 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 4fdc4710ac..35aeb33528 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -145,9 +145,9 @@ namespace osu.Game.Screens.Play bar.UpdatePosition((float)progress); graph.Progress = (int)(graph.ColumnCount * progress); - info.TimeCurrent = TimeSpan.FromMilliseconds(currentTime).ToString(@"m\:ss"); - info.TimeLeft = TimeSpan.FromMilliseconds(lastHitTime - currentTime).ToString(@"m\:ss"); - info.Progress = ((int)(currentTime / lastHitTime * 100)).ToString(); + info.TimeCurrent = currentTime; + info.TimeLeft = lastHitTime - currentTime; + info.Progress = (int)(currentTime / lastHitTime * 100); } } } diff --git a/osu.Game/Screens/Play/SongProgressInfo.cs b/osu.Game/Screens/Play/SongProgressInfo.cs index 1a36f1bd42..ffee4e4094 100644 --- a/osu.Game/Screens/Play/SongProgressInfo.cs +++ b/osu.Game/Screens/Play/SongProgressInfo.cs @@ -7,6 +7,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using System; namespace osu.Game.Screens.Play { @@ -18,28 +19,9 @@ namespace osu.Game.Screens.Play private const int margin = 10; - public string TimeCurrent - { - set - { - timeCurrent.Text = value; - } - } - - public string TimeLeft - { - set - { - timeLeft.Text = @"-" + value; - } - } - public string Progress - { - set - { - progress.Text = value + @"%"; - } - } + public double TimeCurrent { set { timeCurrent.Text = TimeSpan.FromMilliseconds(value).ToString(@"m\:ss"); } } + public double TimeLeft { set { timeLeft.Text = @"- " + TimeSpan.FromMilliseconds(value).ToString(@"m\:ss"); } } + public int Progress { set { progress.Text = value.ToString() + @"%"; } } [BackgroundDependencyLoader] private void load(OsuColour colours) From 4aea18b673a752afe24b83be4e3d2560010c2ef2 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 1 May 2017 17:00:41 +0900 Subject: [PATCH 007/329] Add initial column design. --- .../Tests/TestCaseManiaPlayfield.cs | 217 ++++++++++++++++++ .../osu.Desktop.VisualTests.csproj | 1 + 2 files changed, 218 insertions(+) create mode 100644 osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs new file mode 100644 index 0000000000..5932d0d7eb --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs @@ -0,0 +1,217 @@ +// 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 osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Colour; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using osu.Framework.Testing; +using osu.Game.Graphics; +using osu.Framework.Graphics.Primitives; + +namespace osu.Desktop.VisualTests.Tests +{ + internal class TestCaseManiaPlayfield : TestCase + { + public override string Description => @"Mania playfield"; + + public override void Reset() + { + base.Reset(); + + Add(new Column + { + AccentColour = new Color4(187, 17, 119, 255) + }); + } + } + + public class Column : Container, IHasAccentColour + { + private const float key_size = 50; + + private const float key_icon_size = 10; + private const float key_icon_corner_radius = 3; + private const float key_icon_border_radius = 2; + + private const float hit_target_height = 10; + private const float hit_target_bar_height = 2; + + private const float column_width = 45; + private const float special_column_width = 70; + + private Color4 accentColour; + public Color4 AccentColour + { + get { return accentColour; } + set + { + if (accentColour == value) + return; + accentColour = value; + + setAccentColour(); + } + } + + private bool isSpecialColumn; + public bool IsSpecialColumn + { + get { return isSpecialColumn; } + set + { + isSpecialColumn = value; + Width = isSpecialColumn ? special_column_width : column_width; + } + } + + private Box foreground; + private Container hitTargetBar; + private Container keyIcon; + + public Column() + { + RelativeSizeAxes = Axes.Y; + Width = column_width; + + Children = new Drawable[] + { + new Box + { + Name = "Background", + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black, + }, + new Container + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Left = 1, Right = 1 }, + Children = new[] + { + foreground = new Box + { + Name = "Foreground", + RelativeSizeAxes = Axes.Both, + Alpha = 0.2f + }, + } + }, + new FillFlowContainer + { + Name = "Key + hit target", + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Children = new[] + { + new Container + { + Name = "Key", + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + RelativeSizeAxes = Axes.X, + Height = key_size, + Children = new Drawable[] + { + new Box + { + Name = "Key gradient", + RelativeSizeAxes = Axes.Both, + ColourInfo = ColourInfo.GradientVertical(Color4.Black, Color4.Black.Opacity(0)), + Alpha = 0.5f + }, + new Box + { + Name = "Key down foreground", + Alpha = 0f, + }, + keyIcon = new Container + { + Name = "Key icon", + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(key_icon_size), + Masking = true, + CornerRadius = key_icon_corner_radius, + BorderThickness = 2, + BorderColour = Color4.White, // Not true + Children = new[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Alpha = 0, + AlwaysPresent = true + } + } + } + } + }, + new Container + { + Name = "Hit target", + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + RelativeSizeAxes = Axes.X, + Height = hit_target_height, + Children = new Drawable[] + { + new Box + { + Name = "Background", + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black + }, + hitTargetBar = new Container + { + Name = "Bar", + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + RelativeSizeAxes = Axes.X, + Height = hit_target_bar_height, + Masking = true, + Children = new[] + { + new Box + { + RelativeSizeAxes = Axes.Both + } + } + } + } + } + } + } + }; + } + + private void setAccentColour() + { + foreground.Colour = AccentColour; + + hitTargetBar.EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Glow, + Radius = 5, + Colour = AccentColour.Opacity(0.5f), + }; + + keyIcon.EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Glow, + Radius = 5, + Colour = AccentColour.Opacity(0.5f), + }; + } + } +} diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index 135e4596c7..6a5d082aa3 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -190,6 +190,7 @@ + From 82cbb63af5dfab171f96f721ec08e4501f01a8f9 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 1 May 2017 17:24:35 +0900 Subject: [PATCH 008/329] Add column generation + put spacing one level up. --- .../Tests/TestCaseManiaPlayfield.cs | 73 ++++++++++++++----- 1 file changed, 54 insertions(+), 19 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs index 5932d0d7eb..65978a030c 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs @@ -23,14 +23,63 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Mania playfield"; + private FlowContainer columns; + public override void Reset() { base.Reset(); - Add(new Column + Add(new Container { - AccentColour = new Color4(187, 17, 119, 255) + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Y, + AutoSizeAxes = Axes.X, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black + }, + columns = new FillFlowContainer + { + RelativeSizeAxes = Axes.Y, + AutoSizeAxes = Axes.X, + Direction = FillDirection.Horizontal, + Padding = new MarginPadding { Left = 1, Right = 1 }, + Spacing = new Vector2(1, 0) + } + } }); + + var colours = new Color4[] + { + new Color4(187, 17, 119, 255), + new Color4(96, 204, 0, 255), + new Color4(17, 136, 170, 255) + }; + + int num_columns = 7; + int half_columns = num_columns / 2; + + for (int i = 0; i < num_columns; i++) + columns.Add(new Column()); + + for (int i = 0; i < half_columns; i++) + { + Color4 accent = colours[i % 2]; + columns.Children.ElementAt(i).AccentColour = accent; + columns.Children.ElementAt(num_columns - 1 - i).AccentColour = accent; + } + + bool hasSpecial = half_columns * 2 < num_columns; + if (hasSpecial) + { + Column specialColumn = columns.Children.ElementAt(half_columns); + specialColumn.IsSpecialColumn = true; + specialColumn.AccentColour = colours[2]; + } } } @@ -84,25 +133,11 @@ namespace osu.Desktop.VisualTests.Tests Children = new Drawable[] { - new Box + foreground = new Box { - Name = "Background", + Name = "Foreground", RelativeSizeAxes = Axes.Both, - Colour = Color4.Black, - }, - new Container - { - RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding { Left = 1, Right = 1 }, - Children = new[] - { - foreground = new Box - { - Name = "Foreground", - RelativeSizeAxes = Axes.Both, - Alpha = 0.2f - }, - } + Alpha = 0.2f }, new FillFlowContainer { From 80ebd04e856487b3c3bdb5e71be5631ab3979165 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 1 May 2017 20:48:43 +0900 Subject: [PATCH 009/329] Add keys to columns and add key down transformations. --- .../Tests/TestCaseManiaPlayfield.cs | 46 +++++++++++++++---- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs index 65978a030c..9ee09883aa 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs @@ -16,6 +16,8 @@ using System.Threading.Tasks; using osu.Framework.Testing; using osu.Game.Graphics; using osu.Framework.Graphics.Primitives; +using osu.Framework.Input; +using OpenTK.Input; namespace osu.Desktop.VisualTests.Tests { @@ -60,11 +62,18 @@ namespace osu.Desktop.VisualTests.Tests new Color4(17, 136, 170, 255) }; + var keys = new Key[] { Key.S, Key.D, Key.F, Key.Space, Key.J, Key.K, Key.L }; + int num_columns = 7; int half_columns = num_columns / 2; for (int i = 0; i < num_columns; i++) - columns.Add(new Column()); + { + columns.Add(new Column + { + Key = keys[i] + }); + } for (int i = 0; i < half_columns; i++) { @@ -122,7 +131,9 @@ namespace osu.Desktop.VisualTests.Tests } } - private Box foreground; + public Key Key; + + private Box background; private Container hitTargetBar; private Container keyIcon; @@ -133,7 +144,7 @@ namespace osu.Desktop.VisualTests.Tests Children = new Drawable[] { - foreground = new Box + background = new Box { Name = "Foreground", RelativeSizeAxes = Axes.Both, @@ -165,11 +176,6 @@ namespace osu.Desktop.VisualTests.Tests ColourInfo = ColourInfo.GradientVertical(Color4.Black, Color4.Black.Opacity(0)), Alpha = 0.5f }, - new Box - { - Name = "Key down foreground", - Alpha = 0f, - }, keyIcon = new Container { Name = "Key icon", @@ -232,7 +238,7 @@ namespace osu.Desktop.VisualTests.Tests private void setAccentColour() { - foreground.Colour = AccentColour; + background.Colour = AccentColour; hitTargetBar.EdgeEffect = new EdgeEffect { @@ -248,5 +254,27 @@ namespace osu.Desktop.VisualTests.Tests Colour = AccentColour.Opacity(0.5f), }; } + + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + if (args.Key == Key && !args.Repeat) + { + background.FadeTo(background.Alpha + 0.2f, 50, EasingTypes.OutQuint); + keyIcon.ScaleTo(1.4f, 50, EasingTypes.OutQuint); + } + + return false; + } + + protected override bool OnKeyUp(InputState state, KeyUpEventArgs args) + { + if (args.Key == Key) + { + background.FadeTo(0.2f, 800, EasingTypes.OutQuart); + keyIcon.ScaleTo(1f, 400, EasingTypes.OutQuart); + } + + return false; + } } } From e856abe59ae9b2e9165ccf2793c3f8304a20c3cf Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 2 May 2017 13:02:14 +0900 Subject: [PATCH 010/329] Let's not use Country for drawings-specific stuff... --- .../Tests/TestCaseDrawings.cs | 21 +++++++++---------- osu.Game/Screens/Tournament/Drawings.cs | 10 ++++----- osu.Game/Screens/Tournament/Group.cs | 10 ++++----- osu.Game/Screens/Tournament/GroupContainer.cs | 4 ++-- .../Tournament/ScrollingTeamContainer.cs | 20 +++++++++--------- .../Screens/Tournament/Teams/ITeamList.cs | 3 +-- .../Tournament/Teams/StorageBackedTeamList.cs | 9 ++++---- osu.Game/Screens/Tournament/Teams/Team.cs | 15 +++++++++++++ osu.Game/Users/Country.cs | 5 ----- osu.Game/Users/Team.cs | 2 +- osu.Game/osu.Game.csproj | 1 + 11 files changed, 54 insertions(+), 46 deletions(-) create mode 100644 osu.Game/Screens/Tournament/Teams/Team.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDrawings.cs b/osu.Desktop.VisualTests/Tests/TestCaseDrawings.cs index a0463516de..c4771a2913 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDrawings.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDrawings.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using osu.Framework.Testing; using osu.Game.Screens.Tournament; using osu.Game.Screens.Tournament.Teams; -using osu.Game.Users; namespace osu.Desktop.VisualTests.Tests { @@ -25,57 +24,57 @@ namespace osu.Desktop.VisualTests.Tests private class TestTeamList : ITeamList { - public IEnumerable Teams { get; } = new[] + public IEnumerable Teams { get; } = new[] { - new Country + new Team { FlagName = "GB", FullName = "United Kingdom", Acronym = "UK" }, - new Country + new Team { FlagName = "FR", FullName = "France", Acronym = "FRA" }, - new Country + new Team { FlagName = "CN", FullName = "China", Acronym = "CHN" }, - new Country + new Team { FlagName = "AU", FullName = "Australia", Acronym = "AUS" }, - new Country + new Team { FlagName = "JP", FullName = "Japan", Acronym = "JPN" }, - new Country + new Team { FlagName = "RO", FullName = "Romania", Acronym = "ROM" }, - new Country + new Team { FlagName = "IT", FullName = "Italy", Acronym = "PIZZA" }, - new Country + new Team { FlagName = "VE", FullName = "Venezuela", Acronym = "VNZ" }, - new Country + new Team { FlagName = "US", FullName = "United States of America", diff --git a/osu.Game/Screens/Tournament/Drawings.cs b/osu.Game/Screens/Tournament/Drawings.cs index 9798b4e479..263319d4e5 100644 --- a/osu.Game/Screens/Tournament/Drawings.cs +++ b/osu.Game/Screens/Tournament/Drawings.cs @@ -21,7 +21,7 @@ using osu.Game.Screens.Tournament.Components; using osu.Game.Screens.Tournament.Teams; using OpenTK; using OpenTK.Graphics; -using osu.Game.Users; +using osu.Framework.IO.Stores; namespace osu.Game.Screens.Tournament { @@ -37,7 +37,7 @@ namespace osu.Game.Screens.Tournament private GroupContainer groupsContainer; private OsuSpriteText fullTeamNameText; - private readonly List allTeams = new List(); + private readonly List allTeams = new List(); private DrawingsConfigManager drawingsConfig; @@ -239,7 +239,7 @@ namespace osu.Game.Screens.Tournament reset(true); } - private void onTeamSelected(Country team) + private void onTeamSelected(Team team) { groupsContainer.AddTeam(team); @@ -276,7 +276,7 @@ namespace osu.Game.Screens.Tournament teamsContainer.ClearTeams(); allTeams.Clear(); - foreach (Country t in TeamList.Teams) + foreach (Team t in TeamList.Teams) { if (groupsContainer.ContainsTeam(t.FullName)) continue; @@ -312,7 +312,7 @@ namespace osu.Game.Screens.Tournament if (line.ToUpper().StartsWith("GROUP")) continue; - Country teamToAdd = allTeams.FirstOrDefault(t => t.FullName == line); + Team teamToAdd = allTeams.FirstOrDefault(t => t.FullName == line); if (teamToAdd == null) continue; diff --git a/osu.Game/Screens/Tournament/Group.cs b/osu.Game/Screens/Tournament/Group.cs index 6847c97be8..697ae17e95 100644 --- a/osu.Game/Screens/Tournament/Group.cs +++ b/osu.Game/Screens/Tournament/Group.cs @@ -13,7 +13,7 @@ using osu.Framework.Graphics.Textures; using osu.Game.Graphics.Sprites; using OpenTK; using OpenTK.Graphics; -using osu.Game.Users; +using osu.Game.Screens.Tournament.Teams; namespace osu.Game.Screens.Tournament { @@ -73,7 +73,7 @@ namespace osu.Game.Screens.Tournament }; } - public void AddTeam(Country team) + public void AddTeam(Team team) { GroupTeam gt = new GroupTeam(team); @@ -91,7 +91,7 @@ namespace osu.Game.Screens.Tournament return allTeams.Any(t => t.Team.FullName == fullName); } - public bool RemoveTeam(Country team) + public bool RemoveTeam(Team team) { allTeams.RemoveAll(gt => gt.Team == team); @@ -122,12 +122,12 @@ namespace osu.Game.Screens.Tournament private class GroupTeam : Container { - public readonly Country Team; + public readonly Team Team; private readonly FillFlowContainer innerContainer; private readonly Sprite flagSprite; - public GroupTeam(Country team) + public GroupTeam(Team team) { Team = team; diff --git a/osu.Game/Screens/Tournament/GroupContainer.cs b/osu.Game/Screens/Tournament/GroupContainer.cs index a3c53f2076..bc4c3b71c3 100644 --- a/osu.Game/Screens/Tournament/GroupContainer.cs +++ b/osu.Game/Screens/Tournament/GroupContainer.cs @@ -8,7 +8,7 @@ using System.Text; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using OpenTK; -using osu.Game.Users; +using osu.Game.Screens.Tournament.Teams; namespace osu.Game.Screens.Tournament { @@ -64,7 +64,7 @@ namespace osu.Game.Screens.Tournament } } - public void AddTeam(Country team) + public void AddTeam(Team team) { if (groups[currentGroup].TeamsCount == maxTeams) return; diff --git a/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs b/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs index 5783893b3d..4ae26d3a67 100644 --- a/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs +++ b/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs @@ -15,16 +15,16 @@ using osu.Framework.Graphics.Transforms; using osu.Framework.Threading; using OpenTK; using OpenTK.Graphics; -using osu.Game.Users; +using osu.Game.Screens.Tournament.Teams; namespace osu.Game.Screens.Tournament { public class ScrollingTeamContainer : Container { public event Action OnScrollStarted; - public event Action OnSelected; + public event Action OnSelected; - private readonly List availableTeams = new List(); + private readonly List availableTeams = new List(); private readonly Container tracker; @@ -158,7 +158,7 @@ namespace osu.Game.Screens.Tournament } } - public void AddTeam(Country team) + public void AddTeam(Team team) { if (availableTeams.Contains(team)) return; @@ -169,12 +169,12 @@ namespace osu.Game.Screens.Tournament scrollState = ScrollState.Idle; } - public void AddTeams(IEnumerable teams) + public void AddTeams(IEnumerable teams) { if (teams == null) return; - foreach (Country t in teams) + foreach (Team t in teams) AddTeam(t); } @@ -185,7 +185,7 @@ namespace osu.Game.Screens.Tournament scrollState = ScrollState.Idle; } - public void RemoveTeam(Country team) + public void RemoveTeam(Team team) { availableTeams.Remove(team); @@ -270,7 +270,7 @@ namespace osu.Game.Screens.Tournament private void addFlags() { - foreach (Country t in availableTeams) + foreach (Team t in availableTeams) { Add(new ScrollingTeam(t) { @@ -320,7 +320,7 @@ namespace osu.Game.Screens.Tournament public const float WIDTH = 58; public const float HEIGHT = 41; - public Country Team; + public Team Team; private readonly Sprite flagSprite; private readonly Box outline; @@ -340,7 +340,7 @@ namespace osu.Game.Screens.Tournament } } - public ScrollingTeam(Country team) + public ScrollingTeam(Team team) { Team = team; diff --git a/osu.Game/Screens/Tournament/Teams/ITeamList.cs b/osu.Game/Screens/Tournament/Teams/ITeamList.cs index d4b644e2aa..a4476b64c6 100644 --- a/osu.Game/Screens/Tournament/Teams/ITeamList.cs +++ b/osu.Game/Screens/Tournament/Teams/ITeamList.cs @@ -2,12 +2,11 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Collections.Generic; -using osu.Game.Users; namespace osu.Game.Screens.Tournament.Teams { public interface ITeamList { - IEnumerable Teams { get; } + IEnumerable Teams { get; } } } diff --git a/osu.Game/Screens/Tournament/Teams/StorageBackedTeamList.cs b/osu.Game/Screens/Tournament/Teams/StorageBackedTeamList.cs index 7dd333cdbc..3bca7f2937 100644 --- a/osu.Game/Screens/Tournament/Teams/StorageBackedTeamList.cs +++ b/osu.Game/Screens/Tournament/Teams/StorageBackedTeamList.cs @@ -6,7 +6,6 @@ using System.Collections.Generic; using System.IO; using osu.Framework.Logging; using osu.Framework.Platform; -using osu.Game.Users; namespace osu.Game.Screens.Tournament.Teams { @@ -21,16 +20,16 @@ namespace osu.Game.Screens.Tournament.Teams this.storage = storage; } - public IEnumerable Teams + public IEnumerable Teams { get { - var teams = new List(); + var teams = new List(); try { using (Stream stream = storage.GetStream(teams_filename, FileAccess.Read, FileMode.Open)) - using (StreamReader sr = new StreamReader(stream)) + using (var sr = new StreamReader(stream)) { while (sr.Peek() != -1) { @@ -53,7 +52,7 @@ namespace osu.Game.Screens.Tournament.Teams string acronym = split.Length >= 3 ? split[2].Trim() : teamName; acronym = acronym.Substring(0, Math.Min(3, acronym.Length)); - teams.Add(new Country + teams.Add(new Team { FlagName = flagName, FullName = teamName, diff --git a/osu.Game/Screens/Tournament/Teams/Team.cs b/osu.Game/Screens/Tournament/Teams/Team.cs new file mode 100644 index 0000000000..8da5cfa69e --- /dev/null +++ b/osu.Game/Screens/Tournament/Teams/Team.cs @@ -0,0 +1,15 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Users; + +namespace osu.Game.Screens.Tournament.Teams +{ + public class Team : Country + { + /// + /// Short acronym which appears in the group boxes post-selection. + /// + public string Acronym; + } +} diff --git a/osu.Game/Users/Country.cs b/osu.Game/Users/Country.cs index 729629bdb8..ac95d22329 100644 --- a/osu.Game/Users/Country.cs +++ b/osu.Game/Users/Country.cs @@ -18,11 +18,6 @@ namespace osu.Game.Users [JsonProperty(@"name")] public string FullName; - /// - /// Short acronym which appears in the group boxes post-selection. - /// - public string Acronym; - /// /// Two-letter flag acronym (ISO 3166 standard) /// diff --git a/osu.Game/Users/Team.cs b/osu.Game/Users/Team.cs index 7d5c0322fe..fe94f26931 100644 --- a/osu.Game/Users/Team.cs +++ b/osu.Game/Users/Team.cs @@ -3,7 +3,7 @@ namespace osu.Game.Users { - public class Team + public class Team : Country { public string Name; } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 2a1195135a..0c41ec91bb 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -325,6 +325,7 @@ + From f17046abaf3e72ccd2d04cb066eceb951c4203f3 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 2 May 2017 13:23:09 +0900 Subject: [PATCH 011/329] Add ability to load Drawings flags from osu/Drawings/Flags. --- osu-framework | 2 +- osu.Game/Screens/Tournament/Drawings.cs | 10 ++++++++-- osu.Game/Screens/Tournament/Group.cs | 14 +++++++++----- osu.Game/Screens/Tournament/GroupContainer.cs | 9 +++++++-- .../Tournament/ScrollingTeamContainer.cs | 18 +++++++++++++----- 5 files changed, 38 insertions(+), 15 deletions(-) diff --git a/osu-framework b/osu-framework index b25ed4291b..a093c6cb70 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit b25ed4291bb8a8a38faf404c68b3f97efc9d3413 +Subproject commit a093c6cb70c145168ac359193e72176bf00ee20a diff --git a/osu.Game/Screens/Tournament/Drawings.cs b/osu.Game/Screens/Tournament/Drawings.cs index 263319d4e5..4ef3face07 100644 --- a/osu.Game/Screens/Tournament/Drawings.cs +++ b/osu.Game/Screens/Tournament/Drawings.cs @@ -52,6 +52,12 @@ namespace osu.Game.Screens.Tournament { this.storage = storage; + // Todo: The way this is done is a haaaaaaaaaaaaaaack. + // Currently this store is being passed down all the way to ScrollingTeam/GroupTeam + // but it should replace the TextureStore DI item instead. This is pending some significant DI improvements. + TextureStore flagStore = new TextureStore(new RawTextureLoaderStore(new NamespacedResourceStore(new StorageBackedResourceStore(storage), "Drawings"))); + flagStore.AddStore(textures); + if (TeamList == null) TeamList = new StorageBackedTeamList(storage); @@ -104,7 +110,7 @@ namespace osu.Game.Screens.Tournament Lines = 6 }, // Groups - groupsContainer = new GroupContainer(drawingsConfig.Get(DrawingsConfig.Groups), drawingsConfig.Get(DrawingsConfig.TeamsPerGroup)) + groupsContainer = new GroupContainer(drawingsConfig.Get(DrawingsConfig.Groups), drawingsConfig.Get(DrawingsConfig.TeamsPerGroup), flagStore) { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, @@ -119,7 +125,7 @@ namespace osu.Game.Screens.Tournament } }, // Scrolling teams - teamsContainer = new ScrollingTeamContainer + teamsContainer = new ScrollingTeamContainer(flagStore) { Anchor = Anchor.Centre, Origin = Anchor.Centre, diff --git a/osu.Game/Screens/Tournament/Group.cs b/osu.Game/Screens/Tournament/Group.cs index 697ae17e95..36b8b29e26 100644 --- a/osu.Game/Screens/Tournament/Group.cs +++ b/osu.Game/Screens/Tournament/Group.cs @@ -73,9 +73,9 @@ namespace osu.Game.Screens.Tournament }; } - public void AddTeam(Team team) + public void AddTeam(Team team, TextureStore flagStore) { - GroupTeam gt = new GroupTeam(team); + GroupTeam gt = new GroupTeam(team, flagStore); if (TeamsCount < 8) { @@ -127,8 +127,12 @@ namespace osu.Game.Screens.Tournament private readonly FillFlowContainer innerContainer; private readonly Sprite flagSprite; - public GroupTeam(Team team) + private readonly TextureStore flagStore; + + public GroupTeam(Team team, TextureStore flagStore) { + this.flagStore = flagStore; + Team = team; Width = 36; @@ -178,9 +182,9 @@ namespace osu.Game.Screens.Tournament } [BackgroundDependencyLoader] - private void load(TextureStore textures) + private void load() { - flagSprite.Texture = textures.Get($@"Flags/{Team.FlagName}"); + flagSprite.Texture = flagStore.Get($@"Flags/{Team.FlagName}"); } } } diff --git a/osu.Game/Screens/Tournament/GroupContainer.cs b/osu.Game/Screens/Tournament/GroupContainer.cs index bc4c3b71c3..e789c871b7 100644 --- a/osu.Game/Screens/Tournament/GroupContainer.cs +++ b/osu.Game/Screens/Tournament/GroupContainer.cs @@ -9,6 +9,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using OpenTK; using osu.Game.Screens.Tournament.Teams; +using osu.Framework.Graphics.Textures; namespace osu.Game.Screens.Tournament { @@ -19,8 +20,12 @@ namespace osu.Game.Screens.Tournament private readonly int maxTeams; private int currentGroup; - public GroupContainer(int numGroups, int teamsPerGroup) + private readonly TextureStore flagStore; + + public GroupContainer(int numGroups, int teamsPerGroup, TextureStore flagStore) { + this.flagStore = flagStore; + FlowContainer bottomGroups; FlowContainer topGroups; @@ -69,7 +74,7 @@ namespace osu.Game.Screens.Tournament if (groups[currentGroup].TeamsCount == maxTeams) return; - groups[currentGroup].AddTeam(team); + groups[currentGroup].AddTeam(team, flagStore); currentGroup = (currentGroup + 1) % groups.Count; } diff --git a/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs b/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs index 4ae26d3a67..d46edd48f1 100644 --- a/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs +++ b/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs @@ -39,8 +39,12 @@ namespace osu.Game.Screens.Tournament private ScheduledDelegate delayedStateChangeDelegate; - public ScrollingTeamContainer() + private TextureStore flagStore; + + public ScrollingTeamContainer(TextureStore flagStore) { + this.flagStore = flagStore; + AutoSizeAxes = Axes.Y; Children = new Drawable[] @@ -272,7 +276,7 @@ namespace osu.Game.Screens.Tournament { foreach (Team t in availableTeams) { - Add(new ScrollingTeam(t) + Add(new ScrollingTeam(t, flagStore) { X = leftPos + DrawWidth }); @@ -340,8 +344,12 @@ namespace osu.Game.Screens.Tournament } } - public ScrollingTeam(Team team) + private TextureStore flagStore; + + public ScrollingTeam(Team team, TextureStore flagStore) { + this.flagStore = flagStore; + Team = team; Anchor = Anchor.CentreLeft; @@ -371,9 +379,9 @@ namespace osu.Game.Screens.Tournament } [BackgroundDependencyLoader] - private void load(TextureStore textures) + private void load() { - flagSprite.Texture = textures.Get($@"Flags/{Team.FlagName}"); + flagSprite.Texture = flagStore.Get($@"Flags/{Team.FlagName}"); } } } From 91e000fd44d128d74a1d3ecd7ff1bd2fc9d228b2 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 2 May 2017 14:21:22 +0900 Subject: [PATCH 012/329] Back to sanity. --- osu-framework | 2 +- osu.Game/Screens/Tournament/Drawings.cs | 13 +++++++------ osu.Game/Screens/Tournament/Group.cs | 14 +++++--------- osu.Game/Screens/Tournament/GroupContainer.cs | 8 ++------ .../Tournament/ScrollingTeamContainer.cs | 18 +++++------------- 5 files changed, 20 insertions(+), 35 deletions(-) diff --git a/osu-framework b/osu-framework index a093c6cb70..cc69416da0 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit a093c6cb70c145168ac359193e72176bf00ee20a +Subproject commit cc69416da0e6b04c9a372ac821bfe201cec0d174 diff --git a/osu.Game/Screens/Tournament/Drawings.cs b/osu.Game/Screens/Tournament/Drawings.cs index 4ef3face07..da36e8b5c7 100644 --- a/osu.Game/Screens/Tournament/Drawings.cs +++ b/osu.Game/Screens/Tournament/Drawings.cs @@ -47,17 +47,18 @@ namespace osu.Game.Screens.Tournament public ITeamList TeamList; + protected override DependencyContainer CreateLocalDependencies(DependencyContainer parent) => new DependencyContainer(parent); + [BackgroundDependencyLoader] - private void load(TextureStore textures, Storage storage) + private void load(TextureStore textures, Storage storage, DependencyContainer dependencies) { this.storage = storage; - // Todo: The way this is done is a haaaaaaaaaaaaaaack. - // Currently this store is being passed down all the way to ScrollingTeam/GroupTeam - // but it should replace the TextureStore DI item instead. This is pending some significant DI improvements. TextureStore flagStore = new TextureStore(new RawTextureLoaderStore(new NamespacedResourceStore(new StorageBackedResourceStore(storage), "Drawings"))); flagStore.AddStore(textures); + dependencies.Cache(flagStore); + if (TeamList == null) TeamList = new StorageBackedTeamList(storage); @@ -110,7 +111,7 @@ namespace osu.Game.Screens.Tournament Lines = 6 }, // Groups - groupsContainer = new GroupContainer(drawingsConfig.Get(DrawingsConfig.Groups), drawingsConfig.Get(DrawingsConfig.TeamsPerGroup), flagStore) + groupsContainer = new GroupContainer(drawingsConfig.Get(DrawingsConfig.Groups), drawingsConfig.Get(DrawingsConfig.TeamsPerGroup)) { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, @@ -125,7 +126,7 @@ namespace osu.Game.Screens.Tournament } }, // Scrolling teams - teamsContainer = new ScrollingTeamContainer(flagStore) + teamsContainer = new ScrollingTeamContainer { Anchor = Anchor.Centre, Origin = Anchor.Centre, diff --git a/osu.Game/Screens/Tournament/Group.cs b/osu.Game/Screens/Tournament/Group.cs index 36b8b29e26..697ae17e95 100644 --- a/osu.Game/Screens/Tournament/Group.cs +++ b/osu.Game/Screens/Tournament/Group.cs @@ -73,9 +73,9 @@ namespace osu.Game.Screens.Tournament }; } - public void AddTeam(Team team, TextureStore flagStore) + public void AddTeam(Team team) { - GroupTeam gt = new GroupTeam(team, flagStore); + GroupTeam gt = new GroupTeam(team); if (TeamsCount < 8) { @@ -127,12 +127,8 @@ namespace osu.Game.Screens.Tournament private readonly FillFlowContainer innerContainer; private readonly Sprite flagSprite; - private readonly TextureStore flagStore; - - public GroupTeam(Team team, TextureStore flagStore) + public GroupTeam(Team team) { - this.flagStore = flagStore; - Team = team; Width = 36; @@ -182,9 +178,9 @@ namespace osu.Game.Screens.Tournament } [BackgroundDependencyLoader] - private void load() + private void load(TextureStore textures) { - flagSprite.Texture = flagStore.Get($@"Flags/{Team.FlagName}"); + flagSprite.Texture = textures.Get($@"Flags/{Team.FlagName}"); } } } diff --git a/osu.Game/Screens/Tournament/GroupContainer.cs b/osu.Game/Screens/Tournament/GroupContainer.cs index e789c871b7..52ae53e24f 100644 --- a/osu.Game/Screens/Tournament/GroupContainer.cs +++ b/osu.Game/Screens/Tournament/GroupContainer.cs @@ -20,12 +20,8 @@ namespace osu.Game.Screens.Tournament private readonly int maxTeams; private int currentGroup; - private readonly TextureStore flagStore; - - public GroupContainer(int numGroups, int teamsPerGroup, TextureStore flagStore) + public GroupContainer(int numGroups, int teamsPerGroup) { - this.flagStore = flagStore; - FlowContainer bottomGroups; FlowContainer topGroups; @@ -74,7 +70,7 @@ namespace osu.Game.Screens.Tournament if (groups[currentGroup].TeamsCount == maxTeams) return; - groups[currentGroup].AddTeam(team, flagStore); + groups[currentGroup].AddTeam(team); currentGroup = (currentGroup + 1) % groups.Count; } diff --git a/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs b/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs index d46edd48f1..4ae26d3a67 100644 --- a/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs +++ b/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs @@ -39,12 +39,8 @@ namespace osu.Game.Screens.Tournament private ScheduledDelegate delayedStateChangeDelegate; - private TextureStore flagStore; - - public ScrollingTeamContainer(TextureStore flagStore) + public ScrollingTeamContainer() { - this.flagStore = flagStore; - AutoSizeAxes = Axes.Y; Children = new Drawable[] @@ -276,7 +272,7 @@ namespace osu.Game.Screens.Tournament { foreach (Team t in availableTeams) { - Add(new ScrollingTeam(t, flagStore) + Add(new ScrollingTeam(t) { X = leftPos + DrawWidth }); @@ -344,12 +340,8 @@ namespace osu.Game.Screens.Tournament } } - private TextureStore flagStore; - - public ScrollingTeam(Team team, TextureStore flagStore) + public ScrollingTeam(Team team) { - this.flagStore = flagStore; - Team = team; Anchor = Anchor.CentreLeft; @@ -379,9 +371,9 @@ namespace osu.Game.Screens.Tournament } [BackgroundDependencyLoader] - private void load() + private void load(TextureStore textures) { - flagSprite.Texture = flagStore.Get($@"Flags/{Team.FlagName}"); + flagSprite.Texture = textures.Get($@"Flags/{Team.FlagName}"); } } } From beb98c14b6882e2b308395439398df4975ffdd80 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 2 May 2017 16:26:11 +0900 Subject: [PATCH 013/329] Fix layout not being invalidated when re-filtering playlist display. --- osu.Game/Overlays/Music/PlaylistList.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Music/PlaylistList.cs b/osu.Game/Overlays/Music/PlaylistList.cs index 418fcd41e8..5e2f81ccf9 100644 --- a/osu.Game/Overlays/Music/PlaylistList.cs +++ b/osu.Game/Overlays/Music/PlaylistList.cs @@ -73,7 +73,13 @@ namespace osu.Game.Overlays.Music private class ItemSearchContainer : FillFlowContainer, IHasFilterableChildren { public string[] FilterTerms => new string[] { }; - public bool MatchingCurrentFilter { set { } } + public bool MatchingCurrentFilter + { + set + { + InvalidateLayout(); + } + } public IEnumerable FilterableChildren => Children; From ee0a5409bbbf674a34836a9b9595669b2acb4607 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 2 May 2017 16:33:48 +0900 Subject: [PATCH 014/329] CI fixes. --- osu.Game/Screens/Tournament/GroupContainer.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Screens/Tournament/GroupContainer.cs b/osu.Game/Screens/Tournament/GroupContainer.cs index 52ae53e24f..bc4c3b71c3 100644 --- a/osu.Game/Screens/Tournament/GroupContainer.cs +++ b/osu.Game/Screens/Tournament/GroupContainer.cs @@ -9,7 +9,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using OpenTK; using osu.Game.Screens.Tournament.Teams; -using osu.Framework.Graphics.Textures; namespace osu.Game.Screens.Tournament { From f1d0b77d100eae3935b1000523c37021fb97f7fb Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 2 May 2017 16:40:29 +0900 Subject: [PATCH 015/329] Base the music controller transform direction on relative indices in playlist. --- osu.Game/Overlays/Music/PlaylistOverlay.cs | 2 +- osu.Game/Overlays/MusicController.cs | 26 +++++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Music/PlaylistOverlay.cs b/osu.Game/Overlays/Music/PlaylistOverlay.cs index 3865ed246f..92b8addd97 100644 --- a/osu.Game/Overlays/Music/PlaylistOverlay.cs +++ b/osu.Game/Overlays/Music/PlaylistOverlay.cs @@ -35,7 +35,7 @@ namespace osu.Game.Overlays.Music private readonly Bindable beatmapBacking = new Bindable(); - protected IEnumerable BeatmapSets; + public IEnumerable BeatmapSets; [BackgroundDependencyLoader] private void load(OsuGameBase game, BeatmapDatabase beatmaps, OsuColour colours) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index cf5a2fdee1..91d35db3bb 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -3,6 +3,7 @@ using System; using System.Diagnostics; +using System.Linq; using System.Threading.Tasks; using OpenTK; using OpenTK.Graphics; @@ -260,17 +261,36 @@ namespace osu.Game.Overlays } private WorkingBeatmap current; - private TransformDirection queuedDirection = TransformDirection.Next; + private TransformDirection? queuedDirection; private void beatmapChanged(WorkingBeatmap beatmap) { progressBar.IsEnabled = beatmap != null; bool audioEquals = beatmapBacking.Value?.BeatmapInfo?.AudioEquals(current?.BeatmapInfo) ?? false; + + TransformDirection direction; + + if (audioEquals) + direction = TransformDirection.None; + else if (queuedDirection.HasValue) + { + direction = queuedDirection.Value; + queuedDirection = null; + } + else + { + //figure out the best direction based on order in playlist. + var last = current == null ? -1 : playlist.BeatmapSets.TakeWhile(b => b.ID != current.BeatmapSetInfo.ID).Count(); + var next = beatmapBacking.Value == null ? -1 : playlist.BeatmapSets.TakeWhile(b => b.ID != beatmapBacking.Value.BeatmapSetInfo.ID).Count(); + + direction = last > next ? TransformDirection.Prev : TransformDirection.Next; + } + current = beatmapBacking.Value; - updateDisplay(beatmapBacking, audioEquals ? TransformDirection.None : queuedDirection); - queuedDirection = TransformDirection.Next; + updateDisplay(beatmapBacking, direction); + queuedDirection = null; } private ScheduledDelegate pendingBeatmapSwitch; From 46ae8bc86b8b9808ce93470a6ee89c8b86ce3443 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 2 May 2017 16:49:27 +0900 Subject: [PATCH 016/329] Use value because we need to. --- osu.Game/Overlays/Music/PlaylistList.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Music/PlaylistList.cs b/osu.Game/Overlays/Music/PlaylistList.cs index 5e2f81ccf9..c7909f1a63 100644 --- a/osu.Game/Overlays/Music/PlaylistList.cs +++ b/osu.Game/Overlays/Music/PlaylistList.cs @@ -77,7 +77,8 @@ namespace osu.Game.Overlays.Music { set { - InvalidateLayout(); + if (value) + InvalidateLayout(); } } From e2620e2840d33312be919b4be23d939f3f61737f Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 2 May 2017 16:54:43 +0900 Subject: [PATCH 017/329] Make Team not inherit Country. --- osu.Game/Screens/Tournament/Teams/Team.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Tournament/Teams/Team.cs b/osu.Game/Screens/Tournament/Teams/Team.cs index 8da5cfa69e..cfb35d58f2 100644 --- a/osu.Game/Screens/Tournament/Teams/Team.cs +++ b/osu.Game/Screens/Tournament/Teams/Team.cs @@ -5,11 +5,21 @@ using osu.Game.Users; namespace osu.Game.Screens.Tournament.Teams { - public class Team : Country + public class Team { + /// + /// The name of this team. + /// + public string FullName; + /// /// Short acronym which appears in the group boxes post-selection. /// public string Acronym; + + /// + /// Name of the file containing the flag. + /// + public string FlagName; } } From 40d2fee1dc1f2412d2f658c134e0ad33b1915320 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 2 May 2017 16:55:04 +0900 Subject: [PATCH 018/329] Split up adding of local store from the ctor. --- osu.Game/Screens/Tournament/Drawings.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Tournament/Drawings.cs b/osu.Game/Screens/Tournament/Drawings.cs index da36e8b5c7..ef32ce39cb 100644 --- a/osu.Game/Screens/Tournament/Drawings.cs +++ b/osu.Game/Screens/Tournament/Drawings.cs @@ -54,7 +54,10 @@ namespace osu.Game.Screens.Tournament { this.storage = storage; - TextureStore flagStore = new TextureStore(new RawTextureLoaderStore(new NamespacedResourceStore(new StorageBackedResourceStore(storage), "Drawings"))); + TextureStore flagStore = new TextureStore(); + // Local flag store + flagStore.AddStore(new RawTextureLoaderStore(new NamespacedResourceStore(new StorageBackedResourceStore(storage), "Drawings"))); + /// Default texture store flagStore.AddStore(textures); dependencies.Cache(flagStore); From 116e92a5423ce66a774f7a0b490ea3fd34594269 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 2 May 2017 17:00:30 +0900 Subject: [PATCH 019/329] Remove silly platform specific logic. --- osu.Game/Overlays/Options/Sections/AudioSection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Options/Sections/AudioSection.cs b/osu.Game/Overlays/Options/Sections/AudioSection.cs index 1412fdea34..3de2bb4901 100644 --- a/osu.Game/Overlays/Options/Sections/AudioSection.cs +++ b/osu.Game/Overlays/Options/Sections/AudioSection.cs @@ -17,7 +17,7 @@ namespace osu.Game.Overlays.Options.Sections { Children = new Drawable[] { - new AudioDevicesOptions { Alpha = RuntimeInfo.IsWindows ? 1 : 0 }, + new AudioDevicesOptions(), new VolumeOptions(), new OffsetOptions(), }; From 9ca82951499d5bba365e41af3c9543005b2ce741 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 2 May 2017 17:09:16 +0900 Subject: [PATCH 020/329] Oops. --- osu.Game/Screens/Tournament/Drawings.cs | 2 +- osu.Game/Screens/Tournament/Teams/Team.cs | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/osu.Game/Screens/Tournament/Drawings.cs b/osu.Game/Screens/Tournament/Drawings.cs index ef32ce39cb..924e7adac4 100644 --- a/osu.Game/Screens/Tournament/Drawings.cs +++ b/osu.Game/Screens/Tournament/Drawings.cs @@ -57,7 +57,7 @@ namespace osu.Game.Screens.Tournament TextureStore flagStore = new TextureStore(); // Local flag store flagStore.AddStore(new RawTextureLoaderStore(new NamespacedResourceStore(new StorageBackedResourceStore(storage), "Drawings"))); - /// Default texture store + // Default texture store flagStore.AddStore(textures); dependencies.Cache(flagStore); diff --git a/osu.Game/Screens/Tournament/Teams/Team.cs b/osu.Game/Screens/Tournament/Teams/Team.cs index cfb35d58f2..5ffee1fc37 100644 --- a/osu.Game/Screens/Tournament/Teams/Team.cs +++ b/osu.Game/Screens/Tournament/Teams/Team.cs @@ -1,8 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using osu.Game.Users; - namespace osu.Game.Screens.Tournament.Teams { public class Team From bef15fe6375025990123c1197fe51db8a487be6d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 2 May 2017 17:45:22 +0900 Subject: [PATCH 021/329] Improve organisation of some options and config code. --- osu.Game/Configuration/OsuConfigManager.cs | 69 ++++++++++--------- .../Options/Sections/Audio/MainMenuOptions.cs | 32 +++++++++ .../Overlays/Options/Sections/AudioSection.cs | 2 +- .../Sections/Graphics/MainMenuOptions.cs | 10 --- osu.Game/osu.Game.csproj | 1 + 5 files changed, 72 insertions(+), 42 deletions(-) create mode 100644 osu.Game/Overlays/Options/Sections/Audio/MainMenuOptions.cs diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 30cd31c113..91652e8ef4 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -12,42 +12,61 @@ namespace osu.Game.Configuration { protected override void InitialiseDefaults() { -#pragma warning disable CS0612 // Type or member is obsolete + // UI/selection defaults + + Set(OsuConfig.Ruleset, 0, 0, int.MaxValue); + Set(OsuConfig.BeatmapDetailTab, BeatmapDetailTab.Details); + + // Online settings Set(OsuConfig.Username, string.Empty); Set(OsuConfig.Token, string.Empty); - Set(OsuConfig.Ruleset, 0, 0, int.MaxValue); + Set(OsuConfig.SavePassword, false).ValueChanged += delegate + { + if (Get(OsuConfig.SavePassword)) Set(OsuConfig.SaveUsername, true); + }; + + Set(OsuConfig.SaveUsername, true).ValueChanged += delegate + { + if (!Get(OsuConfig.SaveUsername)) Set(OsuConfig.SavePassword, false); + }; + + // Audio Set(OsuConfig.AudioDevice, string.Empty); - Set(OsuConfig.SavePassword, false); - Set(OsuConfig.SaveUsername, true); - - Set(OsuConfig.MenuCursorSize, 1.0, 0.5f, 2); - Set(OsuConfig.GameplayCursorSize, 1.0, 0.5f, 2); - Set(OsuConfig.DimLevel, 0.3, 0, 1); - - Set(OsuConfig.MouseDisableButtons, false); - Set(OsuConfig.MouseDisableWheel, false); - - Set(OsuConfig.SnakingInSliders, true); - Set(OsuConfig.SnakingOutSliders, true); - - Set(OsuConfig.MenuParallax, true); Set(OsuConfig.MenuVoice, true); Set(OsuConfig.MenuMusic, true); - Set(OsuConfig.BeatmapDetailTab, BeatmapDetailTab.Details); + Set(OsuConfig.AudioOffset, 0, -500.0, 500.0); + + // Input + + Set(OsuConfig.MenuCursorSize, 1.0, 0.5f, 2); + Set(OsuConfig.GameplayCursorSize, 1.0, 0.5f, 2); + + Set(OsuConfig.MouseDisableButtons, false); + Set(OsuConfig.MouseDisableWheel, false); + + // Graphics + + Set(OsuConfig.MenuParallax, true); + + Set(OsuConfig.SnakingInSliders, true); + Set(OsuConfig.SnakingOutSliders, true); + + // Gameplay + + Set(OsuConfig.DimLevel, 0.3, 0, 1); Set(OsuConfig.ShowInterface, true); Set(OsuConfig.KeyOverlay, false); //todo: implement all settings below this line (remove the Disabled set when doing so). - Set(OsuConfig.AudioOffset, 0, -500.0, 500.0); Set(OsuConfig.MouseSpeed, 1.0).Disabled = true; - Set(OsuConfig.BeatmapDirectory, @"Songs").Disabled = true; // TODO: use thi.Disabled = trues + Set(OsuConfig.BeatmapDirectory, @"Songs").Disabled = true; Set(OsuConfig.AllowPublicInvites, true).Disabled = true; Set(OsuConfig.AutoChatHide, true).Disabled = true; Set(OsuConfig.AutomaticDownload, true).Disabled = true; @@ -166,18 +185,6 @@ namespace osu.Game.Configuration Set(OsuConfig.Ticker, false).Disabled = true; Set(OsuConfig.CompatibilityContext, false).Disabled = true; Set(OsuConfig.CanForceOptimusCompatibility, true).Disabled = true; - Set(OsuConfig.ConfineMouse, Get(OsuConfig.ConfineMouseToFullscreen) ? - ConfineMouseMode.Fullscreen : ConfineMouseMode.Never).Disabled = true; - - GetOriginalBindable(OsuConfig.SavePassword).ValueChanged += delegate - { - if (Get(OsuConfig.SavePassword)) Set(OsuConfig.SaveUsername, true); - }; - GetOriginalBindable(OsuConfig.SaveUsername).ValueChanged += delegate - { - if (!Get(OsuConfig.SaveUsername)) Set(OsuConfig.SavePassword, false); - }; -#pragma warning restore CS0612 // Type or member is obsolete } public OsuConfigManager(Storage storage) : base(storage) diff --git a/osu.Game/Overlays/Options/Sections/Audio/MainMenuOptions.cs b/osu.Game/Overlays/Options/Sections/Audio/MainMenuOptions.cs new file mode 100644 index 0000000000..9de74e1b02 --- /dev/null +++ b/osu.Game/Overlays/Options/Sections/Audio/MainMenuOptions.cs @@ -0,0 +1,32 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Allocation; +using osu.Game.Configuration; +using osu.Game.Graphics.UserInterface; + +namespace osu.Game.Overlays.Options.Sections.Audio +{ + public class MainMenuOptions : OptionsSubsection + { + protected override string Header => "Main Menu"; + + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) + { + Children = new[] + { + new OsuCheckbox + { + LabelText = "Interface voices", + Bindable = config.GetBindable(OsuConfig.MenuVoice) + }, + new OsuCheckbox + { + LabelText = "osu! music theme", + Bindable = config.GetBindable(OsuConfig.MenuMusic) + }, + }; + } + } +} \ No newline at end of file diff --git a/osu.Game/Overlays/Options/Sections/AudioSection.cs b/osu.Game/Overlays/Options/Sections/AudioSection.cs index 3de2bb4901..a9f8265a68 100644 --- a/osu.Game/Overlays/Options/Sections/AudioSection.cs +++ b/osu.Game/Overlays/Options/Sections/AudioSection.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 osu.Framework; using osu.Framework.Graphics; using osu.Game.Graphics; using osu.Game.Overlays.Options.Sections.Audio; @@ -20,6 +19,7 @@ namespace osu.Game.Overlays.Options.Sections new AudioDevicesOptions(), new VolumeOptions(), new OffsetOptions(), + new MainMenuOptions(), }; } } diff --git a/osu.Game/Overlays/Options/Sections/Graphics/MainMenuOptions.cs b/osu.Game/Overlays/Options/Sections/Graphics/MainMenuOptions.cs index c5000d8547..13683edb32 100644 --- a/osu.Game/Overlays/Options/Sections/Graphics/MainMenuOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Graphics/MainMenuOptions.cs @@ -31,16 +31,6 @@ namespace osu.Game.Overlays.Options.Sections.Graphics LabelText = "Menu tips", Bindable = config.GetBindable(OsuConfig.ShowMenuTips) }, - new OsuCheckbox - { - LabelText = "Interface voices", - Bindable = config.GetBindable(OsuConfig.MenuVoice) - }, - new OsuCheckbox - { - LabelText = "osu! music theme", - Bindable = config.GetBindable(OsuConfig.MenuMusic) - }, }; } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 2a1195135a..fb364ccdf5 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -78,6 +78,7 @@ + From 1b0f353af3fc400b11abaa21b7eb1c698c9bbd48 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 2 May 2017 17:45:42 +0900 Subject: [PATCH 022/329] Add support for framework-level mouse confining. --- osu.Desktop.VisualTests/VisualTestGame.cs | 2 +- osu.Desktop/OsuGameDesktop.cs | 2 +- osu.Game/Configuration/ConfineMouseMode.cs | 12 ---------- .../Options/Sections/Input/MouseOptions.cs | 22 ++++++++++--------- osu.Game/osu.Game.csproj | 1 - 5 files changed, 14 insertions(+), 25 deletions(-) delete mode 100644 osu.Game/Configuration/ConfineMouseMode.cs diff --git a/osu.Desktop.VisualTests/VisualTestGame.cs b/osu.Desktop.VisualTests/VisualTestGame.cs index e0d168390b..5c5bcd9e21 100644 --- a/osu.Desktop.VisualTests/VisualTestGame.cs +++ b/osu.Desktop.VisualTests/VisualTestGame.cs @@ -29,7 +29,7 @@ namespace osu.Desktop.VisualTests host.DrawThread.InactiveHz = host.DrawThread.ActiveHz; host.InputThread.InactiveHz = host.InputThread.ActiveHz; - host.Window.CursorState = CursorState.Hidden; + host.Window.CursorState |= CursorState.Hidden; } } } diff --git a/osu.Desktop/OsuGameDesktop.cs b/osu.Desktop/OsuGameDesktop.cs index c2bb39ac4a..299f64d998 100644 --- a/osu.Desktop/OsuGameDesktop.cs +++ b/osu.Desktop/OsuGameDesktop.cs @@ -43,7 +43,7 @@ namespace osu.Desktop var desktopWindow = host.Window as DesktopGameWindow; if (desktopWindow != null) { - desktopWindow.CursorState = CursorState.Hidden; + desktopWindow.CursorState |= CursorState.Hidden; desktopWindow.Icon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location); desktopWindow.Title = Name; diff --git a/osu.Game/Configuration/ConfineMouseMode.cs b/osu.Game/Configuration/ConfineMouseMode.cs deleted file mode 100644 index 527f26cf6b..0000000000 --- a/osu.Game/Configuration/ConfineMouseMode.cs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -namespace osu.Game.Configuration -{ - public enum ConfineMouseMode - { - Never, - Fullscreen, - Always - } -} \ No newline at end of file diff --git a/osu.Game/Overlays/Options/Sections/Input/MouseOptions.cs b/osu.Game/Overlays/Options/Sections/Input/MouseOptions.cs index 4a48c9ec86..27b8159d63 100644 --- a/osu.Game/Overlays/Options/Sections/Input/MouseOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Input/MouseOptions.cs @@ -2,7 +2,9 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Allocation; +using osu.Framework.Configuration; using osu.Framework.Graphics; +using osu.Framework.Input; using osu.Game.Configuration; using osu.Game.Graphics.UserInterface; @@ -13,44 +15,44 @@ namespace osu.Game.Overlays.Options.Sections.Input protected override string Header => "Mouse"; [BackgroundDependencyLoader] - private void load(OsuConfigManager config) + private void load(OsuConfigManager osuConfig, FrameworkConfigManager config) { Children = new Drawable[] { new OptionSlider { LabelText = "Sensitivity", - Bindable = config.GetBindable(OsuConfig.MouseSpeed) + Bindable = osuConfig.GetBindable(OsuConfig.MouseSpeed) }, new OsuCheckbox { LabelText = "Raw input", - Bindable = config.GetBindable(OsuConfig.RawInput) + Bindable = osuConfig.GetBindable(OsuConfig.RawInput) }, new OsuCheckbox { LabelText = "Map absolute raw input to the osu! window", - Bindable = config.GetBindable(OsuConfig.AbsoluteToOsuWindow) + Bindable = osuConfig.GetBindable(OsuConfig.AbsoluteToOsuWindow) }, new OptionEnumDropdown { LabelText = "Confine mouse cursor", - Bindable = config.GetBindable(OsuConfig.ConfineMouse), + Bindable = config.GetBindable(FrameworkConfig.ConfineMouseMode), }, new OsuCheckbox { - LabelText = "Disable mouse wheel in play mode", - Bindable = config.GetBindable(OsuConfig.MouseDisableWheel) + LabelText = "Disable mouse wheel during gameplay", + Bindable = osuConfig.GetBindable(OsuConfig.MouseDisableWheel) }, new OsuCheckbox { - LabelText = "Disable mouse buttons in play mode", - Bindable = config.GetBindable(OsuConfig.MouseDisableButtons) + LabelText = "Disable mouse buttons during gameplay", + Bindable = osuConfig.GetBindable(OsuConfig.MouseDisableButtons) }, new OsuCheckbox { LabelText = "Cursor ripples", - Bindable = config.GetBindable(OsuConfig.CursorRipple) + Bindable = osuConfig.GetBindable(OsuConfig.CursorRipple) }, }; } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index fb364ccdf5..7b034c2838 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -385,7 +385,6 @@ - From a993790a66f619c0edafdbd9b34b5524e13bffa6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 2 May 2017 17:54:07 +0900 Subject: [PATCH 023/329] Ensure all searchable terms are non-null non-empty. --- osu.Game/Database/BeatmapMetadata.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Database/BeatmapMetadata.cs b/osu.Game/Database/BeatmapMetadata.cs index 098c524cc3..ebca0f1cad 100644 --- a/osu.Game/Database/BeatmapMetadata.cs +++ b/osu.Game/Database/BeatmapMetadata.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.Linq; using SQLite.Net.Attributes; namespace osu.Game.Database @@ -31,6 +32,6 @@ namespace osu.Game.Database TitleUnicode, Source, Tags - }; + }.Where(s => !string.IsNullOrEmpty(s)).ToArray(); } } \ No newline at end of file From f1f7a26dbde356fe16e97f82311d1f41d0814f4f Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 2 May 2017 17:58:59 +0900 Subject: [PATCH 024/329] Fix incorrect inheritance. --- osu.Game/Users/Team.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Users/Team.cs b/osu.Game/Users/Team.cs index fe94f26931..7d5c0322fe 100644 --- a/osu.Game/Users/Team.cs +++ b/osu.Game/Users/Team.cs @@ -3,7 +3,7 @@ namespace osu.Game.Users { - public class Team : Country + public class Team { public string Name; } From 8e88d86639989520c65fceb34d01bb99a5175097 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 2 May 2017 18:00:37 +0900 Subject: [PATCH 025/329] Fix naming confusion. --- .../Tests/TestCaseDrawings.cs | 20 +++++++++---------- osu.Game/Screens/Tournament/Drawings.cs | 8 ++++---- osu.Game/Screens/Tournament/Group.cs | 8 ++++---- osu.Game/Screens/Tournament/GroupContainer.cs | 2 +- .../Tournament/ScrollingTeamContainer.cs | 18 ++++++++--------- .../Teams/{Team.cs => DrawingsTeam.cs} | 2 +- .../Screens/Tournament/Teams/ITeamList.cs | 2 +- .../Tournament/Teams/StorageBackedTeamList.cs | 6 +++--- osu.Game/osu.Game.csproj | 2 +- 9 files changed, 34 insertions(+), 34 deletions(-) rename osu.Game/Screens/Tournament/Teams/{Team.cs => DrawingsTeam.cs} (91%) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDrawings.cs b/osu.Desktop.VisualTests/Tests/TestCaseDrawings.cs index c4771a2913..ebc9930f93 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDrawings.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDrawings.cs @@ -24,57 +24,57 @@ namespace osu.Desktop.VisualTests.Tests private class TestTeamList : ITeamList { - public IEnumerable Teams { get; } = new[] + public IEnumerable Teams { get; } = new[] { - new Team + new DrawingsTeam { FlagName = "GB", FullName = "United Kingdom", Acronym = "UK" }, - new Team + new DrawingsTeam { FlagName = "FR", FullName = "France", Acronym = "FRA" }, - new Team + new DrawingsTeam { FlagName = "CN", FullName = "China", Acronym = "CHN" }, - new Team + new DrawingsTeam { FlagName = "AU", FullName = "Australia", Acronym = "AUS" }, - new Team + new DrawingsTeam { FlagName = "JP", FullName = "Japan", Acronym = "JPN" }, - new Team + new DrawingsTeam { FlagName = "RO", FullName = "Romania", Acronym = "ROM" }, - new Team + new DrawingsTeam { FlagName = "IT", FullName = "Italy", Acronym = "PIZZA" }, - new Team + new DrawingsTeam { FlagName = "VE", FullName = "Venezuela", Acronym = "VNZ" }, - new Team + new DrawingsTeam { FlagName = "US", FullName = "United States of America", diff --git a/osu.Game/Screens/Tournament/Drawings.cs b/osu.Game/Screens/Tournament/Drawings.cs index 924e7adac4..eada42a53e 100644 --- a/osu.Game/Screens/Tournament/Drawings.cs +++ b/osu.Game/Screens/Tournament/Drawings.cs @@ -37,7 +37,7 @@ namespace osu.Game.Screens.Tournament private GroupContainer groupsContainer; private OsuSpriteText fullTeamNameText; - private readonly List allTeams = new List(); + private readonly List allTeams = new List(); private DrawingsConfigManager drawingsConfig; @@ -249,7 +249,7 @@ namespace osu.Game.Screens.Tournament reset(true); } - private void onTeamSelected(Team team) + private void onTeamSelected(DrawingsTeam team) { groupsContainer.AddTeam(team); @@ -286,7 +286,7 @@ namespace osu.Game.Screens.Tournament teamsContainer.ClearTeams(); allTeams.Clear(); - foreach (Team t in TeamList.Teams) + foreach (DrawingsTeam t in TeamList.Teams) { if (groupsContainer.ContainsTeam(t.FullName)) continue; @@ -322,7 +322,7 @@ namespace osu.Game.Screens.Tournament if (line.ToUpper().StartsWith("GROUP")) continue; - Team teamToAdd = allTeams.FirstOrDefault(t => t.FullName == line); + DrawingsTeam teamToAdd = allTeams.FirstOrDefault(t => t.FullName == line); if (teamToAdd == null) continue; diff --git a/osu.Game/Screens/Tournament/Group.cs b/osu.Game/Screens/Tournament/Group.cs index 697ae17e95..f5695ae1cb 100644 --- a/osu.Game/Screens/Tournament/Group.cs +++ b/osu.Game/Screens/Tournament/Group.cs @@ -73,7 +73,7 @@ namespace osu.Game.Screens.Tournament }; } - public void AddTeam(Team team) + public void AddTeam(DrawingsTeam team) { GroupTeam gt = new GroupTeam(team); @@ -91,7 +91,7 @@ namespace osu.Game.Screens.Tournament return allTeams.Any(t => t.Team.FullName == fullName); } - public bool RemoveTeam(Team team) + public bool RemoveTeam(DrawingsTeam team) { allTeams.RemoveAll(gt => gt.Team == team); @@ -122,12 +122,12 @@ namespace osu.Game.Screens.Tournament private class GroupTeam : Container { - public readonly Team Team; + public readonly DrawingsTeam Team; private readonly FillFlowContainer innerContainer; private readonly Sprite flagSprite; - public GroupTeam(Team team) + public GroupTeam(DrawingsTeam team) { Team = team; diff --git a/osu.Game/Screens/Tournament/GroupContainer.cs b/osu.Game/Screens/Tournament/GroupContainer.cs index bc4c3b71c3..ba73a61c92 100644 --- a/osu.Game/Screens/Tournament/GroupContainer.cs +++ b/osu.Game/Screens/Tournament/GroupContainer.cs @@ -64,7 +64,7 @@ namespace osu.Game.Screens.Tournament } } - public void AddTeam(Team team) + public void AddTeam(DrawingsTeam team) { if (groups[currentGroup].TeamsCount == maxTeams) return; diff --git a/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs b/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs index 4ae26d3a67..3eea239f55 100644 --- a/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs +++ b/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs @@ -22,9 +22,9 @@ namespace osu.Game.Screens.Tournament public class ScrollingTeamContainer : Container { public event Action OnScrollStarted; - public event Action OnSelected; + public event Action OnSelected; - private readonly List availableTeams = new List(); + private readonly List availableTeams = new List(); private readonly Container tracker; @@ -158,7 +158,7 @@ namespace osu.Game.Screens.Tournament } } - public void AddTeam(Team team) + public void AddTeam(DrawingsTeam team) { if (availableTeams.Contains(team)) return; @@ -169,12 +169,12 @@ namespace osu.Game.Screens.Tournament scrollState = ScrollState.Idle; } - public void AddTeams(IEnumerable teams) + public void AddTeams(IEnumerable teams) { if (teams == null) return; - foreach (Team t in teams) + foreach (DrawingsTeam t in teams) AddTeam(t); } @@ -185,7 +185,7 @@ namespace osu.Game.Screens.Tournament scrollState = ScrollState.Idle; } - public void RemoveTeam(Team team) + public void RemoveTeam(DrawingsTeam team) { availableTeams.Remove(team); @@ -270,7 +270,7 @@ namespace osu.Game.Screens.Tournament private void addFlags() { - foreach (Team t in availableTeams) + foreach (DrawingsTeam t in availableTeams) { Add(new ScrollingTeam(t) { @@ -320,7 +320,7 @@ namespace osu.Game.Screens.Tournament public const float WIDTH = 58; public const float HEIGHT = 41; - public Team Team; + public DrawingsTeam Team; private readonly Sprite flagSprite; private readonly Box outline; @@ -340,7 +340,7 @@ namespace osu.Game.Screens.Tournament } } - public ScrollingTeam(Team team) + public ScrollingTeam(DrawingsTeam team) { Team = team; diff --git a/osu.Game/Screens/Tournament/Teams/Team.cs b/osu.Game/Screens/Tournament/Teams/DrawingsTeam.cs similarity index 91% rename from osu.Game/Screens/Tournament/Teams/Team.cs rename to osu.Game/Screens/Tournament/Teams/DrawingsTeam.cs index 5ffee1fc37..2739711c35 100644 --- a/osu.Game/Screens/Tournament/Teams/Team.cs +++ b/osu.Game/Screens/Tournament/Teams/DrawingsTeam.cs @@ -3,7 +3,7 @@ namespace osu.Game.Screens.Tournament.Teams { - public class Team + public class DrawingsTeam { /// /// The name of this team. diff --git a/osu.Game/Screens/Tournament/Teams/ITeamList.cs b/osu.Game/Screens/Tournament/Teams/ITeamList.cs index a4476b64c6..9427ebc7fb 100644 --- a/osu.Game/Screens/Tournament/Teams/ITeamList.cs +++ b/osu.Game/Screens/Tournament/Teams/ITeamList.cs @@ -7,6 +7,6 @@ namespace osu.Game.Screens.Tournament.Teams { public interface ITeamList { - IEnumerable Teams { get; } + IEnumerable Teams { get; } } } diff --git a/osu.Game/Screens/Tournament/Teams/StorageBackedTeamList.cs b/osu.Game/Screens/Tournament/Teams/StorageBackedTeamList.cs index 3bca7f2937..1b2d84a666 100644 --- a/osu.Game/Screens/Tournament/Teams/StorageBackedTeamList.cs +++ b/osu.Game/Screens/Tournament/Teams/StorageBackedTeamList.cs @@ -20,11 +20,11 @@ namespace osu.Game.Screens.Tournament.Teams this.storage = storage; } - public IEnumerable Teams + public IEnumerable Teams { get { - var teams = new List(); + var teams = new List(); try { @@ -52,7 +52,7 @@ namespace osu.Game.Screens.Tournament.Teams string acronym = split.Length >= 3 ? split[2].Trim() : teamName; acronym = acronym.Substring(0, Math.Min(3, acronym.Length)); - teams.Add(new Team + teams.Add(new DrawingsTeam { FlagName = flagName, FullName = teamName, diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 0c41ec91bb..907ba0cd95 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -325,7 +325,7 @@ - + From 57c2dd1f49c26ce19cd21a10e5c18b78b835d7d0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 2 May 2017 18:35:23 +0900 Subject: [PATCH 026/329] Fix options dropdown labels never being displayed. --- osu.Game/Overlays/Options/OptionDropdown.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Overlays/Options/OptionDropdown.cs b/osu.Game/Overlays/Options/OptionDropdown.cs index 8642b132df..6837e71c2c 100644 --- a/osu.Game/Overlays/Options/OptionDropdown.cs +++ b/osu.Game/Overlays/Options/OptionDropdown.cs @@ -24,6 +24,7 @@ namespace osu.Game.Overlays.Options set { text.Text = value; + text.Alpha = !string.IsNullOrEmpty(value) ? 1 : 0; } } From d4045ee2c095467dee0fdb247e8da42b136a60e5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 2 May 2017 18:40:30 +0900 Subject: [PATCH 027/329] We only have one release stream, so let's unlock it. --- osu.Game/Configuration/OsuConfigManager.cs | 7 +++++-- .../Overlays/Options/Sections/General/UpdateOptions.cs | 1 - 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 91652e8ef4..0e4c987e5c 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -56,13 +56,17 @@ namespace osu.Game.Configuration Set(OsuConfig.SnakingInSliders, true); Set(OsuConfig.SnakingOutSliders, true); - // Gameplay + // Gameplay Set(OsuConfig.DimLevel, 0.3, 0, 1); Set(OsuConfig.ShowInterface, true); Set(OsuConfig.KeyOverlay, false); + // Update + + Set(OsuConfig.ReleaseStream, ReleaseStream.Lazer); + //todo: implement all settings below this line (remove the Disabled set when doing so). Set(OsuConfig.MouseSpeed, 1.0).Disabled = true; @@ -177,7 +181,6 @@ namespace osu.Game.Configuration Set(OsuConfig.AlternativeChatFont, false).Disabled = true; Set(OsuConfig.DisplayStarsMaximum, 10.0, 0.0, 10.0).Disabled = true; Set(OsuConfig.DisplayStarsMinimum, 0.0, 0.0, 10.0).Disabled = true; - Set(OsuConfig.ReleaseStream, ReleaseStream.Lazer).Disabled = true; Set(OsuConfig.UpdateFailCount, 0).Disabled = true; //Set(OsuConfig.TreeSortMode, TreeGroupMode.Show_All).Disabled = true; //Set(OsuConfig.TreeSortMode2, TreeSortMode.Title).Disabled = true; diff --git a/osu.Game/Overlays/Options/Sections/General/UpdateOptions.cs b/osu.Game/Overlays/Options/Sections/General/UpdateOptions.cs index 2b2939e432..1d9a5a7d72 100644 --- a/osu.Game/Overlays/Options/Sections/General/UpdateOptions.cs +++ b/osu.Game/Overlays/Options/Sections/General/UpdateOptions.cs @@ -23,7 +23,6 @@ namespace osu.Game.Overlays.Options.Sections.General LabelText = "Release stream", Bindable = config.GetBindable(OsuConfig.ReleaseStream), }, - new OptionLabel { Text = "Your osu! is up to date" }, // TODO: map this to reality new OsuButton { RelativeSizeAxes = Axes.X, From f9de7331285a4c2add1a83f5466a5f6f16b11729 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 2 May 2017 18:53:33 +0900 Subject: [PATCH 028/329] Formatting. --- osu.Game/Overlays/Options/OptionSlider.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Options/OptionSlider.cs b/osu.Game/Overlays/Options/OptionSlider.cs index 42bf4170fa..2d98bc991a 100644 --- a/osu.Game/Overlays/Options/OptionSlider.cs +++ b/osu.Game/Overlays/Options/OptionSlider.cs @@ -12,11 +12,14 @@ using osu.Game.Graphics.UserInterface; namespace osu.Game.Overlays.Options { - public class OptionSlider : OptionSlider> where T: struct + public class OptionSlider : OptionSlider> + where T : struct { } - public class OptionSlider : FillFlowContainer where T : struct where U : SliderBar, new() + public class OptionSlider : FillFlowContainer + where T : struct + where U : SliderBar, new() { private readonly SliderBar slider; private readonly SpriteText text; From 691742b8282cb81a5938259787a3882133636fe4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 2 May 2017 19:40:30 +0900 Subject: [PATCH 029/329] Remove most options which have not yet been implemented. --- osu.Game/Configuration/OsuConfigManager.cs | 256 +----------------- osu.Game/Configuration/ProgressBarType.cs | 18 -- .../Options/Sections/Audio/VolumeOptions.cs | 9 +- .../Options/Sections/EditorSection.cs | 58 ---- .../Sections/Gameplay/GeneralOptions.cs | 30 -- .../Sections/General/LanguageOptions.cs | 9 +- .../Sections/Graphics/DetailOptions.cs | 35 --- .../Sections/Graphics/LayoutOptions.cs | 1 - .../Sections/Graphics/MainMenuOptions.cs | 12 +- .../Sections/Graphics/RendererOptions.cs | 19 +- .../Graphics/SongSelectGraphicsOptions.cs | 27 -- .../Options/Sections/GraphicsSection.cs | 1 - .../Options/Sections/Input/KeyboardOptions.cs | 7 +- .../Options/Sections/Input/MouseOptions.cs | 20 -- .../Sections/Input/OtherInputOptions.cs | 34 --- .../Overlays/Options/Sections/InputSection.cs | 1 - .../Options/Sections/MaintenanceSection.cs | 22 +- .../Sections/Online/InGameChatOptions.cs | 53 ---- .../Sections/Online/IntegrationOptions.cs | 43 --- .../Sections/Online/NotificationsOptions.cs | 53 ---- .../Options/Sections/Online/PrivacyOptions.cs | 33 --- .../Options/Sections/OnlineSection.cs | 5 - .../Overlays/Options/Sections/SkinSection.cs | 42 --- osu.Game/Overlays/OptionsOverlay.cs | 1 - osu.Game/osu.Game.csproj | 8 - 25 files changed, 13 insertions(+), 784 deletions(-) delete mode 100644 osu.Game/Configuration/ProgressBarType.cs delete mode 100644 osu.Game/Overlays/Options/Sections/EditorSection.cs delete mode 100644 osu.Game/Overlays/Options/Sections/Graphics/SongSelectGraphicsOptions.cs delete mode 100644 osu.Game/Overlays/Options/Sections/Input/OtherInputOptions.cs delete mode 100644 osu.Game/Overlays/Options/Sections/Online/InGameChatOptions.cs delete mode 100644 osu.Game/Overlays/Options/Sections/Online/IntegrationOptions.cs delete mode 100644 osu.Game/Overlays/Options/Sections/Online/NotificationsOptions.cs delete mode 100644 osu.Game/Overlays/Options/Sections/Online/PrivacyOptions.cs diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 0e4c987e5c..1fcb33b248 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.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 osu.Framework.Configuration; using osu.Framework.Platform; using osu.Game.Screens.Select; @@ -17,6 +16,9 @@ namespace osu.Game.Configuration Set(OsuConfig.Ruleset, 0, 0, int.MaxValue); Set(OsuConfig.BeatmapDetailTab, BeatmapDetailTab.Details); + Set(OsuConfig.DisplayStarsMinimum, 0.0, 0, 10); + Set(OsuConfig.DisplayStarsMaximum, 10.0, 0, 10); + // Online settings Set(OsuConfig.Username, string.Empty); @@ -66,128 +68,6 @@ namespace osu.Game.Configuration // Update Set(OsuConfig.ReleaseStream, ReleaseStream.Lazer); - - //todo: implement all settings below this line (remove the Disabled set when doing so). - - Set(OsuConfig.MouseSpeed, 1.0).Disabled = true; - Set(OsuConfig.BeatmapDirectory, @"Songs").Disabled = true; - Set(OsuConfig.AllowPublicInvites, true).Disabled = true; - Set(OsuConfig.AutoChatHide, true).Disabled = true; - Set(OsuConfig.AutomaticDownload, true).Disabled = true; - Set(OsuConfig.AutomaticDownloadNoVideo, false).Disabled = true; - Set(OsuConfig.BlockNonFriendPM, false).Disabled = true; - Set(OsuConfig.Bloom, false).Disabled = true; - Set(OsuConfig.BloomSoftening, false).Disabled = true; - Set(OsuConfig.BossKeyFirstActivation, true).Disabled = true; - Set(OsuConfig.ChatAudibleHighlight, true).Disabled = true; - Set(OsuConfig.ChatChannels, string.Empty).Disabled = true; - Set(OsuConfig.ChatFilter, false).Disabled = true; - Set(OsuConfig.ChatHighlightName, true).Disabled = true; - Set(OsuConfig.ChatMessageNotification, true).Disabled = true; - Set(OsuConfig.ChatLastChannel, string.Empty).Disabled = true; - Set(OsuConfig.ChatRemoveForeign, false).Disabled = true; - //Set(OsuConfig.ChatSortMode, UserSortMode.Rank).Disabled = true; - Set(OsuConfig.ComboBurst, true).Disabled = true; - Set(OsuConfig.ComboFire, false).Disabled = true; - Set(OsuConfig.ComboFireHeight, 3).Disabled = true; - Set(OsuConfig.ConfirmExit, false).Disabled = true; - Set(OsuConfig.AutoSendNowPlaying, true).Disabled = true; - Set(OsuConfig.AutomaticCursorSizing, false).Disabled = true; - Set(OsuConfig.Display, 1).Disabled = true; - Set(OsuConfig.DisplayCityLocation, false).Disabled = true; - Set(OsuConfig.DistanceSpacingEnabled, true).Disabled = true; - Set(OsuConfig.EditorTip, 0).Disabled = true; - Set(OsuConfig.VideoEditor, true).Disabled = true; - Set(OsuConfig.EditorDefaultSkin, false).Disabled = true; - Set(OsuConfig.EditorSnakingSliders, true).Disabled = true; - Set(OsuConfig.EditorHitAnimations, false).Disabled = true; - Set(OsuConfig.EditorFollowPoints, true).Disabled = true; - Set(OsuConfig.EditorStacking, true).Disabled = true; - Set(OsuConfig.ForceSliderRendering, false).Disabled = true; - Set(OsuConfig.FpsCounter, false).Disabled = true; - Set(OsuConfig.FrameTimeDisplay, false).Disabled = true; - Set(OsuConfig.GuideTips, @"").Disabled = true; - Set(OsuConfig.CursorRipple, false).Disabled = true; - Set(OsuConfig.HighlightWords, string.Empty).Disabled = true; - Set(OsuConfig.HighResolution, false).Disabled = true; - Set(OsuConfig.HitLighting, true).Disabled = true; - Set(OsuConfig.IgnoreBarline, false).Disabled = true; - Set(OsuConfig.IgnoreBeatmapSamples, false).Disabled = true; - Set(OsuConfig.IgnoreBeatmapSkins, false).Disabled = true; - Set(OsuConfig.IgnoreList, string.Empty).Disabled = true; - Set(OsuConfig.AllowNowPlayingHighlights, false).Disabled = true; - Set(OsuConfig.LastVersion, string.Empty).Disabled = true; - Set(OsuConfig.LastVersionPermissionsFailed, string.Empty).Disabled = true; - Set(OsuConfig.LoadSubmittedThread, true).Disabled = true; - Set(OsuConfig.LobbyPlayMode, -1).Disabled = true; - Set(OsuConfig.ShowInterfaceDuringRelax, false).Disabled = true; - Set(OsuConfig.LobbyShowExistingOnly, false).Disabled = true; - Set(OsuConfig.LobbyShowFriendsOnly, false).Disabled = true; - Set(OsuConfig.LobbyShowFull, false).Disabled = true; - Set(OsuConfig.LobbyShowInProgress, true).Disabled = true; - Set(OsuConfig.LobbyShowPassworded, true).Disabled = true; - Set(OsuConfig.LogPrivateMessages, false).Disabled = true; - Set(OsuConfig.LowResolution, false).Disabled = true; - //Set(OsuConfig.ManiaSpeed, SpeedMania.SPEED_DEFAULT, SpeedMania.SPEED_MIN, SpeedMania.SPEED_MAX).Disabled = true; - Set(OsuConfig.UsePerBeatmapManiaSpeed, true).Disabled = true; - Set(OsuConfig.ManiaSpeedBPMScale, true).Disabled = true; - Set(OsuConfig.MenuTip, 0).Disabled = true; - Set(OsuConfig.MouseSpeed, 1, 0.4, 6).Disabled = true; - Set(OsuConfig.ScoreMeterScale, 1, 0.5, 2).Disabled = true; - //Set(OsuConfig.ScoreMeterScale, 1, 0.5, OsuGame.Tournament ? 10 : 2).Disabled = true; - Set(OsuConfig.DistanceSpacing, 0.8, 0.1, 6).Disabled = true; - Set(OsuConfig.EditorBeatDivisor, 1, 1, 16).Disabled = true; - Set(OsuConfig.EditorGridSize, 32, 4, 32).Disabled = true; - Set(OsuConfig.EditorGridSizeDesign, 32, 4, 32).Disabled = true; - Set(OsuConfig.CustomFrameLimit, 240, 240, 999).Disabled = true; - Set(OsuConfig.MsnIntegration, false).Disabled = true; - Set(OsuConfig.MyPcSucks, false).Disabled = true; - Set(OsuConfig.NotifyFriends, true).Disabled = true; - Set(OsuConfig.NotifySubmittedThread, true).Disabled = true; - Set(OsuConfig.PopupDuringGameplay, true).Disabled = true; - Set(OsuConfig.ProgressBarType, ProgressBarType.Pie).Disabled = true; - Set(OsuConfig.RankType, RankingType.Top).Disabled = true; - Set(OsuConfig.RefreshRate, 60).Disabled = true; - Set(OsuConfig.OverrideRefreshRate, Get(OsuConfig.RefreshRate) != 60).Disabled = true; - //Set(OsuConfig.ScaleMode, ScaleMode.WidescreenConservative).Disabled = true; - Set(OsuConfig.ScoreboardVisible, true).Disabled = true; - Set(OsuConfig.ScoreMeter, ScoreMeterType.Error).Disabled = true; - //Set(OsuConfig.ScoreMeter, OsuGame.Tournament ? ScoreMeterType.Colour : ScoreMeterType.Error).Disabled = true; - Set(OsuConfig.ScreenshotId, 0).Disabled = true; - Set(OsuConfig.MenuSnow, false).Disabled = true; - Set(OsuConfig.MenuTriangles, true).Disabled = true; - Set(OsuConfig.SongSelectThumbnails, true).Disabled = true; - Set(OsuConfig.ScreenshotFormat, ScreenshotFormat.Jpg).Disabled = true; - Set(OsuConfig.ShowReplayComments, true).Disabled = true; - Set(OsuConfig.ShowSpectators, true).Disabled = true; - Set(OsuConfig.ShowStoryboard, true).Disabled = true; - //Set(OsuConfig.Skin, SkinManager.DEFAULT_SKIN).Disabled = true; - Set(OsuConfig.SkinSamples, true).Disabled = true; - Set(OsuConfig.SkipTablet, false).Disabled = true; - Set(OsuConfig.Tablet, false).Disabled = true; - Set(OsuConfig.UpdatePending, false).Disabled = true; - Set(OsuConfig.UseSkinCursor, false).Disabled = true; - Set(OsuConfig.UseTaikoSkin, false).Disabled = true; - Set(OsuConfig.Video, true).Disabled = true; - Set(OsuConfig.Wiimote, false).Disabled = true; - Set(OsuConfig.YahooIntegration, false).Disabled = true; - Set(OsuConfig.ForceFrameFlush, false).Disabled = true; - Set(OsuConfig.DetectPerformanceIssues, true).Disabled = true; - Set(OsuConfig.RawInput, false).Disabled = true; - Set(OsuConfig.AbsoluteToOsuWindow, Get(OsuConfig.RawInput)).Disabled = true; - Set(OsuConfig.ShowMenuTips, true).Disabled = true; - Set(OsuConfig.HiddenShowFirstApproach, true).Disabled = true; - Set(OsuConfig.ComboColourSliderBall, true).Disabled = true; - Set(OsuConfig.AlternativeChatFont, false).Disabled = true; - Set(OsuConfig.DisplayStarsMaximum, 10.0, 0.0, 10.0).Disabled = true; - Set(OsuConfig.DisplayStarsMinimum, 0.0, 0.0, 10.0).Disabled = true; - Set(OsuConfig.UpdateFailCount, 0).Disabled = true; - //Set(OsuConfig.TreeSortMode, TreeGroupMode.Show_All).Disabled = true; - //Set(OsuConfig.TreeSortMode2, TreeSortMode.Title).Disabled = true; - Set(OsuConfig.PermanentSongInfo, false).Disabled = true; - Set(OsuConfig.Ticker, false).Disabled = true; - Set(OsuConfig.CompatibilityContext, false).Disabled = true; - Set(OsuConfig.CanForceOptimusCompatibility, true).Disabled = true; } public OsuConfigManager(Storage storage) : base(storage) @@ -197,150 +77,28 @@ namespace osu.Game.Configuration public enum OsuConfig { - // New osu: Ruleset, Token, - // Imported from old osu: - BeatmapDirectory, - AllowPublicInvites, - AutoChatHide, - AutomaticDownload, - AutomaticDownloadNoVideo, - BlockNonFriendPM, - Bloom, - BloomSoftening, - BossKeyFirstActivation, - ChatAudibleHighlight, - ChatChannels, - ChatFilter, - ChatHighlightName, - ChatMessageNotification, - ChatLastChannel, - ChatRemoveForeign, - ChatSortMode, - ComboBurst, - ComboFire, - ComboFireHeight, - ConfirmExit, - AutoSendNowPlaying, MenuCursorSize, GameplayCursorSize, - AutomaticCursorSizing, DimLevel, - Display, - DisplayCityLocation, - DistanceSpacingEnabled, - EditorTip, - VideoEditor, - EditorDefaultSkin, - EditorSnakingSliders, - EditorHitAnimations, - EditorFollowPoints, - EditorStacking, - ForceSliderRendering, - FpsCounter, - FrameTimeDisplay, - GuideTips, - CursorRipple, - HighlightWords, - HighResolution, - HitLighting, - IgnoreBarline, - IgnoreBeatmapSamples, - IgnoreBeatmapSkins, - IgnoreList, KeyOverlay, - Language, - LastPlayMode, - AllowNowPlayingHighlights, - LastVersion, - LastVersionPermissionsFailed, - LoadSubmittedThread, - LobbyPlayMode, ShowInterface, - ShowInterfaceDuringRelax, - LobbyShowExistingOnly, - LobbyShowFriendsOnly, - LobbyShowFull, - LobbyShowInProgress, - LobbyShowPassworded, - LogPrivateMessages, - LowResolution, - ManiaSpeed, - UsePerBeatmapManiaSpeed, - ManiaSpeedBPMScale, - MenuTip, MouseDisableButtons, MouseDisableWheel, - MouseSpeed, AudioOffset, - ScoreMeterScale, - DistanceSpacing, - EditorBeatDivisor, - EditorGridSize, - EditorGridSizeDesign, - CustomFrameLimit, - MsnIntegration, - MyPcSucks, - NotifyFriends, - NotifySubmittedThread, - PopupDuringGameplay, - ProgressBarType, - RankType, - RefreshRate, - OverrideRefreshRate, - ScaleMode, - ScoreboardVisible, - ScoreMeter, - ScreenshotId, - MenuSnow, - MenuTriangles, - SongSelectThumbnails, - ScreenshotFormat, - ShowReplayComments, - ShowSpectators, - ShowStoryboard, - Skin, - SkinSamples, - SkipTablet, - SnakingInSliders, - SnakingOutSliders, - Tablet, - UpdatePending, - UserFilter, - UseSkinCursor, - UseTaikoSkin, - Video, - Wiimote, - YahooIntegration, - ForceFrameFlush, - DetectPerformanceIssues, MenuMusic, MenuVoice, MenuParallax, BeatmapDetailTab, - RawInput, - AbsoluteToOsuWindow, - ConfineMouse, - [Obsolete] - ConfineMouseToFullscreen, - ShowMenuTips, - HiddenShowFirstApproach, - ComboColourSliderBall, - AlternativeChatFont, Username, - DisplayStarsMaximum, - DisplayStarsMinimum, AudioDevice, ReleaseStream, - UpdateFailCount, SavePassword, SaveUsername, - TreeSortMode, - TreeSortMode2, - PermanentSongInfo, - Ticker, - CompatibilityContext, - CanForceOptimusCompatibility, + DisplayStarsMinimum, + DisplayStarsMaximum, + SnakingInSliders, + SnakingOutSliders } } diff --git a/osu.Game/Configuration/ProgressBarType.cs b/osu.Game/Configuration/ProgressBarType.cs deleted file mode 100644 index a768b9f129..0000000000 --- a/osu.Game/Configuration/ProgressBarType.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using System.ComponentModel; - -namespace osu.Game.Configuration -{ - public enum ProgressBarType - { - Off, - Pie, - [Description("Top Right")] - TopRight, - [Description("Bottom Right")] - BottomRight, - Bottom - } -} \ No newline at end of file diff --git a/osu.Game/Overlays/Options/Sections/Audio/VolumeOptions.cs b/osu.Game/Overlays/Options/Sections/Audio/VolumeOptions.cs index d8e8964b17..c3eb04da13 100644 --- a/osu.Game/Overlays/Options/Sections/Audio/VolumeOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Audio/VolumeOptions.cs @@ -4,8 +4,6 @@ using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Graphics; -using osu.Game.Configuration; -using osu.Game.Graphics.UserInterface; namespace osu.Game.Overlays.Options.Sections.Audio { @@ -14,18 +12,13 @@ namespace osu.Game.Overlays.Options.Sections.Audio protected override string Header => "Volume"; [BackgroundDependencyLoader] - private void load(OsuConfigManager config, AudioManager audio) + private void load(AudioManager audio) { Children = new Drawable[] { new OptionSlider { LabelText = "Master", Bindable = audio.Volume }, new OptionSlider { LabelText = "Effect", Bindable = audio.VolumeSample }, new OptionSlider { LabelText = "Music", Bindable = audio.VolumeTrack }, - new OsuCheckbox - { - LabelText = "Ignore beatmap hitsounds", - Bindable = config.GetBindable(OsuConfig.IgnoreBeatmapSamples) - } }; } } diff --git a/osu.Game/Overlays/Options/Sections/EditorSection.cs b/osu.Game/Overlays/Options/Sections/EditorSection.cs deleted file mode 100644 index 513d89c601..0000000000 --- a/osu.Game/Overlays/Options/Sections/EditorSection.cs +++ /dev/null @@ -1,58 +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.Allocation; -using osu.Framework.Graphics; -using osu.Game.Configuration; -using osu.Game.Graphics; -using osu.Game.Graphics.UserInterface; -using OpenTK; - -namespace osu.Game.Overlays.Options.Sections -{ - public class EditorSection : OptionsSection - { - public override string Header => "Editor"; - public override FontAwesome Icon => FontAwesome.fa_pencil; - - [BackgroundDependencyLoader] - private void load(OsuConfigManager config) - { - FlowContent.Spacing = new Vector2(0, 5); - Children = new Drawable[] - { - new OsuCheckbox - { - LabelText = "Background video", - Bindable = config.GetBindable(OsuConfig.VideoEditor) - }, - new OsuCheckbox - { - LabelText = "Always use default skin", - Bindable = config.GetBindable(OsuConfig.EditorDefaultSkin) - }, - new OsuCheckbox - { - LabelText = "Snaking sliders", - Bindable = config.GetBindable(OsuConfig.EditorSnakingSliders) - }, - new OsuCheckbox - { - LabelText = "Hit animations", - Bindable = config.GetBindable(OsuConfig.EditorHitAnimations) - }, - new OsuCheckbox - { - LabelText = "Follow points", - Bindable = config.GetBindable(OsuConfig.EditorFollowPoints) - }, - new OsuCheckbox - { - LabelText = "Stacking", - Bindable = config.GetBindable(OsuConfig.EditorStacking) - }, - }; - } - } -} - diff --git a/osu.Game/Overlays/Options/Sections/Gameplay/GeneralOptions.cs b/osu.Game/Overlays/Options/Sections/Gameplay/GeneralOptions.cs index 99f9ecbaed..c278b59a51 100644 --- a/osu.Game/Overlays/Options/Sections/Gameplay/GeneralOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Gameplay/GeneralOptions.cs @@ -22,21 +22,6 @@ namespace osu.Game.Overlays.Options.Sections.Gameplay LabelText = "Background dim", Bindable = config.GetBindable(OsuConfig.DimLevel) }, - new OptionEnumDropdown - { - LabelText = "Progress display", - Bindable = config.GetBindable(OsuConfig.ProgressBarType) - }, - new OptionEnumDropdown - { - LabelText = "Score meter type", - Bindable = config.GetBindable(OsuConfig.ScoreMeter) - }, - new OptionSlider - { - LabelText = "Score meter size", - Bindable = config.GetBindable(OsuConfig.ScoreMeterScale) - }, new OsuCheckbox { LabelText = "Show score overlay", @@ -47,21 +32,6 @@ namespace osu.Game.Overlays.Options.Sections.Gameplay LabelText = "Always show key overlay", Bindable = config.GetBindable(OsuConfig.KeyOverlay) }, - new OsuCheckbox - { - LabelText = "Show approach circle on first \"Hidden\" object", - Bindable = config.GetBindable(OsuConfig.HiddenShowFirstApproach) - }, - new OsuCheckbox - { - LabelText = "Scale osu!mania scroll speed with BPM", - Bindable = config.GetBindable(OsuConfig.ManiaSpeedBPMScale) - }, - new OsuCheckbox - { - LabelText = "Remember osu!mania scroll speed per beatmap", - Bindable = config.GetBindable(OsuConfig.UsePerBeatmapManiaSpeed) - }, }; } } diff --git a/osu.Game/Overlays/Options/Sections/General/LanguageOptions.cs b/osu.Game/Overlays/Options/Sections/General/LanguageOptions.cs index 1387f981d3..7bc1a54455 100644 --- a/osu.Game/Overlays/Options/Sections/General/LanguageOptions.cs +++ b/osu.Game/Overlays/Options/Sections/General/LanguageOptions.cs @@ -4,7 +4,6 @@ using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; -using osu.Game.Configuration; using osu.Game.Graphics.UserInterface; namespace osu.Game.Overlays.Options.Sections.General @@ -14,21 +13,15 @@ namespace osu.Game.Overlays.Options.Sections.General protected override string Header => "Language"; [BackgroundDependencyLoader] - private void load(OsuConfigManager osuConfig, FrameworkConfigManager frameworkConfig) + private void load(FrameworkConfigManager frameworkConfig) { Children = new Drawable[] { - new OptionLabel { Text = "TODO: Dropdown" }, new OsuCheckbox { LabelText = "Prefer metadata in original language", Bindable = frameworkConfig.GetBindable(FrameworkConfig.ShowUnicode) }, - new OsuCheckbox - { - LabelText = "Use alternative font for chat display", - Bindable = osuConfig.GetBindable(OsuConfig.AlternativeChatFont) - }, }; } } diff --git a/osu.Game/Overlays/Options/Sections/Graphics/DetailOptions.cs b/osu.Game/Overlays/Options/Sections/Graphics/DetailOptions.cs index 0af8a4c580..d8906d74ba 100644 --- a/osu.Game/Overlays/Options/Sections/Graphics/DetailOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Graphics/DetailOptions.cs @@ -27,41 +27,6 @@ namespace osu.Game.Overlays.Options.Sections.Graphics LabelText = "Snaking out sliders", Bindable = config.GetBindable(OsuConfig.SnakingOutSliders) }, - new OsuCheckbox - { - LabelText = "Background video", - Bindable = config.GetBindable(OsuConfig.Video) - }, - new OsuCheckbox - { - LabelText = "Storyboards", - Bindable = config.GetBindable(OsuConfig.ShowStoryboard) - }, - new OsuCheckbox - { - LabelText = "Combo bursts", - Bindable = config.GetBindable(OsuConfig.ComboBurst) - }, - new OsuCheckbox - { - LabelText = "Hit lighting", - Bindable = config.GetBindable(OsuConfig.HitLighting) - }, - new OsuCheckbox - { - LabelText = "Shaders", - Bindable = config.GetBindable(OsuConfig.Bloom) - }, - new OsuCheckbox - { - LabelText = "Softening filter", - Bindable = config.GetBindable(OsuConfig.BloomSoftening) - }, - new OptionEnumDropdown - { - LabelText = "Screenshot", - Bindable = config.GetBindable(OsuConfig.ScreenshotFormat) - } }; } } diff --git a/osu.Game/Overlays/Options/Sections/Graphics/LayoutOptions.cs b/osu.Game/Overlays/Options/Sections/Graphics/LayoutOptions.cs index 9f5e3458f3..aed39ca764 100644 --- a/osu.Game/Overlays/Options/Sections/Graphics/LayoutOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Graphics/LayoutOptions.cs @@ -24,7 +24,6 @@ namespace osu.Game.Overlays.Options.Sections.Graphics Children = new Drawable[] { - new OptionLabel { Text = "Resolution: TODO dropdown" }, new OptionEnumDropdown { LabelText = "Screen mode", diff --git a/osu.Game/Overlays/Options/Sections/Graphics/MainMenuOptions.cs b/osu.Game/Overlays/Options/Sections/Graphics/MainMenuOptions.cs index 13683edb32..83a2a382ad 100644 --- a/osu.Game/Overlays/Options/Sections/Graphics/MainMenuOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Graphics/MainMenuOptions.cs @@ -9,28 +9,18 @@ namespace osu.Game.Overlays.Options.Sections.Graphics { public class MainMenuOptions : OptionsSubsection { - protected override string Header => "Main Menu"; + protected override string Header => "User Interface"; [BackgroundDependencyLoader] private void load(OsuConfigManager config) { Children = new[] { - new OsuCheckbox - { - LabelText = "Snow", - Bindable = config.GetBindable(OsuConfig.MenuSnow) - }, new OsuCheckbox { LabelText = "Parallax", Bindable = config.GetBindable(OsuConfig.MenuParallax) }, - new OsuCheckbox - { - LabelText = "Menu tips", - Bindable = config.GetBindable(OsuConfig.ShowMenuTips) - }, }; } } diff --git a/osu.Game/Overlays/Options/Sections/Graphics/RendererOptions.cs b/osu.Game/Overlays/Options/Sections/Graphics/RendererOptions.cs index c898879167..fafe91cfc5 100644 --- a/osu.Game/Overlays/Options/Sections/Graphics/RendererOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Graphics/RendererOptions.cs @@ -4,8 +4,6 @@ using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; -using osu.Game.Configuration; -using osu.Game.Graphics.UserInterface; namespace osu.Game.Overlays.Options.Sections.Graphics { @@ -14,7 +12,7 @@ namespace osu.Game.Overlays.Options.Sections.Graphics protected override string Header => "Renderer"; [BackgroundDependencyLoader] - private void load(OsuConfigManager osuConfig, FrameworkConfigManager config) + private void load(FrameworkConfigManager config) { // NOTE: Compatability mode omitted Children = new Drawable[] @@ -25,21 +23,6 @@ namespace osu.Game.Overlays.Options.Sections.Graphics LabelText = "Frame limiter", Bindable = config.GetBindable(FrameworkConfig.FrameSync) }, - new OsuCheckbox - { - LabelText = "Show FPS counter", - Bindable = osuConfig.GetBindable(OsuConfig.FpsCounter), - }, - new OsuCheckbox - { - LabelText = "Reduce dropped frames", - Bindable = osuConfig.GetBindable(OsuConfig.ForceFrameFlush), - }, - new OsuCheckbox - { - LabelText = "Detect performance issues", - Bindable = osuConfig.GetBindable(OsuConfig.DetectPerformanceIssues), - }, }; } } diff --git a/osu.Game/Overlays/Options/Sections/Graphics/SongSelectGraphicsOptions.cs b/osu.Game/Overlays/Options/Sections/Graphics/SongSelectGraphicsOptions.cs deleted file mode 100644 index cbaeebcee3..0000000000 --- a/osu.Game/Overlays/Options/Sections/Graphics/SongSelectGraphicsOptions.cs +++ /dev/null @@ -1,27 +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.Allocation; -using osu.Game.Configuration; -using osu.Game.Graphics.UserInterface; - -namespace osu.Game.Overlays.Options.Sections.Graphics -{ - public class SongSelectGraphicsOptions : OptionsSubsection - { - protected override string Header => "Song Select"; - - [BackgroundDependencyLoader] - private void load(OsuConfigManager config) - { - Children = new[] - { - new OsuCheckbox - { - LabelText = "Show thumbnails", - Bindable = config.GetBindable(OsuConfig.SongSelectThumbnails) - } - }; - } - } -} \ No newline at end of file diff --git a/osu.Game/Overlays/Options/Sections/GraphicsSection.cs b/osu.Game/Overlays/Options/Sections/GraphicsSection.cs index b537cf4219..dbbcbde2b9 100644 --- a/osu.Game/Overlays/Options/Sections/GraphicsSection.cs +++ b/osu.Game/Overlays/Options/Sections/GraphicsSection.cs @@ -20,7 +20,6 @@ namespace osu.Game.Overlays.Options.Sections new LayoutOptions(), new DetailOptions(), new MainMenuOptions(), - new SongSelectGraphicsOptions(), }; } } diff --git a/osu.Game/Overlays/Options/Sections/Input/KeyboardOptions.cs b/osu.Game/Overlays/Options/Sections/Input/KeyboardOptions.cs index f3f5445259..b7e8598cff 100644 --- a/osu.Game/Overlays/Options/Sections/Input/KeyboardOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Input/KeyboardOptions.cs @@ -17,13 +17,8 @@ namespace osu.Game.Overlays.Options.Sections.Input new OsuButton { RelativeSizeAxes = Axes.X, - Text = "Change keyboard bindings" + Text = "Key Configuration" }, - new OsuButton - { - RelativeSizeAxes = Axes.X, - Text = "osu!mania layout" - } }; } } diff --git a/osu.Game/Overlays/Options/Sections/Input/MouseOptions.cs b/osu.Game/Overlays/Options/Sections/Input/MouseOptions.cs index 27b8159d63..12789aa0ec 100644 --- a/osu.Game/Overlays/Options/Sections/Input/MouseOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Input/MouseOptions.cs @@ -19,21 +19,6 @@ namespace osu.Game.Overlays.Options.Sections.Input { Children = new Drawable[] { - new OptionSlider - { - LabelText = "Sensitivity", - Bindable = osuConfig.GetBindable(OsuConfig.MouseSpeed) - }, - new OsuCheckbox - { - LabelText = "Raw input", - Bindable = osuConfig.GetBindable(OsuConfig.RawInput) - }, - new OsuCheckbox - { - LabelText = "Map absolute raw input to the osu! window", - Bindable = osuConfig.GetBindable(OsuConfig.AbsoluteToOsuWindow) - }, new OptionEnumDropdown { LabelText = "Confine mouse cursor", @@ -49,11 +34,6 @@ namespace osu.Game.Overlays.Options.Sections.Input LabelText = "Disable mouse buttons during gameplay", Bindable = osuConfig.GetBindable(OsuConfig.MouseDisableButtons) }, - new OsuCheckbox - { - LabelText = "Cursor ripples", - Bindable = osuConfig.GetBindable(OsuConfig.CursorRipple) - }, }; } diff --git a/osu.Game/Overlays/Options/Sections/Input/OtherInputOptions.cs b/osu.Game/Overlays/Options/Sections/Input/OtherInputOptions.cs deleted file mode 100644 index 9323f7514b..0000000000 --- a/osu.Game/Overlays/Options/Sections/Input/OtherInputOptions.cs +++ /dev/null @@ -1,34 +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.Allocation; -using osu.Framework.Graphics; -using osu.Game.Configuration; -using osu.Game.Graphics.UserInterface; - -namespace osu.Game.Overlays.Options.Sections.Input -{ - public class OtherInputOptions : OptionsSubsection - { - protected override string Header => "Other"; - - [BackgroundDependencyLoader] - private void load(OsuConfigManager config) - { - Children = new Drawable[] - { - new OsuCheckbox - { - LabelText = "OS TabletPC support", - Bindable = config.GetBindable(OsuConfig.Tablet) - }, - new OsuCheckbox - { - LabelText = "Wiimote/TaTaCon Drum Support", - Bindable = config.GetBindable(OsuConfig.Wiimote) - }, - }; - } - } -} - diff --git a/osu.Game/Overlays/Options/Sections/InputSection.cs b/osu.Game/Overlays/Options/Sections/InputSection.cs index 69a3e20f6f..d39d0a0e20 100644 --- a/osu.Game/Overlays/Options/Sections/InputSection.cs +++ b/osu.Game/Overlays/Options/Sections/InputSection.cs @@ -18,7 +18,6 @@ namespace osu.Game.Overlays.Options.Sections { new MouseOptions(), new KeyboardOptions(), - new OtherInputOptions(), }; } } diff --git a/osu.Game/Overlays/Options/Sections/MaintenanceSection.cs b/osu.Game/Overlays/Options/Sections/MaintenanceSection.cs index 638c1c9a64..a50f1f3ff0 100644 --- a/osu.Game/Overlays/Options/Sections/MaintenanceSection.cs +++ b/osu.Game/Overlays/Options/Sections/MaintenanceSection.cs @@ -3,7 +3,6 @@ using osu.Framework.Graphics; using osu.Game.Graphics; -using osu.Game.Graphics.UserInterface; using OpenTK; namespace osu.Game.Overlays.Options.Sections @@ -18,26 +17,7 @@ namespace osu.Game.Overlays.Options.Sections FlowContent.Spacing = new Vector2(0, 5); Children = new Drawable[] { - new OsuButton - { - RelativeSizeAxes = Axes.X, - Text = "Delete all unranked maps", - }, - new OsuButton - { - RelativeSizeAxes = Axes.X, - Text = "Repair folder permissions", - }, - new OsuButton - { - RelativeSizeAxes = Axes.X, - Text = "Mark all maps as played", - }, - new OsuButton - { - RelativeSizeAxes = Axes.X, - Text = "Run osu! updater", - }, + }; } } diff --git a/osu.Game/Overlays/Options/Sections/Online/InGameChatOptions.cs b/osu.Game/Overlays/Options/Sections/Online/InGameChatOptions.cs deleted file mode 100644 index 9a477f40c7..0000000000 --- a/osu.Game/Overlays/Options/Sections/Online/InGameChatOptions.cs +++ /dev/null @@ -1,53 +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.Allocation; -using osu.Framework.Graphics; -using osu.Game.Configuration; -using osu.Game.Graphics.UserInterface; - -namespace osu.Game.Overlays.Options.Sections.Online -{ - public class InGameChatOptions : OptionsSubsection - { - protected override string Header => "Chat"; - - [BackgroundDependencyLoader] - private void load(OsuConfigManager config) - { - Children = new Drawable[] - { - new OsuCheckbox - { - LabelText = "Filter offensive words", - Bindable = config.GetBindable(OsuConfig.ChatFilter) - }, - new OsuCheckbox - { - LabelText = "Filter foreign characters", - Bindable = config.GetBindable(OsuConfig.ChatRemoveForeign) - }, - new OsuCheckbox - { - LabelText = "Log private messages", - Bindable = config.GetBindable(OsuConfig.LogPrivateMessages) - }, - new OsuCheckbox - { - LabelText = "Block private messages from non-friends", - Bindable = config.GetBindable(OsuConfig.BlockNonFriendPM) - }, - new OptionLabel { Text = "Chat ignore list (space-seperated list)" }, - new OptionTextBox { - RelativeSizeAxes = Axes.X, - Bindable = config.GetBindable(OsuConfig.IgnoreList) - }, - new OptionLabel { Text = "Chat highlight words (space-seperated list)" }, - new OptionTextBox { - RelativeSizeAxes = Axes.X, - Bindable = config.GetBindable(OsuConfig.HighlightWords) - }, - }; - } - } -} \ No newline at end of file diff --git a/osu.Game/Overlays/Options/Sections/Online/IntegrationOptions.cs b/osu.Game/Overlays/Options/Sections/Online/IntegrationOptions.cs deleted file mode 100644 index d4298ee43c..0000000000 --- a/osu.Game/Overlays/Options/Sections/Online/IntegrationOptions.cs +++ /dev/null @@ -1,43 +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.Allocation; -using osu.Framework.Graphics; -using osu.Game.Configuration; -using osu.Game.Graphics.UserInterface; - -namespace osu.Game.Overlays.Options.Sections.Online -{ - public class IntegrationOptions : OptionsSubsection - { - protected override string Header => "Integration"; - - [BackgroundDependencyLoader] - private void load(OsuConfigManager config) - { - Children = new Drawable[] - { - new OsuCheckbox - { - LabelText = "Integrate with Yahoo! status display", - Bindable = config.GetBindable(OsuConfig.YahooIntegration) - }, - new OsuCheckbox - { - LabelText = "Integrate with MSN Live status display", - Bindable = config.GetBindable(OsuConfig.MsnIntegration) - }, - new OsuCheckbox - { - LabelText = "Automatically start osu!direct downloads", - Bindable = config.GetBindable(OsuConfig.AutomaticDownload) - }, - new OsuCheckbox - { - LabelText = "Prefer no-video downloads", - Bindable = config.GetBindable(OsuConfig.AutomaticDownloadNoVideo) - }, - }; - } - } -} \ No newline at end of file diff --git a/osu.Game/Overlays/Options/Sections/Online/NotificationsOptions.cs b/osu.Game/Overlays/Options/Sections/Online/NotificationsOptions.cs deleted file mode 100644 index 350121db16..0000000000 --- a/osu.Game/Overlays/Options/Sections/Online/NotificationsOptions.cs +++ /dev/null @@ -1,53 +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.Allocation; -using osu.Framework.Graphics; -using osu.Game.Configuration; -using osu.Game.Graphics.UserInterface; - -namespace osu.Game.Overlays.Options.Sections.Online -{ - public class NotificationsOptions : OptionsSubsection - { - protected override string Header => "Notifications"; - - [BackgroundDependencyLoader] - private void load(OsuConfigManager config) - { - Children = new Drawable[] - { - new OsuCheckbox - { - LabelText = "Enable chat ticker", - Bindable = config.GetBindable(OsuConfig.Ticker) - }, - new OsuCheckbox - { - LabelText = "Show a notification popup when someone says your name", - Bindable = config.GetBindable(OsuConfig.ChatHighlightName) - }, - new OsuCheckbox - { - LabelText = "Show chat message notifications", - Bindable = config.GetBindable(OsuConfig.ChatMessageNotification) - }, - new OsuCheckbox - { - LabelText = "Play a sound when someone says your name", - Bindable = config.GetBindable(OsuConfig.ChatAudibleHighlight) - }, - new OsuCheckbox - { - LabelText = "Show notification popups instantly during gameplay", - Bindable = config.GetBindable(OsuConfig.PopupDuringGameplay) - }, - new OsuCheckbox - { - LabelText = "Show notification popups when friends change status", - Bindable = config.GetBindable(OsuConfig.NotifyFriends) - }, - }; - } - } -} \ No newline at end of file diff --git a/osu.Game/Overlays/Options/Sections/Online/PrivacyOptions.cs b/osu.Game/Overlays/Options/Sections/Online/PrivacyOptions.cs deleted file mode 100644 index 5c4d4c3502..0000000000 --- a/osu.Game/Overlays/Options/Sections/Online/PrivacyOptions.cs +++ /dev/null @@ -1,33 +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.Allocation; -using osu.Framework.Graphics; -using osu.Game.Configuration; -using osu.Game.Graphics.UserInterface; - -namespace osu.Game.Overlays.Options.Sections.Online -{ - public class PrivacyOptions : OptionsSubsection - { - protected override string Header => "Privacy"; - - [BackgroundDependencyLoader] - private void load(OsuConfigManager config) - { - Children = new Drawable[] - { - new OsuCheckbox - { - LabelText = "Share your city location with others", - Bindable = config.GetBindable(OsuConfig.DisplayCityLocation) - }, - new OsuCheckbox - { - LabelText = "Allow multiplayer game invites from all users", - Bindable = config.GetBindable(OsuConfig.AllowPublicInvites) - }, - }; - } - } -} \ No newline at end of file diff --git a/osu.Game/Overlays/Options/Sections/OnlineSection.cs b/osu.Game/Overlays/Options/Sections/OnlineSection.cs index a27b00e405..1a65a23121 100644 --- a/osu.Game/Overlays/Options/Sections/OnlineSection.cs +++ b/osu.Game/Overlays/Options/Sections/OnlineSection.cs @@ -3,7 +3,6 @@ using osu.Framework.Graphics; using osu.Game.Graphics; -using osu.Game.Overlays.Options.Sections.Online; namespace osu.Game.Overlays.Options.Sections { @@ -16,10 +15,6 @@ namespace osu.Game.Overlays.Options.Sections { Children = new Drawable[] { - new InGameChatOptions(), - new PrivacyOptions(), - new NotificationsOptions(), - new IntegrationOptions(), }; } } diff --git a/osu.Game/Overlays/Options/Sections/SkinSection.cs b/osu.Game/Overlays/Options/Sections/SkinSection.cs index 0e533928a8..b3c225d00c 100644 --- a/osu.Game/Overlays/Options/Sections/SkinSection.cs +++ b/osu.Game/Overlays/Options/Sections/SkinSection.cs @@ -21,43 +21,6 @@ namespace osu.Game.Overlays.Options.Sections FlowContent.Spacing = new Vector2(0, 5); Children = new Drawable[] { - new OptionLabel { Text = "TODO: Skin preview textures" }, - new OptionLabel { Text = "Current skin: TODO dropdown" }, - new OsuButton - { - RelativeSizeAxes = Axes.X, - Text = "Preview gameplay", - }, - new OsuButton - { - RelativeSizeAxes = Axes.X, - Text = "Open skin folder", - }, - new OsuButton - { - RelativeSizeAxes = Axes.X, - Text = "Export as .osk", - }, - new OsuCheckbox - { - LabelText = "Ignore all beatmap skins", - Bindable = config.GetBindable(OsuConfig.IgnoreBeatmapSkins) - }, - new OsuCheckbox - { - LabelText = "Use skin's sound samples", - Bindable = config.GetBindable(OsuConfig.SkinSamples) - }, - new OsuCheckbox - { - LabelText = "Use Taiko skin for Taiko mode", - Bindable = config.GetBindable(OsuConfig.UseTaikoSkin) - }, - new OsuCheckbox - { - LabelText = "Always use skin cursor", - Bindable = config.GetBindable(OsuConfig.UseSkinCursor) - }, new OptionSlider { LabelText = "Menu cursor size", @@ -68,11 +31,6 @@ namespace osu.Game.Overlays.Options.Sections LabelText = "Gameplay cursor size", Bindable = config.GetBindable(OsuConfig.GameplayCursorSize) }, - new OsuCheckbox - { - LabelText = "Automatic cursor size", - Bindable = config.GetBindable(OsuConfig.AutomaticCursorSizing) - }, }; } diff --git a/osu.Game/Overlays/OptionsOverlay.cs b/osu.Game/Overlays/OptionsOverlay.cs index 0c66cb5881..dcbce80c69 100644 --- a/osu.Game/Overlays/OptionsOverlay.cs +++ b/osu.Game/Overlays/OptionsOverlay.cs @@ -51,7 +51,6 @@ namespace osu.Game.Overlays new AudioSection(), new SkinSection(), new InputSection(), - new EditorSection(), new OnlineSection(), new MaintenanceSection(), new DebugSection(), diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 7b034c2838..4385e737fd 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -356,7 +356,6 @@ - @@ -367,19 +366,12 @@ - - - - - - - From a036b059e8c31e3fd3d5d7984189f3766691e6cb Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 2 May 2017 21:40:06 +0900 Subject: [PATCH 030/329] Use provided parameters to avoid a second lookup. --- osu.Game/Configuration/OsuConfigManager.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 1fcb33b248..2c9574905f 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -24,14 +24,14 @@ namespace osu.Game.Configuration Set(OsuConfig.Username, string.Empty); Set(OsuConfig.Token, string.Empty); - Set(OsuConfig.SavePassword, false).ValueChanged += delegate + Set(OsuConfig.SavePassword, false).ValueChanged += val => { - if (Get(OsuConfig.SavePassword)) Set(OsuConfig.SaveUsername, true); + if (val) Set(OsuConfig.SaveUsername, true); }; - Set(OsuConfig.SaveUsername, true).ValueChanged += delegate + Set(OsuConfig.SaveUsername, true).ValueChanged += val => { - if (!Get(OsuConfig.SaveUsername)) Set(OsuConfig.SavePassword, false); + if (!val) Set(OsuConfig.SavePassword, false); }; // Audio From 00a8dbbacfa3d1bd1a40379e388c8f5e2f0af2ec Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Tue, 2 May 2017 21:36:55 +0300 Subject: [PATCH 031/329] 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 032/329] 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 033/329] 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 034/329] 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 035/329] 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 60c2e2a90af53a2315cab5cc8a6603a03df7f8fd Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 3 May 2017 11:22:09 +0900 Subject: [PATCH 036/329] Fix taiko auto replay generation not working. --- osu.Game.Rulesets.Taiko/Mods/TaikoMod.cs | 2 +- .../{TaikoAutoReplay.cs => TaikoAutoGenerator.cs} | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) rename osu.Game.Rulesets.Taiko/Replays/{TaikoAutoReplay.cs => TaikoAutoGenerator.cs} (90%) diff --git a/osu.Game.Rulesets.Taiko/Mods/TaikoMod.cs b/osu.Game.Rulesets.Taiko/Mods/TaikoMod.cs index 44430fe6bc..8b7a099b9a 100644 --- a/osu.Game.Rulesets.Taiko/Mods/TaikoMod.cs +++ b/osu.Game.Rulesets.Taiko/Mods/TaikoMod.cs @@ -72,7 +72,7 @@ namespace osu.Game.Rulesets.Taiko.Mods protected override Score CreateReplayScore(Beatmap beatmap) => new Score { User = new User { Username = "mekkadosu!" }, - Replay = new TaikoAutoReplay(beatmap).Generate(), + Replay = new TaikoAutoGenerator(beatmap).Generate(), }; } } diff --git a/osu.Game.Rulesets.Taiko/Replays/TaikoAutoReplay.cs b/osu.Game.Rulesets.Taiko/Replays/TaikoAutoGenerator.cs similarity index 90% rename from osu.Game.Rulesets.Taiko/Replays/TaikoAutoReplay.cs rename to osu.Game.Rulesets.Taiko/Replays/TaikoAutoGenerator.cs index 0af8e2822b..eec614426f 100644 --- a/osu.Game.Rulesets.Taiko/Replays/TaikoAutoReplay.cs +++ b/osu.Game.Rulesets.Taiko/Replays/TaikoAutoGenerator.cs @@ -7,16 +7,24 @@ using osu.Game.Beatmaps; using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Taiko.Objects; using osu.Game.Rulesets.Replays; +using osu.Game.Users; namespace osu.Game.Rulesets.Taiko.Replays { - public class TaikoAutoReplay : AutoGenerator + public class TaikoAutoGenerator : AutoGenerator { private const double swell_hit_speed = 50; - public TaikoAutoReplay(Beatmap beatmap) + public TaikoAutoGenerator(Beatmap beatmap) : base(beatmap) { + Replay = new Replay + { + User = new User + { + Username = @"Autoplay", + } + }; } protected Replay Replay; From 4d27e0abb6140107f5a6710db082a37011d235f2 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 3 May 2017 11:25:54 +0900 Subject: [PATCH 037/329] Oops i didn't save the solution. --- osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj b/osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj index f890e32f90..983dc72d9e 100644 --- a/osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj +++ b/osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj @@ -79,7 +79,7 @@ - + From b4052a099f3d27bab3597a2e4ea068ae3f5c26fe Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 3 May 2017 12:30:03 +0900 Subject: [PATCH 038/329] Create ManiaPlayfield, support up to 9 columns, improve testcase automation. --- .../Tests/TestCaseManiaPlayfield.cs | 147 ++++++++++++------ 1 file changed, 100 insertions(+), 47 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs index 9ee09883aa..89d4d5cc22 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs @@ -18,6 +18,9 @@ using osu.Game.Graphics; using osu.Framework.Graphics.Primitives; using osu.Framework.Input; using OpenTK.Input; +using osu.Game.Rulesets.UI; +using osu.Framework.Allocation; +using osu.Framework.Extensions.IEnumerableExtensions; namespace osu.Desktop.VisualTests.Tests { @@ -25,69 +28,119 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Mania playfield"; - private FlowContainer columns; + protected override double TimePerAction => 200; public override void Reset() { base.Reset(); - Add(new Container - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.Y, - AutoSizeAxes = Axes.X, - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black - }, - columns = new FillFlowContainer - { - RelativeSizeAxes = Axes.Y, - AutoSizeAxes = Axes.X, - Direction = FillDirection.Horizontal, - Padding = new MarginPadding { Left = 1, Right = 1 }, - Spacing = new Vector2(1, 0) - } - } - }); + int max_columns = 9; - var colours = new Color4[] + for (int i = 1; i <= max_columns; i++) { - new Color4(187, 17, 119, 255), - new Color4(96, 204, 0, 255), - new Color4(17, 136, 170, 255) + int tempI = i; + + AddStep($@"{i} column" + (i > 1 ? "s" : ""), () => + { + Clear(); + Add(new ManiaPlayfield(tempI) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre + }); + }); + + AddStep($"Trigger keys down", () => ((ManiaPlayfield)Children.First()).Columns.Children.ForEach(triggerKeyDown)); + AddStep($"Trigger keys up", () => ((ManiaPlayfield)Children.First()).Columns.Children.ForEach(triggerKeyUp)); + } + } + + private void triggerKeyDown(Column column) + { + column.TriggerKeyDown(new InputState(), new KeyDownEventArgs + { + Key = column.Key, + Repeat = false + }); + } + + private void triggerKeyUp(Column column) + { + column.TriggerKeyUp(new InputState(), new KeyUpEventArgs + { + Key = column.Key + }); + } + } + + public class ManiaPlayfield : Container + { + public readonly FlowContainer Columns; + + public ManiaPlayfield(int columnCount) + { + if (columnCount > 9) + throw new ArgumentException($@"{columnCount} columns is not supported."); + if (columnCount <= 0) + throw new ArgumentException($@"Can't have zero or fewer columns."); + + RelativeSizeAxes = Axes.Y; + AutoSizeAxes = Axes.X; + + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black + }, + Columns = new FillFlowContainer + { + RelativeSizeAxes = Axes.Y, + AutoSizeAxes = Axes.X, + Direction = FillDirection.Horizontal, + Padding = new MarginPadding { Left = 1, Right = 1 }, + Spacing = new Vector2(1, 0) + } }; - var keys = new Key[] { Key.S, Key.D, Key.F, Key.Space, Key.J, Key.K, Key.L }; + for (int i = 0; i < columnCount; i++) + Columns.Add(new Column()); + } - int num_columns = 7; - int half_columns = num_columns / 2; - - for (int i = 0; i < num_columns; i++) + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + var columnColours = new Color4[] { - columns.Add(new Column - { - Key = keys[i] - }); + colours.RedDark, + colours.GreenDark, + colours.BlueDark // Special column + }; + + int columnCount = Columns.Children.Count(); + int halfColumns = columnCount / 2; + + var keys = new Key[] { Key.A, Key.S, Key.D, Key.F, Key.Space, Key.J, Key.K, Key.L, Key.Semicolon }; + + for (int i = 0; i < halfColumns; i++) + { + Column leftColumn = Columns.Children.ElementAt(i); + Column rightColumn = Columns.Children.ElementAt(columnCount - 1 - i); + + Color4 accent = columnColours[i % 2]; + leftColumn.AccentColour = rightColumn.AccentColour = accent; + leftColumn.Key = keys[keys.Length / 2 - halfColumns + i]; + rightColumn.Key = keys[keys.Length / 2 + halfColumns - i]; } - for (int i = 0; i < half_columns; i++) - { - Color4 accent = colours[i % 2]; - columns.Children.ElementAt(i).AccentColour = accent; - columns.Children.ElementAt(num_columns - 1 - i).AccentColour = accent; - } - - bool hasSpecial = half_columns * 2 < num_columns; + bool hasSpecial = halfColumns * 2 < columnCount; if (hasSpecial) { - Column specialColumn = columns.Children.ElementAt(half_columns); + Column specialColumn = Columns.Children.ElementAt(halfColumns); specialColumn.IsSpecialColumn = true; - specialColumn.AccentColour = colours[2]; + specialColumn.AccentColour = columnColours[2]; + specialColumn.Key = keys[keys.Length / 2]; } } } From 71acf1c57dd0439796ebdb22bd983c7788f26190 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 3 May 2017 12:37:47 +0900 Subject: [PATCH 039/329] Move classes out of test case. --- .../Tests/TestCaseManiaPlayfield.cs | 259 +----------------- osu.Game.Rulesets.Mania/UI/Column.cs | 204 ++++++++++++++ osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 89 +++++- .../osu.Game.Rulesets.Mania.csproj | 1 + 4 files changed, 282 insertions(+), 271 deletions(-) create mode 100644 osu.Game.Rulesets.Mania/UI/Column.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs index 89d4d5cc22..62abc865a1 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs @@ -21,6 +21,7 @@ using OpenTK.Input; using osu.Game.Rulesets.UI; using osu.Framework.Allocation; using osu.Framework.Extensions.IEnumerableExtensions; +using osu.Game.Rulesets.Mania.UI; namespace osu.Desktop.VisualTests.Tests { @@ -72,262 +73,4 @@ namespace osu.Desktop.VisualTests.Tests }); } } - - public class ManiaPlayfield : Container - { - public readonly FlowContainer Columns; - - public ManiaPlayfield(int columnCount) - { - if (columnCount > 9) - throw new ArgumentException($@"{columnCount} columns is not supported."); - if (columnCount <= 0) - throw new ArgumentException($@"Can't have zero or fewer columns."); - - RelativeSizeAxes = Axes.Y; - AutoSizeAxes = Axes.X; - - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black - }, - Columns = new FillFlowContainer - { - RelativeSizeAxes = Axes.Y, - AutoSizeAxes = Axes.X, - Direction = FillDirection.Horizontal, - Padding = new MarginPadding { Left = 1, Right = 1 }, - Spacing = new Vector2(1, 0) - } - }; - - for (int i = 0; i < columnCount; i++) - Columns.Add(new Column()); - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - var columnColours = new Color4[] - { - colours.RedDark, - colours.GreenDark, - colours.BlueDark // Special column - }; - - int columnCount = Columns.Children.Count(); - int halfColumns = columnCount / 2; - - var keys = new Key[] { Key.A, Key.S, Key.D, Key.F, Key.Space, Key.J, Key.K, Key.L, Key.Semicolon }; - - for (int i = 0; i < halfColumns; i++) - { - Column leftColumn = Columns.Children.ElementAt(i); - Column rightColumn = Columns.Children.ElementAt(columnCount - 1 - i); - - Color4 accent = columnColours[i % 2]; - leftColumn.AccentColour = rightColumn.AccentColour = accent; - leftColumn.Key = keys[keys.Length / 2 - halfColumns + i]; - rightColumn.Key = keys[keys.Length / 2 + halfColumns - i]; - } - - bool hasSpecial = halfColumns * 2 < columnCount; - if (hasSpecial) - { - Column specialColumn = Columns.Children.ElementAt(halfColumns); - specialColumn.IsSpecialColumn = true; - specialColumn.AccentColour = columnColours[2]; - specialColumn.Key = keys[keys.Length / 2]; - } - } - } - - public class Column : Container, IHasAccentColour - { - private const float key_size = 50; - - private const float key_icon_size = 10; - private const float key_icon_corner_radius = 3; - private const float key_icon_border_radius = 2; - - private const float hit_target_height = 10; - private const float hit_target_bar_height = 2; - - private const float column_width = 45; - private const float special_column_width = 70; - - private Color4 accentColour; - public Color4 AccentColour - { - get { return accentColour; } - set - { - if (accentColour == value) - return; - accentColour = value; - - setAccentColour(); - } - } - - private bool isSpecialColumn; - public bool IsSpecialColumn - { - get { return isSpecialColumn; } - set - { - isSpecialColumn = value; - Width = isSpecialColumn ? special_column_width : column_width; - } - } - - public Key Key; - - private Box background; - private Container hitTargetBar; - private Container keyIcon; - - public Column() - { - RelativeSizeAxes = Axes.Y; - Width = column_width; - - Children = new Drawable[] - { - background = new Box - { - Name = "Foreground", - RelativeSizeAxes = Axes.Both, - Alpha = 0.2f - }, - new FillFlowContainer - { - Name = "Key + hit target", - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Direction = FillDirection.Vertical, - Children = new[] - { - new Container - { - Name = "Key", - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, - RelativeSizeAxes = Axes.X, - Height = key_size, - Children = new Drawable[] - { - new Box - { - Name = "Key gradient", - RelativeSizeAxes = Axes.Both, - ColourInfo = ColourInfo.GradientVertical(Color4.Black, Color4.Black.Opacity(0)), - Alpha = 0.5f - }, - keyIcon = new Container - { - Name = "Key icon", - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Size = new Vector2(key_icon_size), - Masking = true, - CornerRadius = key_icon_corner_radius, - BorderThickness = 2, - BorderColour = Color4.White, // Not true - Children = new[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Alpha = 0, - AlwaysPresent = true - } - } - } - } - }, - new Container - { - Name = "Hit target", - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, - RelativeSizeAxes = Axes.X, - Height = hit_target_height, - Children = new Drawable[] - { - new Box - { - Name = "Background", - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black - }, - hitTargetBar = new Container - { - Name = "Bar", - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, - RelativeSizeAxes = Axes.X, - Height = hit_target_bar_height, - Masking = true, - Children = new[] - { - new Box - { - RelativeSizeAxes = Axes.Both - } - } - } - } - } - } - } - }; - } - - private void setAccentColour() - { - background.Colour = AccentColour; - - hitTargetBar.EdgeEffect = new EdgeEffect - { - Type = EdgeEffectType.Glow, - Radius = 5, - Colour = AccentColour.Opacity(0.5f), - }; - - keyIcon.EdgeEffect = new EdgeEffect - { - Type = EdgeEffectType.Glow, - Radius = 5, - Colour = AccentColour.Opacity(0.5f), - }; - } - - protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) - { - if (args.Key == Key && !args.Repeat) - { - background.FadeTo(background.Alpha + 0.2f, 50, EasingTypes.OutQuint); - keyIcon.ScaleTo(1.4f, 50, EasingTypes.OutQuint); - } - - return false; - } - - protected override bool OnKeyUp(InputState state, KeyUpEventArgs args) - { - if (args.Key == Key) - { - background.FadeTo(0.2f, 800, EasingTypes.OutQuart); - keyIcon.ScaleTo(1f, 400, EasingTypes.OutQuart); - } - - return false; - } - } } diff --git a/osu.Game.Rulesets.Mania/UI/Column.cs b/osu.Game.Rulesets.Mania/UI/Column.cs new file mode 100644 index 0000000000..584dfdd09c --- /dev/null +++ b/osu.Game.Rulesets.Mania/UI/Column.cs @@ -0,0 +1,204 @@ +// 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 OpenTK.Input; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Colour; +using osu.Framework.Input; +using osu.Game.Graphics; + +namespace osu.Game.Rulesets.Mania.UI +{ + public class Column : Container, IHasAccentColour + { + private const float key_size = 50; + + private const float key_icon_size = 10; + private const float key_icon_corner_radius = 3; + private const float key_icon_border_radius = 2; + + private const float hit_target_height = 10; + private const float hit_target_bar_height = 2; + + private const float column_width = 45; + private const float special_column_width = 70; + + private Color4 accentColour; + public Color4 AccentColour + { + get { return accentColour; } + set + { + if (accentColour == value) + return; + accentColour = value; + + setAccentColour(); + } + } + + private bool isSpecialColumn; + public bool IsSpecialColumn + { + get { return isSpecialColumn; } + set + { + isSpecialColumn = value; + Width = isSpecialColumn ? special_column_width : column_width; + } + } + + public Key Key; + + private Box background; + private Container hitTargetBar; + private Container keyIcon; + + public Column() + { + RelativeSizeAxes = Axes.Y; + Width = column_width; + + Children = new Drawable[] + { + background = new Box + { + Name = "Foreground", + RelativeSizeAxes = Axes.Both, + Alpha = 0.2f + }, + new FillFlowContainer + { + Name = "Key + hit target", + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Children = new[] + { + new Container + { + Name = "Key", + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + RelativeSizeAxes = Axes.X, + Height = key_size, + Children = new Drawable[] + { + new Box + { + Name = "Key gradient", + RelativeSizeAxes = Axes.Both, + ColourInfo = ColourInfo.GradientVertical(Color4.Black, Color4.Black.Opacity(0)), + Alpha = 0.5f + }, + keyIcon = new Container + { + Name = "Key icon", + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(key_icon_size), + Masking = true, + CornerRadius = key_icon_corner_radius, + BorderThickness = 2, + BorderColour = Color4.White, // Not true + Children = new[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Alpha = 0, + AlwaysPresent = true + } + } + } + } + }, + new Container + { + Name = "Hit target", + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + RelativeSizeAxes = Axes.X, + Height = hit_target_height, + Children = new Drawable[] + { + new Box + { + Name = "Background", + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black + }, + hitTargetBar = new Container + { + Name = "Bar", + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + RelativeSizeAxes = Axes.X, + Height = hit_target_bar_height, + Masking = true, + Children = new[] + { + new Box + { + RelativeSizeAxes = Axes.Both + } + } + } + } + } + } + } + }; + } + + private void setAccentColour() + { + background.Colour = AccentColour; + + hitTargetBar.EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Glow, + Radius = 5, + Colour = AccentColour.Opacity(0.5f), + }; + + keyIcon.EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Glow, + Radius = 5, + Colour = AccentColour.Opacity(0.5f), + }; + } + + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + if (args.Key == Key && !args.Repeat) + { + background.FadeTo(background.Alpha + 0.2f, 50, EasingTypes.OutQuint); + keyIcon.ScaleTo(1.4f, 50, EasingTypes.OutQuint); + } + + return false; + } + + protected override bool OnKeyUp(InputState state, KeyUpEventArgs args) + { + if (args.Key == Key) + { + background.FadeTo(0.2f, 800, EasingTypes.OutQuart); + keyIcon.ScaleTo(1f, 400, EasingTypes.OutQuart); + } + + return false; + } + } + +} diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index 5eea3d70c0..0b7b1df06d 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -8,29 +8,92 @@ using osu.Game.Rulesets.UI; using OpenTK; using OpenTK.Graphics; using osu.Game.Rulesets.Mania.Judgements; +using osu.Framework.Graphics.Containers; +using System; +using osu.Framework.Graphics.Primitives; +using osu.Game.Graphics; +using osu.Framework.Allocation; +using OpenTK.Input; +using System.Linq; namespace osu.Game.Rulesets.Mania.UI { public class ManiaPlayfield : Playfield { + public readonly FlowContainer Columns; + public ManiaPlayfield(int columns) { - Size = new Vector2(0.8f, 1f); - Anchor = Anchor.BottomCentre; - Origin = Anchor.BottomCentre; + if (columns > 9) + throw new ArgumentException($@"{columns} columns is not supported."); + if (columns <= 0) + throw new ArgumentException($@"Can't have zero or fewer columns."); - Add(new Box { RelativeSizeAxes = Axes.Both, Alpha = 0.5f }); + Children = new Drawable[] + { + new Container + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Y, + AutoSizeAxes = Axes.X, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black + }, + Columns = new FillFlowContainer + { + RelativeSizeAxes = Axes.Y, + AutoSizeAxes = Axes.X, + Direction = FillDirection.Horizontal, + Padding = new MarginPadding { Left = 1, Right = 1 }, + Spacing = new Vector2(1, 0) + } + } + } + }; for (int i = 0; i < columns; i++) - Add(new Box - { - RelativeSizeAxes = Axes.Y, - Size = new Vector2(2, 1), - RelativePositionAxes = Axes.Both, - Position = new Vector2((float)i / columns, 0), - Alpha = 0.5f, - Colour = Color4.Black - }); + Columns.Add(new Column()); + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + var columnColours = new Color4[] + { + colours.RedDark, + colours.GreenDark, + colours.BlueDark // Special column + }; + + int columnCount = Columns.Children.Count(); + int halfColumns = columnCount / 2; + + var keys = new Key[] { Key.A, Key.S, Key.D, Key.F, Key.Space, Key.J, Key.K, Key.L, Key.Semicolon }; + + for (int i = 0; i < halfColumns; i++) + { + Column leftColumn = Columns.Children.ElementAt(i); + Column rightColumn = Columns.Children.ElementAt(columnCount - 1 - i); + + Color4 accent = columnColours[i % 2]; + leftColumn.AccentColour = rightColumn.AccentColour = accent; + leftColumn.Key = keys[keys.Length / 2 - halfColumns + i]; + rightColumn.Key = keys[keys.Length / 2 + halfColumns - i]; + } + + bool hasSpecial = halfColumns * 2 < columnCount; + if (hasSpecial) + { + Column specialColumn = Columns.Children.ElementAt(halfColumns); + specialColumn.IsSpecialColumn = true; + specialColumn.AccentColour = columnColours[2]; + specialColumn.Key = keys[keys.Length / 2]; + } } } } \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index facffa757c..18ea1de13a 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -56,6 +56,7 @@ + From 64c677a29dc43ef0a32266b02833ec2d673c5e75 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 3 May 2017 12:42:37 +0900 Subject: [PATCH 040/329] Add IHasColumn. --- osu.Game.Rulesets.Mania/Objects/IHasColumn.cs | 11 +++++++++++ .../osu.Game.Rulesets.Mania.csproj | 1 + 2 files changed, 12 insertions(+) create mode 100644 osu.Game.Rulesets.Mania/Objects/IHasColumn.cs diff --git a/osu.Game.Rulesets.Mania/Objects/IHasColumn.cs b/osu.Game.Rulesets.Mania/Objects/IHasColumn.cs new file mode 100644 index 0000000000..daf7d217cd --- /dev/null +++ b/osu.Game.Rulesets.Mania/Objects/IHasColumn.cs @@ -0,0 +1,11 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + + +namespace osu.Game.Rulesets.Mania.Objects +{ + public interface IHasColumn + { + int Column { get; } + } +} diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index facffa757c..bc23661981 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -50,6 +50,7 @@ + From 53287936939e0a111c7dae0b8bebfa6b9f691d37 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 3 May 2017 12:44:19 +0900 Subject: [PATCH 041/329] ManiaBaseHit -> ManiaHitObject. --- osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs | 4 ++-- osu.Game.Rulesets.Mania/ManiaDifficultyCalculator.cs | 4 ++-- osu.Game.Rulesets.Mania/Objects/Drawable/DrawableNote.cs | 4 ++-- .../Objects/{ManiaBaseHit.cs => ManiaHitObject.cs} | 4 ++-- osu.Game.Rulesets.Mania/Objects/Note.cs | 2 +- osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs | 4 ++-- osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs | 8 ++++---- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 2 +- osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj | 2 +- 9 files changed, 17 insertions(+), 17 deletions(-) rename osu.Game.Rulesets.Mania/Objects/{ManiaBaseHit.cs => ManiaHitObject.cs} (67%) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs index 847af965cc..10bebbdba7 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs @@ -11,11 +11,11 @@ using osu.Game.Rulesets.Objects; namespace osu.Game.Rulesets.Mania.Beatmaps { - internal class ManiaBeatmapConverter : BeatmapConverter + internal class ManiaBeatmapConverter : BeatmapConverter { protected override IEnumerable ValidConversionTypes { get; } = new[] { typeof(IHasXPosition) }; - protected override IEnumerable ConvertHitObject(HitObject original, Beatmap beatmap) + protected override IEnumerable ConvertHitObject(HitObject original, Beatmap beatmap) { yield return null; } diff --git a/osu.Game.Rulesets.Mania/ManiaDifficultyCalculator.cs b/osu.Game.Rulesets.Mania/ManiaDifficultyCalculator.cs index e9bcc60d2c..aaba4d94f0 100644 --- a/osu.Game.Rulesets.Mania/ManiaDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Mania/ManiaDifficultyCalculator.cs @@ -9,7 +9,7 @@ using System.Collections.Generic; namespace osu.Game.Rulesets.Mania { - public class ManiaDifficultyCalculator : DifficultyCalculator + public class ManiaDifficultyCalculator : DifficultyCalculator { public ManiaDifficultyCalculator(Beatmap beatmap) : base(beatmap) @@ -21,6 +21,6 @@ namespace osu.Game.Rulesets.Mania return 0; } - protected override BeatmapConverter CreateBeatmapConverter() => new ManiaBeatmapConverter(); + protected override BeatmapConverter CreateBeatmapConverter() => new ManiaBeatmapConverter(); } } \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/Objects/Drawable/DrawableNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawable/DrawableNote.cs index 07a27b1643..72d1e5314b 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawable/DrawableNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawable/DrawableNote.cs @@ -12,9 +12,9 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawable { public class DrawableNote : Sprite { - private readonly ManiaBaseHit note; + private readonly ManiaHitObject note; - public DrawableNote(ManiaBaseHit note) + public DrawableNote(ManiaHitObject note) { this.note = note; Origin = Anchor.Centre; diff --git a/osu.Game.Rulesets.Mania/Objects/ManiaBaseHit.cs b/osu.Game.Rulesets.Mania/Objects/ManiaHitObject.cs similarity index 67% rename from osu.Game.Rulesets.Mania/Objects/ManiaBaseHit.cs rename to osu.Game.Rulesets.Mania/Objects/ManiaHitObject.cs index 4c15b69eb7..e991c1ad93 100644 --- a/osu.Game.Rulesets.Mania/Objects/ManiaBaseHit.cs +++ b/osu.Game.Rulesets.Mania/Objects/ManiaHitObject.cs @@ -5,8 +5,8 @@ using osu.Game.Rulesets.Objects; namespace osu.Game.Rulesets.Mania.Objects { - public abstract class ManiaBaseHit : HitObject + public abstract class ManiaHitObject : HitObject, IHasColumn { - public int Column; + public int Column { get; set; } } } diff --git a/osu.Game.Rulesets.Mania/Objects/Note.cs b/osu.Game.Rulesets.Mania/Objects/Note.cs index 5a6d6003db..2cc993df64 100644 --- a/osu.Game.Rulesets.Mania/Objects/Note.cs +++ b/osu.Game.Rulesets.Mania/Objects/Note.cs @@ -3,7 +3,7 @@ namespace osu.Game.Rulesets.Mania.Objects { - public class Note : ManiaBaseHit + public class Note : ManiaHitObject { } } diff --git a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs index ba0304a44a..96f04f79d4 100644 --- a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs +++ b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs @@ -8,13 +8,13 @@ using osu.Game.Rulesets.UI; namespace osu.Game.Rulesets.Mania.Scoring { - internal class ManiaScoreProcessor : ScoreProcessor + internal class ManiaScoreProcessor : ScoreProcessor { public ManiaScoreProcessor() { } - public ManiaScoreProcessor(HitRenderer hitRenderer) + public ManiaScoreProcessor(HitRenderer hitRenderer) : base(hitRenderer) { } diff --git a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs index 7fb8f95b4c..c007cdc80e 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs @@ -13,7 +13,7 @@ using osu.Game.Rulesets.UI; namespace osu.Game.Rulesets.Mania.UI { - public class ManiaHitRenderer : HitRenderer + public class ManiaHitRenderer : HitRenderer { private readonly int columns; @@ -25,10 +25,10 @@ namespace osu.Game.Rulesets.Mania.UI public override ScoreProcessor CreateScoreProcessor() => new ManiaScoreProcessor(this); - protected override BeatmapConverter CreateBeatmapConverter() => new ManiaBeatmapConverter(); + protected override BeatmapConverter CreateBeatmapConverter() => new ManiaBeatmapConverter(); - protected override Playfield CreatePlayfield() => new ManiaPlayfield(columns); + protected override Playfield CreatePlayfield() => new ManiaPlayfield(columns); - protected override DrawableHitObject GetVisualRepresentation(ManiaBaseHit h) => null; + protected override DrawableHitObject GetVisualRepresentation(ManiaHitObject h) => null; } } diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index 5eea3d70c0..00f62b9869 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -11,7 +11,7 @@ using osu.Game.Rulesets.Mania.Judgements; namespace osu.Game.Rulesets.Mania.UI { - public class ManiaPlayfield : Playfield + public class ManiaPlayfield : Playfield { public ManiaPlayfield(int columns) { diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index bc23661981..49331bf598 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -54,7 +54,7 @@ - + From 7de36b7aa27db5c0c07a75d8516019839c820698 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 3 May 2017 12:58:46 +0900 Subject: [PATCH 042/329] CI cleanups. --- .../Tests/TestCaseManiaPlayfield.cs | 31 +++++-------------- osu.Game.Rulesets.Mania/UI/Column.cs | 6 ++-- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 8 ++--- 3 files changed, 15 insertions(+), 30 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs index 62abc865a1..4c7433ff5a 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs @@ -1,27 +1,12 @@ // 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 osu.Framework.Extensions.Color4Extensions; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Colour; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using osu.Framework.Testing; -using osu.Game.Graphics; -using osu.Framework.Graphics.Primitives; -using osu.Framework.Input; -using OpenTK.Input; -using osu.Game.Rulesets.UI; -using osu.Framework.Allocation; using osu.Framework.Extensions.IEnumerableExtensions; +using osu.Framework.Input; +using osu.Framework.Testing; +using osu.Framework.Graphics; using osu.Game.Rulesets.Mania.UI; +using System.Linq; namespace osu.Desktop.VisualTests.Tests { @@ -35,13 +20,13 @@ namespace osu.Desktop.VisualTests.Tests { base.Reset(); - int max_columns = 9; + const int max_columns = 9; for (int i = 1; i <= max_columns; i++) { int tempI = i; - AddStep($@"{i} column" + (i > 1 ? "s" : ""), () => + AddStep($"{i} column" + (i > 1 ? "s" : ""), () => { Clear(); Add(new ManiaPlayfield(tempI) @@ -51,8 +36,8 @@ namespace osu.Desktop.VisualTests.Tests }); }); - AddStep($"Trigger keys down", () => ((ManiaPlayfield)Children.First()).Columns.Children.ForEach(triggerKeyDown)); - AddStep($"Trigger keys up", () => ((ManiaPlayfield)Children.First()).Columns.Children.ForEach(triggerKeyUp)); + AddStep("Trigger keys down", () => ((ManiaPlayfield)Children.First()).Columns.Children.ForEach(triggerKeyDown)); + AddStep("Trigger keys up", () => ((ManiaPlayfield)Children.First()).Columns.Children.ForEach(triggerKeyUp)); } } diff --git a/osu.Game.Rulesets.Mania/UI/Column.cs b/osu.Game.Rulesets.Mania/UI/Column.cs index 584dfdd09c..75ae529c4c 100644 --- a/osu.Game.Rulesets.Mania/UI/Column.cs +++ b/osu.Game.Rulesets.Mania/UI/Column.cs @@ -56,9 +56,9 @@ namespace osu.Game.Rulesets.Mania.UI public Key Key; - private Box background; - private Container hitTargetBar; - private Container keyIcon; + private readonly Box background; + private readonly Container hitTargetBar; + private readonly Container keyIcon; public Column() { diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index 0b7b1df06d..08ac4c4a3b 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -25,9 +25,9 @@ namespace osu.Game.Rulesets.Mania.UI public ManiaPlayfield(int columns) { if (columns > 9) - throw new ArgumentException($@"{columns} columns is not supported."); + throw new ArgumentException($"{columns} columns is not supported."); if (columns <= 0) - throw new ArgumentException($@"Can't have zero or fewer columns."); + throw new ArgumentException("Can't have zero or fewer columns."); Children = new Drawable[] { @@ -63,7 +63,7 @@ namespace osu.Game.Rulesets.Mania.UI [BackgroundDependencyLoader] private void load(OsuColour colours) { - var columnColours = new Color4[] + Color4[] columnColours = new[] { colours.RedDark, colours.GreenDark, @@ -73,7 +73,7 @@ namespace osu.Game.Rulesets.Mania.UI int columnCount = Columns.Children.Count(); int halfColumns = columnCount / 2; - var keys = new Key[] { Key.A, Key.S, Key.D, Key.F, Key.Space, Key.J, Key.K, Key.L, Key.Semicolon }; + Key[] keys = new[] { Key.A, Key.S, Key.D, Key.F, Key.Space, Key.J, Key.K, Key.L, Key.Semicolon }; for (int i = 0; i < halfColumns; i++) { From d21c3358b9839086d863fb7c22d2c5890b195524 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Wed, 3 May 2017 13:03:46 +0900 Subject: [PATCH 043/329] Less array explicivity. --- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index 08ac4c4a3b..112f91181d 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -63,7 +63,7 @@ namespace osu.Game.Rulesets.Mania.UI [BackgroundDependencyLoader] private void load(OsuColour colours) { - Color4[] columnColours = new[] + var columnColours = new[] { colours.RedDark, colours.GreenDark, @@ -73,7 +73,7 @@ namespace osu.Game.Rulesets.Mania.UI int columnCount = Columns.Children.Count(); int halfColumns = columnCount / 2; - Key[] keys = new[] { Key.A, Key.S, Key.D, Key.F, Key.Space, Key.J, Key.K, Key.L, Key.Semicolon }; + var keys = new[] { Key.A, Key.S, Key.D, Key.F, Key.Space, Key.J, Key.K, Key.L, Key.Semicolon }; for (int i = 0; i < halfColumns; i++) { @@ -96,4 +96,4 @@ namespace osu.Game.Rulesets.Mania.UI } } } -} \ No newline at end of file +} From d11e5d0060f88b6fd78a1dcad7d5ac1e9280b512 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 3 May 2017 12:53:45 +0900 Subject: [PATCH 044/329] Add hit windows to Note/HoldNote. --- .../Judgements/HitWindows.cs | 162 ++++++++++++++++++ osu.Game.Rulesets.Mania/Objects/HoldNote.cs | 23 ++- .../Objects/ManiaHitObject.cs | 1 + osu.Game.Rulesets.Mania/Objects/Note.cs | 12 ++ .../Objects/{ => Types}/IHasColumn.cs | 2 +- .../osu.Game.Rulesets.Mania.csproj | 3 +- 6 files changed, 200 insertions(+), 3 deletions(-) create mode 100644 osu.Game.Rulesets.Mania/Judgements/HitWindows.cs rename osu.Game.Rulesets.Mania/Objects/{ => Types}/IHasColumn.cs (79%) diff --git a/osu.Game.Rulesets.Mania/Judgements/HitWindows.cs b/osu.Game.Rulesets.Mania/Judgements/HitWindows.cs new file mode 100644 index 0000000000..a1354314bf --- /dev/null +++ b/osu.Game.Rulesets.Mania/Judgements/HitWindows.cs @@ -0,0 +1,162 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Database; + +namespace osu.Game.Rulesets.Mania.Judgements +{ + public class HitWindows + { + #region Constants + + /// + /// PERFECT hit window at OD = 10. + /// + private const double perfect_min = 27.8; + /// + /// PERFECT hit window at OD = 5. + /// + private const double perfect_mid = 38.8; + /// + /// PERFECT hit window at OD = 0. + /// + private const double perfect_max = 44.8; + + /// + /// GREAT hit window at OD = 10. + /// + private const double great_min = 68; + /// + /// GREAT hit window at OD = 5. + /// + private const double great_mid = 98; + /// + /// GREAT hit window at OD = 0. + /// + private const double great_max = 128; + + /// + /// GOOD hit window at OD = 10. + /// + private const double good_min = 134; + /// + /// GOOD hit window at OD = 5. + /// + private const double good_mid = 164; + /// + /// GOOD hit window at OD = 0. + /// + private const double good_max = 194; + + /// + /// OK hit window at OD = 10. + /// + private const double ok_min = 194; + /// + /// OK hit window at OD = 5. + /// + private const double ok_mid = 224; + /// + /// OK hit window at OD = 0. + /// + private const double ok_max = 254; + + /// + /// BAD hit window at OD = 10. + /// + private const double bad_min = 242; + /// + /// BAD hit window at OD = 5. + /// + private const double bad_mid = 272; + /// + /// BAD hit window at OD = 0. + /// + private const double bad_max = 302; + + /// + /// MISS hit window at OD = 10. + /// + private const double miss_min = 316; + /// + /// MISS hit window at OD = 5. + /// + private const double miss_mid = 346; + /// + /// MISS hit window at OD = 0. + /// + private const double miss_max = 376; + + #endregion + + /// + /// Hit window for a PERFECT hit. + /// + public double Perfect = perfect_mid; + + /// + /// Hit window for a GREAT hit. + /// + public double Great = great_mid; + + /// + /// Hit window for a GOOD hit. + /// + public double Good = good_mid; + + /// + /// Hit window for an OK hit. + /// + public double Ok = ok_mid; + + /// + /// Hit window for a BAD hit. + /// + public double Bad = bad_mid; + + /// + /// Hit window for a MISS hit. + /// + public double Miss = miss_mid; + + public HitWindows() + { + } + + public HitWindows(double difficulty) + { + Perfect = BeatmapDifficulty.DifficultyRange(difficulty, perfect_max, perfect_mid, perfect_min); + Great = BeatmapDifficulty.DifficultyRange(difficulty, great_max, great_mid, great_min); + Good = BeatmapDifficulty.DifficultyRange(difficulty, good_max, good_mid, good_min); + Ok = BeatmapDifficulty.DifficultyRange(difficulty, ok_max, ok_mid, ok_min); + Bad = BeatmapDifficulty.DifficultyRange(difficulty, bad_max, bad_mid, bad_min); + Miss = BeatmapDifficulty.DifficultyRange(difficulty, miss_max, miss_mid, miss_min); + } + + public static HitWindows operator *(HitWindows windows, double value) + { + return new HitWindows + { + Perfect = windows.Perfect * value, + Great = windows.Great * value, + Good = windows.Good * value, + Ok = windows.Ok * value, + Bad = windows.Bad * value, + Miss = windows.Miss * value + }; + } + + public static HitWindows operator /(HitWindows windows, double value) + { + return new HitWindows + { + Perfect = windows.Perfect / value, + Great = windows.Great / value, + Good = windows.Good / value, + Ok = windows.Ok / value, + Bad = windows.Bad / value, + Miss = windows.Miss / value + }; + } + } +} diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs index e8ce1da77f..e32eb3f147 100644 --- a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs @@ -1,9 +1,30 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Game.Beatmaps.Timing; +using osu.Game.Database; +using osu.Game.Rulesets.Mania.Judgements; +using osu.Game.Rulesets.Objects.Types; + namespace osu.Game.Rulesets.Mania.Objects { - public class HoldNote : Note + public class HoldNote : Note, IHasEndTime { + /// + /// Lenience of release hit windows. + /// + private const double release_window_lenience = 1.5; + + public double Duration { get; set; } + public double EndTime => StartTime + Duration; + + public HitWindows ReleaseHitWindows { get; protected set; } = new HitWindows(); + + public override void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty) + { + base.ApplyDefaults(timing, difficulty); + + ReleaseHitWindows = HitWindows * release_window_lenience; + } } } diff --git a/osu.Game.Rulesets.Mania/Objects/ManiaHitObject.cs b/osu.Game.Rulesets.Mania/Objects/ManiaHitObject.cs index e991c1ad93..93aaa94f45 100644 --- a/osu.Game.Rulesets.Mania/Objects/ManiaHitObject.cs +++ b/osu.Game.Rulesets.Mania/Objects/ManiaHitObject.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 osu.Game.Rulesets.Mania.Objects.Types; using osu.Game.Rulesets.Objects; namespace osu.Game.Rulesets.Mania.Objects diff --git a/osu.Game.Rulesets.Mania/Objects/Note.cs b/osu.Game.Rulesets.Mania/Objects/Note.cs index 2cc993df64..83299ba7be 100644 --- a/osu.Game.Rulesets.Mania/Objects/Note.cs +++ b/osu.Game.Rulesets.Mania/Objects/Note.cs @@ -1,9 +1,21 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Game.Beatmaps.Timing; +using osu.Game.Database; +using osu.Game.Rulesets.Mania.Judgements; + namespace osu.Game.Rulesets.Mania.Objects { public class Note : ManiaHitObject { + public HitWindows HitWindows { get; protected set; } = new HitWindows(); + + public override void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty) + { + base.ApplyDefaults(timing, difficulty); + + HitWindows = new HitWindows(difficulty.OverallDifficulty); + } } } diff --git a/osu.Game.Rulesets.Mania/Objects/IHasColumn.cs b/osu.Game.Rulesets.Mania/Objects/Types/IHasColumn.cs similarity index 79% rename from osu.Game.Rulesets.Mania/Objects/IHasColumn.cs rename to osu.Game.Rulesets.Mania/Objects/Types/IHasColumn.cs index daf7d217cd..7b98b2b4bb 100644 --- a/osu.Game.Rulesets.Mania/Objects/IHasColumn.cs +++ b/osu.Game.Rulesets.Mania/Objects/Types/IHasColumn.cs @@ -2,7 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -namespace osu.Game.Rulesets.Mania.Objects +namespace osu.Game.Rulesets.Mania.Objects.Types { public interface IHasColumn { diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index 49331bf598..46a006b09c 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -48,9 +48,10 @@ + - + From 1fa42b26e87a9ef15a7eecd62522b23d19b21804 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 3 May 2017 14:02:23 +0900 Subject: [PATCH 045/329] Make base DrawableHitObject uninheritable. --- osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs index a300eeab31..f9b2cd5966 100644 --- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs @@ -49,6 +49,10 @@ namespace osu.Game.Rulesets.Objects.Drawables } } + internal DrawableHitObject() + { + } + protected List Samples = new List(); protected void PlaySamples() From 6ea3629c9a5da836636081ac9e9672372d3a9279 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Wed, 3 May 2017 08:23:52 +0300 Subject: [PATCH 046/329] 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 047/329] 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 048/329] 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 06e014708a92f66ef906d555ce0c1525e9ddccfe Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 3 May 2017 15:56:54 +0900 Subject: [PATCH 049/329] Defer virtual method to load(). --- osu.Game/Rulesets/UI/HitRenderer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Rulesets/UI/HitRenderer.cs b/osu.Game/Rulesets/UI/HitRenderer.cs index 25d8bae205..69e0e73664 100644 --- a/osu.Game/Rulesets/UI/HitRenderer.cs +++ b/osu.Game/Rulesets/UI/HitRenderer.cs @@ -202,8 +202,6 @@ namespace osu.Game.Rulesets.UI protected HitRenderer(WorkingBeatmap beatmap) : base(beatmap) { - KeyConversionInputManager.Add(Playfield = CreatePlayfield()); - InputManager.Add(content = new Container { RelativeSizeAxes = Axes.Both, @@ -216,6 +214,8 @@ namespace osu.Game.Rulesets.UI [BackgroundDependencyLoader] private void load() { + KeyConversionInputManager.Add(Playfield = CreatePlayfield()); + loadObjects(); if (InputManager?.ReplayInputHandler != null) From 14e4714f08209fabd8f548967bd19493d4189e7e Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 3 May 2017 19:38:15 +0900 Subject: [PATCH 050/329] Rewrite a lot of ManiaPlayfield/Column to support left/right special styles and arbitrary number of columns. --- .../Tests/TestCaseManiaPlayfield.cs | 4 +- osu.Game.Rulesets.Mania/UI/Column.cs | 74 ++++++----- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 118 ++++++++++++++---- .../UI/SpecialColumnStyle.cs | 21 ++++ .../osu.Game.Rulesets.Mania.csproj | 1 + 5 files changed, 155 insertions(+), 63 deletions(-) create mode 100644 osu.Game.Rulesets.Mania/UI/SpecialColumnStyle.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs index 4c7433ff5a..9573ab154e 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs @@ -20,7 +20,7 @@ namespace osu.Desktop.VisualTests.Tests { base.Reset(); - const int max_columns = 9; + const int max_columns = 10; for (int i = 1; i <= max_columns; i++) { @@ -38,6 +38,8 @@ namespace osu.Desktop.VisualTests.Tests AddStep("Trigger keys down", () => ((ManiaPlayfield)Children.First()).Columns.Children.ForEach(triggerKeyDown)); AddStep("Trigger keys up", () => ((ManiaPlayfield)Children.First()).Columns.Children.ForEach(triggerKeyUp)); + AddStep("Left special style", () => ((ManiaPlayfield)Children.First()).SpecialColumnStyle = SpecialColumnStyle.Left); + AddStep("Right special style", () => ((ManiaPlayfield)Children.First()).SpecialColumnStyle = SpecialColumnStyle.Right); } } diff --git a/osu.Game.Rulesets.Mania/UI/Column.cs b/osu.Game.Rulesets.Mania/UI/Column.cs index 75ae529c4c..d2fccb2c58 100644 --- a/osu.Game.Rulesets.Mania/UI/Column.cs +++ b/osu.Game.Rulesets.Mania/UI/Column.cs @@ -29,31 +29,6 @@ namespace osu.Game.Rulesets.Mania.UI private const float column_width = 45; private const float special_column_width = 70; - private Color4 accentColour; - public Color4 AccentColour - { - get { return accentColour; } - set - { - if (accentColour == value) - return; - accentColour = value; - - setAccentColour(); - } - } - - private bool isSpecialColumn; - public bool IsSpecialColumn - { - get { return isSpecialColumn; } - set - { - isSpecialColumn = value; - Width = isSpecialColumn ? special_column_width : column_width; - } - } - public Key Key; private readonly Box background; @@ -159,23 +134,46 @@ namespace osu.Game.Rulesets.Mania.UI }; } - private void setAccentColour() + private bool isSpecial; + public bool IsSpecial { - background.Colour = AccentColour; - - hitTargetBar.EdgeEffect = new EdgeEffect + get { return isSpecial; } + set { - Type = EdgeEffectType.Glow, - Radius = 5, - Colour = AccentColour.Opacity(0.5f), - }; + if (isSpecial == value) + return; + isSpecial = value; - keyIcon.EdgeEffect = new EdgeEffect + Width = isSpecial ? special_column_width : column_width; + } + } + + private Color4 accentColour; + public Color4 AccentColour + { + get { return accentColour; } + set { - Type = EdgeEffectType.Glow, - Radius = 5, - Colour = AccentColour.Opacity(0.5f), - }; + if (accentColour == value) + return; + accentColour = value; + + background.Colour = accentColour; + + hitTargetBar.EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Glow, + Radius = 5, + Colour = accentColour.Opacity(0.5f), + }; + + keyIcon.EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Glow, + Radius = 5, + Colour = accentColour.Opacity(0.5f), + }; + } } protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index 112f91181d..471051e3f9 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -15,18 +15,50 @@ using osu.Game.Graphics; using osu.Framework.Allocation; using OpenTK.Input; using System.Linq; +using System.Collections.Generic; namespace osu.Game.Rulesets.Mania.UI { public class ManiaPlayfield : Playfield { + /// + /// Default column keys, expanding outwards from the middle as more column are added. + /// E.g. 2 columns use FJ, 4 columns use DFJK, 6 use SDFJKL, etc... + /// + private static readonly Key[] default_keys = new[] { Key.A, Key.S, Key.D, Key.F, Key.J, Key.K, Key.L, Key.Semicolon }; + + private SpecialColumnStyle specialColumnStyle; + /// + /// The style to use for the special column. + /// + public SpecialColumnStyle SpecialColumnStyle + { + get { return specialColumnStyle; } + set + { + if (specialColumnStyle == value) + return; + specialColumnStyle = value; + + if (!IsLoaded) + return; + + updateColumnStyle(); + } + } + public readonly FlowContainer Columns; - public ManiaPlayfield(int columns) + private List normalColumnColours = new List(); + private Color4 specialColumnColour; + + private readonly int columnCount; + + public ManiaPlayfield(int columnCount) { - if (columns > 9) - throw new ArgumentException($"{columns} columns is not supported."); - if (columns <= 0) + this.columnCount = columnCount; + + if (columnCount <= 0) throw new ArgumentException("Can't have zero or fewer columns."); Children = new Drawable[] @@ -56,43 +88,81 @@ namespace osu.Game.Rulesets.Mania.UI } }; - for (int i = 0; i < columns; i++) + for (int i = 0; i < columnCount; i++) Columns.Add(new Column()); } [BackgroundDependencyLoader] private void load(OsuColour colours) { - var columnColours = new[] + normalColumnColours = new List { colours.RedDark, - colours.GreenDark, - colours.BlueDark // Special column + colours.GreenDark }; - int columnCount = Columns.Children.Count(); - int halfColumns = columnCount / 2; + specialColumnColour = colours.BlueDark; - var keys = new[] { Key.A, Key.S, Key.D, Key.F, Key.Space, Key.J, Key.K, Key.L, Key.Semicolon }; + updateColumnStyle(); + } - for (int i = 0; i < halfColumns; i++) + /// + /// Updates the column style (special style/colours) + keys. + /// + private void updateColumnStyle() + { + // Set the special column + colour + key + for (int i = 0; i < columnCount; i++) { - Column leftColumn = Columns.Children.ElementAt(i); - Column rightColumn = Columns.Children.ElementAt(columnCount - 1 - i); + Column column = Columns.Children.ElementAt(i); + column.IsSpecial = isSpecialColumn(i); - Color4 accent = columnColours[i % 2]; - leftColumn.AccentColour = rightColumn.AccentColour = accent; - leftColumn.Key = keys[keys.Length / 2 - halfColumns + i]; - rightColumn.Key = keys[keys.Length / 2 + halfColumns - i]; + if (!column.IsSpecial) + continue; + + column.Key = Key.Space; + column.AccentColour = specialColumnColour; } - bool hasSpecial = halfColumns * 2 < columnCount; - if (hasSpecial) + var nonSpecialColumns = Columns.Children.Where(c => !c.IsSpecial).ToList(); + + // We'll set the colours of the non-special columns in a separate loop, because the non-special + // column colours are mirrored across their centre and special styles mess with this + for (int i = 0; i < Math.Ceiling(nonSpecialColumns.Count / 2f); i++) { - Column specialColumn = Columns.Children.ElementAt(halfColumns); - specialColumn.IsSpecialColumn = true; - specialColumn.AccentColour = columnColours[2]; - specialColumn.Key = keys[keys.Length / 2]; + Color4 colour = normalColumnColours[i % normalColumnColours.Count]; + nonSpecialColumns[i].AccentColour = colour; + nonSpecialColumns[nonSpecialColumns.Count - 1 - i].AccentColour = colour; + } + + // We'll set the keys for non-special columns in another separate loop because it's not mirrored like the above colours + // Todo: This needs to go when we get to bindings and use Button1, ..., ButtonN instead + for (int i = 0; i < nonSpecialColumns.Count; i++) + { + Column column = nonSpecialColumns[i]; + + int keyOffset = default_keys.Length / 2 - nonSpecialColumns.Count / 2 + i; + if (keyOffset >= 0 && keyOffset < default_keys.Length) + column.Key = default_keys[keyOffset]; + } + } + + /// + /// Whether the column index is a special column for this playfield. + /// + /// The 0-based column index. + /// Whether the column is a special column. + private bool isSpecialColumn(int column) + { + switch (SpecialColumnStyle) + { + default: + case SpecialColumnStyle.Normal: + return columnCount % 2 == 1 && column == columnCount / 2; + case SpecialColumnStyle.Left: + return column == 0; + case SpecialColumnStyle.Right: + return column == columnCount - 1; } } } diff --git a/osu.Game.Rulesets.Mania/UI/SpecialColumnStyle.cs b/osu.Game.Rulesets.Mania/UI/SpecialColumnStyle.cs new file mode 100644 index 0000000000..5acb147312 --- /dev/null +++ b/osu.Game.Rulesets.Mania/UI/SpecialColumnStyle.cs @@ -0,0 +1,21 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Rulesets.Mania.UI +{ + public enum SpecialColumnStyle + { + /// + /// The special column will lie in the center of the columns. + /// + Normal, + /// + /// The special column will lie to the left of the columns. + /// + Left, + /// + /// The special column will lie to the right of the columns. + /// + Right + } +} diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index 18ea1de13a..0a781aa30d 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -61,6 +61,7 @@ + From 8d82a52942c03ffccd48af1790f5bfe8b96f806c Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 3 May 2017 19:38:27 +0900 Subject: [PATCH 051/329] Add revert to normal special style after all steps. --- osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs index 9573ab154e..259dd6b4eb 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs @@ -41,6 +41,8 @@ namespace osu.Desktop.VisualTests.Tests AddStep("Left special style", () => ((ManiaPlayfield)Children.First()).SpecialColumnStyle = SpecialColumnStyle.Left); AddStep("Right special style", () => ((ManiaPlayfield)Children.First()).SpecialColumnStyle = SpecialColumnStyle.Right); } + + AddStep("Normal special style", () => ((ManiaPlayfield)Children.First()).SpecialColumnStyle = SpecialColumnStyle.Normal); } private void triggerKeyDown(Column column) From 8aa6bb636c2f8eec8125aa4d76023eaf27edb822 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 3 May 2017 19:42:20 +0900 Subject: [PATCH 052/329] Reset column key when it can't be set. --- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index 471051e3f9..947b067b02 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -144,6 +144,10 @@ namespace osu.Game.Rulesets.Mania.UI int keyOffset = default_keys.Length / 2 - nonSpecialColumns.Count / 2 + i; if (keyOffset >= 0 && keyOffset < default_keys.Length) column.Key = default_keys[keyOffset]; + else + // There is no default key defined for this column. Let's set this to Unknown for now + // however note that this will be gone after bindings are in place + column.Key = Key.Unknown; } } From 9e35eb8d978be13c4664d378967fe7443ddbd744 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Wed, 3 May 2017 13:53:45 +0300 Subject: [PATCH 053/329] 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 054/329] 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 5024a7419289dc7932a74671397e3ae2237dd52c Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Wed, 3 May 2017 20:11:24 +0900 Subject: [PATCH 055/329] Update ManiaPlayfield.cs --- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index 947b067b02..000a3e47ad 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -25,7 +25,7 @@ namespace osu.Game.Rulesets.Mania.UI /// Default column keys, expanding outwards from the middle as more column are added. /// E.g. 2 columns use FJ, 4 columns use DFJK, 6 use SDFJKL, etc... /// - private static readonly Key[] default_keys = new[] { Key.A, Key.S, Key.D, Key.F, Key.J, Key.K, Key.L, Key.Semicolon }; + private static readonly Key[] default_keys = { Key.A, Key.S, Key.D, Key.F, Key.J, Key.K, Key.L, Key.Semicolon }; private SpecialColumnStyle specialColumnStyle; /// From 956a7288fb27aa524a1ea3e8640bbe328f4c887b Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 3 May 2017 15:50:42 +0900 Subject: [PATCH 056/329] Add basic DrawableNote. --- .../Tests/TestCaseManiaHitObjects.cs | 40 ++++++++++++ .../osu.Desktop.VisualTests.csproj | 1 + .../Objects/Drawable/DrawableNote.cs | 36 ----------- .../Drawables/DrawableManiaHitObject.cs | 52 +++++++++++++++ .../Objects/Drawables/DrawableNote.cs | 27 ++++++++ .../Objects/Drawables/Pieces/NotePiece.cs | 64 +++++++++++++++++++ .../osu.Game.Rulesets.Mania.csproj | 4 +- .../Objects/Drawables/DrawableHitObject.cs | 2 +- 8 files changed, 188 insertions(+), 38 deletions(-) create mode 100644 osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs delete mode 100644 osu.Game.Rulesets.Mania/Objects/Drawable/DrawableNote.cs create mode 100644 osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs create mode 100644 osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs create mode 100644 osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs new file mode 100644 index 0000000000..b2baf26228 --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs @@ -0,0 +1,40 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Testing; +using osu.Game.Rulesets.Mania.Objects; +using osu.Game.Rulesets.Mania.Objects.Drawables; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace osu.Desktop.VisualTests.Tests +{ + internal class TestCaseManiaHitObjects : TestCase + { + public override void Reset() + { + base.Reset(); + + Add(new Container + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Y, + Width = 50, + Children = new[] + { + new DrawableNote(new Note()) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre + } + } + }); + } + } +} diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index 135e4596c7..4312ac4d3b 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.Rulesets.Mania/Objects/Drawable/DrawableNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawable/DrawableNote.cs deleted file mode 100644 index 72d1e5314b..0000000000 --- a/osu.Game.Rulesets.Mania/Objects/Drawable/DrawableNote.cs +++ /dev/null @@ -1,36 +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.Allocation; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Textures; -using osu.Framework.Graphics.Transforms; -using osu.Framework.Graphics; -using OpenTK; - -namespace osu.Game.Rulesets.Mania.Objects.Drawable -{ - public class DrawableNote : Sprite - { - private readonly ManiaHitObject note; - - public DrawableNote(ManiaHitObject note) - { - this.note = note; - Origin = Anchor.Centre; - Scale = new Vector2(0.1f); - } - - [BackgroundDependencyLoader] - private void load(TextureStore textures) - { - Texture = textures.Get(@"Menu/logo"); - - const double duration = 0; - - Transforms.Add(new TransformPositionY { StartTime = note.StartTime - 200, EndTime = note.StartTime, StartValue = -0.1f, EndValue = 0.9f }); - Transforms.Add(new TransformAlpha { StartTime = note.StartTime + duration + 200, EndTime = note.StartTime + duration + 400, StartValue = 1, EndValue = 0 }); - Expire(true); - } - } -} diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs new file mode 100644 index 0000000000..ebf99de72b --- /dev/null +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs @@ -0,0 +1,52 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK.Graphics; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Rulesets.Mania.Judgements; +using osu.Game.Rulesets.Objects.Drawables; + +namespace osu.Game.Rulesets.Mania.Objects.Drawables +{ + public abstract class DrawableManiaHitObject : DrawableHitObject + where TObject : ManiaHitObject + { + public override Color4 AccentColour + { + get { return base.AccentColour; } + set + { + base.AccentColour = value; + UpdateAccent(); + } + } + + public new TObject HitObject; + + protected override Container Content => noteFlow; + private FlowContainer noteFlow; + + public DrawableManiaHitObject(TObject hitObject) + : base(hitObject) + { + HitObject = hitObject; + + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + + AddInternal(noteFlow = new FillFlowContainer + { + Name = "Main container", + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y + }); + } + + protected override ManiaJudgement CreateJudgement() => new ManiaJudgement(); + + protected virtual void UpdateAccent() { } + } +} diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs new file mode 100644 index 0000000000..d9603fb8ea --- /dev/null +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs @@ -0,0 +1,27 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK.Graphics; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces; +using osu.Game.Rulesets.Objects.Drawables; + +namespace osu.Game.Rulesets.Mania.Objects.Drawables +{ + public class DrawableNote : DrawableManiaHitObject + { + private NotePiece headPiece; + + public DrawableNote(Note hitObject) + : base(hitObject) + { + Add(new NotePiece()); + } + + protected override void UpdateState(ArmedState state) + { + } + } +} diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs new file mode 100644 index 0000000000..e456dc3363 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs @@ -0,0 +1,64 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK.Graphics; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics; + +namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces +{ + internal class NotePiece : Container, IHasAccentColour + { + private const float head_height = 10; + private const float head_colour_height = 6; + + private Box colouredBox; + + public NotePiece() + { + RelativeSizeAxes = Axes.X; + Height = head_height; + + Masking = true; + + Children = new[] + { + new Box + { + RelativeSizeAxes = Axes.Both + }, + colouredBox = new Box + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + RelativeSizeAxes = Axes.X, + Height = head_colour_height, + Alpha = 0.5f + } + }; + } + + private Color4 accentColour; + public Color4 AccentColour + { + get { return accentColour; } + set + { + if (accentColour == value) + return; + accentColour = value; + + colouredBox.Colour = AccentColour; + + EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Glow, + Radius = 5, + Colour = AccentColour + }; + } + } + } +} diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index 46a006b09c..32925dcc45 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -51,9 +51,11 @@ + + + - diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs index f9b2cd5966..21eca346c4 100644 --- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs @@ -88,7 +88,7 @@ namespace osu.Game.Rulesets.Objects.Drawables /// /// The colour used for various elements of this DrawableHitObject. /// - public Color4 AccentColour { get; protected set; } + public virtual Color4 AccentColour { get; set; } protected DrawableHitObject(TObject hitObject) { From 489f58688799831916930fbd1c2463d872caa436 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 3 May 2017 20:34:53 +0900 Subject: [PATCH 057/329] Add FPS display toggling. Kinda temporary but better than nothing. --- osu.Game/Configuration/OsuConfigManager.cs | 5 ++++- osu.Game/OsuGameBase.cs | 12 ++++++++++++ .../Options/Sections/Graphics/RendererOptions.cs | 9 ++++++++- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 2c9574905f..3907496ca2 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -53,6 +53,8 @@ namespace osu.Game.Configuration // Graphics + Set(OsuConfig.ShowFpsDisplay, false); + Set(OsuConfig.MenuParallax, true); Set(OsuConfig.SnakingInSliders, true); @@ -99,6 +101,7 @@ namespace osu.Game.Configuration DisplayStarsMinimum, DisplayStarsMaximum, SnakingInSliders, - SnakingOutSliders + SnakingOutSliders, + ShowFpsDisplay } } diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index c9d7d856db..a814b5f125 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -19,6 +19,7 @@ using osu.Game.Graphics.Cursor; using osu.Game.Graphics.Processing; using osu.Game.Online.API; using SQLite.Net; +using osu.Framework.Graphics.Performance; namespace osu.Game { @@ -44,6 +45,8 @@ namespace osu.Game public readonly Bindable Beatmap = new Bindable(); + private Bindable fpsDisplayVisible; + protected AssemblyName AssemblyName => Assembly.GetEntryAssembly()?.GetName() ?? new AssemblyName { Version = new Version() }; public bool IsDeployedBuild => AssemblyName.Version.Major > 0; @@ -160,6 +163,15 @@ namespace osu.Game }, } }); + + // TODO: This is temporary until we reimplement the local FPS display. + // It's just to allow end-users to access the framework FPS display without knowing the shortcut key. + fpsDisplayVisible = LocalConfig.GetBindable(OsuConfig.ShowFpsDisplay); + fpsDisplayVisible.ValueChanged += val => + { + FrameStatisticsMode = val ? FrameStatisticsMode.Minimal : FrameStatisticsMode.None; + }; + fpsDisplayVisible.TriggerChange(); } public override void SetHost(GameHost host) diff --git a/osu.Game/Overlays/Options/Sections/Graphics/RendererOptions.cs b/osu.Game/Overlays/Options/Sections/Graphics/RendererOptions.cs index fafe91cfc5..58bf2b7996 100644 --- a/osu.Game/Overlays/Options/Sections/Graphics/RendererOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Graphics/RendererOptions.cs @@ -4,6 +4,8 @@ using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; +using osu.Game.Configuration; +using osu.Game.Graphics.UserInterface; namespace osu.Game.Overlays.Options.Sections.Graphics { @@ -12,7 +14,7 @@ namespace osu.Game.Overlays.Options.Sections.Graphics protected override string Header => "Renderer"; [BackgroundDependencyLoader] - private void load(FrameworkConfigManager config) + private void load(FrameworkConfigManager config, OsuConfigManager osuConfig) { // NOTE: Compatability mode omitted Children = new Drawable[] @@ -23,6 +25,11 @@ namespace osu.Game.Overlays.Options.Sections.Graphics LabelText = "Frame limiter", Bindable = config.GetBindable(FrameworkConfig.FrameSync) }, + new OsuCheckbox + { + LabelText = "Show FPS", + Bindable = osuConfig.GetBindable(OsuConfig.ShowFpsDisplay) + }, }; } } From 330dd458bd92228038a50a79c948662cffdea3d0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 3 May 2017 20:49:52 +0900 Subject: [PATCH 058/329] Trim whitespace. --- osu.Game/Overlays/Options/Sections/MaintenanceSection.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Options/Sections/MaintenanceSection.cs b/osu.Game/Overlays/Options/Sections/MaintenanceSection.cs index a50f1f3ff0..e8a4f91074 100644 --- a/osu.Game/Overlays/Options/Sections/MaintenanceSection.cs +++ b/osu.Game/Overlays/Options/Sections/MaintenanceSection.cs @@ -17,8 +17,7 @@ namespace osu.Game.Overlays.Options.Sections FlowContent.Spacing = new Vector2(0, 5); Children = new Drawable[] { - }; } } -} \ No newline at end of file +} From c39b314ac296b3cc874b478148daaffcbc10b614 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 3 May 2017 21:29:42 +0900 Subject: [PATCH 059/329] Update framework. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 58c108309f..cebdfb1bbb 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 58c108309f72462d8dc45aa488ab78cd6db08cf1 +Subproject commit cebdfb1bbb260e5aaca0a01e06d7128b3d1faae4 From 6063231e40258ab399bbd7fc8765903b8ed9209d Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Wed, 3 May 2017 16:58:10 +0300 Subject: [PATCH 060/329] 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 061/329] 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 062/329] 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 a2bdd020e5b86c06a436127c28ac9fbe3e475cdf Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 4 May 2017 14:46:10 +0900 Subject: [PATCH 063/329] ColumnStyle -> ColumnPosition. --- .../Tests/TestCaseManiaPlayfield.cs | 6 +++--- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 18 +++++++++--------- ...ColumnStyle.cs => SpecialColumnPosition.cs} | 2 +- .../osu.Game.Rulesets.Mania.csproj | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) rename osu.Game.Rulesets.Mania/UI/{SpecialColumnStyle.cs => SpecialColumnPosition.cs} (90%) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs index 259dd6b4eb..7e5a564da6 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs @@ -38,11 +38,11 @@ namespace osu.Desktop.VisualTests.Tests AddStep("Trigger keys down", () => ((ManiaPlayfield)Children.First()).Columns.Children.ForEach(triggerKeyDown)); AddStep("Trigger keys up", () => ((ManiaPlayfield)Children.First()).Columns.Children.ForEach(triggerKeyUp)); - AddStep("Left special style", () => ((ManiaPlayfield)Children.First()).SpecialColumnStyle = SpecialColumnStyle.Left); - AddStep("Right special style", () => ((ManiaPlayfield)Children.First()).SpecialColumnStyle = SpecialColumnStyle.Right); + AddStep("Left special style", () => ((ManiaPlayfield)Children.First()).SpecialColumnPosition = SpecialColumnPosition.Left); + AddStep("Right special style", () => ((ManiaPlayfield)Children.First()).SpecialColumnPosition = SpecialColumnPosition.Right); } - AddStep("Normal special style", () => ((ManiaPlayfield)Children.First()).SpecialColumnStyle = SpecialColumnStyle.Normal); + AddStep("Normal special style", () => ((ManiaPlayfield)Children.First()).SpecialColumnPosition = SpecialColumnPosition.Normal); } private void triggerKeyDown(Column column) diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index 000a3e47ad..d084326f5b 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -27,18 +27,18 @@ namespace osu.Game.Rulesets.Mania.UI /// private static readonly Key[] default_keys = { Key.A, Key.S, Key.D, Key.F, Key.J, Key.K, Key.L, Key.Semicolon }; - private SpecialColumnStyle specialColumnStyle; + private SpecialColumnPosition specialColumnPosition; /// /// The style to use for the special column. /// - public SpecialColumnStyle SpecialColumnStyle + public SpecialColumnPosition SpecialColumnPosition { - get { return specialColumnStyle; } + get { return specialColumnPosition; } set { - if (specialColumnStyle == value) + if (specialColumnPosition == value) return; - specialColumnStyle = value; + specialColumnPosition = value; if (!IsLoaded) return; @@ -158,14 +158,14 @@ namespace osu.Game.Rulesets.Mania.UI /// Whether the column is a special column. private bool isSpecialColumn(int column) { - switch (SpecialColumnStyle) + switch (SpecialColumnPosition) { default: - case SpecialColumnStyle.Normal: + case SpecialColumnPosition.Normal: return columnCount % 2 == 1 && column == columnCount / 2; - case SpecialColumnStyle.Left: + case SpecialColumnPosition.Left: return column == 0; - case SpecialColumnStyle.Right: + case SpecialColumnPosition.Right: return column == columnCount - 1; } } diff --git a/osu.Game.Rulesets.Mania/UI/SpecialColumnStyle.cs b/osu.Game.Rulesets.Mania/UI/SpecialColumnPosition.cs similarity index 90% rename from osu.Game.Rulesets.Mania/UI/SpecialColumnStyle.cs rename to osu.Game.Rulesets.Mania/UI/SpecialColumnPosition.cs index 5acb147312..7fd30e7d0d 100644 --- a/osu.Game.Rulesets.Mania/UI/SpecialColumnStyle.cs +++ b/osu.Game.Rulesets.Mania/UI/SpecialColumnPosition.cs @@ -3,7 +3,7 @@ namespace osu.Game.Rulesets.Mania.UI { - public enum SpecialColumnStyle + public enum SpecialColumnPosition { /// /// The special column will lie in the center of the columns. diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index 0a781aa30d..e2c6ad9a9f 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -61,7 +61,7 @@ - + From e307b6d563d24bf224909d4af05789ca4f0f2134 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 4 May 2017 15:12:32 +0900 Subject: [PATCH 064/329] Make SpecialColumnPosition only have an effect during load(). --- .../Tests/TestCaseManiaPlayfield.cs | 29 +++++++++++-------- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 25 +--------------- 2 files changed, 18 insertions(+), 36 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs index 7e5a564da6..2d4414d19f 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs @@ -7,6 +7,7 @@ using osu.Framework.Testing; using osu.Framework.Graphics; using osu.Game.Rulesets.Mania.UI; using System.Linq; +using System; namespace osu.Desktop.VisualTests.Tests { @@ -22,27 +23,31 @@ namespace osu.Desktop.VisualTests.Tests const int max_columns = 10; + Action createPlayfield = (cols, pos) => + { + Clear(); + Add(new ManiaPlayfield(cols) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + SpecialColumnPosition = pos + }); + }; + for (int i = 1; i <= max_columns; i++) { int tempI = i; - AddStep($"{i} column" + (i > 1 ? "s" : ""), () => - { - Clear(); - Add(new ManiaPlayfield(tempI) - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre - }); - }); + AddStep($"{i} column" + (i > 1 ? "s" : ""), () => createPlayfield(tempI, SpecialColumnPosition.Normal)); AddStep("Trigger keys down", () => ((ManiaPlayfield)Children.First()).Columns.Children.ForEach(triggerKeyDown)); AddStep("Trigger keys up", () => ((ManiaPlayfield)Children.First()).Columns.Children.ForEach(triggerKeyUp)); - AddStep("Left special style", () => ((ManiaPlayfield)Children.First()).SpecialColumnPosition = SpecialColumnPosition.Left); - AddStep("Right special style", () => ((ManiaPlayfield)Children.First()).SpecialColumnPosition = SpecialColumnPosition.Right); + + AddStep("Left special style", () => createPlayfield(tempI, SpecialColumnPosition.Left)); + AddStep("Right special style", () => createPlayfield(tempI, SpecialColumnPosition.Right)); } - AddStep("Normal special style", () => ((ManiaPlayfield)Children.First()).SpecialColumnPosition = SpecialColumnPosition.Normal); + AddStep("Normal special style", () => createPlayfield(max_columns, SpecialColumnPosition.Normal)); } private void triggerKeyDown(Column column) diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index d084326f5b..7b6c134ede 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -27,25 +27,10 @@ namespace osu.Game.Rulesets.Mania.UI /// private static readonly Key[] default_keys = { Key.A, Key.S, Key.D, Key.F, Key.J, Key.K, Key.L, Key.Semicolon }; - private SpecialColumnPosition specialColumnPosition; /// /// The style to use for the special column. /// - public SpecialColumnPosition SpecialColumnPosition - { - get { return specialColumnPosition; } - set - { - if (specialColumnPosition == value) - return; - specialColumnPosition = value; - - if (!IsLoaded) - return; - - updateColumnStyle(); - } - } + public SpecialColumnPosition SpecialColumnPosition; public readonly FlowContainer Columns; @@ -103,14 +88,6 @@ namespace osu.Game.Rulesets.Mania.UI specialColumnColour = colours.BlueDark; - updateColumnStyle(); - } - - /// - /// Updates the column style (special style/colours) + keys. - /// - private void updateColumnStyle() - { // Set the special column + colour + key for (int i = 0; i < columnCount; i++) { From 72b2467e74ba27fedf4d6ea483de4cdb0d89fe60 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 4 May 2017 15:18:20 +0900 Subject: [PATCH 065/329] Throw exception if SpecialColumnPosition is set after IsLoaded. --- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index 7b6c134ede..fa55768382 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -27,10 +27,20 @@ namespace osu.Game.Rulesets.Mania.UI /// private static readonly Key[] default_keys = { Key.A, Key.S, Key.D, Key.F, Key.J, Key.K, Key.L, Key.Semicolon }; + private SpecialColumnPosition specialColumnPosition; /// /// The style to use for the special column. /// - public SpecialColumnPosition SpecialColumnPosition; + public SpecialColumnPosition SpecialColumnPosition + { + get { return specialColumnPosition; } + set + { + if (IsLoaded) + throw new InvalidOperationException($"Setting {nameof(SpecialColumnPosition)} after the playfield is loaded requires re-creating the playfield."); + specialColumnPosition = value; + } + } public readonly FlowContainer Columns; From f945c636c248e8822e6b2ffebd41af72a6f99922 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 4 May 2017 15:36:37 +0900 Subject: [PATCH 066/329] Make note accent colour work again. --- osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs | 4 +++- .../Objects/Drawables/DrawableNote.cs | 9 ++++++++- .../Objects/Drawables/Pieces/NotePiece.cs | 5 +++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs index b2baf26228..093b6f1e01 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs @@ -11,6 +11,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using OpenTK.Graphics; namespace osu.Desktop.VisualTests.Tests { @@ -31,7 +32,8 @@ namespace osu.Desktop.VisualTests.Tests new DrawableNote(new Note()) { Anchor = Anchor.Centre, - Origin = Anchor.Centre + Origin = Anchor.Centre, + AccentColour = Color4.Red } } }); diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs index d9603fb8ea..2b2b6e5b1a 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK.Graphics; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -17,7 +18,13 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables public DrawableNote(Note hitObject) : base(hitObject) { - Add(new NotePiece()); + Add(headPiece = new NotePiece()); + } + + [BackgroundDependencyLoader] + private void load() + { + headPiece.AccentColour = AccentColour; } protected override void UpdateState(ArmedState state) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs index e456dc3363..90456f4f62 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK.Graphics; +using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -35,7 +36,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces Origin = Anchor.TopCentre, RelativeSizeAxes = Axes.X, Height = head_colour_height, - Alpha = 0.5f + Alpha = 0.2f } }; } @@ -50,7 +51,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces return; accentColour = value; - colouredBox.Colour = AccentColour; + colouredBox.Colour = AccentColour.Lighten(0.9f); EdgeEffect = new EdgeEffect { From 57c423241669ff9f6c3856bc5c4c229f64949ef2 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Thu, 4 May 2017 11:58:37 +0300 Subject: [PATCH 067/329] 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 4ad3e3d64eb821d45da43cb9b4067dfdc6227f41 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 4 May 2017 18:02:43 +0900 Subject: [PATCH 068/329] Basic implementation of hold notes (not finalized yet). --- .../Tests/TestCaseManiaHitObjects.cs | 40 +++++++++-- .../Objects/Drawables/DrawableHoldNote.cs | 72 +++++++++++++++++++ .../Drawables/DrawableManiaHitObject.cs | 68 ++++++++++++------ .../Objects/Drawables/DrawableNote.cs | 13 +++- .../Objects/Drawables/Pieces/BodyPiece.cs | 47 ++++++++++++ .../Objects/Drawables/Pieces/NotePiece.cs | 9 --- .../osu.Game.Rulesets.Mania.csproj | 2 + 7 files changed, 214 insertions(+), 37 deletions(-) create mode 100644 osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs create mode 100644 osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs index 093b6f1e01..a842406f99 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs @@ -12,6 +12,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using OpenTK.Graphics; +using OpenTK; namespace osu.Desktop.VisualTests.Tests { @@ -21,19 +22,48 @@ namespace osu.Desktop.VisualTests.Tests { base.Reset(); - Add(new Container + Add(new FillFlowContainer { Anchor = Anchor.Centre, Origin = Anchor.Centre, RelativeSizeAxes = Axes.Y, - Width = 50, - Children = new[] + Direction = FillDirection.Horizontal, + Spacing = new Vector2(10, 0), + // Imagine that the containers containing the drawable notes are the "columns" + Children = new Drawable[] { - new DrawableNote(new Note()) + new Container { Anchor = Anchor.Centre, Origin = Anchor.Centre, - AccentColour = Color4.Red + RelativeSizeAxes = Axes.Y, + Width = 50, + Children = new[] + { + new DrawableNote(new Note()) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + AccentColour = Color4.Red + } + } + }, + new Container + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Y, + Width = 50, + Children = new[] + { + new DrawableHoldNote(new HoldNote()) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + AccentColour = Color4.Red, + Length = 0.4f + } + } } } }); diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs new file mode 100644 index 0000000000..7db65a6522 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -0,0 +1,72 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using osu.Game.Rulesets.Objects.Drawables; +using osu.Framework.Graphics; +using osu.Framework.Allocation; +using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces; +using OpenTK.Graphics; + +namespace osu.Game.Rulesets.Mania.Objects.Drawables +{ + public class DrawableHoldNote : DrawableManiaHitObject + { + /// + /// Length of this hold note, relative to its parent. + /// + public float Length; + + private NotePiece headPiece; + private BodyPiece bodyPiece; + private NotePiece tailPiece; + + public DrawableHoldNote(HoldNote hitObject) + : base(hitObject) + { + Children = new Drawable[] + { + headPiece = new NotePiece + { + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre + }, + bodyPiece = new BodyPiece + { + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + }, + tailPiece = new NotePiece + { + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre + } + }; + } + + public override Color4 AccentColour + { + get { return AccentColour; } + set + { + if (base.AccentColour == value) + return; + base.AccentColour = value; + + headPiece.AccentColour = value; + bodyPiece.AccentColour = value; + tailPiece.AccentColour = value; + } + } + + + protected override void Update() + { + bodyPiece.Height = Parent.DrawSize.Y * Length; + } + + protected override void UpdateState(ArmedState state) + { + } + } +} diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs index ebf99de72b..9f4c5f6ee2 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs @@ -4,6 +4,7 @@ using OpenTK.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; using osu.Game.Rulesets.Mania.Judgements; using osu.Game.Rulesets.Objects.Drawables; @@ -12,20 +13,12 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables public abstract class DrawableManiaHitObject : DrawableHitObject where TObject : ManiaHitObject { - public override Color4 AccentColour - { - get { return base.AccentColour; } - set - { - base.AccentColour = value; - UpdateAccent(); - } - } - public new TObject HitObject; + private readonly Container glowContainer; + protected override Container Content => noteFlow; - private FlowContainer noteFlow; + private readonly FlowContainer noteFlow; public DrawableManiaHitObject(TObject hitObject) : base(hitObject) @@ -35,18 +28,53 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; - AddInternal(noteFlow = new FillFlowContainer + InternalChildren = new Drawable[] { - Name = "Main container", - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y - }); + glowContainer = new Container + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + Masking = true, + Children = new[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + AlwaysPresent = true, + Alpha = 0 + } + } + }, + noteFlow = new FillFlowContainer + { + Name = "Main container", + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y + } + }; + } + + public override Color4 AccentColour + { + get { return base.AccentColour; } + set + { + if (base.AccentColour == value) + return; + base.AccentColour = value; + + glowContainer.EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Glow, + Radius = 5, + Colour = value + }; + } } protected override ManiaJudgement CreateJudgement() => new ManiaJudgement(); - - protected virtual void UpdateAccent() { } } } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs index 2b2b6e5b1a..09443b6893 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs @@ -21,10 +21,17 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables Add(headPiece = new NotePiece()); } - [BackgroundDependencyLoader] - private void load() + public override Color4 AccentColour { - headPiece.AccentColour = AccentColour; + get { return AccentColour; } + set + { + if (base.AccentColour == value) + return; + base.AccentColour = value; + + headPiece.AccentColour = value; + } } protected override void UpdateState(ArmedState state) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs new file mode 100644 index 0000000000..b2451c9995 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs @@ -0,0 +1,47 @@ +using System; +using OpenTK.Graphics; +using osu.Framework.Graphics; +// 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.Framework.Graphics.Sprites; +using osu.Game.Graphics; + +namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces +{ + internal class BodyPiece : Container, IHasAccentColour + { + private Box box; + + public BodyPiece() + { + RelativeSizeAxes = Axes.X; + Masking = true; + + Children = new[] + { + box = new Box + { + RelativeSizeAxes = Axes.Both, + Alpha = 0.3f + } + }; + } + + private Color4 accentColour; + public Color4 AccentColour + { + get { return accentColour; } + set + { + if (accentColour == value) + return; + accentColour = value; + + box.Colour = accentColour; + } + } + } +} diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs index 90456f4f62..0acb250f88 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs @@ -22,8 +22,6 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces RelativeSizeAxes = Axes.X; Height = head_height; - Masking = true; - Children = new[] { new Box @@ -52,13 +50,6 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces accentColour = value; colouredBox.Colour = AccentColour.Lighten(0.9f); - - EdgeEffect = new EdgeEffect - { - Type = EdgeEffectType.Glow, - Radius = 5, - Colour = AccentColour - }; } } } diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index 32925dcc45..be29b28a38 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -51,8 +51,10 @@ + + From 153951d3ddd060907409593b35d5fa3d8e0b6d6e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 4 May 2017 23:07:24 +0900 Subject: [PATCH 069/329] Add OptionItem class Allow for centalised logic for all option UI controls. --- osu.Game/Overlays/Options/OptionCheckbox.cs | 27 ++++++ osu.Game/Overlays/Options/OptionDropdown.cs | 59 ++----------- osu.Game/Overlays/Options/OptionItem.cs | 84 +++++++++++++++++++ osu.Game/Overlays/Options/OptionLabel.cs | 6 +- osu.Game/Overlays/Options/OptionSlider.cs | 48 ++--------- osu.Game/Overlays/Options/OptionTextBox.cs | 16 +--- .../Options/Sections/Audio/MainMenuOptions.cs | 6 +- .../Options/Sections/Debug/GeneralOptions.cs | 2 +- .../Sections/Gameplay/GeneralOptions.cs | 4 +- .../Sections/General/LanguageOptions.cs | 2 +- .../Options/Sections/General/LoginOptions.cs | 4 +- .../Sections/Graphics/DetailOptions.cs | 6 +- .../Sections/Graphics/LayoutOptions.cs | 4 +- .../Sections/Graphics/MainMenuOptions.cs | 4 +- .../Sections/Graphics/RendererOptions.cs | 4 +- .../Options/Sections/Input/MouseOptions.cs | 4 +- osu.Game/osu.Game.csproj | 2 + 17 files changed, 156 insertions(+), 126 deletions(-) create mode 100644 osu.Game/Overlays/Options/OptionCheckbox.cs create mode 100644 osu.Game/Overlays/Options/OptionItem.cs diff --git a/osu.Game/Overlays/Options/OptionCheckbox.cs b/osu.Game/Overlays/Options/OptionCheckbox.cs new file mode 100644 index 0000000000..4aca15e3b9 --- /dev/null +++ b/osu.Game/Overlays/Options/OptionCheckbox.cs @@ -0,0 +1,27 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Configuration; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Primitives; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.UserInterface; +using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.UserInterface; + +namespace osu.Game.Overlays.Options +{ + public class OptionCheckbox : OptionItem + { + private OsuCheckbox checkbox; + + protected override Drawable CreateControl() => checkbox = new OsuCheckbox(); + + public override string LabelText + { + get { return checkbox.LabelText; } + set { checkbox.LabelText = value; } + } + } +} diff --git a/osu.Game/Overlays/Options/OptionDropdown.cs b/osu.Game/Overlays/Options/OptionDropdown.cs index 6837e71c2c..bb2875f9d8 100644 --- a/osu.Game/Overlays/Options/OptionDropdown.cs +++ b/osu.Game/Overlays/Options/OptionDropdown.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 System.Collections.Generic; using osu.Framework.Configuration; using osu.Framework.Graphics; @@ -13,34 +14,11 @@ using osu.Game.Graphics.UserInterface; namespace osu.Game.Overlays.Options { - public class OptionDropdown : FillFlowContainer + public class OptionDropdown : OptionItem { - private readonly Dropdown dropdown; - private readonly SpriteText text; + private Dropdown dropdown; - public string LabelText - { - get { return text.Text; } - set - { - text.Text = value; - text.Alpha = !string.IsNullOrEmpty(value) ? 1 : 0; - } - } - - public Bindable Bindable - { - get { return bindable; } - set - { - bindable = value; - dropdown.Current.BindTo(bindable); - } - } - - private Bindable bindable; - - private IEnumerable> items; + private IEnumerable> items = new KeyValuePair[] { }; public IEnumerable> Items { get @@ -55,30 +33,11 @@ namespace osu.Game.Overlays.Options } } - public OptionDropdown() + protected override Drawable CreateControl() => dropdown = new OsuDropdown { - Items = new KeyValuePair[0]; - - Direction = FillDirection.Vertical; - RelativeSizeAxes = Axes.X; - AutoSizeAxes = Axes.Y; - Children = new Drawable[] - { - text = new OsuSpriteText { - Alpha = 0, - }, - dropdown = new OsuDropdown - { - Margin = new MarginPadding { Top = 5 }, - RelativeSizeAxes = Axes.X, - Items = Items, - } - }; - - dropdown.Current.DisabledChanged += disabled => - { - Alpha = disabled ? 0.3f : 1; - }; - } + Margin = new MarginPadding { Top = 5 }, + RelativeSizeAxes = Axes.X, + Items = Items, + }; } } diff --git a/osu.Game/Overlays/Options/OptionItem.cs b/osu.Game/Overlays/Options/OptionItem.cs new file mode 100644 index 0000000000..c5b0e08ec0 --- /dev/null +++ b/osu.Game/Overlays/Options/OptionItem.cs @@ -0,0 +1,84 @@ +// 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.Configuration; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Primitives; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.UserInterface; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; + +namespace osu.Game.Overlays.Options +{ + public abstract class OptionItem : FillFlowContainer, IFilterable + { + protected abstract Drawable CreateControl(); + + protected Drawable Control { get; private set; } + + private IHasCurrentValue ControlWithCurrent => Control as IHasCurrentValue; + + private SpriteText text; + + public virtual string LabelText + { + get { return text?.Text ?? string.Empty; } + set + { + if (text == null) + { + // construct lazily for cases where the label is not needed (may be provided by the Control). + Add(text = new OsuSpriteText() { Depth = 1 }); + } + + text.Text = value; + } + } + + // hold a reference to the provided bindable so we don't have to in every options section. + private Bindable bindable; + + public Bindable Bindable + { + get + { + return bindable; + } + + set + { + bindable = value; + (Control as IHasCurrentValue)?.Current.BindTo(bindable); + } + } + + public string[] FilterTerms => new[] { LabelText }; + + public bool MatchingCurrentFilter + { + set + { + // probably needs a better transition. + FadeTo(value ? 1 : 0); + } + } + + public OptionItem() + { + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + Padding = new MarginPadding { Right = 5 }; + + if ((Control = CreateControl()) != null) + { + if (ControlWithCurrent != null) + ControlWithCurrent.Current.DisabledChanged += disabled => { Colour = disabled ? Color4.Gray : Color4.White; }; + Add(Control); + } + } + } +} diff --git a/osu.Game/Overlays/Options/OptionLabel.cs b/osu.Game/Overlays/Options/OptionLabel.cs index 4b0f1e4ec0..03b9a19ef4 100644 --- a/osu.Game/Overlays/Options/OptionLabel.cs +++ b/osu.Game/Overlays/Options/OptionLabel.cs @@ -1,14 +1,18 @@ // 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.Allocation; +using osu.Framework.Graphics; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; namespace osu.Game.Overlays.Options { - internal class OptionLabel : OsuSpriteText + internal class OptionLabel : OptionItem { + protected override Drawable CreateControl() => null; + [BackgroundDependencyLoader] private void load(OsuColour colour) { diff --git a/osu.Game/Overlays/Options/OptionSlider.cs b/osu.Game/Overlays/Options/OptionSlider.cs index 2d98bc991a..367bacb7c2 100644 --- a/osu.Game/Overlays/Options/OptionSlider.cs +++ b/osu.Game/Overlays/Options/OptionSlider.cs @@ -17,52 +17,14 @@ namespace osu.Game.Overlays.Options { } - public class OptionSlider : FillFlowContainer + public class OptionSlider : OptionItem where T : struct where U : SliderBar, new() { - private readonly SliderBar slider; - private readonly SpriteText text; - - public string LabelText + protected override Drawable CreateControl() => new U() { - get { return text.Text; } - set - { - text.Text = value; - text.Alpha = string.IsNullOrEmpty(value) ? 0 : 1; - } - } - - private Bindable bindable; - - public Bindable Bindable - { - set - { - bindable = value; - slider.Current.BindTo(bindable); - } - } - - public OptionSlider() - { - RelativeSizeAxes = Axes.X; - AutoSizeAxes = Axes.Y; - Padding = new MarginPadding { Right = 5 }; - - Children = new Drawable[] - { - text = new OsuSpriteText - { - Alpha = 0, - }, - slider = new U() - { - Margin = new MarginPadding { Top = 5, Bottom = 5 }, - RelativeSizeAxes = Axes.X - } - }; - } + Margin = new MarginPadding { Top = 5, Bottom = 5 }, + RelativeSizeAxes = Axes.X + }; } } diff --git a/osu.Game/Overlays/Options/OptionTextBox.cs b/osu.Game/Overlays/Options/OptionTextBox.cs index 4927122181..3d52eb67d0 100644 --- a/osu.Game/Overlays/Options/OptionTextBox.cs +++ b/osu.Game/Overlays/Options/OptionTextBox.cs @@ -1,22 +1,14 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using osu.Framework.Configuration; +using osu.Framework.Graphics; +using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics.UserInterface; namespace osu.Game.Overlays.Options { - public class OptionTextBox : OsuTextBox + public class OptionTextBox : OptionItem { - private Bindable bindable; - - public Bindable Bindable - { - set - { - bindable = value; - Current.BindTo(bindable); - } - } + protected override Drawable CreateControl() => new OsuTextBox(); } } diff --git a/osu.Game/Overlays/Options/Sections/Audio/MainMenuOptions.cs b/osu.Game/Overlays/Options/Sections/Audio/MainMenuOptions.cs index 9de74e1b02..d8731ff2d7 100644 --- a/osu.Game/Overlays/Options/Sections/Audio/MainMenuOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Audio/MainMenuOptions.cs @@ -16,12 +16,12 @@ namespace osu.Game.Overlays.Options.Sections.Audio { Children = new[] { - new OsuCheckbox + new OptionCheckbox { LabelText = "Interface voices", Bindable = config.GetBindable(OsuConfig.MenuVoice) }, - new OsuCheckbox + new OptionCheckbox { LabelText = "osu! music theme", Bindable = config.GetBindable(OsuConfig.MenuMusic) @@ -29,4 +29,4 @@ namespace osu.Game.Overlays.Options.Sections.Audio }; } } -} \ No newline at end of file +} diff --git a/osu.Game/Overlays/Options/Sections/Debug/GeneralOptions.cs b/osu.Game/Overlays/Options/Sections/Debug/GeneralOptions.cs index 34901e1dac..b87681a014 100644 --- a/osu.Game/Overlays/Options/Sections/Debug/GeneralOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Debug/GeneralOptions.cs @@ -17,7 +17,7 @@ namespace osu.Game.Overlays.Options.Sections.Debug { Children = new Drawable[] { - new OsuCheckbox + new OptionCheckbox { LabelText = "Bypass caching", Bindable = config.GetBindable(FrameworkDebugConfig.BypassCaching) diff --git a/osu.Game/Overlays/Options/Sections/Gameplay/GeneralOptions.cs b/osu.Game/Overlays/Options/Sections/Gameplay/GeneralOptions.cs index c278b59a51..92ea3442d2 100644 --- a/osu.Game/Overlays/Options/Sections/Gameplay/GeneralOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Gameplay/GeneralOptions.cs @@ -22,12 +22,12 @@ namespace osu.Game.Overlays.Options.Sections.Gameplay LabelText = "Background dim", Bindable = config.GetBindable(OsuConfig.DimLevel) }, - new OsuCheckbox + new OptionCheckbox { LabelText = "Show score overlay", Bindable = config.GetBindable(OsuConfig.ShowInterface) }, - new OsuCheckbox + new OptionCheckbox { LabelText = "Always show key overlay", Bindable = config.GetBindable(OsuConfig.KeyOverlay) diff --git a/osu.Game/Overlays/Options/Sections/General/LanguageOptions.cs b/osu.Game/Overlays/Options/Sections/General/LanguageOptions.cs index 7bc1a54455..921470aab1 100644 --- a/osu.Game/Overlays/Options/Sections/General/LanguageOptions.cs +++ b/osu.Game/Overlays/Options/Sections/General/LanguageOptions.cs @@ -17,7 +17,7 @@ namespace osu.Game.Overlays.Options.Sections.General { Children = new Drawable[] { - new OsuCheckbox + new OptionCheckbox { LabelText = "Prefer metadata in original language", Bindable = frameworkConfig.GetBindable(FrameworkConfig.ShowUnicode) diff --git a/osu.Game/Overlays/Options/Sections/General/LoginOptions.cs b/osu.Game/Overlays/Options/Sections/General/LoginOptions.cs index a5e38dd284..a3612a6396 100644 --- a/osu.Game/Overlays/Options/Sections/General/LoginOptions.cs +++ b/osu.Game/Overlays/Options/Sections/General/LoginOptions.cs @@ -132,12 +132,12 @@ namespace osu.Game.Overlays.Options.Sections.General TabbableContentContainer = this, OnCommit = (sender, newText) => performLogin() }, - new OsuCheckbox + new OptionCheckbox { LabelText = "Remember username", Bindable = config.GetBindable(OsuConfig.SaveUsername), }, - new OsuCheckbox + new OptionCheckbox { LabelText = "Stay logged in", Bindable = config.GetBindable(OsuConfig.SavePassword), diff --git a/osu.Game/Overlays/Options/Sections/Graphics/DetailOptions.cs b/osu.Game/Overlays/Options/Sections/Graphics/DetailOptions.cs index d8906d74ba..80bbd1caad 100644 --- a/osu.Game/Overlays/Options/Sections/Graphics/DetailOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Graphics/DetailOptions.cs @@ -17,12 +17,12 @@ namespace osu.Game.Overlays.Options.Sections.Graphics { Children = new Drawable[] { - new OsuCheckbox + new OptionCheckbox { LabelText = "Snaking in sliders", Bindable = config.GetBindable(OsuConfig.SnakingInSliders) }, - new OsuCheckbox + new OptionCheckbox { LabelText = "Snaking out sliders", Bindable = config.GetBindable(OsuConfig.SnakingOutSliders) @@ -30,4 +30,4 @@ namespace osu.Game.Overlays.Options.Sections.Graphics }; } } -} \ No newline at end of file +} diff --git a/osu.Game/Overlays/Options/Sections/Graphics/LayoutOptions.cs b/osu.Game/Overlays/Options/Sections/Graphics/LayoutOptions.cs index aed39ca764..36590045c6 100644 --- a/osu.Game/Overlays/Options/Sections/Graphics/LayoutOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Graphics/LayoutOptions.cs @@ -29,7 +29,7 @@ namespace osu.Game.Overlays.Options.Sections.Graphics LabelText = "Screen mode", Bindable = config.GetBindable(FrameworkConfig.WindowMode), }, - new OsuCheckbox + new OptionCheckbox { LabelText = "Letterboxing", Bindable = letterboxing, @@ -64,4 +64,4 @@ namespace osu.Game.Overlays.Options.Sections.Graphics } } } -} \ No newline at end of file +} diff --git a/osu.Game/Overlays/Options/Sections/Graphics/MainMenuOptions.cs b/osu.Game/Overlays/Options/Sections/Graphics/MainMenuOptions.cs index 83a2a382ad..005573414b 100644 --- a/osu.Game/Overlays/Options/Sections/Graphics/MainMenuOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Graphics/MainMenuOptions.cs @@ -16,7 +16,7 @@ namespace osu.Game.Overlays.Options.Sections.Graphics { Children = new[] { - new OsuCheckbox + new OptionCheckbox { LabelText = "Parallax", Bindable = config.GetBindable(OsuConfig.MenuParallax) @@ -24,4 +24,4 @@ namespace osu.Game.Overlays.Options.Sections.Graphics }; } } -} \ No newline at end of file +} diff --git a/osu.Game/Overlays/Options/Sections/Graphics/RendererOptions.cs b/osu.Game/Overlays/Options/Sections/Graphics/RendererOptions.cs index 58bf2b7996..3e6001c985 100644 --- a/osu.Game/Overlays/Options/Sections/Graphics/RendererOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Graphics/RendererOptions.cs @@ -25,7 +25,7 @@ namespace osu.Game.Overlays.Options.Sections.Graphics LabelText = "Frame limiter", Bindable = config.GetBindable(FrameworkConfig.FrameSync) }, - new OsuCheckbox + new OptionCheckbox { LabelText = "Show FPS", Bindable = osuConfig.GetBindable(OsuConfig.ShowFpsDisplay) @@ -33,4 +33,4 @@ namespace osu.Game.Overlays.Options.Sections.Graphics }; } } -} \ No newline at end of file +} diff --git a/osu.Game/Overlays/Options/Sections/Input/MouseOptions.cs b/osu.Game/Overlays/Options/Sections/Input/MouseOptions.cs index 12789aa0ec..b4ce11e2bc 100644 --- a/osu.Game/Overlays/Options/Sections/Input/MouseOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Input/MouseOptions.cs @@ -24,12 +24,12 @@ namespace osu.Game.Overlays.Options.Sections.Input LabelText = "Confine mouse cursor", Bindable = config.GetBindable(FrameworkConfig.ConfineMouseMode), }, - new OsuCheckbox + new OptionCheckbox { LabelText = "Disable mouse wheel during gameplay", Bindable = osuConfig.GetBindable(OsuConfig.MouseDisableWheel) }, - new OsuCheckbox + new OptionCheckbox { LabelText = "Disable mouse buttons during gameplay", Bindable = osuConfig.GetBindable(OsuConfig.MouseDisableButtons) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 929811226f..3535bc0028 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -371,8 +371,10 @@ + + From 475eb6fe5f14c10d722209e42413a31bf7b41a7f Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Thu, 4 May 2017 17:29:52 +0300 Subject: [PATCH 070/329] 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 98b3b82c07c787ecd6ed677f2bd6b3158337813f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 4 May 2017 23:32:27 +0900 Subject: [PATCH 071/329] Apply CI fixes. --- osu.Game/Overlays/Options/OptionCheckbox.cs | 6 ------ osu.Game/Overlays/Options/OptionDropdown.cs | 5 ----- osu.Game/Overlays/Options/OptionItem.cs | 12 +++++------- osu.Game/Overlays/Options/OptionLabel.cs | 2 -- osu.Game/Overlays/Options/OptionSlider.cs | 4 ---- osu.Game/Overlays/Options/OptionTextBox.cs | 1 - .../Options/Sections/Audio/MainMenuOptions.cs | 1 - .../Options/Sections/Debug/GeneralOptions.cs | 1 - .../Options/Sections/Gameplay/GeneralOptions.cs | 1 - .../Options/Sections/General/LanguageOptions.cs | 1 - .../Options/Sections/Graphics/DetailOptions.cs | 1 - .../Options/Sections/Graphics/LayoutOptions.cs | 1 - .../Options/Sections/Graphics/MainMenuOptions.cs | 1 - .../Options/Sections/Graphics/RendererOptions.cs | 1 - 14 files changed, 5 insertions(+), 33 deletions(-) diff --git a/osu.Game/Overlays/Options/OptionCheckbox.cs b/osu.Game/Overlays/Options/OptionCheckbox.cs index 4aca15e3b9..de7b138c3c 100644 --- a/osu.Game/Overlays/Options/OptionCheckbox.cs +++ b/osu.Game/Overlays/Options/OptionCheckbox.cs @@ -1,13 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using osu.Framework.Configuration; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.UserInterface; -using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; namespace osu.Game.Overlays.Options diff --git a/osu.Game/Overlays/Options/OptionDropdown.cs b/osu.Game/Overlays/Options/OptionDropdown.cs index bb2875f9d8..1427eafe39 100644 --- a/osu.Game/Overlays/Options/OptionDropdown.cs +++ b/osu.Game/Overlays/Options/OptionDropdown.cs @@ -1,15 +1,10 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using System.Collections.Generic; -using osu.Framework.Configuration; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; -using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; -using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; namespace osu.Game.Overlays.Options diff --git a/osu.Game/Overlays/Options/OptionItem.cs b/osu.Game/Overlays/Options/OptionItem.cs index c5b0e08ec0..c09eba7f11 100644 --- a/osu.Game/Overlays/Options/OptionItem.cs +++ b/osu.Game/Overlays/Options/OptionItem.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.Graphics; using osu.Framework.Configuration; using osu.Framework.Graphics; @@ -9,7 +8,6 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; -using osu.Game.Graphics; using osu.Game.Graphics.Sprites; namespace osu.Game.Overlays.Options @@ -18,9 +16,9 @@ namespace osu.Game.Overlays.Options { protected abstract Drawable CreateControl(); - protected Drawable Control { get; private set; } + protected Drawable Control { get; } - private IHasCurrentValue ControlWithCurrent => Control as IHasCurrentValue; + private IHasCurrentValue controlWithCurrent => Control as IHasCurrentValue; private SpriteText text; @@ -67,7 +65,7 @@ namespace osu.Game.Overlays.Options } } - public OptionItem() + protected OptionItem() { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; @@ -75,8 +73,8 @@ namespace osu.Game.Overlays.Options if ((Control = CreateControl()) != null) { - if (ControlWithCurrent != null) - ControlWithCurrent.Current.DisabledChanged += disabled => { Colour = disabled ? Color4.Gray : Color4.White; }; + if (controlWithCurrent != null) + controlWithCurrent.Current.DisabledChanged += disabled => { Colour = disabled ? Color4.Gray : Color4.White; }; Add(Control); } } diff --git a/osu.Game/Overlays/Options/OptionLabel.cs b/osu.Game/Overlays/Options/OptionLabel.cs index 03b9a19ef4..3f3c569f3a 100644 --- a/osu.Game/Overlays/Options/OptionLabel.cs +++ b/osu.Game/Overlays/Options/OptionLabel.cs @@ -1,11 +1,9 @@ // 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.Allocation; using osu.Framework.Graphics; using osu.Game.Graphics; -using osu.Game.Graphics.Sprites; namespace osu.Game.Overlays.Options { diff --git a/osu.Game/Overlays/Options/OptionSlider.cs b/osu.Game/Overlays/Options/OptionSlider.cs index 367bacb7c2..2cceb085a7 100644 --- a/osu.Game/Overlays/Options/OptionSlider.cs +++ b/osu.Game/Overlays/Options/OptionSlider.cs @@ -1,13 +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.Configuration; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; -using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; -using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; namespace osu.Game.Overlays.Options diff --git a/osu.Game/Overlays/Options/OptionTextBox.cs b/osu.Game/Overlays/Options/OptionTextBox.cs index 3d52eb67d0..498f27796a 100644 --- a/osu.Game/Overlays/Options/OptionTextBox.cs +++ b/osu.Game/Overlays/Options/OptionTextBox.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Graphics; -using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics.UserInterface; namespace osu.Game.Overlays.Options diff --git a/osu.Game/Overlays/Options/Sections/Audio/MainMenuOptions.cs b/osu.Game/Overlays/Options/Sections/Audio/MainMenuOptions.cs index d8731ff2d7..b2d1235b97 100644 --- a/osu.Game/Overlays/Options/Sections/Audio/MainMenuOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Audio/MainMenuOptions.cs @@ -3,7 +3,6 @@ using osu.Framework.Allocation; using osu.Game.Configuration; -using osu.Game.Graphics.UserInterface; namespace osu.Game.Overlays.Options.Sections.Audio { diff --git a/osu.Game/Overlays/Options/Sections/Debug/GeneralOptions.cs b/osu.Game/Overlays/Options/Sections/Debug/GeneralOptions.cs index b87681a014..9258b8fbeb 100644 --- a/osu.Game/Overlays/Options/Sections/Debug/GeneralOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Debug/GeneralOptions.cs @@ -4,7 +4,6 @@ using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; -using osu.Game.Graphics.UserInterface; namespace osu.Game.Overlays.Options.Sections.Debug { diff --git a/osu.Game/Overlays/Options/Sections/Gameplay/GeneralOptions.cs b/osu.Game/Overlays/Options/Sections/Gameplay/GeneralOptions.cs index 92ea3442d2..2598d95949 100644 --- a/osu.Game/Overlays/Options/Sections/Gameplay/GeneralOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Gameplay/GeneralOptions.cs @@ -4,7 +4,6 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Game.Configuration; -using osu.Game.Graphics.UserInterface; namespace osu.Game.Overlays.Options.Sections.Gameplay { diff --git a/osu.Game/Overlays/Options/Sections/General/LanguageOptions.cs b/osu.Game/Overlays/Options/Sections/General/LanguageOptions.cs index 921470aab1..2778f2567d 100644 --- a/osu.Game/Overlays/Options/Sections/General/LanguageOptions.cs +++ b/osu.Game/Overlays/Options/Sections/General/LanguageOptions.cs @@ -4,7 +4,6 @@ using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; -using osu.Game.Graphics.UserInterface; namespace osu.Game.Overlays.Options.Sections.General { diff --git a/osu.Game/Overlays/Options/Sections/Graphics/DetailOptions.cs b/osu.Game/Overlays/Options/Sections/Graphics/DetailOptions.cs index 80bbd1caad..6503a7ea90 100644 --- a/osu.Game/Overlays/Options/Sections/Graphics/DetailOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Graphics/DetailOptions.cs @@ -4,7 +4,6 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Game.Configuration; -using osu.Game.Graphics.UserInterface; namespace osu.Game.Overlays.Options.Sections.Graphics { diff --git a/osu.Game/Overlays/Options/Sections/Graphics/LayoutOptions.cs b/osu.Game/Overlays/Options/Sections/Graphics/LayoutOptions.cs index 36590045c6..1b4b0b3c7d 100644 --- a/osu.Game/Overlays/Options/Sections/Graphics/LayoutOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Graphics/LayoutOptions.cs @@ -4,7 +4,6 @@ using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; -using osu.Game.Graphics.UserInterface; namespace osu.Game.Overlays.Options.Sections.Graphics { diff --git a/osu.Game/Overlays/Options/Sections/Graphics/MainMenuOptions.cs b/osu.Game/Overlays/Options/Sections/Graphics/MainMenuOptions.cs index 005573414b..6ebb8f263d 100644 --- a/osu.Game/Overlays/Options/Sections/Graphics/MainMenuOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Graphics/MainMenuOptions.cs @@ -3,7 +3,6 @@ using osu.Framework.Allocation; using osu.Game.Configuration; -using osu.Game.Graphics.UserInterface; namespace osu.Game.Overlays.Options.Sections.Graphics { diff --git a/osu.Game/Overlays/Options/Sections/Graphics/RendererOptions.cs b/osu.Game/Overlays/Options/Sections/Graphics/RendererOptions.cs index 3e6001c985..f11c18d3b4 100644 --- a/osu.Game/Overlays/Options/Sections/Graphics/RendererOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Graphics/RendererOptions.cs @@ -5,7 +5,6 @@ using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Game.Configuration; -using osu.Game.Graphics.UserInterface; namespace osu.Game.Overlays.Options.Sections.Graphics { From 95f6c999bdbb56ae4daf9d489c088eb7ee30e3de Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Thu, 4 May 2017 17:59:01 +0300 Subject: [PATCH 072/329] 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 073/329] 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 074/329] 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 075/329] 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 076/329] 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 077/329] 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 078/329] 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 81d67cbe06381b596b48263f686c675eb7f6f1b3 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 5 May 2017 01:59:24 -0300 Subject: [PATCH 079/329] Play first visible set in playlist when commiting in the search field. --- osu.Game/Overlays/Music/FilterControl.cs | 1 + osu.Game/Overlays/Music/PlaylistItem.cs | 4 ++++ osu.Game/Overlays/Music/PlaylistList.cs | 2 ++ osu.Game/Overlays/Music/PlaylistOverlay.cs | 5 +++++ osu.Game/Screens/Select/SearchTextBox.cs | 7 ++++++- 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Music/FilterControl.cs b/osu.Game/Overlays/Music/FilterControl.cs index c6572c5ed2..5b528b7e89 100644 --- a/osu.Game/Overlays/Music/FilterControl.cs +++ b/osu.Game/Overlays/Music/FilterControl.cs @@ -62,6 +62,7 @@ namespace osu.Game.Overlays.Music protected override Color4 BackgroundUnfocused => backgroundColour; protected override Color4 BackgroundFocused => backgroundColour; + protected override bool AllowCommit => true; public FilterTextBox() { diff --git a/osu.Game/Overlays/Music/PlaylistItem.cs b/osu.Game/Overlays/Music/PlaylistItem.cs index da31e94e22..c2413956b4 100644 --- a/osu.Game/Overlays/Music/PlaylistItem.cs +++ b/osu.Game/Overlays/Music/PlaylistItem.cs @@ -132,6 +132,10 @@ namespace osu.Game.Overlays.Music FadeTo(matching ? 1 : 0, 200); } + get + { + return matching; + } } } } diff --git a/osu.Game/Overlays/Music/PlaylistList.cs b/osu.Game/Overlays/Music/PlaylistList.cs index c7909f1a63..ffe59a9d93 100644 --- a/osu.Game/Overlays/Music/PlaylistList.cs +++ b/osu.Game/Overlays/Music/PlaylistList.cs @@ -22,6 +22,8 @@ namespace osu.Game.Overlays.Music } } + public BeatmapSetInfo FirstVisibleSet => items.Children.FirstOrDefault(i => i.MatchingCurrentFilter)?.BeatmapSetInfo; + private void itemSelected(BeatmapSetInfo b) { OnSelect?.Invoke(b); diff --git a/osu.Game/Overlays/Music/PlaylistOverlay.cs b/osu.Game/Overlays/Music/PlaylistOverlay.cs index 92b8addd97..00d66053a7 100644 --- a/osu.Game/Overlays/Music/PlaylistOverlay.cs +++ b/osu.Game/Overlays/Music/PlaylistOverlay.cs @@ -84,6 +84,11 @@ namespace osu.Game.Overlays.Music list.BeatmapSets = BeatmapSets = beatmaps.GetAllWithChildren().ToList(); beatmapBacking.BindTo(game.Beatmap); + + filter.Search.OnCommit = delegate { + var beatmap = list.FirstVisibleSet?.Beatmaps?.ValueAtOrDefault(0); + if (beatmap != null) playSpecified(beatmap); + }; } protected override void LoadComplete() diff --git a/osu.Game/Screens/Select/SearchTextBox.cs b/osu.Game/Screens/Select/SearchTextBox.cs index 4f2ab221cb..743b1fc5c7 100644 --- a/osu.Game/Screens/Select/SearchTextBox.cs +++ b/osu.Game/Screens/Select/SearchTextBox.cs @@ -15,6 +15,8 @@ namespace osu.Game.Screens.Select /// public class SearchTextBox : FocusedTextBox { + protected virtual bool AllowCommit => false; + public SearchTextBox() { Height = 35; @@ -45,8 +47,11 @@ namespace osu.Game.Screens.Select case Key.Right: case Key.Up: case Key.Down: - case Key.Enter: return false; + + case Key.Enter: + if (!AllowCommit) return false; + break; } } From 5aecc3d76103617ae15aeea0c624d55ac37c979e Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Fri, 5 May 2017 17:44:51 +0200 Subject: [PATCH 080/329] 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 d129bd0c1fe1c931effb4fc5d2a0f5812cd18bf4 Mon Sep 17 00:00:00 2001 From: skettios Date: Fri, 5 May 2017 17:01:44 -0700 Subject: [PATCH 081/329] Fix ModSelectOverlay accepting escape when it shouldn't Because PlaySongSelect is suspending when selecting a song, we don't actually hide ModSelectOverlay. --- osu.Game/Screens/Select/PlaySongSelect.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index c15900eb6d..a8229bd012 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -69,6 +69,14 @@ namespace osu.Game.Screens.Select base.OnResuming(last); } + protected override void OnSuspending(Screen next) + { + if (modSelect.State == Visibility.Visible) + modSelect.Hide(); + + base.OnSuspending(next); + } + protected override bool OnExiting(Screen next) { if (modSelect.State == Visibility.Visible) From 36dff948020184ff1eeff20a773b7e98fda9342f Mon Sep 17 00:00:00 2001 From: skettios Date: Fri, 5 May 2017 18:16:48 -0700 Subject: [PATCH 082/329] removed check if ModSelectOverlay is open --- osu.Game/Screens/Select/PlaySongSelect.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index a8229bd012..315992c113 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -71,8 +71,7 @@ namespace osu.Game.Screens.Select protected override void OnSuspending(Screen next) { - if (modSelect.State == Visibility.Visible) - modSelect.Hide(); + modSelect.Hide(); base.OnSuspending(next); } From 4f491519848cc9afab5babcaa56fd28171ffdc11 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Mon, 1 May 2017 21:29:57 +0800 Subject: [PATCH 083/329] Make metadata a member of WorkingBeatmap. --- osu.Desktop.VisualTests/Beatmaps/TestWorkingBeatmap.cs | 2 +- osu.Game/Beatmaps/WorkingBeatmap.cs | 7 +++++-- osu.Game/Database/BeatmapDatabase.cs | 4 +++- osu.Game/Database/DatabaseWorkingBeatmap.cs | 4 ++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/osu.Desktop.VisualTests/Beatmaps/TestWorkingBeatmap.cs b/osu.Desktop.VisualTests/Beatmaps/TestWorkingBeatmap.cs index 5e3f5b5133..b45574b761 100644 --- a/osu.Desktop.VisualTests/Beatmaps/TestWorkingBeatmap.cs +++ b/osu.Desktop.VisualTests/Beatmaps/TestWorkingBeatmap.cs @@ -10,7 +10,7 @@ namespace osu.Desktop.VisualTests.Beatmaps public class TestWorkingBeatmap : WorkingBeatmap { public TestWorkingBeatmap(Beatmap beatmap) - : base(beatmap.BeatmapInfo, beatmap.BeatmapInfo.BeatmapSet) + : base(beatmap.BeatmapInfo) { this.beatmap = beatmap; } diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index 589557b088..09a6ea7065 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -18,14 +18,17 @@ namespace osu.Game.Beatmaps public readonly BeatmapSetInfo BeatmapSetInfo; + public readonly BeatmapMetadata Metadata; + public readonly Bindable> Mods = new Bindable>(new Mod[] { }); public readonly bool WithStoryboard; - protected WorkingBeatmap(BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo, bool withStoryboard = false) + protected WorkingBeatmap(BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo = null, BeatmapMetadata metadata = null, bool withStoryboard = false) { BeatmapInfo = beatmapInfo; - BeatmapSetInfo = beatmapSetInfo; + BeatmapSetInfo = beatmapSetInfo ?? beatmapInfo?.BeatmapSet; + Metadata = metadata ?? beatmapInfo?.Metadata ?? BeatmapSetInfo?.Metadata; WithStoryboard = withStoryboard; Mods.ValueChanged += mods => applyRateAdjustments(); diff --git a/osu.Game/Database/BeatmapDatabase.cs b/osu.Game/Database/BeatmapDatabase.cs index 0e814dea82..6f4559bc52 100644 --- a/osu.Game/Database/BeatmapDatabase.cs +++ b/osu.Game/Database/BeatmapDatabase.cs @@ -274,6 +274,8 @@ namespace osu.Game.Database if (beatmapSetInfo == null) throw new InvalidOperationException($@"Beatmap set {beatmapInfo.BeatmapSetInfoID} is not in the local database."); + beatmapInfo.BeatmapSet = beatmapSetInfo; + //we need metadata GetChildren(beatmapSetInfo); //we also need a ruleset @@ -282,7 +284,7 @@ namespace osu.Game.Database if (beatmapInfo.Metadata == null) beatmapInfo.Metadata = beatmapSetInfo.Metadata; - WorkingBeatmap working = new DatabaseWorkingBeatmap(this, beatmapInfo, beatmapSetInfo, withStoryboard); + WorkingBeatmap working = new DatabaseWorkingBeatmap(this, beatmapInfo, withStoryboard: withStoryboard); previous?.TransferTo(working); diff --git a/osu.Game/Database/DatabaseWorkingBeatmap.cs b/osu.Game/Database/DatabaseWorkingBeatmap.cs index 9fb3bed1e7..d3d5220e7f 100644 --- a/osu.Game/Database/DatabaseWorkingBeatmap.cs +++ b/osu.Game/Database/DatabaseWorkingBeatmap.cs @@ -14,8 +14,8 @@ namespace osu.Game.Database { private readonly BeatmapDatabase database; - public DatabaseWorkingBeatmap(BeatmapDatabase database, BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo, bool withStoryboard = false) - : base(beatmapInfo, beatmapSetInfo, withStoryboard) + public DatabaseWorkingBeatmap(BeatmapDatabase database, BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo = null, BeatmapMetadata metadata = null, bool withStoryboard = false) + : base(beatmapInfo, beatmapSetInfo, metadata, withStoryboard) { this.database = database; } From 146d57953d6f109f1114f8c51378fe6d9c0fb7f5 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Sat, 6 May 2017 14:03:08 +0800 Subject: [PATCH 084/329] Use metadata field of WorkingBeatmap. --- osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs | 6 ++---- osu.Game/Database/DatabaseWorkingBeatmap.cs | 6 +++--- osu.Game/Overlays/MusicController.cs | 2 +- osu.Game/Screens/Menu/MainMenu.cs | 16 +++++++--------- osu.Game/Screens/Select/BeatmapDeleteDialog.cs | 2 +- osu.Game/Screens/Select/SongSelect.cs | 2 +- 6 files changed, 15 insertions(+), 19 deletions(-) diff --git a/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs b/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs index db14a48af1..8431e5f812 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs @@ -51,14 +51,12 @@ namespace osu.Game.Beatmaps.Drawables title = new OsuSpriteText { Font = @"Exo2.0-BoldItalic", - Text = beatmap.BeatmapSetInfo.Metadata.Title, TextSize = 22, Shadow = true, }, artist = new OsuSpriteText { Font = @"Exo2.0-SemiBoldItalic", - Text = beatmap.BeatmapSetInfo.Metadata.Artist, TextSize = 17, Shadow = true, }, @@ -81,8 +79,8 @@ namespace osu.Game.Beatmaps.Drawables [BackgroundDependencyLoader] private void load(LocalisationEngine localisation) { - title.Current = localisation.GetUnicodePreference(beatmap.BeatmapSetInfo.Metadata.TitleUnicode, beatmap.BeatmapSetInfo.Metadata.Title); - artist.Current = localisation.GetUnicodePreference(beatmap.BeatmapSetInfo.Metadata.ArtistUnicode, beatmap.BeatmapSetInfo.Metadata.Artist); + title.Current = localisation.GetUnicodePreference(beatmap.Metadata.TitleUnicode, beatmap.Metadata.Title); + artist.Current = localisation.GetUnicodePreference(beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist); } private class PanelBackground : BufferedContainer diff --git a/osu.Game/Database/DatabaseWorkingBeatmap.cs b/osu.Game/Database/DatabaseWorkingBeatmap.cs index d3d5220e7f..1c160a14e4 100644 --- a/osu.Game/Database/DatabaseWorkingBeatmap.cs +++ b/osu.Game/Database/DatabaseWorkingBeatmap.cs @@ -51,13 +51,13 @@ namespace osu.Game.Database protected override Texture GetBackground() { - if (BeatmapInfo?.Metadata?.BackgroundFile == null) + if (Metadata?.BackgroundFile == null) return null; try { using (var reader = getReader()) - return new TextureStore(new RawTextureLoaderStore(reader), false).Get(BeatmapInfo.Metadata.BackgroundFile); + return new TextureStore(new RawTextureLoaderStore(reader), false).Get(Metadata.BackgroundFile); } catch { return null; } } @@ -66,7 +66,7 @@ namespace osu.Game.Database { try { - var trackData = getReader()?.GetStream(BeatmapInfo.Metadata.AudioFile); + var trackData = getReader()?.GetStream(Metadata.AudioFile); return trackData == null ? null : new TrackBass(trackData); } catch { return null; } diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 91d35db3bb..e3edaa0ca7 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -315,7 +315,7 @@ namespace osu.Game.Overlays } else { - BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata; + BeatmapMetadata metadata = beatmap.Metadata; title.Current = localisation.GetUnicodePreference(metadata.TitleUnicode, metadata.Title); artist.Current = localisation.GetUnicodePreference(metadata.ArtistUnicode, metadata.Artist); } diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index a23efcd9d4..ed6a263b4c 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -65,7 +65,6 @@ namespace osu.Game.Screens.Menu private Bindable menuMusic; private TrackManager trackManager; - private WorkingBeatmap song; [BackgroundDependencyLoader] private void load(OsuGame game, OsuConfigManager config, BeatmapDatabase beatmaps) @@ -79,8 +78,7 @@ namespace osu.Game.Screens.Menu List choosableBeatmapSets = beatmaps.Query().ToList(); if (choosableBeatmapSets.Count > 0) { - song = beatmaps.GetWorkingBeatmap(beatmaps.GetWithChildren(choosableBeatmapSets[RNG.Next(0, choosableBeatmapSets.Count - 1)].ID).Beatmaps[0]); - Beatmap = song; + Beatmap = beatmaps.GetWorkingBeatmap(beatmaps.GetWithChildren(choosableBeatmapSets[RNG.Next(0, choosableBeatmapSets.Count - 1)].ID).Beatmaps[0]); } } @@ -106,15 +104,15 @@ namespace osu.Game.Screens.Menu { base.OnEntering(last); buttons.FadeInFromZero(500); - if (last is Intro && song != null) + if (last is Intro && Beatmap != null) { Task.Run(() => { - trackManager.SetExclusive(song.Track); - song.Track.Seek(song.Beatmap.Metadata.PreviewTime); - if (song.Beatmap.Metadata.PreviewTime == -1) - song.Track.Seek(song.Track.Length * 0.4f); - song.Track.Start(); + trackManager.SetExclusive(Beatmap.Track); + Beatmap.Track.Seek(Beatmap.Metadata.PreviewTime); + if (Beatmap.Metadata.PreviewTime == -1) + Beatmap.Track.Seek(Beatmap.Track.Length * 0.4f); + Beatmap.Track.Start(); }); } } diff --git a/osu.Game/Screens/Select/BeatmapDeleteDialog.cs b/osu.Game/Screens/Select/BeatmapDeleteDialog.cs index e6e9a86124..ac35f0e254 100644 --- a/osu.Game/Screens/Select/BeatmapDeleteDialog.cs +++ b/osu.Game/Screens/Select/BeatmapDeleteDialog.cs @@ -26,7 +26,7 @@ namespace osu.Game.Screens.Select Icon = FontAwesome.fa_trash_o; HeaderText = @"Confirm deletion of"; - BodyText = $@"{beatmap.Beatmap?.Metadata?.Artist} - {beatmap.Beatmap?.Metadata?.Title}"; + BodyText = $@"{beatmap?.Metadata?.Artist} - {beatmap?.Metadata?.Title}"; Buttons = new PopupDialogButton[] { new PopupDialogOkButton diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 7d0648ac11..4d7904123c 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -343,7 +343,7 @@ namespace osu.Game.Screens.Select { trackManager.SetExclusive(track); if (preview) - track.Seek(Beatmap.Beatmap.Metadata.PreviewTime); + track.Seek(Beatmap.Metadata.PreviewTime); track.Start(); } } From 767cfaaac39bcf02e62c66825678e21f30b4cff2 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Sat, 6 May 2017 15:37:53 +0800 Subject: [PATCH 085/329] Access database recursively. --- .../Beatmaps/IO/ImportBeatmapTest.cs | 7 +++--- osu.Game/Database/BeatmapDatabase.cs | 17 +++----------- osu.Game/Database/Database.cs | 4 ++-- osu.Game/Screens/Menu/MainMenu.cs | 22 ++++++++++--------- osu.Game/Screens/Select/BeatmapCarousel.cs | 6 ++--- osu.Game/Screens/Select/SongSelect.cs | 2 +- 6 files changed, 23 insertions(+), 35 deletions(-) diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs index b39db30fe8..cba150f91d 100644 --- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs @@ -118,7 +118,7 @@ namespace osu.Game.Tests.Beatmaps.IO Action waitAction = () => { while (!(resultSets = host.Dependencies.Get() - .Query().Where(s => s.OnlineBeatmapSetID == 241526)).Any()) + .GetAllWithChildren(s => s.OnlineBeatmapSetID == 241526)).Any()) Thread.Sleep(50); }; @@ -135,15 +135,14 @@ namespace osu.Game.Tests.Beatmaps.IO waitAction = () => { while ((resultBeatmaps = host.Dependencies.Get() - .Query().Where(s => s.OnlineBeatmapSetID == 241526 && s.BaseDifficultyID > 0)).Count() != 12) + .GetAllWithChildren(s => s.OnlineBeatmapSetID == 241526 && s.BaseDifficultyID > 0)).Count() != 12) Thread.Sleep(50); }; Assert.IsTrue(waitAction.BeginInvoke(null, null).AsyncWaitHandle.WaitOne(timeout), @"Beatmaps did not import to the database in allocated time"); - //fetch children and check we can load from the post-storage path... - var set = host.Dependencies.Get().GetChildren(resultSets.First()); + var set = resultSets.First(); Assert.IsTrue(set.Beatmaps.Count == resultBeatmaps.Count(), $@"Incorrect database beatmap count post-import ({resultBeatmaps.Count()} but should be {set.Beatmaps.Count})."); diff --git a/osu.Game/Database/BeatmapDatabase.cs b/osu.Game/Database/BeatmapDatabase.cs index 6f4559bc52..811a067116 100644 --- a/osu.Game/Database/BeatmapDatabase.cs +++ b/osu.Game/Database/BeatmapDatabase.cs @@ -36,14 +36,12 @@ namespace osu.Game.Database private void deletePending() { - foreach (var b in Query().Where(b => b.DeletePending)) + foreach (var b in GetAllWithChildren(b => b.DeletePending)) { try { Storage.Delete(b.Path); - GetChildren(b, true); - foreach (var i in b.Beatmaps) { if (i.Metadata != null) Connection.Delete(i.Metadata); @@ -269,20 +267,11 @@ namespace osu.Game.Database public WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo, WorkingBeatmap previous = null, bool withStoryboard = false) { - var beatmapSetInfo = Query().FirstOrDefault(s => s.ID == beatmapInfo.BeatmapSetInfoID); - - if (beatmapSetInfo == null) + if (beatmapInfo.BeatmapSet == null) throw new InvalidOperationException($@"Beatmap set {beatmapInfo.BeatmapSetInfoID} is not in the local database."); - beatmapInfo.BeatmapSet = beatmapSetInfo; - - //we need metadata - GetChildren(beatmapSetInfo); - //we also need a ruleset - GetChildren(beatmapInfo); - if (beatmapInfo.Metadata == null) - beatmapInfo.Metadata = beatmapSetInfo.Metadata; + beatmapInfo.Metadata = beatmapInfo.BeatmapSet.Metadata; WorkingBeatmap working = new DatabaseWorkingBeatmap(this, beatmapInfo, withStoryboard: withStoryboard); diff --git a/osu.Game/Database/Database.cs b/osu.Game/Database/Database.cs index 23851b3b2e..9b49583875 100644 --- a/osu.Game/Database/Database.cs +++ b/osu.Game/Database/Database.cs @@ -48,9 +48,9 @@ namespace osu.Game.Database return Connection.Table(); } - public T GetWithChildren(object id) where T : class + public T GetWithChildren(object id, bool recursive = false) where T : class { - return Connection.GetWithChildren(id); + return Connection.GetWithChildren(id, recursive); } public List GetAllWithChildren(Expression> filter = null, bool recursive = true) diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index ed6a263b4c..f8b8882d3d 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -1,13 +1,16 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Threading.Tasks; +using OpenTK; +using OpenTK.Input; using osu.Framework.Allocation; using osu.Framework.Audio.Track; using osu.Framework.Configuration; using osu.Framework.Graphics; +using osu.Framework.Input; using osu.Framework.MathUtils; using osu.Framework.Screens; -using osu.Game.Beatmaps; using osu.Game.Configuration; using osu.Game.Database; using osu.Game.Graphics.Containers; @@ -16,14 +19,8 @@ using osu.Game.Screens.Charts; using osu.Game.Screens.Direct; using osu.Game.Screens.Edit; using osu.Game.Screens.Multiplayer; -using OpenTK; using osu.Game.Screens.Select; using osu.Game.Screens.Tournament; -using osu.Framework.Input; -using OpenTK.Input; -using System.Threading.Tasks; -using System.Collections.Generic; -using System.Linq; namespace osu.Game.Screens.Menu { @@ -75,10 +72,15 @@ namespace osu.Game.Screens.Menu if (!menuMusic) { trackManager = game.Audio.Track; - List choosableBeatmapSets = beatmaps.Query().ToList(); - if (choosableBeatmapSets.Count > 0) + + var query = beatmaps.Query().Where(b => !b.DeletePending); + int count = query.Count(); + + if (count > 0) { - Beatmap = beatmaps.GetWorkingBeatmap(beatmaps.GetWithChildren(choosableBeatmapSets[RNG.Next(0, choosableBeatmapSets.Count - 1)].ID).Beatmaps[0]); + var beatmap = query.ElementAt(RNG.Next(0, count - 1)); + beatmaps.GetChildren(beatmap, true); + Beatmap = beatmaps.GetWorkingBeatmap(beatmap.Beatmaps[0]); } } diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index d05dd43b63..fbdaa948cc 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -220,13 +220,11 @@ namespace osu.Game.Screens.Select private BeatmapGroup createGroup(BeatmapSetInfo beatmapSet) { - database.GetChildren(beatmapSet); - beatmapSet.Beatmaps.ForEach(b => + foreach(var b in beatmapSet.Beatmaps) { - database.GetChildren(b); if (b.Metadata == null) b.Metadata = beatmapSet.Metadata; - }); + } return new BeatmapGroup(beatmapSet, database) { diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 4d7904123c..51b67bdbef 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -183,7 +183,7 @@ namespace osu.Game.Screens.Select initialAddSetsTask = new CancellationTokenSource(); carousel.BeatmapsChanged = beatmapsLoaded; - carousel.Beatmaps = database.Query().Where(b => !b.DeletePending); + carousel.Beatmaps = database.GetAllWithChildren(b => !b.DeletePending); } private void beatmapsLoaded() From f37c857af8566c6366866f4d30acb72e028b2f46 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Sat, 6 May 2017 16:06:38 +0800 Subject: [PATCH 086/329] CI fixes. --- osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs | 4 ++-- osu.Game/Screens/Select/BeatmapDeleteDialog.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs index cba150f91d..e259f700b1 100644 --- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs @@ -118,7 +118,7 @@ namespace osu.Game.Tests.Beatmaps.IO Action waitAction = () => { while (!(resultSets = host.Dependencies.Get() - .GetAllWithChildren(s => s.OnlineBeatmapSetID == 241526)).Any()) + .Query().Where(s => s.OnlineBeatmapSetID == 241526)).Any()) Thread.Sleep(50); }; @@ -142,7 +142,7 @@ namespace osu.Game.Tests.Beatmaps.IO Assert.IsTrue(waitAction.BeginInvoke(null, null).AsyncWaitHandle.WaitOne(timeout), @"Beatmaps did not import to the database in allocated time"); - var set = resultSets.First(); + var set = host.Dependencies.Get().GetChildren(resultSets.First(), true); Assert.IsTrue(set.Beatmaps.Count == resultBeatmaps.Count(), $@"Incorrect database beatmap count post-import ({resultBeatmaps.Count()} but should be {set.Beatmaps.Count})."); diff --git a/osu.Game/Screens/Select/BeatmapDeleteDialog.cs b/osu.Game/Screens/Select/BeatmapDeleteDialog.cs index ac35f0e254..0890625eb9 100644 --- a/osu.Game/Screens/Select/BeatmapDeleteDialog.cs +++ b/osu.Game/Screens/Select/BeatmapDeleteDialog.cs @@ -26,7 +26,7 @@ namespace osu.Game.Screens.Select Icon = FontAwesome.fa_trash_o; HeaderText = @"Confirm deletion of"; - BodyText = $@"{beatmap?.Metadata?.Artist} - {beatmap?.Metadata?.Title}"; + BodyText = $@"{beatmap.Metadata?.Artist} - {beatmap.Metadata?.Title}"; Buttons = new PopupDialogButton[] { new PopupDialogOkButton From 4f8549f220e9da6eedb24fe37b0543a7189ff8ea Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Sun, 7 May 2017 00:38:17 +0800 Subject: [PATCH 087/329] Standardise usages of exceptions. --- osu.Game.Rulesets.Osu/Replays/OsuAutoGeneratorBase.cs | 4 ++-- osu.Game.Rulesets.Taiko/Replays/TaikoAutoGenerator.cs | 2 +- osu.Game/Database/ScoreDatabase.cs | 4 ++-- osu.Game/Graphics/OsuColour.cs | 2 +- osu.Game/Rulesets/UI/HitRenderer.cs | 2 +- osu.Game/Screens/Play/Player.cs | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Replays/OsuAutoGeneratorBase.cs b/osu.Game.Rulesets.Osu/Replays/OsuAutoGeneratorBase.cs index d2cd7a1156..65ed9530f2 100644 --- a/osu.Game.Rulesets.Osu/Replays/OsuAutoGeneratorBase.cs +++ b/osu.Game.Rulesets.Osu/Replays/OsuAutoGeneratorBase.cs @@ -58,8 +58,8 @@ namespace osu.Game.Rulesets.Osu.Replays { public int Compare(ReplayFrame f1, ReplayFrame f2) { - if (f1 == null) throw new NullReferenceException($@"{nameof(f1)} cannot be null"); - if (f2 == null) throw new NullReferenceException($@"{nameof(f2)} cannot be null"); + if (f1 == null) throw new ArgumentNullException(nameof(f1)); + if (f2 == null) throw new ArgumentNullException(nameof(f2)); return f1.Time.CompareTo(f2.Time); } diff --git a/osu.Game.Rulesets.Taiko/Replays/TaikoAutoGenerator.cs b/osu.Game.Rulesets.Taiko/Replays/TaikoAutoGenerator.cs index eec614426f..c3e5597f43 100644 --- a/osu.Game.Rulesets.Taiko/Replays/TaikoAutoGenerator.cs +++ b/osu.Game.Rulesets.Taiko/Replays/TaikoAutoGenerator.cs @@ -109,7 +109,7 @@ namespace osu.Game.Rulesets.Taiko.Replays Frames.Add(new ReplayFrame(h.StartTime, null, null, button)); } else - throw new Exception("Unknown hit object type."); + throw new InvalidOperationException("Unknown hit object type."); Frames.Add(new ReplayFrame(endTime + KEY_UP_DELAY, null, null, ReplayButtonState.None)); diff --git a/osu.Game/Database/ScoreDatabase.cs b/osu.Game/Database/ScoreDatabase.cs index 8ea836aceb..adca76d2ac 100644 --- a/osu.Game/Database/ScoreDatabase.cs +++ b/osu.Game/Database/ScoreDatabase.cs @@ -94,13 +94,13 @@ namespace osu.Game.Database { byte[] properties = new byte[5]; if (replayInStream.Read(properties, 0, 5) != 5) - throw new Exception("input .lzma is too short"); + throw new IOException("input .lzma is too short"); long outSize = 0; for (int i = 0; i < 8; i++) { int v = replayInStream.ReadByte(); if (v < 0) - throw new Exception("Can't Read 1"); + throw new IOException("Can't Read 1"); outSize |= (long)(byte)v << (8 * i); } diff --git a/osu.Game/Graphics/OsuColour.cs b/osu.Game/Graphics/OsuColour.cs index cd719431e7..15ffefc45d 100644 --- a/osu.Game/Graphics/OsuColour.cs +++ b/osu.Game/Graphics/OsuColour.cs @@ -16,7 +16,7 @@ namespace osu.Game.Graphics switch (hex.Length) { default: - throw new Exception(@"Invalid hex string length!"); + throw new ArgumentException(@"Invalid hex string length!"); case 3: return new Color4( (byte)(Convert.ToByte(hex.Substring(0, 1), 16) * 17), diff --git a/osu.Game/Rulesets/UI/HitRenderer.cs b/osu.Game/Rulesets/UI/HitRenderer.cs index 69e0e73664..8ee67df95a 100644 --- a/osu.Game/Rulesets/UI/HitRenderer.cs +++ b/osu.Game/Rulesets/UI/HitRenderer.cs @@ -279,7 +279,7 @@ namespace osu.Game.Rulesets.UI protected abstract Playfield CreatePlayfield(); } - public class BeatmapInvalidForRulesetException : Exception + public class BeatmapInvalidForRulesetException : ArgumentException { public BeatmapInvalidForRulesetException(string text) : base(text) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 37b4cf5b45..67bf1e8192 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -90,7 +90,7 @@ namespace osu.Game.Screens.Play Beatmap = beatmaps.GetWorkingBeatmap(BeatmapInfo, withStoryboard: true); if (Beatmap?.Beatmap == null) - throw new Exception("Beatmap was not loaded"); + throw new InvalidOperationException("Beatmap was not loaded"); ruleset = osu?.Ruleset.Value ?? Beatmap.BeatmapInfo.Ruleset; rulesetInstance = ruleset.CreateInstance(); @@ -109,7 +109,7 @@ namespace osu.Game.Screens.Play } if (!HitRenderer.Objects.Any()) - throw new Exception("Beatmap contains no hit objects!"); + throw new InvalidOperationException("Beatmap contains no hit objects!"); } catch (Exception e) { From 3c4faae554d6f99bc1628fdec84d38ecd8f76f60 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Sun, 7 May 2017 20:35:57 +0200 Subject: [PATCH 088/329] add search box and the ability to search --- osu.Game/Overlays/Options/OptionsSection.cs | 17 +++++++++++++++-- osu.Game/Overlays/Options/OptionsSubsection.cs | 14 +++++++++++++- osu.Game/Overlays/OptionsOverlay.cs | 14 +++++++++++++- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Options/OptionsSection.cs b/osu.Game/Overlays/Options/OptionsSection.cs index d5dafad9ba..4069503a51 100644 --- a/osu.Game/Overlays/Options/OptionsSection.cs +++ b/osu.Game/Overlays/Options/OptionsSection.cs @@ -1,4 +1,6 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . +using System; +using System.Collections.Generic; +// Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK; @@ -10,10 +12,11 @@ using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using System.Linq; namespace osu.Game.Overlays.Options { - public abstract class OptionsSection : Container + public abstract class OptionsSection : Container, IHasFilterableChildren { protected FillFlowContainer FlowContent; protected override Container Content => FlowContent; @@ -21,6 +24,16 @@ namespace osu.Game.Overlays.Options public abstract FontAwesome Icon { get; } public abstract string Header { get; } + public IEnumerable FilterableChildren => Children.OfType(); + public string[] FilterTerms => new[] { Header }; + public bool MatchingCurrentFilter + { + set + { + FadeTo(value ? 1 : 0); + } + } + private readonly SpriteText headerLabel; protected OptionsSection() diff --git a/osu.Game/Overlays/Options/OptionsSubsection.cs b/osu.Game/Overlays/Options/OptionsSubsection.cs index 9fd2e8fb1e..ff9e60c273 100644 --- a/osu.Game/Overlays/Options/OptionsSubsection.cs +++ b/osu.Game/Overlays/Options/OptionsSubsection.cs @@ -6,10 +6,12 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Game.Graphics.Sprites; +using System.Collections.Generic; +using System.Linq; namespace osu.Game.Overlays.Options { - public abstract class OptionsSubsection : FillFlowContainer + public abstract class OptionsSubsection : FillFlowContainer, IHasFilterableChildren { protected override Container Content => content; @@ -17,6 +19,16 @@ namespace osu.Game.Overlays.Options protected abstract string Header { get; } + public IEnumerable FilterableChildren => Children.OfType(); + public string[] FilterTerms => new[] { Header }; + public bool MatchingCurrentFilter + { + set + { + FadeTo(value ? 1 : 0); + } + } + protected OptionsSubsection() { RelativeSizeAxes = Axes.X; diff --git a/osu.Game/Overlays/OptionsOverlay.cs b/osu.Game/Overlays/OptionsOverlay.cs index dcbce80c69..afe998c208 100644 --- a/osu.Game/Overlays/OptionsOverlay.cs +++ b/osu.Game/Overlays/OptionsOverlay.cs @@ -13,6 +13,7 @@ using System; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Overlays.Options.Sections; +using osu.Game.Graphics.UserInterface; namespace osu.Game.Overlays { @@ -32,6 +33,7 @@ namespace osu.Game.Overlays private Sidebar sidebar; private SidebarButton[] sidebarButtons; private OptionsSection[] sections; + private SearchContainer searchContainer; private float lastKnownScroll; public OptionsOverlay() @@ -43,6 +45,8 @@ namespace osu.Game.Overlays [BackgroundDependencyLoader(permitNulls: true)] private void load(OsuGame game, OsuColour colours) { + OsuTextBox textBox; + sections = new OptionsSection[] { new GeneralSection(), @@ -92,7 +96,13 @@ namespace osu.Game.Overlays TextSize = 18, Margin = new MarginPadding { Left = CONTENT_MARGINS, Bottom = 30 }, }, - new FillFlowContainer + textBox = new OsuTextBox + { + PlaceholderText = "Type to search!", + Width = width - CONTENT_MARGINS * 2, + Margin = new MarginPadding { Left = CONTENT_MARGINS }, + }, + searchContainer = new SearchContainer { AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, @@ -118,6 +128,8 @@ namespace osu.Game.Overlays } }; + textBox.Current.ValueChanged += newValue => searchContainer.SearchTerm = newValue; + scrollContainer.Padding = new MarginPadding { Top = game?.Toolbar.DrawHeight ?? 0 }; } From ea28a9f7ce2dfcba262710137478e46d543a6c8a Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Mon, 8 May 2017 00:16:58 +0300 Subject: [PATCH 089/329] Adjust values --- osu.Game/Screens/Play/SongProgress.cs | 11 +++--- osu.Game/Screens/Play/SongProgressInfo.cs | 48 +++++++++++++++++++---- 2 files changed, 47 insertions(+), 12 deletions(-) diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 35aeb33528..b0a77afa51 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -139,15 +139,16 @@ namespace osu.Game.Screens.Play if (objects == null) return; - double currentTime = AudioClock?.CurrentTime ?? Time.Current; - double progress = (currentTime - firstHitTime) / lastHitTime; + double drawableCurrentTime = AudioClock?.CurrentTime ?? Time.Current; + double songCurrentTime = drawableCurrentTime - firstHitTime; + double progress = songCurrentTime / lastHitTime; bar.UpdatePosition((float)progress); graph.Progress = (int)(graph.ColumnCount * progress); - info.TimeCurrent = currentTime; - info.TimeLeft = lastHitTime - currentTime; - info.Progress = (int)(currentTime / lastHitTime * 100); + info.Progress = (int)(progress * 100); + info.TimeCurrent = songCurrentTime; + info.TimeLeft = lastHitTime - firstHitTime - songCurrentTime; } } } diff --git a/osu.Game/Screens/Play/SongProgressInfo.cs b/osu.Game/Screens/Play/SongProgressInfo.cs index ffee4e4094..17623ca9f7 100644 --- a/osu.Game/Screens/Play/SongProgressInfo.cs +++ b/osu.Game/Screens/Play/SongProgressInfo.cs @@ -13,22 +13,54 @@ namespace osu.Game.Screens.Play { public class SongProgressInfo : Container { - private OsuSpriteText timeCurrent; + private OsuSpriteText timeCurrentText; private OsuSpriteText timeLeft; - private OsuSpriteText progress; + private OsuSpriteText progressText; + + private int progress; + private double timeCurrent; private const int margin = 10; - public double TimeCurrent { set { timeCurrent.Text = TimeSpan.FromMilliseconds(value).ToString(@"m\:ss"); } } - public double TimeLeft { set { timeLeft.Text = @"- " + TimeSpan.FromMilliseconds(value).ToString(@"m\:ss"); } } - public int Progress { set { progress.Text = value.ToString() + @"%"; } } + public double TimeCurrent + { + set + { + timeCurrent = value; + + if (value > 0) + timeCurrentText.Text = TimeSpan.FromMilliseconds(value).ToString(@"m\:ss"); + } + } + public double TimeLeft + { + set + { + if(timeCurrent < 0) + timeLeft.Text = @"-" + TimeSpan.FromMilliseconds(value + timeCurrent).ToString(@"m\:ss"); + else + timeLeft.Text = @"-" + TimeSpan.FromMilliseconds(value).ToString(@"m\:ss"); + } + } + public int Progress + { + set + { + if (progress == value) + return; + + progress = value; + if (value > 0) + progressText.Text = value.ToString() + @"%"; + } + } [BackgroundDependencyLoader] private void load(OsuColour colours) { Children = new Drawable[] { - timeCurrent = new OsuSpriteText + timeCurrentText = new OsuSpriteText { Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, @@ -38,13 +70,15 @@ namespace osu.Game.Screens.Play { Left = margin, }, + Text = @"0:00", }, - progress = new OsuSpriteText + progressText = new OsuSpriteText { Origin = Anchor.BottomCentre, Anchor = Anchor.BottomCentre, Colour = colours.BlueLighter, Font = @"Venera", + Text = @"0%", }, timeLeft = new OsuSpriteText { From 531f2c410a3a9145ba7b08cd2d4b11b0d3098458 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Mon, 8 May 2017 00:26:34 +0300 Subject: [PATCH 090/329] removed useless variable --- osu.Game/Screens/Play/SongProgress.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index b0a77afa51..6489391d6a 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -139,16 +139,15 @@ namespace osu.Game.Screens.Play if (objects == null) return; - double drawableCurrentTime = AudioClock?.CurrentTime ?? Time.Current; - double songCurrentTime = drawableCurrentTime - firstHitTime; - double progress = songCurrentTime / lastHitTime; + double currentTime = (AudioClock?.CurrentTime ?? Time.Current) - firstHitTime; + double progress = currentTime / lastHitTime; bar.UpdatePosition((float)progress); graph.Progress = (int)(graph.ColumnCount * progress); info.Progress = (int)(progress * 100); - info.TimeCurrent = songCurrentTime; - info.TimeLeft = lastHitTime - firstHitTime - songCurrentTime; + info.TimeCurrent = currentTime; + info.TimeLeft = lastHitTime - firstHitTime - currentTime; } } } From c3a42ded361f647055774a3ac3284555cdf0f32d Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Mon, 8 May 2017 01:23:51 +0300 Subject: [PATCH 091/329] Fixed Graph/seeking offset --- osu.Game/Screens/Play/SongProgress.cs | 2 +- osu.Game/Screens/Play/SongProgressGraph.cs | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 6489391d6a..737c65397c 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -140,7 +140,7 @@ namespace osu.Game.Screens.Play return; double currentTime = (AudioClock?.CurrentTime ?? Time.Current) - firstHitTime; - double progress = currentTime / lastHitTime; + double progress = currentTime / (lastHitTime-firstHitTime); bar.UpdatePosition((float)progress); graph.Progress = (int)(graph.ColumnCount * progress); diff --git a/osu.Game/Screens/Play/SongProgressGraph.cs b/osu.Game/Screens/Play/SongProgressGraph.cs index 20548970e5..4e56f60c31 100644 --- a/osu.Game/Screens/Play/SongProgressGraph.cs +++ b/osu.Game/Screens/Play/SongProgressGraph.cs @@ -20,12 +20,13 @@ namespace osu.Game.Screens.Play const int granularity = 200; + var firstHit = objects.First().StartTime; var lastHit = (objects.Last() as IHasEndTime)?.EndTime ?? 0; if (lastHit == 0) lastHit = objects.Last().StartTime; - var interval = (lastHit + 1) / granularity; + var interval = (lastHit - firstHit + 1) / granularity; var values = new int[granularity]; @@ -33,8 +34,8 @@ namespace osu.Game.Screens.Play { IHasEndTime end = h as IHasEndTime; - int startRange = (int)(h.StartTime / interval); - int endRange = (int)((end?.EndTime > 0 ? end.EndTime : h.StartTime) / interval); + int startRange = (int)((h.StartTime - firstHit)/ interval); + int endRange = (int)(((end?.EndTime > 0 ? end.EndTime : h.StartTime) - firstHit) / interval); for (int i = startRange; i <= endRange; i++) values[i]++; } From dda25219bc07efba77c22e02856536d471ff976e Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Mon, 8 May 2017 01:54:31 +0300 Subject: [PATCH 092/329] code fixes --- osu.Game/Screens/Play/SongProgress.cs | 2 +- osu.Game/Screens/Play/SongProgressInfo.cs | 11 +---------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 737c65397c..020a26f703 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -140,7 +140,7 @@ namespace osu.Game.Screens.Play return; double currentTime = (AudioClock?.CurrentTime ?? Time.Current) - firstHitTime; - double progress = currentTime / (lastHitTime-firstHitTime); + double progress = currentTime / (lastHitTime - firstHitTime); bar.UpdatePosition((float)progress); graph.Progress = (int)(graph.ColumnCount * progress); diff --git a/osu.Game/Screens/Play/SongProgressInfo.cs b/osu.Game/Screens/Play/SongProgressInfo.cs index 17623ca9f7..d2b236035d 100644 --- a/osu.Game/Screens/Play/SongProgressInfo.cs +++ b/osu.Game/Screens/Play/SongProgressInfo.cs @@ -32,16 +32,7 @@ namespace osu.Game.Screens.Play timeCurrentText.Text = TimeSpan.FromMilliseconds(value).ToString(@"m\:ss"); } } - public double TimeLeft - { - set - { - if(timeCurrent < 0) - timeLeft.Text = @"-" + TimeSpan.FromMilliseconds(value + timeCurrent).ToString(@"m\:ss"); - else - timeLeft.Text = @"-" + TimeSpan.FromMilliseconds(value).ToString(@"m\:ss"); - } - } + public double TimeLeft { set { timeLeft.Text = @"-" + TimeSpan.FromMilliseconds((timeCurrent < 0) ? (value + timeCurrent) : value).ToString(@"m\:ss"); } } public int Progress { set From 926ed907c26cdc3d18de40efa38c1c71beab37ff Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Mon, 8 May 2017 02:00:21 +0300 Subject: [PATCH 093/329] CI fixes --- osu.Game/Screens/Play/SongProgressInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/SongProgressInfo.cs b/osu.Game/Screens/Play/SongProgressInfo.cs index d2b236035d..12752e09c3 100644 --- a/osu.Game/Screens/Play/SongProgressInfo.cs +++ b/osu.Game/Screens/Play/SongProgressInfo.cs @@ -32,7 +32,7 @@ namespace osu.Game.Screens.Play timeCurrentText.Text = TimeSpan.FromMilliseconds(value).ToString(@"m\:ss"); } } - public double TimeLeft { set { timeLeft.Text = @"-" + TimeSpan.FromMilliseconds((timeCurrent < 0) ? (value + timeCurrent) : value).ToString(@"m\:ss"); } } + public double TimeLeft { set { timeLeft.Text = @"-" + TimeSpan.FromMilliseconds(timeCurrent < 0 ? value + timeCurrent : value).ToString(@"m\:ss"); } } public int Progress { set From f0145c7f4f6ab6cb533b39e009e80d6942cc9515 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Mon, 8 May 2017 02:16:56 +0300 Subject: [PATCH 094/329] Trying to woke up AppVeyor --- osu.Game/Screens/Play/SongProgressInfo.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Screens/Play/SongProgressInfo.cs b/osu.Game/Screens/Play/SongProgressInfo.cs index 12752e09c3..5b33e6d8af 100644 --- a/osu.Game/Screens/Play/SongProgressInfo.cs +++ b/osu.Game/Screens/Play/SongProgressInfo.cs @@ -27,7 +27,6 @@ namespace osu.Game.Screens.Play set { timeCurrent = value; - if (value > 0) timeCurrentText.Text = TimeSpan.FromMilliseconds(value).ToString(@"m\:ss"); } From fbf05f12fc24522c2db333d0ac6e67b2238029c3 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Mon, 8 May 2017 10:11:45 +0900 Subject: [PATCH 095/329] 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 de8428c95bf09b7323e9e12af99bca15ed7afb65 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sun, 7 May 2017 22:23:33 -0300 Subject: [PATCH 096/329] Make requested changes --- osu.Game/Overlays/Music/PlaylistOverlay.cs | 2 +- osu.Game/Screens/Select/SearchTextBox.cs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Music/PlaylistOverlay.cs b/osu.Game/Overlays/Music/PlaylistOverlay.cs index 00d66053a7..0cae9db2e6 100644 --- a/osu.Game/Overlays/Music/PlaylistOverlay.cs +++ b/osu.Game/Overlays/Music/PlaylistOverlay.cs @@ -85,7 +85,7 @@ namespace osu.Game.Overlays.Music beatmapBacking.BindTo(game.Beatmap); - filter.Search.OnCommit = delegate { + filter.Search.OnCommit = (sender, newText) => { var beatmap = list.FirstVisibleSet?.Beatmaps?.ValueAtOrDefault(0); if (beatmap != null) playSpecified(beatmap); }; diff --git a/osu.Game/Screens/Select/SearchTextBox.cs b/osu.Game/Screens/Select/SearchTextBox.cs index 743b1fc5c7..d451f63a96 100644 --- a/osu.Game/Screens/Select/SearchTextBox.cs +++ b/osu.Game/Screens/Select/SearchTextBox.cs @@ -48,7 +48,6 @@ namespace osu.Game.Screens.Select case Key.Up: case Key.Down: return false; - case Key.Enter: if (!AllowCommit) return false; break; From 2f4fad9d416ad0620b35f37ca59bf41559c22e38 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 8 May 2017 11:33:22 +0900 Subject: [PATCH 097/329] 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 098/329] 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 099/329] 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 100/329] 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; From 4c26a02e99bc59bfde504b54537fb1afd04065db Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Mon, 8 May 2017 16:42:53 +0800 Subject: [PATCH 101/329] Remove unnecessary arguments in WorkingBeatmap's constructor. --- osu.Game/Beatmaps/WorkingBeatmap.cs | 6 +++--- osu.Game/Database/BeatmapDatabase.cs | 2 +- osu.Game/Database/DatabaseWorkingBeatmap.cs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index 09a6ea7065..0e8d8a9546 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -24,11 +24,11 @@ namespace osu.Game.Beatmaps public readonly bool WithStoryboard; - protected WorkingBeatmap(BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo = null, BeatmapMetadata metadata = null, bool withStoryboard = false) + protected WorkingBeatmap(BeatmapInfo beatmapInfo, bool withStoryboard = false) { BeatmapInfo = beatmapInfo; - BeatmapSetInfo = beatmapSetInfo ?? beatmapInfo?.BeatmapSet; - Metadata = metadata ?? beatmapInfo?.Metadata ?? BeatmapSetInfo?.Metadata; + BeatmapSetInfo = beatmapInfo.BeatmapSet; + Metadata = beatmapInfo.Metadata ?? BeatmapSetInfo.Metadata; WithStoryboard = withStoryboard; Mods.ValueChanged += mods => applyRateAdjustments(); diff --git a/osu.Game/Database/BeatmapDatabase.cs b/osu.Game/Database/BeatmapDatabase.cs index 811a067116..760b7ae353 100644 --- a/osu.Game/Database/BeatmapDatabase.cs +++ b/osu.Game/Database/BeatmapDatabase.cs @@ -273,7 +273,7 @@ namespace osu.Game.Database if (beatmapInfo.Metadata == null) beatmapInfo.Metadata = beatmapInfo.BeatmapSet.Metadata; - WorkingBeatmap working = new DatabaseWorkingBeatmap(this, beatmapInfo, withStoryboard: withStoryboard); + WorkingBeatmap working = new DatabaseWorkingBeatmap(this, beatmapInfo, withStoryboard); previous?.TransferTo(working); diff --git a/osu.Game/Database/DatabaseWorkingBeatmap.cs b/osu.Game/Database/DatabaseWorkingBeatmap.cs index 1c160a14e4..c56d6cea51 100644 --- a/osu.Game/Database/DatabaseWorkingBeatmap.cs +++ b/osu.Game/Database/DatabaseWorkingBeatmap.cs @@ -14,8 +14,8 @@ namespace osu.Game.Database { private readonly BeatmapDatabase database; - public DatabaseWorkingBeatmap(BeatmapDatabase database, BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo = null, BeatmapMetadata metadata = null, bool withStoryboard = false) - : base(beatmapInfo, beatmapSetInfo, metadata, withStoryboard) + public DatabaseWorkingBeatmap(BeatmapDatabase database, BeatmapInfo beatmapInfo, bool withStoryboard = false) + : base(beatmapInfo, withStoryboard) { this.database = database; } From dff05bec797551f83239650c6a73a82cfa9f4510 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Mon, 8 May 2017 18:56:04 +0800 Subject: [PATCH 102/329] Use readonly fields. --- .../Beatmaps/IO/LegacyFilesystemReader.cs | 2 +- osu.Game/Beatmaps/Formats/BeatmapDecoder.cs | 2 +- osu.Game/Beatmaps/IO/ArchiveReader.cs | 6 +- osu.Game/Graphics/OsuColour.cs | 92 +++++++++---------- osu.Game/Online/Chat/Channel.cs | 2 +- osu.Game/Overlays/Mods/ModButton.cs | 2 +- osu.Game/Screens/Menu/OsuLogo.cs | 2 +- 7 files changed, 54 insertions(+), 54 deletions(-) diff --git a/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs b/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs index abc45d82ec..8c896646bf 100644 --- a/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs +++ b/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs @@ -14,7 +14,7 @@ namespace osu.Desktop.Beatmaps.IO { public static void Register() => AddReader((storage, path) => Directory.Exists(path)); - private string basePath { get; } + private readonly string basePath; public LegacyFilesystemReader(string path) { diff --git a/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs b/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs index cc9d367a59..21a3ab9842 100644 --- a/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs +++ b/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs @@ -11,7 +11,7 @@ namespace osu.Game.Beatmaps.Formats { public abstract class BeatmapDecoder { - private static Dictionary decoders { get; } = new Dictionary(); + private static readonly Dictionary decoders = new Dictionary(); public static BeatmapDecoder GetDecoder(StreamReader stream) { diff --git a/osu.Game/Beatmaps/IO/ArchiveReader.cs b/osu.Game/Beatmaps/IO/ArchiveReader.cs index 6c6b6be23c..9245c914a6 100644 --- a/osu.Game/Beatmaps/IO/ArchiveReader.cs +++ b/osu.Game/Beatmaps/IO/ArchiveReader.cs @@ -13,11 +13,11 @@ namespace osu.Game.Beatmaps.IO { private class Reader { - public Func Test { get; set; } - public Type Type { get; set; } + public Func Test; + public Type Type; } - private static List readers { get; } = new List(); + private static readonly List readers = new List(); public static ArchiveReader GetReader(Storage storage, string path) { diff --git a/osu.Game/Graphics/OsuColour.cs b/osu.Game/Graphics/OsuColour.cs index 15ffefc45d..b666442f19 100644 --- a/osu.Game/Graphics/OsuColour.cs +++ b/osu.Game/Graphics/OsuColour.cs @@ -33,57 +33,57 @@ namespace osu.Game.Graphics } // See https://github.com/ppy/osu-web/blob/master/resources/assets/less/colors.less - public Color4 PurpleLighter = FromHex(@"eeeeff"); - public Color4 PurpleLight = FromHex(@"aa88ff"); - public Color4 Purple = FromHex(@"8866ee"); - public Color4 PurpleDark = FromHex(@"6644cc"); - public Color4 PurpleDarker = FromHex(@"441188"); + public readonly Color4 PurpleLighter = FromHex(@"eeeeff"); + public readonly Color4 PurpleLight = FromHex(@"aa88ff"); + public readonly Color4 Purple = FromHex(@"8866ee"); + public readonly Color4 PurpleDark = FromHex(@"6644cc"); + public readonly Color4 PurpleDarker = FromHex(@"441188"); - public Color4 PinkLighter = FromHex(@"ffddee"); - public Color4 PinkLight = FromHex(@"ff99cc"); - public Color4 Pink = FromHex(@"ff66aa"); - public Color4 PinkDark = FromHex(@"cc5288"); - public Color4 PinkDarker = FromHex(@"bb1177"); + public readonly Color4 PinkLighter = FromHex(@"ffddee"); + public readonly Color4 PinkLight = FromHex(@"ff99cc"); + public readonly Color4 Pink = FromHex(@"ff66aa"); + public readonly Color4 PinkDark = FromHex(@"cc5288"); + public readonly Color4 PinkDarker = FromHex(@"bb1177"); - public Color4 BlueLighter = FromHex(@"ddffff"); - public Color4 BlueLight = FromHex(@"99eeff"); - public Color4 Blue = FromHex(@"66ccff"); - public Color4 BlueDark = FromHex(@"44aadd"); - public Color4 BlueDarker = FromHex(@"2299bb"); + public readonly Color4 BlueLighter = FromHex(@"ddffff"); + public readonly Color4 BlueLight = FromHex(@"99eeff"); + public readonly Color4 Blue = FromHex(@"66ccff"); + public readonly Color4 BlueDark = FromHex(@"44aadd"); + public readonly Color4 BlueDarker = FromHex(@"2299bb"); - public Color4 YellowLighter = FromHex(@"ffffdd"); - public Color4 YellowLight = FromHex(@"ffdd55"); - public Color4 Yellow = FromHex(@"ffcc22"); - public Color4 YellowDark = FromHex(@"eeaa00"); - public Color4 YellowDarker = FromHex(@"cc6600"); + public readonly Color4 YellowLighter = FromHex(@"ffffdd"); + public readonly Color4 YellowLight = FromHex(@"ffdd55"); + public readonly Color4 Yellow = FromHex(@"ffcc22"); + public readonly Color4 YellowDark = FromHex(@"eeaa00"); + public readonly Color4 YellowDarker = FromHex(@"cc6600"); - public Color4 GreenLighter = FromHex(@"eeffcc"); - public Color4 GreenLight = FromHex(@"b3d944"); - public Color4 Green = FromHex(@"88b300"); - public Color4 GreenDark = FromHex(@"668800"); - public Color4 GreenDarker = FromHex(@"445500"); + public readonly Color4 GreenLighter = FromHex(@"eeffcc"); + public readonly Color4 GreenLight = FromHex(@"b3d944"); + public readonly Color4 Green = FromHex(@"88b300"); + public readonly Color4 GreenDark = FromHex(@"668800"); + public readonly Color4 GreenDarker = FromHex(@"445500"); - public Color4 Gray0 = FromHex(@"000"); - public Color4 Gray1 = FromHex(@"111"); - public Color4 Gray2 = FromHex(@"222"); - public Color4 Gray3 = FromHex(@"333"); - public Color4 Gray4 = FromHex(@"444"); - public Color4 Gray5 = FromHex(@"555"); - public Color4 Gray6 = FromHex(@"666"); - public Color4 Gray7 = FromHex(@"777"); - public Color4 Gray8 = FromHex(@"888"); - public Color4 Gray9 = FromHex(@"999"); - public Color4 GrayA = FromHex(@"aaa"); - public Color4 GrayB = FromHex(@"bbb"); - public Color4 GrayC = FromHex(@"ccc"); - public Color4 GrayD = FromHex(@"ddd"); - public Color4 GrayE = FromHex(@"eee"); - public Color4 GrayF = FromHex(@"fff"); + public readonly Color4 Gray0 = FromHex(@"000"); + public readonly Color4 Gray1 = FromHex(@"111"); + public readonly Color4 Gray2 = FromHex(@"222"); + public readonly Color4 Gray3 = FromHex(@"333"); + public readonly Color4 Gray4 = FromHex(@"444"); + public readonly Color4 Gray5 = FromHex(@"555"); + public readonly Color4 Gray6 = FromHex(@"666"); + public readonly Color4 Gray7 = FromHex(@"777"); + public readonly Color4 Gray8 = FromHex(@"888"); + public readonly Color4 Gray9 = FromHex(@"999"); + public readonly Color4 GrayA = FromHex(@"aaa"); + public readonly Color4 GrayB = FromHex(@"bbb"); + public readonly Color4 GrayC = FromHex(@"ccc"); + public readonly Color4 GrayD = FromHex(@"ddd"); + public readonly Color4 GrayE = FromHex(@"eee"); + public readonly Color4 GrayF = FromHex(@"fff"); - public Color4 RedLighter = FromHex(@"ffeded"); - public Color4 RedLight = FromHex(@"ed7787"); - public Color4 Red = FromHex(@"ed1121"); - public Color4 RedDark = FromHex(@"ba0011"); - public Color4 RedDarker = FromHex(@"870000"); + public readonly Color4 RedLighter = FromHex(@"ffeded"); + public readonly Color4 RedLight = FromHex(@"ed7787"); + public readonly Color4 Red = FromHex(@"ed1121"); + public readonly Color4 RedDark = FromHex(@"ba0011"); + public readonly Color4 RedDarker = FromHex(@"870000"); } } diff --git a/osu.Game/Online/Chat/Channel.cs b/osu.Game/Online/Chat/Channel.cs index 04ebf0a389..d3bd57a1c9 100644 --- a/osu.Game/Online/Chat/Channel.cs +++ b/osu.Game/Online/Chat/Channel.cs @@ -23,7 +23,7 @@ namespace osu.Game.Online.Chat [JsonProperty(@"channel_id")] public int Id; - public SortedList Messages = new SortedList((m1, m2) => m1.Id.CompareTo(m2.Id)); + public readonly SortedList Messages = new SortedList((m1, m2) => m1.Id.CompareTo(m2.Id)); //internal bool Joined; diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs index f380c19d8a..d7a91e2caa 100644 --- a/osu.Game/Overlays/Mods/ModButton.cs +++ b/osu.Game/Overlays/Mods/ModButton.cs @@ -21,7 +21,7 @@ namespace osu.Game.Overlays.Mods { public class ModButton : FillFlowContainer { - private ModIcon foregroundIcon { get; set; } + private ModIcon foregroundIcon; private readonly SpriteText text; private readonly Container iconsContainer; private SampleChannel sampleOn, sampleOff; diff --git a/osu.Game/Screens/Menu/OsuLogo.cs b/osu.Game/Screens/Menu/OsuLogo.cs index 29f6cb2967..f3fffedd43 100644 --- a/osu.Game/Screens/Menu/OsuLogo.cs +++ b/osu.Game/Screens/Menu/OsuLogo.cs @@ -22,7 +22,7 @@ namespace osu.Game.Screens.Menu /// public class OsuLogo : Container { - public Color4 OsuPink = OsuColour.FromHex(@"e967a1"); + public readonly Color4 OsuPink = OsuColour.FromHex(@"e967a1"); private readonly Sprite logo; private readonly CircularContainer logoContainer; From 345f80b775e805d4e4465b20285fc6afef8ab98c Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Mon, 8 May 2017 19:30:55 +0800 Subject: [PATCH 103/329] Simplify constructor of SampleInfoList. --- osu.Game/Audio/SampleInfoList.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Audio/SampleInfoList.cs b/osu.Game/Audio/SampleInfoList.cs index 594341bbb1..06dd716a4a 100644 --- a/osu.Game/Audio/SampleInfoList.cs +++ b/osu.Game/Audio/SampleInfoList.cs @@ -11,9 +11,8 @@ namespace osu.Game.Audio { } - public SampleInfoList(IEnumerable elements) + public SampleInfoList(IEnumerable elements) : base(elements) { - AddRange(elements); } } } \ No newline at end of file From e466380ee24352926fde9f4a2cba400eb88eb0c3 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Mon, 8 May 2017 19:33:37 +0800 Subject: [PATCH 104/329] Generic infer for IJsonSerializable.DeepClone. --- osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs | 2 +- osu.Game/IO/Serialization/IJsonSerializable.cs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs b/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs index 0784c94059..355ce1cf68 100644 --- a/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs +++ b/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs @@ -44,7 +44,7 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps protected override Beatmap ConvertBeatmap(Beatmap original) { // Rewrite the beatmap info to add the slider velocity multiplier - BeatmapInfo info = original.BeatmapInfo.DeepClone(); + BeatmapInfo info = original.BeatmapInfo.DeepClone(); info.Difficulty.SliderMultiplier *= legacy_velocity_multiplier; Beatmap converted = base.ConvertBeatmap(original); diff --git a/osu.Game/IO/Serialization/IJsonSerializable.cs b/osu.Game/IO/Serialization/IJsonSerializable.cs index 33d0801e47..7dbc860979 100644 --- a/osu.Game/IO/Serialization/IJsonSerializable.cs +++ b/osu.Game/IO/Serialization/IJsonSerializable.cs @@ -16,12 +16,13 @@ namespace osu.Game.IO.Serialization return JsonConvert.SerializeObject(obj); } - public static T Deserialize(string objString) + public static T Deserialize(this string objString) { return JsonConvert.DeserializeObject(objString); } - public static T DeepClone(this IJsonSerializable obj) + public static T DeepClone(this T obj) + where T : IJsonSerializable { return Deserialize(Serialize(obj)); } From ced2332d20df70866b9fd458a5127de8aa0f59d7 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Mon, 8 May 2017 19:37:41 +0800 Subject: [PATCH 105/329] Handle overlay in ToolbarOverlayToggleButton. --- osu.Game/Overlays/Toolbar/ToolbarChatButton.cs | 1 - osu.Game/Overlays/Toolbar/ToolbarMusicButton.cs | 1 - osu.Game/Overlays/Toolbar/ToolbarNotificationButton.cs | 1 - osu.Game/Overlays/Toolbar/ToolbarOverlayToggleButton.cs | 1 + osu.Game/Overlays/Toolbar/ToolbarSettingsButton.cs | 1 - 5 files changed, 1 insertion(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Toolbar/ToolbarChatButton.cs b/osu.Game/Overlays/Toolbar/ToolbarChatButton.cs index ca612662e1..39909b8d5b 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarChatButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarChatButton.cs @@ -17,7 +17,6 @@ namespace osu.Game.Overlays.Toolbar private void load(ChatOverlay chat) { StateContainer = chat; - Action = chat.ToggleVisibility; } } } \ No newline at end of file diff --git a/osu.Game/Overlays/Toolbar/ToolbarMusicButton.cs b/osu.Game/Overlays/Toolbar/ToolbarMusicButton.cs index 725af09ee7..82599b9a0d 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarMusicButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarMusicButton.cs @@ -17,7 +17,6 @@ namespace osu.Game.Overlays.Toolbar private void load(MusicController music) { StateContainer = music; - Action = music.ToggleVisibility; } } } \ No newline at end of file diff --git a/osu.Game/Overlays/Toolbar/ToolbarNotificationButton.cs b/osu.Game/Overlays/Toolbar/ToolbarNotificationButton.cs index 4da87a0568..5126f6a2a4 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarNotificationButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarNotificationButton.cs @@ -22,7 +22,6 @@ namespace osu.Game.Overlays.Toolbar private void load(NotificationManager notificationManager) { StateContainer = notificationManager; - Action = notificationManager.ToggleVisibility; } } } \ No newline at end of file diff --git a/osu.Game/Overlays/Toolbar/ToolbarOverlayToggleButton.cs b/osu.Game/Overlays/Toolbar/ToolbarOverlayToggleButton.cs index 023d9cfea7..fa668bad60 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarOverlayToggleButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarOverlayToggleButton.cs @@ -21,6 +21,7 @@ namespace osu.Game.Overlays.Toolbar set { stateContainer = value; + Action = stateContainer.ToggleVisibility; stateContainer.StateChanged += stateChanged; } } diff --git a/osu.Game/Overlays/Toolbar/ToolbarSettingsButton.cs b/osu.Game/Overlays/Toolbar/ToolbarSettingsButton.cs index 9f8170b604..ae54b98aca 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarSettingsButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarSettingsButton.cs @@ -19,7 +19,6 @@ namespace osu.Game.Overlays.Toolbar private void load(OptionsOverlay options) { StateContainer = options; - Action = options.ToggleVisibility; } } } \ No newline at end of file From 01616cc27c59f5e1eb91eea322330b7e2cf46c1b Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Mon, 8 May 2017 19:41:22 +0800 Subject: [PATCH 106/329] Avoid extra MemoryStream in ArchiveReader. --- osu.Game/Beatmaps/IO/ArchiveReader.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/osu.Game/Beatmaps/IO/ArchiveReader.cs b/osu.Game/Beatmaps/IO/ArchiveReader.cs index 9245c914a6..9d7d67007e 100644 --- a/osu.Game/Beatmaps/IO/ArchiveReader.cs +++ b/osu.Game/Beatmaps/IO/ArchiveReader.cs @@ -58,11 +58,9 @@ namespace osu.Game.Beatmaps.IO if (input == null) return null; - using (MemoryStream ms = new MemoryStream()) - { - input.CopyTo(ms); - return ms.ToArray(); - } + byte[] buffer = new byte[input.Length]; + input.Read(buffer, 0, buffer.Length); + return buffer; } } } From cb21e98ae15636e6fe3b9ce871829189950a5676 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Mon, 8 May 2017 19:55:04 +0800 Subject: [PATCH 107/329] MatchCreate.ValidForResume = false. --- osu.Game/Screens/Multiplayer/MatchCreate.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/osu.Game/Screens/Multiplayer/MatchCreate.cs b/osu.Game/Screens/Multiplayer/MatchCreate.cs index 54800c82f3..f28261fa7f 100644 --- a/osu.Game/Screens/Multiplayer/MatchCreate.cs +++ b/osu.Game/Screens/Multiplayer/MatchCreate.cs @@ -11,5 +11,10 @@ namespace osu.Game.Screens.Multiplayer protected override IEnumerable PossibleChildren => new[] { typeof(Match) }; + + public MatchCreate() + { + ValidForResume = false; + } } } From 4b5e24cc36086467809060ebb316cbfc46252cea Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Mon, 8 May 2017 19:14:19 +0300 Subject: [PATCH 108/329] Changed logic a bit --- osu.Game/Screens/Play/SongProgress.cs | 4 ++-- osu.Game/Screens/Play/SongProgressInfo.cs | 28 +++++++++++++++-------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 020a26f703..6a0bc64de9 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -45,6 +45,7 @@ namespace osu.Game.Screens.Play set { graph.Objects = objects = value; + info.SongLenght = lastHitTime - firstHitTime; } } @@ -146,8 +147,7 @@ namespace osu.Game.Screens.Play graph.Progress = (int)(graph.ColumnCount * progress); info.Progress = (int)(progress * 100); - info.TimeCurrent = currentTime; - info.TimeLeft = lastHitTime - firstHitTime - currentTime; + info.CurrentTime = currentTime; } } } diff --git a/osu.Game/Screens/Play/SongProgressInfo.cs b/osu.Game/Screens/Play/SongProgressInfo.cs index 5b33e6d8af..cf73a0d10a 100644 --- a/osu.Game/Screens/Play/SongProgressInfo.cs +++ b/osu.Game/Screens/Play/SongProgressInfo.cs @@ -13,25 +13,26 @@ namespace osu.Game.Screens.Play { public class SongProgressInfo : Container { - private OsuSpriteText timeCurrentText; + private OsuSpriteText timeCurrent; private OsuSpriteText timeLeft; private OsuSpriteText progressText; + private double currentTime; + private double songLenght; private int progress; - private double timeCurrent; private const int margin = 10; - public double TimeCurrent + public double SongLenght { set { songLenght = value; } } + public double CurrentTime { set { - timeCurrent = value; + currentTime = value; if (value > 0) - timeCurrentText.Text = TimeSpan.FromMilliseconds(value).ToString(@"m\:ss"); + timeCurrent.Text = TimeSpan.FromMilliseconds(value).ToString(@"m\:ss"); } } - public double TimeLeft { set { timeLeft.Text = @"-" + TimeSpan.FromMilliseconds(timeCurrent < 0 ? value + timeCurrent : value).ToString(@"m\:ss"); } } public int Progress { set @@ -40,7 +41,7 @@ namespace osu.Game.Screens.Play return; progress = value; - if (value > 0) + if (currentTime > 0) progressText.Text = value.ToString() + @"%"; } } @@ -50,7 +51,7 @@ namespace osu.Game.Screens.Play { Children = new Drawable[] { - timeCurrentText = new OsuSpriteText + timeCurrent = new OsuSpriteText { Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, @@ -79,9 +80,18 @@ namespace osu.Game.Screens.Play Margin = new MarginPadding { Right = margin, - } + }, + Text = @"-" + TimeSpan.FromMilliseconds(songLenght).ToString(@"m\:ss"), } }; } + + protected override void Update() + { + base.Update(); + + if(currentTime > 0) + timeLeft.Text = @"-" + TimeSpan.FromMilliseconds(songLenght - currentTime).ToString(@"m\:ss"); + } } } From 86f0173c6b476a203034e4b2dfc5483b4f0d72c1 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Mon, 8 May 2017 18:30:00 +0200 Subject: [PATCH 109/329] fix license header --- osu.Game/Overlays/Options/OptionsSection.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/Options/OptionsSection.cs b/osu.Game/Overlays/Options/OptionsSection.cs index 4069503a51..5e36f79467 100644 --- a/osu.Game/Overlays/Options/OptionsSection.cs +++ b/osu.Game/Overlays/Options/OptionsSection.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -// Copyright (c) 2007-2017 ppy Pty Ltd . +// Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK; @@ -12,6 +10,7 @@ using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using System.Collections.Generic; using System.Linq; namespace osu.Game.Overlays.Options From 17d1ecb8f592d5c630c17c49892720561bdf130c Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Mon, 8 May 2017 19:42:36 +0300 Subject: [PATCH 110/329] Use float type for progress value --- osu.Game/Screens/Play/SongProgress.cs | 6 +++--- osu.Game/Screens/Play/SongProgressInfo.cs | 13 ++++--------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 6a0bc64de9..e3f96bd395 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -141,12 +141,12 @@ namespace osu.Game.Screens.Play return; double currentTime = (AudioClock?.CurrentTime ?? Time.Current) - firstHitTime; - double progress = currentTime / (lastHitTime - firstHitTime); + float progress = (float)(currentTime / (lastHitTime - firstHitTime)); - bar.UpdatePosition((float)progress); + bar.UpdatePosition(progress); graph.Progress = (int)(graph.ColumnCount * progress); - info.Progress = (int)(progress * 100); + info.Progress = progress; info.CurrentTime = currentTime; } } diff --git a/osu.Game/Screens/Play/SongProgressInfo.cs b/osu.Game/Screens/Play/SongProgressInfo.cs index cf73a0d10a..6719ddfb6b 100644 --- a/osu.Game/Screens/Play/SongProgressInfo.cs +++ b/osu.Game/Screens/Play/SongProgressInfo.cs @@ -15,11 +15,10 @@ namespace osu.Game.Screens.Play { private OsuSpriteText timeCurrent; private OsuSpriteText timeLeft; - private OsuSpriteText progressText; + private OsuSpriteText progress; private double currentTime; private double songLenght; - private int progress; private const int margin = 10; @@ -33,16 +32,12 @@ namespace osu.Game.Screens.Play timeCurrent.Text = TimeSpan.FromMilliseconds(value).ToString(@"m\:ss"); } } - public int Progress + public float Progress { set { - if (progress == value) - return; - - progress = value; if (currentTime > 0) - progressText.Text = value.ToString() + @"%"; + progress.Text = value.ToString("P0"); } } @@ -63,7 +58,7 @@ namespace osu.Game.Screens.Play }, Text = @"0:00", }, - progressText = new OsuSpriteText + progress = new OsuSpriteText { Origin = Anchor.BottomCentre, Anchor = Anchor.BottomCentre, From de2486b8e61481f518db0b7d1075b54f4209c261 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Mon, 8 May 2017 20:36:02 +0300 Subject: [PATCH 111/329] Moved timeLeft recalculation to property --- osu.Game/Screens/Play/SongProgressInfo.cs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/osu.Game/Screens/Play/SongProgressInfo.cs b/osu.Game/Screens/Play/SongProgressInfo.cs index 6719ddfb6b..d805dc2cbd 100644 --- a/osu.Game/Screens/Play/SongProgressInfo.cs +++ b/osu.Game/Screens/Play/SongProgressInfo.cs @@ -29,7 +29,10 @@ namespace osu.Game.Screens.Play { currentTime = value; if (value > 0) + { timeCurrent.Text = TimeSpan.FromMilliseconds(value).ToString(@"m\:ss"); + timeLeft.Text = @"-" + TimeSpan.FromMilliseconds(songLenght - value).ToString(@"m\:ss"); + } } } public float Progress @@ -80,13 +83,5 @@ namespace osu.Game.Screens.Play } }; } - - protected override void Update() - { - base.Update(); - - if(currentTime > 0) - timeLeft.Text = @"-" + TimeSpan.FromMilliseconds(songLenght - currentTime).ToString(@"m\:ss"); - } } } From 2826c663fd665f6f32b8da7c00504defef631a59 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Tue, 9 May 2017 06:05:37 +0300 Subject: [PATCH 112/329] Apply suggested changes --- osu.Game/Screens/Play/SongProgress.cs | 22 ++++--- osu.Game/Screens/Play/SongProgressInfo.cs | 79 +++++++++++++++-------- 2 files changed, 66 insertions(+), 35 deletions(-) diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index e3f96bd395..3d192b990c 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -32,7 +32,15 @@ namespace osu.Game.Screens.Play public Action OnSeek; - public IClock AudioClock; + private IClock audioClock; + public IClock AudioClock + { + set + { + audioClock = value; + info.AudioClock = value; + } + } private double lastHitTime => ((objects.Last() as IHasEndTime)?.EndTime ?? objects.Last().StartTime) + 1; @@ -45,7 +53,9 @@ namespace osu.Game.Screens.Play set { graph.Objects = objects = value; - info.SongLenght = lastHitTime - firstHitTime; + + info.StartTime = firstHitTime; + info.EndTime = lastHitTime; } } @@ -70,7 +80,7 @@ namespace osu.Game.Screens.Play Anchor = Anchor.BottomLeft, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Y = -(bottom_bar_height + graph_height), + Margin = new MarginPadding { Bottom = bottom_bar_height + graph_height }, }, graph = new SongProgressGraph { @@ -140,14 +150,10 @@ namespace osu.Game.Screens.Play if (objects == null) return; - double currentTime = (AudioClock?.CurrentTime ?? Time.Current) - firstHitTime; - float progress = (float)(currentTime / (lastHitTime - firstHitTime)); + float progress = (float)(((audioClock?.CurrentTime ?? Time.Current) - firstHitTime) / (lastHitTime - firstHitTime)); bar.UpdatePosition(progress); graph.Progress = (int)(graph.ColumnCount * progress); - - info.Progress = progress; - info.CurrentTime = currentTime; } } } diff --git a/osu.Game/Screens/Play/SongProgressInfo.cs b/osu.Game/Screens/Play/SongProgressInfo.cs index d805dc2cbd..069c977bf2 100644 --- a/osu.Game/Screens/Play/SongProgressInfo.cs +++ b/osu.Game/Screens/Play/SongProgressInfo.cs @@ -5,6 +5,7 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; +using osu.Framework.Timing; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using System; @@ -17,32 +18,19 @@ namespace osu.Game.Screens.Play private OsuSpriteText timeLeft; private OsuSpriteText progress; - private double currentTime; - private double songLenght; + private double startTime; + private double endTime; - private const int margin = 10; + private int previousPercent; + private int previousSecond; + private bool defaultsSetted; - public double SongLenght { set { songLenght = value; } } - public double CurrentTime - { - set - { - currentTime = value; - if (value > 0) - { - timeCurrent.Text = TimeSpan.FromMilliseconds(value).ToString(@"m\:ss"); - timeLeft.Text = @"-" + TimeSpan.FromMilliseconds(songLenght - value).ToString(@"m\:ss"); - } - } - } - public float Progress - { - set - { - if (currentTime > 0) - progress.Text = value.ToString("P0"); - } - } + private const int margin = 10; + + public IClock AudioClock; + + public double StartTime { set { startTime = value; } } + public double EndTime { set { endTime = value; } } [BackgroundDependencyLoader] private void load(OsuColour colours) @@ -59,7 +47,6 @@ namespace osu.Game.Screens.Play { Left = margin, }, - Text = @"0:00", }, progress = new OsuSpriteText { @@ -67,7 +54,6 @@ namespace osu.Game.Screens.Play Anchor = Anchor.BottomCentre, Colour = colours.BlueLighter, Font = @"Venera", - Text = @"0%", }, timeLeft = new OsuSpriteText { @@ -79,9 +65,48 @@ namespace osu.Game.Screens.Play { Right = margin, }, - Text = @"-" + TimeSpan.FromMilliseconds(songLenght).ToString(@"m\:ss"), } }; } + + protected override void Update() + { + base.Update(); + + double songCurrentTime = AudioClock.CurrentTime - startTime; + + if (!defaultsSetted) + { + timeCurrent.Text = @"0:00"; + timeLeft.Text = TimeSpan.FromMilliseconds(endTime - startTime).ToString(@"m\:ss"); + progress.Text = @"0%"; + + defaultsSetted = true; + } + else + { + if(songCurrentTime >= 0) + { + int currentSecond = TimeSpan.FromMilliseconds(songCurrentTime).Seconds; + + if (currentSecond != previousSecond) + { + previousSecond = currentSecond; + + timeCurrent.Text = TimeSpan.FromMilliseconds(songCurrentTime).ToString(@"m\:ss"); + timeLeft.Text = @"-" + TimeSpan.FromMilliseconds(endTime - AudioClock.CurrentTime).ToString(@"m\:ss"); + } + + int currentPercent = (int)((songCurrentTime / (endTime - startTime)) * 100); + + if (currentPercent != previousPercent) + { + previousPercent = currentPercent; + + progress.Text = currentPercent.ToString() + @"%"; + } + } + } + } } } From 315f1f1256e2295ed2675921d43b32a43c4ffaf2 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Tue, 9 May 2017 06:23:03 +0300 Subject: [PATCH 113/329] CI fixes --- osu.Game/Screens/Play/SongProgressInfo.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/SongProgressInfo.cs b/osu.Game/Screens/Play/SongProgressInfo.cs index 069c977bf2..6483a0b017 100644 --- a/osu.Game/Screens/Play/SongProgressInfo.cs +++ b/osu.Game/Screens/Play/SongProgressInfo.cs @@ -25,7 +25,7 @@ namespace osu.Game.Screens.Play private int previousSecond; private bool defaultsSetted; - private const int margin = 10; + private const int margin = 10; public IClock AudioClock; @@ -97,7 +97,7 @@ namespace osu.Game.Screens.Play timeLeft.Text = @"-" + TimeSpan.FromMilliseconds(endTime - AudioClock.CurrentTime).ToString(@"m\:ss"); } - int currentPercent = (int)((songCurrentTime / (endTime - startTime)) * 100); + int currentPercent = (int)(songCurrentTime / (endTime - startTime) * 100); if (currentPercent != previousPercent) { From d852567d1d09a3e8475d2b9f914cf89328d05e18 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 9 May 2017 20:33:59 +0900 Subject: [PATCH 114/329] Rewrite notes to have time-relative position and length. --- osu-framework | 2 +- .../Tests/TestCaseManiaHitObjects.cs | 20 +++++++--- .../Objects/Drawables/DrawableHoldNote.cs | 30 ++++++++------- .../Drawables/DrawableManiaHitObject.cs | 38 +++++++------------ .../Objects/Drawables/DrawableNote.cs | 9 ++++- .../Objects/Drawables/Pieces/BodyPiece.cs | 2 +- 6 files changed, 53 insertions(+), 48 deletions(-) diff --git a/osu-framework b/osu-framework index cebdfb1bbb..cd37a9cad9 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit cebdfb1bbb260e5aaca0a01e06d7128b3d1faae4 +Subproject commit cd37a9cad9aaede267152cf3753cd31fe697cec4 diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs index a842406f99..c4aa5749b3 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs @@ -34,32 +34,40 @@ namespace osu.Desktop.VisualTests.Tests { new Container { + Name = "Normal note column", Anchor = Anchor.Centre, Origin = Anchor.Centre, RelativeSizeAxes = Axes.Y, Width = 50, + RelativeCoordinateSpace = new Vector2(1, 10000), Children = new[] { - new DrawableNote(new Note()) + new DrawableNote(new Note + { + StartTime = 5000 + }) { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, AccentColour = Color4.Red } } }, new Container { + Name = "Hold note column", Anchor = Anchor.Centre, Origin = Anchor.Centre, RelativeSizeAxes = Axes.Y, Width = 50, + RelativeCoordinateSpace = new Vector2(1, 10000), Children = new[] { - new DrawableHoldNote(new HoldNote()) + new DrawableHoldNote(new HoldNote + { + StartTime = 5000, + Duration = 1000, + + }) { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, AccentColour = Color4.Red, Length = 0.4f } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs index 7db65a6522..460c65dbbd 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -7,6 +7,7 @@ using osu.Framework.Graphics; using osu.Framework.Allocation; using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces; using OpenTK.Graphics; +using osu.Framework.Graphics.Containers; namespace osu.Game.Rulesets.Mania.Objects.Drawables { @@ -24,24 +25,31 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables public DrawableHoldNote(HoldNote hitObject) : base(hitObject) { - Children = new Drawable[] + RelativeSizeAxes = Axes.Both; + Height = (float)HitObject.Duration; + + Add(new Drawable[] { - headPiece = new NotePiece - { - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre - }, bodyPiece = new BodyPiece { Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, }, - tailPiece = new NotePiece + headPiece = new NotePiece { Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre + }, + tailPiece = new NotePiece + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre } - }; + }); + + // The "length" of the hold note stops at the "base" of the tail piece + // but we want to contain the tail piece within our bounds + Height += (float)HitObject.Duration / headPiece.Height; } public override Color4 AccentColour @@ -59,12 +67,6 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables } } - - protected override void Update() - { - bodyPiece.Height = Parent.DrawSize.Y * Length; - } - protected override void UpdateState(ArmedState state) { } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs index 9f4c5f6ee2..28f9fa79b2 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK.Graphics; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -17,44 +18,31 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables private readonly Container glowContainer; - protected override Container Content => noteFlow; - private readonly FlowContainer noteFlow; - public DrawableManiaHitObject(TObject hitObject) : base(hitObject) { HitObject = hitObject; - RelativeSizeAxes = Axes.X; - AutoSizeAxes = Axes.Y; + Anchor = Anchor.TopCentre; + Origin = Anchor.BottomCentre; - InternalChildren = new Drawable[] + RelativePositionAxes = Axes.Y; + Y = (float)HitObject.StartTime; + + Add(glowContainer = new Container { - glowContainer = new Container - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.Both, - Masking = true, - Children = new[] + RelativeSizeAxes = Axes.Both, + Masking = true, + Children = new[] { new Box { RelativeSizeAxes = Axes.Both, - AlwaysPresent = true, - Alpha = 0 + Alpha = 0, + AlwaysPresent = true } } - }, - noteFlow = new FillFlowContainer - { - Name = "Main container", - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y - } - }; + }); } public override Color4 AccentColour diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs index 09443b6893..57990f2738 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs @@ -18,7 +18,14 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables public DrawableNote(Note hitObject) : base(hitObject) { - Add(headPiece = new NotePiece()); + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + + Add(headPiece = new NotePiece + { + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre + }); } public override Color4 AccentColour diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs index b2451c9995..7a61fd3a00 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs @@ -17,7 +17,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces public BodyPiece() { - RelativeSizeAxes = Axes.X; + RelativeSizeAxes = Axes.Both; Masking = true; Children = new[] From 5b323ad4835a588b21bd6817354512ba83a1c721 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 9 May 2017 20:55:20 +0900 Subject: [PATCH 115/329] Cleanups. --- .../Tests/TestCaseManiaHitObjects.cs | 43 +++++++++++++------ .../Judgements/HitWindows.cs | 2 +- .../Objects/Drawables/DrawableHoldNote.cs | 8 ++-- .../Drawables/DrawableManiaHitObject.cs | 12 +++--- .../Objects/Drawables/Pieces/BodyPiece.cs | 12 +++--- .../Objects/Drawables/Pieces/NotePiece.cs | 3 ++ osu.Game.Rulesets.Mania/Objects/HoldNote.cs | 11 ++++- osu.Game.Rulesets.Mania/Objects/Note.cs | 8 +++- .../Objects/Types/IHasColumn.cs | 7 ++- 9 files changed, 71 insertions(+), 35 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs index c4aa5749b3..97c65b799b 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs @@ -39,15 +39,23 @@ namespace osu.Desktop.VisualTests.Tests Origin = Anchor.Centre, RelativeSizeAxes = Axes.Y, Width = 50, - RelativeCoordinateSpace = new Vector2(1, 10000), Children = new[] { - new DrawableNote(new Note + new Container { - StartTime = 5000 - }) - { - AccentColour = Color4.Red + Name = "Timing section", + RelativeSizeAxes = Axes.Both, + RelativeCoordinateSpace = new Vector2(1, 10000), + Children = new[] + { + new DrawableNote(new Note + { + StartTime = 5000 + }) + { + AccentColour = Color4.Red + } + } } } }, @@ -58,18 +66,25 @@ namespace osu.Desktop.VisualTests.Tests Origin = Anchor.Centre, RelativeSizeAxes = Axes.Y, Width = 50, - RelativeCoordinateSpace = new Vector2(1, 10000), Children = new[] { - new DrawableHoldNote(new HoldNote + new Container { - StartTime = 5000, - Duration = 1000, + Name = "Timing section", + RelativeSizeAxes = Axes.Both, + RelativeCoordinateSpace = new Vector2(1, 10000), + Children = new[] + { + new DrawableHoldNote(new HoldNote + { + StartTime = 5000, + Duration = 1000, - }) - { - AccentColour = Color4.Red, - Length = 0.4f + }) + { + AccentColour = Color4.Red + } + } } } } diff --git a/osu.Game.Rulesets.Mania/Judgements/HitWindows.cs b/osu.Game.Rulesets.Mania/Judgements/HitWindows.cs index a1354314bf..7428f34882 100644 --- a/osu.Game.Rulesets.Mania/Judgements/HitWindows.cs +++ b/osu.Game.Rulesets.Mania/Judgements/HitWindows.cs @@ -93,7 +93,7 @@ namespace osu.Game.Rulesets.Mania.Judgements /// Hit window for a PERFECT hit. /// public double Perfect = perfect_mid; - + /// /// Hit window for a GREAT hit. /// diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs index 460c65dbbd..b6943a95ce 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -13,11 +13,6 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables { public class DrawableHoldNote : DrawableManiaHitObject { - /// - /// Length of this hold note, relative to its parent. - /// - public float Length; - private NotePiece headPiece; private BodyPiece bodyPiece; private NotePiece tailPiece; @@ -30,6 +25,9 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables Add(new Drawable[] { + // For now the body piece covers the entire height of the container + // whereas possibly in the future we don't want to extend under the head/tail. + // This will be fixed when new designs are given or the current design is finalized. bodyPiece = new BodyPiece { Anchor = Anchor.BottomCentre, diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs index 28f9fa79b2..f33a6fe699 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs @@ -34,14 +34,14 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables RelativeSizeAxes = Axes.Both, Masking = true, Children = new[] + { + new Box { - new Box - { - RelativeSizeAxes = Axes.Both, - Alpha = 0, - AlwaysPresent = true - } + RelativeSizeAxes = Axes.Both, + Alpha = 0, + AlwaysPresent = true } + } }); } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs index 7a61fd3a00..ac2b7df06f 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs @@ -1,16 +1,18 @@ -using System; -using OpenTK.Graphics; -using osu.Framework.Graphics; -// Copyright (c) 2007-2017 ppy Pty Ltd . +// 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; using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces { + /// + /// Represents length-wise portion of a hold note. + /// internal class BodyPiece : Container, IHasAccentColour { private Box box; diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs index 0acb250f88..2584682833 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs @@ -10,6 +10,9 @@ using osu.Game.Graphics; namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces { + /// + /// Represents the static hit markers of notes. + /// internal class NotePiece : Container, IHasAccentColour { private const float head_height = 10; diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs index e32eb3f147..a25b8fbf2a 100644 --- a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs @@ -8,17 +8,24 @@ using osu.Game.Rulesets.Objects.Types; namespace osu.Game.Rulesets.Mania.Objects { + /// + /// Represents a hit object which requires pressing, holding, and releasing a key. + /// public class HoldNote : Note, IHasEndTime { /// - /// Lenience of release hit windows. + /// Lenience of release hit windows. This is to make cases where the hold note release + /// is timed alongside presses of other hit objects less awkward. /// private const double release_window_lenience = 1.5; public double Duration { get; set; } public double EndTime => StartTime + Duration; - public HitWindows ReleaseHitWindows { get; protected set; } = new HitWindows(); + /// + /// The key-release hit windows for this hold note. + /// + protected HitWindows ReleaseHitWindows = new HitWindows(); public override void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty) { diff --git a/osu.Game.Rulesets.Mania/Objects/Note.cs b/osu.Game.Rulesets.Mania/Objects/Note.cs index 83299ba7be..1d2e4169b5 100644 --- a/osu.Game.Rulesets.Mania/Objects/Note.cs +++ b/osu.Game.Rulesets.Mania/Objects/Note.cs @@ -7,9 +7,15 @@ using osu.Game.Rulesets.Mania.Judgements; namespace osu.Game.Rulesets.Mania.Objects { + /// + /// Represents a hit object which has a single hit press. + /// public class Note : ManiaHitObject { - public HitWindows HitWindows { get; protected set; } = new HitWindows(); + /// + /// The key-press hit window for this note. + /// + protected HitWindows HitWindows = new HitWindows(); public override void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty) { diff --git a/osu.Game.Rulesets.Mania/Objects/Types/IHasColumn.cs b/osu.Game.Rulesets.Mania/Objects/Types/IHasColumn.cs index 7b98b2b4bb..8281d0d9e4 100644 --- a/osu.Game.Rulesets.Mania/Objects/Types/IHasColumn.cs +++ b/osu.Game.Rulesets.Mania/Objects/Types/IHasColumn.cs @@ -1,11 +1,16 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - namespace osu.Game.Rulesets.Mania.Objects.Types { + /// + /// A type of hit object which lies in one of a number of predetermined columns. + /// public interface IHasColumn { + /// + /// The column which the hit object lies in. + /// int Column { get; } } } From 89bfc0ff22a7d8eb4af1fcbacd1098f2710e167f Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 9 May 2017 20:55:38 +0900 Subject: [PATCH 116/329] Fix exception. --- 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 1bc1dea04f..11475a0f19 100644 --- a/osu.Game/Graphics/Cursor/CursorTrail.cs +++ b/osu.Game/Graphics/Cursor/CursorTrail.cs @@ -78,7 +78,7 @@ namespace osu.Game.Graphics.Cursor [BackgroundDependencyLoader] private void load(ShaderManager shaders, TextureStore textures) { - shader = shaders?.Load(@"CursorTrail", FragmentShaderDescriptor.Texture); + shader = shaders?.Load(@"CursorTrail", FragmentShaderDescriptor.TEXTURE); texture = textures.Get(@"Cursor/cursortrail"); Scale = new Vector2(1 / texture.ScaleAdjust); } From e1ed785cbfde15a4b9f2345745c199d7e7b3adb2 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 9 May 2017 21:00:40 +0900 Subject: [PATCH 117/329] Update framework. --- osu-framework | 2 +- osu.Game/Graphics/Cursor/CursorTrail.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu-framework b/osu-framework index cebdfb1bbb..1c95c94fab 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit cebdfb1bbb260e5aaca0a01e06d7128b3d1faae4 +Subproject commit 1c95c94fab6852620cd82eb0899ca0132ac82667 diff --git a/osu.Game/Graphics/Cursor/CursorTrail.cs b/osu.Game/Graphics/Cursor/CursorTrail.cs index 1bc1dea04f..11475a0f19 100644 --- a/osu.Game/Graphics/Cursor/CursorTrail.cs +++ b/osu.Game/Graphics/Cursor/CursorTrail.cs @@ -78,7 +78,7 @@ namespace osu.Game.Graphics.Cursor [BackgroundDependencyLoader] private void load(ShaderManager shaders, TextureStore textures) { - shader = shaders?.Load(@"CursorTrail", FragmentShaderDescriptor.Texture); + shader = shaders?.Load(@"CursorTrail", FragmentShaderDescriptor.TEXTURE); texture = textures.Get(@"Cursor/cursortrail"); Scale = new Vector2(1 / texture.ScaleAdjust); } From cdd71b496d18e7755d8a8b0557a2ae25ff277cab Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Tue, 9 May 2017 21:08:53 +0900 Subject: [PATCH 118/329] Fix unnecessary newline. --- osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs index 97c65b799b..4234140be6 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs @@ -78,8 +78,7 @@ namespace osu.Desktop.VisualTests.Tests new DrawableHoldNote(new HoldNote { StartTime = 5000, - Duration = 1000, - + Duration = 1000 }) { AccentColour = Color4.Red From 7b17e331c46d98bcbf2a563317d98d98f74529d6 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Wed, 10 May 2017 03:45:31 +0300 Subject: [PATCH 119/329] cleanups --- osu.Game/Screens/Play/SongProgress.cs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 3d192b990c..548befdb36 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -33,14 +33,7 @@ namespace osu.Game.Screens.Play public Action OnSeek; private IClock audioClock; - public IClock AudioClock - { - set - { - audioClock = value; - info.AudioClock = value; - } - } + public IClock AudioClock { set { audioClock = info.AudioClock = value; } } private double lastHitTime => ((objects.Last() as IHasEndTime)?.EndTime ?? objects.Last().StartTime) + 1; @@ -150,9 +143,9 @@ namespace osu.Game.Screens.Play if (objects == null) return; - float progress = (float)(((audioClock?.CurrentTime ?? Time.Current) - firstHitTime) / (lastHitTime - firstHitTime)); + double progress = ((audioClock?.CurrentTime ?? Time.Current) - firstHitTime) / (lastHitTime - firstHitTime); - bar.UpdatePosition(progress); + bar.UpdatePosition((float)progress); graph.Progress = (int)(graph.ColumnCount * progress); } } From 2e7812956a2af8614a3b7bc29a12565282e2cec2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 10 May 2017 14:15:11 +0900 Subject: [PATCH 120/329] Update framework. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 1c95c94fab..3dd870dc42 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 1c95c94fab6852620cd82eb0899ca0132ac82667 +Subproject commit 3dd870dc42474978c0465d4276641431eba16c91 From 2edc39ae163b89f63dcd07b3220f75d29c737df4 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 10 May 2017 14:56:39 +0900 Subject: [PATCH 121/329] Add timing sections. --- osu.Game.Rulesets.Mania/UI/Column.cs | 44 ++++++++++++- .../UI/ManiaHitRenderer.cs | 61 +++++++++++++++++++ osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 6 ++ .../Timing/DrawableTimingSection.cs | 27 ++++++++ .../Timing/TimingSection.cs | 15 +++++ .../osu.Game.Rulesets.Taiko.csproj | 2 + 6 files changed, 154 insertions(+), 1 deletion(-) create mode 100644 osu.Game.Rulesets.Taiko/Timing/DrawableTimingSection.cs create mode 100644 osu.Game.Rulesets.Taiko/Timing/TimingSection.cs diff --git a/osu.Game.Rulesets.Mania/UI/Column.cs b/osu.Game.Rulesets.Mania/UI/Column.cs index d2fccb2c58..681c5a5ef2 100644 --- a/osu.Game.Rulesets.Mania/UI/Column.cs +++ b/osu.Game.Rulesets.Mania/UI/Column.cs @@ -12,6 +12,7 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Colour; using osu.Framework.Input; using osu.Game.Graphics; +using osu.Game.Rulesets.Taiko.Timing; namespace osu.Game.Rulesets.Mania.UI { @@ -29,11 +30,17 @@ namespace osu.Game.Rulesets.Mania.UI private const float column_width = 45; private const float special_column_width = 70; + private const double time_span_default = 2000; + private const double time_span_min = 10; + private const double time_span_max = 20000; + private const double time_span_step = 100; + public Key Key; private readonly Box background; private readonly Container hitTargetBar; private readonly Container keyIcon; + private readonly Container timingSectionContainer; public Column() { @@ -130,6 +137,14 @@ namespace osu.Game.Rulesets.Mania.UI } } } + }, + timingSectionContainer = new Container + { + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + RelativeSizeAxes = Axes.Both, + Y = -hit_target_bar_height, + RelativeCoordinateSpace = new Vector2(1, (float)time_span_default) } }; } @@ -176,14 +191,32 @@ namespace osu.Game.Rulesets.Mania.UI } } + public void AddTimingSection(TimingSection timingSection) => timingSectionContainer.Add(new DrawableTimingSection(timingSection)); + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { - if (args.Key == Key && !args.Repeat) + if (args.Repeat) + return false; + + if (args.Key == Key) { background.FadeTo(background.Alpha + 0.2f, 50, EasingTypes.OutQuint); keyIcon.ScaleTo(1.4f, 50, EasingTypes.OutQuint); } + if (state.Keyboard.ControlPressed) + { + switch (args.Key) + { + case Key.Minus: + timeSpan += time_span_step; + break; + case Key.Plus: + timeSpan -= time_span_step; + break; + } + } + return false; } @@ -197,6 +230,15 @@ namespace osu.Game.Rulesets.Mania.UI return false; } + + /// + /// The amount of time which the length of this column spans. + /// + private double timeSpan + { + get { return timingSectionContainer.RelativeCoordinateSpace.Y; } + set { timingSectionContainer.RelativeCoordinateSpace = new Vector2(1, (float)MathHelper.Clamp(value, time_span_min, time_span_max)); } + } } } diff --git a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs index c007cdc80e..f72ddf3227 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs @@ -1,14 +1,21 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; +using System.Collections.Generic; +using System.Linq; +using osu.Framework.Allocation; using osu.Game.Beatmaps; +using osu.Game.Beatmaps.Timing; using osu.Game.Rulesets.Beatmaps; using osu.Game.Rulesets.Mania.Beatmaps; using osu.Game.Rulesets.Mania.Judgements; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Scoring; using osu.Game.Rulesets.Objects.Drawables; +using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Scoring; +using osu.Game.Rulesets.Taiko.Timing; using osu.Game.Rulesets.UI; namespace osu.Game.Rulesets.Mania.UI @@ -21,6 +28,60 @@ namespace osu.Game.Rulesets.Mania.UI : base(beatmap) { this.columns = columns; + // Has to be done before drawable hit objects are generated in load() + loadTimingSections(); + } + + private void loadTimingSections() + { + var maniaPlayfield = Playfield as ManiaPlayfield; + if (maniaPlayfield == null) + return; + + var sections = new List(); + + // Construct all the relevant timing sections + ControlPoint lastTimingChange = null; + foreach (ControlPoint point in Beatmap.TimingInfo.ControlPoints) + { + if (point.TimingChange) + lastTimingChange = point; + + sections.Add(new TimingSection + { + StartTime = point.Time, + // Todo: Should this be dividing by beatlength? + BeatLength = point.SpeedMultiplier * lastTimingChange.BeatLength, + TimeSignature = point.TimeSignature + }); + } + + double lastObjectTime = (Objects.Last() as IHasEndTime)?.EndTime ?? Objects.Last().StartTime; + + // Perform some post processing of the timing sections + sections = sections + // Collapse sections after the last hit object + .Where(s => s.StartTime <= lastObjectTime) + // Collapse sections with the same start time + .GroupBy(s => s.StartTime).Select(g => g.Last()).OrderBy(s => s.StartTime) + // Collapse sections with the same beat length + .GroupBy(s => s.BeatLength).Select(g => g.First()) + .ToList(); + + // Determine duration of timing sections + for (int i = 0; i < sections.Count; i++) + { + if (i < sections.Count - 1) + sections[i].Duration = sections[i + 1].StartTime - sections[i].StartTime; + else + { + // Extra length added for the last timing section to extend past the last hitobject + double extraLength = sections[i].BeatLength * (int)sections[i].TimeSignature; + sections[i].Duration = lastObjectTime + extraLength - sections[i].StartTime; + } + } + + sections.ForEach(s => maniaPlayfield.Columns.Children.ForEach(c => c.AddTimingSection(s))); } public override ScoreProcessor CreateScoreProcessor() => new ManiaScoreProcessor(this); diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index 438c1f4b5f..6999ae3952 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -16,6 +16,10 @@ using osu.Framework.Allocation; using OpenTK.Input; using System.Linq; using System.Collections.Generic; +using osu.Game.Rulesets.Taiko.Timing; +using osu.Framework.Extensions.IEnumerableExtensions; +using osu.Game.Rulesets.Objects.Drawables; +using osu.Game.Rulesets.Mania.Objects.Drawables; namespace osu.Game.Rulesets.Mania.UI { @@ -156,5 +160,7 @@ namespace osu.Game.Rulesets.Mania.UI return column == columnCount - 1; } } + + public void Add(TimingSection timingSection) => columns.Children.ForEach(c => c.Add(timingSection)); } } diff --git a/osu.Game.Rulesets.Taiko/Timing/DrawableTimingSection.cs b/osu.Game.Rulesets.Taiko/Timing/DrawableTimingSection.cs new file mode 100644 index 0000000000..e9c403302c --- /dev/null +++ b/osu.Game.Rulesets.Taiko/Timing/DrawableTimingSection.cs @@ -0,0 +1,27 @@ +// 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.Framework.Graphics.Containers; + +namespace osu.Game.Rulesets.Taiko.Timing +{ + public class DrawableTimingSection : Container + { + private readonly TimingSection section; + + public DrawableTimingSection(TimingSection section) + { + this.section = section; + + RelativePositionAxes = Axes.Y; + Y = -(float)section.StartTime; + + RelativeSizeAxes = Axes.Both; + Height = (float)section.Duration; + + RelativeCoordinateSpace = new Vector2(1, Height); + } + } +} \ No newline at end of file diff --git a/osu.Game.Rulesets.Taiko/Timing/TimingSection.cs b/osu.Game.Rulesets.Taiko/Timing/TimingSection.cs new file mode 100644 index 0000000000..418ccac8c8 --- /dev/null +++ b/osu.Game.Rulesets.Taiko/Timing/TimingSection.cs @@ -0,0 +1,15 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Beatmaps.Timing; + +namespace osu.Game.Rulesets.Taiko.Timing +{ + public class TimingSection + { + public double StartTime; + public double Duration; + public double BeatLength; + public TimeSignatures TimeSignature; + } +} \ No newline at end of file diff --git a/osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj b/osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj index 983dc72d9e..5308de741a 100644 --- a/osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj +++ b/osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj @@ -85,6 +85,8 @@ + + From d8f9e71b846e9f822f3d9841525f89bd6a64d431 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Wed, 10 May 2017 10:14:44 +0300 Subject: [PATCH 122/329] Applied suggested changes --- osu.Game/Screens/Play/SongProgressInfo.cs | 43 ++++++++--------------- 1 file changed, 15 insertions(+), 28 deletions(-) diff --git a/osu.Game/Screens/Play/SongProgressInfo.cs b/osu.Game/Screens/Play/SongProgressInfo.cs index 6483a0b017..54a645aa99 100644 --- a/osu.Game/Screens/Play/SongProgressInfo.cs +++ b/osu.Game/Screens/Play/SongProgressInfo.cs @@ -23,7 +23,7 @@ namespace osu.Game.Screens.Play private int previousPercent; private int previousSecond; - private bool defaultsSetted; + private double previousTimespan; private const int margin = 10; @@ -75,37 +75,24 @@ namespace osu.Game.Screens.Play double songCurrentTime = AudioClock.CurrentTime - startTime; - if (!defaultsSetted) - { - timeCurrent.Text = @"0:00"; - timeLeft.Text = TimeSpan.FromMilliseconds(endTime - startTime).ToString(@"m\:ss"); - progress.Text = @"0%"; + int currentSecond = TimeSpan.FromMilliseconds(songCurrentTime).Seconds; - defaultsSetted = true; + if (currentSecond != previousSecond || (previousTimespan < 0 && songCurrentTime > 0)) + { + previousTimespan = songCurrentTime; + previousSecond = currentSecond; + + timeCurrent.Text = ((songCurrentTime < 0) ? @"-" : @"") + TimeSpan.FromMilliseconds(songCurrentTime).ToString(@"m\:ss"); + timeLeft.Text = @"-" + TimeSpan.FromMilliseconds(endTime - AudioClock.CurrentTime).ToString(@"m\:ss"); } - else + + int currentPercent = (int)(songCurrentTime / (endTime - startTime) * 100); + + if (currentPercent != previousPercent) { - if(songCurrentTime >= 0) - { - int currentSecond = TimeSpan.FromMilliseconds(songCurrentTime).Seconds; + previousPercent = currentPercent; - if (currentSecond != previousSecond) - { - previousSecond = currentSecond; - - timeCurrent.Text = TimeSpan.FromMilliseconds(songCurrentTime).ToString(@"m\:ss"); - timeLeft.Text = @"-" + TimeSpan.FromMilliseconds(endTime - AudioClock.CurrentTime).ToString(@"m\:ss"); - } - - int currentPercent = (int)(songCurrentTime / (endTime - startTime) * 100); - - if (currentPercent != previousPercent) - { - previousPercent = currentPercent; - - progress.Text = currentPercent.ToString() + @"%"; - } - } + progress.Text = ((currentPercent <= 0) ? @"0" : currentPercent.ToString()) + @"%"; } } } From bcc8a94e36e4f68cf08455c8449a8d779439252e Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 10 May 2017 16:32:11 +0900 Subject: [PATCH 123/329] Construct mania playfield with proper column count. --- osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs | 7 ++++++- osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs | 8 ++++---- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs index 10bebbdba7..94984146f7 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs @@ -8,6 +8,7 @@ using System; using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Beatmaps; using osu.Game.Rulesets.Objects; +using osu.Game.Rulesets.Mania.Objects.Drawables; namespace osu.Game.Rulesets.Mania.Beatmaps { @@ -17,7 +18,11 @@ namespace osu.Game.Rulesets.Mania.Beatmaps protected override IEnumerable ConvertHitObject(HitObject original, Beatmap beatmap) { - yield return null; + yield return new Note + { + StartTime = original.StartTime, + Column = 1, + }; } } } diff --git a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs index f72ddf3227..b34442b1e1 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; +using osu.Framework.Extensions.IEnumerableExtensions; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Timing; using osu.Game.Rulesets.Beatmaps; @@ -22,12 +23,11 @@ namespace osu.Game.Rulesets.Mania.UI { public class ManiaHitRenderer : HitRenderer { - private readonly int columns; + public int? Columns; - public ManiaHitRenderer(WorkingBeatmap beatmap, int columns = 5) + public ManiaHitRenderer(WorkingBeatmap beatmap) : base(beatmap) { - this.columns = columns; // Has to be done before drawable hit objects are generated in load() loadTimingSections(); } @@ -88,7 +88,7 @@ namespace osu.Game.Rulesets.Mania.UI protected override BeatmapConverter CreateBeatmapConverter() => new ManiaBeatmapConverter(); - protected override Playfield CreatePlayfield() => new ManiaPlayfield(columns); + protected override Playfield CreatePlayfield() => new ManiaPlayfield(Columns ?? (int)Math.Round(Beatmap.BeatmapInfo.Difficulty.CircleSize)); protected override DrawableHitObject GetVisualRepresentation(ManiaHitObject h) => null; } diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index 6999ae3952..e468d6f533 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -161,6 +161,6 @@ namespace osu.Game.Rulesets.Mania.UI } } - public void Add(TimingSection timingSection) => columns.Children.ForEach(c => c.Add(timingSection)); + public override void Add(DrawableHitObject h) => Columns.Children.ElementAt(h.HitObject.Column).Add(h); } } From 5b469eff6990f8f7126f424c010e8bae5e90b71a Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Wed, 10 May 2017 10:33:02 +0300 Subject: [PATCH 124/329] Fixes --- osu.Game/Screens/Play/SongProgressInfo.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Play/SongProgressInfo.cs b/osu.Game/Screens/Play/SongProgressInfo.cs index 54a645aa99..88ef358fbc 100644 --- a/osu.Game/Screens/Play/SongProgressInfo.cs +++ b/osu.Game/Screens/Play/SongProgressInfo.cs @@ -77,12 +77,16 @@ namespace osu.Game.Screens.Play int currentSecond = TimeSpan.FromMilliseconds(songCurrentTime).Seconds; - if (currentSecond != previousSecond || (previousTimespan < 0 && songCurrentTime > 0)) + if (currentSecond != previousSecond || previousTimespan < 0 && songCurrentTime > 0) { previousTimespan = songCurrentTime; previousSecond = currentSecond; - timeCurrent.Text = ((songCurrentTime < 0) ? @"-" : @"") + TimeSpan.FromMilliseconds(songCurrentTime).ToString(@"m\:ss"); + if(songCurrentTime < 0) + timeCurrent.Text = @"-" + TimeSpan.FromMilliseconds(songCurrentTime - 1000).ToString(@"m\:ss"); + else + timeCurrent.Text = TimeSpan.FromMilliseconds(songCurrentTime).ToString(@"m\:ss"); + timeLeft.Text = @"-" + TimeSpan.FromMilliseconds(endTime - AudioClock.CurrentTime).ToString(@"m\:ss"); } @@ -92,7 +96,7 @@ namespace osu.Game.Screens.Play { previousPercent = currentPercent; - progress.Text = ((currentPercent <= 0) ? @"0" : currentPercent.ToString()) + @"%"; + progress.Text = (currentPercent <= 0 ? @"0" : currentPercent.ToString()) + @"%"; } } } From 11c47454ad02b40d9657e62704a7d0122e7b692f Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 10 May 2017 17:13:33 +0900 Subject: [PATCH 125/329] Update framework. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index cd37a9cad9..d4a40115e7 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit cd37a9cad9aaede267152cf3753cd31fe697cec4 +Subproject commit d4a40115e704656191ae875ec742db6427767329 From 3b533de8acb5c3cf9c84abe8dbe67320f74ae6a6 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 10 May 2017 17:29:54 +0900 Subject: [PATCH 126/329] Add xmldoc to HitWindows.cs. --- .../Judgements/HitWindows.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/osu.Game.Rulesets.Mania/Judgements/HitWindows.cs b/osu.Game.Rulesets.Mania/Judgements/HitWindows.cs index 7428f34882..2a0ce88506 100644 --- a/osu.Game.Rulesets.Mania/Judgements/HitWindows.cs +++ b/osu.Game.Rulesets.Mania/Judgements/HitWindows.cs @@ -119,10 +119,17 @@ namespace osu.Game.Rulesets.Mania.Judgements /// public double Miss = miss_mid; + /// + /// Constructs default hit windows. + /// public HitWindows() { } + /// + /// Constructs hit windows by fitting a parameter to a 2-part piecewise linear function for each hit window. + /// + /// The parameter. public HitWindows(double difficulty) { Perfect = BeatmapDifficulty.DifficultyRange(difficulty, perfect_max, perfect_mid, perfect_min); @@ -133,6 +140,11 @@ namespace osu.Game.Rulesets.Mania.Judgements Miss = BeatmapDifficulty.DifficultyRange(difficulty, miss_max, miss_mid, miss_min); } + /// + /// Constructs new hit windows which have been multiplied by a value. + /// + /// The original hit windows. + /// The value to multiply each hit window by. public static HitWindows operator *(HitWindows windows, double value) { return new HitWindows @@ -146,6 +158,11 @@ namespace osu.Game.Rulesets.Mania.Judgements }; } + /// + /// Constructs new hit windows which have been divided by a value. + /// + /// The original hit windows. + /// The value to divide each hit window by. public static HitWindows operator /(HitWindows windows, double value) { return new HitWindows From 2867606913e2c4ea5443d39cedf9088ef522dedb Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 10 May 2017 17:34:43 +0900 Subject: [PATCH 127/329] Whoops wrong project. --- .../Timing/DrawableTimingSection.cs | 2 +- .../Timing/TimingSection.cs | 2 +- osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj | 2 ++ osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj | 2 -- 4 files changed, 4 insertions(+), 4 deletions(-) rename {osu.Game.Rulesets.Taiko => osu.Game.Rulesets.Mania}/Timing/DrawableTimingSection.cs (94%) rename {osu.Game.Rulesets.Taiko => osu.Game.Rulesets.Mania}/Timing/TimingSection.cs (89%) diff --git a/osu.Game.Rulesets.Taiko/Timing/DrawableTimingSection.cs b/osu.Game.Rulesets.Mania/Timing/DrawableTimingSection.cs similarity index 94% rename from osu.Game.Rulesets.Taiko/Timing/DrawableTimingSection.cs rename to osu.Game.Rulesets.Mania/Timing/DrawableTimingSection.cs index e9c403302c..8dcb39ae0d 100644 --- a/osu.Game.Rulesets.Taiko/Timing/DrawableTimingSection.cs +++ b/osu.Game.Rulesets.Mania/Timing/DrawableTimingSection.cs @@ -5,7 +5,7 @@ using OpenTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -namespace osu.Game.Rulesets.Taiko.Timing +namespace osu.Game.Rulesets.Mania.Timing { public class DrawableTimingSection : Container { diff --git a/osu.Game.Rulesets.Taiko/Timing/TimingSection.cs b/osu.Game.Rulesets.Mania/Timing/TimingSection.cs similarity index 89% rename from osu.Game.Rulesets.Taiko/Timing/TimingSection.cs rename to osu.Game.Rulesets.Mania/Timing/TimingSection.cs index 418ccac8c8..fdc367de11 100644 --- a/osu.Game.Rulesets.Taiko/Timing/TimingSection.cs +++ b/osu.Game.Rulesets.Mania/Timing/TimingSection.cs @@ -3,7 +3,7 @@ using osu.Game.Beatmaps.Timing; -namespace osu.Game.Rulesets.Taiko.Timing +namespace osu.Game.Rulesets.Mania.Timing { public class TimingSection { diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index 0f2d7e7c1c..f745845f6e 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -58,6 +58,8 @@ + + diff --git a/osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj b/osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj index 5308de741a..983dc72d9e 100644 --- a/osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj +++ b/osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj @@ -85,8 +85,6 @@ - - From 46149044093b83aeb81a44b70296ea215fa6f6f0 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 10 May 2017 17:38:59 +0900 Subject: [PATCH 128/329] Update framework. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index cd37a9cad9..a1a62c14a5 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit cd37a9cad9aaede267152cf3753cd31fe697cec4 +Subproject commit a1a62c14a51654c933c5b077c725d566f167145b From ba998035a891bfdfaa4ccf14cbccf2c1d9590bdd Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 10 May 2017 17:53:51 +0900 Subject: [PATCH 129/329] More concrete way to determine whether all hit objects have been judged. --- .../Objects/Drawables/DrawableHitObject.cs | 17 ++++++++++++----- osu.Game/Rulesets/UI/HitRenderer.cs | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs index 21eca346c4..f443b5e279 100644 --- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs @@ -12,6 +12,7 @@ using Container = osu.Framework.Graphics.Containers.Container; using osu.Game.Rulesets.Objects.Types; using OpenTK.Graphics; using osu.Game.Audio; +using System.Linq; namespace osu.Game.Rulesets.Objects.Drawables { @@ -24,6 +25,11 @@ namespace osu.Game.Rulesets.Objects.Drawables public TJudgement Judgement; + /// + /// Whether this hit object has been judged. + /// + public virtual bool Judged => (Judgement?.Result ?? HitResult.None) != HitResult.None; + protected abstract TJudgement CreateJudgement(); protected abstract void UpdateState(ArmedState state); @@ -90,6 +96,11 @@ namespace osu.Game.Rulesets.Objects.Drawables /// public virtual Color4 AccentColour { get; set; } + /// + /// Whether this hit object and all of its nested hit objects have been judged. + /// + public sealed override bool Judged => base.Judged && NestedHitObjects.All(h => h.Judged); + protected DrawableHitObject(TObject hitObject) { HitObject = hitObject; @@ -172,15 +183,11 @@ namespace osu.Game.Rulesets.Objects.Drawables } } - private List> nestedHitObjects; - + private List> nestedHitObjects = new List>(); protected IEnumerable> NestedHitObjects => nestedHitObjects; protected void AddNested(DrawableHitObject h) { - if (nestedHitObjects == null) - nestedHitObjects = new List>(); - h.OnJudgement += d => OnJudgement?.Invoke(d); nestedHitObjects.Add(h); } diff --git a/osu.Game/Rulesets/UI/HitRenderer.cs b/osu.Game/Rulesets/UI/HitRenderer.cs index 8ee67df95a..bae8c5e75b 100644 --- a/osu.Game/Rulesets/UI/HitRenderer.cs +++ b/osu.Game/Rulesets/UI/HitRenderer.cs @@ -188,7 +188,7 @@ namespace osu.Game.Rulesets.UI public sealed override bool ProvidingUserCursor => !HasReplayLoaded && Playfield.ProvidingUserCursor; protected override Container Content => content; - protected override bool AllObjectsJudged => Playfield.HitObjects.Children.All(h => h.Judgement.Result != HitResult.None); + protected override bool AllObjectsJudged => Playfield.HitObjects.Children.All(h => h.Judged); /// /// The playfield. From 62656b98dffd155d752a37fa86ca6ec2f6d1aa1b Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 10 May 2017 20:39:13 +0900 Subject: [PATCH 130/329] Internalize HitObjects to playfields, since some playfields may not use that container. --- osu.Game/Rulesets/UI/HitRenderer.cs | 11 ++++++++--- osu.Game/Rulesets/UI/Playfield.cs | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/osu.Game/Rulesets/UI/HitRenderer.cs b/osu.Game/Rulesets/UI/HitRenderer.cs index bae8c5e75b..cbca4fbfa2 100644 --- a/osu.Game/Rulesets/UI/HitRenderer.cs +++ b/osu.Game/Rulesets/UI/HitRenderer.cs @@ -187,17 +187,19 @@ namespace osu.Game.Rulesets.UI public sealed override bool ProvidingUserCursor => !HasReplayLoaded && Playfield.ProvidingUserCursor; - protected override Container Content => content; - protected override bool AllObjectsJudged => Playfield.HitObjects.Children.All(h => h.Judged); + public override IEnumerable Objects => Beatmap.HitObjects; + + protected override bool AllObjectsJudged => drawableObjects.All(o => o.Judged); /// /// The playfield. /// protected Playfield Playfield; + protected override Container Content => content; private readonly Container content; - public override IEnumerable Objects => Beatmap.HitObjects; + private List> drawableObjects = new List>(); protected HitRenderer(WorkingBeatmap beatmap) : base(beatmap) @@ -224,6 +226,8 @@ namespace osu.Game.Rulesets.UI private void loadObjects() { + drawableObjects.Clear(); + foreach (TObject h in Beatmap.HitObjects) { var drawableObject = GetVisualRepresentation(h); @@ -233,6 +237,7 @@ namespace osu.Game.Rulesets.UI drawableObject.OnJudgement += onJudgement; + drawableObjects.Add(drawableObject); Playfield.Add(drawableObject); } diff --git a/osu.Game/Rulesets/UI/Playfield.cs b/osu.Game/Rulesets/UI/Playfield.cs index 0586c0385a..612569a9ae 100644 --- a/osu.Game/Rulesets/UI/Playfield.cs +++ b/osu.Game/Rulesets/UI/Playfield.cs @@ -19,7 +19,7 @@ namespace osu.Game.Rulesets.UI /// /// The HitObjects contained in this Playfield. /// - public HitObjectContainer> HitObjects; + protected HitObjectContainer> HitObjects; internal Container ScaledContent; From d55c97a08ad2cf93127022523d853c24700d1eaa Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Thu, 11 May 2017 01:48:46 +0300 Subject: [PATCH 131/329] Stop progress as soon as we at 100% --- osu.Game/Screens/Play/SongProgress.cs | 7 +++-- osu.Game/Screens/Play/SongProgressInfo.cs | 35 ++++++++++++----------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 548befdb36..c10248e97d 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -145,8 +145,11 @@ namespace osu.Game.Screens.Play double progress = ((audioClock?.CurrentTime ?? Time.Current) - firstHitTime) / (lastHitTime - firstHitTime); - bar.UpdatePosition((float)progress); - graph.Progress = (int)(graph.ColumnCount * progress); + if((int)progress * 100 < 100) + { + bar.UpdatePosition((float)progress); + graph.Progress = (int)(graph.ColumnCount * progress); + } } } } diff --git a/osu.Game/Screens/Play/SongProgressInfo.cs b/osu.Game/Screens/Play/SongProgressInfo.cs index 88ef358fbc..2767e4ec63 100644 --- a/osu.Game/Screens/Play/SongProgressInfo.cs +++ b/osu.Game/Screens/Play/SongProgressInfo.cs @@ -75,28 +75,31 @@ namespace osu.Game.Screens.Play double songCurrentTime = AudioClock.CurrentTime - startTime; - int currentSecond = TimeSpan.FromMilliseconds(songCurrentTime).Seconds; - - if (currentSecond != previousSecond || previousTimespan < 0 && songCurrentTime > 0) + if(songCurrentTime < endTime - startTime) { - previousTimespan = songCurrentTime; - previousSecond = currentSecond; + int currentSecond = TimeSpan.FromMilliseconds(songCurrentTime).Seconds; - if(songCurrentTime < 0) - timeCurrent.Text = @"-" + TimeSpan.FromMilliseconds(songCurrentTime - 1000).ToString(@"m\:ss"); - else - timeCurrent.Text = TimeSpan.FromMilliseconds(songCurrentTime).ToString(@"m\:ss"); + if (currentSecond != previousSecond || previousTimespan < 0 && songCurrentTime > 0) + { + previousTimespan = songCurrentTime; + previousSecond = currentSecond; - timeLeft.Text = @"-" + TimeSpan.FromMilliseconds(endTime - AudioClock.CurrentTime).ToString(@"m\:ss"); - } + if (songCurrentTime < 0) + timeCurrent.Text = @"-" + TimeSpan.FromMilliseconds(songCurrentTime - 1000).ToString(@"m\:ss"); + else + timeCurrent.Text = TimeSpan.FromMilliseconds(songCurrentTime).ToString(@"m\:ss"); - int currentPercent = (int)(songCurrentTime / (endTime - startTime) * 100); + timeLeft.Text = @"-" + TimeSpan.FromMilliseconds(endTime - AudioClock.CurrentTime).ToString(@"m\:ss"); + } - if (currentPercent != previousPercent) - { - previousPercent = currentPercent; + int currentPercent = (int)(songCurrentTime / (endTime - startTime) * 100) + 1; - progress.Text = (currentPercent <= 0 ? @"0" : currentPercent.ToString()) + @"%"; + if (currentPercent != previousPercent) + { + previousPercent = currentPercent; + + progress.Text = (currentPercent <= 0 ? @"0" : currentPercent.ToString()) + @"%"; + } } } } From c0acc1799b5841d129444647b2ba687e233ccb40 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Thu, 11 May 2017 01:49:57 +0300 Subject: [PATCH 132/329] Now progress testcase has it's own clock --- osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs index 6d8aac1d09..e3c343f5f8 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs @@ -18,10 +18,14 @@ namespace osu.Desktop.VisualTests.Tests private SongProgress progress; private SongProgressGraph graph; + private StopwatchClock clock; + public override void Reset() { base.Reset(); + clock = new StopwatchClock(true); + Add(progress = new SongProgress { RelativeSizeAxes = Axes.X, @@ -55,6 +59,9 @@ namespace osu.Desktop.VisualTests.Tests progress.Objects = objects; graph.Objects = objects; + + progress.AudioClock = clock; + progress.OnSeek = pos => clock.Seek(pos); } } } From ea0add2354cc73cf2ed8ac5650ba4e396d40e303 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Thu, 11 May 2017 02:34:57 +0300 Subject: [PATCH 133/329] Fixed update condition --- osu.Game/Screens/Play/SongProgress.cs | 2 +- osu.Game/Screens/Play/SongProgressInfo.cs | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index c10248e97d..8cead0684e 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -145,7 +145,7 @@ namespace osu.Game.Screens.Play double progress = ((audioClock?.CurrentTime ?? Time.Current) - firstHitTime) / (lastHitTime - firstHitTime); - if((int)progress * 100 < 100) + if(progress < 1) { bar.UpdatePosition((float)progress); graph.Progress = (int)(graph.ColumnCount * progress); diff --git a/osu.Game/Screens/Play/SongProgressInfo.cs b/osu.Game/Screens/Play/SongProgressInfo.cs index 2767e4ec63..ae6436bc6c 100644 --- a/osu.Game/Screens/Play/SongProgressInfo.cs +++ b/osu.Game/Screens/Play/SongProgressInfo.cs @@ -74,8 +74,9 @@ namespace osu.Game.Screens.Play base.Update(); double songCurrentTime = AudioClock.CurrentTime - startTime; + int currentPercent = (int)(songCurrentTime / (endTime - startTime) * 100); - if(songCurrentTime < endTime - startTime) + if (currentPercent <= 100) { int currentSecond = TimeSpan.FromMilliseconds(songCurrentTime).Seconds; @@ -92,8 +93,6 @@ namespace osu.Game.Screens.Play timeLeft.Text = @"-" + TimeSpan.FromMilliseconds(endTime - AudioClock.CurrentTime).ToString(@"m\:ss"); } - int currentPercent = (int)(songCurrentTime / (endTime - startTime) * 100) + 1; - if (currentPercent != previousPercent) { previousPercent = currentPercent; From 185e98aa14cd906a0d7fe6c5c9bf422b5b505688 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 11 May 2017 12:32:30 +0900 Subject: [PATCH 134/329] Add basic column conversion to ManiaBeatmapConverter. --- .../Beatmaps/ManiaBeatmapConverter.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs index 94984146f7..8e4fd83956 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs @@ -18,10 +18,17 @@ namespace osu.Game.Rulesets.Mania.Beatmaps protected override IEnumerable ConvertHitObject(HitObject original, Beatmap beatmap) { + int columns = (int)Math.Round(beatmap.BeatmapInfo.Difficulty.CircleSize); + + var positionData = original as IHasXPosition; + + float localWDivisor = 512.0f / columns; + int column = Math.Min((int)Math.Floor(positionData.X / localWDivisor), columns - 1); + yield return new Note { StartTime = original.StartTime, - Column = 1, + Column = column, }; } } From b10df740797f9bb9ece12cb5cd147fa9929995cd Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 11 May 2017 12:33:19 +0900 Subject: [PATCH 135/329] Full rewrite of timing section code, partially working for now. --- .../Tests/TestCaseManiaPlayfield.cs | 4 +- .../Timing/DrawableTimingSection.cs | 17 +- osu.Game.Rulesets.Mania/UI/Column.cs | 179 ++++++++---------- .../UI/ManiaHitRenderer.cs | 42 ++-- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 67 ++++++- .../UI/TimingSectionContainer.cs | 39 ++++ .../osu.Game.Rulesets.Mania.csproj | 1 + 7 files changed, 219 insertions(+), 130 deletions(-) create mode 100644 osu.Game.Rulesets.Mania/UI/TimingSectionContainer.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs index 2d4414d19f..459f4589b5 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs @@ -8,6 +8,8 @@ using osu.Framework.Graphics; using osu.Game.Rulesets.Mania.UI; using System.Linq; using System; +using System.Collections.Generic; +using osu.Game.Rulesets.Mania.Timing; namespace osu.Desktop.VisualTests.Tests { @@ -26,7 +28,7 @@ namespace osu.Desktop.VisualTests.Tests Action createPlayfield = (cols, pos) => { Clear(); - Add(new ManiaPlayfield(cols) + Add(new ManiaPlayfield(cols, new List()) { Anchor = Anchor.Centre, Origin = Anchor.Centre, diff --git a/osu.Game.Rulesets.Mania/Timing/DrawableTimingSection.cs b/osu.Game.Rulesets.Mania/Timing/DrawableTimingSection.cs index 8dcb39ae0d..b5943c272a 100644 --- a/osu.Game.Rulesets.Mania/Timing/DrawableTimingSection.cs +++ b/osu.Game.Rulesets.Mania/Timing/DrawableTimingSection.cs @@ -1,19 +1,27 @@ // 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 osu.Framework.Graphics; using osu.Framework.Graphics.Containers; + namespace osu.Game.Rulesets.Mania.Timing { + /// + /// A container that contains hit objects within the time span of a timing section. + /// public class DrawableTimingSection : Container { - private readonly TimingSection section; + public readonly TimingSection TimingSection; public DrawableTimingSection(TimingSection section) { - this.section = section; + TimingSection = section; + + Anchor = Anchor.BottomCentre; + Origin = Anchor.BottomCentre; RelativePositionAxes = Axes.Y; Y = -(float)section.StartTime; @@ -23,5 +31,10 @@ namespace osu.Game.Rulesets.Mania.Timing RelativeCoordinateSpace = new Vector2(1, Height); } + + protected override void Update() + { + Y = (float)(Time.Current - TimingSection.StartTime); + } } } \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/UI/Column.cs b/osu.Game.Rulesets.Mania/UI/Column.cs index 681c5a5ef2..a140fa1984 100644 --- a/osu.Game.Rulesets.Mania/UI/Column.cs +++ b/osu.Game.Rulesets.Mania/UI/Column.cs @@ -12,14 +12,18 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Colour; using osu.Framework.Input; using osu.Game.Graphics; -using osu.Game.Rulesets.Taiko.Timing; +using osu.Game.Rulesets.Mania.Timing; +using System.Collections.Generic; +using osu.Framework.Extensions.IEnumerableExtensions; +using osu.Framework.Graphics.Primitives; +using osu.Game.Rulesets.Objects.Drawables; +using osu.Game.Rulesets.Mania.Objects; +using osu.Game.Rulesets.Mania.Judgements; namespace osu.Game.Rulesets.Mania.UI { public class Column : Container, IHasAccentColour { - private const float key_size = 50; - private const float key_icon_size = 10; private const float key_icon_corner_radius = 3; private const float key_icon_border_radius = 2; @@ -30,24 +34,20 @@ namespace osu.Game.Rulesets.Mania.UI private const float column_width = 45; private const float special_column_width = 70; - private const double time_span_default = 2000; - private const double time_span_min = 10; - private const double time_span_max = 20000; - private const double time_span_step = 100; - public Key Key; private readonly Box background; private readonly Container hitTargetBar; private readonly Container keyIcon; - private readonly Container timingSectionContainer; - public Column() + public readonly TimingSectionContainer TimingSectionContainer; + + public Column(IEnumerable timingSections) { RelativeSizeAxes = Axes.Y; Width = column_width; - Children = new Drawable[] + InternalChildren = new Drawable[] { background = new Box { @@ -55,96 +55,85 @@ namespace osu.Game.Rulesets.Mania.UI RelativeSizeAxes = Axes.Both, Alpha = 0.2f }, - new FillFlowContainer + new Container { - Name = "Key + hit target", + Name = "Key", Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Direction = FillDirection.Vertical, - Children = new[] + Height = ManiaPlayfield.HIT_TARGET_POSITION, + Children = new Drawable[] { - new Container + new Box { - Name = "Key", - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, - RelativeSizeAxes = Axes.X, - Height = key_size, - Children = new Drawable[] - { - new Box - { - Name = "Key gradient", - RelativeSizeAxes = Axes.Both, - ColourInfo = ColourInfo.GradientVertical(Color4.Black, Color4.Black.Opacity(0)), - Alpha = 0.5f - }, - keyIcon = new Container - { - Name = "Key icon", - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Size = new Vector2(key_icon_size), - Masking = true, - CornerRadius = key_icon_corner_radius, - BorderThickness = 2, - BorderColour = Color4.White, // Not true - Children = new[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Alpha = 0, - AlwaysPresent = true - } - } - } - } + Name = "Key gradient", + RelativeSizeAxes = Axes.Both, + ColourInfo = ColourInfo.GradientVertical(Color4.Black, Color4.Black.Opacity(0)), + Alpha = 0.5f }, - new Container + keyIcon = new Container { - Name = "Hit target", - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, - RelativeSizeAxes = Axes.X, - Height = hit_target_height, - Children = new Drawable[] + Name = "Key icon", + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(key_icon_size), + Masking = true, + CornerRadius = key_icon_corner_radius, + BorderThickness = 2, + BorderColour = Color4.White, // Not true + Children = new[] { new Box { - Name = "Background", RelativeSizeAxes = Axes.Both, - Colour = Color4.Black - }, - hitTargetBar = new Container - { - Name = "Bar", - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, - RelativeSizeAxes = Axes.X, - Height = hit_target_bar_height, - Masking = true, - Children = new[] - { - new Box - { - RelativeSizeAxes = Axes.Both - } - } + Alpha = 0, + AlwaysPresent = true } } } } }, - timingSectionContainer = new Container + TimingSectionContainer = new TimingSectionContainer(timingSections) { + Name = "Hit objects", + RelativeSizeAxes = Axes.Both, Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, - RelativeSizeAxes = Axes.Both, - Y = -hit_target_bar_height, - RelativeCoordinateSpace = new Vector2(1, (float)time_span_default) + Y = -ManiaPlayfield.HIT_TARGET_POSITION + }, + new Container + { + Name = "Hit target", + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + RelativeSizeAxes = Axes.X, + Height = hit_target_height, + Y = -ManiaPlayfield.HIT_TARGET_POSITION, + Children = new Drawable[] + { + new Box + { + Name = "Background", + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black + }, + hitTargetBar = new Container + { + Name = "Bar", + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + RelativeSizeAxes = Axes.X, + Height = hit_target_bar_height, + Masking = true, + Children = new[] + { + new Box + { + RelativeSizeAxes = Axes.Both + } + } + } + } } }; } @@ -191,7 +180,10 @@ namespace osu.Game.Rulesets.Mania.UI } } - public void AddTimingSection(TimingSection timingSection) => timingSectionContainer.Add(new DrawableTimingSection(timingSection)); + public void Add(DrawableHitObject hitObject) + { + TimingSectionContainer.Add(hitObject); + } protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { @@ -204,19 +196,6 @@ namespace osu.Game.Rulesets.Mania.UI keyIcon.ScaleTo(1.4f, 50, EasingTypes.OutQuint); } - if (state.Keyboard.ControlPressed) - { - switch (args.Key) - { - case Key.Minus: - timeSpan += time_span_step; - break; - case Key.Plus: - timeSpan -= time_span_step; - break; - } - } - return false; } @@ -230,15 +209,5 @@ namespace osu.Game.Rulesets.Mania.UI return false; } - - /// - /// The amount of time which the length of this column spans. - /// - private double timeSpan - { - get { return timingSectionContainer.RelativeCoordinateSpace.Y; } - set { timingSectionContainer.RelativeCoordinateSpace = new Vector2(1, (float)MathHelper.Clamp(value, time_span_min, time_span_max)); } - } } - } diff --git a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs index b34442b1e1..20a7d9983e 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs @@ -12,11 +12,12 @@ using osu.Game.Rulesets.Beatmaps; using osu.Game.Rulesets.Mania.Beatmaps; using osu.Game.Rulesets.Mania.Judgements; using osu.Game.Rulesets.Mania.Objects; +using osu.Game.Rulesets.Mania.Objects.Drawables; using osu.Game.Rulesets.Mania.Scoring; +using osu.Game.Rulesets.Mania.Timing; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Scoring; -using osu.Game.Rulesets.Taiko.Timing; using osu.Game.Rulesets.UI; namespace osu.Game.Rulesets.Mania.UI @@ -28,17 +29,11 @@ namespace osu.Game.Rulesets.Mania.UI public ManiaHitRenderer(WorkingBeatmap beatmap) : base(beatmap) { - // Has to be done before drawable hit objects are generated in load() - loadTimingSections(); } - private void loadTimingSections() + protected override Playfield CreatePlayfield() { - var maniaPlayfield = Playfield as ManiaPlayfield; - if (maniaPlayfield == null) - return; - - var sections = new List(); + List timingSections = new List(); // Construct all the relevant timing sections ControlPoint lastTimingChange = null; @@ -47,7 +42,7 @@ namespace osu.Game.Rulesets.Mania.UI if (point.TimingChange) lastTimingChange = point; - sections.Add(new TimingSection + timingSections.Add(new TimingSection { StartTime = point.Time, // Todo: Should this be dividing by beatlength? @@ -59,7 +54,7 @@ namespace osu.Game.Rulesets.Mania.UI double lastObjectTime = (Objects.Last() as IHasEndTime)?.EndTime ?? Objects.Last().StartTime; // Perform some post processing of the timing sections - sections = sections + timingSections = timingSections // Collapse sections after the last hit object .Where(s => s.StartTime <= lastObjectTime) // Collapse sections with the same start time @@ -69,27 +64,36 @@ namespace osu.Game.Rulesets.Mania.UI .ToList(); // Determine duration of timing sections - for (int i = 0; i < sections.Count; i++) + for (int i = 0; i < timingSections.Count; i++) { - if (i < sections.Count - 1) - sections[i].Duration = sections[i + 1].StartTime - sections[i].StartTime; + if (i < timingSections.Count - 1) + timingSections[i].Duration = timingSections[i + 1].StartTime - timingSections[i].StartTime; else { // Extra length added for the last timing section to extend past the last hitobject - double extraLength = sections[i].BeatLength * (int)sections[i].TimeSignature; - sections[i].Duration = lastObjectTime + extraLength - sections[i].StartTime; + double extraLength = timingSections[i].BeatLength * (int)timingSections[i].TimeSignature; + timingSections[i].Duration = lastObjectTime + extraLength - timingSections[i].StartTime; } } - sections.ForEach(s => maniaPlayfield.Columns.Children.ForEach(c => c.AddTimingSection(s))); + return new ManiaPlayfield(Columns ?? (int)Math.Round(Beatmap.BeatmapInfo.Difficulty.CircleSize), timingSections); } public override ScoreProcessor CreateScoreProcessor() => new ManiaScoreProcessor(this); protected override BeatmapConverter CreateBeatmapConverter() => new ManiaBeatmapConverter(); - protected override Playfield CreatePlayfield() => new ManiaPlayfield(Columns ?? (int)Math.Round(Beatmap.BeatmapInfo.Difficulty.CircleSize)); + protected override DrawableHitObject GetVisualRepresentation(ManiaHitObject h) + { + var note = h as Note; + if (note != null) + return new DrawableNote(note); - protected override DrawableHitObject GetVisualRepresentation(ManiaHitObject h) => null; + var holdNote = h as HoldNote; + if (holdNote != null) + return new DrawableHoldNote(holdNote); + + return null; + } } } diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index e468d6f533..4572239b55 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -16,15 +16,23 @@ using osu.Framework.Allocation; using OpenTK.Input; using System.Linq; using System.Collections.Generic; -using osu.Game.Rulesets.Taiko.Timing; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Mania.Objects.Drawables; +using osu.Game.Rulesets.Mania.Timing; +using osu.Framework.Input; namespace osu.Game.Rulesets.Mania.UI { public class ManiaPlayfield : Playfield { + public const float HIT_TARGET_POSITION = 50; + + private const float time_span_default = 500; + private const float time_span_min = 10; + private const float time_span_max = 20000; + private const float time_span_step = 100; + /// /// Default column keys, expanding outwards from the middle as more column are added. /// E.g. 2 columns use FJ, 4 columns use DFJK, 6 use SDFJKL, etc... @@ -48,12 +56,14 @@ namespace osu.Game.Rulesets.Mania.UI public readonly FlowContainer Columns; + private readonly TimingSectionContainer barlineContainer; + private List normalColumnColours = new List(); private Color4 specialColumnColour; private readonly int columnCount; - public ManiaPlayfield(int columnCount) + public ManiaPlayfield(int columnCount, IEnumerable timingSections) { this.columnCount = columnCount; @@ -77,18 +87,29 @@ namespace osu.Game.Rulesets.Mania.UI }, Columns = new FillFlowContainer { + Name = "Columns", RelativeSizeAxes = Axes.Y, AutoSizeAxes = Axes.X, Direction = FillDirection.Horizontal, Padding = new MarginPadding { Left = 1, Right = 1 }, Spacing = new Vector2(1, 0) + }, + barlineContainer = new TimingSectionContainer(timingSections) + { + Name = "Barlines", + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Bottom = HIT_TARGET_POSITION } } } } }; for (int i = 0; i < columnCount; i++) - Columns.Add(new Column()); + Columns.Add(new Column(timingSections)); + + TimeSpan = time_span_default; } [BackgroundDependencyLoader] @@ -162,5 +183,45 @@ namespace osu.Game.Rulesets.Mania.UI } public override void Add(DrawableHitObject h) => Columns.Children.ElementAt(h.HitObject.Column).Add(h); + + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + if (args.Repeat) + return false; + + if (state.Keyboard.ControlPressed) + { + switch (args.Key) + { + case Key.Minus: + TimeSpan += time_span_step; + break; + case Key.Plus: + TimeSpan -= time_span_step; + break; + } + } + + return false; + } + + private double timeSpan; + /// + /// The amount of time which the length of the playfield spans. + /// + public double TimeSpan + { + get { return timeSpan; } + set + { + if (timeSpan == value) + return; + timeSpan = value; + + barlineContainer.TimeSpan = value; + Columns.Children.ForEach(c => c.TimingSectionContainer.TimeSpan = value); + } + } + } } diff --git a/osu.Game.Rulesets.Mania/UI/TimingSectionContainer.cs b/osu.Game.Rulesets.Mania/UI/TimingSectionContainer.cs new file mode 100644 index 0000000000..378d4279e5 --- /dev/null +++ b/osu.Game.Rulesets.Mania/UI/TimingSectionContainer.cs @@ -0,0 +1,39 @@ +// 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 OpenTK; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Rulesets.Mania.Judgements; +using osu.Game.Rulesets.Mania.Objects; +using osu.Game.Rulesets.Mania.Timing; +using osu.Game.Rulesets.Objects.Drawables; + +namespace osu.Game.Rulesets.Mania.UI +{ + public class TimingSectionContainer : Container + { + /// + /// The amount of time which the length of this container spans. + /// + public double TimeSpan + { + get { return RelativeCoordinateSpace.Y; } + set { RelativeCoordinateSpace = new Vector2(1, (float)value); } + } + + public TimingSectionContainer(IEnumerable timingSections) + { + Children = timingSections.Select(t => new DrawableTimingSection(t)); + } + + public void Add(Drawable drawable) + { + var section = Children.LastOrDefault(t => t.TimingSection.StartTime <= drawable.Y) ?? Children.First(); + drawable.Y -= (float)section.TimingSection.StartTime; + section.Add(drawable); + } + } +} \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index f745845f6e..e1d033c214 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -70,6 +70,7 @@ + From 8160f36a48b39f051180e6db1e0d9c463497a178 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 11 May 2017 12:56:51 +0900 Subject: [PATCH 136/329] Fix notes scrolling from end of map -> start of map. --- .../Objects/Drawables/DrawableManiaHitObject.cs | 4 ++-- osu.Game.Rulesets.Mania/UI/TimingSectionContainer.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs index f33a6fe699..14d930893f 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs @@ -23,11 +23,11 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables { HitObject = hitObject; - Anchor = Anchor.TopCentre; + Anchor = Anchor.BottomCentre; Origin = Anchor.BottomCentre; RelativePositionAxes = Axes.Y; - Y = (float)HitObject.StartTime; + Y = (float)-HitObject.StartTime; Add(glowContainer = new Container { diff --git a/osu.Game.Rulesets.Mania/UI/TimingSectionContainer.cs b/osu.Game.Rulesets.Mania/UI/TimingSectionContainer.cs index 378d4279e5..a43d107341 100644 --- a/osu.Game.Rulesets.Mania/UI/TimingSectionContainer.cs +++ b/osu.Game.Rulesets.Mania/UI/TimingSectionContainer.cs @@ -31,8 +31,8 @@ namespace osu.Game.Rulesets.Mania.UI public void Add(Drawable drawable) { - var section = Children.LastOrDefault(t => t.TimingSection.StartTime <= drawable.Y) ?? Children.First(); - drawable.Y -= (float)section.TimingSection.StartTime; + var section = Children.LastOrDefault(t => t.Y >= drawable.Y) ?? Children.First(); + drawable.Y -= (float)section.Y; section.Add(drawable); } } From 7fcbf2d8d4dfc8c472f056352ce9bfea82cd3bb2 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 11 May 2017 12:57:07 +0900 Subject: [PATCH 137/329] Add t=0 display to notes. --- osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs index 57990f2738..393ddfb3e0 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs @@ -41,6 +41,12 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables } } + protected override void Update() + { + if (Time.Current > HitObject.StartTime) + Colour = Color4.Green; + } + protected override void UpdateState(ArmedState state) { } From 7d8af5f1da4fd320c20b32ee5f76acf2d16e9bf6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 11 May 2017 13:19:31 +0900 Subject: [PATCH 138/329] Use SearchTextBox Correctly handle focus. --- osu.Game/Overlays/OptionsOverlay.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/OptionsOverlay.cs b/osu.Game/Overlays/OptionsOverlay.cs index afe998c208..677c3f7c40 100644 --- a/osu.Game/Overlays/OptionsOverlay.cs +++ b/osu.Game/Overlays/OptionsOverlay.cs @@ -13,7 +13,7 @@ using System; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Overlays.Options.Sections; -using osu.Game.Graphics.UserInterface; +using osu.Game.Screens.Select; namespace osu.Game.Overlays { @@ -33,7 +33,10 @@ namespace osu.Game.Overlays private Sidebar sidebar; private SidebarButton[] sidebarButtons; private OptionsSection[] sections; + private SearchContainer searchContainer; + private SearchTextBox searchTextBox; + private float lastKnownScroll; public OptionsOverlay() @@ -45,8 +48,6 @@ namespace osu.Game.Overlays [BackgroundDependencyLoader(permitNulls: true)] private void load(OsuGame game, OsuColour colours) { - OsuTextBox textBox; - sections = new OptionsSection[] { new GeneralSection(), @@ -96,11 +97,11 @@ namespace osu.Game.Overlays TextSize = 18, Margin = new MarginPadding { Left = CONTENT_MARGINS, Bottom = 30 }, }, - textBox = new OsuTextBox + searchTextBox = new SearchTextBox { - PlaceholderText = "Type to search!", Width = width - CONTENT_MARGINS * 2, Margin = new MarginPadding { Left = CONTENT_MARGINS }, + Exit = () => Hide(), }, searchContainer = new SearchContainer { @@ -128,7 +129,7 @@ namespace osu.Game.Overlays } }; - textBox.Current.ValueChanged += newValue => searchContainer.SearchTerm = newValue; + searchTextBox.Current.ValueChanged += newValue => searchContainer.SearchTerm = newValue; scrollContainer.Padding = new MarginPadding { Top = game?.Toolbar.DrawHeight ?? 0 }; } @@ -169,6 +170,8 @@ namespace osu.Game.Overlays scrollContainer.MoveToX(0, TRANSITION_LENGTH, EasingTypes.OutQuint); sidebar.MoveToX(0, TRANSITION_LENGTH, EasingTypes.OutQuint); FadeTo(1, TRANSITION_LENGTH / 2); + + searchTextBox.HoldFocus = true; } protected override void PopOut() @@ -178,6 +181,9 @@ namespace osu.Game.Overlays scrollContainer.MoveToX(-width, TRANSITION_LENGTH, EasingTypes.OutQuint); sidebar.MoveToX(-SIDEBAR_WIDTH, TRANSITION_LENGTH, EasingTypes.OutQuint); FadeTo(0, TRANSITION_LENGTH / 2); + + searchTextBox.HoldFocus = false; + searchTextBox.TriggerFocusLost(); } } } From cdf827df8ea19c902a74453959bd43657e4b3e0a Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 11 May 2017 13:11:36 +0900 Subject: [PATCH 139/329] CI fixes. --- .../Tests/TestCaseManiaHitObjects.cs | 5 ----- .../Objects/Drawables/DrawableHoldNote.cs | 11 ++++------- .../Objects/Drawables/DrawableManiaHitObject.cs | 3 +-- .../Objects/Drawables/DrawableNote.cs | 7 ++----- .../Objects/Drawables/Pieces/BodyPiece.cs | 3 +-- .../Objects/Drawables/Pieces/NotePiece.cs | 2 +- 6 files changed, 9 insertions(+), 22 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs index 4234140be6..3ad83beb73 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs @@ -6,11 +6,6 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Testing; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Objects.Drawables; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using OpenTK.Graphics; using OpenTK; diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs index b6943a95ce..61dc2638a6 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -1,21 +1,18 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using osu.Game.Rulesets.Objects.Drawables; using osu.Framework.Graphics; -using osu.Framework.Allocation; using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces; using OpenTK.Graphics; -using osu.Framework.Graphics.Containers; namespace osu.Game.Rulesets.Mania.Objects.Drawables { public class DrawableHoldNote : DrawableManiaHitObject { - private NotePiece headPiece; - private BodyPiece bodyPiece; - private NotePiece tailPiece; + private readonly NotePiece headPiece; + private readonly BodyPiece bodyPiece; + private readonly NotePiece tailPiece; public DrawableHoldNote(HoldNote hitObject) : base(hitObject) @@ -52,7 +49,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables public override Color4 AccentColour { - get { return AccentColour; } + get { return base.AccentColour; } set { if (base.AccentColour == value) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs index f33a6fe699..29e4137bba 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK.Graphics; -using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -18,7 +17,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables private readonly Container glowContainer; - public DrawableManiaHitObject(TObject hitObject) + protected DrawableManiaHitObject(TObject hitObject) : base(hitObject) { HitObject = hitObject; diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs index 57990f2738..bc194b7703 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs @@ -2,10 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK.Graphics; -using osu.Framework.Allocation; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces; using osu.Game.Rulesets.Objects.Drawables; @@ -13,7 +10,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables { public class DrawableNote : DrawableManiaHitObject { - private NotePiece headPiece; + private readonly NotePiece headPiece; public DrawableNote(Note hitObject) : base(hitObject) @@ -30,7 +27,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables public override Color4 AccentColour { - get { return AccentColour; } + get { return base.AccentColour; } set { if (base.AccentColour == value) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs index ac2b7df06f..ce61a7a86f 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.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.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -15,7 +14,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces /// internal class BodyPiece : Container, IHasAccentColour { - private Box box; + private readonly Box box; public BodyPiece() { diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs index 2584682833..e01199e929 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs @@ -18,7 +18,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces private const float head_height = 10; private const float head_colour_height = 6; - private Box colouredBox; + private readonly Box colouredBox; public NotePiece() { From df4820440376e89f619752581d555814b3888767 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 11 May 2017 13:56:21 +0900 Subject: [PATCH 140/329] Fix OptionsOverlay stealing focus itself. --- osu.Game/Overlays/OptionsOverlay.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/osu.Game/Overlays/OptionsOverlay.cs b/osu.Game/Overlays/OptionsOverlay.cs index 677c3f7c40..1176e91a36 100644 --- a/osu.Game/Overlays/OptionsOverlay.cs +++ b/osu.Game/Overlays/OptionsOverlay.cs @@ -14,6 +14,7 @@ using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Overlays.Options.Sections; using osu.Game.Screens.Select; +using osu.Framework.Input; namespace osu.Game.Overlays { @@ -185,5 +186,11 @@ namespace osu.Game.Overlays searchTextBox.HoldFocus = false; searchTextBox.TriggerFocusLost(); } + + protected override bool OnFocus(InputState state) + { + searchTextBox.TriggerFocus(state); + return false; + } } } From a6b71f8ccbe5c7442be11b5dd3351fbeab25fdb6 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 11 May 2017 14:11:52 +0900 Subject: [PATCH 141/329] Resharper fixes. --- .../Tests/TestCaseManiaHitObjects.cs | 5 ----- .../Beatmaps/ManiaBeatmapConverter.cs | 1 - .../Objects/Drawables/DrawableHoldNote.cs | 11 ++++------- .../Objects/Drawables/DrawableManiaHitObject.cs | 3 +-- .../Objects/Drawables/DrawableNote.cs | 7 ++----- .../Objects/Drawables/Pieces/BodyPiece.cs | 3 +-- .../Objects/Drawables/Pieces/NotePiece.cs | 2 +- .../Timing/DrawableTimingSection.cs | 2 -- osu.Game.Rulesets.Mania/UI/Column.cs | 2 -- osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs | 2 -- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 1 - osu.Game.Rulesets.Mania/UI/TimingSectionContainer.cs | 5 +---- .../Rulesets/Objects/Drawables/DrawableHitObject.cs | 2 +- osu.Game/Rulesets/UI/HitRenderer.cs | 2 +- 14 files changed, 12 insertions(+), 36 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs index 97c65b799b..4368e8488c 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs @@ -6,11 +6,6 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Testing; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Objects.Drawables; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using OpenTK.Graphics; using OpenTK; diff --git a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs index 8e4fd83956..08ee8c0bf8 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs @@ -8,7 +8,6 @@ using System; using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Beatmaps; using osu.Game.Rulesets.Objects; -using osu.Game.Rulesets.Mania.Objects.Drawables; namespace osu.Game.Rulesets.Mania.Beatmaps { diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs index b6943a95ce..61dc2638a6 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -1,21 +1,18 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using osu.Game.Rulesets.Objects.Drawables; using osu.Framework.Graphics; -using osu.Framework.Allocation; using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces; using OpenTK.Graphics; -using osu.Framework.Graphics.Containers; namespace osu.Game.Rulesets.Mania.Objects.Drawables { public class DrawableHoldNote : DrawableManiaHitObject { - private NotePiece headPiece; - private BodyPiece bodyPiece; - private NotePiece tailPiece; + private readonly NotePiece headPiece; + private readonly BodyPiece bodyPiece; + private readonly NotePiece tailPiece; public DrawableHoldNote(HoldNote hitObject) : base(hitObject) @@ -52,7 +49,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables public override Color4 AccentColour { - get { return AccentColour; } + get { return base.AccentColour; } set { if (base.AccentColour == value) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs index 14d930893f..e3b28c8aca 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK.Graphics; -using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -18,7 +17,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables private readonly Container glowContainer; - public DrawableManiaHitObject(TObject hitObject) + protected DrawableManiaHitObject(TObject hitObject) : base(hitObject) { HitObject = hitObject; diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs index 393ddfb3e0..8832fc8d48 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs @@ -2,10 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK.Graphics; -using osu.Framework.Allocation; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces; using osu.Game.Rulesets.Objects.Drawables; @@ -13,7 +10,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables { public class DrawableNote : DrawableManiaHitObject { - private NotePiece headPiece; + private readonly NotePiece headPiece; public DrawableNote(Note hitObject) : base(hitObject) @@ -30,7 +27,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables public override Color4 AccentColour { - get { return AccentColour; } + get { return base.AccentColour; } set { if (base.AccentColour == value) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs index ac2b7df06f..ce61a7a86f 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.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.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -15,7 +14,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces /// internal class BodyPiece : Container, IHasAccentColour { - private Box box; + private readonly Box box; public BodyPiece() { diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs index 2584682833..e01199e929 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs @@ -18,7 +18,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces private const float head_height = 10; private const float head_colour_height = 6; - private Box colouredBox; + private readonly Box colouredBox; public NotePiece() { diff --git a/osu.Game.Rulesets.Mania/Timing/DrawableTimingSection.cs b/osu.Game.Rulesets.Mania/Timing/DrawableTimingSection.cs index b5943c272a..2225a63cdf 100644 --- a/osu.Game.Rulesets.Mania/Timing/DrawableTimingSection.cs +++ b/osu.Game.Rulesets.Mania/Timing/DrawableTimingSection.cs @@ -1,12 +1,10 @@ // 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 osu.Framework.Graphics; using osu.Framework.Graphics.Containers; - namespace osu.Game.Rulesets.Mania.Timing { /// diff --git a/osu.Game.Rulesets.Mania/UI/Column.cs b/osu.Game.Rulesets.Mania/UI/Column.cs index a140fa1984..abfa3c921b 100644 --- a/osu.Game.Rulesets.Mania/UI/Column.cs +++ b/osu.Game.Rulesets.Mania/UI/Column.cs @@ -14,8 +14,6 @@ using osu.Framework.Input; using osu.Game.Graphics; using osu.Game.Rulesets.Mania.Timing; using System.Collections.Generic; -using osu.Framework.Extensions.IEnumerableExtensions; -using osu.Framework.Graphics.Primitives; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Judgements; diff --git a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs index 20a7d9983e..b6dae3dfe9 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs @@ -4,8 +4,6 @@ using System; using System.Collections.Generic; using System.Linq; -using osu.Framework.Allocation; -using osu.Framework.Extensions.IEnumerableExtensions; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Timing; using osu.Game.Rulesets.Beatmaps; diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index 4572239b55..8cf792dbb0 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -18,7 +18,6 @@ using System.Linq; using System.Collections.Generic; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Game.Rulesets.Objects.Drawables; -using osu.Game.Rulesets.Mania.Objects.Drawables; using osu.Game.Rulesets.Mania.Timing; using osu.Framework.Input; diff --git a/osu.Game.Rulesets.Mania/UI/TimingSectionContainer.cs b/osu.Game.Rulesets.Mania/UI/TimingSectionContainer.cs index a43d107341..9a63c17c59 100644 --- a/osu.Game.Rulesets.Mania/UI/TimingSectionContainer.cs +++ b/osu.Game.Rulesets.Mania/UI/TimingSectionContainer.cs @@ -6,10 +6,7 @@ using System.Linq; using OpenTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Game.Rulesets.Mania.Judgements; -using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Timing; -using osu.Game.Rulesets.Objects.Drawables; namespace osu.Game.Rulesets.Mania.UI { @@ -32,7 +29,7 @@ namespace osu.Game.Rulesets.Mania.UI public void Add(Drawable drawable) { var section = Children.LastOrDefault(t => t.Y >= drawable.Y) ?? Children.First(); - drawable.Y -= (float)section.Y; + drawable.Y -= section.Y; section.Add(drawable); } } diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs index f443b5e279..8e153415c7 100644 --- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs @@ -183,7 +183,7 @@ namespace osu.Game.Rulesets.Objects.Drawables } } - private List> nestedHitObjects = new List>(); + private readonly List> nestedHitObjects = new List>(); protected IEnumerable> NestedHitObjects => nestedHitObjects; protected void AddNested(DrawableHitObject h) diff --git a/osu.Game/Rulesets/UI/HitRenderer.cs b/osu.Game/Rulesets/UI/HitRenderer.cs index cbca4fbfa2..52b7a2766a 100644 --- a/osu.Game/Rulesets/UI/HitRenderer.cs +++ b/osu.Game/Rulesets/UI/HitRenderer.cs @@ -199,7 +199,7 @@ namespace osu.Game.Rulesets.UI protected override Container Content => content; private readonly Container content; - private List> drawableObjects = new List>(); + private readonly List> drawableObjects = new List>(); protected HitRenderer(WorkingBeatmap beatmap) : base(beatmap) From 623912b40a0f5b246cbdcd5caa155c0ca9546fcf Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 11 May 2017 14:26:00 +0900 Subject: [PATCH 142/329] Fix playfield position. --- osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs | 12 ++++++++++-- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs index b6dae3dfe9..6a047b4997 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs @@ -4,6 +4,8 @@ using System; using System.Collections.Generic; using System.Linq; +using OpenTK; +using osu.Framework.Graphics; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Timing; using osu.Game.Rulesets.Beatmaps; @@ -31,7 +33,7 @@ namespace osu.Game.Rulesets.Mania.UI protected override Playfield CreatePlayfield() { - List timingSections = new List(); + var timingSections = new List(); // Construct all the relevant timing sections ControlPoint lastTimingChange = null; @@ -74,7 +76,11 @@ namespace osu.Game.Rulesets.Mania.UI } } - return new ManiaPlayfield(Columns ?? (int)Math.Round(Beatmap.BeatmapInfo.Difficulty.CircleSize), timingSections); + return new ManiaPlayfield(Columns ?? (int)Math.Round(Beatmap.BeatmapInfo.Difficulty.CircleSize), timingSections) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre + }; } public override ScoreProcessor CreateScoreProcessor() => new ManiaScoreProcessor(this); @@ -93,5 +99,7 @@ namespace osu.Game.Rulesets.Mania.UI return null; } + + protected override Vector2 GetPlayfieldAspectAdjust() => new Vector2(1, 0.8f); } } diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index 8cf792dbb0..75c1140a9a 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -73,8 +73,8 @@ namespace osu.Game.Rulesets.Mania.UI { new Container { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, RelativeSizeAxes = Axes.Y, AutoSizeAxes = Axes.X, Children = new Drawable[] From da4be2f9d614f31ec845486285f7fd2a25ecd112 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 11 May 2017 14:32:31 +0900 Subject: [PATCH 143/329] Move notes above judgement area but below keys. --- osu.Game.Rulesets.Mania/UI/Column.cs | 84 ++++++++++++++-------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/osu.Game.Rulesets.Mania/UI/Column.cs b/osu.Game.Rulesets.Mania/UI/Column.cs index abfa3c921b..4f89d3b634 100644 --- a/osu.Game.Rulesets.Mania/UI/Column.cs +++ b/osu.Game.Rulesets.Mania/UI/Column.cs @@ -54,6 +54,48 @@ namespace osu.Game.Rulesets.Mania.UI Alpha = 0.2f }, new Container + { + Name = "Hit target", + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + RelativeSizeAxes = Axes.X, + Height = hit_target_height, + Y = -ManiaPlayfield.HIT_TARGET_POSITION, + Children = new Drawable[] + { + new Box + { + Name = "Background", + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black + }, + hitTargetBar = new Container + { + Name = "Bar", + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + RelativeSizeAxes = Axes.X, + Height = hit_target_bar_height, + Masking = true, + Children = new[] + { + new Box + { + RelativeSizeAxes = Axes.Both + } + } + } + } + }, + TimingSectionContainer = new TimingSectionContainer(timingSections) + { + Name = "Hit objects", + RelativeSizeAxes = Axes.Both, + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + Y = -ManiaPlayfield.HIT_TARGET_POSITION + }, + new Container { Name = "Key", Anchor = Anchor.BottomCentre, @@ -90,48 +132,6 @@ namespace osu.Game.Rulesets.Mania.UI } } } - }, - TimingSectionContainer = new TimingSectionContainer(timingSections) - { - Name = "Hit objects", - RelativeSizeAxes = Axes.Both, - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, - Y = -ManiaPlayfield.HIT_TARGET_POSITION - }, - new Container - { - Name = "Hit target", - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, - RelativeSizeAxes = Axes.X, - Height = hit_target_height, - Y = -ManiaPlayfield.HIT_TARGET_POSITION, - Children = new Drawable[] - { - new Box - { - Name = "Background", - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black - }, - hitTargetBar = new Container - { - Name = "Bar", - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, - RelativeSizeAxes = Axes.X, - Height = hit_target_bar_height, - Masking = true, - Children = new[] - { - new Box - { - RelativeSizeAxes = Axes.Both - } - } - } - } } }; } From 6445bea864d2bd3fdd3e0f9fc21186a65569857e Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 11 May 2017 14:43:57 +0900 Subject: [PATCH 144/329] Make Playfield.HitObjects internal to playfields. Because not all playfields will be using this. --- osu.Game/Rulesets/UI/HitRenderer.cs | 11 ++++++++--- osu.Game/Rulesets/UI/Playfield.cs | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/osu.Game/Rulesets/UI/HitRenderer.cs b/osu.Game/Rulesets/UI/HitRenderer.cs index 8ee67df95a..4ca77f71df 100644 --- a/osu.Game/Rulesets/UI/HitRenderer.cs +++ b/osu.Game/Rulesets/UI/HitRenderer.cs @@ -187,17 +187,19 @@ namespace osu.Game.Rulesets.UI public sealed override bool ProvidingUserCursor => !HasReplayLoaded && Playfield.ProvidingUserCursor; - protected override Container Content => content; - protected override bool AllObjectsJudged => Playfield.HitObjects.Children.All(h => h.Judgement.Result != HitResult.None); + public override IEnumerable Objects => Beatmap.HitObjects; + + protected override bool AllObjectsJudged => drawableObjects.All(h => h.Judgement.Result != HitResult.None); /// /// The playfield. /// protected Playfield Playfield; + protected override Container Content => content; private readonly Container content; - public override IEnumerable Objects => Beatmap.HitObjects; + private List> drawableObjects; protected HitRenderer(WorkingBeatmap beatmap) : base(beatmap) @@ -224,6 +226,8 @@ namespace osu.Game.Rulesets.UI private void loadObjects() { + drawableObjects = new List>(Beatmap.HitObjects.Count); + foreach (TObject h in Beatmap.HitObjects) { var drawableObject = GetVisualRepresentation(h); @@ -233,6 +237,7 @@ namespace osu.Game.Rulesets.UI drawableObject.OnJudgement += onJudgement; + drawableObjects.Add(drawableObject); Playfield.Add(drawableObject); } diff --git a/osu.Game/Rulesets/UI/Playfield.cs b/osu.Game/Rulesets/UI/Playfield.cs index 0586c0385a..612569a9ae 100644 --- a/osu.Game/Rulesets/UI/Playfield.cs +++ b/osu.Game/Rulesets/UI/Playfield.cs @@ -19,7 +19,7 @@ namespace osu.Game.Rulesets.UI /// /// The HitObjects contained in this Playfield. /// - public HitObjectContainer> HitObjects; + protected HitObjectContainer> HitObjects; internal Container ScaledContent; From 2d2d1bedddf1664ef5037de502cc9b7885462b89 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 11 May 2017 14:48:08 +0900 Subject: [PATCH 145/329] More concrete method to determine if all hit objects have been judged. Covers the case where nested hit objects are involved. --- .../Objects/Drawables/DrawableHitObject.cs | 14 ++++++++++++-- osu.Game/Rulesets/UI/HitRenderer.cs | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs index a300eeab31..45ef2553b5 100644 --- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs @@ -12,6 +12,7 @@ using Container = osu.Framework.Graphics.Containers.Container; using osu.Game.Rulesets.Objects.Types; using OpenTK.Graphics; using osu.Game.Audio; +using System.Linq; namespace osu.Game.Rulesets.Objects.Drawables { @@ -24,6 +25,11 @@ namespace osu.Game.Rulesets.Objects.Drawables public TJudgement Judgement; + /// + /// Whether this hit object has been judged. + /// + public virtual bool Judged => (Judgement?.Result ?? HitResult.None) != HitResult.None; + protected abstract TJudgement CreateJudgement(); protected abstract void UpdateState(ArmedState state); @@ -86,6 +92,11 @@ namespace osu.Game.Rulesets.Objects.Drawables /// public Color4 AccentColour { get; protected set; } + /// + /// Whether this hit object and all of its nested hit objects have been judged. + /// + public sealed override bool Judged => base.Judged && (NestedHitObjects?.All(h => h.Judged) ?? true); + protected DrawableHitObject(TObject hitObject) { HitObject = hitObject; @@ -97,7 +108,7 @@ namespace osu.Game.Rulesets.Objects.Drawables /// Whether a hit was processed. protected bool UpdateJudgement(bool userTriggered) { - IPartialJudgement partial = Judgement as IPartialJudgement; + var partial = Judgement as IPartialJudgement; // Never re-process non-partial hits if (Judgement.Result != HitResult.None && partial == null) @@ -169,7 +180,6 @@ namespace osu.Game.Rulesets.Objects.Drawables } private List> nestedHitObjects; - protected IEnumerable> NestedHitObjects => nestedHitObjects; protected void AddNested(DrawableHitObject h) diff --git a/osu.Game/Rulesets/UI/HitRenderer.cs b/osu.Game/Rulesets/UI/HitRenderer.cs index 4ca77f71df..559014ce95 100644 --- a/osu.Game/Rulesets/UI/HitRenderer.cs +++ b/osu.Game/Rulesets/UI/HitRenderer.cs @@ -189,7 +189,7 @@ namespace osu.Game.Rulesets.UI public override IEnumerable Objects => Beatmap.HitObjects; - protected override bool AllObjectsJudged => drawableObjects.All(h => h.Judgement.Result != HitResult.None); + protected override bool AllObjectsJudged => drawableObjects.All(h => h.Judged); /// /// The playfield. From a762f820c68d900df075e3a571b3e25878c9e286 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 11 May 2017 14:50:18 +0900 Subject: [PATCH 146/329] Fix possible nullrefs. --- osu.Game/Rulesets/UI/HitRenderer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Rulesets/UI/HitRenderer.cs b/osu.Game/Rulesets/UI/HitRenderer.cs index 559014ce95..3ec5c353a0 100644 --- a/osu.Game/Rulesets/UI/HitRenderer.cs +++ b/osu.Game/Rulesets/UI/HitRenderer.cs @@ -199,7 +199,7 @@ namespace osu.Game.Rulesets.UI protected override Container Content => content; private readonly Container content; - private List> drawableObjects; + private readonly List> drawableObjects = new List>(); protected HitRenderer(WorkingBeatmap beatmap) : base(beatmap) @@ -226,7 +226,7 @@ namespace osu.Game.Rulesets.UI private void loadObjects() { - drawableObjects = new List>(Beatmap.HitObjects.Count); + drawableObjects.Capacity = Beatmap.HitObjects.Count; foreach (TObject h in Beatmap.HitObjects) { From 3118dad52b2aa7173f10858f201dd9cea9e42733 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 11 May 2017 15:05:21 +0900 Subject: [PATCH 147/329] Subtract out playfield/hitrenderer/drawablehitobject changes. --- .../Objects/Drawables/DrawableHitObject.cs | 23 +++++-------------- osu.Game/Rulesets/UI/HitRenderer.cs | 11 +++------ osu.Game/Rulesets/UI/Playfield.cs | 2 +- 3 files changed, 10 insertions(+), 26 deletions(-) diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs index 8e153415c7..a300eeab31 100644 --- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs @@ -12,7 +12,6 @@ using Container = osu.Framework.Graphics.Containers.Container; using osu.Game.Rulesets.Objects.Types; using OpenTK.Graphics; using osu.Game.Audio; -using System.Linq; namespace osu.Game.Rulesets.Objects.Drawables { @@ -25,11 +24,6 @@ namespace osu.Game.Rulesets.Objects.Drawables public TJudgement Judgement; - /// - /// Whether this hit object has been judged. - /// - public virtual bool Judged => (Judgement?.Result ?? HitResult.None) != HitResult.None; - protected abstract TJudgement CreateJudgement(); protected abstract void UpdateState(ArmedState state); @@ -55,10 +49,6 @@ namespace osu.Game.Rulesets.Objects.Drawables } } - internal DrawableHitObject() - { - } - protected List Samples = new List(); protected void PlaySamples() @@ -94,12 +84,7 @@ namespace osu.Game.Rulesets.Objects.Drawables /// /// The colour used for various elements of this DrawableHitObject. /// - public virtual Color4 AccentColour { get; set; } - - /// - /// Whether this hit object and all of its nested hit objects have been judged. - /// - public sealed override bool Judged => base.Judged && NestedHitObjects.All(h => h.Judged); + public Color4 AccentColour { get; protected set; } protected DrawableHitObject(TObject hitObject) { @@ -183,11 +168,15 @@ namespace osu.Game.Rulesets.Objects.Drawables } } - private readonly List> nestedHitObjects = new List>(); + private List> nestedHitObjects; + protected IEnumerable> NestedHitObjects => nestedHitObjects; protected void AddNested(DrawableHitObject h) { + if (nestedHitObjects == null) + nestedHitObjects = new List>(); + h.OnJudgement += d => OnJudgement?.Invoke(d); nestedHitObjects.Add(h); } diff --git a/osu.Game/Rulesets/UI/HitRenderer.cs b/osu.Game/Rulesets/UI/HitRenderer.cs index 52b7a2766a..8ee67df95a 100644 --- a/osu.Game/Rulesets/UI/HitRenderer.cs +++ b/osu.Game/Rulesets/UI/HitRenderer.cs @@ -187,19 +187,17 @@ namespace osu.Game.Rulesets.UI public sealed override bool ProvidingUserCursor => !HasReplayLoaded && Playfield.ProvidingUserCursor; - public override IEnumerable Objects => Beatmap.HitObjects; - - protected override bool AllObjectsJudged => drawableObjects.All(o => o.Judged); + protected override Container Content => content; + protected override bool AllObjectsJudged => Playfield.HitObjects.Children.All(h => h.Judgement.Result != HitResult.None); /// /// The playfield. /// protected Playfield Playfield; - protected override Container Content => content; private readonly Container content; - private readonly List> drawableObjects = new List>(); + public override IEnumerable Objects => Beatmap.HitObjects; protected HitRenderer(WorkingBeatmap beatmap) : base(beatmap) @@ -226,8 +224,6 @@ namespace osu.Game.Rulesets.UI private void loadObjects() { - drawableObjects.Clear(); - foreach (TObject h in Beatmap.HitObjects) { var drawableObject = GetVisualRepresentation(h); @@ -237,7 +233,6 @@ namespace osu.Game.Rulesets.UI drawableObject.OnJudgement += onJudgement; - drawableObjects.Add(drawableObject); Playfield.Add(drawableObject); } diff --git a/osu.Game/Rulesets/UI/Playfield.cs b/osu.Game/Rulesets/UI/Playfield.cs index 612569a9ae..0586c0385a 100644 --- a/osu.Game/Rulesets/UI/Playfield.cs +++ b/osu.Game/Rulesets/UI/Playfield.cs @@ -19,7 +19,7 @@ namespace osu.Game.Rulesets.UI /// /// The HitObjects contained in this Playfield. /// - protected HitObjectContainer> HitObjects; + public HitObjectContainer> HitObjects; internal Container ScaledContent; From ec67b617aea07053a8cecd7fd0e3140dfe065a7f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 11 May 2017 14:55:25 +0900 Subject: [PATCH 148/329] Add OptionsHeader class Makes search textbox anchor correctly. Also improves visual styling. --- osu.Game/Overlays/Options/OptionsHeader.cs | 108 +++++++++++++++++++++ osu.Game/Overlays/OptionsOverlay.cs | 72 ++++++-------- osu.Game/osu.Game.csproj | 1 + 3 files changed, 137 insertions(+), 44 deletions(-) create mode 100644 osu.Game/Overlays/Options/OptionsHeader.cs diff --git a/osu.Game/Overlays/Options/OptionsHeader.cs b/osu.Game/Overlays/Options/OptionsHeader.cs new file mode 100644 index 0000000000..1add9dc409 --- /dev/null +++ b/osu.Game/Overlays/Options/OptionsHeader.cs @@ -0,0 +1,108 @@ +// 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.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Primitives; +using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Game.Screens.Select; +using OpenTK.Graphics; + +namespace osu.Game.Overlays.Options +{ + public class OptionsHeader : Container + { + public SearchTextBox SearchTextBox; + + private Box background; + + private readonly Func currentScrollOffset; + + public Action Exit; + + /// A reference to the current scroll position of the ScrollContainer we are contained within. + public OptionsHeader(Func currentScrollOffset) + { + this.currentScrollOffset = currentScrollOffset; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + + Children = new Drawable[] + { + background = new Box + { + Colour = Color4.Black, + RelativeSizeAxes = Axes.Both, + }, + new FillFlowContainer + { + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + Direction = FillDirection.Vertical, + Children = new Drawable[] + { + new OsuSpriteText + { + Text = "settings", + TextSize = 40, + Margin = new MarginPadding { + Left = OptionsOverlay.CONTENT_MARGINS, + Top = Toolbar.Toolbar.TOOLTIP_HEIGHT + }, + }, + new OsuSpriteText + { + Colour = colours.Pink, + Text = "Change the way osu! behaves", + TextSize = 18, + Margin = new MarginPadding { + Left = OptionsOverlay.CONTENT_MARGINS, + Bottom = 30 + }, + }, + SearchTextBox = new SearchTextBox + { + RelativeSizeAxes = Axes.X, + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + Width = 0.95f, + Margin = new MarginPadding { + Top = 20, + Bottom = 20 + }, + Exit = () => Exit(), + }, + } + } + }; + } + + protected override void UpdateAfterChildren() + { + base.UpdateAfterChildren(); + + // the point at which we will start anchoring to the top. + float anchorOffset = SearchTextBox.Y; + + float scrollPosition = currentScrollOffset(); + + // we want to anchor the search field to the top of the screen when scrolling. + Margin = new MarginPadding { Top = Math.Max(0, scrollPosition - anchorOffset) }; + + // we don't want the header to scroll when scrolling beyond the upper extent. + Y = Math.Min(0, scrollPosition); + + // we get darker as scroll progresses + background.Alpha = Math.Min(1, scrollPosition / anchorOffset) * 0.5f; + } + } +} \ No newline at end of file diff --git a/osu.Game/Overlays/OptionsOverlay.cs b/osu.Game/Overlays/OptionsOverlay.cs index 1176e91a36..6d1a3a64fc 100644 --- a/osu.Game/Overlays/OptionsOverlay.cs +++ b/osu.Game/Overlays/OptionsOverlay.cs @@ -10,10 +10,7 @@ using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Game.Overlays.Options; using System; -using osu.Game.Graphics; -using osu.Game.Graphics.Sprites; using osu.Game.Overlays.Options.Sections; -using osu.Game.Screens.Select; using osu.Framework.Input; namespace osu.Game.Overlays @@ -35,8 +32,11 @@ namespace osu.Game.Overlays private SidebarButton[] sidebarButtons; private OptionsSection[] sections; + private OptionsHeader header; + + private OptionsFooter footer; + private SearchContainer searchContainer; - private SearchTextBox searchTextBox; private float lastKnownScroll; @@ -47,7 +47,7 @@ namespace osu.Game.Overlays } [BackgroundDependencyLoader(permitNulls: true)] - private void load(OsuGame game, OsuColour colours) + private void load(OsuGame game) { sections = new OptionsSection[] { @@ -75,45 +75,20 @@ namespace osu.Game.Overlays RelativeSizeAxes = Axes.Y, Width = width, Margin = new MarginPadding { Left = SIDEBAR_WIDTH }, - Children = new[] + Children = new Drawable[] { - new FillFlowContainer + searchContainer = new SearchContainer { AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, Direction = FillDirection.Vertical, - - Children = new Drawable[] - { - new OsuSpriteText - { - Text = "settings", - TextSize = 40, - Margin = new MarginPadding { Left = CONTENT_MARGINS, Top = Toolbar.Toolbar.TOOLTIP_HEIGHT }, - }, - new OsuSpriteText - { - Colour = colours.Pink, - Text = "Change the way osu! behaves", - TextSize = 18, - Margin = new MarginPadding { Left = CONTENT_MARGINS, Bottom = 30 }, - }, - searchTextBox = new SearchTextBox - { - Width = width - CONTENT_MARGINS * 2, - Margin = new MarginPadding { Left = CONTENT_MARGINS }, - Exit = () => Hide(), - }, - searchContainer = new SearchContainer - { - AutoSizeAxes = Axes.Y, - RelativeSizeAxes = Axes.X, - Direction = FillDirection.Vertical, - Children = sections, - }, - new OptionsFooter() - } - } + Children = sections, + }, + footer = new OptionsFooter(), + header = new OptionsHeader(() => scrollContainer.Current) + { + Exit = Hide, + }, } }, sidebar = new Sidebar @@ -130,11 +105,20 @@ namespace osu.Game.Overlays } }; - searchTextBox.Current.ValueChanged += newValue => searchContainer.SearchTerm = newValue; + header.SearchTextBox.Current.ValueChanged += newValue => searchContainer.SearchTerm = newValue; scrollContainer.Padding = new MarginPadding { Top = game?.Toolbar.DrawHeight ?? 0 }; } + protected override void UpdateAfterChildren() + { + base.UpdateAfterChildren(); + + //we need to update these manually because we can't put the OptionsHeader inside the SearchContainer (due to its anchoring). + searchContainer.Y = header.DrawHeight; + footer.Y = searchContainer.Y + searchContainer.DrawHeight; + } + protected override void Update() { base.Update(); @@ -172,7 +156,7 @@ namespace osu.Game.Overlays sidebar.MoveToX(0, TRANSITION_LENGTH, EasingTypes.OutQuint); FadeTo(1, TRANSITION_LENGTH / 2); - searchTextBox.HoldFocus = true; + header.SearchTextBox.HoldFocus = true; } protected override void PopOut() @@ -183,13 +167,13 @@ namespace osu.Game.Overlays sidebar.MoveToX(-SIDEBAR_WIDTH, TRANSITION_LENGTH, EasingTypes.OutQuint); FadeTo(0, TRANSITION_LENGTH / 2); - searchTextBox.HoldFocus = false; - searchTextBox.TriggerFocusLost(); + header.SearchTextBox.HoldFocus = false; + header.SearchTextBox.TriggerFocusLost(); } protected override bool OnFocus(InputState state) { - searchTextBox.TriggerFocus(state); + header.SearchTextBox.TriggerFocus(state); return false; } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index bd9f087cf7..904cf7f437 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -78,6 +78,7 @@ + From c0c33c09abbe851165eadca6ef962fcb9e5dd7a1 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 11 May 2017 15:40:51 +0900 Subject: [PATCH 149/329] Fix merge error. --- osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs index 45ef2553b5..f671e2af60 100644 --- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs @@ -90,7 +90,7 @@ namespace osu.Game.Rulesets.Objects.Drawables /// /// The colour used for various elements of this DrawableHitObject. /// - public Color4 AccentColour { get; protected set; } + public virtual Color4 AccentColour { get; set; } /// /// Whether this hit object and all of its nested hit objects have been judged. From 5f30a89f763f4289653a184f6d8ef35fe650d182 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 11 May 2017 16:09:48 +0900 Subject: [PATCH 150/329] General refactoring + renaming of TimingSectionContainer. --- .../Timing/DrawableTimingSection.cs | 27 ----- .../Timing/TimeRelativeContainer.cs | 102 ++++++++++++++++++ osu.Game.Rulesets.Mania/UI/Column.cs | 4 +- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 4 +- .../UI/TimingSectionContainer.cs | 36 ------- .../osu.Game.Rulesets.Mania.csproj | 2 +- 6 files changed, 107 insertions(+), 68 deletions(-) create mode 100644 osu.Game.Rulesets.Mania/Timing/TimeRelativeContainer.cs delete mode 100644 osu.Game.Rulesets.Mania/UI/TimingSectionContainer.cs diff --git a/osu.Game.Rulesets.Mania/Timing/DrawableTimingSection.cs b/osu.Game.Rulesets.Mania/Timing/DrawableTimingSection.cs index 2225a63cdf..0ffdb837f2 100644 --- a/osu.Game.Rulesets.Mania/Timing/DrawableTimingSection.cs +++ b/osu.Game.Rulesets.Mania/Timing/DrawableTimingSection.cs @@ -7,32 +7,5 @@ using osu.Framework.Graphics.Containers; namespace osu.Game.Rulesets.Mania.Timing { - /// - /// A container that contains hit objects within the time span of a timing section. - /// - public class DrawableTimingSection : Container - { - public readonly TimingSection TimingSection; - public DrawableTimingSection(TimingSection section) - { - TimingSection = section; - - Anchor = Anchor.BottomCentre; - Origin = Anchor.BottomCentre; - - RelativePositionAxes = Axes.Y; - Y = -(float)section.StartTime; - - RelativeSizeAxes = Axes.Both; - Height = (float)section.Duration; - - RelativeCoordinateSpace = new Vector2(1, Height); - } - - protected override void Update() - { - Y = (float)(Time.Current - TimingSection.StartTime); - } - } } \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/Timing/TimeRelativeContainer.cs b/osu.Game.Rulesets.Mania/Timing/TimeRelativeContainer.cs new file mode 100644 index 0000000000..d3fcb56174 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Timing/TimeRelativeContainer.cs @@ -0,0 +1,102 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using System.Linq; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using OpenTK; + +namespace osu.Game.Rulesets.Mania.Timing +{ + /// + /// A container in which the Y-relative coordinate space is spanned by a length of time. + /// + /// This container contains s which scroll inside this container. + /// Drawables added to this container are moved inside the relevant , + /// and as such, will scroll along with the s. + /// + /// + public class TimeRelativeContainer : Container + { + /// + /// The amount of time which the height of this container spans. + /// + public double TimeSpan + { + get { return RelativeCoordinateSpace.Y; } + set { RelativeCoordinateSpace = new Vector2(1, (float)value); } + } + + public TimeRelativeContainer(IEnumerable timingSections) + { + Children = timingSections.Select(t => new DrawableTimingSection(t)); + } + + /// + /// Adds a drawable to this container. Note that the drawable added must have a + /// Y-position as a time relative to this container. + /// + /// The drawable to add. + public override void Add(Drawable drawable) + { + // Always add timing sections to ourselves + if (drawable is DrawableTimingSection) + { + base.Add(drawable); + return; + } + + var section = (Children.LastOrDefault(t => t.Y >= drawable.Y) ?? Children.First()) as DrawableTimingSection; + + if (section == null) + throw new Exception("Could not find suitable timing section to add object to."); + + section.Add(drawable); + } + + /// + /// A container that contains drawables within the time span of a timing section. + /// + /// Scrolls relative to the current time. + /// + /// + private class DrawableTimingSection : Container + { + private readonly TimingSection section; + + public DrawableTimingSection(TimingSection section) + { + this.section = section; + + Anchor = Anchor.BottomCentre; + Origin = Anchor.BottomCentre; + + RelativePositionAxes = Axes.Y; + Y = -(float)section.StartTime; + + RelativeSizeAxes = Axes.Both; + Height = (float)section.Duration; + + RelativeCoordinateSpace = new Vector2(1, Height); + } + + protected override void Update() + { + Y = (float)(Time.Current - section.StartTime); + } + + public override void Add(Drawable drawable) + { + // The previously relatively-positioned drawable will now become relative to us, but since the drawable has no knowledge of us, + // we need to offset it back by our position so that it becomes correctly relatively-positioned to us + // This can be removed if hit objects were stored such that either their StartTime or their "beat offset" was relative to the timing section + // they belonged to, but this requires a radical change to the beatmap format which we're not ready to do just yet + drawable.Y -= Y; + + base.Add(drawable); + } + } + } +} \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/UI/Column.cs b/osu.Game.Rulesets.Mania/UI/Column.cs index 4f89d3b634..96f4b17ff8 100644 --- a/osu.Game.Rulesets.Mania/UI/Column.cs +++ b/osu.Game.Rulesets.Mania/UI/Column.cs @@ -38,7 +38,7 @@ namespace osu.Game.Rulesets.Mania.UI private readonly Container hitTargetBar; private readonly Container keyIcon; - public readonly TimingSectionContainer TimingSectionContainer; + public readonly TimeRelativeContainer TimingSectionContainer; public Column(IEnumerable timingSections) { @@ -87,7 +87,7 @@ namespace osu.Game.Rulesets.Mania.UI } } }, - TimingSectionContainer = new TimingSectionContainer(timingSections) + TimingSectionContainer = new TimeRelativeContainer(timingSections) { Name = "Hit objects", RelativeSizeAxes = Axes.Both, diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index 75c1140a9a..826f7262f6 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -55,7 +55,7 @@ namespace osu.Game.Rulesets.Mania.UI public readonly FlowContainer Columns; - private readonly TimingSectionContainer barlineContainer; + private readonly TimeRelativeContainer barlineContainer; private List normalColumnColours = new List(); private Color4 specialColumnColour; @@ -93,7 +93,7 @@ namespace osu.Game.Rulesets.Mania.UI Padding = new MarginPadding { Left = 1, Right = 1 }, Spacing = new Vector2(1, 0) }, - barlineContainer = new TimingSectionContainer(timingSections) + barlineContainer = new TimeRelativeContainer(timingSections) { Name = "Barlines", Anchor = Anchor.BottomCentre, diff --git a/osu.Game.Rulesets.Mania/UI/TimingSectionContainer.cs b/osu.Game.Rulesets.Mania/UI/TimingSectionContainer.cs deleted file mode 100644 index 9a63c17c59..0000000000 --- a/osu.Game.Rulesets.Mania/UI/TimingSectionContainer.cs +++ /dev/null @@ -1,36 +0,0 @@ -// 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 OpenTK; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Game.Rulesets.Mania.Timing; - -namespace osu.Game.Rulesets.Mania.UI -{ - public class TimingSectionContainer : Container - { - /// - /// The amount of time which the length of this container spans. - /// - public double TimeSpan - { - get { return RelativeCoordinateSpace.Y; } - set { RelativeCoordinateSpace = new Vector2(1, (float)value); } - } - - public TimingSectionContainer(IEnumerable timingSections) - { - Children = timingSections.Select(t => new DrawableTimingSection(t)); - } - - public void Add(Drawable drawable) - { - var section = Children.LastOrDefault(t => t.Y >= drawable.Y) ?? Children.First(); - drawable.Y -= section.Y; - section.Add(drawable); - } - } -} \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index e1d033c214..948f25a80b 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -70,7 +70,7 @@ - + From b0e522345cda92b51033c72d9aeeb29a017bc0c2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 11 May 2017 17:07:46 +0900 Subject: [PATCH 151/329] Combine DrawableHitObject classes into one --- .../Objects/Drawables/DrawableHitObject.cs | 43 +++++++------------ 1 file changed, 15 insertions(+), 28 deletions(-) diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs index 21eca346c4..5622df9d14 100644 --- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; @@ -15,9 +14,19 @@ using osu.Game.Audio; namespace osu.Game.Rulesets.Objects.Drawables { - public abstract class DrawableHitObject : Container, IStateful + public abstract class DrawableHitObject : Container + where TObject : HitObject where TJudgement : Judgement { + public event Action> OnJudgement; + + public TObject HitObject; + + /// + /// The colour used for various elements of this DrawableHitObject. + /// + public virtual Color4 AccentColour { get; set; } + public override bool HandleInput => Interactive; public bool Interactive = true; @@ -49,10 +58,6 @@ namespace osu.Game.Rulesets.Objects.Drawables } } - internal DrawableHitObject() - { - } - protected List Samples = new List(); protected void PlaySamples() @@ -60,14 +65,6 @@ namespace osu.Game.Rulesets.Objects.Drawables Samples.ForEach(s => s?.Play()); } - [BackgroundDependencyLoader] - private void load() - { - //we may be setting a custom judgement in test cases or what not. - if (Judgement == null) - Judgement = CreateJudgement(); - } - protected override void LoadComplete() { base.LoadComplete(); @@ -75,20 +72,6 @@ namespace osu.Game.Rulesets.Objects.Drawables //force application of the state that was set before we loaded. UpdateState(State); } - } - - public abstract class DrawableHitObject : DrawableHitObject - where TObject : HitObject - where TJudgement : Judgement - { - public event Action> OnJudgement; - - public TObject HitObject; - - /// - /// The colour used for various elements of this DrawableHitObject. - /// - public virtual Color4 AccentColour { get; set; } protected DrawableHitObject(TObject hitObject) { @@ -170,6 +153,10 @@ namespace osu.Game.Rulesets.Objects.Drawables channel.Volume.Value = sample.Volume; Samples.Add(channel); } + + //we may be setting a custom judgement in test cases or what not. + if (Judgement == null) + Judgement = CreateJudgement(); } private List> nestedHitObjects; From 6fd95e0c5286ff4a1f6ac8321b43ba088bcd975c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 11 May 2017 17:16:01 +0900 Subject: [PATCH 152/329] Fix post-merge breakage --- osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs index 07be689446..c5dbc27fd3 100644 --- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs @@ -34,11 +34,6 @@ namespace osu.Game.Rulesets.Objects.Drawables public TJudgement Judgement; - /// - /// Whether this hit object has been judged. - /// - public virtual bool Judged => (Judgement?.Result ?? HitResult.None) != HitResult.None; - protected abstract TJudgement CreateJudgement(); protected abstract void UpdateState(ArmedState state); @@ -82,7 +77,7 @@ namespace osu.Game.Rulesets.Objects.Drawables /// /// Whether this hit object and all of its nested hit objects have been judged. /// - public sealed override bool Judged => base.Judged && (NestedHitObjects?.All(h => h.Judged) ?? true); + public bool Judged => (Judgement?.Result ?? HitResult.None) != HitResult.None && (NestedHitObjects?.All(h => h.Judged) ?? true); protected DrawableHitObject(TObject hitObject) { From 6cc54773e8493b20607a7aa9576a475b2dafc17c Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 11 May 2017 17:18:22 +0900 Subject: [PATCH 153/329] Fix taiko right background not scaling with the playfield as intended. --- osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs | 42 ++++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs index 8e6f1c8556..23c7606a15 100644 --- a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs +++ b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs @@ -54,33 +54,33 @@ namespace osu.Game.Rulesets.Taiko.UI { AddInternal(new Drawable[] { - rightBackgroundContainer = new Container - { - Name = "Transparent playfield background", - RelativeSizeAxes = Axes.Both, - BorderThickness = 2, - Masking = true, - EdgeEffect = new EdgeEffect - { - Type = EdgeEffectType.Shadow, - Colour = Color4.Black.Opacity(0.2f), - Radius = 5, - }, - Children = new Drawable[] - { - rightBackground = new Box - { - RelativeSizeAxes = Axes.Both, - Alpha = 0.6f - }, - } - }, new ScaleFixContainer { RelativeSizeAxes = Axes.X, Height = DEFAULT_PLAYFIELD_HEIGHT, Children = new[] { + rightBackgroundContainer = new Container + { + Name = "Transparent playfield background", + RelativeSizeAxes = Axes.Both, + BorderThickness = 2, + Masking = true, + EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Shadow, + Colour = Color4.Black.Opacity(0.2f), + Radius = 5, + }, + Children = new Drawable[] + { + rightBackground = new Box + { + RelativeSizeAxes = Axes.Both, + Alpha = 0.6f + }, + } + }, new Container { Name = "Transparent playfield elements", From 5dd83067ee7f7bd39f21b67bded173f6a0cc5bc5 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 11 May 2017 17:41:00 +0900 Subject: [PATCH 154/329] Fix line endings. --- .../Timing/TimeRelativeContainer.cs | 100 +++++++++--------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Timing/TimeRelativeContainer.cs b/osu.Game.Rulesets.Mania/Timing/TimeRelativeContainer.cs index d3fcb56174..d4705c2352 100644 --- a/osu.Game.Rulesets.Mania/Timing/TimeRelativeContainer.cs +++ b/osu.Game.Rulesets.Mania/Timing/TimeRelativeContainer.cs @@ -1,67 +1,67 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using System; -using System.Collections.Generic; -using System.Linq; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using OpenTK; - -namespace osu.Game.Rulesets.Mania.Timing +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using System.Linq; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using OpenTK; + +namespace osu.Game.Rulesets.Mania.Timing { /// - /// A container in which the Y-relative coordinate space is spanned by a length of time. - /// - /// This container contains s which scroll inside this container. + /// A container in which the Y-relative coordinate space is spanned by a length of time. + /// + /// This container contains s which scroll inside this container. /// Drawables added to this container are moved inside the relevant , - /// and as such, will scroll along with the s. + /// and as such, will scroll along with the s. /// /// public class TimeRelativeContainer : Container - { - /// - /// The amount of time which the height of this container spans. - /// - public double TimeSpan - { - get { return RelativeCoordinateSpace.Y; } - set { RelativeCoordinateSpace = new Vector2(1, (float)value); } - } - - public TimeRelativeContainer(IEnumerable timingSections) + { + /// + /// The amount of time which the height of this container spans. + /// + public double TimeSpan { - Children = timingSections.Select(t => new DrawableTimingSection(t)); + get { return RelativeCoordinateSpace.Y; } + set { RelativeCoordinateSpace = new Vector2(1, (float)value); } } - /// - /// Adds a drawable to this container. Note that the drawable added must have a - /// Y-position as a time relative to this container. - /// - /// The drawable to add. - public override void Add(Drawable drawable) + public TimeRelativeContainer(IEnumerable timingSections) + { + Children = timingSections.Select(t => new DrawableTimingSection(t)); + } + + /// + /// Adds a drawable to this container. Note that the drawable added must have a + /// Y-position as a time relative to this container. + /// + /// The drawable to add. + public override void Add(Drawable drawable) { // Always add timing sections to ourselves - if (drawable is DrawableTimingSection) - { + if (drawable is DrawableTimingSection) + { base.Add(drawable); - return; + return; } - - var section = (Children.LastOrDefault(t => t.Y >= drawable.Y) ?? Children.First()) as DrawableTimingSection; - - if (section == null) + + var section = (Children.LastOrDefault(t => t.Y >= drawable.Y) ?? Children.First()) as DrawableTimingSection; + + if (section == null) throw new Exception("Could not find suitable timing section to add object to."); - - section.Add(drawable); + + section.Add(drawable); } - /// + /// /// A container that contains drawables within the time span of a timing section. /// /// Scrolls relative to the current time. - /// - /// + /// + /// private class DrawableTimingSection : Container { private readonly TimingSection section; @@ -93,10 +93,10 @@ namespace osu.Game.Rulesets.Mania.Timing // we need to offset it back by our position so that it becomes correctly relatively-positioned to us // This can be removed if hit objects were stored such that either their StartTime or their "beat offset" was relative to the timing section // they belonged to, but this requires a radical change to the beatmap format which we're not ready to do just yet - drawable.Y -= Y; - - base.Add(drawable); + drawable.Y -= Y; + + base.Add(drawable); } - } - } + } + } } \ No newline at end of file From a2f6d8a3e68a2c7b4c014d80e3c5e282cd231c29 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 11 May 2017 18:14:48 +0900 Subject: [PATCH 155/329] Fix broken test cases, remove some recursive lookup methods. --- osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs | 2 +- osu.Game/Database/BeatmapDatabase.cs | 3 +++ osu.Game/Database/Database.cs | 8 +++----- osu.Game/Screens/Menu/MainMenu.cs | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs index e259f700b1..0e456941a1 100644 --- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs @@ -142,7 +142,7 @@ namespace osu.Game.Tests.Beatmaps.IO Assert.IsTrue(waitAction.BeginInvoke(null, null).AsyncWaitHandle.WaitOne(timeout), @"Beatmaps did not import to the database in allocated time"); - var set = host.Dependencies.Get().GetChildren(resultSets.First(), true); + var set = host.Dependencies.Get().GetChildren(resultSets.First()); Assert.IsTrue(set.Beatmaps.Count == resultBeatmaps.Count(), $@"Incorrect database beatmap count post-import ({resultBeatmaps.Count()} but should be {set.Beatmaps.Count})."); diff --git a/osu.Game/Database/BeatmapDatabase.cs b/osu.Game/Database/BeatmapDatabase.cs index 760b7ae353..de570d3e7e 100644 --- a/osu.Game/Database/BeatmapDatabase.cs +++ b/osu.Game/Database/BeatmapDatabase.cs @@ -267,6 +267,9 @@ namespace osu.Game.Database public WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo, WorkingBeatmap previous = null, bool withStoryboard = false) { + if (beatmapInfo.BeatmapSet == null) + beatmapInfo = GetChildren(beatmapInfo, true); + if (beatmapInfo.BeatmapSet == null) throw new InvalidOperationException($@"Beatmap set {beatmapInfo.BeatmapSetInfoID} is not in the local database."); diff --git a/osu.Game/Database/Database.cs b/osu.Game/Database/Database.cs index 9b49583875..a55c0f570b 100644 --- a/osu.Game/Database/Database.cs +++ b/osu.Game/Database/Database.cs @@ -48,11 +48,9 @@ namespace osu.Game.Database return Connection.Table(); } - public T GetWithChildren(object id, bool recursive = false) where T : class - { - return Connection.GetWithChildren(id, recursive); - } - + /// + /// This is expensive. Use with caution. + /// public List GetAllWithChildren(Expression> filter = null, bool recursive = true) where T : class { diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index f8b8882d3d..c8a00e0671 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -79,7 +79,7 @@ namespace osu.Game.Screens.Menu if (count > 0) { var beatmap = query.ElementAt(RNG.Next(0, count - 1)); - beatmaps.GetChildren(beatmap, true); + beatmaps.GetChildren(beatmap); Beatmap = beatmaps.GetWorkingBeatmap(beatmap.Beatmaps[0]); } } From b258109a9ee1c9e98299a0543a7e99bfec18d2fe Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 11 May 2017 18:27:14 +0900 Subject: [PATCH 156/329] Fix chat input box not always keeping focus as expected --- osu.Game/Overlays/ChatOverlay.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index 457611dfab..dc586bd363 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -110,12 +110,18 @@ namespace osu.Game.Overlays { MoveToY(0, transition_length, EasingTypes.OutQuint); FadeIn(transition_length, EasingTypes.OutQuint); + + inputTextBox.HoldFocus = true; + base.PopIn(); } protected override void PopOut() { MoveToY(DrawSize.Y, transition_length, EasingTypes.InSine); FadeOut(transition_length, EasingTypes.InSine); + + inputTextBox.HoldFocus = false; + base.PopOut(); } [BackgroundDependencyLoader] From 7d221802a2fa0dc81f78204c644a6b861f23c746 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 11 May 2017 19:27:02 +0900 Subject: [PATCH 157/329] Fix refresh tokens not working correctly Turns out there's plenty of slashes in refresh tokens. --- osu.Game/Online/API/OAuthToken.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Online/API/OAuthToken.cs b/osu.Game/Online/API/OAuthToken.cs index 4085e5602a..328888ab8a 100644 --- a/osu.Game/Online/API/OAuthToken.cs +++ b/osu.Game/Online/API/OAuthToken.cs @@ -41,13 +41,13 @@ namespace osu.Game.Online.API [JsonProperty(@"refresh_token")] public string RefreshToken; - public override string ToString() => $@"{AccessToken}/{AccessTokenExpiry.ToString(NumberFormatInfo.InvariantInfo)}/{RefreshToken}"; + public override string ToString() => $@"{AccessToken}|{AccessTokenExpiry.ToString(NumberFormatInfo.InvariantInfo)}|{RefreshToken}"; public static OAuthToken Parse(string value) { try { - string[] parts = value.Split('/'); + string[] parts = value.Split('|'); return new OAuthToken { AccessToken = parts[0], From 4e881644f60995a90325d99f77d00a99fad354a9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 11 May 2017 19:35:07 +0900 Subject: [PATCH 158/329] Add thread-safety on access token validation logic. --- osu.Game/Online/API/OAuth.cs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/osu.Game/Online/API/OAuth.cs b/osu.Game/Online/API/OAuth.cs index 0ee7e0e030..2f841b67b1 100644 --- a/osu.Game/Online/API/OAuth.cs +++ b/osu.Game/Online/API/OAuth.cs @@ -72,21 +72,28 @@ namespace osu.Game.Online.API } } + private static readonly object access_token_retrieval_lock = new object(); + /// /// Should be run before any API request to make sure we have a valid key. /// private bool ensureAccessToken() { - //todo: we need to mutex this to ensure only one authentication request is running at a time. - - //If we already have a valid access token, let's use it. + // if we already have a valid access token, let's use it. if (accessTokenValid) return true; - //If not, let's try using our refresh token to request a new access token. - if (!string.IsNullOrEmpty(Token?.RefreshToken)) - AuthenticateWithRefresh(Token.RefreshToken); + // we want to ensure only a single authentication update is happening at once. + lock (access_token_retrieval_lock) + { + // re-check if valid, in case another requrest completed and revalidated our access. + if (accessTokenValid) return true; - return accessTokenValid; + // if not, let's try using our refresh token to request a new access token. + if (!string.IsNullOrEmpty(Token?.RefreshToken)) + AuthenticateWithRefresh(Token.RefreshToken); + + return accessTokenValid; + } } private bool accessTokenValid => Token?.IsValid ?? false; From c3d2cdd2f2ab15c353a08f403fc1a55de06a71f6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 11 May 2017 19:49:28 +0900 Subject: [PATCH 159/329] Fix typo --- osu.Game/Online/API/OAuth.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Online/API/OAuth.cs b/osu.Game/Online/API/OAuth.cs index 2f841b67b1..c96b21a855 100644 --- a/osu.Game/Online/API/OAuth.cs +++ b/osu.Game/Online/API/OAuth.cs @@ -85,7 +85,7 @@ namespace osu.Game.Online.API // we want to ensure only a single authentication update is happening at once. lock (access_token_retrieval_lock) { - // re-check if valid, in case another requrest completed and revalidated our access. + // re-check if valid, in case another request completed and revalidated our access. if (accessTokenValid) return true; // if not, let's try using our refresh token to request a new access token. From 6a79c8b66c2595b0a1d5a3766e0ea2bff21db035 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 11 May 2017 19:57:24 +0900 Subject: [PATCH 160/329] Make notes scroll with beat length. --- .../Timing/TimeRelativeContainer.cs | 53 +++++++++++++++---- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 6 +-- 2 files changed, 46 insertions(+), 13 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Timing/TimeRelativeContainer.cs b/osu.Game.Rulesets.Mania/Timing/TimeRelativeContainer.cs index d4705c2352..06e7cd1f53 100644 --- a/osu.Game.Rulesets.Mania/Timing/TimeRelativeContainer.cs +++ b/osu.Game.Rulesets.Mania/Timing/TimeRelativeContainer.cs @@ -29,9 +29,13 @@ namespace osu.Game.Rulesets.Mania.Timing set { RelativeCoordinateSpace = new Vector2(1, (float)value); } } + private readonly List drawableTimingSections; + public TimeRelativeContainer(IEnumerable timingSections) { - Children = timingSections.Select(t => new DrawableTimingSection(t)); + drawableTimingSections = timingSections.Select(t => new DrawableTimingSection(t)).ToList(); + + Children = drawableTimingSections; } /// @@ -48,7 +52,7 @@ namespace osu.Game.Rulesets.Mania.Timing return; } - var section = (Children.LastOrDefault(t => t.Y >= drawable.Y) ?? Children.First()) as DrawableTimingSection; + var section = drawableTimingSections.LastOrDefault(t => t.CanContain(drawable)) ?? drawableTimingSections.First(); if (section == null) throw new Exception("Could not find suitable timing section to add object to."); @@ -59,13 +63,28 @@ namespace osu.Game.Rulesets.Mania.Timing /// /// A container that contains drawables within the time span of a timing section. /// - /// Scrolls relative to the current time. + /// The content of this container will scroll relative to the current time. /// /// private class DrawableTimingSection : Container { + protected override Container Content => content; + /// + /// The container which will scroll relative to the current time. + /// + private readonly Container content; + private readonly TimingSection section; + /// + /// Creates a drawable timing section. The height of this container will be proportional + /// to the beat length of the timing section and the timespan of its parent at all times. + /// + /// This is so that, e.g. a beat length of 500ms results in this container being twice as high as its parent, + /// which means that the content container will scroll at twice the normal rate. + /// + /// + /// The section to create the drawable timing section for. public DrawableTimingSection(TimingSection section) { this.section = section; @@ -73,18 +92,30 @@ namespace osu.Game.Rulesets.Mania.Timing Anchor = Anchor.BottomCentre; Origin = Anchor.BottomCentre; - RelativePositionAxes = Axes.Y; - Y = -(float)section.StartTime; - RelativeSizeAxes = Axes.Both; - Height = (float)section.Duration; - RelativeCoordinateSpace = new Vector2(1, Height); + AddInternal(content = new Container + { + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + RelativePositionAxes = Axes.Both, + RelativeSizeAxes = Axes.Both, + Y = -(float)section.StartTime, + Height = (float)section.Duration, + RelativeCoordinateSpace = new Vector2(1, (float)section.Duration) + }); } protected override void Update() { - Y = (float)(Time.Current - section.StartTime); + var parent = (TimeRelativeContainer)Parent; + + // Adjust our height to account for the speed changes + Height = (float)(parent.TimeSpan * 1000 / section.BeatLength); + RelativeCoordinateSpace = new Vector2(1, (float)parent.TimeSpan); + + // Scroll the content + content.Y = (float)(Time.Current - section.StartTime); } public override void Add(Drawable drawable) @@ -93,10 +124,12 @@ namespace osu.Game.Rulesets.Mania.Timing // we need to offset it back by our position so that it becomes correctly relatively-positioned to us // This can be removed if hit objects were stored such that either their StartTime or their "beat offset" was relative to the timing section // they belonged to, but this requires a radical change to the beatmap format which we're not ready to do just yet - drawable.Y -= Y; + drawable.Y += (float)section.StartTime; base.Add(drawable); } + + public bool CanContain(Drawable drawable) => content.Y >= drawable.Y; } } } \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index 826f7262f6..7636e41099 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -27,10 +27,10 @@ namespace osu.Game.Rulesets.Mania.UI { public const float HIT_TARGET_POSITION = 50; - private const float time_span_default = 500; + private const float time_span_default = 20000; private const float time_span_min = 10; - private const float time_span_max = 20000; - private const float time_span_step = 100; + private const float time_span_max = 50000; + private const float time_span_step = 1000; /// /// Default column keys, expanding outwards from the middle as more column are added. From ee219c18db8afdc382cf83a5b585fcbbbafed19a Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 11 May 2017 20:04:28 +0900 Subject: [PATCH 161/329] Make the playfield mask for now. --- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index 7636e41099..a3b1a49c9c 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -77,6 +77,7 @@ namespace osu.Game.Rulesets.Mania.UI Origin = Anchor.BottomCentre, RelativeSizeAxes = Axes.Y, AutoSizeAxes = Axes.X, + Masking = true, Children = new Drawable[] { new Box From 0739a764974d999e07bf261a2d544e477c35bba4 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 11 May 2017 20:04:45 +0900 Subject: [PATCH 162/329] Make the playfield work in TestCaseGamefield. --- osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs | 12 ++++++++++-- .../Timing/TimeRelativeContainer.cs | 2 +- osu.Game/Beatmaps/Timing/ControlPoint.cs | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs b/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs index cb15558ec3..1049a8818a 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs @@ -18,6 +18,7 @@ using osu.Game.Rulesets.Taiko.UI; using System.Collections.Generic; using osu.Desktop.VisualTests.Beatmaps; using osu.Framework.Allocation; +using osu.Game.Beatmaps.Timing; namespace osu.Desktop.VisualTests.Tests { @@ -52,6 +53,12 @@ namespace osu.Desktop.VisualTests.Tests time += RNG.Next(50, 500); } + TimingInfo timing = new TimingInfo(); + timing.ControlPoints.Add(new ControlPoint + { + BeatLength = 200 + }); + WorkingBeatmap beatmap = new TestWorkingBeatmap(new Beatmap { HitObjects = objects, @@ -64,8 +71,9 @@ namespace osu.Desktop.VisualTests.Tests Artist = @"Unknown", Title = @"Sample Beatmap", Author = @"peppy", - } - } + }, + }, + TimingInfo = timing }); Add(new Drawable[] diff --git a/osu.Game.Rulesets.Mania/Timing/TimeRelativeContainer.cs b/osu.Game.Rulesets.Mania/Timing/TimeRelativeContainer.cs index 06e7cd1f53..466639fc02 100644 --- a/osu.Game.Rulesets.Mania/Timing/TimeRelativeContainer.cs +++ b/osu.Game.Rulesets.Mania/Timing/TimeRelativeContainer.cs @@ -52,7 +52,7 @@ namespace osu.Game.Rulesets.Mania.Timing return; } - var section = drawableTimingSections.LastOrDefault(t => t.CanContain(drawable)) ?? drawableTimingSections.First(); + var section = drawableTimingSections.LastOrDefault(t => t.CanContain(drawable)) ?? drawableTimingSections.FirstOrDefault(); if (section == null) throw new Exception("Could not find suitable timing section to add object to."); diff --git a/osu.Game/Beatmaps/Timing/ControlPoint.cs b/osu.Game/Beatmaps/Timing/ControlPoint.cs index ea152ccb39..fbae7d9614 100644 --- a/osu.Game/Beatmaps/Timing/ControlPoint.cs +++ b/osu.Game/Beatmaps/Timing/ControlPoint.cs @@ -7,7 +7,7 @@ namespace osu.Game.Beatmaps.Timing { public string SampleBank; public int SampleVolume; - public TimeSignatures TimeSignature; + public TimeSignatures TimeSignature = TimeSignatures.SimpleQuadruple; public double Time; public double BeatLength = 500; public double SpeedMultiplier = 1; From f764ed89037b05eef9ed0e8801d18561ad2296b5 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 11 May 2017 20:05:11 +0900 Subject: [PATCH 163/329] Remove unused class. --- .../Timing/DrawableTimingSection.cs | 11 ----------- .../osu.Game.Rulesets.Mania.csproj | 1 - 2 files changed, 12 deletions(-) delete mode 100644 osu.Game.Rulesets.Mania/Timing/DrawableTimingSection.cs diff --git a/osu.Game.Rulesets.Mania/Timing/DrawableTimingSection.cs b/osu.Game.Rulesets.Mania/Timing/DrawableTimingSection.cs deleted file mode 100644 index 0ffdb837f2..0000000000 --- a/osu.Game.Rulesets.Mania/Timing/DrawableTimingSection.cs +++ /dev/null @@ -1,11 +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.Framework.Graphics.Containers; - -namespace osu.Game.Rulesets.Mania.Timing -{ - -} \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index 948f25a80b..7ee397e0ea 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -59,7 +59,6 @@ - From 9a1c662d1fb2e767f4118716ff348a1bccc4e208 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 11 May 2017 21:12:13 +0900 Subject: [PATCH 164/329] Update framework --- osu-framework | 2 +- osu.Game/Input/GlobalHotkeys.cs | 26 -------------------------- osu.Game/OsuGame.cs | 1 - osu.Game/osu.Game.csproj | 1 - 4 files changed, 1 insertion(+), 29 deletions(-) delete mode 100644 osu.Game/Input/GlobalHotkeys.cs diff --git a/osu-framework b/osu-framework index a1a62c14a5..682f078b2e 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit a1a62c14a51654c933c5b077c725d566f167145b +Subproject commit 682f078b2efc82fa19342f499f14c4a8458843d5 diff --git a/osu.Game/Input/GlobalHotkeys.cs b/osu.Game/Input/GlobalHotkeys.cs deleted file mode 100644 index b1b22f7069..0000000000 --- a/osu.Game/Input/GlobalHotkeys.cs +++ /dev/null @@ -1,26 +0,0 @@ -// 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.Input; - -namespace osu.Game.Input -{ - public class GlobalHotkeys : Drawable - { - public Func Handler; - - public override bool HandleInput => true; - - public GlobalHotkeys() - { - RelativeSizeAxes = Axes.Both; - } - - protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) - { - return Handler(state, args); - } - } -} \ No newline at end of file diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index c9f41de5f2..ccead95ede 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -9,7 +9,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Overlays; using osu.Framework.Input; -using osu.Game.Input; using OpenTK.Input; using osu.Framework.Logging; using osu.Game.Graphics.UserInterface.Volume; diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index bd9f087cf7..fd15115fe2 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -284,7 +284,6 @@ - From 7b49ed141940128d33934d4f7100aeda830b630d Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 11 May 2017 21:57:28 +0900 Subject: [PATCH 165/329] Fix up todo. --- osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs index 6a047b4997..79fb6f8615 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs @@ -45,8 +45,7 @@ namespace osu.Game.Rulesets.Mania.UI timingSections.Add(new TimingSection { StartTime = point.Time, - // Todo: Should this be dividing by beatlength? - BeatLength = point.SpeedMultiplier * lastTimingChange.BeatLength, + BeatLength = lastTimingChange.BeatLength / point.SpeedMultiplier, TimeSignature = point.TimeSignature }); } From d57bb7e5fda5f5eeb790a04f37114451fb64917f Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 11 May 2017 22:01:37 +0900 Subject: [PATCH 166/329] General cleanups. --- .../Timing/TimeRelativeContainer.cs | 5 +++ .../Timing/TimingSection.cs | 43 +++++++++++++------ osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 2 +- 3 files changed, 35 insertions(+), 15 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Timing/TimeRelativeContainer.cs b/osu.Game.Rulesets.Mania/Timing/TimeRelativeContainer.cs index 466639fc02..c5060eabbb 100644 --- a/osu.Game.Rulesets.Mania/Timing/TimeRelativeContainer.cs +++ b/osu.Game.Rulesets.Mania/Timing/TimeRelativeContainer.cs @@ -129,6 +129,11 @@ namespace osu.Game.Rulesets.Mania.Timing base.Add(drawable); } + /// + /// Whether this timing section can contain a drawable. A timing section can contain a drawable if the drawable + /// can be placed within the timing section's bounds (in this case, from the start of the timing section up to infinity). + /// + /// The drawable to check. public bool CanContain(Drawable drawable) => content.Y >= drawable.Y; } } diff --git a/osu.Game.Rulesets.Mania/Timing/TimingSection.cs b/osu.Game.Rulesets.Mania/Timing/TimingSection.cs index fdc367de11..65a2094c46 100644 --- a/osu.Game.Rulesets.Mania/Timing/TimingSection.cs +++ b/osu.Game.Rulesets.Mania/Timing/TimingSection.cs @@ -1,15 +1,30 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Game.Beatmaps.Timing; - -namespace osu.Game.Rulesets.Mania.Timing -{ - public class TimingSection - { - public double StartTime; - public double Duration; - public double BeatLength; - public TimeSignatures TimeSignature; - } +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Beatmaps.Timing; + +namespace osu.Game.Rulesets.Mania.Timing +{ + /// + /// A point in the map where the beat length or speed multiplier has changed . + /// + public class TimingSection + { + /// + /// The time at which the change occurred. + /// + public double StartTime; + /// + /// The duration of this timing section - lasts until the next timing section. + /// + public double Duration; + /// + /// The beat length, includes any speed multiplier. + /// + public double BeatLength; + /// + /// The time signature of this timing section. + /// + public TimeSignatures TimeSignature; + } } \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index a3b1a49c9c..46fe64ff66 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -96,7 +96,7 @@ namespace osu.Game.Rulesets.Mania.UI }, barlineContainer = new TimeRelativeContainer(timingSections) { - Name = "Barlines", + Name = "Bar lines", Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, RelativeSizeAxes = Axes.Both, From 0597a95db09c4b38baa2b2cfae8f994110898c9d Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 11 May 2017 22:16:50 +0900 Subject: [PATCH 167/329] Resharper is too smart. --- .../Beatmaps/ManiaBeatmapConverter.cs | 7 ++++--- osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs | 10 +++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs index 08ee8c0bf8..e51bbcdc13 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs @@ -8,6 +8,7 @@ using System; using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Beatmaps; using osu.Game.Rulesets.Objects; +using OpenTK; namespace osu.Game.Rulesets.Mania.Beatmaps { @@ -17,12 +18,12 @@ namespace osu.Game.Rulesets.Mania.Beatmaps protected override IEnumerable ConvertHitObject(HitObject original, Beatmap beatmap) { - int columns = (int)Math.Round(beatmap.BeatmapInfo.Difficulty.CircleSize); + int availableColumns = (int)Math.Round(beatmap.BeatmapInfo.Difficulty.CircleSize); var positionData = original as IHasXPosition; - float localWDivisor = 512.0f / columns; - int column = Math.Min((int)Math.Floor(positionData.X / localWDivisor), columns - 1); + float localWDivisor = 512.0f / availableColumns; + int column = MathHelper.Clamp((int)Math.Floor((positionData?.X ?? 1) / localWDivisor), 0, availableColumns - 1); yield return new Note { diff --git a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs index 79fb6f8615..4cb5b8853b 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs @@ -36,7 +36,11 @@ namespace osu.Game.Rulesets.Mania.UI var timingSections = new List(); // Construct all the relevant timing sections - ControlPoint lastTimingChange = null; + ControlPoint lastTimingChange = Beatmap.TimingInfo.ControlPoints.FirstOrDefault(t => t.TimingChange); + + if (lastTimingChange == null) + throw new Exception("The Beatmap contains no timing points!"); + foreach (ControlPoint point in Beatmap.TimingInfo.ControlPoints) { if (point.TimingChange) @@ -92,10 +96,6 @@ namespace osu.Game.Rulesets.Mania.UI if (note != null) return new DrawableNote(note); - var holdNote = h as HoldNote; - if (holdNote != null) - return new DrawableHoldNote(holdNote); - return null; } From f044b95ce81d9822ae6e08e70939794b21c8e20d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 11 May 2017 23:10:19 +0900 Subject: [PATCH 168/329] Allow OsuTabControl to handle non-enum types. --- osu.Game/Graphics/UserInterface/OsuTabControl.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index 242a9a8f6a..8b72eedbfd 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -25,15 +25,15 @@ namespace osu.Game.Graphics.UserInterface protected override bool InternalContains(Vector2 screenSpacePos) => base.InternalContains(screenSpacePos) || Dropdown.Contains(screenSpacePos); + private bool isEnumType => typeof(T).IsEnum; + public OsuTabControl() { TabContainer.Spacing = new Vector2(10f, 0f); - if (!typeof(T).IsEnum) - throw new InvalidOperationException("OsuTabControl only supports enums as the generic type argument"); - - foreach (var val in (T[])Enum.GetValues(typeof(T))) - AddItem(val); + if (isEnumType) + foreach (var val in (T[])Enum.GetValues(typeof(T))) + AddItem(val); } [BackgroundDependencyLoader] @@ -136,7 +136,7 @@ namespace osu.Game.Graphics.UserInterface Margin = new MarginPadding { Top = 5, Bottom = 5 }, Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, - Text = (value as Enum)?.GetDescription(), + Text = (value as Enum)?.GetDescription() ?? value.ToString(), TextSize = 14, Font = @"Exo2.0-Bold", // Font should only turn bold when active? }, From a77049213dc51b98c793af5765a5a14da21d7b2f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 11 May 2017 23:10:48 +0900 Subject: [PATCH 169/329] Add basic hard-coded inefficient multi-channel support. --- osu.Game/Online/Chat/Channel.cs | 2 + .../Online/Chat/Drawables/DrawableChannel.cs | 10 +-- osu.Game/Overlays/ChatOverlay.cs | 63 +++++++++++++++---- 3 files changed, 54 insertions(+), 21 deletions(-) diff --git a/osu.Game/Online/Chat/Channel.cs b/osu.Game/Online/Chat/Channel.cs index d3bd57a1c9..6b43010776 100644 --- a/osu.Game/Online/Chat/Channel.cs +++ b/osu.Game/Online/Chat/Channel.cs @@ -53,5 +53,7 @@ namespace osu.Game.Online.Chat if (messageCount > MAX_HISTORY) Messages.RemoveRange(0, messageCount - MAX_HISTORY); } + + public override string ToString() => Name; } } diff --git a/osu.Game/Online/Chat/Drawables/DrawableChannel.cs b/osu.Game/Online/Chat/Drawables/DrawableChannel.cs index e3101e8fd7..8268ab41c5 100644 --- a/osu.Game/Online/Chat/Drawables/DrawableChannel.cs +++ b/osu.Game/Online/Chat/Drawables/DrawableChannel.cs @@ -25,14 +25,6 @@ namespace osu.Game.Online.Chat.Drawables Children = new Drawable[] { - new OsuSpriteText - { - Text = channel.Name, - TextSize = 50, - Alpha = 0.3f, - Anchor = Anchor.Centre, - Origin = Anchor.Centre - }, scroll = new ScrollContainer { RelativeSizeAxes = Axes.Both, @@ -93,4 +85,4 @@ namespace osu.Game.Online.Chat.Drawables private void scrollToEnd() => Scheduler.AddDelayed(() => scroll.ScrollToEnd(), 50); } -} \ No newline at end of file +} diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index dc586bd363..77c9f36af5 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -30,9 +30,7 @@ namespace osu.Game.Overlays private ScheduledDelegate messageRequest; - private readonly Container content; - - protected override Container Content => content; + private readonly Container currentChannelContainer; private readonly FocusedTextBox inputTextBox; @@ -42,6 +40,8 @@ namespace osu.Game.Overlays private GetMessagesRequest fetchReq; + private readonly OsuTabControl channelTabs; + public ChatOverlay() { RelativeSizeAxes = Axes.X; @@ -49,8 +49,13 @@ namespace osu.Game.Overlays Anchor = Anchor.BottomLeft; Origin = Anchor.BottomLeft; - AddInternal(new Drawable[] + Children = new Drawable[] { + channelTabs = new OsuTabControl() + { + RelativeSizeAxes = Axes.X, + Height = 20, + }, new Box { Depth = float.MaxValue, @@ -58,10 +63,10 @@ namespace osu.Game.Overlays Colour = Color4.Black, Alpha = 0.9f, }, - content = new Container + currentChannelContainer = new Container { RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding { Top = 5, Bottom = textbox_height + 5 }, + Padding = new MarginPadding { Top = 25, Bottom = textbox_height + 5 }, }, new Container { @@ -83,7 +88,9 @@ namespace osu.Game.Overlays } } } - }); + }; + + channelTabs.Current.ValueChanged += newChannel => CurrentChannel = newChannel; } public void APIStateChanged(APIAccess api, APIState state) @@ -137,7 +144,7 @@ namespace osu.Game.Overlays private void initializeChannels() { - Clear(); + currentChannelContainer.Clear(); careChannels = new List(); @@ -161,24 +168,56 @@ namespace osu.Game.Overlays { loading.FadeOut(100); addChannel(channels.Find(c => c.Name == @"#lazer")); + addChannel(channels.Find(c => c.Name == @"#osu")); + addChannel(channels.Find(c => c.Name == @"#lobby")); }); - messageRequest = Scheduler.AddDelayed(fetchNewMessages, 1000, true); + messageRequest = Scheduler.AddDelayed(() => fetchNewMessages(), 1000, true); }; + api.Queue(req); } + private Channel currentChannel; + + protected Channel CurrentChannel + { + get + { + return currentChannel; + } + + set + { + if (currentChannel == value) return; + + if (currentChannel != null) + currentChannelContainer.Clear(); + + currentChannel = value; + currentChannelContainer.Add(new DrawableChannel(currentChannel)); + + channelTabs.Current.Value = value; + } + } + private void addChannel(Channel channel) { - Add(new DrawableChannel(channel)); careChannels.Add(channel); + channelTabs.AddItem(channel); + + // we need to get a good number of messages initially for each channel we care about. + fetchNewMessages(channel); + + if (CurrentChannel == null) + CurrentChannel = channel; } - private void fetchNewMessages() + private void fetchNewMessages(Channel specificChannel = null) { if (fetchReq != null) return; - fetchReq = new GetMessagesRequest(careChannels, lastMessageId); + fetchReq = new GetMessagesRequest(specificChannel != null ? new List { specificChannel } : careChannels, lastMessageId); fetchReq.Success += delegate (List messages) { var ids = messages.Where(m => m.TargetType == TargetType.Channel).Select(m => m.TargetId).Distinct(); From ffa59c6cb3a0cd7fa9036e008cfbb78ee24fb3ee Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 11 May 2017 23:51:26 +0900 Subject: [PATCH 170/329] Support read-only channels, post to correct channel. Also cache drawable channels better. --- osu.Game/Online/Chat/Channel.cs | 2 ++ .../Online/Chat/Drawables/DrawableChannel.cs | 8 ++++---- osu.Game/Overlays/ChatOverlay.cs | 20 +++++++++++++++---- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/osu.Game/Online/Chat/Channel.cs b/osu.Game/Online/Chat/Channel.cs index 6b43010776..d159f482a9 100644 --- a/osu.Game/Online/Chat/Channel.cs +++ b/osu.Game/Online/Chat/Channel.cs @@ -27,6 +27,8 @@ namespace osu.Game.Online.Chat //internal bool Joined; + public bool ReadOnly => Name != "#lazer"; + public const int MAX_HISTORY = 300; [JsonConstructor] diff --git a/osu.Game/Online/Chat/Drawables/DrawableChannel.cs b/osu.Game/Online/Chat/Drawables/DrawableChannel.cs index 8268ab41c5..870f67a01e 100644 --- a/osu.Game/Online/Chat/Drawables/DrawableChannel.cs +++ b/osu.Game/Online/Chat/Drawables/DrawableChannel.cs @@ -13,13 +13,13 @@ namespace osu.Game.Online.Chat.Drawables { public class DrawableChannel : Container { - private readonly Channel channel; + public readonly Channel Channel; private readonly FillFlowContainer flow; private readonly ScrollContainer scroll; public DrawableChannel(Channel channel) { - this.channel = channel; + Channel = channel; RelativeSizeAxes = Axes.Both; @@ -48,14 +48,14 @@ namespace osu.Game.Online.Chat.Drawables { base.LoadComplete(); - newMessagesArrived(channel.Messages); + newMessagesArrived(Channel.Messages); scrollToEnd(); } protected override void Dispose(bool isDisposing) { base.Dispose(isDisposing); - channel.NewMessagesArrived -= newMessagesArrived; + Channel.NewMessagesArrived -= newMessagesArrived; } private void newMessagesArrived(IEnumerable newMessages) diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index 77c9f36af5..05239082ef 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -142,10 +142,14 @@ namespace osu.Game.Overlays private List careChannels; + private List loadedChannels = new List(); + private void initializeChannels() { currentChannelContainer.Clear(); + loadedChannels.Clear(); + careChannels = new List(); SpriteText loading; @@ -167,6 +171,7 @@ namespace osu.Game.Overlays Scheduler.Add(delegate { loading.FadeOut(100); + addChannel(channels.Find(c => c.Name == @"#lazer")); addChannel(channels.Find(c => c.Name == @"#osu")); addChannel(channels.Find(c => c.Name == @"#lobby")); @@ -192,10 +197,17 @@ namespace osu.Game.Overlays if (currentChannel == value) return; if (currentChannel != null) - currentChannelContainer.Clear(); + currentChannelContainer.Clear(false); currentChannel = value; - currentChannelContainer.Add(new DrawableChannel(currentChannel)); + + var loaded = loadedChannels.Find(d => d.Channel == value); + if (loaded == null) + loadedChannels.Add(loaded = new DrawableChannel(currentChannel)); + + inputTextBox.Current.Disabled = currentChannel.ReadOnly; + + currentChannelContainer.Add(loaded); channelTabs.Current.Value = value; } @@ -203,6 +215,8 @@ namespace osu.Game.Overlays private void addChannel(Channel channel) { + if (channel == null) return; + careChannels.Add(channel); channelTabs.AddItem(channel); @@ -246,8 +260,6 @@ namespace osu.Game.Overlays if (!string.IsNullOrEmpty(postText) && api.LocalUser.Value != null) { - var currentChannel = careChannels.FirstOrDefault(); - if (currentChannel == null) return; var message = new Message From 79ed92a0d7d3fa9d15a4a02e8e577b28654e3c4a Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Fri, 12 May 2017 01:48:28 +0300 Subject: [PATCH 171/329] Simplified logic --- osu.Game/Screens/Play/SongProgressInfo.cs | 49 ++++++++++++----------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/osu.Game/Screens/Play/SongProgressInfo.cs b/osu.Game/Screens/Play/SongProgressInfo.cs index ae6436bc6c..0303d024b4 100644 --- a/osu.Game/Screens/Play/SongProgressInfo.cs +++ b/osu.Game/Screens/Play/SongProgressInfo.cs @@ -25,6 +25,11 @@ namespace osu.Game.Screens.Play private int previousSecond; private double previousTimespan; + private double songLenght => endTime - startTime; + + private bool percentHasChanged = true; + private bool secondHasChanged = true; + private const int margin = 10; public IClock AudioClock; @@ -74,32 +79,30 @@ namespace osu.Game.Screens.Play base.Update(); double songCurrentTime = AudioClock.CurrentTime - startTime; - int currentPercent = (int)(songCurrentTime / (endTime - startTime) * 100); + int currentPercent = songCurrentTime < 0 ? 0 : songCurrentTime > songLenght ? 100 : (int)(songCurrentTime / songLenght * 100); + int currentSecond = TimeSpan.FromMilliseconds(songCurrentTime).Seconds; - if (currentPercent <= 100) + if (percentHasChanged) { - int currentSecond = TimeSpan.FromMilliseconds(songCurrentTime).Seconds; - - if (currentSecond != previousSecond || previousTimespan < 0 && songCurrentTime > 0) - { - previousTimespan = songCurrentTime; - previousSecond = currentSecond; - - if (songCurrentTime < 0) - timeCurrent.Text = @"-" + TimeSpan.FromMilliseconds(songCurrentTime - 1000).ToString(@"m\:ss"); - else - timeCurrent.Text = TimeSpan.FromMilliseconds(songCurrentTime).ToString(@"m\:ss"); - - timeLeft.Text = @"-" + TimeSpan.FromMilliseconds(endTime - AudioClock.CurrentTime).ToString(@"m\:ss"); - } - - if (currentPercent != previousPercent) - { - previousPercent = currentPercent; - - progress.Text = (currentPercent <= 0 ? @"0" : currentPercent.ToString()) + @"%"; - } + progress.Text = currentPercent.ToString() + @"%"; + previousPercent = currentPercent; } + + if (secondHasChanged && songCurrentTime < songLenght || previousTimespan < 0 && songCurrentTime > 0) + { + if (songCurrentTime < 0) + timeCurrent.Text = @"-" + TimeSpan.FromMilliseconds(songCurrentTime - 1000).ToString(@"m\:ss"); + else + timeCurrent.Text = TimeSpan.FromMilliseconds(songCurrentTime).ToString(@"m\:ss"); + + timeLeft.Text = @"-" + TimeSpan.FromMilliseconds(endTime - AudioClock.CurrentTime).ToString(@"m\:ss"); + + previousSecond = currentSecond; + previousTimespan = songCurrentTime; + } + + percentHasChanged = currentPercent != previousPercent; + secondHasChanged = currentSecond != previousSecond; } } } From f248efb01f5cdc8b6a1747bd1a179fb981fbe7d9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 12 May 2017 13:25:50 +0900 Subject: [PATCH 172/329] CI Fixes --- osu.Game/Online/Chat/Drawables/DrawableChannel.cs | 1 - osu.Game/Overlays/ChatOverlay.cs | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Game/Online/Chat/Drawables/DrawableChannel.cs b/osu.Game/Online/Chat/Drawables/DrawableChannel.cs index 870f67a01e..d179f851b2 100644 --- a/osu.Game/Online/Chat/Drawables/DrawableChannel.cs +++ b/osu.Game/Online/Chat/Drawables/DrawableChannel.cs @@ -7,7 +7,6 @@ using System.Linq; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; -using osu.Game.Graphics.Sprites; namespace osu.Game.Online.Chat.Drawables { diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index 05239082ef..75ddcd89b6 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -51,7 +51,7 @@ namespace osu.Game.Overlays Children = new Drawable[] { - channelTabs = new OsuTabControl() + channelTabs = new OsuTabControl { RelativeSizeAxes = Axes.X, Height = 20, @@ -142,7 +142,7 @@ namespace osu.Game.Overlays private List careChannels; - private List loadedChannels = new List(); + private readonly List loadedChannels = new List(); private void initializeChannels() { From 34b4efc4e9ce0676258882fa4e65a06228804aa2 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Fri, 12 May 2017 08:12:34 +0300 Subject: [PATCH 173/329] Applied suggested changes --- osu.Game/Screens/Play/SongProgressInfo.cs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/osu.Game/Screens/Play/SongProgressInfo.cs b/osu.Game/Screens/Play/SongProgressInfo.cs index 0303d024b4..36bb344dab 100644 --- a/osu.Game/Screens/Play/SongProgressInfo.cs +++ b/osu.Game/Screens/Play/SongProgressInfo.cs @@ -23,9 +23,8 @@ namespace osu.Game.Screens.Play private int previousPercent; private int previousSecond; - private double previousTimespan; - private double songLenght => endTime - startTime; + private double songLength => endTime - startTime; private bool percentHasChanged = true; private bool secondHasChanged = true; @@ -79,8 +78,8 @@ namespace osu.Game.Screens.Play base.Update(); double songCurrentTime = AudioClock.CurrentTime - startTime; - int currentPercent = songCurrentTime < 0 ? 0 : songCurrentTime > songLenght ? 100 : (int)(songCurrentTime / songLenght * 100); - int currentSecond = TimeSpan.FromMilliseconds(songCurrentTime).Seconds; + int currentPercent = Math.Max(0, Math.Min(100, (int)(songCurrentTime / songLength * 100))); + int currentSecond = (int)Math.Floor(songCurrentTime / 1000.0); if (percentHasChanged) { @@ -88,17 +87,12 @@ namespace osu.Game.Screens.Play previousPercent = currentPercent; } - if (secondHasChanged && songCurrentTime < songLenght || previousTimespan < 0 && songCurrentTime > 0) + if (secondHasChanged && songCurrentTime < songLength) { - if (songCurrentTime < 0) - timeCurrent.Text = @"-" + TimeSpan.FromMilliseconds(songCurrentTime - 1000).ToString(@"m\:ss"); - else - timeCurrent.Text = TimeSpan.FromMilliseconds(songCurrentTime).ToString(@"m\:ss"); - - timeLeft.Text = @"-" + TimeSpan.FromMilliseconds(endTime - AudioClock.CurrentTime).ToString(@"m\:ss"); + timeCurrent.Text = TimeSpan.FromSeconds(currentSecond).ToString(songCurrentTime < 0 ? @"\-m\:ss" : @"m\:ss"); + timeLeft.Text = TimeSpan.FromMilliseconds(endTime - AudioClock.CurrentTime).ToString(@"\-m\:ss"); previousSecond = currentSecond; - previousTimespan = songCurrentTime; } percentHasChanged = currentPercent != previousPercent; From 1420aa406c8d12ba8d4b8ee0c3fa4adb3fb1f181 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 12 May 2017 14:24:32 +0900 Subject: [PATCH 174/329] Add framework fix. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 682f078b2e..fcf36739bc 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 682f078b2efc82fa19342f499f14c4a8458843d5 +Subproject commit fcf36739bc8a97b43a08ce0b29bd7c67ce1a3547 From 9cf4998701e4e11038e273304817efb1f02647bd Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 12 May 2017 13:54:02 +0900 Subject: [PATCH 175/329] Make chat resizable via drag, save user set size --- osu.Game/Configuration/OsuConfigManager.cs | 6 +++- osu.Game/Overlays/ChatOverlay.cs | 33 +++++++++++++++++++--- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 3907496ca2..ba19d8592a 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -3,6 +3,7 @@ using osu.Framework.Configuration; using osu.Framework.Platform; +using osu.Game.Overlays; using osu.Game.Screens.Select; namespace osu.Game.Configuration @@ -19,6 +20,8 @@ namespace osu.Game.Configuration Set(OsuConfig.DisplayStarsMinimum, 0.0, 0, 10); Set(OsuConfig.DisplayStarsMaximum, 10.0, 0, 10); + Set(OsuConfig.ChatDisplayHeight, ChatOverlay.DEFAULT_HEIGHT, 0.2, 1); + // Online settings Set(OsuConfig.Username, string.Empty); @@ -102,6 +105,7 @@ namespace osu.Game.Configuration DisplayStarsMaximum, SnakingInSliders, SnakingOutSliders, - ShowFpsDisplay + ShowFpsDisplay, + ChatDisplayHeight } } diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index 75ddcd89b6..3630ad0518 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -7,6 +7,7 @@ using System.Diagnostics; using System.Linq; using OpenTK; using osu.Framework.Allocation; +using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -21,6 +22,7 @@ using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.UserInterface; using OpenTK.Graphics; using osu.Framework.Input; +using osu.Game.Configuration; namespace osu.Game.Overlays { @@ -38,14 +40,19 @@ namespace osu.Game.Overlays private const int transition_length = 500; + public const float DEFAULT_HEIGHT = 0.4f; + private GetMessagesRequest fetchReq; private readonly OsuTabControl channelTabs; + private Bindable chatHeight; + public ChatOverlay() { - RelativeSizeAxes = Axes.X; - Size = new Vector2(1, 300); + RelativeSizeAxes = Axes.Both; + RelativePositionAxes = Axes.Both; + Size = new Vector2(1, DEFAULT_HEIGHT); Anchor = Anchor.BottomLeft; Origin = Anchor.BottomLeft; @@ -93,6 +100,20 @@ namespace osu.Game.Overlays channelTabs.Current.ValueChanged += newChannel => CurrentChannel = newChannel; } + protected override bool OnDragStart(InputState state) + { + if (channelTabs.Hovering) + return true; + + return base.OnDragStart(state); + } + + protected override bool OnDrag(InputState state) + { + chatHeight.Value = Height - state.Mouse.Delta.Y / Parent.DrawSize.Y; + return base.OnDrag(state); + } + public void APIStateChanged(APIAccess api, APIState state) { switch (state) @@ -124,7 +145,7 @@ namespace osu.Game.Overlays protected override void PopOut() { - MoveToY(DrawSize.Y, transition_length, EasingTypes.InSine); + MoveToY(Height, transition_length, EasingTypes.InSine); FadeOut(transition_length, EasingTypes.InSine); inputTextBox.HoldFocus = false; @@ -132,10 +153,14 @@ namespace osu.Game.Overlays } [BackgroundDependencyLoader] - private void load(APIAccess api) + private void load(APIAccess api, OsuConfigManager config) { this.api = api; api.Register(this); + + chatHeight = config.GetBindable(OsuConfig.ChatDisplayHeight); + chatHeight.ValueChanged += h => Height = (float)h; + chatHeight.TriggerChange(); } private long? lastMessageId; From c4a93cbc8540870d68405194318e0ad1c5eb01a7 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 12 May 2017 14:21:57 +0900 Subject: [PATCH 176/329] Move drawable chat related classes to better namespace --- .../Chat/Drawables => Overlays/Chat}/ChatLine.cs | 14 +++++++++----- .../Drawables => Overlays/Chat}/DrawableChannel.cs | 3 ++- osu.Game/Overlays/ChatOverlay.cs | 3 ++- osu.Game/osu.Game.csproj | 4 ++-- 4 files changed, 15 insertions(+), 9 deletions(-) rename osu.Game/{Online/Chat/Drawables => Overlays/Chat}/ChatLine.cs (87%) rename osu.Game/{Online/Chat/Drawables => Overlays/Chat}/DrawableChannel.cs (94%) diff --git a/osu.Game/Online/Chat/Drawables/ChatLine.cs b/osu.Game/Overlays/Chat/ChatLine.cs similarity index 87% rename from osu.Game/Online/Chat/Drawables/ChatLine.cs rename to osu.Game/Overlays/Chat/ChatLine.cs index 6bfa25755f..d4063efbb5 100644 --- a/osu.Game/Online/Chat/Drawables/ChatLine.cs +++ b/osu.Game/Overlays/Chat/ChatLine.cs @@ -6,10 +6,11 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using osu.Game.Online.Chat; using OpenTK; using OpenTK.Graphics; -namespace osu.Game.Online.Chat.Drawables +namespace osu.Game.Overlays.Chat { public class ChatLine : Container { @@ -62,7 +63,10 @@ namespace osu.Game.Online.Chat.Drawables return username_colours[message.UserId % username_colours.Length]; } - private const float padding = 200; + public const float LEFT_PADDING = message_padding + padding * 2; + + private const float padding = 15; + private const float message_padding = 200; private const float text_size = 20; public ChatLine(Message message) @@ -72,13 +76,13 @@ namespace osu.Game.Online.Chat.Drawables RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; - Padding = new MarginPadding { Left = 15, Right = 15 }; + Padding = new MarginPadding { Left = padding, Right = padding }; Children = new Drawable[] { new Container { - Size = new Vector2(padding, text_size), + Size = new Vector2(message_padding, text_size), Children = new Drawable[] { new OsuSpriteText @@ -106,7 +110,7 @@ namespace osu.Game.Online.Chat.Drawables { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Padding = new MarginPadding { Left = padding + 15 }, + Padding = new MarginPadding { Left = message_padding + padding }, Children = new Drawable[] { new OsuSpriteText diff --git a/osu.Game/Online/Chat/Drawables/DrawableChannel.cs b/osu.Game/Overlays/Chat/DrawableChannel.cs similarity index 94% rename from osu.Game/Online/Chat/Drawables/DrawableChannel.cs rename to osu.Game/Overlays/Chat/DrawableChannel.cs index d179f851b2..39dc1914ab 100644 --- a/osu.Game/Online/Chat/Drawables/DrawableChannel.cs +++ b/osu.Game/Overlays/Chat/DrawableChannel.cs @@ -7,8 +7,9 @@ using System.Linq; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; +using osu.Game.Online.Chat; -namespace osu.Game.Online.Chat.Drawables +namespace osu.Game.Overlays.Chat { public class DrawableChannel : Container { diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index 3630ad0518..a9dc915c6b 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -16,13 +16,14 @@ using osu.Game.Graphics.Sprites; using osu.Game.Online.API; using osu.Game.Online.API.Requests; using osu.Game.Online.Chat; -using osu.Game.Online.Chat.Drawables; using osu.Game.Graphics.UserInterface; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.UserInterface; using OpenTK.Graphics; using osu.Framework.Input; using osu.Game.Configuration; +using osu.Game.Graphics; +using osu.Game.Overlays.Chat; namespace osu.Game.Overlays { diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index fd15115fe2..313d003605 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -304,8 +304,8 @@ - - + + From 6ea65009c402f5517d7b8db5bc2def862631e727 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 12 May 2017 14:22:11 +0900 Subject: [PATCH 177/329] Initial design update pass --- osu.Game/Overlays/ChatOverlay.cs | 89 ++++++++++++++++++++++---------- 1 file changed, 62 insertions(+), 27 deletions(-) diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index a9dc915c6b..7f74750873 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -29,7 +29,7 @@ namespace osu.Game.Overlays { public class ChatOverlay : FocusedOverlayContainer, IOnlineComponent { - private const float textbox_height = 40; + private const float textbox_height = 60; private ScheduledDelegate messageRequest; @@ -43,6 +43,8 @@ namespace osu.Game.Overlays public const float DEFAULT_HEIGHT = 0.4f; + private const float tab_area_height = 50; + private GetMessagesRequest fetchReq; private readonly OsuTabControl channelTabs; @@ -57,45 +59,78 @@ namespace osu.Game.Overlays Anchor = Anchor.BottomLeft; Origin = Anchor.BottomLeft; + const float padding = 5; + Children = new Drawable[] { - channelTabs = new OsuTabControl + new Container { + Name = @"tabs area", RelativeSizeAxes = Axes.X, - Height = 20, - }, - new Box - { - Depth = float.MaxValue, - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black, - Alpha = 0.9f, - }, - currentChannelContainer = new Container - { - RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding { Top = 25, Bottom = textbox_height + 5 }, + Height = tab_area_height, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black, + Alpha = 0.8f, + }, + channelTabs = new OsuTabControl + { + RelativeSizeAxes = Axes.Both, + }, + } }, new Container { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - RelativeSizeAxes = Axes.X, - Height = textbox_height, - Padding = new MarginPadding(5), + Name = @"chat area", + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Top = tab_area_height }, Children = new Drawable[] { - inputTextBox = new FocusedTextBox + new Box { RelativeSizeAxes = Axes.Both, - Height = 1, - PlaceholderText = "type your message", - Exit = () => State = Visibility.Hidden, - OnCommit = postMessage, - HoldFocus = true, + Colour = OsuColour.FromHex(@"17292e"), + }, + currentChannelContainer = new Container + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding + { + Top = padding, + Bottom = textbox_height + padding + }, + }, + new Container + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + RelativeSizeAxes = Axes.X, + Height = textbox_height, + Padding = new MarginPadding + { + Top = padding * 2, + Bottom = padding * 2, + Left = ChatLine.LEFT_PADDING + padding * 2, + Right = padding * 2, + }, + Children = new Drawable[] + { + inputTextBox = new FocusedTextBox + { + RelativeSizeAxes = Axes.Both, + Height = 1, + PlaceholderText = "type your message", + Exit = () => State = Visibility.Hidden, + OnCommit = postMessage, + HoldFocus = true, + } + } } } - } + }, }; channelTabs.Current.ValueChanged += newChannel => CurrentChannel = newChannel; From dbf60d24bf8aff079f418fed073806f9382716cc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 12 May 2017 15:32:52 +0900 Subject: [PATCH 178/329] Second design update pass. --- osu.Game/Graphics/OsuColour.cs | 2 + osu.Game/Overlays/Chat/ChatTabControl.cs | 182 +++++++++++++++++++++++ osu.Game/Overlays/ChatOverlay.cs | 53 +++---- osu.Game/osu.Game.csproj | 1 + 4 files changed, 213 insertions(+), 25 deletions(-) create mode 100644 osu.Game/Overlays/Chat/ChatTabControl.cs diff --git a/osu.Game/Graphics/OsuColour.cs b/osu.Game/Graphics/OsuColour.cs index b666442f19..3d83668d07 100644 --- a/osu.Game/Graphics/OsuColour.cs +++ b/osu.Game/Graphics/OsuColour.cs @@ -85,5 +85,7 @@ namespace osu.Game.Graphics public readonly Color4 Red = FromHex(@"ed1121"); public readonly Color4 RedDark = FromHex(@"ba0011"); public readonly Color4 RedDarker = FromHex(@"870000"); + + public readonly Color4 ChatBlue = FromHex(@"17292e"); } } diff --git a/osu.Game/Overlays/Chat/ChatTabControl.cs b/osu.Game/Overlays/Chat/ChatTabControl.cs new file mode 100644 index 0000000000..c7e1382255 --- /dev/null +++ b/osu.Game/Overlays/Chat/ChatTabControl.cs @@ -0,0 +1,182 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Allocation; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Primitives; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.UserInterface; +using osu.Framework.Input; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.UserInterface; +using osu.Game.Online.Chat; +using OpenTK; +using OpenTK.Graphics; + +namespace osu.Game.Overlays.Chat +{ + public class ChatTabControl : OsuTabControl + { + protected override TabItem CreateTabItem(Channel value) => new ChannelTabItem(value); + + private const float shear_width = 10; + + public ChatTabControl() + { + TabContainer.Margin = new MarginPadding { Left = 50 }; + TabContainer.Spacing = new Vector2(-shear_width, 0); + TabContainer.Masking = false; + + AddInternal(new TextAwesome + { + Icon = FontAwesome.fa_comments, + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + TextSize = 20, + Padding = new MarginPadding(10), + }); + } + + private class ChannelTabItem : TabItem + { + private Color4 backgroundInactive; + private Color4 backgroundHover; + private Color4 backgroundActive; + + private readonly SpriteText text; + private readonly Box box; + private readonly Box highlightBox; + + public override bool Active + { + get { return base.Active; } + set + { + if (Active == value) return; + + base.Active = value; + updateState(); + } + } + + private void updateState() + { + if (Active) + fadeActive(); + else + fadeInactive(); + } + + private const float transition_length = 400; + + private void fadeActive() + { + ResizeTo(new Vector2(Width, 1.1f), transition_length, EasingTypes.OutQuint); + + box.FadeColour(backgroundActive, transition_length, EasingTypes.OutQuint); + highlightBox.FadeIn(transition_length, EasingTypes.OutQuint); + text.Font = @"Exo2.0-Bold"; + } + + private void fadeInactive() + { + ResizeTo(new Vector2(Width, 1), transition_length, EasingTypes.OutQuint); + + box.FadeColour(backgroundInactive, transition_length, EasingTypes.OutQuint); + highlightBox.FadeOut(transition_length, EasingTypes.OutQuint); + text.Font = @"Exo2.0-Regular"; + } + + protected override bool OnHover(InputState state) + { + if (!Active) + box.FadeColour(backgroundHover, transition_length, EasingTypes.OutQuint); + return true; + } + + protected override void OnHoverLost(InputState state) + { + updateState(); + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + backgroundActive = colours.ChatBlue; + backgroundInactive = colours.Gray4; + backgroundHover = colours.Gray7; + + highlightBox.Colour = colours.Yellow; + + updateState(); + } + + public ChannelTabItem(Channel value) : base(value) + { + Width = 150; + + RelativeSizeAxes = Axes.Y; + + Anchor = Anchor.BottomLeft; + Origin = Anchor.BottomLeft; + + Shear = new Vector2(shear_width / ChatOverlay.TAB_AREA_HEIGHT, 0); + + Masking = true; + EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Shadow, + Radius = 10, + Colour = Color4.Black.Opacity(0.2f), + }; + + Children = new Drawable[] + { + box = new Box + { + EdgeSmoothness = new Vector2(1, 0), + RelativeSizeAxes = Axes.Both, + }, + highlightBox = new Box + { + Width = 5, + Alpha = 0, + Anchor = Anchor.BottomRight, + Origin = Anchor.BottomRight, + EdgeSmoothness = new Vector2(1, 0), + RelativeSizeAxes = Axes.Y, + }, + new Container + { + Shear = new Vector2(-shear_width / ChatOverlay.TAB_AREA_HEIGHT, 0), + RelativeSizeAxes = Axes.Both, + Children = new Drawable[] + { + new TextAwesome + { + Icon = FontAwesome.fa_hashtag, + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Colour = Color4.Black, + X = -10, + Alpha = 0.2f, + TextSize = ChatOverlay.TAB_AREA_HEIGHT, + }, + text = new OsuSpriteText + { + Margin = new MarginPadding(5), + Origin = Anchor.CentreLeft, + Anchor = Anchor.CentreLeft, + Text = value.ToString(), + TextSize = 18, + }, + } + } + }; + } + } + } +} diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index 7f74750873..812ab236e7 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -43,11 +43,13 @@ namespace osu.Game.Overlays public const float DEFAULT_HEIGHT = 0.4f; - private const float tab_area_height = 50; + public const float TAB_AREA_HEIGHT = 50; private GetMessagesRequest fetchReq; - private readonly OsuTabControl channelTabs; + private readonly ChatTabControl channelTabs; + + private readonly Box chatBackground; private Bindable chatHeight; @@ -63,36 +65,16 @@ namespace osu.Game.Overlays Children = new Drawable[] { - new Container - { - Name = @"tabs area", - RelativeSizeAxes = Axes.X, - Height = tab_area_height, - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black, - Alpha = 0.8f, - }, - channelTabs = new OsuTabControl - { - RelativeSizeAxes = Axes.Both, - }, - } - }, new Container { Name = @"chat area", RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding { Top = tab_area_height }, + Padding = new MarginPadding { Top = TAB_AREA_HEIGHT }, Children = new Drawable[] { - new Box + chatBackground = new Box { RelativeSizeAxes = Axes.Both, - Colour = OsuColour.FromHex(@"17292e"), }, currentChannelContainer = new Container { @@ -131,6 +113,25 @@ namespace osu.Game.Overlays } } }, + new Container + { + Name = @"tabs area", + RelativeSizeAxes = Axes.X, + Height = TAB_AREA_HEIGHT, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black, + Alpha = 0.8f, + }, + channelTabs = new ChatTabControl + { + RelativeSizeAxes = Axes.Both, + }, + } + }, }; channelTabs.Current.ValueChanged += newChannel => CurrentChannel = newChannel; @@ -189,7 +190,7 @@ namespace osu.Game.Overlays } [BackgroundDependencyLoader] - private void load(APIAccess api, OsuConfigManager config) + private void load(APIAccess api, OsuConfigManager config, OsuColour colours) { this.api = api; api.Register(this); @@ -197,6 +198,8 @@ namespace osu.Game.Overlays chatHeight = config.GetBindable(OsuConfig.ChatDisplayHeight); chatHeight.ValueChanged += h => Height = (float)h; chatHeight.TriggerChange(); + + chatBackground.Colour = colours.ChatBlue; } private long? lastMessageId; diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 313d003605..a738e7180b 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -75,6 +75,7 @@ + From 9a040691238ab2d377128efe00a72200e178a279 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Fri, 12 May 2017 10:16:31 +0300 Subject: [PATCH 179/329] removed useless booleans, using nullables instead --- osu.Game/Screens/Play/SongProgressInfo.cs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/osu.Game/Screens/Play/SongProgressInfo.cs b/osu.Game/Screens/Play/SongProgressInfo.cs index 36bb344dab..4c53b61313 100644 --- a/osu.Game/Screens/Play/SongProgressInfo.cs +++ b/osu.Game/Screens/Play/SongProgressInfo.cs @@ -21,14 +21,11 @@ namespace osu.Game.Screens.Play private double startTime; private double endTime; - private int previousPercent; - private int previousSecond; + private int? previousPercent; + private int? previousSecond; private double songLength => endTime - startTime; - private bool percentHasChanged = true; - private bool secondHasChanged = true; - private const int margin = 10; public IClock AudioClock; @@ -81,22 +78,19 @@ namespace osu.Game.Screens.Play int currentPercent = Math.Max(0, Math.Min(100, (int)(songCurrentTime / songLength * 100))); int currentSecond = (int)Math.Floor(songCurrentTime / 1000.0); - if (percentHasChanged) + if (currentPercent != previousPercent) { progress.Text = currentPercent.ToString() + @"%"; previousPercent = currentPercent; } - if (secondHasChanged && songCurrentTime < songLength) + if (currentSecond != previousSecond && songCurrentTime < songLength) { timeCurrent.Text = TimeSpan.FromSeconds(currentSecond).ToString(songCurrentTime < 0 ? @"\-m\:ss" : @"m\:ss"); timeLeft.Text = TimeSpan.FromMilliseconds(endTime - AudioClock.CurrentTime).ToString(@"\-m\:ss"); previousSecond = currentSecond; } - - percentHasChanged = currentPercent != previousPercent; - secondHasChanged = currentSecond != previousSecond; } } } From cf239f4d9cbffa7d57f3b6b014fbfe822ca350ef Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 12 May 2017 19:03:21 +0900 Subject: [PATCH 180/329] Move chat into main content Also changes the way parallax is applied to OsuScreens game-wide. --- osu.Game/OsuGame.cs | 5 ++--- osu.Game/Screens/OsuScreen.cs | 4 ++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index ccead95ede..a84333df8c 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -160,7 +160,7 @@ namespace osu.Game }); //overlay elements - LoadComponentAsync(chat = new ChatOverlay { Depth = 0 }, overlayContent.Add); + LoadComponentAsync(chat = new ChatOverlay { Depth = -1 }, mainContent.Add); LoadComponentAsync(options = new OptionsOverlay { Depth = -1 }, overlayContent.Add); LoadComponentAsync(musicController = new MusicController { @@ -320,8 +320,7 @@ namespace osu.Game { base.UpdateAfterChildren(); - if (intro?.ChildScreen != null) - intro.ChildScreen.Padding = new MarginPadding { Top = Toolbar.Position.Y + Toolbar.DrawHeight }; + mainContent.Padding = new MarginPadding { Top = Toolbar.Position.Y + Toolbar.DrawHeight }; Cursor.State = currentScreen?.HasLocalCursorDisplayed == false ? Visibility.Visible : Visibility.Hidden; } diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index 0b3ecb4f5a..16bdd6132f 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -7,6 +7,7 @@ using osu.Framework.Screens; using osu.Game.Beatmaps; using osu.Game.Database; using osu.Game.Graphics.Containers; +using OpenTK; namespace osu.Game.Screens { @@ -96,6 +97,9 @@ namespace osu.Game.Screens } else if (bg != null) { + // this makes up for the fact our padding changes when the global toolbar is visible. + bg.Scale = new Vector2(1.06f); + AddInternal(new ParallaxContainer { Depth = float.MaxValue, From bc5bcfa66a5c737d62128e793a373bf04f8d741c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 12 May 2017 19:15:04 +0900 Subject: [PATCH 181/329] Make tab background opaque when chat is fullscreen --- osu.Game/Overlays/ChatOverlay.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index 812ab236e7..15f8586125 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -50,6 +50,7 @@ namespace osu.Game.Overlays private readonly ChatTabControl channelTabs; private readonly Box chatBackground; + private readonly Box tabBackground; private Bindable chatHeight; @@ -120,11 +121,10 @@ namespace osu.Game.Overlays Height = TAB_AREA_HEIGHT, Children = new Drawable[] { - new Box + tabBackground = new Box { RelativeSizeAxes = Axes.Both, Colour = Color4.Black, - Alpha = 0.8f, }, channelTabs = new ChatTabControl { @@ -196,7 +196,11 @@ namespace osu.Game.Overlays api.Register(this); chatHeight = config.GetBindable(OsuConfig.ChatDisplayHeight); - chatHeight.ValueChanged += h => Height = (float)h; + chatHeight.ValueChanged += h => + { + Height = (float)h; + tabBackground.FadeTo(Height == 1 ? 1 : 0.8f, 200); + }; chatHeight.TriggerChange(); chatBackground.Colour = colours.ChatBlue; From d2e066ca35f199d6e12f9da330b0f14ba83e6855 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 12 May 2017 19:57:06 +0900 Subject: [PATCH 182/329] Move SearchTextBox to better namespace Is being used in multiple places now. --- .../Select => Graphics/UserInterface}/SearchTextBox.cs | 6 ++---- osu.Game/Overlays/Options/OptionsHeader.cs | 1 + osu.Game/osu.Game.csproj | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) rename osu.Game/{Screens/Select => Graphics/UserInterface}/SearchTextBox.cs (91%) diff --git a/osu.Game/Screens/Select/SearchTextBox.cs b/osu.Game/Graphics/UserInterface/SearchTextBox.cs similarity index 91% rename from osu.Game/Screens/Select/SearchTextBox.cs rename to osu.Game/Graphics/UserInterface/SearchTextBox.cs index 4f2ab221cb..18148e9d31 100644 --- a/osu.Game/Screens/Select/SearchTextBox.cs +++ b/osu.Game/Graphics/UserInterface/SearchTextBox.cs @@ -1,14 +1,12 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK.Input; using osu.Framework.Graphics; using osu.Framework.Graphics.Primitives; using osu.Framework.Input; -using osu.Game.Graphics; -using osu.Game.Graphics.UserInterface; +using OpenTK.Input; -namespace osu.Game.Screens.Select +namespace osu.Game.Graphics.UserInterface { /// /// A textbox which holds focus eagerly. diff --git a/osu.Game/Overlays/Options/OptionsHeader.cs b/osu.Game/Overlays/Options/OptionsHeader.cs index 1add9dc409..c173b8844d 100644 --- a/osu.Game/Overlays/Options/OptionsHeader.cs +++ b/osu.Game/Overlays/Options/OptionsHeader.cs @@ -9,6 +9,7 @@ using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.UserInterface; using osu.Game.Screens.Select; using OpenTK.Graphics; diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 904cf7f437..a8f5c11a80 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -384,7 +384,7 @@ - + From fec91d4de12f74398d6b3635d33c68d85e45aed8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 12 May 2017 19:58:31 +0900 Subject: [PATCH 183/329] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index fcf36739bc..e1ac6316aa 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit fcf36739bc8a97b43a08ce0b29bd7c67ce1a3547 +Subproject commit e1ac6316aa3862efb8e79e585a7b4c901a4e1b3c From a9b3f74218ec4d4c26f55636912c389c500a7492 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 12 May 2017 20:05:44 +0900 Subject: [PATCH 184/329] Fix ruleset not always getting populated in a WorkingBeatmap --- osu.Game/Database/BeatmapDatabase.cs | 2 +- osu.Game/Screens/Select/BeatmapInfoWedge.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Database/BeatmapDatabase.cs b/osu.Game/Database/BeatmapDatabase.cs index de570d3e7e..bd25ebe8a9 100644 --- a/osu.Game/Database/BeatmapDatabase.cs +++ b/osu.Game/Database/BeatmapDatabase.cs @@ -267,7 +267,7 @@ namespace osu.Game.Database public WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo, WorkingBeatmap previous = null, bool withStoryboard = false) { - if (beatmapInfo.BeatmapSet == null) + if (beatmapInfo.BeatmapSet == null || beatmapInfo.Ruleset == null) beatmapInfo = GetChildren(beatmapInfo, true); if (beatmapInfo.BeatmapSet == null) diff --git a/osu.Game/Screens/Select/BeatmapInfoWedge.cs b/osu.Game/Screens/Select/BeatmapInfoWedge.cs index 44f2aeb0da..6a2f7a26fc 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedge.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedge.cs @@ -124,7 +124,7 @@ namespace osu.Game.Screens.Select Content = getBPMRange(beatmap.Beatmap), })); - //get statistics fromt he current ruleset. + //get statistics from the current ruleset. labels.AddRange(beatmapInfo.Ruleset.CreateInstance().GetBeatmapStatistics(beatmap).Select(s => new InfoLabel(s))); } From 6c117f15afa03da81f62d9600331e107a22399d8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 12 May 2017 20:06:38 +0900 Subject: [PATCH 185/329] Remove unnecessary usings --- osu.Game/Overlays/Music/FilterControl.cs | 1 - osu.Game/Overlays/Options/OptionsHeader.cs | 1 - 2 files changed, 2 deletions(-) diff --git a/osu.Game/Overlays/Music/FilterControl.cs b/osu.Game/Overlays/Music/FilterControl.cs index c6572c5ed2..0b4e067fff 100644 --- a/osu.Game/Overlays/Music/FilterControl.cs +++ b/osu.Game/Overlays/Music/FilterControl.cs @@ -10,7 +10,6 @@ using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; -using osu.Game.Screens.Select; using OpenTK; using OpenTK.Graphics; using System; diff --git a/osu.Game/Overlays/Options/OptionsHeader.cs b/osu.Game/Overlays/Options/OptionsHeader.cs index c173b8844d..8b97a607a2 100644 --- a/osu.Game/Overlays/Options/OptionsHeader.cs +++ b/osu.Game/Overlays/Options/OptionsHeader.cs @@ -10,7 +10,6 @@ using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; -using osu.Game.Screens.Select; using OpenTK.Graphics; namespace osu.Game.Overlays.Options From fd9218b6d541795038c9311415523fbdac88837e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 12 May 2017 20:48:25 +0900 Subject: [PATCH 186/329] Use FirstOrDefault --- osu.Game/Overlays/Music/PlaylistOverlay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Music/PlaylistOverlay.cs b/osu.Game/Overlays/Music/PlaylistOverlay.cs index 0cae9db2e6..eb5dff57b3 100644 --- a/osu.Game/Overlays/Music/PlaylistOverlay.cs +++ b/osu.Game/Overlays/Music/PlaylistOverlay.cs @@ -86,7 +86,7 @@ namespace osu.Game.Overlays.Music beatmapBacking.BindTo(game.Beatmap); filter.Search.OnCommit = (sender, newText) => { - var beatmap = list.FirstVisibleSet?.Beatmaps?.ValueAtOrDefault(0); + var beatmap = list.FirstVisibleSet?.Beatmaps?.FirstOrDefault(); if (beatmap != null) playSpecified(beatmap); }; } From 19728b3d98f16bede4fe52613c3cb90069d1fa5b Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Fri, 12 May 2017 15:13:02 +0300 Subject: [PATCH 187/329] Fixed IncompatibleMods for OsuModAutoplay --- osu.Game.Rulesets.Osu/Mods/OsuMod.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuMod.cs b/osu.Game.Rulesets.Osu/Mods/OsuMod.cs index ff277dea1f..cc06946d38 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuMod.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuMod.cs @@ -92,7 +92,7 @@ namespace osu.Game.Rulesets.Osu.Mods public class OsuModAutoplay : ModAutoplay { - public override Type[] IncompatibleMods => base.IncompatibleMods.Concat(new[] { typeof(OsuModAutopilot) }).ToArray(); + public override Type[] IncompatibleMods => base.IncompatibleMods.Concat(new[] { typeof(OsuModAutopilot), typeof(OsuModSpunOut) }).ToArray(); protected override Score CreateReplayScore(Beatmap beatmap) => new Score { From a25f11e8099ff509f7fcd6d3a655db2cd9aed3ee Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 12 May 2017 22:23:32 +0900 Subject: [PATCH 188/329] Initial removal of TimingSection. --- .../Timing/TimeRelativeContainer.cs | 44 ++++++---------- .../Timing/TimingSection.cs | 30 ----------- osu.Game.Rulesets.Mania/UI/Column.cs | 5 +- .../UI/ManiaHitRenderer.cs | 52 +++++++------------ osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 7 +-- .../osu.Game.Rulesets.Mania.csproj | 1 - 6 files changed, 40 insertions(+), 99 deletions(-) delete mode 100644 osu.Game.Rulesets.Mania/Timing/TimingSection.cs diff --git a/osu.Game.Rulesets.Mania/Timing/TimeRelativeContainer.cs b/osu.Game.Rulesets.Mania/Timing/TimeRelativeContainer.cs index c5060eabbb..8ca30488ff 100644 --- a/osu.Game.Rulesets.Mania/Timing/TimeRelativeContainer.cs +++ b/osu.Game.Rulesets.Mania/Timing/TimeRelativeContainer.cs @@ -7,15 +7,16 @@ using System.Linq; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using OpenTK; +using osu.Game.Beatmaps.Timing; namespace osu.Game.Rulesets.Mania.Timing { /// /// A container in which the Y-relative coordinate space is spanned by a length of time. /// - /// This container contains s which scroll inside this container. - /// Drawables added to this container are moved inside the relevant , - /// and as such, will scroll along with the s. + /// This container contains s which scroll inside this container. + /// Drawables added to this container are moved inside the relevant , + /// and as such, will scroll along with the s. /// /// public class TimeRelativeContainer : Container @@ -31,9 +32,9 @@ namespace osu.Game.Rulesets.Mania.Timing private readonly List drawableTimingSections; - public TimeRelativeContainer(IEnumerable timingSections) + public TimeRelativeContainer(IEnumerable timingChanges) { - drawableTimingSections = timingSections.Select(t => new DrawableTimingSection(t)).ToList(); + drawableTimingSections = timingChanges.Select(t => new DrawableTimingSection(t)).ToList(); Children = drawableTimingSections; } @@ -68,13 +69,7 @@ namespace osu.Game.Rulesets.Mania.Timing /// private class DrawableTimingSection : Container { - protected override Container Content => content; - /// - /// The container which will scroll relative to the current time. - /// - private readonly Container content; - - private readonly TimingSection section; + private readonly ControlPoint timingChange; /// /// Creates a drawable timing section. The height of this container will be proportional @@ -84,26 +79,17 @@ namespace osu.Game.Rulesets.Mania.Timing /// which means that the content container will scroll at twice the normal rate. /// /// - /// The section to create the drawable timing section for. - public DrawableTimingSection(TimingSection section) + /// The timing change to create the drawable timing section for. + public DrawableTimingSection(ControlPoint timingChange) { - this.section = section; + this.timingChange = timingChange; Anchor = Anchor.BottomCentre; Origin = Anchor.BottomCentre; RelativeSizeAxes = Axes.Both; - AddInternal(content = new Container - { - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, - RelativePositionAxes = Axes.Both, - RelativeSizeAxes = Axes.Both, - Y = -(float)section.StartTime, - Height = (float)section.Duration, - RelativeCoordinateSpace = new Vector2(1, (float)section.Duration) - }); + Y = -(float)timingChange.Time; } protected override void Update() @@ -111,11 +97,11 @@ namespace osu.Game.Rulesets.Mania.Timing var parent = (TimeRelativeContainer)Parent; // Adjust our height to account for the speed changes - Height = (float)(parent.TimeSpan * 1000 / section.BeatLength); + Height = (float)(parent.TimeSpan * 1000 / timingChange.BeatLength / timingChange.SpeedMultiplier); RelativeCoordinateSpace = new Vector2(1, (float)parent.TimeSpan); // Scroll the content - content.Y = (float)(Time.Current - section.StartTime); + Y = (float)(Time.Current - timingChange.Time); } public override void Add(Drawable drawable) @@ -124,7 +110,7 @@ namespace osu.Game.Rulesets.Mania.Timing // we need to offset it back by our position so that it becomes correctly relatively-positioned to us // This can be removed if hit objects were stored such that either their StartTime or their "beat offset" was relative to the timing section // they belonged to, but this requires a radical change to the beatmap format which we're not ready to do just yet - drawable.Y += (float)section.StartTime; + drawable.Y += (float)timingChange.Time; base.Add(drawable); } @@ -134,7 +120,7 @@ namespace osu.Game.Rulesets.Mania.Timing /// can be placed within the timing section's bounds (in this case, from the start of the timing section up to infinity). /// /// The drawable to check. - public bool CanContain(Drawable drawable) => content.Y >= drawable.Y; + public bool CanContain(Drawable drawable) => Y >= drawable.Y; } } } \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/Timing/TimingSection.cs b/osu.Game.Rulesets.Mania/Timing/TimingSection.cs deleted file mode 100644 index 65a2094c46..0000000000 --- a/osu.Game.Rulesets.Mania/Timing/TimingSection.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Game.Beatmaps.Timing; - -namespace osu.Game.Rulesets.Mania.Timing -{ - /// - /// A point in the map where the beat length or speed multiplier has changed . - /// - public class TimingSection - { - /// - /// The time at which the change occurred. - /// - public double StartTime; - /// - /// The duration of this timing section - lasts until the next timing section. - /// - public double Duration; - /// - /// The beat length, includes any speed multiplier. - /// - public double BeatLength; - /// - /// The time signature of this timing section. - /// - public TimeSignatures TimeSignature; - } -} \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/UI/Column.cs b/osu.Game.Rulesets.Mania/UI/Column.cs index 96f4b17ff8..34d241485c 100644 --- a/osu.Game.Rulesets.Mania/UI/Column.cs +++ b/osu.Game.Rulesets.Mania/UI/Column.cs @@ -17,6 +17,7 @@ using System.Collections.Generic; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Judgements; +using osu.Game.Beatmaps.Timing; namespace osu.Game.Rulesets.Mania.UI { @@ -40,7 +41,7 @@ namespace osu.Game.Rulesets.Mania.UI public readonly TimeRelativeContainer TimingSectionContainer; - public Column(IEnumerable timingSections) + public Column(IEnumerable timingChanges) { RelativeSizeAxes = Axes.Y; Width = column_width; @@ -87,7 +88,7 @@ namespace osu.Game.Rulesets.Mania.UI } } }, - TimingSectionContainer = new TimeRelativeContainer(timingSections) + TimingSectionContainer = new TimeRelativeContainer(timingChanges) { Name = "Hit objects", RelativeSizeAxes = Axes.Both, diff --git a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs index 4cb5b8853b..9b476c4c1a 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs @@ -33,53 +33,37 @@ namespace osu.Game.Rulesets.Mania.UI protected override Playfield CreatePlayfield() { - var timingSections = new List(); + ControlPoint firstTimingChange = Beatmap.TimingInfo.ControlPoints.FirstOrDefault(t => t.TimingChange); - // Construct all the relevant timing sections - ControlPoint lastTimingChange = Beatmap.TimingInfo.ControlPoints.FirstOrDefault(t => t.TimingChange); - - if (lastTimingChange == null) + if (firstTimingChange == null) throw new Exception("The Beatmap contains no timing points!"); - foreach (ControlPoint point in Beatmap.TimingInfo.ControlPoints) + // Generate the timing points, making non-timing changes use the previous timing change + var timingChanges = Beatmap.TimingInfo.ControlPoints.Select(c => { - if (point.TimingChange) - lastTimingChange = point; + ControlPoint t = c.Clone(); - timingSections.Add(new TimingSection - { - StartTime = point.Time, - BeatLength = lastTimingChange.BeatLength / point.SpeedMultiplier, - TimeSignature = point.TimeSignature - }); - } + if (c.TimingChange) + firstTimingChange = c; + else + t.BeatLength = firstTimingChange.BeatLength; + + return t; + }); double lastObjectTime = (Objects.Last() as IHasEndTime)?.EndTime ?? Objects.Last().StartTime; - // Perform some post processing of the timing sections - timingSections = timingSections + // Perform some post processing of the timing changes + timingChanges = timingChanges // Collapse sections after the last hit object - .Where(s => s.StartTime <= lastObjectTime) + .Where(s => s.Time <= lastObjectTime) // Collapse sections with the same start time - .GroupBy(s => s.StartTime).Select(g => g.Last()).OrderBy(s => s.StartTime) + .GroupBy(s => s.Time).Select(g => g.Last()).OrderBy(s => s.Time) // Collapse sections with the same beat length - .GroupBy(s => s.BeatLength).Select(g => g.First()) + .GroupBy(s => s.BeatLength * s.SpeedMultiplier).Select(g => g.First()) .ToList(); - // Determine duration of timing sections - for (int i = 0; i < timingSections.Count; i++) - { - if (i < timingSections.Count - 1) - timingSections[i].Duration = timingSections[i + 1].StartTime - timingSections[i].StartTime; - else - { - // Extra length added for the last timing section to extend past the last hitobject - double extraLength = timingSections[i].BeatLength * (int)timingSections[i].TimeSignature; - timingSections[i].Duration = lastObjectTime + extraLength - timingSections[i].StartTime; - } - } - - return new ManiaPlayfield(Columns ?? (int)Math.Round(Beatmap.BeatmapInfo.Difficulty.CircleSize), timingSections) + return new ManiaPlayfield(Columns ?? (int)Math.Round(Beatmap.BeatmapInfo.Difficulty.CircleSize), timingChanges) { Anchor = Anchor.Centre, Origin = Anchor.Centre diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index 46fe64ff66..2461ed458f 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -20,6 +20,7 @@ using osu.Framework.Extensions.IEnumerableExtensions; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Mania.Timing; using osu.Framework.Input; +using osu.Game.Beatmaps.Timing; namespace osu.Game.Rulesets.Mania.UI { @@ -62,7 +63,7 @@ namespace osu.Game.Rulesets.Mania.UI private readonly int columnCount; - public ManiaPlayfield(int columnCount, IEnumerable timingSections) + public ManiaPlayfield(int columnCount, IEnumerable timingChanges) { this.columnCount = columnCount; @@ -94,7 +95,7 @@ namespace osu.Game.Rulesets.Mania.UI Padding = new MarginPadding { Left = 1, Right = 1 }, Spacing = new Vector2(1, 0) }, - barlineContainer = new TimeRelativeContainer(timingSections) + barlineContainer = new TimeRelativeContainer(timingChanges) { Name = "Bar lines", Anchor = Anchor.BottomCentre, @@ -107,7 +108,7 @@ namespace osu.Game.Rulesets.Mania.UI }; for (int i = 0; i < columnCount; i++) - Columns.Add(new Column(timingSections)); + Columns.Add(new Column(timingChanges)); TimeSpan = time_span_default; } diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index 7ee397e0ea..70c875fd34 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -58,7 +58,6 @@ - From 86ebd9d663a2de0b8f0f133402ea22804a40814a Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Sat, 13 May 2017 02:51:58 +0300 Subject: [PATCH 189/329] spinner's progress depends on current map OD now --- .../Objects/Drawables/DrawableSpinner.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs index 90a6d432c4..0e0784c8ba 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs @@ -10,6 +10,8 @@ using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces; using OpenTK; using OpenTK.Graphics; using osu.Game.Rulesets.Osu.UI; +using osu.Game.Beatmaps; +using osu.Framework.Allocation; namespace osu.Game.Rulesets.Osu.Objects.Drawables { @@ -22,6 +24,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables private readonly Container circleContainer; private readonly DrawableHitCircle circle; + private WorkingBeatmap currentBeatmap; + public DrawableSpinner(Spinner s) : base(s) { AlwaysReceiveInput = true; @@ -71,6 +75,12 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables disc.Scale = scaleToCircle; } + [BackgroundDependencyLoader(permitNulls: true)] + private void load(OsuGame game) + { + currentBeatmap = game?.Beatmap?.Value; + } + protected override void CheckJudgement(bool userTriggered) { if (Time.Current < HitObject.StartTime) return; @@ -108,9 +118,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables private Vector2 scaleToCircle => circle.Scale * circle.DrawWidth / DrawWidth * 0.95f; - private const float spins_per_minute_needed = 100 + 5 * 15; //TODO: read per-map OD and place it on the 5 + private float spinsPerMinuteNeeded => 100 + (currentBeatmap?.Beatmap.BeatmapInfo.Difficulty.OverallDifficulty ?? 5) * 15; - private float rotationsNeeded => (float)(spins_per_minute_needed * (spinner.EndTime - spinner.StartTime) / 60000f); + private float rotationsNeeded => (float)(spinsPerMinuteNeeded * (spinner.EndTime - spinner.StartTime) / 60000f); public float Progress => MathHelper.Clamp(disc.RotationAbsolute / 360 / rotationsNeeded, 0, 1); From 5532d3ec496b9cb9171efd19fbc18dcb2ecfdc53 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Sat, 13 May 2017 03:04:40 +0300 Subject: [PATCH 190/329] storing OD value only --- osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs index 0e0784c8ba..2586f246e5 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs @@ -24,7 +24,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables private readonly Container circleContainer; private readonly DrawableHitCircle circle; - private WorkingBeatmap currentBeatmap; + private float beatmapOD; public DrawableSpinner(Spinner s) : base(s) { @@ -78,7 +78,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables [BackgroundDependencyLoader(permitNulls: true)] private void load(OsuGame game) { - currentBeatmap = game?.Beatmap?.Value; + beatmapOD = game?.Beatmap?.Value.Beatmap.BeatmapInfo.Difficulty.OverallDifficulty ?? 5; } protected override void CheckJudgement(bool userTriggered) @@ -118,7 +118,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables private Vector2 scaleToCircle => circle.Scale * circle.DrawWidth / DrawWidth * 0.95f; - private float spinsPerMinuteNeeded => 100 + (currentBeatmap?.Beatmap.BeatmapInfo.Difficulty.OverallDifficulty ?? 5) * 15; + private float spinsPerMinuteNeeded => 100 + beatmapOD * 15; private float rotationsNeeded => (float)(spinsPerMinuteNeeded * (spinner.EndTime - spinner.StartTime) / 60000f); From 6d9e11a74f8ff7be393e340d3ae80744b0b6eae2 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Sat, 13 May 2017 03:10:13 +0300 Subject: [PATCH 191/329] CI fixes --- osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs index 2586f246e5..59a381149c 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs @@ -10,7 +10,6 @@ using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces; using OpenTK; using OpenTK.Graphics; using osu.Game.Rulesets.Osu.UI; -using osu.Game.Beatmaps; using osu.Framework.Allocation; namespace osu.Game.Rulesets.Osu.Objects.Drawables @@ -24,7 +23,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables private readonly Container circleContainer; private readonly DrawableHitCircle circle; - private float beatmapOD; + private float beatmapOd; public DrawableSpinner(Spinner s) : base(s) { @@ -78,7 +77,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables [BackgroundDependencyLoader(permitNulls: true)] private void load(OsuGame game) { - beatmapOD = game?.Beatmap?.Value.Beatmap.BeatmapInfo.Difficulty.OverallDifficulty ?? 5; + beatmapOd = game?.Beatmap?.Value.Beatmap.BeatmapInfo.Difficulty.OverallDifficulty ?? 5; } protected override void CheckJudgement(bool userTriggered) @@ -118,7 +117,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables private Vector2 scaleToCircle => circle.Scale * circle.DrawWidth / DrawWidth * 0.95f; - private float spinsPerMinuteNeeded => 100 + beatmapOD * 15; + private float spinsPerMinuteNeeded => 100 + beatmapOd * 15; private float rotationsNeeded => (float)(spinsPerMinuteNeeded * (spinner.EndTime - spinner.StartTime) / 60000f); From ca6df533bd128837b49291c3fc917e8e09fc3f88 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Sat, 13 May 2017 03:46:37 +0300 Subject: [PATCH 192/329] 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 ef234057334eb899030e824d837cf6d53b80ebc1 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Sun, 14 May 2017 06:45:35 +0300 Subject: [PATCH 193/329] Applied suggested changes --- .../Objects/Drawables/DrawableSpinner.cs | 15 +-------------- osu.Game.Rulesets.Osu/Objects/Spinner.cs | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs index 59a381149c..e06e72a8bf 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs @@ -10,7 +10,6 @@ using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces; using OpenTK; using OpenTK.Graphics; using osu.Game.Rulesets.Osu.UI; -using osu.Framework.Allocation; namespace osu.Game.Rulesets.Osu.Objects.Drawables { @@ -23,8 +22,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables private readonly Container circleContainer; private readonly DrawableHitCircle circle; - private float beatmapOd; - public DrawableSpinner(Spinner s) : base(s) { AlwaysReceiveInput = true; @@ -74,12 +71,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables disc.Scale = scaleToCircle; } - [BackgroundDependencyLoader(permitNulls: true)] - private void load(OsuGame game) - { - beatmapOd = game?.Beatmap?.Value.Beatmap.BeatmapInfo.Difficulty.OverallDifficulty ?? 5; - } - protected override void CheckJudgement(bool userTriggered) { if (Time.Current < HitObject.StartTime) return; @@ -117,11 +108,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables private Vector2 scaleToCircle => circle.Scale * circle.DrawWidth / DrawWidth * 0.95f; - private float spinsPerMinuteNeeded => 100 + beatmapOd * 15; - - private float rotationsNeeded => (float)(spinsPerMinuteNeeded * (spinner.EndTime - spinner.StartTime) / 60000f); - - public float Progress => MathHelper.Clamp(disc.RotationAbsolute / 360 / rotationsNeeded, 0, 1); + public float Progress => MathHelper.Clamp(disc.RotationAbsolute / 360 / (float)spinner.SpinsRequired, 0, 1); protected override void UpdatePreemptState() { diff --git a/osu.Game.Rulesets.Osu/Objects/Spinner.cs b/osu.Game.Rulesets.Osu/Objects/Spinner.cs index 0a2c05833a..ab5d03dadc 100644 --- a/osu.Game.Rulesets.Osu/Objects/Spinner.cs +++ b/osu.Game.Rulesets.Osu/Objects/Spinner.cs @@ -2,6 +2,8 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Game.Rulesets.Objects.Types; +using osu.Game.Beatmaps.Timing; +using osu.Game.Database; namespace osu.Game.Rulesets.Osu.Objects { @@ -10,6 +12,18 @@ namespace osu.Game.Rulesets.Osu.Objects public double EndTime { get; set; } public double Duration => EndTime - StartTime; + /// + /// Number of spins required to finish the spinner without miss. + /// + public double SpinsRequired { get; protected set; } + public override bool NewCombo => true; + + public override void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty) + { + base.ApplyDefaults(timing, difficulty); + + SpinsRequired = Duration / 1000 * BeatmapDifficulty.DifficultyRange(difficulty.OverallDifficulty, 3, 5, 7.5); + } } } From 12dab6f75c93d586e9b715e98ac34836d7a16f92 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Sun, 14 May 2017 07:28:12 +0300 Subject: [PATCH 194/329] 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 195/329] 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 a4d5660e418cf3c4a3b0af93512b3e8012c04b0d Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Sun, 14 May 2017 09:22:49 +0300 Subject: [PATCH 196/329] Cast SpinsRequired value to int --- osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs | 2 +- osu.Game.Rulesets.Osu/Objects/Spinner.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs index e06e72a8bf..a8ff231cc7 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs @@ -108,7 +108,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables private Vector2 scaleToCircle => circle.Scale * circle.DrawWidth / DrawWidth * 0.95f; - public float Progress => MathHelper.Clamp(disc.RotationAbsolute / 360 / (float)spinner.SpinsRequired, 0, 1); + public float Progress => MathHelper.Clamp(disc.RotationAbsolute / 360 / spinner.SpinsRequired, 0, 1); protected override void UpdatePreemptState() { diff --git a/osu.Game.Rulesets.Osu/Objects/Spinner.cs b/osu.Game.Rulesets.Osu/Objects/Spinner.cs index ab5d03dadc..04ed7798af 100644 --- a/osu.Game.Rulesets.Osu/Objects/Spinner.cs +++ b/osu.Game.Rulesets.Osu/Objects/Spinner.cs @@ -15,7 +15,7 @@ namespace osu.Game.Rulesets.Osu.Objects /// /// Number of spins required to finish the spinner without miss. /// - public double SpinsRequired { get; protected set; } + public int SpinsRequired { get; protected set; } public override bool NewCombo => true; @@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Osu.Objects { base.ApplyDefaults(timing, difficulty); - SpinsRequired = Duration / 1000 * BeatmapDifficulty.DifficultyRange(difficulty.OverallDifficulty, 3, 5, 7.5); + SpinsRequired = (int)(Duration / 1000 * BeatmapDifficulty.DifficultyRange(difficulty.OverallDifficulty, 3, 5, 7.5)); } } } From 7055c99df07b05fb43689f4d357ede4b1ce75d56 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Sun, 14 May 2017 09:36:09 +0300 Subject: [PATCH 197/329] Added default value --- osu.Game.Rulesets.Osu/Objects/Spinner.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/Objects/Spinner.cs b/osu.Game.Rulesets.Osu/Objects/Spinner.cs index 04ed7798af..3761b62b65 100644 --- a/osu.Game.Rulesets.Osu/Objects/Spinner.cs +++ b/osu.Game.Rulesets.Osu/Objects/Spinner.cs @@ -15,7 +15,7 @@ namespace osu.Game.Rulesets.Osu.Objects /// /// Number of spins required to finish the spinner without miss. /// - public int SpinsRequired { get; protected set; } + public int SpinsRequired { get; protected set; } = 1; public override bool NewCombo => true; From b6460d89c97c7220639230d00ac9151fe9c56f26 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Sun, 14 May 2017 10:26:52 +0300 Subject: [PATCH 198/329] 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 eaaba11586f2c3cadf8f541746eb90b331c136a5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 15 May 2017 10:55:29 +0900 Subject: [PATCH 199/329] Change all instances of options to settings where applicable --- osu-framework | 2 +- ...TestCaseOptions.cs => TestCaseSettings.cs} | 10 +-- .../osu.Desktop.VisualTests.csproj | 2 +- osu.Game/OsuGame.cs | 20 ++--- osu.Game/Overlays/LoginOverlay.cs | 12 +-- .../Sections/Audio/AudioDevicesSettings.cs} | 8 +- .../Sections/Audio/MainMenuSettings.cs} | 8 +- .../Sections/Audio/OffsetSettings.cs} | 6 +- .../Sections/Audio/VolumeSettings.cs} | 10 +-- .../Sections/AudioSection.cs | 14 ++-- .../Sections/Debug/GCSettings.cs} | 6 +- .../Sections/Debug/GeneralSettings.cs} | 6 +- .../Sections/DebugSection.cs | 10 +-- .../Sections/Gameplay/GeneralSettings.cs} | 10 +-- .../Sections/Gameplay/SongSelectSettings.cs} | 8 +- .../Sections/GameplaySection.cs | 10 +-- .../Sections/General/LanguageSettings.cs} | 8 +- .../Sections/General/LoginSettings.cs} | 8 +- .../Sections/General/UpdateSettings.cs} | 6 +- .../Sections/GeneralSection.cs | 10 +-- .../Sections/Graphics/DetailSettings.cs} | 8 +- .../Sections/Graphics/LayoutSettings.cs} | 24 +++--- .../Sections/Graphics/MainMenuSettings.cs} | 6 +- .../Sections/Graphics/RendererSettings.cs} | 10 +-- .../Sections/GraphicsSection.cs | 14 ++-- .../Sections/Input/KeyboardSettings.cs} | 6 +- .../Sections/Input/MouseSettings.cs} | 12 +-- .../Sections/InputSection.cs | 10 +-- .../Sections/MaintenanceSection.cs | 4 +- .../Sections/OnlineSection.cs | 4 +- .../Sections/SkinSection.cs | 8 +- .../SettingsCheckbox.cs} | 4 +- .../SettingsDropdown.cs} | 4 +- .../SettingsEnumDropdown.cs} | 8 +- .../SettingsFooter.cs} | 4 +- .../SettingsHeader.cs} | 10 +-- .../SettingsItem.cs} | 8 +- .../SettingsLabel.cs} | 4 +- .../SettingsSection.cs} | 10 +-- .../SettingsSlider.cs} | 6 +- .../SettingsSubsection.cs} | 6 +- .../SettingsTextBox.cs} | 4 +- .../Overlays/{Options => Settings}/Sidebar.cs | 2 +- .../{Options => Settings}/SidebarButton.cs | 6 +- .../{OptionsOverlay.cs => SettingsOverlay.cs} | 26 +++--- .../Overlays/Toolbar/ToolbarSettingsButton.cs | 4 +- osu.Game/Screens/Menu/ButtonSystem.cs | 2 +- osu.Game/Screens/Menu/MainMenu.cs | 2 +- .../Select/Options/BeatmapOptionsButton.cs | 6 +- .../Select/Options/BeatmapOptionsOverlay.cs | 6 +- osu.Game/osu.Game.csproj | 84 +++++++++---------- 51 files changed, 243 insertions(+), 243 deletions(-) rename osu.Desktop.VisualTests/Tests/{TestCaseOptions.cs => TestCaseSettings.cs} (54%) rename osu.Game/Overlays/{Options/Sections/Audio/AudioDevicesOptions.cs => Settings/Sections/Audio/AudioDevicesSettings.cs} (88%) rename osu.Game/Overlays/{Options/Sections/Audio/MainMenuOptions.cs => Settings/Sections/Audio/MainMenuSettings.cs} (78%) rename osu.Game/Overlays/{Options/Sections/Audio/OffsetOptions.cs => Settings/Sections/Audio/OffsetSettings.cs} (83%) rename osu.Game/Overlays/{Options/Sections/Audio/VolumeOptions.cs => Settings/Sections/Audio/VolumeSettings.cs} (53%) rename osu.Game/Overlays/{Options => Settings}/Sections/AudioSection.cs (58%) rename osu.Game/Overlays/{Options/Sections/Debug/GCOptions.cs => Settings/Sections/Debug/GCSettings.cs} (83%) rename osu.Game/Overlays/{Options/Sections/Debug/GeneralOptions.cs => Settings/Sections/Debug/GeneralSettings.cs} (80%) rename osu.Game/Overlays/{Options => Settings}/Sections/DebugSection.cs (65%) rename osu.Game/Overlays/{Options/Sections/Gameplay/GeneralOptions.cs => Settings/Sections/Gameplay/GeneralSettings.cs} (79%) rename osu.Game/Overlays/{Options/Sections/Gameplay/SongSelectOptions.cs => Settings/Sections/Gameplay/SongSelectSettings.cs} (80%) rename osu.Game/Overlays/{Options => Settings}/Sections/GameplaySection.cs (64%) rename osu.Game/Overlays/{Options/Sections/General/LanguageOptions.cs => Settings/Sections/General/LanguageSettings.cs} (77%) rename osu.Game/Overlays/{Options/Sections/General/LoginOptions.cs => Settings/Sections/General/LoginSettings.cs} (93%) rename osu.Game/Overlays/{Options/Sections/General/UpdateOptions.cs => Settings/Sections/General/UpdateSettings.cs} (83%) rename osu.Game/Overlays/{Options => Settings}/Sections/GeneralSection.cs (64%) rename osu.Game/Overlays/{Options/Sections/Graphics/DetailOptions.cs => Settings/Sections/Graphics/DetailSettings.cs} (79%) rename osu.Game/Overlays/{Options/Sections/Graphics/LayoutOptions.cs => Settings/Sections/Graphics/LayoutSettings.cs} (70%) rename osu.Game/Overlays/{Options/Sections/Graphics/MainMenuOptions.cs => Settings/Sections/Graphics/MainMenuSettings.cs} (78%) rename osu.Game/Overlays/{Options/Sections/Graphics/RendererOptions.cs => Settings/Sections/Graphics/RendererSettings.cs} (79%) rename osu.Game/Overlays/{Options => Settings}/Sections/GraphicsSection.cs (58%) rename osu.Game/Overlays/{Options/Sections/Input/KeyboardOptions.cs => Settings/Sections/Input/KeyboardSettings.cs} (76%) rename osu.Game/Overlays/{Options/Sections/Input/MouseOptions.cs => Settings/Sections/Input/MouseSettings.cs} (80%) rename osu.Game/Overlays/{Options => Settings}/Sections/InputSection.cs (65%) rename osu.Game/Overlays/{Options => Settings}/Sections/MaintenanceSection.cs (81%) rename osu.Game/Overlays/{Options => Settings}/Sections/OnlineSection.cs (79%) rename osu.Game/Overlays/{Options => Settings}/Sections/SkinSection.cs (83%) rename osu.Game/Overlays/{Options/OptionCheckbox.cs => Settings/SettingsCheckbox.cs} (82%) rename osu.Game/Overlays/{Options/OptionDropdown.cs => Settings/SettingsDropdown.cs} (88%) rename osu.Game/Overlays/{Options/OptionEnumDropdown.cs => Settings/SettingsEnumDropdown.cs} (75%) rename osu.Game/Overlays/{Options/OptionsFooter.cs => Settings/SettingsFooter.cs} (93%) rename osu.Game/Overlays/{Options/OptionsHeader.cs => Settings/SettingsHeader.cs} (90%) rename osu.Game/Overlays/{Options/OptionItem.cs => Settings/SettingsItem.cs} (89%) rename osu.Game/Overlays/{Options/OptionLabel.cs => Settings/SettingsLabel.cs} (80%) rename osu.Game/Overlays/{Options/OptionsSection.cs => Settings/SettingsSection.cs} (88%) rename osu.Game/Overlays/{Options/OptionSlider.cs => Settings/SettingsSlider.cs} (76%) rename osu.Game/Overlays/{Options/OptionsSubsection.cs => Settings/SettingsSubsection.cs} (87%) rename osu.Game/Overlays/{Options/OptionTextBox.cs => Settings/SettingsTextBox.cs} (74%) rename osu.Game/Overlays/{Options => Settings}/Sidebar.cs (95%) rename osu.Game/Overlays/{Options => Settings}/SidebarButton.cs (93%) rename osu.Game/Overlays/{OptionsOverlay.cs => SettingsOverlay.cs} (86%) diff --git a/osu-framework b/osu-framework index e1ac6316aa..f699dfe3c9 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit e1ac6316aa3862efb8e79e585a7b4c901a4e1b3c +Subproject commit f699dfe3c995c43b15cd66ec094d628bac1697c0 diff --git a/osu.Desktop.VisualTests/Tests/TestCaseOptions.cs b/osu.Desktop.VisualTests/Tests/TestCaseSettings.cs similarity index 54% rename from osu.Desktop.VisualTests/Tests/TestCaseOptions.cs rename to osu.Desktop.VisualTests/Tests/TestCaseSettings.cs index ff6bdc8a5a..660085e558 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseOptions.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseSettings.cs @@ -6,18 +6,18 @@ using osu.Game.Overlays; namespace osu.Desktop.VisualTests.Tests { - internal class TestCaseOptions : TestCase + internal class TestCaseSettings : TestCase { - public override string Description => @"Tests the options overlay"; + public override string Description => @"Tests the settings overlay"; - private OptionsOverlay options; + private SettingsOverlay settings; public override void Reset() { base.Reset(); - Children = new[] { options = new OptionsOverlay() }; - options.ToggleVisibility(); + Children = new[] { settings = new SettingsOverlay() }; + settings.ToggleVisibility(); } } } diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index 66cad48964..9b07ebf90b 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -211,7 +211,7 @@ - + diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index a84333df8c..8d9d5cd26c 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -62,14 +62,14 @@ namespace osu.Game private readonly string[] args; - private OptionsOverlay options; + private SettingsOverlay settings; public OsuGame(string[] args = null) { this.args = args; } - public void ToggleOptions() => options.ToggleVisibility(); + public void ToggleSettings() => settings.ToggleVisibility(); [BackgroundDependencyLoader] private void load() @@ -161,7 +161,7 @@ namespace osu.Game //overlay elements LoadComponentAsync(chat = new ChatOverlay { Depth = -1 }, mainContent.Add); - LoadComponentAsync(options = new OptionsOverlay { Depth = -1 }, overlayContent.Add); + LoadComponentAsync(settings = new SettingsOverlay { Depth = -1 }, overlayContent.Add); LoadComponentAsync(musicController = new MusicController { Depth = -2, @@ -192,7 +192,7 @@ namespace osu.Game }); }; - Dependencies.Cache(options); + Dependencies.Cache(settings); Dependencies.Cache(chat); Dependencies.Cache(musicController); Dependencies.Cache(notificationManager); @@ -204,15 +204,15 @@ namespace osu.Game OnHome = delegate { intro?.ChildScreen?.MakeCurrent(); }, }, overlayContent.Add); - options.StateChanged += delegate + settings.StateChanged += delegate { - switch (options.State) + switch (settings.State) { case Visibility.Hidden: - intro.MoveToX(0, OptionsOverlay.TRANSITION_LENGTH, EasingTypes.OutQuint); + intro.MoveToX(0, SettingsOverlay.TRANSITION_LENGTH, EasingTypes.OutQuint); break; case Visibility.Visible: - intro.MoveToX(OptionsOverlay.SIDEBAR_WIDTH / 2, OptionsOverlay.TRANSITION_LENGTH, EasingTypes.OutQuint); + intro.MoveToX(SettingsOverlay.SIDEBAR_WIDTH / 2, SettingsOverlay.TRANSITION_LENGTH, EasingTypes.OutQuint); break; } }; @@ -247,7 +247,7 @@ namespace osu.Game Toolbar.ToggleVisibility(); return true; case Key.O: - options.ToggleVisibility(); + settings.ToggleVisibility(); return true; } } @@ -276,7 +276,7 @@ namespace osu.Game //central game screen change logic. if (!currentScreen.ShowOverlays) { - options.State = Visibility.Hidden; + settings.State = Visibility.Hidden; Toolbar.State = Visibility.Hidden; musicController.State = Visibility.Hidden; chat.State = Visibility.Hidden; diff --git a/osu.Game/Overlays/LoginOverlay.cs b/osu.Game/Overlays/LoginOverlay.cs index 694eba2c41..8c4a3b85c0 100644 --- a/osu.Game/Overlays/LoginOverlay.cs +++ b/osu.Game/Overlays/LoginOverlay.cs @@ -7,14 +7,14 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; -using osu.Game.Overlays.Options.Sections.General; +using osu.Game.Overlays.Settings.Sections.General; using OpenTK.Graphics; namespace osu.Game.Overlays { internal class LoginOverlay : FocusedOverlayContainer { - private LoginOptions optionsSection; + private LoginSettings settingsSection; private const float transition_time = 400; @@ -42,7 +42,7 @@ namespace osu.Game.Overlays AutoSizeEasing = EasingTypes.OutQuint, Children = new Drawable[] { - optionsSection = new LoginOptions + settingsSection = new LoginSettings { Padding = new MarginPadding(10), }, @@ -64,17 +64,17 @@ namespace osu.Game.Overlays { base.PopIn(); - optionsSection.Bounding = true; + settingsSection.Bounding = true; FadeIn(transition_time, EasingTypes.OutQuint); - optionsSection.TriggerFocus(); + settingsSection.TriggerFocus(); } protected override void PopOut() { base.PopOut(); - optionsSection.Bounding = false; + settingsSection.Bounding = false; FadeOut(transition_time); } } diff --git a/osu.Game/Overlays/Options/Sections/Audio/AudioDevicesOptions.cs b/osu.Game/Overlays/Settings/Sections/Audio/AudioDevicesSettings.cs similarity index 88% rename from osu.Game/Overlays/Options/Sections/Audio/AudioDevicesOptions.cs rename to osu.Game/Overlays/Settings/Sections/Audio/AudioDevicesSettings.cs index e3033b876d..47f7abf571 100644 --- a/osu.Game/Overlays/Options/Sections/Audio/AudioDevicesOptions.cs +++ b/osu.Game/Overlays/Settings/Sections/Audio/AudioDevicesSettings.cs @@ -7,14 +7,14 @@ using osu.Framework.Graphics; using System.Collections.Generic; using System.Linq; -namespace osu.Game.Overlays.Options.Sections.Audio +namespace osu.Game.Overlays.Settings.Sections.Audio { - public class AudioDevicesOptions : OptionsSubsection + public class AudioDevicesSettings : SettingsSubsection { protected override string Header => "Devices"; private AudioManager audio; - private OptionDropdown dropdown; + private SettingsDropdown dropdown; [BackgroundDependencyLoader] private void load(AudioManager audio) @@ -56,7 +56,7 @@ namespace osu.Game.Overlays.Options.Sections.Audio Children = new Drawable[] { - dropdown = new OptionDropdown + dropdown = new SettingsDropdown { Bindable = audio.AudioDevice }, diff --git a/osu.Game/Overlays/Options/Sections/Audio/MainMenuOptions.cs b/osu.Game/Overlays/Settings/Sections/Audio/MainMenuSettings.cs similarity index 78% rename from osu.Game/Overlays/Options/Sections/Audio/MainMenuOptions.cs rename to osu.Game/Overlays/Settings/Sections/Audio/MainMenuSettings.cs index b2d1235b97..8101720d04 100644 --- a/osu.Game/Overlays/Options/Sections/Audio/MainMenuOptions.cs +++ b/osu.Game/Overlays/Settings/Sections/Audio/MainMenuSettings.cs @@ -4,9 +4,9 @@ using osu.Framework.Allocation; using osu.Game.Configuration; -namespace osu.Game.Overlays.Options.Sections.Audio +namespace osu.Game.Overlays.Settings.Sections.Audio { - public class MainMenuOptions : OptionsSubsection + public class MainMenuSettings : SettingsSubsection { protected override string Header => "Main Menu"; @@ -15,12 +15,12 @@ namespace osu.Game.Overlays.Options.Sections.Audio { Children = new[] { - new OptionCheckbox + new SettingsCheckbox { LabelText = "Interface voices", Bindable = config.GetBindable(OsuConfig.MenuVoice) }, - new OptionCheckbox + new SettingsCheckbox { LabelText = "osu! music theme", Bindable = config.GetBindable(OsuConfig.MenuMusic) diff --git a/osu.Game/Overlays/Options/Sections/Audio/OffsetOptions.cs b/osu.Game/Overlays/Settings/Sections/Audio/OffsetSettings.cs similarity index 83% rename from osu.Game/Overlays/Options/Sections/Audio/OffsetOptions.cs rename to osu.Game/Overlays/Settings/Sections/Audio/OffsetSettings.cs index 72c3dd071a..593002eb36 100644 --- a/osu.Game/Overlays/Options/Sections/Audio/OffsetOptions.cs +++ b/osu.Game/Overlays/Settings/Sections/Audio/OffsetSettings.cs @@ -6,9 +6,9 @@ using osu.Framework.Graphics; using osu.Game.Configuration; using osu.Game.Graphics.UserInterface; -namespace osu.Game.Overlays.Options.Sections.Audio +namespace osu.Game.Overlays.Settings.Sections.Audio { - public class OffsetOptions : OptionsSubsection + public class OffsetSettings : SettingsSubsection { protected override string Header => "Offset Adjustment"; @@ -17,7 +17,7 @@ namespace osu.Game.Overlays.Options.Sections.Audio { Children = new Drawable[] { - new OptionSlider + new SettingsSlider { LabelText = "Audio Offset", Bindable = config.GetBindable(OsuConfig.AudioOffset) diff --git a/osu.Game/Overlays/Options/Sections/Audio/VolumeOptions.cs b/osu.Game/Overlays/Settings/Sections/Audio/VolumeSettings.cs similarity index 53% rename from osu.Game/Overlays/Options/Sections/Audio/VolumeOptions.cs rename to osu.Game/Overlays/Settings/Sections/Audio/VolumeSettings.cs index c3eb04da13..ea442cdfc2 100644 --- a/osu.Game/Overlays/Options/Sections/Audio/VolumeOptions.cs +++ b/osu.Game/Overlays/Settings/Sections/Audio/VolumeSettings.cs @@ -5,9 +5,9 @@ using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Graphics; -namespace osu.Game.Overlays.Options.Sections.Audio +namespace osu.Game.Overlays.Settings.Sections.Audio { - public class VolumeOptions : OptionsSubsection + public class VolumeSettings : SettingsSubsection { protected override string Header => "Volume"; @@ -16,9 +16,9 @@ namespace osu.Game.Overlays.Options.Sections.Audio { Children = new Drawable[] { - new OptionSlider { LabelText = "Master", Bindable = audio.Volume }, - new OptionSlider { LabelText = "Effect", Bindable = audio.VolumeSample }, - new OptionSlider { LabelText = "Music", Bindable = audio.VolumeTrack }, + new SettingsSlider { LabelText = "Master", Bindable = audio.Volume }, + new SettingsSlider { LabelText = "Effect", Bindable = audio.VolumeSample }, + new SettingsSlider { LabelText = "Music", Bindable = audio.VolumeTrack }, }; } } diff --git a/osu.Game/Overlays/Options/Sections/AudioSection.cs b/osu.Game/Overlays/Settings/Sections/AudioSection.cs similarity index 58% rename from osu.Game/Overlays/Options/Sections/AudioSection.cs rename to osu.Game/Overlays/Settings/Sections/AudioSection.cs index a9f8265a68..c994a6296c 100644 --- a/osu.Game/Overlays/Options/Sections/AudioSection.cs +++ b/osu.Game/Overlays/Settings/Sections/AudioSection.cs @@ -3,11 +3,11 @@ using osu.Framework.Graphics; using osu.Game.Graphics; -using osu.Game.Overlays.Options.Sections.Audio; +using osu.Game.Overlays.Settings.Sections.Audio; -namespace osu.Game.Overlays.Options.Sections +namespace osu.Game.Overlays.Settings.Sections { - public class AudioSection : OptionsSection + public class AudioSection : SettingsSection { public override string Header => "Audio"; public override FontAwesome Icon => FontAwesome.fa_headphones; @@ -16,10 +16,10 @@ namespace osu.Game.Overlays.Options.Sections { Children = new Drawable[] { - new AudioDevicesOptions(), - new VolumeOptions(), - new OffsetOptions(), - new MainMenuOptions(), + new AudioDevicesSettings(), + new VolumeSettings(), + new OffsetSettings(), + new MainMenuSettings(), }; } } diff --git a/osu.Game/Overlays/Options/Sections/Debug/GCOptions.cs b/osu.Game/Overlays/Settings/Sections/Debug/GCSettings.cs similarity index 83% rename from osu.Game/Overlays/Options/Sections/Debug/GCOptions.cs rename to osu.Game/Overlays/Settings/Sections/Debug/GCSettings.cs index 4350625d51..29b96a59c2 100644 --- a/osu.Game/Overlays/Options/Sections/Debug/GCOptions.cs +++ b/osu.Game/Overlays/Settings/Sections/Debug/GCSettings.cs @@ -8,9 +8,9 @@ using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Game.Graphics.UserInterface; -namespace osu.Game.Overlays.Options.Sections.Debug +namespace osu.Game.Overlays.Settings.Sections.Debug { - public class GCOptions : OptionsSubsection + public class GCSettings : SettingsSubsection { protected override string Header => "Garbage Collector"; @@ -19,7 +19,7 @@ namespace osu.Game.Overlays.Options.Sections.Debug { Children = new Drawable[] { - new OptionEnumDropdown + new SettingsEnumDropdown { LabelText = "Active mode", Bindable = config.GetBindable(FrameworkDebugConfig.ActiveGCMode) diff --git a/osu.Game/Overlays/Options/Sections/Debug/GeneralOptions.cs b/osu.Game/Overlays/Settings/Sections/Debug/GeneralSettings.cs similarity index 80% rename from osu.Game/Overlays/Options/Sections/Debug/GeneralOptions.cs rename to osu.Game/Overlays/Settings/Sections/Debug/GeneralSettings.cs index 9258b8fbeb..9fbb4011b7 100644 --- a/osu.Game/Overlays/Options/Sections/Debug/GeneralOptions.cs +++ b/osu.Game/Overlays/Settings/Sections/Debug/GeneralSettings.cs @@ -5,9 +5,9 @@ using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; -namespace osu.Game.Overlays.Options.Sections.Debug +namespace osu.Game.Overlays.Settings.Sections.Debug { - public class GeneralOptions : OptionsSubsection + public class GeneralSettings : SettingsSubsection { protected override string Header => "General"; @@ -16,7 +16,7 @@ namespace osu.Game.Overlays.Options.Sections.Debug { Children = new Drawable[] { - new OptionCheckbox + new SettingsCheckbox { LabelText = "Bypass caching", Bindable = config.GetBindable(FrameworkDebugConfig.BypassCaching) diff --git a/osu.Game/Overlays/Options/Sections/DebugSection.cs b/osu.Game/Overlays/Settings/Sections/DebugSection.cs similarity index 65% rename from osu.Game/Overlays/Options/Sections/DebugSection.cs rename to osu.Game/Overlays/Settings/Sections/DebugSection.cs index a90558a319..05b7171eed 100644 --- a/osu.Game/Overlays/Options/Sections/DebugSection.cs +++ b/osu.Game/Overlays/Settings/Sections/DebugSection.cs @@ -3,11 +3,11 @@ using osu.Framework.Graphics; using osu.Game.Graphics; -using osu.Game.Overlays.Options.Sections.Debug; +using osu.Game.Overlays.Settings.Sections.Debug; -namespace osu.Game.Overlays.Options.Sections +namespace osu.Game.Overlays.Settings.Sections { - public class DebugSection : OptionsSection + public class DebugSection : SettingsSection { public override string Header => "Debug"; public override FontAwesome Icon => FontAwesome.fa_bug; @@ -16,8 +16,8 @@ namespace osu.Game.Overlays.Options.Sections { Children = new Drawable[] { - new GeneralOptions(), - new GCOptions(), + new GeneralSettings(), + new GCSettings(), }; } } diff --git a/osu.Game/Overlays/Options/Sections/Gameplay/GeneralOptions.cs b/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs similarity index 79% rename from osu.Game/Overlays/Options/Sections/Gameplay/GeneralOptions.cs rename to osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs index 2598d95949..770ec3aaf3 100644 --- a/osu.Game/Overlays/Options/Sections/Gameplay/GeneralOptions.cs +++ b/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs @@ -5,9 +5,9 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Game.Configuration; -namespace osu.Game.Overlays.Options.Sections.Gameplay +namespace osu.Game.Overlays.Settings.Sections.Gameplay { - public class GeneralOptions : OptionsSubsection + public class GeneralSettings : SettingsSubsection { protected override string Header => "General"; @@ -16,17 +16,17 @@ namespace osu.Game.Overlays.Options.Sections.Gameplay { Children = new Drawable[] { - new OptionSlider + new SettingsSlider { LabelText = "Background dim", Bindable = config.GetBindable(OsuConfig.DimLevel) }, - new OptionCheckbox + new SettingsCheckbox { LabelText = "Show score overlay", Bindable = config.GetBindable(OsuConfig.ShowInterface) }, - new OptionCheckbox + new SettingsCheckbox { LabelText = "Always show key overlay", Bindable = config.GetBindable(OsuConfig.KeyOverlay) diff --git a/osu.Game/Overlays/Options/Sections/Gameplay/SongSelectOptions.cs b/osu.Game/Overlays/Settings/Sections/Gameplay/SongSelectSettings.cs similarity index 80% rename from osu.Game/Overlays/Options/Sections/Gameplay/SongSelectOptions.cs rename to osu.Game/Overlays/Settings/Sections/Gameplay/SongSelectSettings.cs index 910eae9a5a..14d6f36535 100644 --- a/osu.Game/Overlays/Options/Sections/Gameplay/SongSelectOptions.cs +++ b/osu.Game/Overlays/Settings/Sections/Gameplay/SongSelectSettings.cs @@ -6,9 +6,9 @@ using osu.Framework.Graphics; using osu.Game.Configuration; using osu.Game.Graphics.UserInterface; -namespace osu.Game.Overlays.Options.Sections.Gameplay +namespace osu.Game.Overlays.Settings.Sections.Gameplay { - public class SongSelectOptions : OptionsSubsection + public class SongSelectSettings : SettingsSubsection { protected override string Header => "Song Select"; @@ -17,12 +17,12 @@ namespace osu.Game.Overlays.Options.Sections.Gameplay { Children = new Drawable[] { - new OptionSlider + new SettingsSlider { LabelText = "Display beatmaps from", Bindable = config.GetBindable(OsuConfig.DisplayStarsMinimum) }, - new OptionSlider + new SettingsSlider { LabelText = "up to", Bindable = config.GetBindable(OsuConfig.DisplayStarsMaximum) diff --git a/osu.Game/Overlays/Options/Sections/GameplaySection.cs b/osu.Game/Overlays/Settings/Sections/GameplaySection.cs similarity index 64% rename from osu.Game/Overlays/Options/Sections/GameplaySection.cs rename to osu.Game/Overlays/Settings/Sections/GameplaySection.cs index 85a180ccbc..be957912c1 100644 --- a/osu.Game/Overlays/Options/Sections/GameplaySection.cs +++ b/osu.Game/Overlays/Settings/Sections/GameplaySection.cs @@ -3,11 +3,11 @@ using osu.Framework.Graphics; using osu.Game.Graphics; -using osu.Game.Overlays.Options.Sections.Gameplay; +using osu.Game.Overlays.Settings.Sections.Gameplay; -namespace osu.Game.Overlays.Options.Sections +namespace osu.Game.Overlays.Settings.Sections { - public class GameplaySection : OptionsSection + public class GameplaySection : SettingsSection { public override string Header => "Gameplay"; public override FontAwesome Icon => FontAwesome.fa_circle_o; @@ -16,8 +16,8 @@ namespace osu.Game.Overlays.Options.Sections { Children = new Drawable[] { - new GeneralOptions(), - new SongSelectOptions(), + new GeneralSettings(), + new SongSelectSettings(), }; } } diff --git a/osu.Game/Overlays/Options/Sections/General/LanguageOptions.cs b/osu.Game/Overlays/Settings/Sections/General/LanguageSettings.cs similarity index 77% rename from osu.Game/Overlays/Options/Sections/General/LanguageOptions.cs rename to osu.Game/Overlays/Settings/Sections/General/LanguageSettings.cs index 2778f2567d..552b8bea1b 100644 --- a/osu.Game/Overlays/Options/Sections/General/LanguageOptions.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LanguageSettings.cs @@ -5,9 +5,9 @@ using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; -namespace osu.Game.Overlays.Options.Sections.General +namespace osu.Game.Overlays.Settings.Sections.General { - public class LanguageOptions : OptionsSubsection + public class LanguageSettings : SettingsSubsection { protected override string Header => "Language"; @@ -16,10 +16,10 @@ namespace osu.Game.Overlays.Options.Sections.General { Children = new Drawable[] { - new OptionCheckbox + new SettingsCheckbox { LabelText = "Prefer metadata in original language", - Bindable = frameworkConfig.GetBindable(FrameworkConfig.ShowUnicode) + Bindable = frameworkConfig.GetBindable(FrameworkSetting.ShowUnicode) }, }; } diff --git a/osu.Game/Overlays/Options/Sections/General/LoginOptions.cs b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs similarity index 93% rename from osu.Game/Overlays/Options/Sections/General/LoginOptions.cs rename to osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs index a3612a6396..3193c2eb5a 100644 --- a/osu.Game/Overlays/Options/Sections/General/LoginOptions.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs @@ -13,9 +13,9 @@ using osu.Game.Online.API; using OpenTK; using osu.Framework.Input; -namespace osu.Game.Overlays.Options.Sections.General +namespace osu.Game.Overlays.Settings.Sections.General { - public class LoginOptions : OptionsSubsection, IOnlineComponent + public class LoginSettings : SettingsSubsection, IOnlineComponent { private bool bounding = true; private LoginForm form; @@ -132,12 +132,12 @@ namespace osu.Game.Overlays.Options.Sections.General TabbableContentContainer = this, OnCommit = (sender, newText) => performLogin() }, - new OptionCheckbox + new SettingsCheckbox { LabelText = "Remember username", Bindable = config.GetBindable(OsuConfig.SaveUsername), }, - new OptionCheckbox + new SettingsCheckbox { LabelText = "Stay logged in", Bindable = config.GetBindable(OsuConfig.SavePassword), diff --git a/osu.Game/Overlays/Options/Sections/General/UpdateOptions.cs b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs similarity index 83% rename from osu.Game/Overlays/Options/Sections/General/UpdateOptions.cs rename to osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs index 1d9a5a7d72..3f2f073bff 100644 --- a/osu.Game/Overlays/Options/Sections/General/UpdateOptions.cs +++ b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs @@ -7,9 +7,9 @@ using osu.Framework.Platform; using osu.Game.Configuration; using osu.Game.Graphics.UserInterface; -namespace osu.Game.Overlays.Options.Sections.General +namespace osu.Game.Overlays.Settings.Sections.General { - public class UpdateOptions : OptionsSubsection + public class UpdateSettings : SettingsSubsection { protected override string Header => "Updates"; @@ -18,7 +18,7 @@ namespace osu.Game.Overlays.Options.Sections.General { Children = new Drawable[] { - new OptionEnumDropdown + new SettingsEnumDropdown { LabelText = "Release stream", Bindable = config.GetBindable(OsuConfig.ReleaseStream), diff --git a/osu.Game/Overlays/Options/Sections/GeneralSection.cs b/osu.Game/Overlays/Settings/Sections/GeneralSection.cs similarity index 64% rename from osu.Game/Overlays/Options/Sections/GeneralSection.cs rename to osu.Game/Overlays/Settings/Sections/GeneralSection.cs index e0c447b08b..5511f827e2 100644 --- a/osu.Game/Overlays/Options/Sections/GeneralSection.cs +++ b/osu.Game/Overlays/Settings/Sections/GeneralSection.cs @@ -3,11 +3,11 @@ using osu.Framework.Graphics; using osu.Game.Graphics; -using osu.Game.Overlays.Options.Sections.General; +using osu.Game.Overlays.Settings.Sections.General; -namespace osu.Game.Overlays.Options.Sections +namespace osu.Game.Overlays.Settings.Sections { - public class GeneralSection : OptionsSection + public class GeneralSection : SettingsSection { public override string Header => "General"; public override FontAwesome Icon => FontAwesome.fa_gear; @@ -16,8 +16,8 @@ namespace osu.Game.Overlays.Options.Sections { Children = new Drawable[] { - new LanguageOptions(), - new UpdateOptions(), + new LanguageSettings(), + new UpdateSettings(), }; } } diff --git a/osu.Game/Overlays/Options/Sections/Graphics/DetailOptions.cs b/osu.Game/Overlays/Settings/Sections/Graphics/DetailSettings.cs similarity index 79% rename from osu.Game/Overlays/Options/Sections/Graphics/DetailOptions.cs rename to osu.Game/Overlays/Settings/Sections/Graphics/DetailSettings.cs index 6503a7ea90..5bfb8a4373 100644 --- a/osu.Game/Overlays/Options/Sections/Graphics/DetailOptions.cs +++ b/osu.Game/Overlays/Settings/Sections/Graphics/DetailSettings.cs @@ -5,9 +5,9 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Game.Configuration; -namespace osu.Game.Overlays.Options.Sections.Graphics +namespace osu.Game.Overlays.Settings.Sections.Graphics { - public class DetailOptions : OptionsSubsection + public class DetailSettings : SettingsSubsection { protected override string Header => "Detail Settings"; @@ -16,12 +16,12 @@ namespace osu.Game.Overlays.Options.Sections.Graphics { Children = new Drawable[] { - new OptionCheckbox + new SettingsCheckbox { LabelText = "Snaking in sliders", Bindable = config.GetBindable(OsuConfig.SnakingInSliders) }, - new OptionCheckbox + new SettingsCheckbox { LabelText = "Snaking out sliders", Bindable = config.GetBindable(OsuConfig.SnakingOutSliders) diff --git a/osu.Game/Overlays/Options/Sections/Graphics/LayoutOptions.cs b/osu.Game/Overlays/Settings/Sections/Graphics/LayoutSettings.cs similarity index 70% rename from osu.Game/Overlays/Options/Sections/Graphics/LayoutOptions.cs rename to osu.Game/Overlays/Settings/Sections/Graphics/LayoutSettings.cs index 1b4b0b3c7d..9a5fd769cd 100644 --- a/osu.Game/Overlays/Options/Sections/Graphics/LayoutOptions.cs +++ b/osu.Game/Overlays/Settings/Sections/Graphics/LayoutSettings.cs @@ -5,43 +5,43 @@ using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; -namespace osu.Game.Overlays.Options.Sections.Graphics +namespace osu.Game.Overlays.Settings.Sections.Graphics { - public class LayoutOptions : OptionsSubsection + public class LayoutSettings : SettingsSubsection { protected override string Header => "Layout"; - private OptionSlider letterboxPositionX; - private OptionSlider letterboxPositionY; + private SettingsSlider letterboxPositionX; + private SettingsSlider letterboxPositionY; private Bindable letterboxing; [BackgroundDependencyLoader] private void load(FrameworkConfigManager config) { - letterboxing = config.GetBindable(FrameworkConfig.Letterboxing); + letterboxing = config.GetBindable(FrameworkSetting.Letterboxing); Children = new Drawable[] { - new OptionEnumDropdown + new SettingsEnumDropdown { LabelText = "Screen mode", - Bindable = config.GetBindable(FrameworkConfig.WindowMode), + Bindable = config.GetBindable(FrameworkSetting.WindowMode), }, - new OptionCheckbox + new SettingsCheckbox { LabelText = "Letterboxing", Bindable = letterboxing, }, - letterboxPositionX = new OptionSlider + letterboxPositionX = new SettingsSlider { LabelText = "Horizontal position", - Bindable = config.GetBindable(FrameworkConfig.LetterboxPositionX) + Bindable = config.GetBindable(FrameworkSetting.LetterboxPositionX) }, - letterboxPositionY = new OptionSlider + letterboxPositionY = new SettingsSlider { LabelText = "Vertical position", - Bindable = config.GetBindable(FrameworkConfig.LetterboxPositionY) + Bindable = config.GetBindable(FrameworkSetting.LetterboxPositionY) }, }; diff --git a/osu.Game/Overlays/Options/Sections/Graphics/MainMenuOptions.cs b/osu.Game/Overlays/Settings/Sections/Graphics/MainMenuSettings.cs similarity index 78% rename from osu.Game/Overlays/Options/Sections/Graphics/MainMenuOptions.cs rename to osu.Game/Overlays/Settings/Sections/Graphics/MainMenuSettings.cs index 6ebb8f263d..fd135e336f 100644 --- a/osu.Game/Overlays/Options/Sections/Graphics/MainMenuOptions.cs +++ b/osu.Game/Overlays/Settings/Sections/Graphics/MainMenuSettings.cs @@ -4,9 +4,9 @@ using osu.Framework.Allocation; using osu.Game.Configuration; -namespace osu.Game.Overlays.Options.Sections.Graphics +namespace osu.Game.Overlays.Settings.Sections.Graphics { - public class MainMenuOptions : OptionsSubsection + public class MainMenuSettings : SettingsSubsection { protected override string Header => "User Interface"; @@ -15,7 +15,7 @@ namespace osu.Game.Overlays.Options.Sections.Graphics { Children = new[] { - new OptionCheckbox + new SettingsCheckbox { LabelText = "Parallax", Bindable = config.GetBindable(OsuConfig.MenuParallax) diff --git a/osu.Game/Overlays/Options/Sections/Graphics/RendererOptions.cs b/osu.Game/Overlays/Settings/Sections/Graphics/RendererSettings.cs similarity index 79% rename from osu.Game/Overlays/Options/Sections/Graphics/RendererOptions.cs rename to osu.Game/Overlays/Settings/Sections/Graphics/RendererSettings.cs index f11c18d3b4..0c79c8cd42 100644 --- a/osu.Game/Overlays/Options/Sections/Graphics/RendererOptions.cs +++ b/osu.Game/Overlays/Settings/Sections/Graphics/RendererSettings.cs @@ -6,9 +6,9 @@ using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Game.Configuration; -namespace osu.Game.Overlays.Options.Sections.Graphics +namespace osu.Game.Overlays.Settings.Sections.Graphics { - public class RendererOptions : OptionsSubsection + public class RendererSettings : SettingsSubsection { protected override string Header => "Renderer"; @@ -19,12 +19,12 @@ namespace osu.Game.Overlays.Options.Sections.Graphics Children = new Drawable[] { // TODO: this needs to be a custom dropdown at some point - new OptionEnumDropdown + new SettingsEnumDropdown { LabelText = "Frame limiter", - Bindable = config.GetBindable(FrameworkConfig.FrameSync) + Bindable = config.GetBindable(FrameworkSetting.FrameSync) }, - new OptionCheckbox + new SettingsCheckbox { LabelText = "Show FPS", Bindable = osuConfig.GetBindable(OsuConfig.ShowFpsDisplay) diff --git a/osu.Game/Overlays/Options/Sections/GraphicsSection.cs b/osu.Game/Overlays/Settings/Sections/GraphicsSection.cs similarity index 58% rename from osu.Game/Overlays/Options/Sections/GraphicsSection.cs rename to osu.Game/Overlays/Settings/Sections/GraphicsSection.cs index dbbcbde2b9..f188f2476c 100644 --- a/osu.Game/Overlays/Options/Sections/GraphicsSection.cs +++ b/osu.Game/Overlays/Settings/Sections/GraphicsSection.cs @@ -3,11 +3,11 @@ using osu.Framework.Graphics; using osu.Game.Graphics; -using osu.Game.Overlays.Options.Sections.Graphics; +using osu.Game.Overlays.Settings.Sections.Graphics; -namespace osu.Game.Overlays.Options.Sections +namespace osu.Game.Overlays.Settings.Sections { - public class GraphicsSection : OptionsSection + public class GraphicsSection : SettingsSection { public override string Header => "Graphics"; public override FontAwesome Icon => FontAwesome.fa_laptop; @@ -16,10 +16,10 @@ namespace osu.Game.Overlays.Options.Sections { Children = new Drawable[] { - new RendererOptions(), - new LayoutOptions(), - new DetailOptions(), - new MainMenuOptions(), + new RendererSettings(), + new LayoutSettings(), + new DetailSettings(), + new MainMenuSettings(), }; } } diff --git a/osu.Game/Overlays/Options/Sections/Input/KeyboardOptions.cs b/osu.Game/Overlays/Settings/Sections/Input/KeyboardSettings.cs similarity index 76% rename from osu.Game/Overlays/Options/Sections/Input/KeyboardOptions.cs rename to osu.Game/Overlays/Settings/Sections/Input/KeyboardSettings.cs index b7e8598cff..9ead4ca7a4 100644 --- a/osu.Game/Overlays/Options/Sections/Input/KeyboardOptions.cs +++ b/osu.Game/Overlays/Settings/Sections/Input/KeyboardSettings.cs @@ -4,13 +4,13 @@ using osu.Framework.Graphics; using osu.Game.Graphics.UserInterface; -namespace osu.Game.Overlays.Options.Sections.Input +namespace osu.Game.Overlays.Settings.Sections.Input { - public class KeyboardOptions : OptionsSubsection + public class KeyboardSettings : SettingsSubsection { protected override string Header => "Keyboard"; - public KeyboardOptions() + public KeyboardSettings() { Children = new Drawable[] { diff --git a/osu.Game/Overlays/Options/Sections/Input/MouseOptions.cs b/osu.Game/Overlays/Settings/Sections/Input/MouseSettings.cs similarity index 80% rename from osu.Game/Overlays/Options/Sections/Input/MouseOptions.cs rename to osu.Game/Overlays/Settings/Sections/Input/MouseSettings.cs index b4ce11e2bc..7bf42fd7e7 100644 --- a/osu.Game/Overlays/Options/Sections/Input/MouseOptions.cs +++ b/osu.Game/Overlays/Settings/Sections/Input/MouseSettings.cs @@ -8,9 +8,9 @@ using osu.Framework.Input; using osu.Game.Configuration; using osu.Game.Graphics.UserInterface; -namespace osu.Game.Overlays.Options.Sections.Input +namespace osu.Game.Overlays.Settings.Sections.Input { - public class MouseOptions : OptionsSubsection + public class MouseSettings : SettingsSubsection { protected override string Header => "Mouse"; @@ -19,17 +19,17 @@ namespace osu.Game.Overlays.Options.Sections.Input { Children = new Drawable[] { - new OptionEnumDropdown + new SettingsEnumDropdown { LabelText = "Confine mouse cursor", - Bindable = config.GetBindable(FrameworkConfig.ConfineMouseMode), + Bindable = config.GetBindable(FrameworkSetting.ConfineMouseMode), }, - new OptionCheckbox + new SettingsCheckbox { LabelText = "Disable mouse wheel during gameplay", Bindable = osuConfig.GetBindable(OsuConfig.MouseDisableWheel) }, - new OptionCheckbox + new SettingsCheckbox { LabelText = "Disable mouse buttons during gameplay", Bindable = osuConfig.GetBindable(OsuConfig.MouseDisableButtons) diff --git a/osu.Game/Overlays/Options/Sections/InputSection.cs b/osu.Game/Overlays/Settings/Sections/InputSection.cs similarity index 65% rename from osu.Game/Overlays/Options/Sections/InputSection.cs rename to osu.Game/Overlays/Settings/Sections/InputSection.cs index d39d0a0e20..cfa3bc78f0 100644 --- a/osu.Game/Overlays/Options/Sections/InputSection.cs +++ b/osu.Game/Overlays/Settings/Sections/InputSection.cs @@ -3,11 +3,11 @@ using osu.Framework.Graphics; using osu.Game.Graphics; -using osu.Game.Overlays.Options.Sections.Input; +using osu.Game.Overlays.Settings.Sections.Input; -namespace osu.Game.Overlays.Options.Sections +namespace osu.Game.Overlays.Settings.Sections { - public class InputSection : OptionsSection + public class InputSection : SettingsSection { public override string Header => "Input"; public override FontAwesome Icon => FontAwesome.fa_keyboard_o; @@ -16,8 +16,8 @@ namespace osu.Game.Overlays.Options.Sections { Children = new Drawable[] { - new MouseOptions(), - new KeyboardOptions(), + new MouseSettings(), + new KeyboardSettings(), }; } } diff --git a/osu.Game/Overlays/Options/Sections/MaintenanceSection.cs b/osu.Game/Overlays/Settings/Sections/MaintenanceSection.cs similarity index 81% rename from osu.Game/Overlays/Options/Sections/MaintenanceSection.cs rename to osu.Game/Overlays/Settings/Sections/MaintenanceSection.cs index e8a4f91074..529cec79c1 100644 --- a/osu.Game/Overlays/Options/Sections/MaintenanceSection.cs +++ b/osu.Game/Overlays/Settings/Sections/MaintenanceSection.cs @@ -5,9 +5,9 @@ using osu.Framework.Graphics; using osu.Game.Graphics; using OpenTK; -namespace osu.Game.Overlays.Options.Sections +namespace osu.Game.Overlays.Settings.Sections { - public class MaintenanceSection : OptionsSection + public class MaintenanceSection : SettingsSection { public override string Header => "Maintenance"; public override FontAwesome Icon => FontAwesome.fa_wrench; diff --git a/osu.Game/Overlays/Options/Sections/OnlineSection.cs b/osu.Game/Overlays/Settings/Sections/OnlineSection.cs similarity index 79% rename from osu.Game/Overlays/Options/Sections/OnlineSection.cs rename to osu.Game/Overlays/Settings/Sections/OnlineSection.cs index 1a65a23121..4494da1bf4 100644 --- a/osu.Game/Overlays/Options/Sections/OnlineSection.cs +++ b/osu.Game/Overlays/Settings/Sections/OnlineSection.cs @@ -4,9 +4,9 @@ using osu.Framework.Graphics; using osu.Game.Graphics; -namespace osu.Game.Overlays.Options.Sections +namespace osu.Game.Overlays.Settings.Sections { - public class OnlineSection : OptionsSection + public class OnlineSection : SettingsSection { public override string Header => "Online"; public override FontAwesome Icon => FontAwesome.fa_globe; diff --git a/osu.Game/Overlays/Options/Sections/SkinSection.cs b/osu.Game/Overlays/Settings/Sections/SkinSection.cs similarity index 83% rename from osu.Game/Overlays/Options/Sections/SkinSection.cs rename to osu.Game/Overlays/Settings/Sections/SkinSection.cs index b3c225d00c..cc416f45ca 100644 --- a/osu.Game/Overlays/Options/Sections/SkinSection.cs +++ b/osu.Game/Overlays/Settings/Sections/SkinSection.cs @@ -8,9 +8,9 @@ using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; using OpenTK; -namespace osu.Game.Overlays.Options.Sections +namespace osu.Game.Overlays.Settings.Sections { - public class SkinSection : OptionsSection + public class SkinSection : SettingsSection { public override string Header => "Skin"; public override FontAwesome Icon => FontAwesome.fa_paint_brush; @@ -21,12 +21,12 @@ namespace osu.Game.Overlays.Options.Sections FlowContent.Spacing = new Vector2(0, 5); Children = new Drawable[] { - new OptionSlider + new SettingsSlider { LabelText = "Menu cursor size", Bindable = config.GetBindable(OsuConfig.MenuCursorSize) }, - new OptionSlider + new SettingsSlider { LabelText = "Gameplay cursor size", Bindable = config.GetBindable(OsuConfig.GameplayCursorSize) diff --git a/osu.Game/Overlays/Options/OptionCheckbox.cs b/osu.Game/Overlays/Settings/SettingsCheckbox.cs similarity index 82% rename from osu.Game/Overlays/Options/OptionCheckbox.cs rename to osu.Game/Overlays/Settings/SettingsCheckbox.cs index de7b138c3c..659754ce79 100644 --- a/osu.Game/Overlays/Options/OptionCheckbox.cs +++ b/osu.Game/Overlays/Settings/SettingsCheckbox.cs @@ -4,9 +4,9 @@ using osu.Framework.Graphics; using osu.Game.Graphics.UserInterface; -namespace osu.Game.Overlays.Options +namespace osu.Game.Overlays.Settings { - public class OptionCheckbox : OptionItem + public class SettingsCheckbox : SettingsItem { private OsuCheckbox checkbox; diff --git a/osu.Game/Overlays/Options/OptionDropdown.cs b/osu.Game/Overlays/Settings/SettingsDropdown.cs similarity index 88% rename from osu.Game/Overlays/Options/OptionDropdown.cs rename to osu.Game/Overlays/Settings/SettingsDropdown.cs index 1427eafe39..8ce755b90e 100644 --- a/osu.Game/Overlays/Options/OptionDropdown.cs +++ b/osu.Game/Overlays/Settings/SettingsDropdown.cs @@ -7,9 +7,9 @@ using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics.UserInterface; -namespace osu.Game.Overlays.Options +namespace osu.Game.Overlays.Settings { - public class OptionDropdown : OptionItem + public class SettingsDropdown : SettingsItem { private Dropdown dropdown; diff --git a/osu.Game/Overlays/Options/OptionEnumDropdown.cs b/osu.Game/Overlays/Settings/SettingsEnumDropdown.cs similarity index 75% rename from osu.Game/Overlays/Options/OptionEnumDropdown.cs rename to osu.Game/Overlays/Settings/SettingsEnumDropdown.cs index 1a4f4635e2..a9f0848403 100644 --- a/osu.Game/Overlays/Options/OptionEnumDropdown.cs +++ b/osu.Game/Overlays/Settings/SettingsEnumDropdown.cs @@ -6,14 +6,14 @@ using System.Reflection; using System.ComponentModel; using System.Collections.Generic; -namespace osu.Game.Overlays.Options +namespace osu.Game.Overlays.Settings { - public class OptionEnumDropdown : OptionDropdown + public class SettingsEnumDropdown : SettingsDropdown { - public OptionEnumDropdown() + public SettingsEnumDropdown() { if (!typeof(T).IsEnum) - throw new InvalidOperationException("OptionsDropdown only supports enums as the generic type argument"); + throw new InvalidOperationException("SettingsDropdown only supports enums as the generic type argument"); List> items = new List>(); foreach(var val in (T[])Enum.GetValues(typeof(T))) diff --git a/osu.Game/Overlays/Options/OptionsFooter.cs b/osu.Game/Overlays/Settings/SettingsFooter.cs similarity index 93% rename from osu.Game/Overlays/Options/OptionsFooter.cs rename to osu.Game/Overlays/Settings/SettingsFooter.cs index c785f2d0c0..a9293ac2af 100644 --- a/osu.Game/Overlays/Options/OptionsFooter.cs +++ b/osu.Game/Overlays/Settings/SettingsFooter.cs @@ -12,9 +12,9 @@ using osu.Game.Graphics.Sprites; using OpenTK; using OpenTK.Graphics; -namespace osu.Game.Overlays.Options +namespace osu.Game.Overlays.Settings { - public class OptionsFooter : FillFlowContainer + public class SettingsFooter : FillFlowContainer { [BackgroundDependencyLoader] private void load(OsuGameBase game, OsuColour colours, RulesetDatabase rulesets) diff --git a/osu.Game/Overlays/Options/OptionsHeader.cs b/osu.Game/Overlays/Settings/SettingsHeader.cs similarity index 90% rename from osu.Game/Overlays/Options/OptionsHeader.cs rename to osu.Game/Overlays/Settings/SettingsHeader.cs index 8b97a607a2..8a118120de 100644 --- a/osu.Game/Overlays/Options/OptionsHeader.cs +++ b/osu.Game/Overlays/Settings/SettingsHeader.cs @@ -12,9 +12,9 @@ using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using OpenTK.Graphics; -namespace osu.Game.Overlays.Options +namespace osu.Game.Overlays.Settings { - public class OptionsHeader : Container + public class SettingsHeader : Container { public SearchTextBox SearchTextBox; @@ -25,7 +25,7 @@ namespace osu.Game.Overlays.Options public Action Exit; /// A reference to the current scroll position of the ScrollContainer we are contained within. - public OptionsHeader(Func currentScrollOffset) + public SettingsHeader(Func currentScrollOffset) { this.currentScrollOffset = currentScrollOffset; } @@ -55,7 +55,7 @@ namespace osu.Game.Overlays.Options Text = "settings", TextSize = 40, Margin = new MarginPadding { - Left = OptionsOverlay.CONTENT_MARGINS, + Left = SettingsOverlay.CONTENT_MARGINS, Top = Toolbar.Toolbar.TOOLTIP_HEIGHT }, }, @@ -65,7 +65,7 @@ namespace osu.Game.Overlays.Options Text = "Change the way osu! behaves", TextSize = 18, Margin = new MarginPadding { - Left = OptionsOverlay.CONTENT_MARGINS, + Left = SettingsOverlay.CONTENT_MARGINS, Bottom = 30 }, }, diff --git a/osu.Game/Overlays/Options/OptionItem.cs b/osu.Game/Overlays/Settings/SettingsItem.cs similarity index 89% rename from osu.Game/Overlays/Options/OptionItem.cs rename to osu.Game/Overlays/Settings/SettingsItem.cs index 2124796089..a40f895e0a 100644 --- a/osu.Game/Overlays/Options/OptionItem.cs +++ b/osu.Game/Overlays/Settings/SettingsItem.cs @@ -10,9 +10,9 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics.Sprites; -namespace osu.Game.Overlays.Options +namespace osu.Game.Overlays.Settings { - public abstract class OptionItem : FillFlowContainer, IFilterable + public abstract class SettingsItem : FillFlowContainer, IFilterable { protected abstract Drawable CreateControl(); @@ -37,7 +37,7 @@ namespace osu.Game.Overlays.Options } } - // hold a reference to the provided bindable so we don't have to in every options section. + // hold a reference to the provided bindable so we don't have to in every settings section. private Bindable bindable; public Bindable Bindable @@ -65,7 +65,7 @@ namespace osu.Game.Overlays.Options } } - protected OptionItem() + protected SettingsItem() { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; diff --git a/osu.Game/Overlays/Options/OptionLabel.cs b/osu.Game/Overlays/Settings/SettingsLabel.cs similarity index 80% rename from osu.Game/Overlays/Options/OptionLabel.cs rename to osu.Game/Overlays/Settings/SettingsLabel.cs index 3f3c569f3a..7d1364ef41 100644 --- a/osu.Game/Overlays/Options/OptionLabel.cs +++ b/osu.Game/Overlays/Settings/SettingsLabel.cs @@ -5,9 +5,9 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Game.Graphics; -namespace osu.Game.Overlays.Options +namespace osu.Game.Overlays.Settings { - internal class OptionLabel : OptionItem + internal class SettingsLabel : SettingsItem { protected override Drawable CreateControl() => null; diff --git a/osu.Game/Overlays/Options/OptionsSection.cs b/osu.Game/Overlays/Settings/SettingsSection.cs similarity index 88% rename from osu.Game/Overlays/Options/OptionsSection.cs rename to osu.Game/Overlays/Settings/SettingsSection.cs index 5e36f79467..66b860402a 100644 --- a/osu.Game/Overlays/Options/OptionsSection.cs +++ b/osu.Game/Overlays/Settings/SettingsSection.cs @@ -13,9 +13,9 @@ using osu.Game.Graphics.Sprites; using System.Collections.Generic; using System.Linq; -namespace osu.Game.Overlays.Options +namespace osu.Game.Overlays.Settings { - public abstract class OptionsSection : Container, IHasFilterableChildren + public abstract class SettingsSection : Container, IHasFilterableChildren { protected FillFlowContainer FlowContent; protected override Container Content => FlowContent; @@ -35,7 +35,7 @@ namespace osu.Game.Overlays.Options private readonly SpriteText headerLabel; - protected OptionsSection() + protected SettingsSection() { Margin = new MarginPadding { Top = 20 }; AutoSizeAxes = Axes.Y; @@ -57,8 +57,8 @@ namespace osu.Game.Overlays.Options Padding = new MarginPadding { Top = 20 + border_size, - Left = OptionsOverlay.CONTENT_MARGINS, - Right = OptionsOverlay.CONTENT_MARGINS, + Left = SettingsOverlay.CONTENT_MARGINS, + Right = SettingsOverlay.CONTENT_MARGINS, Bottom = 10, }, RelativeSizeAxes = Axes.X, diff --git a/osu.Game/Overlays/Options/OptionSlider.cs b/osu.Game/Overlays/Settings/SettingsSlider.cs similarity index 76% rename from osu.Game/Overlays/Options/OptionSlider.cs rename to osu.Game/Overlays/Settings/SettingsSlider.cs index 2cceb085a7..9ce4efdd52 100644 --- a/osu.Game/Overlays/Options/OptionSlider.cs +++ b/osu.Game/Overlays/Settings/SettingsSlider.cs @@ -6,14 +6,14 @@ using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics.UserInterface; -namespace osu.Game.Overlays.Options +namespace osu.Game.Overlays.Settings { - public class OptionSlider : OptionSlider> + public class SettingsSlider : SettingsSlider> where T : struct { } - public class OptionSlider : OptionItem + public class SettingsSlider : SettingsItem where T : struct where U : SliderBar, new() { diff --git a/osu.Game/Overlays/Options/OptionsSubsection.cs b/osu.Game/Overlays/Settings/SettingsSubsection.cs similarity index 87% rename from osu.Game/Overlays/Options/OptionsSubsection.cs rename to osu.Game/Overlays/Settings/SettingsSubsection.cs index ff9e60c273..b4ce54cb75 100644 --- a/osu.Game/Overlays/Options/OptionsSubsection.cs +++ b/osu.Game/Overlays/Settings/SettingsSubsection.cs @@ -9,9 +9,9 @@ using osu.Game.Graphics.Sprites; using System.Collections.Generic; using System.Linq; -namespace osu.Game.Overlays.Options +namespace osu.Game.Overlays.Settings { - public abstract class OptionsSubsection : FillFlowContainer, IHasFilterableChildren + public abstract class SettingsSubsection : FillFlowContainer, IHasFilterableChildren { protected override Container Content => content; @@ -29,7 +29,7 @@ namespace osu.Game.Overlays.Options } } - protected OptionsSubsection() + protected SettingsSubsection() { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; diff --git a/osu.Game/Overlays/Options/OptionTextBox.cs b/osu.Game/Overlays/Settings/SettingsTextBox.cs similarity index 74% rename from osu.Game/Overlays/Options/OptionTextBox.cs rename to osu.Game/Overlays/Settings/SettingsTextBox.cs index 498f27796a..710330ad41 100644 --- a/osu.Game/Overlays/Options/OptionTextBox.cs +++ b/osu.Game/Overlays/Settings/SettingsTextBox.cs @@ -4,9 +4,9 @@ using osu.Framework.Graphics; using osu.Game.Graphics.UserInterface; -namespace osu.Game.Overlays.Options +namespace osu.Game.Overlays.Settings { - public class OptionTextBox : OptionItem + public class SettingsTextBox : SettingsItem { protected override Drawable CreateControl() => new OsuTextBox(); } diff --git a/osu.Game/Overlays/Options/Sidebar.cs b/osu.Game/Overlays/Settings/Sidebar.cs similarity index 95% rename from osu.Game/Overlays/Options/Sidebar.cs rename to osu.Game/Overlays/Settings/Sidebar.cs index eb489810ad..be93fdbac5 100644 --- a/osu.Game/Overlays/Options/Sidebar.cs +++ b/osu.Game/Overlays/Settings/Sidebar.cs @@ -10,7 +10,7 @@ using osu.Framework.Input; using osu.Framework.Threading; using osu.Game.Overlays.Toolbar; -namespace osu.Game.Overlays.Options +namespace osu.Game.Overlays.Settings { public class Sidebar : Container { diff --git a/osu.Game/Overlays/Options/SidebarButton.cs b/osu.Game/Overlays/Settings/SidebarButton.cs similarity index 93% rename from osu.Game/Overlays/Options/SidebarButton.cs rename to osu.Game/Overlays/Settings/SidebarButton.cs index 7c0049e8c7..766c6cf7e2 100644 --- a/osu.Game/Overlays/Options/SidebarButton.cs +++ b/osu.Game/Overlays/Settings/SidebarButton.cs @@ -12,7 +12,7 @@ using osu.Framework.Input; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; -namespace osu.Game.Overlays.Options +namespace osu.Game.Overlays.Settings { public class SidebarButton : Container { @@ -23,8 +23,8 @@ namespace osu.Game.Overlays.Options private readonly Container text; public Action Action; - private OptionsSection section; - public OptionsSection Section + private SettingsSection section; + public SettingsSection Section { get { diff --git a/osu.Game/Overlays/OptionsOverlay.cs b/osu.Game/Overlays/SettingsOverlay.cs similarity index 86% rename from osu.Game/Overlays/OptionsOverlay.cs rename to osu.Game/Overlays/SettingsOverlay.cs index 6d1a3a64fc..e3fbf12df3 100644 --- a/osu.Game/Overlays/OptionsOverlay.cs +++ b/osu.Game/Overlays/SettingsOverlay.cs @@ -8,14 +8,14 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; -using osu.Game.Overlays.Options; +using osu.Game.Overlays.Settings; using System; -using osu.Game.Overlays.Options.Sections; +using osu.Game.Overlays.Settings.Sections; using osu.Framework.Input; namespace osu.Game.Overlays { - public class OptionsOverlay : FocusedOverlayContainer + public class SettingsOverlay : FocusedOverlayContainer { internal const float CONTENT_MARGINS = 10; @@ -30,17 +30,17 @@ namespace osu.Game.Overlays private ScrollContainer scrollContainer; private Sidebar sidebar; private SidebarButton[] sidebarButtons; - private OptionsSection[] sections; + private SettingsSection[] sections; - private OptionsHeader header; + private SettingsHeader header; - private OptionsFooter footer; + private SettingsFooter footer; private SearchContainer searchContainer; private float lastKnownScroll; - public OptionsOverlay() + public SettingsOverlay() { RelativeSizeAxes = Axes.Y; AutoSizeAxes = Axes.X; @@ -49,7 +49,7 @@ namespace osu.Game.Overlays [BackgroundDependencyLoader(permitNulls: true)] private void load(OsuGame game) { - sections = new OptionsSection[] + sections = new SettingsSection[] { new GeneralSection(), new GraphicsSection(), @@ -84,8 +84,8 @@ namespace osu.Game.Overlays Direction = FillDirection.Vertical, Children = sections, }, - footer = new OptionsFooter(), - header = new OptionsHeader(() => scrollContainer.Current) + footer = new SettingsFooter(), + header = new SettingsHeader(() => scrollContainer.Current) { Exit = Hide, }, @@ -114,7 +114,7 @@ namespace osu.Game.Overlays { base.UpdateAfterChildren(); - //we need to update these manually because we can't put the OptionsHeader inside the SearchContainer (due to its anchoring). + //we need to update these manually because we can't put the SettingsHeader inside the SearchContainer (due to its anchoring). searchContainer.Y = header.DrawHeight; footer.Y = searchContainer.Y + searchContainer.DrawHeight; } @@ -128,10 +128,10 @@ namespace osu.Game.Overlays { lastKnownScroll = currentScroll; - OptionsSection bestCandidate = null; + SettingsSection bestCandidate = null; float bestDistance = float.MaxValue; - foreach (OptionsSection section in sections) + foreach (SettingsSection section in sections) { float distance = Math.Abs(scrollContainer.GetChildPosInContent(section) - currentScroll); if (distance < bestDistance) diff --git a/osu.Game/Overlays/Toolbar/ToolbarSettingsButton.cs b/osu.Game/Overlays/Toolbar/ToolbarSettingsButton.cs index ae54b98aca..2eb8c15dcf 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarSettingsButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarSettingsButton.cs @@ -16,9 +16,9 @@ namespace osu.Game.Overlays.Toolbar } [BackgroundDependencyLoader] - private void load(OptionsOverlay options) + private void load(SettingsOverlay settings) { - StateContainer = options; + StateContainer = settings; } } } \ No newline at end of file diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index b0d12cb5a1..2f418d2f88 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -82,7 +82,7 @@ namespace osu.Game.Screens.Menu AutoSizeAxes = Axes.Both, Children = new[] { - settingsButton = new Button(@"settings", @"options", FontAwesome.fa_gear, new Color4(85, 85, 85, 255), () => OnSettings?.Invoke(), -WEDGE_WIDTH, Key.O), + settingsButton = new Button(@"settings", @"settings", FontAwesome.fa_gear, new Color4(85, 85, 85, 255), () => OnSettings?.Invoke(), -WEDGE_WIDTH, Key.O), backButton = new Button(@"back", @"back", FontAwesome.fa_osu_left_o, new Color4(51, 58, 94, 255), onBack, -WEDGE_WIDTH), iconFacade = new Container //need a container to make the osu! icon flow properly. { diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index c8a00e0671..3e03a9aac8 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -84,7 +84,7 @@ namespace osu.Game.Screens.Menu } } - buttons.OnSettings = game.ToggleOptions; + buttons.OnSettings = game.ToggleSettings; preloadSongSelect(); } diff --git a/osu.Game/Screens/Select/Options/BeatmapOptionsButton.cs b/osu.Game/Screens/Select/Options/BeatmapOptionsButton.cs index 965ea12fe2..0935bb3686 100644 --- a/osu.Game/Screens/Select/Options/BeatmapOptionsButton.cs +++ b/osu.Game/Screens/Select/Options/BeatmapOptionsButton.cs @@ -1,9 +1,6 @@ // 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 OpenTK.Input; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -12,6 +9,9 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.Input; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using OpenTK; +using OpenTK.Graphics; +using OpenTK.Input; namespace osu.Game.Screens.Select.Options { diff --git a/osu.Game/Screens/Select/Options/BeatmapOptionsOverlay.cs b/osu.Game/Screens/Select/Options/BeatmapOptionsOverlay.cs index 77001950f6..c064a0272e 100644 --- a/osu.Game/Screens/Select/Options/BeatmapOptionsOverlay.cs +++ b/osu.Game/Screens/Select/Options/BeatmapOptionsOverlay.cs @@ -4,14 +4,14 @@ using System; using System.Collections.Generic; using System.Linq; -using OpenTK; -using OpenTK.Graphics; -using OpenTK.Input; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; +using OpenTK; +using OpenTK.Graphics; +using OpenTK.Input; namespace osu.Game.Screens.Select.Options { diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index ee6153dc55..1f866f0e17 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -79,8 +79,8 @@ - - + + @@ -207,13 +207,13 @@ - - + + - - - - + + + + @@ -278,6 +278,8 @@ + + @@ -313,7 +315,7 @@ - + @@ -346,39 +348,39 @@ - - - + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + @@ -410,8 +412,6 @@ - - From 622b155fda4535bd45facffe36b0d390535bebf0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 15 May 2017 10:56:27 +0900 Subject: [PATCH 200/329] OsuConfig -> OsuSetting --- .../Objects/Drawables/Pieces/SliderBody.cs | 4 +- osu.Game/Configuration/OsuConfigManager.cs | 58 +++++++++---------- .../Graphics/Containers/ParallaxContainer.cs | 2 +- osu.Game/Graphics/Cursor/GameplayCursor.cs | 2 +- osu.Game/Graphics/Cursor/MenuCursor.cs | 2 +- osu.Game/OsuGame.cs | 2 +- osu.Game/OsuGameBase.cs | 10 ++-- osu.Game/Overlays/ChatOverlay.cs | 2 +- .../Sections/Audio/MainMenuSettings.cs | 4 +- .../Settings/Sections/Audio/OffsetSettings.cs | 2 +- .../Sections/Gameplay/GeneralSettings.cs | 6 +- .../Sections/Gameplay/SongSelectSettings.cs | 4 +- .../Sections/General/LoginSettings.cs | 4 +- .../Sections/General/UpdateSettings.cs | 2 +- .../Sections/Graphics/DetailSettings.cs | 4 +- .../Sections/Graphics/MainMenuSettings.cs | 2 +- .../Sections/Graphics/RendererSettings.cs | 2 +- .../Settings/Sections/Input/MouseSettings.cs | 4 +- .../Overlays/Settings/Sections/SkinSection.cs | 4 +- osu.Game/Screens/Menu/Intro.cs | 4 +- osu.Game/Screens/Menu/MainMenu.cs | 2 +- osu.Game/Screens/Play/HUDOverlay.cs | 4 +- osu.Game/Screens/Play/Player.cs | 6 +- osu.Game/Screens/Play/PlayerInputManager.cs | 2 +- .../Select/BeatmapDetailAreaTabControl.cs | 2 +- 25 files changed, 70 insertions(+), 70 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SliderBody.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SliderBody.cs index b23fdde4e8..8b9441ea65 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SliderBody.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SliderBody.cs @@ -97,8 +97,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces [BackgroundDependencyLoader] private void load(OsuConfigManager config) { - snakingIn = config.GetBindable(OsuConfig.SnakingInSliders); - snakingOut = config.GetBindable(OsuConfig.SnakingOutSliders); + snakingIn = config.GetBindable(OsuSetting.SnakingInSliders); + snakingOut = config.GetBindable(OsuSetting.SnakingOutSliders); reloadTexture(); } diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index ba19d8592a..14f83ed11f 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -8,71 +8,71 @@ using osu.Game.Screens.Select; namespace osu.Game.Configuration { - public class OsuConfigManager : ConfigManager + public class OsuConfigManager : ConfigManager { protected override void InitialiseDefaults() { // UI/selection defaults - Set(OsuConfig.Ruleset, 0, 0, int.MaxValue); - Set(OsuConfig.BeatmapDetailTab, BeatmapDetailTab.Details); + Set(OsuSetting.Ruleset, 0, 0, int.MaxValue); + Set(OsuSetting.BeatmapDetailTab, BeatmapDetailTab.Details); - Set(OsuConfig.DisplayStarsMinimum, 0.0, 0, 10); - Set(OsuConfig.DisplayStarsMaximum, 10.0, 0, 10); + Set(OsuSetting.DisplayStarsMinimum, 0.0, 0, 10); + Set(OsuSetting.DisplayStarsMaximum, 10.0, 0, 10); - Set(OsuConfig.ChatDisplayHeight, ChatOverlay.DEFAULT_HEIGHT, 0.2, 1); + Set(OsuSetting.ChatDisplayHeight, ChatOverlay.DEFAULT_HEIGHT, 0.2, 1); // Online settings - Set(OsuConfig.Username, string.Empty); - Set(OsuConfig.Token, string.Empty); + Set(OsuSetting.Username, string.Empty); + Set(OsuSetting.Token, string.Empty); - Set(OsuConfig.SavePassword, false).ValueChanged += val => + Set(OsuSetting.SavePassword, false).ValueChanged += val => { - if (val) Set(OsuConfig.SaveUsername, true); + if (val) Set(OsuSetting.SaveUsername, true); }; - Set(OsuConfig.SaveUsername, true).ValueChanged += val => + Set(OsuSetting.SaveUsername, true).ValueChanged += val => { - if (!val) Set(OsuConfig.SavePassword, false); + if (!val) Set(OsuSetting.SavePassword, false); }; // Audio - Set(OsuConfig.AudioDevice, string.Empty); + Set(OsuSetting.AudioDevice, string.Empty); - Set(OsuConfig.MenuVoice, true); - Set(OsuConfig.MenuMusic, true); + Set(OsuSetting.MenuVoice, true); + Set(OsuSetting.MenuMusic, true); - Set(OsuConfig.AudioOffset, 0, -500.0, 500.0); + Set(OsuSetting.AudioOffset, 0, -500.0, 500.0); // Input - Set(OsuConfig.MenuCursorSize, 1.0, 0.5f, 2); - Set(OsuConfig.GameplayCursorSize, 1.0, 0.5f, 2); + Set(OsuSetting.MenuCursorSize, 1.0, 0.5f, 2); + Set(OsuSetting.GameplayCursorSize, 1.0, 0.5f, 2); - Set(OsuConfig.MouseDisableButtons, false); - Set(OsuConfig.MouseDisableWheel, false); + Set(OsuSetting.MouseDisableButtons, false); + Set(OsuSetting.MouseDisableWheel, false); // Graphics - Set(OsuConfig.ShowFpsDisplay, false); + Set(OsuSetting.ShowFpsDisplay, false); - Set(OsuConfig.MenuParallax, true); + Set(OsuSetting.MenuParallax, true); - Set(OsuConfig.SnakingInSliders, true); - Set(OsuConfig.SnakingOutSliders, true); + Set(OsuSetting.SnakingInSliders, true); + Set(OsuSetting.SnakingOutSliders, true); // Gameplay - Set(OsuConfig.DimLevel, 0.3, 0, 1); + Set(OsuSetting.DimLevel, 0.3, 0, 1); - Set(OsuConfig.ShowInterface, true); - Set(OsuConfig.KeyOverlay, false); + Set(OsuSetting.ShowInterface, true); + Set(OsuSetting.KeyOverlay, false); // Update - Set(OsuConfig.ReleaseStream, ReleaseStream.Lazer); + Set(OsuSetting.ReleaseStream, ReleaseStream.Lazer); } public OsuConfigManager(Storage storage) : base(storage) @@ -80,7 +80,7 @@ namespace osu.Game.Configuration } } - public enum OsuConfig + public enum OsuSetting { Ruleset, Token, diff --git a/osu.Game/Graphics/Containers/ParallaxContainer.cs b/osu.Game/Graphics/Containers/ParallaxContainer.cs index 8352656f8e..2d5952a3ce 100644 --- a/osu.Game/Graphics/Containers/ParallaxContainer.cs +++ b/osu.Game/Graphics/Containers/ParallaxContainer.cs @@ -39,7 +39,7 @@ namespace osu.Game.Graphics.Containers private void load(UserInputManager input, OsuConfigManager config) { this.input = input; - parallaxEnabled = config.GetBindable(OsuConfig.MenuParallax); + parallaxEnabled = config.GetBindable(OsuSetting.MenuParallax); parallaxEnabled.ValueChanged += delegate { if (!parallaxEnabled) diff --git a/osu.Game/Graphics/Cursor/GameplayCursor.cs b/osu.Game/Graphics/Cursor/GameplayCursor.cs index 3f699219a4..dcdbe675b4 100644 --- a/osu.Game/Graphics/Cursor/GameplayCursor.cs +++ b/osu.Game/Graphics/Cursor/GameplayCursor.cs @@ -114,7 +114,7 @@ namespace osu.Game.Graphics.Cursor }, }; - cursorScale = config.GetBindable(OsuConfig.GameplayCursorSize); + cursorScale = config.GetBindable(OsuSetting.GameplayCursorSize); cursorScale.ValueChanged += newScale => cursorContainer.Scale = new Vector2((float)cursorScale); cursorScale.TriggerChange(); } diff --git a/osu.Game/Graphics/Cursor/MenuCursor.cs b/osu.Game/Graphics/Cursor/MenuCursor.cs index 8d5f95aad5..b48ab879a6 100644 --- a/osu.Game/Graphics/Cursor/MenuCursor.cs +++ b/osu.Game/Graphics/Cursor/MenuCursor.cs @@ -128,7 +128,7 @@ namespace osu.Game.Graphics.Cursor } }; - cursorScale = config.GetBindable(OsuConfig.MenuCursorSize); + cursorScale = config.GetBindable(OsuSetting.MenuCursorSize); cursorScale.ValueChanged += newScale => cursorContainer.Scale = new Vector2((float)newScale); cursorScale.TriggerChange(); } diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 8d9d5cd26c..9ce725661b 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -88,7 +88,7 @@ namespace osu.Game Dependencies.Cache(this); - configRuleset = LocalConfig.GetBindable(OsuConfig.Ruleset); + configRuleset = LocalConfig.GetBindable(OsuSetting.Ruleset); Ruleset.Value = RulesetDatabase.GetRuleset(configRuleset.Value); Ruleset.ValueChanged += r => configRuleset.Value = r.ID ?? 0; } diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index a814b5f125..7e16030ec3 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -125,8 +125,8 @@ namespace osu.Game Dependencies.Cache(API = new APIAccess { - Username = LocalConfig.Get(OsuConfig.Username), - Token = LocalConfig.Get(OsuConfig.Token) + Username = LocalConfig.Get(OsuSetting.Username), + Token = LocalConfig.Get(OsuSetting.Token) }); API.Register(this); @@ -137,7 +137,7 @@ namespace osu.Game switch (state) { case APIState.Online: - LocalConfig.Set(OsuConfig.Username, LocalConfig.Get(OsuConfig.SaveUsername) ? API.Username : string.Empty); + LocalConfig.Set(OsuSetting.Username, LocalConfig.Get(OsuSetting.SaveUsername) ? API.Username : string.Empty); break; } } @@ -166,7 +166,7 @@ namespace osu.Game // TODO: This is temporary until we reimplement the local FPS display. // It's just to allow end-users to access the framework FPS display without knowing the shortcut key. - fpsDisplayVisible = LocalConfig.GetBindable(OsuConfig.ShowFpsDisplay); + fpsDisplayVisible = LocalConfig.GetBindable(OsuSetting.ShowFpsDisplay); fpsDisplayVisible.ValueChanged += val => { FrameStatisticsMode = val ? FrameStatisticsMode.Minimal : FrameStatisticsMode.None; @@ -192,7 +192,7 @@ namespace osu.Game //refresh token may have changed. if (LocalConfig != null && API != null) { - LocalConfig.Set(OsuConfig.Token, LocalConfig.Get(OsuConfig.SavePassword) ? API.Token : string.Empty); + LocalConfig.Set(OsuSetting.Token, LocalConfig.Get(OsuSetting.SavePassword) ? API.Token : string.Empty); LocalConfig.Save(); } diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index 15f8586125..7c5651b5ff 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -195,7 +195,7 @@ namespace osu.Game.Overlays this.api = api; api.Register(this); - chatHeight = config.GetBindable(OsuConfig.ChatDisplayHeight); + chatHeight = config.GetBindable(OsuSetting.ChatDisplayHeight); chatHeight.ValueChanged += h => { Height = (float)h; diff --git a/osu.Game/Overlays/Settings/Sections/Audio/MainMenuSettings.cs b/osu.Game/Overlays/Settings/Sections/Audio/MainMenuSettings.cs index 8101720d04..41a1bad364 100644 --- a/osu.Game/Overlays/Settings/Sections/Audio/MainMenuSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Audio/MainMenuSettings.cs @@ -18,12 +18,12 @@ namespace osu.Game.Overlays.Settings.Sections.Audio new SettingsCheckbox { LabelText = "Interface voices", - Bindable = config.GetBindable(OsuConfig.MenuVoice) + Bindable = config.GetBindable(OsuSetting.MenuVoice) }, new SettingsCheckbox { LabelText = "osu! music theme", - Bindable = config.GetBindable(OsuConfig.MenuMusic) + Bindable = config.GetBindable(OsuSetting.MenuMusic) }, }; } diff --git a/osu.Game/Overlays/Settings/Sections/Audio/OffsetSettings.cs b/osu.Game/Overlays/Settings/Sections/Audio/OffsetSettings.cs index 593002eb36..bc09a2145a 100644 --- a/osu.Game/Overlays/Settings/Sections/Audio/OffsetSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Audio/OffsetSettings.cs @@ -20,7 +20,7 @@ namespace osu.Game.Overlays.Settings.Sections.Audio new SettingsSlider { LabelText = "Audio Offset", - Bindable = config.GetBindable(OsuConfig.AudioOffset) + Bindable = config.GetBindable(OsuSetting.AudioOffset) }, new OsuButton { diff --git a/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs b/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs index 770ec3aaf3..a8ec04514a 100644 --- a/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs @@ -19,17 +19,17 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay new SettingsSlider { LabelText = "Background dim", - Bindable = config.GetBindable(OsuConfig.DimLevel) + Bindable = config.GetBindable(OsuSetting.DimLevel) }, new SettingsCheckbox { LabelText = "Show score overlay", - Bindable = config.GetBindable(OsuConfig.ShowInterface) + Bindable = config.GetBindable(OsuSetting.ShowInterface) }, new SettingsCheckbox { LabelText = "Always show key overlay", - Bindable = config.GetBindable(OsuConfig.KeyOverlay) + Bindable = config.GetBindable(OsuSetting.KeyOverlay) }, }; } diff --git a/osu.Game/Overlays/Settings/Sections/Gameplay/SongSelectSettings.cs b/osu.Game/Overlays/Settings/Sections/Gameplay/SongSelectSettings.cs index 14d6f36535..7626911627 100644 --- a/osu.Game/Overlays/Settings/Sections/Gameplay/SongSelectSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Gameplay/SongSelectSettings.cs @@ -20,12 +20,12 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay new SettingsSlider { LabelText = "Display beatmaps from", - Bindable = config.GetBindable(OsuConfig.DisplayStarsMinimum) + Bindable = config.GetBindable(OsuSetting.DisplayStarsMinimum) }, new SettingsSlider { LabelText = "up to", - Bindable = config.GetBindable(OsuConfig.DisplayStarsMaximum) + Bindable = config.GetBindable(OsuSetting.DisplayStarsMaximum) }, }; } diff --git a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs index 3193c2eb5a..86a47d8a95 100644 --- a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs @@ -135,12 +135,12 @@ namespace osu.Game.Overlays.Settings.Sections.General new SettingsCheckbox { LabelText = "Remember username", - Bindable = config.GetBindable(OsuConfig.SaveUsername), + Bindable = config.GetBindable(OsuSetting.SaveUsername), }, new SettingsCheckbox { LabelText = "Stay logged in", - Bindable = config.GetBindable(OsuConfig.SavePassword), + Bindable = config.GetBindable(OsuSetting.SavePassword), }, new OsuButton { diff --git a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs index 3f2f073bff..3ceb8d2ff4 100644 --- a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs @@ -21,7 +21,7 @@ namespace osu.Game.Overlays.Settings.Sections.General new SettingsEnumDropdown { LabelText = "Release stream", - Bindable = config.GetBindable(OsuConfig.ReleaseStream), + Bindable = config.GetBindable(OsuSetting.ReleaseStream), }, new OsuButton { diff --git a/osu.Game/Overlays/Settings/Sections/Graphics/DetailSettings.cs b/osu.Game/Overlays/Settings/Sections/Graphics/DetailSettings.cs index 5bfb8a4373..78eab6ebd8 100644 --- a/osu.Game/Overlays/Settings/Sections/Graphics/DetailSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Graphics/DetailSettings.cs @@ -19,12 +19,12 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics new SettingsCheckbox { LabelText = "Snaking in sliders", - Bindable = config.GetBindable(OsuConfig.SnakingInSliders) + Bindable = config.GetBindable(OsuSetting.SnakingInSliders) }, new SettingsCheckbox { LabelText = "Snaking out sliders", - Bindable = config.GetBindable(OsuConfig.SnakingOutSliders) + Bindable = config.GetBindable(OsuSetting.SnakingOutSliders) }, }; } diff --git a/osu.Game/Overlays/Settings/Sections/Graphics/MainMenuSettings.cs b/osu.Game/Overlays/Settings/Sections/Graphics/MainMenuSettings.cs index fd135e336f..7fe5be2fa1 100644 --- a/osu.Game/Overlays/Settings/Sections/Graphics/MainMenuSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Graphics/MainMenuSettings.cs @@ -18,7 +18,7 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics new SettingsCheckbox { LabelText = "Parallax", - Bindable = config.GetBindable(OsuConfig.MenuParallax) + Bindable = config.GetBindable(OsuSetting.MenuParallax) }, }; } diff --git a/osu.Game/Overlays/Settings/Sections/Graphics/RendererSettings.cs b/osu.Game/Overlays/Settings/Sections/Graphics/RendererSettings.cs index 0c79c8cd42..8e84a25bb9 100644 --- a/osu.Game/Overlays/Settings/Sections/Graphics/RendererSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Graphics/RendererSettings.cs @@ -27,7 +27,7 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics new SettingsCheckbox { LabelText = "Show FPS", - Bindable = osuConfig.GetBindable(OsuConfig.ShowFpsDisplay) + Bindable = osuConfig.GetBindable(OsuSetting.ShowFpsDisplay) }, }; } diff --git a/osu.Game/Overlays/Settings/Sections/Input/MouseSettings.cs b/osu.Game/Overlays/Settings/Sections/Input/MouseSettings.cs index 7bf42fd7e7..9cf5c42319 100644 --- a/osu.Game/Overlays/Settings/Sections/Input/MouseSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Input/MouseSettings.cs @@ -27,12 +27,12 @@ namespace osu.Game.Overlays.Settings.Sections.Input new SettingsCheckbox { LabelText = "Disable mouse wheel during gameplay", - Bindable = osuConfig.GetBindable(OsuConfig.MouseDisableWheel) + Bindable = osuConfig.GetBindable(OsuSetting.MouseDisableWheel) }, new SettingsCheckbox { LabelText = "Disable mouse buttons during gameplay", - Bindable = osuConfig.GetBindable(OsuConfig.MouseDisableButtons) + Bindable = osuConfig.GetBindable(OsuSetting.MouseDisableButtons) }, }; } diff --git a/osu.Game/Overlays/Settings/Sections/SkinSection.cs b/osu.Game/Overlays/Settings/Sections/SkinSection.cs index cc416f45ca..46bc899499 100644 --- a/osu.Game/Overlays/Settings/Sections/SkinSection.cs +++ b/osu.Game/Overlays/Settings/Sections/SkinSection.cs @@ -24,12 +24,12 @@ namespace osu.Game.Overlays.Settings.Sections new SettingsSlider { LabelText = "Menu cursor size", - Bindable = config.GetBindable(OsuConfig.MenuCursorSize) + Bindable = config.GetBindable(OsuSetting.MenuCursorSize) }, new SettingsSlider { LabelText = "Gameplay cursor size", - Bindable = config.GetBindable(OsuConfig.GameplayCursorSize) + Bindable = config.GetBindable(OsuSetting.GameplayCursorSize) }, }; } diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index 92032e5120..01659edd72 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -64,8 +64,8 @@ namespace osu.Game.Screens.Menu [BackgroundDependencyLoader] private void load(AudioManager audio, OsuConfigManager config) { - menuVoice = config.GetBindable(OsuConfig.MenuVoice); - menuMusic = config.GetBindable(OsuConfig.MenuMusic); + menuVoice = config.GetBindable(OsuSetting.MenuVoice); + menuMusic = config.GetBindable(OsuSetting.MenuMusic); bgm = audio.Track.Get(@"circles"); bgm.Looping = true; diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index 3e03a9aac8..71d020b0f2 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -66,7 +66,7 @@ namespace osu.Game.Screens.Menu [BackgroundDependencyLoader] private void load(OsuGame game, OsuConfigManager config, BeatmapDatabase beatmaps) { - menuMusic = config.GetBindable(OsuConfig.MenuMusic); + menuMusic = config.GetBindable(OsuSetting.MenuMusic); LoadComponentAsync(background); if (!menuMusic) diff --git a/osu.Game/Screens/Play/HUDOverlay.cs b/osu.Game/Screens/Play/HUDOverlay.cs index 12e2cb197e..1e57c2ba2a 100644 --- a/osu.Game/Screens/Play/HUDOverlay.cs +++ b/osu.Game/Screens/Play/HUDOverlay.cs @@ -67,7 +67,7 @@ namespace osu.Game.Screens.Play [BackgroundDependencyLoader(true)] private void load(OsuConfigManager config, NotificationManager notificationManager) { - showKeyCounter = config.GetBindable(OsuConfig.KeyOverlay); + showKeyCounter = config.GetBindable(OsuSetting.KeyOverlay); showKeyCounter.ValueChanged += keyCounterVisibility => { if (keyCounterVisibility) @@ -77,7 +77,7 @@ namespace osu.Game.Screens.Play }; showKeyCounter.TriggerChange(); - showHud = config.GetBindable(OsuConfig.ShowInterface); + showHud = config.GetBindable(OsuSetting.ShowInterface); showHud.ValueChanged += hudVisibility => { if (hudVisibility) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 7b910c11e5..de390b63b3 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -79,8 +79,8 @@ namespace osu.Game.Screens.Play [BackgroundDependencyLoader(permitNulls: true)] private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuConfigManager config, OsuGame osu) { - dimLevel = config.GetBindable(OsuConfig.DimLevel); - mouseWheelDisabled = config.GetBindable(OsuConfig.MouseDisableWheel); + dimLevel = config.GetBindable(OsuSetting.DimLevel); + mouseWheelDisabled = config.GetBindable(OsuSetting.MouseDisableWheel); Ruleset rulesetInstance; @@ -138,7 +138,7 @@ namespace osu.Game.Screens.Play offsetClock = new FramedOffsetClock(decoupledClock); - userAudioOffset = config.GetBindable(OsuConfig.AudioOffset); + userAudioOffset = config.GetBindable(OsuSetting.AudioOffset); userAudioOffset.ValueChanged += v => offsetClock.Offset = v; userAudioOffset.TriggerChange(); diff --git a/osu.Game/Screens/Play/PlayerInputManager.cs b/osu.Game/Screens/Play/PlayerInputManager.cs index 9707ccbc35..f5e57f9e9d 100644 --- a/osu.Game/Screens/Play/PlayerInputManager.cs +++ b/osu.Game/Screens/Play/PlayerInputManager.cs @@ -40,7 +40,7 @@ namespace osu.Game.Screens.Play [BackgroundDependencyLoader] private void load(OsuConfigManager config) { - mouseDisabled = config.GetBindable(OsuConfig.MouseDisableButtons); + mouseDisabled = config.GetBindable(OsuSetting.MouseDisableButtons); } protected override void LoadComplete() diff --git a/osu.Game/Screens/Select/BeatmapDetailAreaTabControl.cs b/osu.Game/Screens/Select/BeatmapDetailAreaTabControl.cs index 51ec6f7707..e3c95d42a1 100644 --- a/osu.Game/Screens/Select/BeatmapDetailAreaTabControl.cs +++ b/osu.Game/Screens/Select/BeatmapDetailAreaTabControl.cs @@ -35,7 +35,7 @@ namespace osu.Game.Screens.Select { modsCheckbox.AccentColour = tabs.AccentColour = colour.YellowLight; - selectedTab = config.GetBindable(OsuConfig.BeatmapDetailTab); + selectedTab = config.GetBindable(OsuSetting.BeatmapDetailTab); tabs.Current.BindTo(selectedTab); tabs.Current.TriggerChange(); From d969507f65a8d3fde2a18acb4c191dfcef7cbcda Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 15 May 2017 11:14:19 +0900 Subject: [PATCH 201/329] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index f699dfe3c9..fa44e5a47e 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit f699dfe3c995c43b15cd66ec094d628bac1697c0 +Subproject commit fa44e5a47e20956b12e598e85159a1a25b500b3c From f73076918607487569b5aaf66283fbc0fbc27ed8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 15 May 2017 12:54:56 +0900 Subject: [PATCH 202/329] 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 203/329] 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 dcd4b4450d4fa41d165e4714f22f6078ce80b4e2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 15 May 2017 13:26:35 +0900 Subject: [PATCH 204/329] Add error message in chat when attempting to use commands --- osu.Game/Online/Chat/Channel.cs | 4 +- osu.Game/Online/Chat/ErrorMessage.cs | 25 ++++++++++ osu.Game/Online/Chat/Message.cs | 5 ++ osu.Game/Overlays/ChatOverlay.cs | 69 +++++++++++++++------------- osu.Game/osu.Game.csproj | 1 + 5 files changed, 71 insertions(+), 33 deletions(-) create mode 100644 osu.Game/Online/Chat/ErrorMessage.cs diff --git a/osu.Game/Online/Chat/Channel.cs b/osu.Game/Online/Chat/Channel.cs index d159f482a9..2925c3ccb4 100644 --- a/osu.Game/Online/Chat/Channel.cs +++ b/osu.Game/Online/Chat/Channel.cs @@ -38,9 +38,9 @@ namespace osu.Game.Online.Chat public event Action> NewMessagesArrived; - public void AddNewMessages(IEnumerable messages) + public void AddNewMessages(params Message[] messages) { - messages = messages.Except(Messages).ToList(); + messages = messages.Except(Messages).ToArray(); Messages.AddRange(messages); diff --git a/osu.Game/Online/Chat/ErrorMessage.cs b/osu.Game/Online/Chat/ErrorMessage.cs new file mode 100644 index 0000000000..a410e9044a --- /dev/null +++ b/osu.Game/Online/Chat/ErrorMessage.cs @@ -0,0 +1,25 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using osu.Game.Users; + +namespace osu.Game.Online.Chat +{ + public class ErrorMessage : Message + { + private static int errorId = -1; + + public ErrorMessage(string message) : base(errorId--) + { + Timestamp = DateTime.Now; + Content = message; + + Sender = new User + { + Username = @"system", + Colour = @"ff0000", + }; + } + } +} \ No newline at end of file diff --git a/osu.Game/Online/Chat/Message.cs b/osu.Game/Online/Chat/Message.cs index 372e43be38..bf53a68910 100644 --- a/osu.Game/Online/Chat/Message.cs +++ b/osu.Game/Online/Chat/Message.cs @@ -37,6 +37,11 @@ namespace osu.Game.Online.Chat { } + public Message(long id) + { + Id = id; + } + public override bool Equals(object obj) { var objMessage = obj as Message; diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index 7c5651b5ff..d43d0b22aa 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -306,7 +306,7 @@ namespace osu.Game.Overlays //batch messages per channel. foreach (var id in ids) - careChannels.Find(c => c.Id == id)?.AddNewMessages(messages.Where(m => m.TargetId == id)); + careChannels.Find(c => c.Id == id)?.AddNewMessages(messages.Where(m => m.TargetId == id).ToArray()); lastMessageId = messages.LastOrDefault()?.Id ?? lastMessageId; @@ -326,38 +326,45 @@ namespace osu.Game.Overlays { var postText = textbox.Text; - if (!string.IsNullOrEmpty(postText) && api.LocalUser.Value != null) + if (string.IsNullOrEmpty(postText) || api.LocalUser.Value == null) return; + + if (currentChannel == null) return; + + if (postText[0] == '/') { - if (currentChannel == null) return; - - var message = new Message - { - Sender = api.LocalUser.Value, - Timestamp = DateTimeOffset.Now, - TargetType = TargetType.Channel, //TODO: read this from currentChannel - TargetId = currentChannel.Id, - Content = postText - }; - - textbox.ReadOnly = true; - var req = new PostMessageRequest(message); - - req.Failure += e => - { - textbox.FlashColour(Color4.Red, 1000); - textbox.ReadOnly = false; - }; - - req.Success += m => - { - currentChannel.AddNewMessages(new[] { m }); - - textbox.ReadOnly = false; - textbox.Text = string.Empty; - }; - - api.Queue(req); + // TODO: handle commands + currentChannel.AddNewMessages(new ErrorMessage("Chat commands are not supported yet!")); + textbox.Text = string.Empty; + return; } + + var message = new Message + { + Sender = api.LocalUser.Value, + Timestamp = DateTimeOffset.Now, + TargetType = TargetType.Channel, //TODO: read this from currentChannel + TargetId = currentChannel.Id, + Content = postText + }; + + textbox.ReadOnly = true; + var req = new PostMessageRequest(message); + + req.Failure += e => + { + textbox.FlashColour(Color4.Red, 1000); + textbox.ReadOnly = false; + }; + + req.Success += m => + { + currentChannel.AddNewMessages(m); + + textbox.ReadOnly = false; + textbox.Text = string.Empty; + }; + + api.Queue(req); } } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 1f866f0e17..919b2bb732 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -75,6 +75,7 @@ + From 3b1d5ce7df2881d981d507fb602f12ebefc600f9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 15 May 2017 13:31:51 +0900 Subject: [PATCH 205/329] CI fix --- osu.Game/Overlays/ChatOverlay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index d43d0b22aa..111d3e5eb4 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -337,7 +337,7 @@ namespace osu.Game.Overlays textbox.Text = string.Empty; return; } - + var message = new Message { Sender = api.LocalUser.Value, From fa889c4340a9295d7862530041b2d0c08aaf315a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 15 May 2017 16:20:02 +0900 Subject: [PATCH 206/329] 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 From 23760d6805251e7f499e196421ba91d47b760008 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 15 May 2017 19:36:03 +0900 Subject: [PATCH 207/329] Adjust osu! logo metrics and add shockwave impact animation --- osu-resources | 2 +- osu.Game/Screens/Menu/ButtonSystem.cs | 6 ++++ osu.Game/Screens/Menu/OsuLogo.cs | 42 ++++++++++++++++++++++++--- 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/osu-resources b/osu-resources index b90c4ed490..ffccbeb98d 160000 --- a/osu-resources +++ b/osu-resources @@ -1 +1 @@ -Subproject commit b90c4ed490f76f2995662b3a8af3a32b8756a012 +Subproject commit ffccbeb98dc9e8f0965520270b5885e63f244c83 diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index 2f418d2f88..72db445052 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -245,8 +245,14 @@ namespace osu.Game.Screens.Menu buttonArea.FadeIn(300); if (lastState == MenuState.Initial) + { buttonArea.Delay(150, true); + if (osuLogo.Scale.X > 0.5f) + using (osuLogo.BeginDelayedSequence(200, true)) + osuLogo.Impact(); + } + Scheduler.AddDelayed(() => toolbar?.Show(), 150); foreach (Button b in buttonsTopLevel) diff --git a/osu.Game/Screens/Menu/OsuLogo.cs b/osu.Game/Screens/Menu/OsuLogo.cs index f3fffedd43..e28adeacff 100644 --- a/osu.Game/Screens/Menu/OsuLogo.cs +++ b/osu.Game/Screens/Menu/OsuLogo.cs @@ -35,7 +35,7 @@ namespace osu.Game.Screens.Menu public Action Action; - public float SizeForFlow => logo == null ? 0 : logo.DrawSize.X * logo.Scale.X * logoBounceContainer.Scale.X * logoHoverContainer.Scale.X * 0.78f; + public float SizeForFlow => logo == null ? 0 : logo.DrawSize.X * logo.Scale.X * logoBounceContainer.Scale.X * logoHoverContainer.Scale.X * 0.74f; private readonly Sprite ripple; @@ -63,8 +63,14 @@ namespace osu.Game.Screens.Menu public bool Interactive = true; private readonly Box flashLayer; + private readonly Container impactContainer; + + private const float default_size = 480; + public OsuLogo() { + Size = new Vector2(default_size); + Anchor = Anchor.Centre; Origin = Anchor.Centre; @@ -92,7 +98,7 @@ namespace osu.Game.Screens.Menu Anchor = Anchor.Centre, Origin = Anchor.Centre, RelativeSizeAxes = Axes.Both, - Scale = new Vector2(0.8f), + Scale = new Vector2(0.88f), Masking = true, Children = new Drawable[] { @@ -137,6 +143,7 @@ namespace osu.Game.Screens.Menu { Anchor = Anchor.Centre, Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, Children = new Drawable[] { ripple = new Sprite @@ -148,11 +155,30 @@ namespace osu.Game.Screens.Menu } } }, + impactContainer = new CircularContainer + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Alpha = 0, + BorderColour = Color4.White, + RelativeSizeAxes = Axes.Both, + BorderThickness = 10, + Masking = true, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + AlwaysPresent = true, + Alpha = 0, + } + } + }, new MenuVisualisation { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Size = logo.Size, + RelativeSizeAxes = Axes.Both, BlendingMode = BlendingMode.Additive, Alpha = 0.2f, } @@ -211,7 +237,8 @@ namespace osu.Game.Screens.Menu protected override bool OnHover(InputState state) { if (!Interactive) return false; - logoHoverContainer.ScaleTo(1.2f, 500, EasingTypes.OutElastic); + + logoHoverContainer.ScaleTo(1.1f, 500, EasingTypes.OutElastic); return true; } @@ -219,5 +246,12 @@ namespace osu.Game.Screens.Menu { logoHoverContainer.ScaleTo(1, 500, EasingTypes.OutElastic); } + + public void Impact() + { + impactContainer.FadeOutFromOne(250, EasingTypes.In); + impactContainer.ScaleTo(0.96f); + impactContainer.ScaleTo(1.12f, 250); + } } } \ No newline at end of file From efab186384aefe32c8353416da2287a5dc59b356 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 16 May 2017 12:50:30 +0900 Subject: [PATCH 208/329] Update namespaces in line with framework --- osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs | 1 - osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs | 1 - osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs | 2 +- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 1 - .../Objects/Drawables/Pieces/ElongatedCirclePiece.cs | 2 +- osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs | 1 - osu.Game/Beatmaps/Drawables/BeatmapPanel.cs | 1 - osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs | 1 - osu.Game/Graphics/Cursor/TooltipContainer.cs | 1 - osu.Game/Graphics/UserInterface/OsuCheckbox.cs | 1 - osu.Game/Graphics/UserInterface/OsuDropdown.cs | 1 - osu.Game/Graphics/UserInterface/OsuMenu.cs | 1 - osu.Game/Graphics/UserInterface/OsuTabControl.cs | 1 - osu.Game/Graphics/UserInterface/OsuTabControlCheckbox.cs | 1 - osu.Game/Graphics/UserInterface/OsuTextBox.cs | 1 - osu.Game/Graphics/UserInterface/SearchTextBox.cs | 1 - osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs | 1 - osu.Game/OsuGame.cs | 1 - osu.Game/Overlays/Chat/ChatLine.cs | 1 - osu.Game/Overlays/Chat/ChatTabControl.cs | 1 - osu.Game/Overlays/Chat/DrawableChannel.cs | 1 - osu.Game/Overlays/ChatOverlay.cs | 1 - osu.Game/Overlays/Dialog/PopupDialog.cs | 1 - osu.Game/Overlays/LoginOverlay.cs | 1 - osu.Game/Overlays/Mods/ModSection.cs | 1 - osu.Game/Overlays/Mods/ModSelectOverlay.cs | 1 - osu.Game/Overlays/Music/FilterControl.cs | 1 - osu.Game/Overlays/Music/PlaylistItem.cs | 1 - osu.Game/Overlays/Music/PlaylistOverlay.cs | 1 - osu.Game/Overlays/MusicController.cs | 1 - osu.Game/Overlays/NotificationManager.cs | 1 - osu.Game/Overlays/Notifications/Notification.cs | 1 - osu.Game/Overlays/Notifications/NotificationSection.cs | 1 - osu.Game/Overlays/Settings/SettingsDropdown.cs | 1 - osu.Game/Overlays/Settings/SettingsFooter.cs | 1 - osu.Game/Overlays/Settings/SettingsHeader.cs | 1 - osu.Game/Overlays/Settings/SettingsItem.cs | 1 - osu.Game/Overlays/Settings/SettingsSection.cs | 1 - osu.Game/Overlays/Settings/SettingsSlider.cs | 1 - osu.Game/Overlays/Settings/SettingsSubsection.cs | 1 - osu.Game/Overlays/SettingsOverlay.cs | 1 - osu.Game/Overlays/Toolbar/ToolbarButton.cs | 1 - osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs | 1 - osu.Game/Screens/Menu/Disclaimer.cs | 1 - osu.Game/Screens/Play/HUD/ComboCounter.cs | 1 - osu.Game/Screens/Play/HUD/ModDisplay.cs | 1 - osu.Game/Screens/Play/Pause/PauseProgressBar.cs | 1 - osu.Game/Screens/Play/PlayerLoader.cs | 1 - osu.Game/Screens/Play/SongProgress.cs | 1 - osu.Game/Screens/Play/SongProgressInfo.cs | 1 - osu.Game/Screens/Play/StandardHUDOverlay.cs | 1 - osu.Game/Screens/Ranking/ResultModeTabControl.cs | 1 - osu.Game/Screens/Ranking/Results.cs | 1 - osu.Game/Screens/Ranking/ResultsPageScore.cs | 1 - osu.Game/Screens/Select/BeatmapDetailArea.cs | 1 - osu.Game/Screens/Select/BeatmapDetails.cs | 1 - osu.Game/Screens/Select/BeatmapInfoWedge.cs | 1 - osu.Game/Screens/Select/FilterControl.cs | 1 - osu.Game/Screens/Select/Leaderboards/Leaderboard.cs | 1 - osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs | 1 - osu.Game/Screens/Select/Options/BeatmapOptionsButton.cs | 1 - osu.Game/Screens/Select/PlaySongSelect.cs | 1 - osu.Game/Screens/Select/SongSelect.cs | 1 - osu.Game/Screens/Tournament/Drawings.cs | 1 - osu.Game/Screens/Tournament/Group.cs | 1 - 65 files changed, 2 insertions(+), 65 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs index 4a59ad9534..58cbad936a 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Graphics; -using osu.Framework.Graphics.Primitives; using osu.Framework.Testing; using osu.Game.Database; using osu.Game.Screens.Select; diff --git a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs index cfa66f12ed..f86fa4dab5 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs @@ -3,7 +3,6 @@ using OpenTK; using osu.Framework.Graphics; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.MathUtils; using osu.Framework.Testing; diff --git a/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs b/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs index b72abd1992..96933a15e7 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs @@ -1,8 +1,8 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Framework.Graphics; using OpenTK; -using osu.Framework.Graphics.Primitives; using osu.Framework.Testing; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index 438c1f4b5f..487304d7f3 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -10,7 +10,6 @@ using OpenTK.Graphics; using osu.Game.Rulesets.Mania.Judgements; using osu.Framework.Graphics.Containers; using System; -using osu.Framework.Graphics.Primitives; using osu.Game.Graphics; using osu.Framework.Allocation; using OpenTK.Input; diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/ElongatedCirclePiece.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/ElongatedCirclePiece.cs index bed54d358e..f607e2040f 100644 --- a/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/ElongatedCirclePiece.cs +++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/ElongatedCirclePiece.cs @@ -2,7 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using osu.Framework.Graphics.Primitives; +using osu.Framework.Graphics; namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces { diff --git a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs index 23c7606a15..2278158506 100644 --- a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs +++ b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs @@ -13,7 +13,6 @@ using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Extensions.Color4Extensions; -using osu.Framework.Graphics.Primitives; using System.Linq; using osu.Game.Rulesets.Taiko.Objects.Drawables; using System; diff --git a/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs b/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs index 34e4ebf8ac..cb929dcca5 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs @@ -5,7 +5,6 @@ using System; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Game.Database; using osu.Game.Graphics; diff --git a/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs b/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs index 8431e5f812..2ab5487082 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs @@ -9,7 +9,6 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Localisation; using osu.Game.Graphics.Sprites; diff --git a/osu.Game/Graphics/Cursor/TooltipContainer.cs b/osu.Game/Graphics/Cursor/TooltipContainer.cs index 5f0743746a..c5b8382816 100644 --- a/osu.Game/Graphics/Cursor/TooltipContainer.cs +++ b/osu.Game/Graphics/Cursor/TooltipContainer.cs @@ -8,7 +8,6 @@ using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Input; using osu.Framework.Threading; diff --git a/osu.Game/Graphics/UserInterface/OsuCheckbox.cs b/osu.Game/Graphics/UserInterface/OsuCheckbox.cs index e81db4954e..85231ffab9 100644 --- a/osu.Game/Graphics/UserInterface/OsuCheckbox.cs +++ b/osu.Game/Graphics/UserInterface/OsuCheckbox.cs @@ -6,7 +6,6 @@ using osu.Framework.Audio; using osu.Framework.Audio.Sample; using osu.Framework.Configuration; using osu.Framework.Graphics; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; using osu.Framework.Input; diff --git a/osu.Game/Graphics/UserInterface/OsuDropdown.cs b/osu.Game/Graphics/UserInterface/OsuDropdown.cs index 59bee8baad..4f286ba7b5 100644 --- a/osu.Game/Graphics/UserInterface/OsuDropdown.cs +++ b/osu.Game/Graphics/UserInterface/OsuDropdown.cs @@ -7,7 +7,6 @@ using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics.Sprites; diff --git a/osu.Game/Graphics/UserInterface/OsuMenu.cs b/osu.Game/Graphics/UserInterface/OsuMenu.cs index c51c5d210e..84b88da96e 100644 --- a/osu.Game/Graphics/UserInterface/OsuMenu.cs +++ b/osu.Game/Graphics/UserInterface/OsuMenu.cs @@ -5,7 +5,6 @@ using OpenTK; using OpenTK.Graphics; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.UserInterface; namespace osu.Game.Graphics.UserInterface diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index 8b72eedbfd..a9fad0c739 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -9,7 +9,6 @@ using osu.Framework.Allocation; using osu.Framework.Extensions; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; using osu.Framework.Input; diff --git a/osu.Game/Graphics/UserInterface/OsuTabControlCheckbox.cs b/osu.Game/Graphics/UserInterface/OsuTabControlCheckbox.cs index f732916889..6fc3875f61 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControlCheckbox.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControlCheckbox.cs @@ -6,7 +6,6 @@ using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; using osu.Framework.Input; diff --git a/osu.Game/Graphics/UserInterface/OsuTextBox.cs b/osu.Game/Graphics/UserInterface/OsuTextBox.cs index 62b10b96ef..97c38f6b85 100644 --- a/osu.Game/Graphics/UserInterface/OsuTextBox.cs +++ b/osu.Game/Graphics/UserInterface/OsuTextBox.cs @@ -3,7 +3,6 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; using osu.Framework.Input; diff --git a/osu.Game/Graphics/UserInterface/SearchTextBox.cs b/osu.Game/Graphics/UserInterface/SearchTextBox.cs index 6a8236529b..0a37024d0f 100644 --- a/osu.Game/Graphics/UserInterface/SearchTextBox.cs +++ b/osu.Game/Graphics/UserInterface/SearchTextBox.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Graphics; -using osu.Framework.Graphics.Primitives; using osu.Framework.Input; using OpenTK.Input; diff --git a/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs b/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs index 4933c170e8..f2ae47354e 100644 --- a/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs +++ b/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs @@ -6,7 +6,6 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Input; using osu.Framework.Threading; using OpenTK; -using osu.Framework.Graphics.Primitives; using osu.Framework.Audio; using osu.Framework.Allocation; diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 9ce725661b..5a3b47eb23 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -19,7 +19,6 @@ using osu.Game.Screens; using osu.Game.Screens.Menu; using OpenTK; using System.Linq; -using osu.Framework.Graphics.Primitives; using System.Threading.Tasks; using osu.Framework.Threading; using osu.Game.Database; diff --git a/osu.Game/Overlays/Chat/ChatLine.cs b/osu.Game/Overlays/Chat/ChatLine.cs index d4063efbb5..3aaca7593c 100644 --- a/osu.Game/Overlays/Chat/ChatLine.cs +++ b/osu.Game/Overlays/Chat/ChatLine.cs @@ -3,7 +3,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Online.Chat; diff --git a/osu.Game/Overlays/Chat/ChatTabControl.cs b/osu.Game/Overlays/Chat/ChatTabControl.cs index c7e1382255..5778999a0c 100644 --- a/osu.Game/Overlays/Chat/ChatTabControl.cs +++ b/osu.Game/Overlays/Chat/ChatTabControl.cs @@ -5,7 +5,6 @@ using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; using osu.Framework.Input; diff --git a/osu.Game/Overlays/Chat/DrawableChannel.cs b/osu.Game/Overlays/Chat/DrawableChannel.cs index 39dc1914ab..355aeed134 100644 --- a/osu.Game/Overlays/Chat/DrawableChannel.cs +++ b/osu.Game/Overlays/Chat/DrawableChannel.cs @@ -6,7 +6,6 @@ using System.Collections.Generic; using System.Linq; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Game.Online.Chat; namespace osu.Game.Overlays.Chat diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index 7c5651b5ff..ed6ecdffcf 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -17,7 +17,6 @@ using osu.Game.Online.API; using osu.Game.Online.API.Requests; using osu.Game.Online.Chat; using osu.Game.Graphics.UserInterface; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.UserInterface; using OpenTK.Graphics; using osu.Framework.Input; diff --git a/osu.Game/Overlays/Dialog/PopupDialog.cs b/osu.Game/Overlays/Dialog/PopupDialog.cs index b4127c8af4..47674de817 100644 --- a/osu.Game/Overlays/Dialog/PopupDialog.cs +++ b/osu.Game/Overlays/Dialog/PopupDialog.cs @@ -6,7 +6,6 @@ using System.Linq; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Input; using osu.Game.Graphics; diff --git a/osu.Game/Overlays/LoginOverlay.cs b/osu.Game/Overlays/LoginOverlay.cs index 8c4a3b85c0..e555600028 100644 --- a/osu.Game/Overlays/LoginOverlay.cs +++ b/osu.Game/Overlays/LoginOverlay.cs @@ -4,7 +4,6 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; using osu.Game.Overlays.Settings.Sections.General; diff --git a/osu.Game/Overlays/Mods/ModSection.cs b/osu.Game/Overlays/Mods/ModSection.cs index 40bd1e8b07..aac8a72dd7 100644 --- a/osu.Game/Overlays/Mods/ModSection.cs +++ b/osu.Game/Overlays/Mods/ModSection.cs @@ -6,7 +6,6 @@ using OpenTK.Graphics; using OpenTK.Input; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Framework.Input; using osu.Game.Graphics.Sprites; using osu.Game.Rulesets.Mods; diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index 2840ffd1e4..c001d613e4 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -8,7 +8,6 @@ using osu.Framework.Configuration; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; using osu.Game.Graphics.Backgrounds; diff --git a/osu.Game/Overlays/Music/FilterControl.cs b/osu.Game/Overlays/Music/FilterControl.cs index f6188d941c..6d8790a9e8 100644 --- a/osu.Game/Overlays/Music/FilterControl.cs +++ b/osu.Game/Overlays/Music/FilterControl.cs @@ -6,7 +6,6 @@ using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; diff --git a/osu.Game/Overlays/Music/PlaylistItem.cs b/osu.Game/Overlays/Music/PlaylistItem.cs index c2413956b4..16978903a7 100644 --- a/osu.Game/Overlays/Music/PlaylistItem.cs +++ b/osu.Game/Overlays/Music/PlaylistItem.cs @@ -5,7 +5,6 @@ using System; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Game.Database; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; diff --git a/osu.Game/Overlays/Music/PlaylistOverlay.cs b/osu.Game/Overlays/Music/PlaylistOverlay.cs index eb5dff57b3..5e433aa414 100644 --- a/osu.Game/Overlays/Music/PlaylistOverlay.cs +++ b/osu.Game/Overlays/Music/PlaylistOverlay.cs @@ -10,7 +10,6 @@ using osu.Framework.Configuration; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Game.Beatmaps; using osu.Game.Database; diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index e3edaa0ca7..4faa339bed 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -12,7 +12,6 @@ using osu.Framework.Configuration; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; using osu.Framework.Input; diff --git a/osu.Game/Overlays/NotificationManager.cs b/osu.Game/Overlays/NotificationManager.cs index 264543367c..b344d533ee 100644 --- a/osu.Game/Overlays/NotificationManager.cs +++ b/osu.Game/Overlays/NotificationManager.cs @@ -6,7 +6,6 @@ using osu.Framework.Allocation; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Game.Overlays.Notifications; using OpenTK.Graphics; diff --git a/osu.Game/Overlays/Notifications/Notification.cs b/osu.Game/Overlays/Notifications/Notification.cs index 961e83e958..cb3efaf269 100644 --- a/osu.Game/Overlays/Notifications/Notification.cs +++ b/osu.Game/Overlays/Notifications/Notification.cs @@ -7,7 +7,6 @@ using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transforms; using osu.Framework.Input; diff --git a/osu.Game/Overlays/Notifications/NotificationSection.cs b/osu.Game/Overlays/Notifications/NotificationSection.cs index 663c5cf90c..b53f8e6b14 100644 --- a/osu.Game/Overlays/Notifications/NotificationSection.cs +++ b/osu.Game/Overlays/Notifications/NotificationSection.cs @@ -8,7 +8,6 @@ using osu.Framework.Allocation; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using OpenTK; diff --git a/osu.Game/Overlays/Settings/SettingsDropdown.cs b/osu.Game/Overlays/Settings/SettingsDropdown.cs index 8ce755b90e..bf2cd10b9d 100644 --- a/osu.Game/Overlays/Settings/SettingsDropdown.cs +++ b/osu.Game/Overlays/Settings/SettingsDropdown.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using osu.Framework.Graphics; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics.UserInterface; diff --git a/osu.Game/Overlays/Settings/SettingsFooter.cs b/osu.Game/Overlays/Settings/SettingsFooter.cs index a9293ac2af..be08e61c1a 100644 --- a/osu.Game/Overlays/Settings/SettingsFooter.cs +++ b/osu.Game/Overlays/Settings/SettingsFooter.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Game.Database; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; diff --git a/osu.Game/Overlays/Settings/SettingsHeader.cs b/osu.Game/Overlays/Settings/SettingsHeader.cs index 8a118120de..56018dc7d9 100644 --- a/osu.Game/Overlays/Settings/SettingsHeader.cs +++ b/osu.Game/Overlays/Settings/SettingsHeader.cs @@ -5,7 +5,6 @@ using System; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; diff --git a/osu.Game/Overlays/Settings/SettingsItem.cs b/osu.Game/Overlays/Settings/SettingsItem.cs index a40f895e0a..e592ca9e37 100644 --- a/osu.Game/Overlays/Settings/SettingsItem.cs +++ b/osu.Game/Overlays/Settings/SettingsItem.cs @@ -5,7 +5,6 @@ using OpenTK.Graphics; using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics.Sprites; diff --git a/osu.Game/Overlays/Settings/SettingsSection.cs b/osu.Game/Overlays/Settings/SettingsSection.cs index 66b860402a..8b95c72412 100644 --- a/osu.Game/Overlays/Settings/SettingsSection.cs +++ b/osu.Game/Overlays/Settings/SettingsSection.cs @@ -6,7 +6,6 @@ using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; diff --git a/osu.Game/Overlays/Settings/SettingsSlider.cs b/osu.Game/Overlays/Settings/SettingsSlider.cs index 9ce4efdd52..beb2bdf645 100644 --- a/osu.Game/Overlays/Settings/SettingsSlider.cs +++ b/osu.Game/Overlays/Settings/SettingsSlider.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Graphics; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics.UserInterface; diff --git a/osu.Game/Overlays/Settings/SettingsSubsection.cs b/osu.Game/Overlays/Settings/SettingsSubsection.cs index b4ce54cb75..30abbc3805 100644 --- a/osu.Game/Overlays/Settings/SettingsSubsection.cs +++ b/osu.Game/Overlays/Settings/SettingsSubsection.cs @@ -4,7 +4,6 @@ using OpenTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Game.Graphics.Sprites; using System.Collections.Generic; using System.Linq; diff --git a/osu.Game/Overlays/SettingsOverlay.cs b/osu.Game/Overlays/SettingsOverlay.cs index e3fbf12df3..71ad18e081 100644 --- a/osu.Game/Overlays/SettingsOverlay.cs +++ b/osu.Game/Overlays/SettingsOverlay.cs @@ -6,7 +6,6 @@ using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Game.Overlays.Settings; using System; diff --git a/osu.Game/Overlays/Toolbar/ToolbarButton.cs b/osu.Game/Overlays/Toolbar/ToolbarButton.cs index 6be63b1fe8..5ae88d9049 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarButton.cs @@ -8,7 +8,6 @@ using osu.Framework.Audio.Sample; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Input; using osu.Game.Graphics; diff --git a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs index 209b64e709..8e610545f5 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs @@ -6,7 +6,6 @@ using osu.Framework.Allocation; using osu.Framework.Caching; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Game.Database; using OpenTK; diff --git a/osu.Game/Screens/Menu/Disclaimer.cs b/osu.Game/Screens/Menu/Disclaimer.cs index 4640067017..beaaa373b6 100644 --- a/osu.Game/Screens/Menu/Disclaimer.cs +++ b/osu.Game/Screens/Menu/Disclaimer.cs @@ -4,7 +4,6 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Framework.Screens; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; diff --git a/osu.Game/Screens/Play/HUD/ComboCounter.cs b/osu.Game/Screens/Play/HUD/ComboCounter.cs index a130bc2eab..46c7084cec 100644 --- a/osu.Game/Screens/Play/HUD/ComboCounter.cs +++ b/osu.Game/Screens/Play/HUD/ComboCounter.cs @@ -4,7 +4,6 @@ using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transforms; using osu.Framework.MathUtils; diff --git a/osu.Game/Screens/Play/HUD/ModDisplay.cs b/osu.Game/Screens/Play/HUD/ModDisplay.cs index 1b67d8dc66..92c40f6351 100644 --- a/osu.Game/Screens/Play/HUD/ModDisplay.cs +++ b/osu.Game/Screens/Play/HUD/ModDisplay.cs @@ -6,7 +6,6 @@ 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; diff --git a/osu.Game/Screens/Play/Pause/PauseProgressBar.cs b/osu.Game/Screens/Play/Pause/PauseProgressBar.cs index fa380540a3..bfde7dd6d7 100644 --- a/osu.Game/Screens/Play/Pause/PauseProgressBar.cs +++ b/osu.Game/Screens/Play/Pause/PauseProgressBar.cs @@ -4,7 +4,6 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Game.Beatmaps; using OpenTK.Graphics; diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 9afa1018c6..726397a3b1 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -4,7 +4,6 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Screens; using osu.Game.Beatmaps; diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 8cead0684e..887442b8c0 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -12,7 +12,6 @@ using System.Linq; using osu.Framework.Timing; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Types; -using osu.Framework.Graphics.Primitives; namespace osu.Game.Screens.Play { diff --git a/osu.Game/Screens/Play/SongProgressInfo.cs b/osu.Game/Screens/Play/SongProgressInfo.cs index 4c53b61313..06d7176cc5 100644 --- a/osu.Game/Screens/Play/SongProgressInfo.cs +++ b/osu.Game/Screens/Play/SongProgressInfo.cs @@ -4,7 +4,6 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Framework.Timing; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; diff --git a/osu.Game/Screens/Play/StandardHUDOverlay.cs b/osu.Game/Screens/Play/StandardHUDOverlay.cs index 41f9ee1394..87fbea6810 100644 --- a/osu.Game/Screens/Play/StandardHUDOverlay.cs +++ b/osu.Game/Screens/Play/StandardHUDOverlay.cs @@ -3,7 +3,6 @@ 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; diff --git a/osu.Game/Screens/Ranking/ResultModeTabControl.cs b/osu.Game/Screens/Ranking/ResultModeTabControl.cs index 346bff5720..06a6d31e37 100644 --- a/osu.Game/Screens/Ranking/ResultModeTabControl.cs +++ b/osu.Game/Screens/Ranking/ResultModeTabControl.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Graphics; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.UserInterface; using OpenTK; diff --git a/osu.Game/Screens/Ranking/Results.cs b/osu.Game/Screens/Ranking/Results.cs index 5bcaba7813..f3dae710b2 100644 --- a/osu.Game/Screens/Ranking/Results.cs +++ b/osu.Game/Screens/Ranking/Results.cs @@ -7,7 +7,6 @@ using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Game.Rulesets.Scoring; using osu.Framework.Graphics.Sprites; using osu.Framework.Screens; diff --git a/osu.Game/Screens/Ranking/ResultsPageScore.cs b/osu.Game/Screens/Ranking/ResultsPageScore.cs index 4bfd998c54..fad914e9d4 100644 --- a/osu.Game/Screens/Ranking/ResultsPageScore.cs +++ b/osu.Game/Screens/Ranking/ResultsPageScore.cs @@ -11,7 +11,6 @@ using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; using osu.Framework.Localisation; diff --git a/osu.Game/Screens/Select/BeatmapDetailArea.cs b/osu.Game/Screens/Select/BeatmapDetailArea.cs index cc22cca8bf..d116e5b159 100644 --- a/osu.Game/Screens/Select/BeatmapDetailArea.cs +++ b/osu.Game/Screens/Select/BeatmapDetailArea.cs @@ -3,7 +3,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Game.Beatmaps; using osu.Game.Screens.Select.Leaderboards; diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index 63fdfe3717..aaa267a299 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -6,7 +6,6 @@ using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Game.Database; using osu.Game.Graphics; diff --git a/osu.Game/Screens/Select/BeatmapInfoWedge.cs b/osu.Game/Screens/Select/BeatmapInfoWedge.cs index 6a2f7a26fc..2f5b35f92a 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedge.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedge.cs @@ -11,7 +11,6 @@ using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.MathUtils; using osu.Game.Beatmaps; diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index e0b197e9ca..7c7863acd1 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -8,7 +8,6 @@ using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics; diff --git a/osu.Game/Screens/Select/Leaderboards/Leaderboard.cs b/osu.Game/Screens/Select/Leaderboards/Leaderboard.cs index 02a412685c..a136e298b5 100644 --- a/osu.Game/Screens/Select/Leaderboards/Leaderboard.cs +++ b/osu.Game/Screens/Select/Leaderboards/Leaderboard.cs @@ -8,7 +8,6 @@ using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using System; using osu.Framework.Allocation; using osu.Framework.Threading; diff --git a/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs b/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs index 8df95f6913..c5fa0a5011 100644 --- a/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs +++ b/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs @@ -5,7 +5,6 @@ using OpenTK; using OpenTK.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; diff --git a/osu.Game/Screens/Select/Options/BeatmapOptionsButton.cs b/osu.Game/Screens/Select/Options/BeatmapOptionsButton.cs index 0935bb3686..182f778dd4 100644 --- a/osu.Game/Screens/Select/Options/BeatmapOptionsButton.cs +++ b/osu.Game/Screens/Select/Options/BeatmapOptionsButton.cs @@ -4,7 +4,6 @@ using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Input; using osu.Game.Graphics; diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 315992c113..8f91f1ed0f 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -5,7 +5,6 @@ using OpenTK.Input; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Framework.Screens; using osu.Game.Beatmaps; using osu.Game.Graphics; diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 51b67bdbef..4438b656b0 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -11,7 +11,6 @@ using osu.Framework.Audio.Track; using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Framework.Input; using osu.Framework.Screens; using osu.Framework.Threading; diff --git a/osu.Game/Screens/Tournament/Drawings.cs b/osu.Game/Screens/Tournament/Drawings.cs index eada42a53e..05bf3a250f 100644 --- a/osu.Game/Screens/Tournament/Drawings.cs +++ b/osu.Game/Screens/Tournament/Drawings.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; using osu.Framework.Logging; diff --git a/osu.Game/Screens/Tournament/Group.cs b/osu.Game/Screens/Tournament/Group.cs index f5695ae1cb..90ee90901f 100644 --- a/osu.Game/Screens/Tournament/Group.cs +++ b/osu.Game/Screens/Tournament/Group.cs @@ -7,7 +7,6 @@ using System.Text; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; using osu.Game.Graphics.Sprites; From 696c53646d6969e85304b113c6c81be23280b2f7 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 16 May 2017 12:51:07 +0900 Subject: [PATCH 209/329] Change severity of unaccessed private collections to hint --- osu.sln.DotSettings | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.sln.DotSettings b/osu.sln.DotSettings index 03d9e34805..70bfacd6ef 100644 --- a/osu.sln.DotSettings +++ b/osu.sln.DotSettings @@ -20,6 +20,8 @@ HINT WARNING HINT + SUGGESTION + HINT HINT WARNING WARNING From e09f1c7c918cbe3ccb1770170178294cd585fc37 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 16 May 2017 12:51:43 +0900 Subject: [PATCH 210/329] Remove AudioDevice from game-level setting Should be (and is already) in FrameworkConfig. --- osu.Game/Configuration/OsuConfigManager.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 43b0456973..8f177d6b56 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -39,8 +39,6 @@ namespace osu.Game.Configuration // Audio - Set(OsuSetting.AudioDevice, string.Empty); - Set(OsuSetting.MenuVoice, true); Set(OsuSetting.MenuMusic, true); @@ -99,7 +97,6 @@ namespace osu.Game.Configuration MenuParallax, BeatmapDetailTab, Username, - AudioDevice, ReleaseStream, SavePassword, SaveUsername, From 5e5ad9a8999dcb80969cb53beed10c0e63098097 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 16 May 2017 12:53:50 +0900 Subject: [PATCH 211/329] Add basic on-screen display --- .../Tests/TestCaseOnScreenDisplay.cs | 47 ++++ .../osu.Desktop.VisualTests.csproj | 1 + osu.Game/OsuGame.cs | 1 + osu.Game/Overlays/OnScreenDisplay.cs | 262 ++++++++++++++++++ osu.Game/osu.Game.csproj | 1 + 5 files changed, 312 insertions(+) create mode 100644 osu.Desktop.VisualTests/Tests/TestCaseOnScreenDisplay.cs create mode 100644 osu.Game/Overlays/OnScreenDisplay.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseOnScreenDisplay.cs b/osu.Desktop.VisualTests/Tests/TestCaseOnScreenDisplay.cs new file mode 100644 index 0000000000..3cefb8a3d2 --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCaseOnScreenDisplay.cs @@ -0,0 +1,47 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Allocation; +using osu.Framework.Configuration; +using osu.Framework.Testing; +using osu.Game.Overlays; + +namespace osu.Desktop.VisualTests.Tests +{ + internal class TestCaseOnScreenDisplay : TestCase + { + private FrameworkConfigManager config; + private Bindable frameSyncMode; + + public override string Description => @"Make it easier to see setting changes"; + + public override void Reset() + { + base.Reset(); + + Add(new OnScreenDisplay()); + + frameSyncMode = config.GetBindable(FrameworkSetting.FrameSync); + + FrameSync initial = frameSyncMode.Value; + + AddRepeatStep(@"Change frame limiter", setNextMode, 3); + + AddStep(@"Restore frame limiter", () => frameSyncMode.Value = initial); + } + + private void setNextMode() + { + var nextMode = frameSyncMode.Value + 1; + if (nextMode > FrameSync.Unlimited) + nextMode = FrameSync.VSync; + frameSyncMode.Value = nextMode; + } + + [BackgroundDependencyLoader] + private void load(FrameworkConfigManager config) + { + this.config = config; + } + } +} diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index 9b07ebf90b..dbb1750b72 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -195,6 +195,7 @@ + diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 9ce725661b..dfa94b2bfe 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -146,6 +146,7 @@ namespace osu.Game }, volume = new VolumeControl(), overlayContent = new Container{ RelativeSizeAxes = Axes.Both }, + new OnScreenDisplay(), new GlobalHotkeys //exists because UserInputManager is at a level below us. { Handler = globalHotkeyPressed diff --git a/osu.Game/Overlays/OnScreenDisplay.cs b/osu.Game/Overlays/OnScreenDisplay.cs new file mode 100644 index 0000000000..1c837eb602 --- /dev/null +++ b/osu.Game/Overlays/OnScreenDisplay.cs @@ -0,0 +1,262 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using System.Linq; +using osu.Framework.Allocation; +using osu.Framework.Configuration; +using osu.Framework.Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Primitives; +using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics; +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Extensions.Color4Extensions; + +namespace osu.Game.Overlays +{ + public class OnScreenDisplay : Container + { + private readonly Container box; + + public override bool HandleInput => false; + + private readonly SpriteText textLine1; + private readonly SpriteText textLine2; + private readonly SpriteText textLine3; + + private const float height = 110; + private const float height_contracted = height * 0.9f; + + private readonly FillFlowContainer optionLights; + + public OnScreenDisplay() + { + RelativeSizeAxes = Axes.Both; + + Children = new Drawable[] + { + box = new Container + { + Origin = Anchor.Centre, + RelativePositionAxes = Axes.Both, + Position = new Vector2(0.5f, 0.75f), + Masking = true, + AutoSizeAxes = Axes.X, + Height = height_contracted, + Alpha = 0, + CornerRadius = 20, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black, + Alpha = 0.7f, + }, + new Container // purely to add a minimum width + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Width = 240, + RelativeSizeAxes = Axes.Y, + }, + textLine1 = new SpriteText + { + Padding = new MarginPadding(10), + Font = @"Exo2.0-Black", + Spacing = new Vector2(1, 0), + TextSize = 14, + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + }, + textLine2 = new SpriteText + { + TextSize = 24, + Font = @"Exo2.0-Light", + Anchor = Anchor.Centre, + Origin = Anchor.BottomCentre, + }, + new FillFlowContainer + { + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Children = new Drawable[] + { + optionLights = new FillFlowContainer + { + Padding = new MarginPadding { Top = 20, Bottom = 5 }, + Spacing = new Vector2(5, 0), + Direction = FillDirection.Horizontal, + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + AutoSizeAxes = Axes.Both + }, + textLine3 = new SpriteText + { + Padding = new MarginPadding { Bottom = 15 }, + Font = @"Exo2.0-Bold", + TextSize = 12, + Alpha = 0.3f, + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + }, + } + } + } + }, + }; + } + + [BackgroundDependencyLoader] + private void load(FrameworkConfigManager frameworkConfig) + { + trackSetting(frameworkConfig.GetBindable(FrameworkSetting.FrameSync), v => display(v, "Frame Limiter", v.GetDescription(), "Ctrl+F7")); + trackSetting(frameworkConfig.GetBindable(FrameworkSetting.AudioDevice), v => display(v, "Audio Device", v, v)); + trackSetting(frameworkConfig.GetBindable(FrameworkSetting.ShowLogOverlay), v => display(v, "Debug Logs", v ? "visible" : "hidden", "Ctrl+F10")); + + Action displayResolution = delegate { display(null, "Screen Resolution", frameworkConfig.Get(FrameworkSetting.Width) + "x" + frameworkConfig.Get(FrameworkSetting.Height)); }; + + trackSetting(frameworkConfig.GetBindable(FrameworkSetting.Width), v => displayResolution()); + trackSetting(frameworkConfig.GetBindable(FrameworkSetting.Height), v => displayResolution()); + + trackSetting(frameworkConfig.GetBindable(FrameworkSetting.WindowMode), v => display(v, "Screen Mode", v.ToString(), "Alt+Enter")); + } + + private readonly List references = new List(); + + private void trackSetting(Bindable bindable, Bindable.BindableValueChanged action) + { + // we need to keep references as we bind + references.Add(bindable); + + bindable.ValueChanged += action; + } + + private void display(object rawValue, string settingName, string settingValue, string shortcut = @"") + { + Schedule(() => + { + textLine1.Text = settingName.ToUpper(); + textLine2.Text = settingValue; + textLine3.Text = shortcut.ToUpper(); + + box.FadeIn(500, EasingTypes.OutQuint); + box.ResizeHeightTo(height, 500, EasingTypes.OutQuint); + + using (box.BeginDelayedSequence(500)) + { + box.FadeOutFromOne(1500, EasingTypes.InQuint); + box.ResizeHeightTo(height_contracted, 1500, EasingTypes.InQuint); + } + + int optionCount = 0; + int selectedOption = -1; + + if (rawValue is bool) + { + optionCount = 1; + if ((bool)rawValue) selectedOption = 0; + } + else if (rawValue is Enum) + { + var values = Enum.GetValues(rawValue.GetType()); + optionCount = values.Length; + selectedOption = Convert.ToInt32(rawValue); + } + + textLine2.Origin = optionCount > 0 ? Anchor.BottomCentre : Anchor.Centre; + textLine2.Y = optionCount > 0 ? 0 : 5; + + if (optionLights.Children.Count() != optionCount) + { + optionLights.Clear(); + for (int i = 0; i < optionCount; i++) + optionLights.Add(new OptionLight()); + } + + for (int i = 0; i < optionCount; i++) + optionLights.Children.Skip(i).First().Glowing = i == selectedOption; + }); + } + + private class OptionLight : Container + { + private Color4 glowingColour, idleColour; + + private const float transition_speed = 300; + + private const float glow_strength = 0.4f; + + private readonly Box fill; + + public OptionLight() + { + Children = new[] + { + fill = new Box + { + RelativeSizeAxes = Axes.Both, + Alpha = 1, + }, + }; + } + + private bool glowing; + + public bool Glowing + { + set + { + glowing = value; + if (!IsLoaded) return; + + updateGlow(); + } + } + + private void updateGlow() + { + if (glowing) + { + fill.FadeColour(glowingColour, transition_speed, EasingTypes.OutQuint); + FadeEdgeEffectTo(glow_strength, transition_speed, EasingTypes.OutQuint); + } + else + { + FadeEdgeEffectTo(0, transition_speed, EasingTypes.OutQuint); + fill.FadeColour(idleColour, transition_speed, EasingTypes.OutQuint); + } + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + fill.Colour = idleColour = Color4.White.Opacity(0.4f); + glowingColour = Color4.White; + + Size = new Vector2(25, 5); + + Masking = true; + CornerRadius = 3; + + EdgeEffect = new EdgeEffect + { + Colour = colours.BlueDark.Opacity(glow_strength), + Type = EdgeEffectType.Glow, + Radius = 8, + }; + + FadeEdgeEffectTo(0); + + updateGlow(); + Flush(true); + } + } + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 1f866f0e17..2e94b3d658 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -79,6 +79,7 @@ + From f0ea445e4696082bf6a906f7762eeb7e5e1ee825 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 16 May 2017 15:56:53 +0900 Subject: [PATCH 212/329] Fix initial requests of channel mesages not being performed fetchReq was being set even for initial lookups, which caused only one to run, and subsequent requests to be excessive to try and catch up. --- osu.Game/Overlays/ChatOverlay.cs | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index 111d3e5eb4..5bbf20e196 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -245,7 +245,7 @@ namespace osu.Game.Overlays addChannel(channels.Find(c => c.Name == @"#lobby")); }); - messageRequest = Scheduler.AddDelayed(() => fetchNewMessages(), 1000, true); + messageRequest = Scheduler.AddDelayed(fetchNewMessages, 1000, true); }; api.Queue(req); @@ -289,17 +289,34 @@ namespace osu.Game.Overlays channelTabs.AddItem(channel); // we need to get a good number of messages initially for each channel we care about. - fetchNewMessages(channel); + fetchInitialMessages(channel); if (CurrentChannel == null) CurrentChannel = channel; } - private void fetchNewMessages(Channel specificChannel = null) + private void fetchInitialMessages(Channel channel) + { + var req = new GetMessagesRequest(new List { channel }, null); + + req.Success += delegate (List messages) + { + channel.AddNewMessages(messages.ToArray()); + Debug.Write("success!"); + }; + req.Failure += delegate + { + Debug.Write("failure!"); + }; + + api.Queue(req); + } + + private void fetchNewMessages() { if (fetchReq != null) return; - fetchReq = new GetMessagesRequest(specificChannel != null ? new List { specificChannel } : careChannels, lastMessageId); + fetchReq = new GetMessagesRequest(careChannels, lastMessageId); fetchReq.Success += delegate (List messages) { var ids = messages.Where(m => m.TargetType == TargetType.Channel).Select(m => m.TargetId).Distinct(); From 694b85c4b0399801c288ce9ab71c07819850c880 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 16 May 2017 16:29:18 +0900 Subject: [PATCH 213/329] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 7146c07159..30cd231fc6 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 7146c07159d2cf3d07a8d371fa50ef8b200ba038 +Subproject commit 30cd231fc6b3e971c70456433dbcf03591141f28 From ed92a1ee4e594194207c6d70f06be490fd328822 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 16 May 2017 16:37:05 +0900 Subject: [PATCH 214/329] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 7146c07159..3111d1aa4f 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 7146c07159d2cf3d07a8d371fa50ef8b200ba038 +Subproject commit 3111d1aa4f0d3aa1c0df03f8003b6c5c726b10d2 From da932276e87c89a8a533f1b009818aed01264be8 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 16 May 2017 17:03:43 +0900 Subject: [PATCH 215/329] Make timing sections scroll again. --- .../Objects/Drawables/DrawableHoldNote.cs | 4 -- .../Objects/Drawables/DrawableNote.cs | 4 +- .../Timing/TimeRelativeContainer.cs | 37 +++++++++++++++++-- 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs index 61dc2638a6..f943d817a8 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -41,10 +41,6 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables Origin = Anchor.TopCentre } }); - - // The "length" of the hold note stops at the "base" of the tail piece - // but we want to contain the tail piece within our bounds - Height += (float)HitObject.Duration / headPiece.Height; } public override Color4 AccentColour diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs index 8832fc8d48..a105c21e43 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs @@ -15,8 +15,8 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables public DrawableNote(Note hitObject) : base(hitObject) { - RelativeSizeAxes = Axes.X; - AutoSizeAxes = Axes.Y; + RelativeSizeAxes = Axes.Both; + Height = 100; Add(headPiece = new NotePiece { diff --git a/osu.Game.Rulesets.Mania/Timing/TimeRelativeContainer.cs b/osu.Game.Rulesets.Mania/Timing/TimeRelativeContainer.cs index 8ca30488ff..64b5b4e5ef 100644 --- a/osu.Game.Rulesets.Mania/Timing/TimeRelativeContainer.cs +++ b/osu.Game.Rulesets.Mania/Timing/TimeRelativeContainer.cs @@ -71,6 +71,9 @@ namespace osu.Game.Rulesets.Mania.Timing { private readonly ControlPoint timingChange; + protected override Container Content => content; + private readonly Container content; + /// /// Creates a drawable timing section. The height of this container will be proportional /// to the beat length of the timing section and the timespan of its parent at all times. @@ -89,7 +92,14 @@ namespace osu.Game.Rulesets.Mania.Timing RelativeSizeAxes = Axes.Both; - Y = -(float)timingChange.Time; + AddInternal(content = new AutoTimeRelativeContainer + { + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + RelativeSizeAxes = Axes.Both, + RelativePositionAxes = Axes.Both, + Y = -(float)timingChange.Time + }); } protected override void Update() @@ -101,7 +111,7 @@ namespace osu.Game.Rulesets.Mania.Timing RelativeCoordinateSpace = new Vector2(1, (float)parent.TimeSpan); // Scroll the content - Y = (float)(Time.Current - timingChange.Time); + content.Y = (float)(Time.Current - timingChange.Time); } public override void Add(Drawable drawable) @@ -120,7 +130,28 @@ namespace osu.Game.Rulesets.Mania.Timing /// can be placed within the timing section's bounds (in this case, from the start of the timing section up to infinity). /// /// The drawable to check. - public bool CanContain(Drawable drawable) => Y >= drawable.Y; + public bool CanContain(Drawable drawable) => content.Y >= drawable.Y; + + private class AutoTimeRelativeContainer : Container + { + public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true) + { + float height = 0; + + foreach (Drawable child in Children) + { + // Todo: This is wrong, it won't work for absolute-y-sized children + float childEndPos = -child.Y + child.Height; + if (childEndPos > height) + height = childEndPos; + } + + Height = height; + RelativeCoordinateSpace = new Vector2(1, height); + + return base.Invalidate(invalidation, source, shallPropagate); + } + } } } } \ No newline at end of file From 8d19bafc19c99e42ef431e827391369b9176ab83 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 16 May 2017 17:04:05 +0900 Subject: [PATCH 216/329] Add ability to hold down speed-changing keys. --- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index 2461ed458f..2d99b4dac7 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -28,10 +28,10 @@ namespace osu.Game.Rulesets.Mania.UI { public const float HIT_TARGET_POSITION = 50; - private const float time_span_default = 20000; + private const float time_span_default = 5000; private const float time_span_min = 10; private const float time_span_max = 50000; - private const float time_span_step = 1000; + private const float time_span_step = 200; /// /// Default column keys, expanding outwards from the middle as more column are added. @@ -187,9 +187,6 @@ namespace osu.Game.Rulesets.Mania.UI protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { - if (args.Repeat) - return false; - if (state.Keyboard.ControlPressed) { switch (args.Key) From 62139015fba89b5b835275edbd68fc89d25b7e25 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 16 May 2017 17:06:54 +0900 Subject: [PATCH 217/329] Clamp TimeSpan. --- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index 2d99b4dac7..118cf610dc 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -216,6 +216,8 @@ namespace osu.Game.Rulesets.Mania.UI return; timeSpan = value; + timeSpan = MathHelper.Clamp(timeSpan, time_span_min, time_span_max); + barlineContainer.TimeSpan = value; Columns.Children.ForEach(c => c.TimingSectionContainer.TimeSpan = value); } From 703920536346066233249fa84d247c4f3f399a4f Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 16 May 2017 17:34:41 +0900 Subject: [PATCH 218/329] Invert the playfield by default to make calculations a bit simpler and clean up a lot of code. --- .../Objects/Drawables/DrawableHoldNote.cs | 12 ++-- .../Drawables/DrawableManiaHitObject.cs | 5 +- .../Objects/Drawables/DrawableNote.cs | 4 +- .../Timing/TimeRelativeContainer.cs | 16 ++--- osu.Game.Rulesets.Mania/UI/Column.cs | 62 +++++++++---------- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 19 +++--- 6 files changed, 57 insertions(+), 61 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs index f943d817a8..767a2b3458 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -27,18 +27,18 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables // This will be fixed when new designs are given or the current design is finalized. bodyPiece = new BodyPiece { - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, }, headPiece = new NotePiece { - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre }, tailPiece = new NotePiece { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre } }); } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs index e3b28c8aca..0307e9162a 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs @@ -22,11 +22,8 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables { HitObject = hitObject; - Anchor = Anchor.BottomCentre; - Origin = Anchor.BottomCentre; - RelativePositionAxes = Axes.Y; - Y = (float)-HitObject.StartTime; + Y = (float)HitObject.StartTime; Add(glowContainer = new Container { diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs index a105c21e43..b216c362f5 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs @@ -20,8 +20,8 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables Add(headPiece = new NotePiece { - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre }); } diff --git a/osu.Game.Rulesets.Mania/Timing/TimeRelativeContainer.cs b/osu.Game.Rulesets.Mania/Timing/TimeRelativeContainer.cs index 64b5b4e5ef..5407b083df 100644 --- a/osu.Game.Rulesets.Mania/Timing/TimeRelativeContainer.cs +++ b/osu.Game.Rulesets.Mania/Timing/TimeRelativeContainer.cs @@ -87,18 +87,13 @@ namespace osu.Game.Rulesets.Mania.Timing { this.timingChange = timingChange; - Anchor = Anchor.BottomCentre; - Origin = Anchor.BottomCentre; - RelativeSizeAxes = Axes.Both; AddInternal(content = new AutoTimeRelativeContainer { - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, RelativeSizeAxes = Axes.Both, RelativePositionAxes = Axes.Both, - Y = -(float)timingChange.Time + Y = (float)timingChange.Time }); } @@ -111,7 +106,7 @@ namespace osu.Game.Rulesets.Mania.Timing RelativeCoordinateSpace = new Vector2(1, (float)parent.TimeSpan); // Scroll the content - content.Y = (float)(Time.Current - timingChange.Time); + content.Y = (float)(timingChange.Time - Time.Current); } public override void Add(Drawable drawable) @@ -120,7 +115,7 @@ namespace osu.Game.Rulesets.Mania.Timing // we need to offset it back by our position so that it becomes correctly relatively-positioned to us // This can be removed if hit objects were stored such that either their StartTime or their "beat offset" was relative to the timing section // they belonged to, but this requires a radical change to the beatmap format which we're not ready to do just yet - drawable.Y += (float)timingChange.Time; + drawable.Y -= (float)timingChange.Time; base.Add(drawable); } @@ -130,7 +125,7 @@ namespace osu.Game.Rulesets.Mania.Timing /// can be placed within the timing section's bounds (in this case, from the start of the timing section up to infinity). /// /// The drawable to check. - public bool CanContain(Drawable drawable) => content.Y >= drawable.Y; + public bool CanContain(Drawable drawable) => content.Y <= drawable.Y; private class AutoTimeRelativeContainer : Container { @@ -140,8 +135,7 @@ namespace osu.Game.Rulesets.Mania.Timing foreach (Drawable child in Children) { - // Todo: This is wrong, it won't work for absolute-y-sized children - float childEndPos = -child.Y + child.Height; + float childEndPos = child.Y + child.Height; if (childEndPos > height) height = childEndPos; } diff --git a/osu.Game.Rulesets.Mania/UI/Column.cs b/osu.Game.Rulesets.Mania/UI/Column.cs index 34d241485c..8491b631c5 100644 --- a/osu.Game.Rulesets.Mania/UI/Column.cs +++ b/osu.Game.Rulesets.Mania/UI/Column.cs @@ -18,6 +18,7 @@ using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Judgements; using osu.Game.Beatmaps.Timing; +using osu.Framework.Graphics.Primitives; namespace osu.Game.Rulesets.Mania.UI { @@ -56,51 +57,50 @@ namespace osu.Game.Rulesets.Mania.UI }, new Container { - Name = "Hit target", - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, - RelativeSizeAxes = Axes.X, - Height = hit_target_height, - Y = -ManiaPlayfield.HIT_TARGET_POSITION, + Name = "Hit target + hit objects", + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Top = ManiaPlayfield.HIT_TARGET_POSITION}, Children = new Drawable[] { - new Box + new Container { - Name = "Background", - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black - }, - hitTargetBar = new Container - { - Name = "Bar", - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, + Name = "Hit target", RelativeSizeAxes = Axes.X, - Height = hit_target_bar_height, - Masking = true, - Children = new[] + Height = hit_target_height, + Children = new Drawable[] { new Box { - RelativeSizeAxes = Axes.Both + Name = "Background", + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black + }, + hitTargetBar = new Container + { + Name = "Bar", + RelativeSizeAxes = Axes.X, + Height = hit_target_bar_height, + Masking = true, + Children = new[] + { + new Box + { + RelativeSizeAxes = Axes.Both + } + } } } - } + }, + TimingSectionContainer = new TimeRelativeContainer(timingChanges) + { + Name = "Hit objects", + RelativeSizeAxes = Axes.Both, + }, } }, - TimingSectionContainer = new TimeRelativeContainer(timingChanges) - { - Name = "Hit objects", - RelativeSizeAxes = Axes.Both, - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, - Y = -ManiaPlayfield.HIT_TARGET_POSITION - }, new Container { Name = "Key", - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, RelativeSizeAxes = Axes.X, Height = ManiaPlayfield.HIT_TARGET_POSITION, Children = new Drawable[] diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index 118cf610dc..1929bfdf7d 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -74,8 +74,8 @@ namespace osu.Game.Rulesets.Mania.UI { new Container { - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, RelativeSizeAxes = Axes.Y, AutoSizeAxes = Axes.X, Masking = true, @@ -95,13 +95,18 @@ namespace osu.Game.Rulesets.Mania.UI Padding = new MarginPadding { Left = 1, Right = 1 }, Spacing = new Vector2(1, 0) }, - barlineContainer = new TimeRelativeContainer(timingChanges) + new Container { - Name = "Bar lines", - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding { Bottom = HIT_TARGET_POSITION } + Padding = new MarginPadding { Top = HIT_TARGET_POSITION }, + Children = new[] + { + barlineContainer = new TimeRelativeContainer(timingChanges) + { + Name = "Bar lines", + RelativeSizeAxes = Axes.Both, + } + } } } } From ac02d1ab10a694da73f59f3f60eb5de33f16ba29 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 16 May 2017 17:50:09 +0900 Subject: [PATCH 219/329] TimeRelativeContainer -> ControlPointContainer, optimize AutoTimeRelativeContainer a little bit (only recompute on invalidation). --- .../Tests/TestCaseManiaPlayfield.cs | 4 +-- ...eContainer.cs => ControlPointContainer.cs} | 27 +++++++++++-------- osu.Game.Rulesets.Mania/UI/Column.cs | 4 +-- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 4 +-- .../osu.Game.Rulesets.Mania.csproj | 2 +- 5 files changed, 23 insertions(+), 18 deletions(-) rename osu.Game.Rulesets.Mania/Timing/{TimeRelativeContainer.cs => ControlPointContainer.cs} (84%) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs index 459f4589b5..4b7efa7499 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs @@ -9,7 +9,7 @@ using osu.Game.Rulesets.Mania.UI; using System.Linq; using System; using System.Collections.Generic; -using osu.Game.Rulesets.Mania.Timing; +using osu.Game.Beatmaps.Timing; namespace osu.Desktop.VisualTests.Tests { @@ -28,7 +28,7 @@ namespace osu.Desktop.VisualTests.Tests Action createPlayfield = (cols, pos) => { Clear(); - Add(new ManiaPlayfield(cols, new List()) + Add(new ManiaPlayfield(cols, new List()) { Anchor = Anchor.Centre, Origin = Anchor.Centre, diff --git a/osu.Game.Rulesets.Mania/Timing/TimeRelativeContainer.cs b/osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs similarity index 84% rename from osu.Game.Rulesets.Mania/Timing/TimeRelativeContainer.cs rename to osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs index 5407b083df..769164a761 100644 --- a/osu.Game.Rulesets.Mania/Timing/TimeRelativeContainer.cs +++ b/osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs @@ -19,20 +19,16 @@ namespace osu.Game.Rulesets.Mania.Timing /// and as such, will scroll along with the s. /// /// - public class TimeRelativeContainer : Container + public class ControlPointContainer : Container { /// /// The amount of time which the height of this container spans. /// - public double TimeSpan - { - get { return RelativeCoordinateSpace.Y; } - set { RelativeCoordinateSpace = new Vector2(1, (float)value); } - } + public double TimeSpan { get; set; } private readonly List drawableTimingSections; - public TimeRelativeContainer(IEnumerable timingChanges) + public ControlPointContainer(IEnumerable timingChanges) { drawableTimingSections = timingChanges.Select(t => new DrawableTimingSection(t)).ToList(); @@ -99,10 +95,10 @@ namespace osu.Game.Rulesets.Mania.Timing protected override void Update() { - var parent = (TimeRelativeContainer)Parent; + var parent = (ControlPointContainer)Parent; // Adjust our height to account for the speed changes - Height = (float)(parent.TimeSpan * 1000 / timingChange.BeatLength / timingChange.SpeedMultiplier); + Height = (float)(1000 / timingChange.BeatLength / timingChange.SpeedMultiplier); RelativeCoordinateSpace = new Vector2(1, (float)parent.TimeSpan); // Scroll the content @@ -127,10 +123,19 @@ namespace osu.Game.Rulesets.Mania.Timing /// The drawable to check. public bool CanContain(Drawable drawable) => content.Y <= drawable.Y; + /// + /// A container which always keeps its height and relative coordinate space "auto-sized" to its children. + /// private class AutoTimeRelativeContainer : Container { - public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true) + public override void InvalidateFromChild(Invalidation invalidation) { + if ((invalidation & Invalidation.Geometry) == 0) + { + base.InvalidateFromChild(invalidation); + return; + } + float height = 0; foreach (Drawable child in Children) @@ -143,7 +148,7 @@ namespace osu.Game.Rulesets.Mania.Timing Height = height; RelativeCoordinateSpace = new Vector2(1, height); - return base.Invalidate(invalidation, source, shallPropagate); + base.InvalidateFromChild(invalidation); } } } diff --git a/osu.Game.Rulesets.Mania/UI/Column.cs b/osu.Game.Rulesets.Mania/UI/Column.cs index 8491b631c5..b8a88263b9 100644 --- a/osu.Game.Rulesets.Mania/UI/Column.cs +++ b/osu.Game.Rulesets.Mania/UI/Column.cs @@ -40,7 +40,7 @@ namespace osu.Game.Rulesets.Mania.UI private readonly Container hitTargetBar; private readonly Container keyIcon; - public readonly TimeRelativeContainer TimingSectionContainer; + public readonly ControlPointContainer TimingSectionContainer; public Column(IEnumerable timingChanges) { @@ -91,7 +91,7 @@ namespace osu.Game.Rulesets.Mania.UI } } }, - TimingSectionContainer = new TimeRelativeContainer(timingChanges) + TimingSectionContainer = new ControlPointContainer(timingChanges) { Name = "Hit objects", RelativeSizeAxes = Axes.Both, diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index 1929bfdf7d..9caa852c9c 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -56,7 +56,7 @@ namespace osu.Game.Rulesets.Mania.UI public readonly FlowContainer Columns; - private readonly TimeRelativeContainer barlineContainer; + private readonly ControlPointContainer barlineContainer; private List normalColumnColours = new List(); private Color4 specialColumnColour; @@ -101,7 +101,7 @@ namespace osu.Game.Rulesets.Mania.UI Padding = new MarginPadding { Top = HIT_TARGET_POSITION }, Children = new[] { - barlineContainer = new TimeRelativeContainer(timingChanges) + barlineContainer = new ControlPointContainer(timingChanges) { Name = "Bar lines", RelativeSizeAxes = Axes.Both, diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index 70c875fd34..00deaba85d 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -68,7 +68,7 @@ - + From b016d53b85e94c1088652c97b99cdca6dfe79f74 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 16 May 2017 17:57:40 +0900 Subject: [PATCH 220/329] Fix TwoLayerButton not capturing MouseDown events Caused clicks to pass through the skip button to the progress bar. --- osu.Game/Graphics/UserInterface/TwoLayerButton.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/osu.Game/Graphics/UserInterface/TwoLayerButton.cs b/osu.Game/Graphics/UserInterface/TwoLayerButton.cs index 601970e36d..237aaa44a6 100644 --- a/osu.Game/Graphics/UserInterface/TwoLayerButton.cs +++ b/osu.Game/Graphics/UserInterface/TwoLayerButton.cs @@ -216,6 +216,11 @@ namespace osu.Game.Graphics.UserInterface }); } + protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) + { + return true; + } + protected override bool OnClick(InputState state) { var flash = new Box From 6487bf45cff7f69e61cedb5718ee88b1317d82c8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 16 May 2017 17:55:35 +0900 Subject: [PATCH 221/329] Eagerly attempt to pause the game when the window is not focused --- osu.Game/Screens/Play/Player.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index de390b63b3..8ee0de12b9 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -224,6 +224,15 @@ namespace osu.Game.Screens.Play }; } + protected override void Update() + { + // eagerly pause when we lose window focus (if we are locally playing). + if (!Game.IsActive && !HitRenderer.HasReplayLoaded) + Pause(); + + base.Update(); + } + private void initializeSkipButton() { const double skip_required_cutoff = 3000; From 3673e4af1fa926a62f5dc3f4b6f386c27e2c3631 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 16 May 2017 17:37:54 +0900 Subject: [PATCH 222/329] Fade bold state of chat tabs better --- osu.Game/Overlays/Chat/ChatTabControl.cs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Chat/ChatTabControl.cs b/osu.Game/Overlays/Chat/ChatTabControl.cs index 5778999a0c..57447f1913 100644 --- a/osu.Game/Overlays/Chat/ChatTabControl.cs +++ b/osu.Game/Overlays/Chat/ChatTabControl.cs @@ -46,6 +46,7 @@ namespace osu.Game.Overlays.Chat private Color4 backgroundActive; private readonly SpriteText text; + private readonly SpriteText textBold; private readonly Box box; private readonly Box highlightBox; @@ -77,7 +78,9 @@ namespace osu.Game.Overlays.Chat box.FadeColour(backgroundActive, transition_length, EasingTypes.OutQuint); highlightBox.FadeIn(transition_length, EasingTypes.OutQuint); - text.Font = @"Exo2.0-Bold"; + + text.FadeOut(transition_length, EasingTypes.OutQuint); + textBold.FadeIn(transition_length, EasingTypes.OutQuint); } private void fadeInactive() @@ -86,7 +89,9 @@ namespace osu.Game.Overlays.Chat box.FadeColour(backgroundInactive, transition_length, EasingTypes.OutQuint); highlightBox.FadeOut(transition_length, EasingTypes.OutQuint); - text.Font = @"Exo2.0-Regular"; + + text.FadeIn(transition_length, EasingTypes.OutQuint); + textBold.FadeOut(transition_length, EasingTypes.OutQuint); } protected override bool OnHover(InputState state) @@ -172,6 +177,16 @@ namespace osu.Game.Overlays.Chat Text = value.ToString(), TextSize = 18, }, + textBold = new OsuSpriteText + { + Alpha = 0, + Margin = new MarginPadding(5), + Origin = Anchor.CentreLeft, + Anchor = Anchor.CentreLeft, + Text = value.ToString(), + Font = @"Exo2.0-Bold", + TextSize = 18, + }, } } }; From 8ed97a833568bb8adebab1d4a6a0ba0e4282b38e Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 16 May 2017 18:02:54 +0900 Subject: [PATCH 223/329] Let's invert the playfield by default for now. --- osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs | 4 +++- osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs index 4b7efa7499..1f572f6c2c 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs @@ -10,6 +10,7 @@ using System.Linq; using System; using System.Collections.Generic; using osu.Game.Beatmaps.Timing; +using OpenTK; namespace osu.Desktop.VisualTests.Tests { @@ -32,7 +33,8 @@ namespace osu.Desktop.VisualTests.Tests { Anchor = Anchor.Centre, Origin = Anchor.Centre, - SpecialColumnPosition = pos + SpecialColumnPosition = pos, + Scale = new Vector2(1, -1) }); }; diff --git a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs index 9b476c4c1a..518917ed8e 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs @@ -66,7 +66,9 @@ namespace osu.Game.Rulesets.Mania.UI return new ManiaPlayfield(Columns ?? (int)Math.Round(Beatmap.BeatmapInfo.Difficulty.CircleSize), timingChanges) { Anchor = Anchor.Centre, - Origin = Anchor.Centre + Origin = Anchor.Centre, + // Invert by default for now (should be moved to config/skin later) + Scale = new Vector2(1, -1) }; } From f4a03ec1cff255fe6285f6d950266a3ea5eaa22a Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 16 May 2017 18:03:30 +0900 Subject: [PATCH 224/329] Fix usings. --- osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs index 518917ed8e..986aefb2bd 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Collections.Generic; using System.Linq; using OpenTK; using osu.Framework.Graphics; @@ -14,7 +13,6 @@ using osu.Game.Rulesets.Mania.Judgements; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Objects.Drawables; using osu.Game.Rulesets.Mania.Scoring; -using osu.Game.Rulesets.Mania.Timing; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Scoring; From 60666dc8248206c732a2ed2224b869c856fad988 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 16 May 2017 18:05:09 +0900 Subject: [PATCH 225/329] Rename. --- osu.Game.Rulesets.Mania/UI/Column.cs | 6 +++--- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game.Rulesets.Mania/UI/Column.cs b/osu.Game.Rulesets.Mania/UI/Column.cs index b8a88263b9..172533f889 100644 --- a/osu.Game.Rulesets.Mania/UI/Column.cs +++ b/osu.Game.Rulesets.Mania/UI/Column.cs @@ -40,7 +40,7 @@ namespace osu.Game.Rulesets.Mania.UI private readonly Container hitTargetBar; private readonly Container keyIcon; - public readonly ControlPointContainer TimingSectionContainer; + public readonly ControlPointContainer ControlPointContainer; public Column(IEnumerable timingChanges) { @@ -91,7 +91,7 @@ namespace osu.Game.Rulesets.Mania.UI } } }, - TimingSectionContainer = new ControlPointContainer(timingChanges) + ControlPointContainer = new ControlPointContainer(timingChanges) { Name = "Hit objects", RelativeSizeAxes = Axes.Both, @@ -181,7 +181,7 @@ namespace osu.Game.Rulesets.Mania.UI public void Add(DrawableHitObject hitObject) { - TimingSectionContainer.Add(hitObject); + ControlPointContainer.Add(hitObject); } protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index 9caa852c9c..8709e039ec 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -224,7 +224,7 @@ namespace osu.Game.Rulesets.Mania.UI timeSpan = MathHelper.Clamp(timeSpan, time_span_min, time_span_max); barlineContainer.TimeSpan = value; - Columns.Children.ForEach(c => c.TimingSectionContainer.TimeSpan = value); + Columns.Children.ForEach(c => c.ControlPointContainer.TimeSpan = value); } } From 620b4bf863a682c0879a4d0b99a20204442643ba Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 16 May 2017 18:17:34 +0900 Subject: [PATCH 226/329] Cleanup. --- .../Timing/ControlPointContainer.cs | 57 ++++++++----------- 1 file changed, 23 insertions(+), 34 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs b/osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs index 769164a761..e84fe0115e 100644 --- a/osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs +++ b/osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs @@ -12,7 +12,7 @@ using osu.Game.Beatmaps.Timing; namespace osu.Game.Rulesets.Mania.Timing { /// - /// A container in which the Y-relative coordinate space is spanned by a length of time. + /// A container in which added drawables are put into a relative coordinate space spanned by a length of time. /// /// This container contains s which scroll inside this container. /// Drawables added to this container are moved inside the relevant , @@ -22,39 +22,38 @@ namespace osu.Game.Rulesets.Mania.Timing public class ControlPointContainer : Container { /// - /// The amount of time which the height of this container spans. + /// The amount of time which this container spans. /// public double TimeSpan { get; set; } - private readonly List drawableTimingSections; + private readonly List drawableControlPoints; public ControlPointContainer(IEnumerable timingChanges) { - drawableTimingSections = timingChanges.Select(t => new DrawableTimingSection(t)).ToList(); - - Children = drawableTimingSections; + drawableControlPoints = timingChanges.Select(t => new DrawableControlPoint(t)).ToList(); + Children = drawableControlPoints; } /// - /// Adds a drawable to this container. Note that the drawable added must have a - /// Y-position as a time relative to this container. + /// Adds a drawable to this container. Note that the drawable added must have its Y-position be + /// an absolute unit of time that is _not_ relative to . /// /// The drawable to add. public override void Add(Drawable drawable) { // Always add timing sections to ourselves - if (drawable is DrawableTimingSection) + if (drawable is DrawableControlPoint) { base.Add(drawable); return; } - var section = drawableTimingSections.LastOrDefault(t => t.CanContain(drawable)) ?? drawableTimingSections.FirstOrDefault(); + var controlPoint = drawableControlPoints.LastOrDefault(t => t.CanContain(drawable)) ?? drawableControlPoints.FirstOrDefault(); - if (section == null) + if (controlPoint == null) throw new Exception("Could not find suitable timing section to add object to."); - section.Add(drawable); + controlPoint.Add(drawable); } /// @@ -63,7 +62,7 @@ namespace osu.Game.Rulesets.Mania.Timing /// The content of this container will scroll relative to the current time. /// /// - private class DrawableTimingSection : Container + private class DrawableControlPoint : Container { private readonly ControlPoint timingChange; @@ -71,15 +70,13 @@ namespace osu.Game.Rulesets.Mania.Timing private readonly Container content; /// - /// Creates a drawable timing section. The height of this container will be proportional - /// to the beat length of the timing section and the timespan of its parent at all times. - /// - /// This is so that, e.g. a beat length of 500ms results in this container being twice as high as its parent, - /// which means that the content container will scroll at twice the normal rate. - /// + /// Creates a drawable control point. The height of this container will be proportional + /// to the beat length of the control point it is initialized with such that, e.g. a beat length + /// of 500ms results in this container being twice as high as its parent, which further means that + /// the content container will scroll at twice the normal rate. /// - /// The timing change to create the drawable timing section for. - public DrawableTimingSection(ControlPoint timingChange) + /// The control point to create the drawable control point for. + public DrawableControlPoint(ControlPoint timingChange) { this.timingChange = timingChange; @@ -107,9 +104,9 @@ namespace osu.Game.Rulesets.Mania.Timing public override void Add(Drawable drawable) { - // The previously relatively-positioned drawable will now become relative to us, but since the drawable has no knowledge of us, - // we need to offset it back by our position so that it becomes correctly relatively-positioned to us - // This can be removed if hit objects were stored such that either their StartTime or their "beat offset" was relative to the timing section + // The previously relatively-positioned drawable will now become relative to content, but since the drawable has no knowledge of content, + // we need to offset it back by content's position position so that it becomes correctly relatively-positioned to content + // This can be removed if hit objects were stored such that either their StartTime or their "beat offset" was relative to the timing change // they belonged to, but this requires a radical change to the beatmap format which we're not ready to do just yet drawable.Y -= (float)timingChange.Time; @@ -117,8 +114,7 @@ namespace osu.Game.Rulesets.Mania.Timing } /// - /// Whether this timing section can contain a drawable. A timing section can contain a drawable if the drawable - /// can be placed within the timing section's bounds (in this case, from the start of the timing section up to infinity). + /// Whether this control point can contain a drawable. This control point can contain a drawable if the drawable is positioned "after" this control point. /// /// The drawable to check. public bool CanContain(Drawable drawable) => content.Y <= drawable.Y; @@ -136,14 +132,7 @@ namespace osu.Game.Rulesets.Mania.Timing return; } - float height = 0; - - foreach (Drawable child in Children) - { - float childEndPos = child.Y + child.Height; - if (childEndPos > height) - height = childEndPos; - } + float height = Children.Select(child => child.Y + child.Height).Max(); Height = height; RelativeCoordinateSpace = new Vector2(1, height); From be4ff5c038dbfeb1cead8f2ced650b635c426918 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 16 May 2017 18:26:49 +0900 Subject: [PATCH 227/329] Fix possible no-children-in-sequence exception. --- osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs b/osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs index e84fe0115e..40903f9213 100644 --- a/osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs +++ b/osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs @@ -132,6 +132,9 @@ namespace osu.Game.Rulesets.Mania.Timing return; } + if (!Children.Any()) + return; + float height = Children.Select(child => child.Y + child.Height).Max(); Height = height; From 235a5b1dff446d58e253453c1281e1cf101d2ffe Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 16 May 2017 18:27:33 +0900 Subject: [PATCH 228/329] Add notes to test case. --- .../Tests/TestCaseManiaPlayfield.cs | 50 ++++++++++++++----- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs index 1f572f6c2c..04fcd8e94a 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs @@ -1,16 +1,16 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Input; using osu.Framework.Testing; using osu.Framework.Graphics; using osu.Game.Rulesets.Mania.UI; -using System.Linq; using System; using System.Collections.Generic; using osu.Game.Beatmaps.Timing; using OpenTK; +using osu.Game.Rulesets.Mania.Objects.Drawables; +using osu.Game.Rulesets.Mania.Objects; namespace osu.Desktop.VisualTests.Tests { @@ -24,8 +24,6 @@ namespace osu.Desktop.VisualTests.Tests { base.Reset(); - const int max_columns = 10; - Action createPlayfield = (cols, pos) => { Clear(); @@ -38,20 +36,46 @@ namespace osu.Desktop.VisualTests.Tests }); }; - for (int i = 1; i <= max_columns; i++) + Action createPlayfieldWithNotes = (cols, pos) => { - int tempI = i; + Clear(); - AddStep($"{i} column" + (i > 1 ? "s" : ""), () => createPlayfield(tempI, SpecialColumnPosition.Normal)); + ManiaPlayfield playField; + Add(playField = new ManiaPlayfield(cols, new List { new ControlPoint { BeatLength = 200 } }) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + SpecialColumnPosition = pos, + Scale = new Vector2(1, -1) + }); - AddStep("Trigger keys down", () => ((ManiaPlayfield)Children.First()).Columns.Children.ForEach(triggerKeyDown)); - AddStep("Trigger keys up", () => ((ManiaPlayfield)Children.First()).Columns.Children.ForEach(triggerKeyUp)); + for (int i = 0; i < cols; i++) + { + playField.Add(new DrawableNote(new Note + { + StartTime = Time.Current + 1000, + Column = i + })); + } + }; - AddStep("Left special style", () => createPlayfield(tempI, SpecialColumnPosition.Left)); - AddStep("Right special style", () => createPlayfield(tempI, SpecialColumnPosition.Right)); - } + AddStep("1 column", () => createPlayfield(1, SpecialColumnPosition.Normal)); + AddStep("4 columns", () => createPlayfield(4, SpecialColumnPosition.Normal)); + AddStep("Left special style", () => createPlayfield(4, SpecialColumnPosition.Left)); + AddStep("Right special style", () => createPlayfield(4, SpecialColumnPosition.Right)); + AddStep("5 columns", () => createPlayfield(5, SpecialColumnPosition.Normal)); + AddStep("8 columns", () => createPlayfield(8, SpecialColumnPosition.Normal)); + AddStep("Left special style", () => createPlayfield(8, SpecialColumnPosition.Left)); + AddStep("Right special style", () => createPlayfield(8, SpecialColumnPosition.Right)); - AddStep("Normal special style", () => createPlayfield(max_columns, SpecialColumnPosition.Normal)); + AddStep("Normal special style", () => createPlayfield(4, SpecialColumnPosition.Normal)); + + AddStep("Notes", () => createPlayfieldWithNotes(4, SpecialColumnPosition.Normal)); + AddWaitStep(10); + AddStep("Left special style", () => createPlayfieldWithNotes(4, SpecialColumnPosition.Left)); + AddWaitStep(10); + AddStep("Right special style", () => createPlayfieldWithNotes(4, SpecialColumnPosition.Right)); + AddWaitStep(10); } private void triggerKeyDown(Column column) From 712bd21e2524b90bc253ee8fb3f1d6cb345f70fc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 16 May 2017 18:25:03 +0900 Subject: [PATCH 229/329] Fix duplicate channels being created on connection loss Resolves #763 --- osu.Game/Overlays/ChatOverlay.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index e6dffbfe63..4748eb7de6 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -284,10 +284,21 @@ namespace osu.Game.Overlays { if (channel == null) return; - careChannels.Add(channel); - channelTabs.AddItem(channel); + var existing = careChannels.Find(c => c.Id == channel.Id); - // we need to get a good number of messages initially for each channel we care about. + if (existing != null) + { + // if we already have this channel loaded, we don't want to make a second one. + channel = existing; + } + else + { + + careChannels.Add(channel); + channelTabs.AddItem(channel); + } + + // let's fetch a small number of messages to bring us up-to-date with the backlog. fetchInitialMessages(channel); if (CurrentChannel == null) From 3c8d75effb15c4141ef2646ec9494ca884f955da Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 16 May 2017 18:36:38 +0900 Subject: [PATCH 230/329] Fix unused directive. --- osu.Game.Rulesets.Mania/UI/Column.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game.Rulesets.Mania/UI/Column.cs b/osu.Game.Rulesets.Mania/UI/Column.cs index 172533f889..6663f3bc4c 100644 --- a/osu.Game.Rulesets.Mania/UI/Column.cs +++ b/osu.Game.Rulesets.Mania/UI/Column.cs @@ -18,7 +18,6 @@ using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Judgements; using osu.Game.Beatmaps.Timing; -using osu.Framework.Graphics.Primitives; namespace osu.Game.Rulesets.Mania.UI { From 9b0aed7c4827d20186560ed12fd0267c2e4fe194 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 16 May 2017 19:14:27 +0900 Subject: [PATCH 231/329] Add tween to time span changing. --- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 33 ++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index 22c190e07b..56a86873e9 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -20,6 +20,8 @@ using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Mania.Timing; using osu.Framework.Input; using osu.Game.Beatmaps.Timing; +using osu.Framework.Graphics.Transforms; +using osu.Framework.MathUtils; namespace osu.Game.Rulesets.Mania.UI { @@ -196,10 +198,10 @@ namespace osu.Game.Rulesets.Mania.UI switch (args.Key) { case Key.Minus: - TimeSpan += time_span_step; + transformTimeSpanTo(TimeSpan + time_span_step, 200, EasingTypes.OutQuint); break; case Key.Plus: - TimeSpan -= time_span_step; + transformTimeSpanTo(TimeSpan - time_span_step, 200, EasingTypes.OutQuint); break; } } @@ -227,5 +229,32 @@ namespace osu.Game.Rulesets.Mania.UI } } + private void transformTimeSpanTo(double newTimeSpan, double duration = 0, EasingTypes easing = EasingTypes.None) + { + TransformTo(() => TimeSpan, newTimeSpan, duration, easing, new TransformTimeSpan()); + } + + private class TransformTimeSpan : Transform + { + public override double CurrentValue + { + get + { + double time = Time?.Current ?? 0; + if (time < StartTime) return StartValue; + if (time >= EndTime) return EndValue; + + return Interpolation.ValueAt(time, StartValue, EndValue, StartTime, EndTime, Easing); + } + } + + public override void Apply(Drawable d) + { + base.Apply(d); + + var p = (ManiaPlayfield)d; + p.TimeSpan = CurrentValue; + } + } } } From bc629d193d47f0f48cbb1de8c29eaefa231f658d Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 16 May 2017 19:26:46 +0900 Subject: [PATCH 232/329] InternalChildren -> Children. --- osu.Game.Rulesets.Mania/UI/Column.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Mania/UI/Column.cs b/osu.Game.Rulesets.Mania/UI/Column.cs index 6663f3bc4c..dea00433e6 100644 --- a/osu.Game.Rulesets.Mania/UI/Column.cs +++ b/osu.Game.Rulesets.Mania/UI/Column.cs @@ -46,7 +46,7 @@ namespace osu.Game.Rulesets.Mania.UI RelativeSizeAxes = Axes.Y; Width = column_width; - InternalChildren = new Drawable[] + Children = new Drawable[] { background = new Box { From 0eba5531382155a850453ea37d03a40176f0cdc0 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 16 May 2017 19:33:56 +0900 Subject: [PATCH 233/329] Comments? --- osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs b/osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs index 40903f9213..6c39ba40f9 100644 --- a/osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs +++ b/osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs @@ -121,11 +121,16 @@ namespace osu.Game.Rulesets.Mania.Timing /// /// A container which always keeps its height and relative coordinate space "auto-sized" to its children. + /// + /// This is used in the case where children are relatively positioned/sized to time values (e.g. notes/bar lines) to keep + /// such children wrapped inside a container, otherwise they would disappear due to container flattening. + /// /// private class AutoTimeRelativeContainer : Container { public override void InvalidateFromChild(Invalidation invalidation) { + // We only want to re-compute our size when a child's size or position has changed if ((invalidation & Invalidation.Geometry) == 0) { base.InvalidateFromChild(invalidation); From 2384f7b0c132597dd88ee7e395fcbb7b8bb6ada7 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 16 May 2017 19:49:50 +0900 Subject: [PATCH 234/329] Ensure LocalUser is never null --- osu.Game/Online/API/APIAccess.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/osu.Game/Online/API/APIAccess.cs b/osu.Game/Online/API/APIAccess.cs index c4b679fc92..e56e4efe24 100644 --- a/osu.Game/Online/API/APIAccess.cs +++ b/osu.Game/Online/API/APIAccess.cs @@ -34,7 +34,7 @@ namespace osu.Game.Online.API public string Password; - public Bindable LocalUser = new Bindable(); + public Bindable LocalUser = new Bindable(createGustUser()); public string Token { @@ -295,8 +295,15 @@ namespace osu.Game.Online.API clearCredentials(); authentication.Clear(); State = APIState.Offline; + LocalUser.Value = createGustUser(); } + private static User createGustUser() => new User + { + Username = @"Guest", + Id = 1, + }; + public void Update() { Scheduler.Update(); From 23807aa3b99419447e8a4d117eb973eac6ed0984 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 16 May 2017 19:55:45 +0900 Subject: [PATCH 235/329] Better handling of logged in state --- osu.Game/Online/API/APIAccess.cs | 4 +++- osu.Game/Overlays/ChatOverlay.cs | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/osu.Game/Online/API/APIAccess.cs b/osu.Game/Online/API/APIAccess.cs index e56e4efe24..9d48c38908 100644 --- a/osu.Game/Online/API/APIAccess.cs +++ b/osu.Game/Online/API/APIAccess.cs @@ -191,7 +191,7 @@ namespace osu.Game.Online.API req.Perform(this); //we could still be in initialisation, at which point we don't want to say we're Online yet. - if (LocalUser.Value != null) + if (IsLoggedIn) State = APIState.Online; failureCount = 0; @@ -266,6 +266,8 @@ namespace osu.Game.Online.API } } + public bool IsLoggedIn => LocalUser.Value.Id > 1; + public void Queue(APIRequest request) { queue.Enqueue(request); diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index 4748eb7de6..b360417dfd 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -353,7 +353,15 @@ namespace osu.Game.Overlays { var postText = textbox.Text; - if (string.IsNullOrEmpty(postText) || api.LocalUser.Value == null) return; + if (string.IsNullOrEmpty(postText)) + return; + + if (!api.IsLoggedIn) + { + currentChannel?.AddNewMessages(new ErrorMessage("Please login to participate in chat!")); + textbox.Text = string.Empty; + return; + } if (currentChannel == null) return; From fdf0137fc2818b7dd27d297b3a022071e571fccc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 16 May 2017 16:22:11 +0900 Subject: [PATCH 236/329] Remove incorrect padding --- osu.Game/Overlays/ChatOverlay.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index 4748eb7de6..53a2b0170a 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -81,7 +81,6 @@ namespace osu.Game.Overlays RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { - Top = padding, Bottom = textbox_height + padding }, }, From 041d4f93c0a66e84b9496b629a477965bfc983e2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 16 May 2017 20:08:22 +0900 Subject: [PATCH 237/329] Fix typo --- osu.Game/Online/API/APIAccess.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Online/API/APIAccess.cs b/osu.Game/Online/API/APIAccess.cs index 9d48c38908..032e5ccc6e 100644 --- a/osu.Game/Online/API/APIAccess.cs +++ b/osu.Game/Online/API/APIAccess.cs @@ -34,7 +34,7 @@ namespace osu.Game.Online.API public string Password; - public Bindable LocalUser = new Bindable(createGustUser()); + public Bindable LocalUser = new Bindable(createGuestUser()); public string Token { @@ -297,10 +297,10 @@ namespace osu.Game.Online.API clearCredentials(); authentication.Clear(); State = APIState.Offline; - LocalUser.Value = createGustUser(); + LocalUser.Value = createGuestUser(); } - private static User createGustUser() => new User + private static User createGuestUser() => new User { Username = @"Guest", Id = 1, From 3d74492c956d0e814c6f07988c0dabc5dfeae6d3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 16 May 2017 21:19:34 +0900 Subject: [PATCH 238/329] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 3111d1aa4f..67f3958036 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 3111d1aa4f0d3aa1c0df03f8003b6c5c726b10d2 +Subproject commit 67f39580365f7d0a42f8788eae2b60881dde1c67 From 5a9745b492ee41e85acb95b4bb209c65d27a2aa2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 16 May 2017 21:37:55 +0900 Subject: [PATCH 239/329] Update API endpoint --- osu.Game/Online/API/APIAccess.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Online/API/APIAccess.cs b/osu.Game/Online/API/APIAccess.cs index 032e5ccc6e..2f344e0bdf 100644 --- a/osu.Game/Online/API/APIAccess.cs +++ b/osu.Game/Online/API/APIAccess.cs @@ -20,7 +20,7 @@ namespace osu.Game.Online.API { private readonly OAuth authentication; - public string Endpoint = @"https://new.ppy.sh"; + public string Endpoint = @"https://osu.ppy.sh"; private const string client_id = @"5"; private const string client_secret = @"FGc9GAtyHzeQDshWP5Ah7dega8hJACAJpQtw6OXk"; From b9a40a841b7311673c517f5f1b11bb4bd53d7a8d Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Sat, 13 May 2017 21:28:53 +0800 Subject: [PATCH 240/329] Use IsAssignableFrom. --- osu.Game/Graphics/UserInterface/RollingCounter.cs | 2 +- osu.Game/Overlays/NotificationManager.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/RollingCounter.cs b/osu.Game/Graphics/UserInterface/RollingCounter.cs index e98867277a..bdb2054ca4 100644 --- a/osu.Game/Graphics/UserInterface/RollingCounter.cs +++ b/osu.Game/Graphics/UserInterface/RollingCounter.cs @@ -181,7 +181,7 @@ namespace osu.Game.Graphics.UserInterface protected virtual void TransformCount(T currentValue, T newValue) { Debug.Assert( - TransformType.IsSubclassOf(typeof(Transform)) || TransformType == typeof(Transform), + typeof(Transform).IsAssignableFrom(TransformType), @"transformType should be a subclass of Transform." ); diff --git a/osu.Game/Overlays/NotificationManager.cs b/osu.Game/Overlays/NotificationManager.cs index b344d533ee..3ddd85cfcf 100644 --- a/osu.Game/Overlays/NotificationManager.cs +++ b/osu.Game/Overlays/NotificationManager.cs @@ -81,7 +81,7 @@ namespace osu.Game.Overlays hasCompletionTarget.CompletionTarget = Post; var ourType = notification.GetType(); - sections.Children.FirstOrDefault(s => s.AcceptTypes.Any(accept => ourType == accept || ourType.IsSubclassOf(accept)))?.Add(notification); + sections.Children.FirstOrDefault(s => s.AcceptTypes.Any(accept => accept.IsAssignableFrom(ourType)))?.Add(notification); } protected override void PopIn() From d213706d076f384734196e0475ca89f3c390ef42 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 16 May 2017 21:14:50 +0800 Subject: [PATCH 241/329] Use DateTimeOffset. --- osu.Desktop.VisualTests/Tests/TestCaseResults.cs | 2 +- osu.Game/Online/Chat/ErrorMessage.cs | 2 +- osu.Game/Rulesets/Scoring/Score.cs | 2 +- osu.Game/Rulesets/Scoring/ScoreProcessor.cs | 2 +- osu.Game/Screens/Ranking/ResultsPageScore.cs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseResults.cs b/osu.Desktop.VisualTests/Tests/TestCaseResults.cs index aa3a117667..f8c93e9a73 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseResults.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseResults.cs @@ -47,7 +47,7 @@ namespace osu.Desktop.VisualTests.Tests Accuracy = 0.98, MaxCombo = 123, Rank = ScoreRank.A, - Date = DateTime.Now, + Date = DateTimeOffset.Now, Statistics = new Dictionary() { { "300", 50 }, diff --git a/osu.Game/Online/Chat/ErrorMessage.cs b/osu.Game/Online/Chat/ErrorMessage.cs index a410e9044a..48557ca648 100644 --- a/osu.Game/Online/Chat/ErrorMessage.cs +++ b/osu.Game/Online/Chat/ErrorMessage.cs @@ -12,7 +12,7 @@ namespace osu.Game.Online.Chat public ErrorMessage(string message) : base(errorId--) { - Timestamp = DateTime.Now; + Timestamp = DateTimeOffset.Now; Content = message; Sender = new User diff --git a/osu.Game/Rulesets/Scoring/Score.cs b/osu.Game/Rulesets/Scoring/Score.cs index 15d8690322..2cca0f54af 100644 --- a/osu.Game/Rulesets/Scoring/Score.cs +++ b/osu.Game/Rulesets/Scoring/Score.cs @@ -46,7 +46,7 @@ namespace osu.Game.Rulesets.Scoring public long OnlineScoreID; [JsonProperty(@"created_at")] - public DateTime Date; + public DateTimeOffset Date; [JsonProperty(@"statistics")] private Dictionary jsonStats diff --git a/osu.Game/Rulesets/Scoring/ScoreProcessor.cs b/osu.Game/Rulesets/Scoring/ScoreProcessor.cs index 11c1c273e2..79fb34a523 100644 --- a/osu.Game/Rulesets/Scoring/ScoreProcessor.cs +++ b/osu.Game/Rulesets/Scoring/ScoreProcessor.cs @@ -129,7 +129,7 @@ namespace osu.Game.Rulesets.Scoring score.MaxCombo = HighestCombo; score.Accuracy = Accuracy; score.Rank = rankFrom(Accuracy); - score.Date = DateTime.Now; + score.Date = DateTimeOffset.Now; score.Health = Health; } } diff --git a/osu.Game/Screens/Ranking/ResultsPageScore.cs b/osu.Game/Screens/Ranking/ResultsPageScore.cs index fad914e9d4..4dc61b8160 100644 --- a/osu.Game/Screens/Ranking/ResultsPageScore.cs +++ b/osu.Game/Screens/Ranking/ResultsPageScore.cs @@ -116,7 +116,7 @@ namespace osu.Game.Screens.Ranking Origin = Anchor.TopCentre, Margin = new MarginPadding { Bottom = 10 }, }, - new DateDisplay(Score.Date) + new DateDisplay(Score.Date.LocalDateTime) { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, From d929de466a2e43e52b5682f2010fa1fe585341f3 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 16 May 2017 21:16:52 +0800 Subject: [PATCH 242/329] DateDisplay -> DateTimeDisplay for more exactly. --- osu.Game/Screens/Ranking/ResultsPageScore.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/osu.Game/Screens/Ranking/ResultsPageScore.cs b/osu.Game/Screens/Ranking/ResultsPageScore.cs index 4dc61b8160..70542dab8b 100644 --- a/osu.Game/Screens/Ranking/ResultsPageScore.cs +++ b/osu.Game/Screens/Ranking/ResultsPageScore.cs @@ -116,7 +116,7 @@ namespace osu.Game.Screens.Ranking Origin = Anchor.TopCentre, Margin = new MarginPadding { Bottom = 10 }, }, - new DateDisplay(Score.Date.LocalDateTime) + new DateTimeDisplay(Score.Date.LocalDateTime) { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, @@ -220,13 +220,13 @@ namespace osu.Game.Screens.Ranking } } - private class DateDisplay : Container + private class DateTimeDisplay : Container { - private DateTime date; + private DateTime datetime; - public DateDisplay(DateTime date) + public DateTimeDisplay(DateTime datetime) { - this.date = date; + this.datetime = datetime; AutoSizeAxes = Axes.Y; @@ -250,7 +250,7 @@ namespace osu.Game.Screens.Ranking { Origin = Anchor.CentreLeft, Anchor = Anchor.CentreLeft, - Text = date.ToString("HH:mm"), + Text = datetime.ToString("HH:mm"), Padding = new MarginPadding { Left = 10, Right = 10, Top = 5, Bottom = 5 }, Colour = Color4.White, }, @@ -258,7 +258,7 @@ namespace osu.Game.Screens.Ranking { Origin = Anchor.CentreRight, Anchor = Anchor.CentreRight, - Text = date.ToString("yyyy/MM/dd"), + Text = datetime.ToString("yyyy/MM/dd"), Padding = new MarginPadding { Left = 10, Right = 10, Top = 5, Bottom = 5 }, Colour = Color4.White, } From e911441394ad80a7871b41a1be8686f672fa76d5 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 16 May 2017 21:23:14 +0800 Subject: [PATCH 243/329] Why AbandonedMutexException? --- osu.Game/IO/Legacy/SerializationReader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/IO/Legacy/SerializationReader.cs b/osu.Game/IO/Legacy/SerializationReader.cs index 6bb6c3bbbf..c4d56641af 100644 --- a/osu.Game/IO/Legacy/SerializationReader.cs +++ b/osu.Game/IO/Legacy/SerializationReader.cs @@ -66,7 +66,7 @@ namespace osu.Game.IO.Legacy public DateTime ReadDateTime() { long ticks = ReadInt64(); - if (ticks < 0) throw new AbandonedMutexException("oops"); + if (ticks < 0) throw new IOException("Bad ticks count read!"); return new DateTime(ticks, DateTimeKind.Utc); } From aaaee5ed102e54a2fe40209e0ebe967015b29b83 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 16 May 2017 21:46:22 +0800 Subject: [PATCH 244/329] Use generic IComparable for message. --- osu.Game/Online/Chat/Channel.cs | 2 +- osu.Game/Online/Chat/Message.cs | 14 ++------------ 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/osu.Game/Online/Chat/Channel.cs b/osu.Game/Online/Chat/Channel.cs index 2925c3ccb4..93fd0a8956 100644 --- a/osu.Game/Online/Chat/Channel.cs +++ b/osu.Game/Online/Chat/Channel.cs @@ -23,7 +23,7 @@ namespace osu.Game.Online.Chat [JsonProperty(@"channel_id")] public int Id; - public readonly SortedList Messages = new SortedList((m1, m2) => m1.Id.CompareTo(m2.Id)); + public readonly SortedList Messages = new SortedList(Comparer.Default); //internal bool Joined; diff --git a/osu.Game/Online/Chat/Message.cs b/osu.Game/Online/Chat/Message.cs index bf53a68910..c1887e7824 100644 --- a/osu.Game/Online/Chat/Message.cs +++ b/osu.Game/Online/Chat/Message.cs @@ -8,7 +8,7 @@ using osu.Game.Users; namespace osu.Game.Online.Chat { - public class Message + public class Message : IComparable { [JsonProperty(@"message_id")] public readonly long Id; @@ -42,17 +42,7 @@ namespace osu.Game.Online.Chat Id = id; } - public override bool Equals(object obj) - { - var objMessage = obj as Message; - - return Id == objMessage?.Id; - } - - public override int GetHashCode() - { - return Id.GetHashCode(); - } + public int CompareTo(Message other) => Id.CompareTo(other.Id); } public enum TargetType From f1d5a929505419c71fcd790c37f22a70db49ccb2 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 16 May 2017 21:49:38 +0800 Subject: [PATCH 245/329] Use generic IEqutable to avoid typeless Equals. --- osu.Game/Graphics/UserInterface/OsuSliderBar.cs | 4 +++- osu.Game/Overlays/Settings/SettingsSlider.cs | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuSliderBar.cs b/osu.Game/Graphics/UserInterface/OsuSliderBar.cs index 027473921f..6cf7b2dfa5 100644 --- a/osu.Game/Graphics/UserInterface/OsuSliderBar.cs +++ b/osu.Game/Graphics/UserInterface/OsuSliderBar.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 osu.Framework.Allocation; using osu.Framework.Audio; @@ -13,7 +14,8 @@ using osu.Framework.Input; namespace osu.Game.Graphics.UserInterface { - public class OsuSliderBar : SliderBar, IHasTooltip where T : struct + public class OsuSliderBar : SliderBar, IHasTooltip + where T : struct, IEquatable { private SampleChannel sample; private double lastSampleTime; diff --git a/osu.Game/Overlays/Settings/SettingsSlider.cs b/osu.Game/Overlays/Settings/SettingsSlider.cs index beb2bdf645..522d242f2a 100644 --- a/osu.Game/Overlays/Settings/SettingsSlider.cs +++ b/osu.Game/Overlays/Settings/SettingsSlider.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 osu.Framework.Graphics; using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics.UserInterface; @@ -8,12 +9,12 @@ using osu.Game.Graphics.UserInterface; namespace osu.Game.Overlays.Settings { public class SettingsSlider : SettingsSlider> - where T : struct + where T : struct, IEquatable { } public class SettingsSlider : SettingsItem - where T : struct + where T : struct, IEquatable where U : SliderBar, new() { protected override Drawable CreateControl() => new U() From e2a7f00a5255cc6a68f456a26ee282e0f665181e Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 16 May 2017 22:20:05 +0800 Subject: [PATCH 246/329] Remove unused namespace. --- osu.Game/IO/Legacy/SerializationReader.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/IO/Legacy/SerializationReader.cs b/osu.Game/IO/Legacy/SerializationReader.cs index c4d56641af..bad143fa6c 100644 --- a/osu.Game/IO/Legacy/SerializationReader.cs +++ b/osu.Game/IO/Legacy/SerializationReader.cs @@ -10,7 +10,6 @@ using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters; using System.Runtime.Serialization.Formatters.Binary; using System.Text; -using System.Threading; namespace osu.Game.IO.Legacy { From b22c84287a2678c954d4025bd042af9aa0eb9cc7 Mon Sep 17 00:00:00 2001 From: nyaamara Date: Tue, 16 May 2017 16:54:33 -0400 Subject: [PATCH 247/329] Fix typo. --- osu.Game/Screens/Select/BeatmapDetails.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index a0d15101e0..18288da901 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -156,7 +156,7 @@ namespace osu.Game.Screens.Select drainRate = new DifficultyRow("HP Drain"), overallDifficulty = new DifficultyRow("Accuracy"), approachRate = new DifficultyRow("Approach Rate"), - stars = new DifficultyRow("Star Diffculty"), + stars = new DifficultyRow("Star Difficulty"), }, }, }, From 231f7939a684377bdaf8aeba6099e65ae29a5cf3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 17 May 2017 12:41:37 +0900 Subject: [PATCH 248/329] Fix channels being unnecessarily recycled on disconnect Resolves #768 --- osu.Game/Overlays/ChatOverlay.cs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index a85af251c5..cbcfbbfd9e 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -206,18 +206,12 @@ namespace osu.Game.Overlays private long? lastMessageId; - private List careChannels; + private List careChannels = new List(); private readonly List loadedChannels = new List(); private void initializeChannels() { - currentChannelContainer.Clear(); - - loadedChannels.Clear(); - - careChannels = new List(); - SpriteText loading; Add(loading = new OsuSpriteText { @@ -232,8 +226,6 @@ namespace osu.Game.Overlays ListChannelsRequest req = new ListChannelsRequest(); req.Success += delegate (List channels) { - Debug.Assert(careChannels.Count == 0); - Scheduler.Add(delegate { loading.FadeOut(100); From 93e2b21084cce70a18abecec6ca3aea15c7b2a9d Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 17 May 2017 12:52:07 +0900 Subject: [PATCH 249/329] Add FastRandom class for use in beatmap conversion. --- .../MathUtils/FastRandom.cs | 92 +++++++++++++++++++ .../osu.Game.Rulesets.Mania.csproj | 1 + 2 files changed, 93 insertions(+) create mode 100644 osu.Game.Rulesets.Mania/MathUtils/FastRandom.cs diff --git a/osu.Game.Rulesets.Mania/MathUtils/FastRandom.cs b/osu.Game.Rulesets.Mania/MathUtils/FastRandom.cs new file mode 100644 index 0000000000..d090fbb0a0 --- /dev/null +++ b/osu.Game.Rulesets.Mania/MathUtils/FastRandom.cs @@ -0,0 +1,92 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; + +namespace osu.Game.Rulesets.Mania.MathUtils +{ + /// + /// A PRNG specified in http://heliosphan.org/fastrandom.html. + /// + internal class FastRandom + { + private const double uint_to_real = 1.0 / (int.MaxValue + 1.0); + private const uint int_mask = 0x7FFFFFFF; + private const uint y = 842502087; + private const uint z = 3579807591; + private const uint w = 273326509; + private uint _x, _y = y, _z = z, _w = w; + + public FastRandom(int seed) + { + _x = (uint)seed; + } + + public FastRandom() + : this(Environment.TickCount) + { + } + + /// + /// Generates a random unsigned integer within the range [, ). + /// + /// The random value. + public uint NextUInt() + { + uint t = (_x ^ (_x << 11)); + _x = _y; + _y = _z; + _z = _w; + return (_w = (_w ^ (_w >> 19)) ^ (t ^ (t >> 8))); + } + + /// + /// Generates a random integer value within the range [0, ). + /// + /// The random value. + public int Next() => (int)(int_mask & NextUInt()); + + /// + /// Generates a random integer value within the range [0, ). + /// + /// The upper bound. + /// The random value. + public int Next(int upperBound) => (int)(NextDouble() * upperBound); + + /// + /// Generates a random integer value within the range [, ). + /// + /// The lower bound of the range. + /// The upper bound of the range. + /// The random value. + public int Next(int lowerBound, int upperBound) => (int)(lowerBound + NextDouble() * (upperBound - lowerBound)); + + /// + /// Generates a random double value within the range [0, 1). + /// + /// The random value. + public double NextDouble() => uint_to_real * NextUInt(); + + private uint bitBuffer; + private int bitIndex = 32; + + /// + /// Generates a reandom boolean value. Cached such that a random value is only generated once in every 32 calls. + /// + /// The random value. + public bool NextBool() + { + if (bitIndex == 32) + { + bitBuffer = NextUInt(); + bitIndex = 1; + + return (bitBuffer & 1) == 1; + } + + bitIndex++; + return ((bitBuffer >>= 1) & 1) == 1; + } + + } +} diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index 00deaba85d..52396debf5 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -48,6 +48,7 @@ + From 51f7904c137aaf8bec05cd468306d53f4729aac1 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 17 May 2017 13:04:34 +0900 Subject: [PATCH 250/329] Remove redundant parentheses. --- osu.Game.Rulesets.Mania/MathUtils/FastRandom.cs | 4 ++-- osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Mania/MathUtils/FastRandom.cs b/osu.Game.Rulesets.Mania/MathUtils/FastRandom.cs index d090fbb0a0..381e24c84c 100644 --- a/osu.Game.Rulesets.Mania/MathUtils/FastRandom.cs +++ b/osu.Game.Rulesets.Mania/MathUtils/FastRandom.cs @@ -33,11 +33,11 @@ namespace osu.Game.Rulesets.Mania.MathUtils /// The random value. public uint NextUInt() { - uint t = (_x ^ (_x << 11)); + uint t = _x ^ _x << 11; _x = _y; _y = _z; _z = _w; - return (_w = (_w ^ (_w >> 19)) ^ (t ^ (t >> 8))); + return _w = _w ^ _w >> 19 ^ t ^ t >> 8; } /// diff --git a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs index 986aefb2bd..da4a693dd8 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs @@ -17,6 +17,7 @@ using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; +using osu.Game.Rulesets.Mania.MathUtils; namespace osu.Game.Rulesets.Mania.UI { @@ -27,6 +28,11 @@ namespace osu.Game.Rulesets.Mania.UI public ManiaHitRenderer(WorkingBeatmap beatmap) : base(beatmap) { + FastRandom fr = new FastRandom(1337); + while (true) + { + int value = fr.Next(); + } } protected override Playfield CreatePlayfield() From 1ded04377815f3b0ef926982f2f2c93afb7a1d2f Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 17 May 2017 13:07:56 +0900 Subject: [PATCH 251/329] Add basic mania-specific beatmap conversion. # Conflicts: # osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs --- .../Beatmaps/LegacyConverter.cs | 72 +++++++++++++++++++ .../Beatmaps/ManiaBeatmapConverter.cs | 41 ++++++----- .../osu.Game.Rulesets.Mania.csproj | 1 + 3 files changed, 95 insertions(+), 19 deletions(-) create mode 100644 osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs diff --git a/osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs new file mode 100644 index 0000000000..20a3dc612b --- /dev/null +++ b/osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs @@ -0,0 +1,72 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using osu.Game.Beatmaps; +using osu.Game.Rulesets.Mania.Objects; +using osu.Game.Rulesets.Objects; +using osu.Game.Rulesets.Objects.Types; +using SharpNeat.Utility; +using System; +using System.Collections.Generic; + +namespace osu.Game.Rulesets.Mania.Beatmaps +{ + /// + /// Special converter used for converting from osu!stable beatmaps. + /// + internal class LegacyConverter + { + private readonly FastRandom random; + + private readonly int availableColumns; + private readonly float localXDivisor; + + private readonly Beatmap beatmap; + + public LegacyConverter(Beatmap beatmap) + { + this.beatmap = beatmap; + + int seed = (int)Math.Round(beatmap.BeatmapInfo.Difficulty.DrainRate + beatmap.BeatmapInfo.Difficulty.CircleSize) + * 20 + (int)(beatmap.BeatmapInfo.Difficulty.OverallDifficulty * 41.2) + (int)Math.Round(beatmap.BeatmapInfo.Difficulty.ApproachRate); + + availableColumns = (int)Math.Round(beatmap.BeatmapInfo.Difficulty.CircleSize); + localXDivisor = 512.0f / availableColumns; + } + + public IEnumerable Convert(HitObject original) + { + if (beatmap.BeatmapInfo.RulesetID == 3) + yield return generateSpecific(original); + } + + private ManiaHitObject generateSpecific(HitObject original) + { + var endTimeData = original as IHasEndTime; + var positionData = original as IHasPosition; + + int column = getColumn(positionData?.X ?? 0); + + if (endTimeData != null) + { + return new HoldNote + { + StartTime = original.StartTime, + Samples = original.Samples, + Duration = endTimeData.Duration, + Column = column, + }; + } + + return new Note + { + StartTime = original.StartTime, + Samples = original.Samples, + Column = column + }; + } + + private int getColumn(float position) => MathHelper.Clamp((int)Math.Floor(position / localXDivisor), 0, availableColumns - 1); + } +} diff --git a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs index e51bbcdc13..e9dae95782 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs @@ -1,35 +1,38 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using osu.Game.Beatmaps; -using osu.Game.Rulesets.Mania.Objects; -using System.Collections.Generic; -using System; -using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Beatmaps; +using osu.Game.Rulesets.Mania.Objects; +using System; +using System.Collections.Generic; +using osu.Game.Beatmaps; using osu.Game.Rulesets.Objects; -using OpenTK; +using osu.Game.Rulesets.Objects.Types; +using System.Linq; namespace osu.Game.Rulesets.Mania.Beatmaps { - internal class ManiaBeatmapConverter : BeatmapConverter + public class ManiaBeatmapConverter : BeatmapConverter { protected override IEnumerable ValidConversionTypes { get; } = new[] { typeof(IHasXPosition) }; + protected override Beatmap ConvertBeatmap(Beatmap original) + { + // Todo: This should be cased when we get better conversion methods + var converter = new LegacyConverter(original); + + return new Beatmap + { + BeatmapInfo = original.BeatmapInfo, + TimingInfo = original.TimingInfo, + HitObjects = original.HitObjects.SelectMany(converter.Convert).ToList() + }; + } + protected override IEnumerable ConvertHitObject(HitObject original, Beatmap beatmap) { - int availableColumns = (int)Math.Round(beatmap.BeatmapInfo.Difficulty.CircleSize); - - var positionData = original as IHasXPosition; - - float localWDivisor = 512.0f / availableColumns; - int column = MathHelper.Clamp((int)Math.Floor((positionData?.X ?? 1) / localWDivisor), 0, availableColumns - 1); - - yield return new Note - { - StartTime = original.StartTime, - Column = column, - }; + // Handled by the LegacyConvereter + yield return null; } } } diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index 52396debf5..781dc3e228 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -47,6 +47,7 @@ + From fdd98e23bdf315e1f7071fb21dd1cdc6b5dc99ed Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 12 May 2017 16:12:18 +0900 Subject: [PATCH 252/329] Fix generation. --- osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs index 20a3dc612b..3d3b052ce6 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs @@ -44,7 +44,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps private ManiaHitObject generateSpecific(HitObject original) { var endTimeData = original as IHasEndTime; - var positionData = original as IHasPosition; + var positionData = original as IHasXPosition; int column = getColumn(positionData?.X ?? 0); From 17466a662cb98fbbd10caef177619e34be3a6c10 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 12 May 2017 16:35:57 +0900 Subject: [PATCH 253/329] Add hold note conversion. --- .../UI/ManiaHitRenderer.cs | 4 +++ .../Legacy/Catch/ConvertHitObjectParser.cs | 5 ++++ .../Objects/Legacy/ConvertHitObjectParser.cs | 29 +++++++++++++------ .../Rulesets/Objects/Legacy/ConvertHold.cs | 22 -------------- .../Legacy/Mania/ConvertHitObjectParser.cs | 9 ++++++ .../Objects/Legacy/Mania/ConvertHold.cs | 16 ++++++++++ .../Legacy/Osu/ConvertHitObjectParser.cs | 5 ++++ .../Legacy/Taiko/ConvertHitObjectParser.cs | 5 ++++ osu.Game/Rulesets/Objects/Types/IHasHold.cs | 4 +++ osu.Game/osu.Game.csproj | 2 +- 10 files changed, 69 insertions(+), 32 deletions(-) delete mode 100644 osu.Game/Rulesets/Objects/Legacy/ConvertHold.cs create mode 100644 osu.Game/Rulesets/Objects/Legacy/Mania/ConvertHold.cs diff --git a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs index da4a693dd8..9387b8e9cb 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs @@ -82,6 +82,10 @@ namespace osu.Game.Rulesets.Mania.UI protected override DrawableHitObject GetVisualRepresentation(ManiaHitObject h) { + var holdNote = h as HoldNote; + if (holdNote != null) + return new DrawableHoldNote(holdNote); + var note = h as Note; if (note != null) return new DrawableNote(note); diff --git a/osu.Game/Rulesets/Objects/Legacy/Catch/ConvertHitObjectParser.cs b/osu.Game/Rulesets/Objects/Legacy/Catch/ConvertHitObjectParser.cs index 5c534456ef..c7f7802191 100644 --- a/osu.Game/Rulesets/Objects/Legacy/Catch/ConvertHitObjectParser.cs +++ b/osu.Game/Rulesets/Objects/Legacy/Catch/ConvertHitObjectParser.cs @@ -43,5 +43,10 @@ namespace osu.Game.Rulesets.Objects.Legacy.Catch EndTime = endTime }; } + + protected override HitObject CreateHold(Vector2 position, bool newCombo, double endTime) + { + return null; + } } } diff --git a/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs b/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs index c5551082ec..3b2d7211bb 100644 --- a/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs +++ b/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs @@ -8,6 +8,7 @@ using System.Collections.Generic; using System.Globalization; using osu.Game.Beatmaps.Formats; using osu.Game.Audio; +using System.Linq; namespace osu.Game.Rulesets.Objects.Legacy { @@ -26,7 +27,7 @@ namespace osu.Game.Rulesets.Objects.Legacy var soundType = (LegacySoundType)int.Parse(split[4]); var bankInfo = new SampleBankInfo(); - HitObject result; + HitObject result = null; if ((type & ConvertHitObjectType.Circle) > 0) { @@ -140,17 +141,19 @@ namespace osu.Game.Rulesets.Objects.Legacy { // Note: Hold is generated by BMS converts - // Todo: Apparently end time is determined by samples?? - // Shouldn't need implementation until mania + double endTime = Convert.ToDouble(split[2], CultureInfo.InvariantCulture); - result = new ConvertHold + if (split.Length > 5 && !string.IsNullOrEmpty(split[5])) { - Position = new Vector2(int.Parse(split[0]), int.Parse(split[1])), - NewCombo = combo - }; + endTime = Convert.ToDouble(split[0], CultureInfo.InvariantCulture); + readCustomSampleBanks(string.Join(":", split.Skip(1)), bankInfo); + } + + result = CreateHold(new Vector2(int.Parse(split[0]), int.Parse(split[1])), combo, endTime); } - else - throw new InvalidOperationException($@"Unknown hit object type {type}"); + + if (result == null) + throw new InvalidOperationException($@"Unknown hit object type {type}."); result.StartTime = Convert.ToDouble(split[2], CultureInfo.InvariantCulture); result.Samples = convertSoundType(soundType, bankInfo); @@ -214,6 +217,14 @@ namespace osu.Game.Rulesets.Objects.Legacy /// The hit object. protected abstract HitObject CreateSpinner(Vector2 position, double endTime); + /// + /// Creates a legacy Hold-type hit object. + /// + /// The position of the hit object. + /// Whether the hit object creates a new combo. + /// The hold end time. + protected abstract HitObject CreateHold(Vector2 position, bool newCombo, double endTime); + private SampleInfoList convertSoundType(LegacySoundType type, SampleBankInfo bankInfo) { var soundTypes = new SampleInfoList diff --git a/osu.Game/Rulesets/Objects/Legacy/ConvertHold.cs b/osu.Game/Rulesets/Objects/Legacy/ConvertHold.cs deleted file mode 100644 index d79f6e324e..0000000000 --- a/osu.Game/Rulesets/Objects/Legacy/ConvertHold.cs +++ /dev/null @@ -1,22 +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.Game.Rulesets.Objects.Types; - -namespace osu.Game.Rulesets.Objects.Legacy -{ - /// - /// Legacy Hold-type, used for parsing "specials" in beatmaps. - /// - internal sealed class ConvertHold : HitObject, IHasPosition, IHasCombo, IHasHold - { - public Vector2 Position { get; set; } - - public float X => Position.X; - - public float Y => Position.Y; - - public bool NewCombo { get; set; } - } -} diff --git a/osu.Game/Rulesets/Objects/Legacy/Mania/ConvertHitObjectParser.cs b/osu.Game/Rulesets/Objects/Legacy/Mania/ConvertHitObjectParser.cs index 224f068323..7141876b8b 100644 --- a/osu.Game/Rulesets/Objects/Legacy/Mania/ConvertHitObjectParser.cs +++ b/osu.Game/Rulesets/Objects/Legacy/Mania/ConvertHitObjectParser.cs @@ -44,5 +44,14 @@ namespace osu.Game.Rulesets.Objects.Legacy.Mania EndTime = endTime }; } + + protected override HitObject CreateHold(Vector2 position, bool newCombo, double endTime) + { + return new ConvertHold + { + X = position.X, + EndTime = endTime + }; + } } } diff --git a/osu.Game/Rulesets/Objects/Legacy/Mania/ConvertHold.cs b/osu.Game/Rulesets/Objects/Legacy/Mania/ConvertHold.cs new file mode 100644 index 0000000000..1dda577320 --- /dev/null +++ b/osu.Game/Rulesets/Objects/Legacy/Mania/ConvertHold.cs @@ -0,0 +1,16 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Rulesets.Objects.Types; + +namespace osu.Game.Rulesets.Objects.Legacy.Mania +{ + internal sealed class ConvertHold : HitObject, IHasXPosition, IHasEndTime + { + public float X { get; set; } + + public double EndTime { get; set; } + + public double Duration => EndTime - StartTime; + } +} diff --git a/osu.Game/Rulesets/Objects/Legacy/Osu/ConvertHitObjectParser.cs b/osu.Game/Rulesets/Objects/Legacy/Osu/ConvertHitObjectParser.cs index 41bf142831..00fe171f0f 100644 --- a/osu.Game/Rulesets/Objects/Legacy/Osu/ConvertHitObjectParser.cs +++ b/osu.Game/Rulesets/Objects/Legacy/Osu/ConvertHitObjectParser.cs @@ -44,5 +44,10 @@ namespace osu.Game.Rulesets.Objects.Legacy.Osu EndTime = endTime }; } + + protected override HitObject CreateHold(Vector2 position, bool newCombo, double endTime) + { + return null; + } } } diff --git a/osu.Game/Rulesets/Objects/Legacy/Taiko/ConvertHitObjectParser.cs b/osu.Game/Rulesets/Objects/Legacy/Taiko/ConvertHitObjectParser.cs index 0d755d7527..5929c5a907 100644 --- a/osu.Game/Rulesets/Objects/Legacy/Taiko/ConvertHitObjectParser.cs +++ b/osu.Game/Rulesets/Objects/Legacy/Taiko/ConvertHitObjectParser.cs @@ -41,5 +41,10 @@ namespace osu.Game.Rulesets.Objects.Legacy.Taiko EndTime = endTime }; } + + protected override HitObject CreateHold(Vector2 position, bool newCombo, double endTime) + { + return null; + } } } diff --git a/osu.Game/Rulesets/Objects/Types/IHasHold.cs b/osu.Game/Rulesets/Objects/Types/IHasHold.cs index 82ec790524..4054fc4fd1 100644 --- a/osu.Game/Rulesets/Objects/Types/IHasHold.cs +++ b/osu.Game/Rulesets/Objects/Types/IHasHold.cs @@ -8,5 +8,9 @@ namespace osu.Game.Rulesets.Objects.Types /// public interface IHasHold { + /// + /// The time at which the hold ends. + /// + double EndTime { get; } } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 63acdb1914..9352cfba6e 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -125,6 +125,7 @@ + @@ -161,7 +162,6 @@ - From 9565bb9572a80aeb4cf8ef32c23b92d4b583e3f7 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 12 May 2017 19:10:26 +0900 Subject: [PATCH 254/329] Fix hold notes - remove glow for now. # Conflicts: # osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs # osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs --- .../Tests/TestCaseManiaHitObjects.cs | 14 +++------- .../Objects/Drawables/DrawableHoldNote.cs | 11 ++++++++ .../Drawables/DrawableManiaHitObject.cs | 26 ------------------- .../Objects/Drawables/Pieces/BodyPiece.cs | 1 - .../Objects/Legacy/ConvertHitObjectParser.cs | 5 ++-- 5 files changed, 17 insertions(+), 40 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs index 3ad83beb73..3113b63db1 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs @@ -43,13 +43,8 @@ namespace osu.Desktop.VisualTests.Tests RelativeCoordinateSpace = new Vector2(1, 10000), Children = new[] { - new DrawableNote(new Note - { - StartTime = 5000 - }) - { - AccentColour = Color4.Red - } + new DrawableNote(new Note { StartTime = 5000 }) { AccentColour = Color4.Red }, + new DrawableNote(new Note { StartTime = 6000 }) { AccentColour = Color4.Red } } } } @@ -74,10 +69,7 @@ namespace osu.Desktop.VisualTests.Tests { StartTime = 5000, Duration = 1000 - }) - { - AccentColour = Color4.Red - } + }) { AccentColour = Color4.Red } } } } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs index 767a2b3458..a1327a3105 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -61,5 +61,16 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables protected override void UpdateState(ArmedState state) { } + + protected override void Update() + { + if (Time.Current > HitObject.StartTime) + headPiece.Colour = Color4.Green; + if (Time.Current > HitObject.EndTime) + { + bodyPiece.Colour = Color4.Green; + tailPiece.Colour = Color4.Green; + } + } } } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs index 0307e9162a..d33a8c48ee 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs @@ -3,8 +3,6 @@ using OpenTK.Graphics; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; using osu.Game.Rulesets.Mania.Judgements; using osu.Game.Rulesets.Objects.Drawables; @@ -15,8 +13,6 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables { public new TObject HitObject; - private readonly Container glowContainer; - protected DrawableManiaHitObject(TObject hitObject) : base(hitObject) { @@ -24,21 +20,6 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables RelativePositionAxes = Axes.Y; Y = (float)HitObject.StartTime; - - Add(glowContainer = new Container - { - RelativeSizeAxes = Axes.Both, - Masking = true, - Children = new[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Alpha = 0, - AlwaysPresent = true - } - } - }); } public override Color4 AccentColour @@ -49,13 +30,6 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables if (base.AccentColour == value) return; base.AccentColour = value; - - glowContainer.EdgeEffect = new EdgeEffect - { - Type = EdgeEffectType.Glow, - Radius = 5, - Colour = value - }; } } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs index ce61a7a86f..c10aa9994b 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs @@ -19,7 +19,6 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces public BodyPiece() { RelativeSizeAxes = Axes.Both; - Masking = true; Children = new[] { diff --git a/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs b/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs index 3b2d7211bb..a4c319291c 100644 --- a/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs +++ b/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs @@ -145,8 +145,9 @@ namespace osu.Game.Rulesets.Objects.Legacy if (split.Length > 5 && !string.IsNullOrEmpty(split[5])) { - endTime = Convert.ToDouble(split[0], CultureInfo.InvariantCulture); - readCustomSampleBanks(string.Join(":", split.Skip(1)), bankInfo); + string[] ss = split[5].Split(':'); + endTime = Convert.ToDouble(ss[0], CultureInfo.InvariantCulture); + readCustomSampleBanks(string.Join(":", ss.Skip(1)), bankInfo); } result = CreateHold(new Vector2(int.Parse(split[0]), int.Parse(split[1])), combo, endTime); From c5d823d7d985948aeddf7181277268bf36176b80 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 17 May 2017 13:04:34 +0900 Subject: [PATCH 255/329] Remove redundant parentheses. --- osu.Game.Rulesets.Mania/MathUtils/FastRandom.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Mania/MathUtils/FastRandom.cs b/osu.Game.Rulesets.Mania/MathUtils/FastRandom.cs index d090fbb0a0..381e24c84c 100644 --- a/osu.Game.Rulesets.Mania/MathUtils/FastRandom.cs +++ b/osu.Game.Rulesets.Mania/MathUtils/FastRandom.cs @@ -33,11 +33,11 @@ namespace osu.Game.Rulesets.Mania.MathUtils /// The random value. public uint NextUInt() { - uint t = (_x ^ (_x << 11)); + uint t = _x ^ _x << 11; _x = _y; _y = _z; _z = _w; - return (_w = (_w ^ (_w >> 19)) ^ (t ^ (t >> 8))); + return _w = _w ^ _w >> 19 ^ t ^ t >> 8; } /// From 4d9aea6aecefb0287b78ffeaaaed798e25401228 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 17 May 2017 13:14:42 +0900 Subject: [PATCH 256/329] Remove while statement (came from fastrandom...). --- osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs index 9387b8e9cb..3c31c6b854 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs @@ -17,7 +17,6 @@ using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; -using osu.Game.Rulesets.Mania.MathUtils; namespace osu.Game.Rulesets.Mania.UI { @@ -28,11 +27,6 @@ namespace osu.Game.Rulesets.Mania.UI public ManiaHitRenderer(WorkingBeatmap beatmap) : base(beatmap) { - FastRandom fr = new FastRandom(1337); - while (true) - { - int value = fr.Next(); - } } protected override Playfield CreatePlayfield() From 2f8556a44a36a88041f5efc7fc380e6a98c9b99f Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 17 May 2017 13:20:33 +0900 Subject: [PATCH 257/329] Fix hold notes + make it compile again. --- osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs | 2 +- osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs index 3d3b052ce6..544f396f4a 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs @@ -6,9 +6,9 @@ using osu.Game.Beatmaps; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Types; -using SharpNeat.Utility; using System; using System.Collections.Generic; +using osu.Game.Rulesets.Mania.MathUtils; namespace osu.Game.Rulesets.Mania.Beatmaps { diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs index a1327a3105..d9e46f4720 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -38,7 +38,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables tailPiece = new NotePiece { Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre + Origin = Anchor.TopCentre } }); } From 78c1d4581f84978a2db96e78807edaac2b417456 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 17 May 2017 13:44:43 +0900 Subject: [PATCH 258/329] Revert "Use generic IComparable for message." This reverts commit aaaee5ed102e54a2fe40209e0ebe967015b29b83. --- osu.Game/Online/Chat/Channel.cs | 2 +- osu.Game/Online/Chat/Message.cs | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/osu.Game/Online/Chat/Channel.cs b/osu.Game/Online/Chat/Channel.cs index 93fd0a8956..2925c3ccb4 100644 --- a/osu.Game/Online/Chat/Channel.cs +++ b/osu.Game/Online/Chat/Channel.cs @@ -23,7 +23,7 @@ namespace osu.Game.Online.Chat [JsonProperty(@"channel_id")] public int Id; - public readonly SortedList Messages = new SortedList(Comparer.Default); + public readonly SortedList Messages = new SortedList((m1, m2) => m1.Id.CompareTo(m2.Id)); //internal bool Joined; diff --git a/osu.Game/Online/Chat/Message.cs b/osu.Game/Online/Chat/Message.cs index c1887e7824..bf53a68910 100644 --- a/osu.Game/Online/Chat/Message.cs +++ b/osu.Game/Online/Chat/Message.cs @@ -8,7 +8,7 @@ using osu.Game.Users; namespace osu.Game.Online.Chat { - public class Message : IComparable + public class Message { [JsonProperty(@"message_id")] public readonly long Id; @@ -42,7 +42,17 @@ namespace osu.Game.Online.Chat Id = id; } - public int CompareTo(Message other) => Id.CompareTo(other.Id); + public override bool Equals(object obj) + { + var objMessage = obj as Message; + + return Id == objMessage?.Id; + } + + public override int GetHashCode() + { + return Id.GetHashCode(); + } } public enum TargetType From cab12ee55a6ce09ae2f01eed9fb8bf06a40e330a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 17 May 2017 16:45:17 +0900 Subject: [PATCH 259/329] Reduce the possibility of recomputing drawables when underlying beatmap hasn't changed --- osu.Game/Screens/Select/BeatmapDetails.cs | 2 ++ .../Screens/Select/Leaderboards/Leaderboard.cs | 2 ++ osu.Game/Screens/Select/SongSelect.cs | 16 ++++++++-------- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index b750fc9bbe..abe54375cc 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -49,6 +49,8 @@ namespace osu.Game.Screens.Select get { return beatmap; } set { + if (beatmap == value) return; + beatmap = value; pendingBeatmapSwitch?.Cancel(); diff --git a/osu.Game/Screens/Select/Leaderboards/Leaderboard.cs b/osu.Game/Screens/Select/Leaderboards/Leaderboard.cs index a136e298b5..a7aa752d65 100644 --- a/osu.Game/Screens/Select/Leaderboards/Leaderboard.cs +++ b/osu.Game/Screens/Select/Leaderboards/Leaderboard.cs @@ -100,6 +100,8 @@ namespace osu.Game.Screens.Select.Leaderboards get { return beatmap; } set { + if (beatmap == value) return; + beatmap = value; Scores = null; diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 4438b656b0..4982ca096f 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -313,15 +313,15 @@ namespace osu.Game.Screens.Select { bool beatmapSetChange = false; - if (!beatmap.Equals(Beatmap?.BeatmapInfo)) + if (beatmap.Equals(Beatmap?.BeatmapInfo)) + return; + + if (beatmap.BeatmapSetInfoID == selectionChangeNoBounce?.BeatmapSetInfoID) + sampleChangeDifficulty.Play(); + else { - if (beatmap.BeatmapSetInfoID == selectionChangeNoBounce?.BeatmapSetInfoID) - sampleChangeDifficulty.Play(); - else - { - sampleChangeBeatmap.Play(); - beatmapSetChange = true; - } + sampleChangeBeatmap.Play(); + beatmapSetChange = true; } selectionChangeNoBounce = beatmap; From 7bb38e927b5a0487994d3616f33b8525405d10e9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 17 May 2017 17:15:25 +0900 Subject: [PATCH 260/329] Fix song select reverting to first difficulty of current group on entering --- osu.Game/Screens/Select/BeatmapCarousel.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index fbdaa948cc..4df24c1314 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -107,6 +107,8 @@ namespace osu.Game.Screens.Select return; } + if (beatmap == SelectedBeatmap) return; + foreach (BeatmapGroup group in groups) { var panel = group.BeatmapPanels.FirstOrDefault(p => p.Beatmap.Equals(beatmap)); @@ -204,7 +206,7 @@ namespace osu.Game.Screens.Select if (selectedGroup == null || selectedGroup.State == BeatmapGroupState.Hidden) SelectNext(); else - selectGroup(selectedGroup); + selectGroup(selectedGroup, selectedPanel); }; filterTask?.Cancel(); @@ -339,6 +341,8 @@ namespace osu.Game.Screens.Select selectedGroup.State = BeatmapGroupState.Collapsed; group.State = BeatmapGroupState.Expanded; + group.SelectedPanel = panel; + panel.State = PanelSelectedState.Selected; if (selectedPanel == panel) return; From cba77967777da8f22469ae31b2f0f31bc34dbbf3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 17 May 2017 18:49:30 +0900 Subject: [PATCH 261/329] Fix ratio container being added to a level too high That's a bad ratio container! How did we not notice this until now? --- osu.Game/OsuGameBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 7e16030ec3..2c39a82245 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -146,7 +146,7 @@ namespace osu.Game { base.LoadComplete(); - AddInternal(ratioContainer = new RatioAdjust + base.Content.Add(ratioContainer = new RatioAdjust { Children = new Drawable[] { From 88a70e407ca2ce9805177f88f18ae073acb77265 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 17 May 2017 20:11:41 +0900 Subject: [PATCH 262/329] Fix and simplifty pause logic Resolves #770 --- osu.Game/Screens/Play/Player.cs | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 8ee0de12b9..68fbbaddcc 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -38,7 +38,7 @@ namespace osu.Game.Screens.Play public Action RestartRequested; - public bool IsPaused => !decoupledClock.IsRunning; + public bool IsPaused { get; private set; } internal override bool AllowRulesetChange => false; @@ -264,19 +264,18 @@ namespace osu.Game.Screens.Play { if (!canPause && !force) return; - // the actual pausing is potentially happening on a different thread. - // we want to wait for the source clock to stop so we can be sure all components are in a stable state. - if (!IsPaused) - { - decoupledClock.Stop(); + if (IsPaused) return; - Schedule(() => Pause(force)); - return; - } + // stop the decoupled clock (stops the audio eventually) + decoupledClock.Stop(); + + // stop processing updatess on the offset clock (instantly freezes time for all our components) + offsetClock.ProcessSourceClockFrames = false; + + IsPaused = true; // we need to do a final check after all of our children have processed up to the paused clock time. - // this is to cover cases where, for instance, the player fails in the last processed frame (which would change canPause). - // as the scheduler runs before children updates, let's schedule for the next frame. + // this is to cover cases where, for instance, the player fails in the current processing frame. Schedule(() => { if (!canPause) return; @@ -291,6 +290,11 @@ namespace osu.Game.Screens.Play public void Resume() { + if (!IsPaused) return; + + IsPaused = false; + offsetClock.ProcessSourceClockFrames = true; + lastPauseActionTime = Time.Current; hudOverlay.KeyCounter.IsCounting = true; hudOverlay.Progress.Hide(); From 74c23ff6d8a4f110993141266070a8ed843b85ee Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 17 May 2017 18:42:48 +0900 Subject: [PATCH 263/329] Add base for event parsing code. --- osu.Game/Beatmaps/Beatmap.cs | 3 + .../{EventType.cs => BackgroundEvent.cs} | 15 ++--- osu.Game/Beatmaps/Events/BreakEvent.cs | 28 +++++++++ osu.Game/Beatmaps/Events/Event.cs | 13 ++++ osu.Game/Beatmaps/Events/EventInfo.cs | 26 ++++++++ osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs | 59 +++++++++++++++---- osu.Game/osu.Game.csproj | 5 +- 7 files changed, 126 insertions(+), 23 deletions(-) rename osu.Game/Beatmaps/Events/{EventType.cs => BackgroundEvent.cs} (52%) create mode 100644 osu.Game/Beatmaps/Events/BreakEvent.cs create mode 100644 osu.Game/Beatmaps/Events/Event.cs create mode 100644 osu.Game/Beatmaps/Events/EventInfo.cs diff --git a/osu.Game/Beatmaps/Beatmap.cs b/osu.Game/Beatmaps/Beatmap.cs index 3964fd25a7..a64002e0b0 100644 --- a/osu.Game/Beatmaps/Beatmap.cs +++ b/osu.Game/Beatmaps/Beatmap.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK.Graphics; +using osu.Game.Beatmaps.Events; using osu.Game.Beatmaps.Timing; using osu.Game.Database; using osu.Game.Rulesets.Objects; @@ -17,6 +18,7 @@ namespace osu.Game.Beatmaps { public BeatmapInfo BeatmapInfo; public TimingInfo TimingInfo = new TimingInfo(); + public EventInfo EventInfo = new EventInfo(); public readonly List ComboColors = new List { new Color4(17, 136, 170, 255), @@ -40,6 +42,7 @@ namespace osu.Game.Beatmaps { BeatmapInfo = original?.BeatmapInfo ?? BeatmapInfo; TimingInfo = original?.TimingInfo ?? TimingInfo; + EventInfo = original?.EventInfo ?? EventInfo; ComboColors = original?.ComboColors ?? ComboColors; } } diff --git a/osu.Game/Beatmaps/Events/EventType.cs b/osu.Game/Beatmaps/Events/BackgroundEvent.cs similarity index 52% rename from osu.Game/Beatmaps/Events/EventType.cs rename to osu.Game/Beatmaps/Events/BackgroundEvent.cs index 0d4be693f0..215373bd3b 100644 --- a/osu.Game/Beatmaps/Events/EventType.cs +++ b/osu.Game/Beatmaps/Events/BackgroundEvent.cs @@ -3,14 +3,11 @@ namespace osu.Game.Beatmaps.Events { - public enum EventType + public class BackgroundEvent : Event { - Background = 0, - Video = 1, - Break = 2, - Colour = 3, - Sprite = 4, - Sample = 5, - Animation = 6 + /// + /// The file name. + /// + public string Filename; } -} \ No newline at end of file +} diff --git a/osu.Game/Beatmaps/Events/BreakEvent.cs b/osu.Game/Beatmaps/Events/BreakEvent.cs new file mode 100644 index 0000000000..78e33f2fbb --- /dev/null +++ b/osu.Game/Beatmaps/Events/BreakEvent.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Beatmaps.Events +{ + public class BreakEvent : Event + { + /// + /// The minimum duration required for a break to have any effect. + /// + private const double min_break_duration = 650; + + /// + /// The break end time. + /// + public double EndTime; + + /// + /// The duration of the break. + /// + public double Duration => EndTime - StartTime; + + /// + /// Whether the break has any effect. Breaks that are too short are culled before they reach the EventInfo. + /// + public bool HasEffect => Duration >= min_break_duration; + } +} diff --git a/osu.Game/Beatmaps/Events/Event.cs b/osu.Game/Beatmaps/Events/Event.cs new file mode 100644 index 0000000000..3af3909462 --- /dev/null +++ b/osu.Game/Beatmaps/Events/Event.cs @@ -0,0 +1,13 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Beatmaps.Events +{ + public abstract class Event + { + /// + /// The event start time. + /// + public double StartTime; + } +} diff --git a/osu.Game/Beatmaps/Events/EventInfo.cs b/osu.Game/Beatmaps/Events/EventInfo.cs new file mode 100644 index 0000000000..646dea898e --- /dev/null +++ b/osu.Game/Beatmaps/Events/EventInfo.cs @@ -0,0 +1,26 @@ +// 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; + +namespace osu.Game.Beatmaps.Events +{ + public class EventInfo + { + /// + /// All the background events. + /// + public readonly List Backgrounds = new List(); + + /// + /// All the break events. + /// + public readonly List Breaks = new List(); + + /// + /// Total duration of all breaks. + /// + public double TotalBreakTime => Breaks.Sum(b => b.Duration); + } +} diff --git a/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs b/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs index 95213417ed..772c0e9c07 100644 --- a/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs +++ b/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs @@ -204,23 +204,42 @@ namespace osu.Game.Beatmaps.Formats private void handleEvents(Beatmap beatmap, string val) { - if (val.StartsWith(@"//")) - return; - if (val.StartsWith(@" ")) - return; // TODO string[] split = val.Split(','); + EventType type; - int intType; - if (!int.TryParse(split[0], out intType)) + if (!Enum.TryParse(split[0], out type)) + throw new InvalidDataException($@"Unknown event type {split[0]}"); + + // Todo: Implement the rest + switch (type) { - if (!Enum.TryParse(split[0], out type)) - throw new InvalidDataException($@"Unknown event type {split[0]}"); + case EventType.Video: + case EventType.Background: + string filename = split[2].Trim('"'); + + beatmap.EventInfo.Backgrounds.Add(new BackgroundEvent + { + StartTime = double.Parse(split[1], NumberFormatInfo.InvariantInfo), + Filename = filename + }); + + if (type == EventType.Background) + beatmap.BeatmapInfo.Metadata.BackgroundFile = filename; + + break; + case EventType.Break: + var breakEvent = new BreakEvent + { + StartTime = double.Parse(split[1], NumberFormatInfo.InvariantInfo), + EndTime = double.Parse(split[2], NumberFormatInfo.InvariantInfo) + }; + + if (!breakEvent.HasEffect) + return; + + beatmap.EventInfo.Breaks.Add(breakEvent); + break; } - else - type = (EventType)intType; - // TODO: Parse and store the rest of the event - if (type == EventType.Background) - beatmap.BeatmapInfo.Metadata.BackgroundFile = split[2].Trim('"'); } private void handleTimingPoints(Beatmap beatmap, string val) @@ -330,6 +349,9 @@ namespace osu.Game.Beatmaps.Formats if (string.IsNullOrEmpty(line)) continue; + if (line.StartsWith(" ") || line.StartsWith("_") || line.StartsWith("//")) + continue; + if (line.StartsWith(@"osu file format v")) { beatmap.BeatmapInfo.BeatmapVersion = int.Parse(line.Substring(17)); @@ -390,5 +412,16 @@ namespace osu.Game.Beatmaps.Formats Soft = 2, Drum = 3 } + + internal enum EventType + { + Background = 0, + Video = 1, + Break = 2, + Colour = 3, + Sprite = 4, + Sample = 5, + Animation = 6 + } } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 9352cfba6e..ed2532d238 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -74,6 +74,10 @@ + + + + @@ -342,7 +346,6 @@ - From b52ec11260f4d6a207d63c7232941cc974fddcc7 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 17 May 2017 20:47:02 +0900 Subject: [PATCH 264/329] Add (almost finished) basis of slider hit object conversion... --- .../Beatmaps/DistanceObjectConversion.cs | 409 ++++++++++++++++++ .../Beatmaps/LegacyConvertType.cs | 62 +++ .../Beatmaps/LegacyConverter.cs | 67 ++- .../Beatmaps/ObjectConversion.cs | 77 ++++ osu.Game.Rulesets.Mania/Beatmaps/ObjectRow.cs | 44 ++ .../osu.Game.Rulesets.Mania.csproj | 4 + 6 files changed, 657 insertions(+), 6 deletions(-) create mode 100644 osu.Game.Rulesets.Mania/Beatmaps/DistanceObjectConversion.cs create mode 100644 osu.Game.Rulesets.Mania/Beatmaps/LegacyConvertType.cs create mode 100644 osu.Game.Rulesets.Mania/Beatmaps/ObjectConversion.cs create mode 100644 osu.Game.Rulesets.Mania/Beatmaps/ObjectRow.cs diff --git a/osu.Game.Rulesets.Mania/Beatmaps/DistanceObjectConversion.cs b/osu.Game.Rulesets.Mania/Beatmaps/DistanceObjectConversion.cs new file mode 100644 index 0000000000..c775c189e1 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Beatmaps/DistanceObjectConversion.cs @@ -0,0 +1,409 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Rulesets.Mania.Objects; +using osu.Game.Beatmaps; +using osu.Game.Beatmaps.Timing; +using osu.Game.Rulesets.Objects; +using osu.Game.Rulesets.Objects.Types; +using System; +using osu.Game.Rulesets.Mania.MathUtils; +using System.Linq; +using OpenTK; +using osu.Game.Database; +using osu.Game.Audio; +using System.Collections.Generic; + +namespace osu.Game.Rulesets.Mania.Beatmaps +{ + internal class DistanceObjectConversion : ObjectConversion + { + private readonly HitObject originalObject; + + private readonly double endTime; + private readonly int repeatCount; + + private LegacyConvertType convertType; + + public DistanceObjectConversion(HitObject originalObject, ObjectRow previousRow, FastRandom random, Beatmap beatmap) + : base(previousRow, random, beatmap) + { + this.originalObject = originalObject; + + ControlPoint overridePoint; + ControlPoint controlPoint = Beatmap.TimingInfo.TimingPointAt(originalObject.StartTime, out overridePoint); + + convertType = LegacyConvertType.None; + if ((overridePoint ?? controlPoint)?.KiaiMode == false) + convertType = LegacyConvertType.LowProbability; + + var distanceData = originalObject as IHasDistance; + var repeatsData = originalObject as IHasRepeats; + + endTime = distanceData?.EndTime ?? 0; + repeatCount = repeatsData?.RepeatCount ?? 1; + } + + public override ObjectRow GenerateConversion() + { + double segmentDuration = endTime / repeatCount; + + if (repeatCount > 1) + { + if (segmentDuration <= 90) + return generateRandomHoldNotes(originalObject.StartTime, endTime, 1); + + if (segmentDuration <= 120) + { + convertType |= LegacyConvertType.ForceNotStack; + return addRandomNotes(originalObject.StartTime, segmentDuration, repeatCount); + } + + if (segmentDuration <= 160) + return addStair(originalObject.StartTime, segmentDuration, repeatCount); + + if (segmentDuration <= 200 && conversionDifficulty > 3) + return addMultipleNotes(originalObject.StartTime, segmentDuration, repeatCount); + + double duration = endTime - originalObject.StartTime; + if (duration >= 4000) + return addNRandomNotes(originalObject.StartTime, endTime, 0.23, 0, 0); + + if (segmentDuration > 400 && duration < 4000 && repeatCount < AvailableColumns - 1 - RandomStart) + return generateTiledHoldNotes(originalObject.StartTime, segmentDuration, repeatCount); + + return generateLongAndNormalNotes(originalObject.StartTime, segmentDuration); + } + + if (segmentDuration <= 110) + { + if (PreviousRow.Columns < AvailableColumns) + convertType |= LegacyConvertType.ForceNotStack; + else + convertType &= ~LegacyConvertType.ForceNotStack; + return addRandomNotes(originalObject.StartTime, segmentDuration, segmentDuration < 80 ? 0 : 1); + } + + if (conversionDifficulty > 6.5) + { + if ((convertType & LegacyConvertType.LowProbability) > 0) + return addNRandomNotes(originalObject.StartTime, endTime, 0.78, 0.3, 0); + return addNRandomNotes(originalObject.StartTime, endTime, 0.85, 0.36, 0.03); + } + + if (conversionDifficulty > 4) + { + if ((convertType & LegacyConvertType.LowProbability) > 0) + return addNRandomNotes(originalObject.StartTime, endTime, 0.43, 0.08, 0); + return addNRandomNotes(originalObject.StartTime, endTime, 0.56, 0.18, 0); + } + + if (conversionDifficulty > 2.5) + { + if ((convertType & LegacyConvertType.LowProbability) > 0) + return addNRandomNotes(originalObject.StartTime, endTime, 0.3, 0, 0); + return addNRandomNotes(originalObject.StartTime, endTime, 0.37, 0.08, 0); + } + + if ((convertType & LegacyConvertType.LowProbability) > 0) + return addNRandomNotes(originalObject.StartTime, endTime, 0.17, 0, 0); + return addNRandomNotes(originalObject.StartTime, endTime, 0.27, 0, 0); + } + + /// + /// Adds random hold notes. + /// + /// Number of hold notes. + /// Start time of each hold note. + /// End time of the hold notes. + /// The new row. + private ObjectRow generateRandomHoldNotes(double startTime, double endTime, int count) + { + var newRow = new ObjectRow(); + + int usableColumns = AvailableColumns - RandomStart - PreviousRow.Columns; + int nextColumn = Random.Next(RandomStart, AvailableColumns); + for (int i = 0; i < Math.Min(usableColumns, count); i++) + { + while (newRow.IsTaken(nextColumn) || PreviousRow.IsTaken(nextColumn)) //find available column + nextColumn = Random.Next(RandomStart, AvailableColumns); + add(newRow, nextColumn, startTime, endTime, count); + } + + // This is can't be combined with the above loop due to RNG + for (int i = 0; i < count - usableColumns; i++) + { + while (newRow.IsTaken(nextColumn)) + nextColumn = Random.Next(RandomStart, AvailableColumns); + add(newRow, nextColumn, startTime, endTime, count); + } + + return newRow; + } + + /// + /// Adds random notes, with one note per row. No stacking. + /// + /// The start time. + /// The separation of notes between rows. + /// The number of rows. + /// The new row. + private ObjectRow addRandomNotes(double startTime, double separationTime, int repeatCount) + { + var newRow = new ObjectRow(); + + int nextColumn = GetColumn((originalObject as IHasXPosition)?.X ?? 0, true); + if ((convertType & LegacyConvertType.ForceNotStack) > 0 && PreviousRow.Columns < AvailableColumns) + { + while (PreviousRow.IsTaken(nextColumn)) + nextColumn = Random.Next(RandomStart, AvailableColumns); + } + + int lastColumn = nextColumn; + for (int i = 0; i <= repeatCount; i++) + { + add(newRow, nextColumn, startTime, startTime); + while (nextColumn == lastColumn) + nextColumn = Random.Next(RandomStart, AvailableColumns); + + lastColumn = nextColumn; + startTime += separationTime; + } + + return newRow; + } + + /// + /// Creates a stair of notes, with one note per row. + /// + /// The start time. + /// The separation of notes between rows. + /// The number of rows/notes. + /// The new row. + private ObjectRow addStair(double startTime, double separationTime, int repeatCount) + { + var newRow = new ObjectRow(); + + int column = GetColumn((originalObject as IHasXPosition)?.X ?? 0, true); + bool increasing = Random.NextDouble() > 0.5; + + for (int i = 0; i <= repeatCount; i++) + { + add(newRow, column, startTime, startTime); + startTime += separationTime; + + // Check if we're at the borders of the stage, and invert the pattern if so + if (increasing) + { + if (column >= AvailableColumns - 1) + { + increasing = false; + column--; + } + else + column++; + } + else + { + if (column <= RandomStart) + { + increasing = true; + column++; + } + else + column--; + } + } + + return newRow; + } + + /// + /// Adds random notes, with 1-2 notes per row. No stacking. + /// + /// The start time. + /// The separation of notes between rows. + /// The number of rows. + /// The new row. + private ObjectRow addMultipleNotes(double startTime, double separationTime, int repeatCount) + { + var newRow = new ObjectRow(); + + bool legacy = AvailableColumns >= 4 && AvailableColumns <= 8; + int interval = Random.Next(1, AvailableColumns - (legacy ? 1 : 0)); + + int nextColumn = GetColumn((originalObject as IHasXPosition)?.X ?? 0, true); + for (int i = 0; i <= repeatCount; i++) + { + add(newRow, nextColumn, startTime, startTime, 2); + + nextColumn += interval; + if (nextColumn >= AvailableColumns - RandomStart) + nextColumn = nextColumn - AvailableColumns - RandomStart + (legacy ? 1 : 0); + nextColumn += RandomStart; + + // If we're in 2K, let's not add many consecutive doubles + if (AvailableColumns > 2) + add(newRow, nextColumn, startTime, startTime, 2); + + nextColumn = Random.Next(RandomStart, AvailableColumns); + startTime += separationTime; + } + + return newRow; + } + + /// + /// Generates random hold notes. The amount of hold notes generated is determined by probabilities. + /// + /// The hold note start time. + /// The hold note end time. + /// The probability required for 2 hold notes to be generated. + /// The probability required for 3 hold notes to be generated. + /// The probability required for 4 hold notes to be generated. + /// The new row. + private ObjectRow addNRandomNotes(double startTime, double endTime, double p2, double p3, double p4) + { + switch (AvailableColumns) + { + case 2: + p2 = 0; + p3 = 0; + p4 = 0; + break; + case 3: + p2 = Math.Max(p2, 0.1); + p3 = 0; + p4 = 0; + break; + case 4: + p2 = Math.Max(p2, 0.3); + p3 = Math.Max(p3, 0.04); + p4 = 0; + break; + case 5: + p2 = Math.Max(p2, 0.34); + p3 = Math.Max(p3, 0.1); + p4 = Math.Max(p4, 0.03); + break; + } + + Func isDoubleSample = sample => sample.Name == SampleInfo.HIT_CLAP && sample.Name == SampleInfo.HIT_FINISH; + + bool canGenerateTwoNotes = (convertType & LegacyConvertType.LowProbability) == 0; + canGenerateTwoNotes &= originalObject.Samples.Any(isDoubleSample) || sampleInfoListAt(originalObject.StartTime, originalObject.StartTime - endTime).Any(isDoubleSample); + + if (canGenerateTwoNotes) + p2 = 0; + + return generateRandomHoldNotes(startTime, endTime, GetRandomNoteCount(p2, p3, p4)); + } + + private ObjectRow generateTiledHoldNotes(double startTime, double separationTime, int noteCount) + { + var newRow = new ObjectRow(); + + int columnRepeat = Math.Min(noteCount, AvailableColumns); + + int nextColumn = GetColumn((originalObject as IHasXPosition)?.X ?? 0, true); + if ((convertType & LegacyConvertType.ForceNotStack) > 0 && PreviousRow.Columns < AvailableColumns) + { + while (PreviousRow.IsTaken(nextColumn)) + nextColumn = Random.Next(RandomStart, AvailableColumns); + } + + for (int i = 0; i < columnRepeat; i++) + { + while (newRow.IsTaken(nextColumn)) + nextColumn = Random.Next(RandomStart, AvailableColumns); + + add(newRow, nextColumn, startTime, endTime, noteCount); + startTime += separationTime; + } + + return newRow; + } + + private ObjectRow generateLongAndNormalNotes(double startTime, double separationTime) + { + var newRow = new ObjectRow(); + + int holdColumn = GetColumn((originalObject as IHasXPosition)?.X ?? 0, true); + if ((convertType & LegacyConvertType.ForceNotStack) > 0 && PreviousRow.Columns < AvailableColumns) + { + while (PreviousRow.IsTaken(holdColumn)) + holdColumn = Random.Next(RandomStart, AvailableColumns); + } + + // Create the hold note + add(newRow, holdColumn, startTime, separationTime * repeatCount); + + // Todo: Complete + } + + private void add(ObjectRow row, int column, double startTime, double endTime, int siblings = 1) + { + ManiaHitObject newObject; + + if (startTime == endTime) + { + newObject = new Note + { + StartTime = startTime, + Samples = originalObject.Samples, + Column = column + }; + } + else + { + newObject = new HoldNote + { + StartTime = startTime, + Samples = originalObject.Samples, + Column = column, + Duration = endTime - startTime + }; + } + + // Todo: Consider siblings and write sample volumes (probably at ManiaHitObject level) + + row.Add(newObject); + } + + private SampleInfoList sampleInfoListAt(double time, double separationTime) + { + var curveData = originalObject as IHasCurve; + + if (curveData == null) + return originalObject.Samples; + + int index = (int)(separationTime == 0 ? 0 : (time - originalObject.StartTime) / separationTime); + return curveData.RepeatSamples[index]; + } + + private double? _conversionDifficulty; + private double conversionDifficulty + { + get + { + if (_conversionDifficulty != null) + return _conversionDifficulty.Value; + + HitObject lastObject = Beatmap.HitObjects.LastOrDefault(); + HitObject firstObject = Beatmap.HitObjects.FirstOrDefault(); + + double drainTime = (lastObject?.StartTime ?? 0) - (firstObject?.StartTime ?? 0); + drainTime -= Beatmap.EventInfo.TotalBreakTime; + + if (drainTime == 0) + drainTime = 10000; + + BeatmapDifficulty difficulty = Beatmap.BeatmapInfo.Difficulty; + _conversionDifficulty = ((difficulty.DrainRate + MathHelper.Clamp(difficulty.ApproachRate, 4, 7)) / 1.5 + Beatmap.HitObjects.Count / drainTime * 9f) / 38f * 5f / 1.15; + _conversionDifficulty = Math.Min(_conversionDifficulty.Value, 12); + + return _conversionDifficulty.Value; + } + } + } +} diff --git a/osu.Game.Rulesets.Mania/Beatmaps/LegacyConvertType.cs b/osu.Game.Rulesets.Mania/Beatmaps/LegacyConvertType.cs new file mode 100644 index 0000000000..086bc89292 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Beatmaps/LegacyConvertType.cs @@ -0,0 +1,62 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; + +namespace osu.Game.Rulesets.Mania.Beatmaps +{ + [Flags] + internal enum LegacyConvertType + { + None = 0, + /// + /// Keep the same as last row. + /// + ForceStack = 1, + /// + /// Keep different from last row. + /// + ForceNotStack = 2, + /// + /// Keep as single note at its original position. + /// + KeepSingle = 4, + /// + /// Use a lower random value. + /// + LowProbability = 8, + /// + /// Reserved. + /// + Alternate = 16, + /// + /// Ignore the repeat count. + /// + ForceSigSlider = 32, + /// + /// Convert slider to circle. + /// + ForceNotSlider = 64, + /// + /// Notes gathered together. + /// + Gathered = 128, + Mirror = 256, + /// + /// Change 0 -> 6. + /// + Reverse = 512, + /// + /// 1 -> 5 -> 1 -> 5 like reverse. + /// + Cycle = 1024, + /// + /// Next note will be at column + 1. + /// + Stair = 2048, + /// + /// Next note will be at column - 1. + /// + ReverseStair = 4096 + } +} diff --git a/osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs index 544f396f4a..ebc6ed2dcf 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs @@ -9,6 +9,7 @@ using osu.Game.Rulesets.Objects.Types; using System; using System.Collections.Generic; using osu.Game.Rulesets.Mania.MathUtils; +using osu.Game.Beatmaps.Timing; namespace osu.Game.Rulesets.Mania.Beatmaps { @@ -17,28 +18,51 @@ namespace osu.Game.Rulesets.Mania.Beatmaps /// internal class LegacyConverter { + private const int max_previous_note_times = 7; + private readonly FastRandom random; + private readonly List previousNoteTimes; + private readonly bool[] previousNotes; + private readonly double lastNoteTime; + private readonly float lastNotePosition; + private readonly int availableColumns; private readonly float localXDivisor; private readonly Beatmap beatmap; - public LegacyConverter(Beatmap beatmap) + public LegacyConverter(ObjectRow previousrow, Beatmap beatmap) { this.beatmap = beatmap; int seed = (int)Math.Round(beatmap.BeatmapInfo.Difficulty.DrainRate + beatmap.BeatmapInfo.Difficulty.CircleSize) * 20 + (int)(beatmap.BeatmapInfo.Difficulty.OverallDifficulty * 41.2) + (int)Math.Round(beatmap.BeatmapInfo.Difficulty.ApproachRate); + random = new FastRandom(seed); availableColumns = (int)Math.Round(beatmap.BeatmapInfo.Difficulty.CircleSize); localXDivisor = 512.0f / availableColumns; + + previousNoteTimes = new List(max_previous_note_times); + previousNotes = new bool[availableColumns]; } public IEnumerable Convert(HitObject original) { + var maniaOriginal = original as ManiaHitObject; + if (maniaOriginal != null) + { + yield return maniaOriginal; + yield break; + } + if (beatmap.BeatmapInfo.RulesetID == 3) yield return generateSpecific(original); + else + { + foreach (ManiaHitObject c in generateConverted(original)) + yield return c; + } } private ManiaHitObject generateSpecific(HitObject original) @@ -59,12 +83,43 @@ namespace osu.Game.Rulesets.Mania.Beatmaps }; } - return new Note + if (positionData != null) { - StartTime = original.StartTime, - Samples = original.Samples, - Column = column - }; + return new Note + { + StartTime = original.StartTime, + Samples = original.Samples, + Column = column + }; + } + + return null; + } + + private IEnumerable generateConverted(HitObject original) + { + var endTimeData = original as IHasEndTime; + var distanceData = original as IHasDistance; + var positionData = original as IHasPosition; + + ObjectConversion conversion = null; + + if (distanceData != null) + conversion = new DistanceObjectConversion(distanceData, beatmap); + else if (endTimeData != null) + { + // Spinner + } + else if (positionData != null) + { + // Circle + } + + if (conversion == null) + yield break; + + foreach (ManiaHitObject obj in conversion.GenerateConversion()) + yield return obj; } private int getColumn(float position) => MathHelper.Clamp((int)Math.Floor(position / localXDivisor), 0, availableColumns - 1); diff --git a/osu.Game.Rulesets.Mania/Beatmaps/ObjectConversion.cs b/osu.Game.Rulesets.Mania/Beatmaps/ObjectConversion.cs new file mode 100644 index 0000000000..9dee1116e0 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Beatmaps/ObjectConversion.cs @@ -0,0 +1,77 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using osu.Game.Beatmaps; +using osu.Game.Rulesets.Mania.MathUtils; +using System; + +namespace osu.Game.Rulesets.Mania.Beatmaps +{ + internal abstract class ObjectConversion + { + protected readonly int AvailableColumns; + protected readonly int RandomStart; + + protected ObjectRow PreviousRow; + protected readonly FastRandom Random; + protected readonly Beatmap Beatmap; + + protected ObjectConversion(ObjectRow previousRow, FastRandom random, Beatmap beatmap) + { + PreviousRow = previousRow; + Random = random; + Beatmap = beatmap; + + AvailableColumns = (int)Math.Round(beatmap.BeatmapInfo.Difficulty.CircleSize); + RandomStart = AvailableColumns == 8 ? 1 : 0; + } + + /// + /// Generates a new row filled with converted hit objects. + /// + /// The new row. + public abstract ObjectRow GenerateConversion(); + + /// + /// Converts an x-position into a column. + /// + /// The x-position. + /// Whether to treat as 7K + 1. + /// The column. + protected int GetColumn(float position, bool allowSpecial = false) + { + if (allowSpecial && AvailableColumns == 8) + { + const float local_x_divisor = 512f / 7; + return MathHelper.Clamp((int)Math.Floor(position / local_x_divisor), 0, 6) + 1; + } + + float localXDivisor = 512f / AvailableColumns; + return MathHelper.Clamp((int)Math.Floor(position / localXDivisor), 0, AvailableColumns - 1); + } + + /// + /// Generates a count of notes to be generated from probabilities. + /// + /// Probability for 2 notes to be generated. + /// Probability for 3 notes to be generated. + /// Probability for 4 notes to be generated. + /// Probability for 5 notes to be generated. + /// Probability for 6 notes to be generated. + /// The amount of notes to be generated. + protected int GetRandomNoteCount(double p2, double p3, double p4 = 1, double p5 = 1, double p6 = 1) + { + double val = Random.NextDouble(); + if (val >= 1 - p6) + return 6; + if (val >= 1 - p5) + return 5; + if (val >= 1 - p4) + return 4; + if (val >= 1 - p3) + return 3; + return val >= 1 - p2 ? 2 : 1; + } + } +} diff --git a/osu.Game.Rulesets.Mania/Beatmaps/ObjectRow.cs b/osu.Game.Rulesets.Mania/Beatmaps/ObjectRow.cs new file mode 100644 index 0000000000..fe51c16bed --- /dev/null +++ b/osu.Game.Rulesets.Mania/Beatmaps/ObjectRow.cs @@ -0,0 +1,44 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Rulesets.Mania.Objects; +using System.Collections.Generic; +using System.Linq; + +namespace osu.Game.Rulesets.Mania.Beatmaps +{ + internal class ObjectRow + { + private readonly List hitObjects = new List(); + public IEnumerable HitObjects => hitObjects; + + /// + /// Whether a column of this row has been taken. + /// + /// The column index. + /// Whether the column already contains a hit object. + public bool IsTaken(int column) => hitObjects.Exists(h => h.Column == column); + + /// + /// Amount of columns taken up by hit objects in this row. + /// + public int Columns => HitObjects.GroupBy(h => h.Column).Count(); + + /// + /// Adds a hit object to this row. + /// + /// The hit object to add. + public void Add(ManiaHitObject hitObject) => hitObjects.Add(hitObject); + + /// + /// Clears this row. + /// + public void Clear() => hitObjects.Clear(); + + /// + /// Removes a hit object from this row. + /// + /// The hit object to remove. + public bool Remove(ManiaHitObject hitObject) => hitObjects.Remove(hitObject); + } +} diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index 781dc3e228..36c17ccf04 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -47,8 +47,12 @@ + + + + From 41c252760d560bb1a567e0a0ff7814154ebd6c9c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 17 May 2017 21:57:01 +0900 Subject: [PATCH 265/329] Move all pause logic into PauseContainer --- .../Tests/TestCaseMenuOverlays.cs | 4 +- osu.Game/Screens/Play/KeyCounterCollection.cs | 11 +- osu.Game/Screens/Play/MenuOverlay.cs | 20 +- osu.Game/Screens/Play/Pause/PauseButton.cs | 19 -- .../Screens/Play/Pause/PauseProgressBar.cs | 149 ------------- .../Screens/Play/Pause/PauseProgressGraph.cs | 12 -- osu.Game/Screens/Play/PauseContainer.cs | 155 ++++++++++++++ osu.Game/Screens/Play/PauseOverlay.cs | 40 ---- osu.Game/Screens/Play/Player.cs | 195 ++++++------------ osu.Game/Screens/Play/SongProgress.cs | 2 + osu.Game/osu.Game.csproj | 5 +- 11 files changed, 242 insertions(+), 370 deletions(-) delete mode 100644 osu.Game/Screens/Play/Pause/PauseButton.cs delete mode 100644 osu.Game/Screens/Play/Pause/PauseProgressBar.cs delete mode 100644 osu.Game/Screens/Play/Pause/PauseProgressGraph.cs create mode 100644 osu.Game/Screens/Play/PauseContainer.cs delete mode 100644 osu.Game/Screens/Play/PauseOverlay.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseMenuOverlays.cs b/osu.Desktop.VisualTests/Tests/TestCaseMenuOverlays.cs index acf98ea86b..23fe8f16db 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseMenuOverlays.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseMenuOverlays.cs @@ -12,7 +12,7 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Tests pause and fail overlays"; - private PauseOverlay pauseOverlay; + private PauseContainer.PauseOverlay pauseOverlay; private FailOverlay failOverlay; private int retryCount; @@ -22,7 +22,7 @@ namespace osu.Desktop.VisualTests.Tests retryCount = 0; - Add(pauseOverlay = new PauseOverlay + Add(pauseOverlay = new PauseContainer.PauseOverlay { OnResume = () => Logger.Log(@"Resume"), OnRetry = () => Logger.Log(@"Retry"), diff --git a/osu.Game/Screens/Play/KeyCounterCollection.cs b/osu.Game/Screens/Play/KeyCounterCollection.cs index ef6e635c49..4a561e6036 100644 --- a/osu.Game/Screens/Play/KeyCounterCollection.cs +++ b/osu.Game/Screens/Play/KeyCounterCollection.cs @@ -41,12 +41,11 @@ namespace osu.Game.Screens.Play get { return isCounting; } set { - if (value != isCounting) - { - isCounting = value; - foreach (var child in Children) - child.IsCounting = value; - } + if (value == isCounting) return; + + isCounting = value; + foreach (var child in Children) + child.IsCounting = value; } } diff --git a/osu.Game/Screens/Play/MenuOverlay.cs b/osu.Game/Screens/Play/MenuOverlay.cs index fa522956f7..424b26350f 100644 --- a/osu.Game/Screens/Play/MenuOverlay.cs +++ b/osu.Game/Screens/Play/MenuOverlay.cs @@ -8,11 +8,11 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Input; using osu.Game.Graphics.Sprites; -using osu.Game.Screens.Play.Pause; using OpenTK; using OpenTK.Graphics; using osu.Game.Graphics; using osu.Framework.Allocation; +using osu.Framework.Audio; using osu.Game.Graphics.UserInterface; namespace osu.Game.Screens.Play @@ -89,7 +89,7 @@ namespace osu.Game.Screens.Play protected void AddButton(string text, Color4 colour, Action action) { - Buttons.Add(new PauseButton + Buttons.Add(new Button { Text = text, ButtonColour = colour, @@ -179,12 +179,6 @@ namespace osu.Game.Screens.Play } } }, - new PauseProgressBar - { - Origin = Anchor.BottomCentre, - Anchor = Anchor.BottomCentre, - Width = 1f - } }; Retries = 0; @@ -195,5 +189,15 @@ namespace osu.Game.Screens.Play AlwaysReceiveInput = true; RelativeSizeAxes = Axes.Both; } + + public class Button : DialogButton + { + [BackgroundDependencyLoader] + private void load(AudioManager audio) + { + SampleHover = audio.Sample.Get(@"Menu/menuclick"); + SampleClick = audio.Sample.Get(@"Menu/menuback"); + } + } } } diff --git a/osu.Game/Screens/Play/Pause/PauseButton.cs b/osu.Game/Screens/Play/Pause/PauseButton.cs deleted file mode 100644 index 7698913ea5..0000000000 --- a/osu.Game/Screens/Play/Pause/PauseButton.cs +++ /dev/null @@ -1,19 +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.Allocation; -using osu.Framework.Audio; -using osu.Game.Graphics.UserInterface; - -namespace osu.Game.Screens.Play.Pause -{ - public class PauseButton : DialogButton - { - [BackgroundDependencyLoader] - private void load(AudioManager audio) - { - SampleHover = audio.Sample.Get(@"Menu/menuclick"); - SampleClick = audio.Sample.Get(@"Menu/menuback"); - } - } -} diff --git a/osu.Game/Screens/Play/Pause/PauseProgressBar.cs b/osu.Game/Screens/Play/Pause/PauseProgressBar.cs deleted file mode 100644 index bfde7dd6d7..0000000000 --- a/osu.Game/Screens/Play/Pause/PauseProgressBar.cs +++ /dev/null @@ -1,149 +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.Allocation; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; -using osu.Game.Beatmaps; -using OpenTK.Graphics; - -namespace osu.Game.Screens.Play.Pause -{ - public class PauseProgressBar : Container - { - private readonly Color4 fillColour = new Color4(221, 255, 255, 255); - private readonly Color4 glowColour = new Color4(221, 255, 255, 150); - - private readonly Container fill; - private WorkingBeatmap current; - - [BackgroundDependencyLoader] - private void load(OsuGameBase osuGame) - { - current = osuGame.Beatmap.Value; - } - - protected override void Update() - { - base.Update(); - - if (current?.TrackLoaded ?? false) - { - fill.Width = (float)(current.Track.CurrentTime / current.Track.Length); - } - } - - public PauseProgressBar() - { - RelativeSizeAxes = Axes.X; - Height = 60; - - Children = new Drawable[] - { - new PauseProgressGraph - { - RelativeSizeAxes = Axes.X, - Origin = Anchor.BottomCentre, - Anchor = Anchor.BottomCentre, - Height = 35, - Margin = new MarginPadding - { - Bottom = 5 - } - }, - new Container - { - Origin = Anchor.BottomRight, - Anchor = Anchor.BottomRight, - RelativeSizeAxes = Axes.X, - Height = 5, - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black, - Alpha = 0.5f - } - } - }, - fill = new Container - { - RelativeSizeAxes = Axes.X, - Origin = Anchor.BottomLeft, - Anchor = Anchor.BottomLeft, - Width = 0, - Height = 60, - Children = new Drawable[] - { - new Container - { - RelativeSizeAxes = Axes.Both, - Origin = Anchor.BottomLeft, - Anchor = Anchor.BottomLeft, - Masking = true, - Children = new Drawable[] - { - new Container - { - Origin = Anchor.BottomLeft, - Anchor = Anchor.BottomLeft, - RelativeSizeAxes = Axes.X, - Height = 5, - Masking = true, - EdgeEffect = new EdgeEffect - { - Type = EdgeEffectType.Glow, - Colour = glowColour, - Radius = 5 - }, - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = fillColour - } - } - } - } - }, - new Container - { - Origin = Anchor.BottomRight, - Anchor = Anchor.BottomRight, - Width = 2, - Height = 35, - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.White - }, - new Container - { - Origin = Anchor.BottomCentre, - Anchor = Anchor.TopCentre, - Width = 14, - Height = 25, - CornerRadius = 5, - Masking = true, - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.White - } - } - } - } - } - } - } - }; - } - } -} diff --git a/osu.Game/Screens/Play/Pause/PauseProgressGraph.cs b/osu.Game/Screens/Play/Pause/PauseProgressGraph.cs deleted file mode 100644 index 89b9b42b86..0000000000 --- a/osu.Game/Screens/Play/Pause/PauseProgressGraph.cs +++ /dev/null @@ -1,12 +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; - -namespace osu.Game.Screens.Play.Pause -{ - public class PauseProgressGraph : Container - { - // TODO: Implement the pause progress graph - } -} diff --git a/osu.Game/Screens/Play/PauseContainer.cs b/osu.Game/Screens/Play/PauseContainer.cs new file mode 100644 index 0000000000..1de62048b7 --- /dev/null +++ b/osu.Game/Screens/Play/PauseContainer.cs @@ -0,0 +1,155 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Linq; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Input; +using osu.Framework.Timing; +using osu.Game.Graphics; +using OpenTK.Graphics; +using OpenTK.Input; + +namespace osu.Game.Screens.Play +{ + /// + /// A container which handles pausing children, displaying a pause overlay with choices etc. + /// This alleviates a lot of the intricate pause logic from being in + /// + public class PauseContainer : Container + { + public bool IsPaused { get; private set; } + + public bool AllowExit => IsPaused && pauseOverlay.Alpha == 1; + + public Func CheckCanPause; + + private const double pause_cooldown = 1000; + private double lastPauseActionTime; + + private readonly PauseOverlay pauseOverlay; + + private readonly Container content; + + protected override Container Content => content; + + public int Retries { set { pauseOverlay.Retries = value; } } + + public bool CanPause => (CheckCanPause?.Invoke() ?? true) && Time.Current >= lastPauseActionTime + pause_cooldown; + + public Action OnRetry; + public Action OnQuit; + + public Action OnResume; + public Action OnPause; + + public IAdjustableClock AudioClock; + public FramedClock FramedClock; + + public PauseContainer() + { + RelativeSizeAxes = Axes.Both; + + AddInternal(content = new Container { RelativeSizeAxes = Axes.Both }); + + AddInternal(pauseOverlay = new PauseOverlay + { + OnResume = delegate + { + Delay(400); + Schedule(Resume); + }, + OnRetry = () => OnRetry(), + OnQuit = () => OnQuit(), + }); + } + + public void Pause(bool force = false) + { + if (!CanPause && !force) return; + + if (IsPaused) return; + + // stop the decoupled clock (stops the audio eventually) + AudioClock.Stop(); + + // stop processing updatess on the offset clock (instantly freezes time for all our components) + FramedClock.ProcessSourceClockFrames = false; + + IsPaused = true; + + // we need to do a final check after all of our children have processed up to the paused clock time. + // this is to cover cases where, for instance, the player fails in the current processing frame. + Schedule(() => + { + if (!CanPause) return; + + lastPauseActionTime = Time.Current; + + OnPause?.Invoke(); + pauseOverlay.Show(); + }); + } + + public void Resume() + { + if (!IsPaused) return; + + IsPaused = false; + FramedClock.ProcessSourceClockFrames = true; + + lastPauseActionTime = Time.Current; + + OnResume?.Invoke(); + + pauseOverlay.Hide(); + AudioClock.Start(); + } + + private OsuGameBase game; + + [BackgroundDependencyLoader] + private void load(OsuGameBase game) + { + this.game = game; + } + + protected override void Update() + { + // eagerly pause when we lose window focus (if we are locally playing). + if (!game.IsActive && CanPause) + Pause(); + + base.Update(); + } + + public class PauseOverlay : MenuOverlay + { + public Action OnResume; + + public override string Header => "paused"; + public override string Description => "you're not going to do what i think you're going to do, are ya?"; + + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + if (!args.Repeat && args.Key == Key.Escape) + { + Buttons.Children.First().TriggerClick(); + return true; + } + + return base.OnKeyDown(state, args); + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + AddButton("Continue", colours.Green, OnResume); + AddButton("Retry", colours.YellowDark, OnRetry); + AddButton("Quit", new Color4(170, 27, 39, 255), OnQuit); + } + } + } +} diff --git a/osu.Game/Screens/Play/PauseOverlay.cs b/osu.Game/Screens/Play/PauseOverlay.cs deleted file mode 100644 index 9561979751..0000000000 --- a/osu.Game/Screens/Play/PauseOverlay.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using System; -using System.Linq; -using osu.Framework.Input; -using osu.Game.Graphics; -using OpenTK.Input; -using OpenTK.Graphics; -using osu.Framework.Allocation; - -namespace osu.Game.Screens.Play -{ - public class PauseOverlay : MenuOverlay - { - public Action OnResume; - - public override string Header => "paused"; - public override string Description => "you're not going to do what i think you're going to do, are ya?"; - - protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) - { - if (!args.Repeat && args.Key == Key.Escape) - { - Buttons.Children.First().TriggerClick(); - return true; - } - - return base.OnKeyDown(state, args); - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - AddButton("Continue", colours.Green, OnResume); - AddButton("Retry", colours.YellowDark, OnRetry); - AddButton("Quit", new Color4(170, 27, 39, 255), OnQuit); - } - } -} diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 68fbbaddcc..d9585b8c04 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -32,29 +32,24 @@ namespace osu.Game.Screens.Play internal override bool ShowOverlays => false; - internal override bool HasLocalCursorDisplayed => !IsPaused && !HasFailed && HitRenderer.ProvidingUserCursor; + internal override bool HasLocalCursorDisplayed => !pauseContainer.IsPaused && !HasFailed && HitRenderer.ProvidingUserCursor; public BeatmapInfo BeatmapInfo; public Action RestartRequested; - public bool IsPaused { get; private set; } - internal override bool AllowRulesetChange => false; public bool HasFailed { get; private set; } public int RestartCount; - private const double pause_cooldown = 1000; - private double lastPauseActionTime; - - private bool canPause => ValidForResume && !HasFailed && Time.Current >= lastPauseActionTime + pause_cooldown; - private IAdjustableClock adjustableSourceClock; private FramedOffsetClock offsetClock; private DecoupleableInterpolatingFramedClock decoupledClock; + private PauseContainer pauseContainer; + private RulesetInfo ruleset; private ScoreProcessor scoreProcessor; @@ -70,10 +65,7 @@ namespace osu.Game.Screens.Play private SkipButton skipButton; - private Container hitRendererContainer; - private HUDOverlay hudOverlay; - private PauseOverlay pauseOverlay; private FailOverlay failOverlay; [BackgroundDependencyLoader(permitNulls: true)] @@ -152,14 +144,63 @@ namespace osu.Game.Screens.Play decoupledClock.ChangeSource(adjustableSourceClock); }); - scoreProcessor = HitRenderer.CreateScoreProcessor(); - - hudOverlay = new StandardHUDOverlay() + Children = new Drawable[] { - Anchor = Anchor.Centre, - Origin = Anchor.Centre + pauseContainer = new PauseContainer + { + AudioClock = decoupledClock, + FramedClock = offsetClock, + OnRetry = Restart, + OnQuit = Exit, + CheckCanPause = () => ValidForResume && !HasFailed, + Retries = RestartCount, + OnPause = () => { + hudOverlay.KeyCounter.IsCounting = pauseContainer.IsPaused; + }, + OnResume = () => { + hudOverlay.KeyCounter.IsCounting = true; + }, + Children = new Drawable[] + { + new Container + { + RelativeSizeAxes = Axes.Both, + Clock = offsetClock, + Children = new Drawable[] + { + HitRenderer, + skipButton = new SkipButton + { + Alpha = 0, + Margin = new MarginPadding { Bottom = 140 } // this is temporary + }, + } + }, + hudOverlay = new StandardHUDOverlay + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre + }, + } + }, + failOverlay = new FailOverlay + { + OnRetry = Restart, + OnQuit = Exit, + }, + new HotkeyRetryOverlay + { + Action = () => { + //we want to hide the hitrenderer immediately (looks better). + //we may be able to remove this once the mouse cursor trail is improved. + HitRenderer?.Hide(); + Restart(); + }, + } }; + scoreProcessor = HitRenderer.CreateScoreProcessor(); + hudOverlay.KeyCounter.Add(rulesetInstance.CreateGameplayKeys()); hudOverlay.BindProcessor(scoreProcessor); hudOverlay.BindHitRenderer(HitRenderer); @@ -176,61 +217,6 @@ namespace osu.Game.Screens.Play //bind ScoreProcessor to ourselves (for a fail situation) scoreProcessor.Failed += onFail; - - Children = new Drawable[] - { - hitRendererContainer = new Container - { - RelativeSizeAxes = Axes.Both, - Children = new Drawable[] - { - new Container - { - RelativeSizeAxes = Axes.Both, - Clock = offsetClock, - Children = new Drawable[] - { - HitRenderer, - skipButton = new SkipButton { Alpha = 0 }, - } - }, - } - }, - hudOverlay, - pauseOverlay = new PauseOverlay - { - OnResume = delegate - { - Delay(400); - Schedule(Resume); - }, - OnRetry = Restart, - OnQuit = Exit, - }, - failOverlay = new FailOverlay - { - OnRetry = Restart, - OnQuit = Exit, - }, - new HotkeyRetryOverlay - { - Action = () => { - //we want to hide the hitrenderer immediately (looks better). - //we may be able to remove this once the mouse cursor trail is improved. - HitRenderer?.Hide(); - Restart(); - }, - } - }; - } - - protected override void Update() - { - // eagerly pause when we lose window focus (if we are locally playing). - if (!Game.IsActive && !HitRenderer.HasReplayLoaded) - Pause(); - - base.Update(); } private void initializeSkipButton() @@ -260,48 +246,6 @@ namespace osu.Game.Screens.Play skipButton.Expire(); } - public void Pause(bool force = false) - { - if (!canPause && !force) return; - - if (IsPaused) return; - - // stop the decoupled clock (stops the audio eventually) - decoupledClock.Stop(); - - // stop processing updatess on the offset clock (instantly freezes time for all our components) - offsetClock.ProcessSourceClockFrames = false; - - IsPaused = true; - - // we need to do a final check after all of our children have processed up to the paused clock time. - // this is to cover cases where, for instance, the player fails in the current processing frame. - Schedule(() => - { - if (!canPause) return; - - lastPauseActionTime = Time.Current; - hudOverlay.KeyCounter.IsCounting = false; - hudOverlay.Progress.Show(); - pauseOverlay.Retries = RestartCount; - pauseOverlay.Show(); - }); - } - - public void Resume() - { - if (!IsPaused) return; - - IsPaused = false; - offsetClock.ProcessSourceClockFrames = true; - - lastPauseActionTime = Time.Current; - hudOverlay.KeyCounter.IsCounting = true; - hudOverlay.Progress.Hide(); - pauseOverlay.Hide(); - decoupledClock.Start(); - } - public void Restart() { ValidForResume = false; @@ -367,8 +311,8 @@ namespace osu.Game.Screens.Play initializeSkipButton(); }); - hitRendererContainer.Alpha = 0; - hitRendererContainer.FadeIn(750, EasingTypes.OutQuint); + pauseContainer.Alpha = 0; + pauseContainer.FadeIn(750, EasingTypes.OutQuint); } protected override void OnSuspending(Screen next) @@ -379,23 +323,14 @@ namespace osu.Game.Screens.Play protected override bool OnExiting(Screen next) { - if (!HasFailed && ValidForResume) + if (HasFailed || !ValidForResume || pauseContainer.AllowExit || HitRenderer.HasReplayLoaded) { - if (pauseOverlay != null && !HitRenderer.HasReplayLoaded) - { - //pause screen override logic. - if (pauseOverlay?.State == Visibility.Hidden && !canPause) return true; - - if (!IsPaused) // For if the user presses escape quickly when entering the map - { - Pause(); - return true; - } - } + fadeOut(); + return base.OnExiting(next); } - fadeOut(); - return base.OnExiting(next); + pauseContainer.Pause(); + return true; } private void fadeOut() @@ -410,6 +345,6 @@ namespace osu.Game.Screens.Play Background?.FadeTo(1f, fade_out_duration); } - protected override bool OnWheel(InputState state) => mouseWheelDisabled.Value && !IsPaused; + protected override bool OnWheel(InputState state) => mouseWheelDisabled.Value && !pauseContainer.IsPaused; } } diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 887442b8c0..6b3f81628c 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -31,6 +31,8 @@ namespace osu.Game.Screens.Play public Action OnSeek; + public override bool HandleInput => AllowSeeking; + private IClock audioClock; public IClock AudioClock { set { audioClock = info.AudioClock = value; } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 63acdb1914..6cd32d7fea 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -231,6 +231,7 @@ + @@ -254,8 +255,6 @@ - - @@ -395,8 +394,6 @@ - - From d606b5b3a73a70c51d8f89c06bebe2d753f85a6e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 17 May 2017 22:13:56 +0900 Subject: [PATCH 266/329] Fix CI warning --- osu.Game/Overlays/ChatOverlay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index cbcfbbfd9e..2836be22ae 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -206,7 +206,7 @@ namespace osu.Game.Overlays private long? lastMessageId; - private List careChannels = new List(); + private readonly List careChannels = new List(); private readonly List loadedChannels = new List(); From d1f85c3f8e6dc4982a731b51073b2b948fdafa35 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 17 May 2017 23:21:23 +0900 Subject: [PATCH 267/329] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 67f3958036..f8e5b10f68 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 67f39580365f7d0a42f8788eae2b60881dde1c67 +Subproject commit f8e5b10f6883af83ffbc431b03fe4ee3e89797a6 From 817bae3219871b7541569984522c11cb8425ed20 Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Thu, 18 May 2017 01:54:17 +0200 Subject: [PATCH 268/329] Fixes the auto mod not hitting stacks of notes on certain maps. --- osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs b/osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs index f8365bf9ab..db99ddf0d4 100644 --- a/osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs +++ b/osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs @@ -92,24 +92,24 @@ namespace osu.Game.Rulesets.Osu.Replays if (h.StartTime - h.HitWindowFor(OsuScoreResult.Miss) > endTime + h.HitWindowFor(OsuScoreResult.Hit50) + 50) { if (!(prev is Spinner) && h.StartTime - endTime < 1000) AddFrameToReplay(new ReplayFrame(endTime + h.HitWindowFor(OsuScoreResult.Hit50), prev.EndPosition.X, prev.EndPosition.Y, ReplayButtonState.None)); - if (!(h is Spinner)) AddFrameToReplay(new ReplayFrame(h.StartTime - h.HitWindowFor(OsuScoreResult.Miss), h.Position.X, h.Position.Y, ReplayButtonState.None)); + if (!(h is Spinner)) AddFrameToReplay(new ReplayFrame(h.StartTime - h.HitWindowFor(OsuScoreResult.Miss), h.StackedPosition.X, h.StackedPosition.Y, ReplayButtonState.None)); } else if (h.StartTime - h.HitWindowFor(OsuScoreResult.Hit50) > endTime + h.HitWindowFor(OsuScoreResult.Hit50) + 50) { if (!(prev is Spinner) && h.StartTime - endTime < 1000) AddFrameToReplay(new ReplayFrame(endTime + h.HitWindowFor(OsuScoreResult.Hit50), prev.EndPosition.X, prev.EndPosition.Y, ReplayButtonState.None)); - if (!(h is Spinner)) AddFrameToReplay(new ReplayFrame(h.StartTime - h.HitWindowFor(OsuScoreResult.Hit50), h.Position.X, h.Position.Y, ReplayButtonState.None)); + if (!(h is Spinner)) AddFrameToReplay(new ReplayFrame(h.StartTime - h.HitWindowFor(OsuScoreResult.Hit50), h.StackedPosition.X, h.StackedPosition.Y, ReplayButtonState.None)); } else if (h.StartTime - h.HitWindowFor(OsuScoreResult.Hit100) > endTime + h.HitWindowFor(OsuScoreResult.Hit100) + 50) { if (!(prev is Spinner) && h.StartTime - endTime < 1000) AddFrameToReplay(new ReplayFrame(endTime + h.HitWindowFor(OsuScoreResult.Hit100), prev.EndPosition.X, prev.EndPosition.Y, ReplayButtonState.None)); - if (!(h is Spinner)) AddFrameToReplay(new ReplayFrame(h.StartTime - h.HitWindowFor(OsuScoreResult.Hit100), h.Position.X, h.Position.Y, ReplayButtonState.None)); + if (!(h is Spinner)) AddFrameToReplay(new ReplayFrame(h.StartTime - h.HitWindowFor(OsuScoreResult.Hit100), h.StackedPosition.X, h.StackedPosition.Y, ReplayButtonState.None)); } } private void addHitObjectReplay(OsuHitObject h) { // Default values for circles/sliders - Vector2 startPosition = h.Position; + Vector2 startPosition = h.StackedPosition; EasingTypes easing = preferredEasing; float spinnerDirection = -1; @@ -238,7 +238,7 @@ namespace osu.Game.Rulesets.Osu.Replays // TODO: Why do we delay 1 ms if the object is a spinner? There already is KEY_UP_DELAY from hEndTime. double hEndTime = ((h as IHasEndTime)?.EndTime ?? h.StartTime) + KEY_UP_DELAY; int endDelay = h is Spinner ? 1 : 0; - ReplayFrame endFrame = new ReplayFrame(hEndTime + endDelay, h.EndPosition.X, h.EndPosition.Y, ReplayButtonState.None); + ReplayFrame endFrame = new ReplayFrame(hEndTime + endDelay, h.StackedEndPosition.X, h.StackedEndPosition.Y, ReplayButtonState.None); // Decrement because we want the previous frame, not the next one int index = FindInsertionIndex(startFrame) - 1; From 91859042e8f5f167291b1ade81f3a0a07128d97f Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Thu, 18 May 2017 02:15:16 +0200 Subject: [PATCH 269/329] Fix not all cases of the auto replay generator fix being covered. --- osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs b/osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs index db99ddf0d4..22246af5fd 100644 --- a/osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs +++ b/osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs @@ -91,17 +91,17 @@ namespace osu.Game.Rulesets.Osu.Replays // Make the cursor stay at a hitObject as long as possible (mainly for autopilot). if (h.StartTime - h.HitWindowFor(OsuScoreResult.Miss) > endTime + h.HitWindowFor(OsuScoreResult.Hit50) + 50) { - if (!(prev is Spinner) && h.StartTime - endTime < 1000) AddFrameToReplay(new ReplayFrame(endTime + h.HitWindowFor(OsuScoreResult.Hit50), prev.EndPosition.X, prev.EndPosition.Y, ReplayButtonState.None)); + if (!(prev is Spinner) && h.StartTime - endTime < 1000) AddFrameToReplay(new ReplayFrame(endTime + h.HitWindowFor(OsuScoreResult.Hit50), prev.StackedPosition.X, prev.StackedPosition.Y, ReplayButtonState.None)); if (!(h is Spinner)) AddFrameToReplay(new ReplayFrame(h.StartTime - h.HitWindowFor(OsuScoreResult.Miss), h.StackedPosition.X, h.StackedPosition.Y, ReplayButtonState.None)); } else if (h.StartTime - h.HitWindowFor(OsuScoreResult.Hit50) > endTime + h.HitWindowFor(OsuScoreResult.Hit50) + 50) { - if (!(prev is Spinner) && h.StartTime - endTime < 1000) AddFrameToReplay(new ReplayFrame(endTime + h.HitWindowFor(OsuScoreResult.Hit50), prev.EndPosition.X, prev.EndPosition.Y, ReplayButtonState.None)); + if (!(prev is Spinner) && h.StartTime - endTime < 1000) AddFrameToReplay(new ReplayFrame(endTime + h.HitWindowFor(OsuScoreResult.Hit50), prev.StackedPosition.X, prev.StackedPosition.Y, ReplayButtonState.None)); if (!(h is Spinner)) AddFrameToReplay(new ReplayFrame(h.StartTime - h.HitWindowFor(OsuScoreResult.Hit50), h.StackedPosition.X, h.StackedPosition.Y, ReplayButtonState.None)); } else if (h.StartTime - h.HitWindowFor(OsuScoreResult.Hit100) > endTime + h.HitWindowFor(OsuScoreResult.Hit100) + 50) { - if (!(prev is Spinner) && h.StartTime - endTime < 1000) AddFrameToReplay(new ReplayFrame(endTime + h.HitWindowFor(OsuScoreResult.Hit100), prev.EndPosition.X, prev.EndPosition.Y, ReplayButtonState.None)); + if (!(prev is Spinner) && h.StartTime - endTime < 1000) AddFrameToReplay(new ReplayFrame(endTime + h.HitWindowFor(OsuScoreResult.Hit100), prev.StackedPosition.X, prev.StackedPosition.Y, ReplayButtonState.None)); if (!(h is Spinner)) AddFrameToReplay(new ReplayFrame(h.StartTime - h.HitWindowFor(OsuScoreResult.Hit100), h.StackedPosition.X, h.StackedPosition.Y, ReplayButtonState.None)); } } From 58ebb24032350bf2ef79aef08ae9a5dd44833efc Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Thu, 18 May 2017 02:17:49 +0200 Subject: [PATCH 270/329] Use the end position of a previous note stack rather than the start position. --- osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs b/osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs index 22246af5fd..5ede3f56f5 100644 --- a/osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs +++ b/osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs @@ -91,17 +91,17 @@ namespace osu.Game.Rulesets.Osu.Replays // Make the cursor stay at a hitObject as long as possible (mainly for autopilot). if (h.StartTime - h.HitWindowFor(OsuScoreResult.Miss) > endTime + h.HitWindowFor(OsuScoreResult.Hit50) + 50) { - if (!(prev is Spinner) && h.StartTime - endTime < 1000) AddFrameToReplay(new ReplayFrame(endTime + h.HitWindowFor(OsuScoreResult.Hit50), prev.StackedPosition.X, prev.StackedPosition.Y, ReplayButtonState.None)); + if (!(prev is Spinner) && h.StartTime - endTime < 1000) AddFrameToReplay(new ReplayFrame(endTime + h.HitWindowFor(OsuScoreResult.Hit50), prev.StackedEndPosition.X, prev.StackedEndPosition.Y, ReplayButtonState.None)); if (!(h is Spinner)) AddFrameToReplay(new ReplayFrame(h.StartTime - h.HitWindowFor(OsuScoreResult.Miss), h.StackedPosition.X, h.StackedPosition.Y, ReplayButtonState.None)); } else if (h.StartTime - h.HitWindowFor(OsuScoreResult.Hit50) > endTime + h.HitWindowFor(OsuScoreResult.Hit50) + 50) { - if (!(prev is Spinner) && h.StartTime - endTime < 1000) AddFrameToReplay(new ReplayFrame(endTime + h.HitWindowFor(OsuScoreResult.Hit50), prev.StackedPosition.X, prev.StackedPosition.Y, ReplayButtonState.None)); + if (!(prev is Spinner) && h.StartTime - endTime < 1000) AddFrameToReplay(new ReplayFrame(endTime + h.HitWindowFor(OsuScoreResult.Hit50), prev.StackedEndPosition.X, prev.StackedEndPosition.Y, ReplayButtonState.None)); if (!(h is Spinner)) AddFrameToReplay(new ReplayFrame(h.StartTime - h.HitWindowFor(OsuScoreResult.Hit50), h.StackedPosition.X, h.StackedPosition.Y, ReplayButtonState.None)); } else if (h.StartTime - h.HitWindowFor(OsuScoreResult.Hit100) > endTime + h.HitWindowFor(OsuScoreResult.Hit100) + 50) { - if (!(prev is Spinner) && h.StartTime - endTime < 1000) AddFrameToReplay(new ReplayFrame(endTime + h.HitWindowFor(OsuScoreResult.Hit100), prev.StackedPosition.X, prev.StackedPosition.Y, ReplayButtonState.None)); + if (!(prev is Spinner) && h.StartTime - endTime < 1000) AddFrameToReplay(new ReplayFrame(endTime + h.HitWindowFor(OsuScoreResult.Hit100), prev.StackedEndPosition.X, prev.StackedEndPosition.Y, ReplayButtonState.None)); if (!(h is Spinner)) AddFrameToReplay(new ReplayFrame(h.StartTime - h.HitWindowFor(OsuScoreResult.Hit100), h.StackedPosition.X, h.StackedPosition.Y, ReplayButtonState.None)); } } From 22128f158cfb774aa284616ed2849f111ccae4c1 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 18 May 2017 12:10:01 +0900 Subject: [PATCH 271/329] Fix a few errors. --- osu.Game.Rulesets.Mania/Beatmaps/DistanceObjectConversion.cs | 2 ++ osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/DistanceObjectConversion.cs b/osu.Game.Rulesets.Mania/Beatmaps/DistanceObjectConversion.cs index c775c189e1..5df4279cca 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/DistanceObjectConversion.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/DistanceObjectConversion.cs @@ -339,6 +339,8 @@ namespace osu.Game.Rulesets.Mania.Beatmaps add(newRow, holdColumn, startTime, separationTime * repeatCount); // Todo: Complete + + return newRow; } private void add(ObjectRow row, int column, double startTime, double endTime, int siblings = 1) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs index ebc6ed2dcf..7c8e58862b 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs @@ -32,7 +32,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps private readonly Beatmap beatmap; - public LegacyConverter(ObjectRow previousrow, Beatmap beatmap) + public LegacyConverter(Beatmap beatmap) { this.beatmap = beatmap; @@ -118,7 +118,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps if (conversion == null) yield break; - foreach (ManiaHitObject obj in conversion.GenerateConversion()) + foreach (ManiaHitObject obj in conversion.GenerateConversion().HitObjects) yield return obj; } From e9275138e1b0312cdc9e5a306ec52eb86807cad3 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 18 May 2017 12:39:37 +0900 Subject: [PATCH 272/329] Finish up DistanceObjectConversion. --- .../Beatmaps/DistanceObjectConversion.cs | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/DistanceObjectConversion.cs b/osu.Game.Rulesets.Mania/Beatmaps/DistanceObjectConversion.cs index 5df4279cca..6bc7c8c45c 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/DistanceObjectConversion.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/DistanceObjectConversion.cs @@ -338,7 +338,37 @@ namespace osu.Game.Rulesets.Mania.Beatmaps // Create the hold note add(newRow, holdColumn, startTime, separationTime * repeatCount); - // Todo: Complete + int noteCount = 0; + if (conversionDifficulty > 6.5) + noteCount = GetRandomNoteCount(0.63, 0); + else if (conversionDifficulty > 4) + noteCount = GetRandomNoteCount(AvailableColumns < 6 ? 0.12 : 0.45, 0); + else if (conversionDifficulty > 2.5) + noteCount = GetRandomNoteCount(AvailableColumns < 6 ? 0 : 0.24, 0); + noteCount = Math.Min(AvailableColumns - 1, noteCount); + + bool ignoreHead = !sampleInfoListAt(startTime, separationTime).Any(s => s.Name == SampleInfo.HIT_WHISTLE || s.Name == SampleInfo.HIT_FINISH || s.Name == SampleInfo.HIT_CLAP); + int nextColumn = Random.Next(RandomStart, AvailableColumns); + + var tempRow = new ObjectRow(); + for (int i = 0; i <= repeatCount; i++) + { + if (!(ignoreHead && startTime == originalObject.StartTime)) + { + for (int j = 0; j < noteCount; j++) + { + while (tempRow.IsTaken(nextColumn) || nextColumn == holdColumn) + nextColumn = Random.Next(RandomStart, AvailableColumns); + add(tempRow, nextColumn, startTime, startTime, noteCount + 1); + } + } + + foreach (ManiaHitObject obj in tempRow.HitObjects) + newRow.Add(obj); + + tempRow.Clear(); + startTime += separationTime; + } return newRow; } From f6dc85c2f8334d8ab1ab368d4a3d6dcdb6f9c038 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 18 May 2017 12:39:51 +0900 Subject: [PATCH 273/329] Fix incorrect note count probabilities. --- osu.Game.Rulesets.Mania/Beatmaps/ObjectConversion.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/ObjectConversion.cs b/osu.Game.Rulesets.Mania/Beatmaps/ObjectConversion.cs index 9dee1116e0..bee7477261 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/ObjectConversion.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/ObjectConversion.cs @@ -60,7 +60,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps /// Probability for 5 notes to be generated. /// Probability for 6 notes to be generated. /// The amount of notes to be generated. - protected int GetRandomNoteCount(double p2, double p3, double p4 = 1, double p5 = 1, double p6 = 1) + protected int GetRandomNoteCount(double p2, double p3, double p4 = 0, double p5 = 0, double p6 = 0) { double val = Random.NextDouble(); if (val >= 1 - p6) From 16eda2467fc87a563b06f2e6552569968f878063 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 18 May 2017 12:50:12 +0900 Subject: [PATCH 274/329] Make compile. --- osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs index 7c8e58862b..18dea8ebc3 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs @@ -27,6 +27,8 @@ namespace osu.Game.Rulesets.Mania.Beatmaps private readonly double lastNoteTime; private readonly float lastNotePosition; + private ObjectRow lastRow = new ObjectRow(); + private readonly int availableColumns; private readonly float localXDivisor; @@ -105,7 +107,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps ObjectConversion conversion = null; if (distanceData != null) - conversion = new DistanceObjectConversion(distanceData, beatmap); + conversion = new DistanceObjectConversion(original, lastRow, random, beatmap); else if (endTimeData != null) { // Spinner @@ -118,8 +120,12 @@ namespace osu.Game.Rulesets.Mania.Beatmaps if (conversion == null) yield break; - foreach (ManiaHitObject obj in conversion.GenerateConversion().HitObjects) + ObjectRow newRow = conversion.GenerateConversion(); + + foreach (ManiaHitObject obj in newRow.HitObjects) yield return obj; + + lastRow = newRow; } private int getColumn(float position) => MathHelper.Clamp((int)Math.Floor(position / localXDivisor), 0, availableColumns - 1); From c1a44ea6b4f1d2452ad293d908cf97698b55a2b3 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 18 May 2017 13:21:54 +0900 Subject: [PATCH 275/329] Renaming + commenting. --- .../Beatmaps/DistanceObjectConversion.cs | 238 ++++++++++++------ .../Beatmaps/LegacyConverter.cs | 4 +- .../Beatmaps/ObjectConversion.cs | 12 +- .../Beatmaps/{ObjectRow.cs => ObjectList.cs} | 30 ++- .../osu.Game.Rulesets.Mania.csproj | 2 +- 5 files changed, 189 insertions(+), 97 deletions(-) rename osu.Game.Rulesets.Mania/Beatmaps/{ObjectRow.cs => ObjectList.cs} (56%) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/DistanceObjectConversion.cs b/osu.Game.Rulesets.Mania/Beatmaps/DistanceObjectConversion.cs index 6bc7c8c45c..52c5cf16da 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/DistanceObjectConversion.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/DistanceObjectConversion.cs @@ -12,7 +12,6 @@ using System.Linq; using OpenTK; using osu.Game.Database; using osu.Game.Audio; -using System.Collections.Generic; namespace osu.Game.Rulesets.Mania.Beatmaps { @@ -25,8 +24,8 @@ namespace osu.Game.Rulesets.Mania.Beatmaps private LegacyConvertType convertType; - public DistanceObjectConversion(HitObject originalObject, ObjectRow previousRow, FastRandom random, Beatmap beatmap) - : base(previousRow, random, beatmap) + public DistanceObjectConversion(HitObject originalObject, ObjectList previousObjects, FastRandom random, Beatmap beatmap) + : base(previousObjects, random, beatmap) { this.originalObject = originalObject; @@ -44,7 +43,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps repeatCount = repeatsData?.RepeatCount ?? 1; } - public override ObjectRow GenerateConversion() + public override ObjectList Generate() { double segmentDuration = endTime / repeatCount; @@ -56,113 +55,125 @@ namespace osu.Game.Rulesets.Mania.Beatmaps if (segmentDuration <= 120) { convertType |= LegacyConvertType.ForceNotStack; - return addRandomNotes(originalObject.StartTime, segmentDuration, repeatCount); + return generateRandomNotes(originalObject.StartTime, segmentDuration, repeatCount); } if (segmentDuration <= 160) - return addStair(originalObject.StartTime, segmentDuration, repeatCount); + return generateStair(originalObject.StartTime, segmentDuration, repeatCount); if (segmentDuration <= 200 && conversionDifficulty > 3) - return addMultipleNotes(originalObject.StartTime, segmentDuration, repeatCount); + return generateRandomMultipleNotes(originalObject.StartTime, segmentDuration, repeatCount); double duration = endTime - originalObject.StartTime; if (duration >= 4000) - return addNRandomNotes(originalObject.StartTime, endTime, 0.23, 0, 0); + return generateNRandomNotes(originalObject.StartTime, endTime, 0.23, 0, 0); if (segmentDuration > 400 && duration < 4000 && repeatCount < AvailableColumns - 1 - RandomStart) return generateTiledHoldNotes(originalObject.StartTime, segmentDuration, repeatCount); - return generateLongAndNormalNotes(originalObject.StartTime, segmentDuration); + return generateHoldAndNormalNotes(originalObject.StartTime, segmentDuration); } if (segmentDuration <= 110) { - if (PreviousRow.Columns < AvailableColumns) + if (PreviousObjects.ColumnsFilled < AvailableColumns) convertType |= LegacyConvertType.ForceNotStack; else convertType &= ~LegacyConvertType.ForceNotStack; - return addRandomNotes(originalObject.StartTime, segmentDuration, segmentDuration < 80 ? 0 : 1); + return generateRandomNotes(originalObject.StartTime, segmentDuration, segmentDuration < 80 ? 0 : 1); } if (conversionDifficulty > 6.5) { if ((convertType & LegacyConvertType.LowProbability) > 0) - return addNRandomNotes(originalObject.StartTime, endTime, 0.78, 0.3, 0); - return addNRandomNotes(originalObject.StartTime, endTime, 0.85, 0.36, 0.03); + return generateNRandomNotes(originalObject.StartTime, endTime, 0.78, 0.3, 0); + return generateNRandomNotes(originalObject.StartTime, endTime, 0.85, 0.36, 0.03); } if (conversionDifficulty > 4) { if ((convertType & LegacyConvertType.LowProbability) > 0) - return addNRandomNotes(originalObject.StartTime, endTime, 0.43, 0.08, 0); - return addNRandomNotes(originalObject.StartTime, endTime, 0.56, 0.18, 0); + return generateNRandomNotes(originalObject.StartTime, endTime, 0.43, 0.08, 0); + return generateNRandomNotes(originalObject.StartTime, endTime, 0.56, 0.18, 0); } if (conversionDifficulty > 2.5) { if ((convertType & LegacyConvertType.LowProbability) > 0) - return addNRandomNotes(originalObject.StartTime, endTime, 0.3, 0, 0); - return addNRandomNotes(originalObject.StartTime, endTime, 0.37, 0.08, 0); + return generateNRandomNotes(originalObject.StartTime, endTime, 0.3, 0, 0); + return generateNRandomNotes(originalObject.StartTime, endTime, 0.37, 0.08, 0); } if ((convertType & LegacyConvertType.LowProbability) > 0) - return addNRandomNotes(originalObject.StartTime, endTime, 0.17, 0, 0); - return addNRandomNotes(originalObject.StartTime, endTime, 0.27, 0, 0); + return generateNRandomNotes(originalObject.StartTime, endTime, 0.17, 0, 0); + return generateNRandomNotes(originalObject.StartTime, endTime, 0.27, 0, 0); } /// - /// Adds random hold notes. + /// Generates random hold notes that start at an span the same amount of rows. /// - /// Number of hold notes. /// Start time of each hold note. /// End time of the hold notes. - /// The new row. - private ObjectRow generateRandomHoldNotes(double startTime, double endTime, int count) + /// Number of hold notes. + /// The containing the hit objects. + private ObjectList generateRandomHoldNotes(double startTime, double endTime, int noteCount) { - var newRow = new ObjectRow(); + // - - - - + // ■ - ■ ■ + // □ - □ □ + // ■ - ■ ■ + + var newObjects = new ObjectList(); + + int usableColumns = AvailableColumns - RandomStart - PreviousObjects.ColumnsFilled; - int usableColumns = AvailableColumns - RandomStart - PreviousRow.Columns; int nextColumn = Random.Next(RandomStart, AvailableColumns); - for (int i = 0; i < Math.Min(usableColumns, count); i++) + for (int i = 0; i < Math.Min(usableColumns, noteCount); i++) { - while (newRow.IsTaken(nextColumn) || PreviousRow.IsTaken(nextColumn)) //find available column + while (newObjects.IsFilled(nextColumn) || PreviousObjects.IsFilled(nextColumn)) //find available column nextColumn = Random.Next(RandomStart, AvailableColumns); - add(newRow, nextColumn, startTime, endTime, count); + add(newObjects, nextColumn, startTime, endTime, noteCount); } // This is can't be combined with the above loop due to RNG - for (int i = 0; i < count - usableColumns; i++) + for (int i = 0; i < noteCount - usableColumns; i++) { - while (newRow.IsTaken(nextColumn)) + while (newObjects.IsFilled(nextColumn)) nextColumn = Random.Next(RandomStart, AvailableColumns); - add(newRow, nextColumn, startTime, endTime, count); + add(newObjects, nextColumn, startTime, endTime, noteCount); } - return newRow; + return newObjects; } /// - /// Adds random notes, with one note per row. No stacking. + /// Generates random notes, with one note per row and no stacking. /// /// The start time. /// The separation of notes between rows. /// The number of rows. - /// The new row. - private ObjectRow addRandomNotes(double startTime, double separationTime, int repeatCount) + /// The containing the hit objects. + private ObjectList generateRandomNotes(double startTime, double separationTime, int repeatCount) { - var newRow = new ObjectRow(); + // - - - - + // x - - - + // - - x - + // - - - x + // x - - - + + var newObjects = new ObjectList(); int nextColumn = GetColumn((originalObject as IHasXPosition)?.X ?? 0, true); - if ((convertType & LegacyConvertType.ForceNotStack) > 0 && PreviousRow.Columns < AvailableColumns) + if ((convertType & LegacyConvertType.ForceNotStack) > 0 && PreviousObjects.ColumnsFilled < AvailableColumns) { - while (PreviousRow.IsTaken(nextColumn)) + while (PreviousObjects.IsFilled(nextColumn)) nextColumn = Random.Next(RandomStart, AvailableColumns); } int lastColumn = nextColumn; for (int i = 0; i <= repeatCount; i++) { - add(newRow, nextColumn, startTime, startTime); + add(newObjects, nextColumn, startTime, startTime); while (nextColumn == lastColumn) nextColumn = Random.Next(RandomStart, AvailableColumns); @@ -170,26 +181,35 @@ namespace osu.Game.Rulesets.Mania.Beatmaps startTime += separationTime; } - return newRow; + return newObjects; } /// - /// Creates a stair of notes, with one note per row. + /// Generates a stair of notes, with one note per row. /// /// The start time. /// The separation of notes between rows. /// The number of rows/notes. - /// The new row. - private ObjectRow addStair(double startTime, double separationTime, int repeatCount) + /// The containing the hit objects. + private ObjectList generateStair(double startTime, double separationTime, int repeatCount) { - var newRow = new ObjectRow(); + // - - - - + // x - - - + // - x - - + // - - x - + // - - - x + // - - x - + // - x - - + // x - - - + + var newObjects = new ObjectList(); int column = GetColumn((originalObject as IHasXPosition)?.X ?? 0, true); bool increasing = Random.NextDouble() > 0.5; for (int i = 0; i <= repeatCount; i++) { - add(newRow, column, startTime, startTime); + add(newObjects, column, startTime, startTime); startTime += separationTime; // Check if we're at the borders of the stage, and invert the pattern if so @@ -215,19 +235,25 @@ namespace osu.Game.Rulesets.Mania.Beatmaps } } - return newRow; + return newObjects; } /// - /// Adds random notes, with 1-2 notes per row. No stacking. + /// Generates random notes with 1-2 notes per row and no stacking. /// /// The start time. /// The separation of notes between rows. /// The number of rows. - /// The new row. - private ObjectRow addMultipleNotes(double startTime, double separationTime, int repeatCount) + /// The containing the hit objects. + private ObjectList generateRandomMultipleNotes(double startTime, double separationTime, int repeatCount) { - var newRow = new ObjectRow(); + // - - - - + // x - - + // - x x - + // - - - x + // x - x - + + var newObjects = new ObjectList(); bool legacy = AvailableColumns >= 4 && AvailableColumns <= 8; int interval = Random.Next(1, AvailableColumns - (legacy ? 1 : 0)); @@ -235,7 +261,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps int nextColumn = GetColumn((originalObject as IHasXPosition)?.X ?? 0, true); for (int i = 0; i <= repeatCount; i++) { - add(newRow, nextColumn, startTime, startTime, 2); + add(newObjects, nextColumn, startTime, startTime, 2); nextColumn += interval; if (nextColumn >= AvailableColumns - RandomStart) @@ -244,13 +270,13 @@ namespace osu.Game.Rulesets.Mania.Beatmaps // If we're in 2K, let's not add many consecutive doubles if (AvailableColumns > 2) - add(newRow, nextColumn, startTime, startTime, 2); + add(newObjects, nextColumn, startTime, startTime, 2); nextColumn = Random.Next(RandomStart, AvailableColumns); startTime += separationTime; } - return newRow; + return newObjects; } /// @@ -261,9 +287,14 @@ namespace osu.Game.Rulesets.Mania.Beatmaps /// The probability required for 2 hold notes to be generated. /// The probability required for 3 hold notes to be generated. /// The probability required for 4 hold notes to be generated. - /// The new row. - private ObjectRow addNRandomNotes(double startTime, double endTime, double p2, double p3, double p4) + /// The containing the hit objects. + private ObjectList generateNRandomNotes(double startTime, double endTime, double p2, double p3, double p4) { + // - - - - + // ■ - ■ ■ + // □ - □ □ + // ■ - ■ ■ + switch (AvailableColumns) { case 2: @@ -291,7 +322,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps Func isDoubleSample = sample => sample.Name == SampleInfo.HIT_CLAP && sample.Name == SampleInfo.HIT_FINISH; bool canGenerateTwoNotes = (convertType & LegacyConvertType.LowProbability) == 0; - canGenerateTwoNotes &= originalObject.Samples.Any(isDoubleSample) || sampleInfoListAt(originalObject.StartTime, originalObject.StartTime - endTime).Any(isDoubleSample); + canGenerateTwoNotes &= originalObject.Samples.Any(isDoubleSample) || sampleInfoListAt(originalObject.StartTime).Any(isDoubleSample); if (canGenerateTwoNotes) p2 = 0; @@ -299,44 +330,72 @@ namespace osu.Game.Rulesets.Mania.Beatmaps return generateRandomHoldNotes(startTime, endTime, GetRandomNoteCount(p2, p3, p4)); } - private ObjectRow generateTiledHoldNotes(double startTime, double separationTime, int noteCount) + /// + /// Generates tiled hold notes. You can think of this as a stair of hold notes. + /// + /// The first hold note start time. + /// The separation time between hold notes. + /// The amount of hold notes. + /// The containing the hit objects. + private ObjectList generateTiledHoldNotes(double startTime, double separationTime, int noteCount) { - var newRow = new ObjectRow(); + // - - - - + // ■ ■ ■ ■ + // □ □ □ □ + // □ □ □ □ + // □ □ □ ■ + // □ □ ■ - + // □ ■ - - + // ■ - - - + + var newObjects = new ObjectList(); int columnRepeat = Math.Min(noteCount, AvailableColumns); int nextColumn = GetColumn((originalObject as IHasXPosition)?.X ?? 0, true); - if ((convertType & LegacyConvertType.ForceNotStack) > 0 && PreviousRow.Columns < AvailableColumns) + if ((convertType & LegacyConvertType.ForceNotStack) > 0 && PreviousObjects.ColumnsFilled < AvailableColumns) { - while (PreviousRow.IsTaken(nextColumn)) + while (PreviousObjects.IsFilled(nextColumn)) nextColumn = Random.Next(RandomStart, AvailableColumns); } for (int i = 0; i < columnRepeat; i++) { - while (newRow.IsTaken(nextColumn)) + while (newObjects.IsFilled(nextColumn)) nextColumn = Random.Next(RandomStart, AvailableColumns); - add(newRow, nextColumn, startTime, endTime, noteCount); + add(newObjects, nextColumn, startTime, endTime, noteCount); startTime += separationTime; } - return newRow; + return newObjects; } - private ObjectRow generateLongAndNormalNotes(double startTime, double separationTime) + /// + /// Generates a hold note alongside normal notes. + /// + /// The start time of notes. + /// The separation time between notes. + /// The containing the hit objects. + private ObjectList generateHoldAndNormalNotes(double startTime, double separationTime) { - var newRow = new ObjectRow(); + // - - - - + // ■ x x - + // ■ - x x + // ■ x - x + // ■ - x x + + var newObjects = new ObjectList(); int holdColumn = GetColumn((originalObject as IHasXPosition)?.X ?? 0, true); - if ((convertType & LegacyConvertType.ForceNotStack) > 0 && PreviousRow.Columns < AvailableColumns) + if ((convertType & LegacyConvertType.ForceNotStack) > 0 && PreviousObjects.ColumnsFilled < AvailableColumns) { - while (PreviousRow.IsTaken(holdColumn)) + while (PreviousObjects.IsFilled(holdColumn)) holdColumn = Random.Next(RandomStart, AvailableColumns); } // Create the hold note - add(newRow, holdColumn, startTime, separationTime * repeatCount); + add(newObjects, holdColumn, startTime, separationTime * repeatCount); int noteCount = 0; if (conversionDifficulty > 6.5) @@ -347,33 +406,41 @@ namespace osu.Game.Rulesets.Mania.Beatmaps noteCount = GetRandomNoteCount(AvailableColumns < 6 ? 0 : 0.24, 0); noteCount = Math.Min(AvailableColumns - 1, noteCount); - bool ignoreHead = !sampleInfoListAt(startTime, separationTime).Any(s => s.Name == SampleInfo.HIT_WHISTLE || s.Name == SampleInfo.HIT_FINISH || s.Name == SampleInfo.HIT_CLAP); + bool ignoreHead = !sampleInfoListAt(startTime).Any(s => s.Name == SampleInfo.HIT_WHISTLE || s.Name == SampleInfo.HIT_FINISH || s.Name == SampleInfo.HIT_CLAP); int nextColumn = Random.Next(RandomStart, AvailableColumns); - var tempRow = new ObjectRow(); + var tempObjects = new ObjectList(); for (int i = 0; i <= repeatCount; i++) { if (!(ignoreHead && startTime == originalObject.StartTime)) { for (int j = 0; j < noteCount; j++) { - while (tempRow.IsTaken(nextColumn) || nextColumn == holdColumn) + while (tempObjects.IsFilled(nextColumn) || nextColumn == holdColumn) nextColumn = Random.Next(RandomStart, AvailableColumns); - add(tempRow, nextColumn, startTime, startTime, noteCount + 1); + add(tempObjects, nextColumn, startTime, startTime, noteCount + 1); } } - foreach (ManiaHitObject obj in tempRow.HitObjects) - newRow.Add(obj); + foreach (ManiaHitObject obj in tempObjects.HitObjects) + newObjects.Add(obj); - tempRow.Clear(); + tempObjects.Clear(); startTime += separationTime; } - return newRow; + return newObjects; } - private void add(ObjectRow row, int column, double startTime, double endTime, int siblings = 1) + /// + /// Constructs and adds a note to an object list. + /// + /// The list to add to. + /// The column to add the note to. + /// The start time of the note. + /// The end time of the note (set to for a non-hold note). + /// The number of children alongside this note (these will not be generated, but are used for volume calculations). + private void add(ObjectList objectList, int column, double startTime, double endTime, int siblings = 1) { ManiaHitObject newObject; @@ -399,21 +466,32 @@ namespace osu.Game.Rulesets.Mania.Beatmaps // Todo: Consider siblings and write sample volumes (probably at ManiaHitObject level) - row.Add(newObject); + objectList.Add(newObject); } - private SampleInfoList sampleInfoListAt(double time, double separationTime) + /// + /// Retrieves the sample info list at a point in time. + /// + /// The time to retrieve the sample info list from. + /// + /// + private SampleInfoList sampleInfoListAt(double time) { var curveData = originalObject as IHasCurve; if (curveData == null) return originalObject.Samples; - int index = (int)(separationTime == 0 ? 0 : (time - originalObject.StartTime) / separationTime); + double segmentTime = (curveData.EndTime - originalObject.StartTime) / repeatCount; + + int index = (int)(segmentTime == 0 ? 0 : (time - originalObject.StartTime) / segmentTime); return curveData.RepeatSamples[index]; } private double? _conversionDifficulty; + /// + /// A difficulty factor used for various conversion methods from osu!stable. + /// private double conversionDifficulty { get diff --git a/osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs index 18dea8ebc3..1acf2fbec2 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs @@ -27,7 +27,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps private readonly double lastNoteTime; private readonly float lastNotePosition; - private ObjectRow lastRow = new ObjectRow(); + private ObjectList lastRow = new ObjectList(); private readonly int availableColumns; private readonly float localXDivisor; @@ -120,7 +120,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps if (conversion == null) yield break; - ObjectRow newRow = conversion.GenerateConversion(); + ObjectList newRow = conversion.Generate(); foreach (ManiaHitObject obj in newRow.HitObjects) yield return obj; diff --git a/osu.Game.Rulesets.Mania/Beatmaps/ObjectConversion.cs b/osu.Game.Rulesets.Mania/Beatmaps/ObjectConversion.cs index bee7477261..42510e8e7b 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/ObjectConversion.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/ObjectConversion.cs @@ -13,13 +13,13 @@ namespace osu.Game.Rulesets.Mania.Beatmaps protected readonly int AvailableColumns; protected readonly int RandomStart; - protected ObjectRow PreviousRow; + protected ObjectList PreviousObjects; protected readonly FastRandom Random; protected readonly Beatmap Beatmap; - protected ObjectConversion(ObjectRow previousRow, FastRandom random, Beatmap beatmap) + protected ObjectConversion(ObjectList previousObjects, FastRandom random, Beatmap beatmap) { - PreviousRow = previousRow; + PreviousObjects = previousObjects; Random = random; Beatmap = beatmap; @@ -28,10 +28,10 @@ namespace osu.Game.Rulesets.Mania.Beatmaps } /// - /// Generates a new row filled with converted hit objects. + /// Generates a new object list filled with converted hit objects. /// - /// The new row. - public abstract ObjectRow GenerateConversion(); + /// The containing the hit objects. + public abstract ObjectList Generate(); /// /// Converts an x-position into a column. diff --git a/osu.Game.Rulesets.Mania/Beatmaps/ObjectRow.cs b/osu.Game.Rulesets.Mania/Beatmaps/ObjectList.cs similarity index 56% rename from osu.Game.Rulesets.Mania/Beatmaps/ObjectRow.cs rename to osu.Game.Rulesets.Mania/Beatmaps/ObjectList.cs index fe51c16bed..13bb32a113 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/ObjectRow.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/ObjectList.cs @@ -1,42 +1,56 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Framework.Extensions.IEnumerableExtensions; using osu.Game.Rulesets.Mania.Objects; using System.Collections.Generic; using System.Linq; namespace osu.Game.Rulesets.Mania.Beatmaps { - internal class ObjectRow + internal class ObjectList { private readonly List hitObjects = new List(); + + /// + /// All the hit objects contained in this list. + /// public IEnumerable HitObjects => hitObjects; /// - /// Whether a column of this row has been taken. + /// Whether a column of this list has been taken. /// /// The column index. /// Whether the column already contains a hit object. - public bool IsTaken(int column) => hitObjects.Exists(h => h.Column == column); + public bool IsFilled(int column) => hitObjects.Exists(h => h.Column == column); /// - /// Amount of columns taken up by hit objects in this row. + /// Amount of columns taken up by hit objects in this list. /// - public int Columns => HitObjects.GroupBy(h => h.Column).Count(); + public int ColumnsFilled => HitObjects.GroupBy(h => h.Column).Count(); /// - /// Adds a hit object to this row. + /// Adds a hit object to this list. /// /// The hit object to add. public void Add(ManiaHitObject hitObject) => hitObjects.Add(hitObject); /// - /// Clears this row. + /// Copies hit object from another list to this one. + /// + /// The other list. + public void Add(ObjectList other) + { + other.HitObjects.ForEach(Add); + } + + /// + /// Clears this list. /// public void Clear() => hitObjects.Clear(); /// - /// Removes a hit object from this row. + /// Removes a hit object from this list. /// /// The hit object to remove. public bool Remove(ManiaHitObject hitObject) => hitObjects.Remove(hitObject); diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index 36c17ccf04..3d93dd3068 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -52,7 +52,7 @@ - + From 7c48fb2b9259c8cc252a4c860aafc9550172d23f Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 18 May 2017 13:37:22 +0900 Subject: [PATCH 276/329] General fixes. --- .../Beatmaps/DistanceObjectConversion.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/DistanceObjectConversion.cs b/osu.Game.Rulesets.Mania/Beatmaps/DistanceObjectConversion.cs index 52c5cf16da..20ee944dbf 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/DistanceObjectConversion.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/DistanceObjectConversion.cs @@ -126,7 +126,6 @@ namespace osu.Game.Rulesets.Mania.Beatmaps var newObjects = new ObjectList(); int usableColumns = AvailableColumns - RandomStart - PreviousObjects.ColumnsFilled; - int nextColumn = Random.Next(RandomStart, AvailableColumns); for (int i = 0; i < Math.Min(usableColumns, noteCount); i++) { @@ -325,7 +324,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps canGenerateTwoNotes &= originalObject.Samples.Any(isDoubleSample) || sampleInfoListAt(originalObject.StartTime).Any(isDoubleSample); if (canGenerateTwoNotes) - p2 = 0; + p2 = 1; return generateRandomHoldNotes(startTime, endTime, GetRandomNoteCount(p2, p3, p4)); } @@ -397,7 +396,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps // Create the hold note add(newObjects, holdColumn, startTime, separationTime * repeatCount); - int noteCount = 0; + int noteCount = 1; if (conversionDifficulty > 6.5) noteCount = GetRandomNoteCount(0.63, 0); else if (conversionDifficulty > 4) @@ -422,10 +421,9 @@ namespace osu.Game.Rulesets.Mania.Beatmaps } } - foreach (ManiaHitObject obj in tempObjects.HitObjects) - newObjects.Add(obj); - + newObjects.Add(tempObjects); tempObjects.Clear(); + startTime += separationTime; } From 6010243736f6bd1cc7fc798bd5940c356bcdc36a Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 18 May 2017 14:07:57 +0900 Subject: [PATCH 277/329] Fix incorrect uint_to_real factor. --- osu.Game.Rulesets.Mania/MathUtils/FastRandom.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Mania/MathUtils/FastRandom.cs b/osu.Game.Rulesets.Mania/MathUtils/FastRandom.cs index 381e24c84c..ff3fd8e4b7 100644 --- a/osu.Game.Rulesets.Mania/MathUtils/FastRandom.cs +++ b/osu.Game.Rulesets.Mania/MathUtils/FastRandom.cs @@ -10,7 +10,7 @@ namespace osu.Game.Rulesets.Mania.MathUtils /// internal class FastRandom { - private const double uint_to_real = 1.0 / (int.MaxValue + 1.0); + private const double uint_to_real = 1.0 / (uint.MaxValue + 1.0); private const uint int_mask = 0x7FFFFFFF; private const uint y = 842502087; private const uint z = 3579807591; From 6dae5cbacf53281e47506e548442007586e9771f Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 18 May 2017 14:08:32 +0900 Subject: [PATCH 278/329] Fix distance object conversion not calculating end time. --- .../Beatmaps/DistanceObjectConversion.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/DistanceObjectConversion.cs b/osu.Game.Rulesets.Mania/Beatmaps/DistanceObjectConversion.cs index 20ee944dbf..0dbc38ded6 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/DistanceObjectConversion.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/DistanceObjectConversion.cs @@ -17,6 +17,11 @@ namespace osu.Game.Rulesets.Mania.Beatmaps { internal class DistanceObjectConversion : ObjectConversion { + /// + /// Base osu! slider scoring distance. + /// + private const float osu_base_scoring_distance = 100; + private readonly HitObject originalObject; private readonly double endTime; @@ -39,8 +44,20 @@ namespace osu.Game.Rulesets.Mania.Beatmaps var distanceData = originalObject as IHasDistance; var repeatsData = originalObject as IHasRepeats; - endTime = distanceData?.EndTime ?? 0; repeatCount = repeatsData?.RepeatCount ?? 1; + + double speedAdjustment = beatmap.TimingInfo.SpeedMultiplierAt(originalObject.StartTime); + double speedAdjustedBeatLength = beatmap.TimingInfo.BeatLengthAt(originalObject.StartTime) * speedAdjustment; + + // The true distance, accounting for any repeats. This ends up being the drum roll distance later + double distance = distanceData.Distance * repeatCount; + + // The velocity of the osu! hit object - calculated as the velocity of a slider + double osuVelocity = osu_base_scoring_distance * beatmap.BeatmapInfo.Difficulty.SliderMultiplier / speedAdjustedBeatLength; + // The duration of the osu! hit object + double osuDuration = distance / osuVelocity; + + endTime = originalObject.StartTime + osuDuration; } public override ObjectList Generate() From de8271ad6bff2193377e12fafbccf0953d99402d Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 18 May 2017 14:08:48 +0900 Subject: [PATCH 279/329] Fix out of range exceptions due to out-of-order hitobjects. --- osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs index e9dae95782..37150adb66 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs @@ -25,7 +25,8 @@ namespace osu.Game.Rulesets.Mania.Beatmaps { BeatmapInfo = original.BeatmapInfo, TimingInfo = original.TimingInfo, - HitObjects = original.HitObjects.SelectMany(converter.Convert).ToList() + // We need to sort here, because the converter generates patterns + HitObjects = original.HitObjects.SelectMany(converter.Convert).OrderBy(h => h.StartTime).ToList() }; } From 618c162535162b321f4db36b995f2da873fc8641 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 18 May 2017 14:17:23 +0900 Subject: [PATCH 280/329] Move more functions to ObjectConversion + resharper cleanup. --- .../Beatmaps/DistanceObjectConversion.cs | 101 +++--------------- .../Beatmaps/LegacyConverter.cs | 11 -- .../Beatmaps/ObjectConversion.cs | 70 ++++++++++++ 3 files changed, 86 insertions(+), 96 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/DistanceObjectConversion.cs b/osu.Game.Rulesets.Mania/Beatmaps/DistanceObjectConversion.cs index 0dbc38ded6..59d4a7a80c 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/DistanceObjectConversion.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/DistanceObjectConversion.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 osu.Game.Rulesets.Mania.Objects; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Timing; using osu.Game.Rulesets.Objects; @@ -9,8 +8,6 @@ using osu.Game.Rulesets.Objects.Types; using System; using osu.Game.Rulesets.Mania.MathUtils; using System.Linq; -using OpenTK; -using osu.Game.Database; using osu.Game.Audio; namespace osu.Game.Rulesets.Mania.Beatmaps @@ -78,7 +75,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps if (segmentDuration <= 160) return generateStair(originalObject.StartTime, segmentDuration, repeatCount); - if (segmentDuration <= 200 && conversionDifficulty > 3) + if (segmentDuration <= 200 && ConversionDifficulty > 3) return generateRandomMultipleNotes(originalObject.StartTime, segmentDuration, repeatCount); double duration = endTime - originalObject.StartTime; @@ -100,21 +97,21 @@ namespace osu.Game.Rulesets.Mania.Beatmaps return generateRandomNotes(originalObject.StartTime, segmentDuration, segmentDuration < 80 ? 0 : 1); } - if (conversionDifficulty > 6.5) + if (ConversionDifficulty > 6.5) { if ((convertType & LegacyConvertType.LowProbability) > 0) return generateNRandomNotes(originalObject.StartTime, endTime, 0.78, 0.3, 0); return generateNRandomNotes(originalObject.StartTime, endTime, 0.85, 0.36, 0.03); } - if (conversionDifficulty > 4) + if (ConversionDifficulty > 4) { if ((convertType & LegacyConvertType.LowProbability) > 0) return generateNRandomNotes(originalObject.StartTime, endTime, 0.43, 0.08, 0); return generateNRandomNotes(originalObject.StartTime, endTime, 0.56, 0.18, 0); } - if (conversionDifficulty > 2.5) + if (ConversionDifficulty > 2.5) { if ((convertType & LegacyConvertType.LowProbability) > 0) return generateNRandomNotes(originalObject.StartTime, endTime, 0.3, 0, 0); @@ -148,7 +145,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps { while (newObjects.IsFilled(nextColumn) || PreviousObjects.IsFilled(nextColumn)) //find available column nextColumn = Random.Next(RandomStart, AvailableColumns); - add(newObjects, nextColumn, startTime, endTime, noteCount); + Add(newObjects, originalObject, nextColumn, startTime, endTime, noteCount); } // This is can't be combined with the above loop due to RNG @@ -156,7 +153,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps { while (newObjects.IsFilled(nextColumn)) nextColumn = Random.Next(RandomStart, AvailableColumns); - add(newObjects, nextColumn, startTime, endTime, noteCount); + Add(newObjects, originalObject, nextColumn, startTime, endTime, noteCount); } return newObjects; @@ -189,7 +186,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps int lastColumn = nextColumn; for (int i = 0; i <= repeatCount; i++) { - add(newObjects, nextColumn, startTime, startTime); + Add(newObjects, originalObject, nextColumn, startTime, startTime); while (nextColumn == lastColumn) nextColumn = Random.Next(RandomStart, AvailableColumns); @@ -225,7 +222,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps for (int i = 0; i <= repeatCount; i++) { - add(newObjects, column, startTime, startTime); + Add(newObjects, originalObject, column, startTime, startTime); startTime += separationTime; // Check if we're at the borders of the stage, and invert the pattern if so @@ -277,7 +274,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps int nextColumn = GetColumn((originalObject as IHasXPosition)?.X ?? 0, true); for (int i = 0; i <= repeatCount; i++) { - add(newObjects, nextColumn, startTime, startTime, 2); + Add(newObjects, originalObject, nextColumn, startTime, startTime, 2); nextColumn += interval; if (nextColumn >= AvailableColumns - RandomStart) @@ -286,7 +283,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps // If we're in 2K, let's not add many consecutive doubles if (AvailableColumns > 2) - add(newObjects, nextColumn, startTime, startTime, 2); + Add(newObjects, originalObject, nextColumn, startTime, startTime, 2); nextColumn = Random.Next(RandomStart, AvailableColumns); startTime += separationTime; @@ -380,7 +377,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps while (newObjects.IsFilled(nextColumn)) nextColumn = Random.Next(RandomStart, AvailableColumns); - add(newObjects, nextColumn, startTime, endTime, noteCount); + Add(newObjects, originalObject, nextColumn, startTime, endTime, noteCount); startTime += separationTime; } @@ -411,14 +408,14 @@ namespace osu.Game.Rulesets.Mania.Beatmaps } // Create the hold note - add(newObjects, holdColumn, startTime, separationTime * repeatCount); + Add(newObjects, originalObject, holdColumn, startTime, separationTime * repeatCount); int noteCount = 1; - if (conversionDifficulty > 6.5) + if (ConversionDifficulty > 6.5) noteCount = GetRandomNoteCount(0.63, 0); - else if (conversionDifficulty > 4) + else if (ConversionDifficulty > 4) noteCount = GetRandomNoteCount(AvailableColumns < 6 ? 0.12 : 0.45, 0); - else if (conversionDifficulty > 2.5) + else if (ConversionDifficulty > 2.5) noteCount = GetRandomNoteCount(AvailableColumns < 6 ? 0 : 0.24, 0); noteCount = Math.Min(AvailableColumns - 1, noteCount); @@ -434,7 +431,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps { while (tempObjects.IsFilled(nextColumn) || nextColumn == holdColumn) nextColumn = Random.Next(RandomStart, AvailableColumns); - add(tempObjects, nextColumn, startTime, startTime, noteCount + 1); + Add(tempObjects, originalObject, nextColumn, startTime, startTime, noteCount + 1); } } @@ -447,48 +444,10 @@ namespace osu.Game.Rulesets.Mania.Beatmaps return newObjects; } - /// - /// Constructs and adds a note to an object list. - /// - /// The list to add to. - /// The column to add the note to. - /// The start time of the note. - /// The end time of the note (set to for a non-hold note). - /// The number of children alongside this note (these will not be generated, but are used for volume calculations). - private void add(ObjectList objectList, int column, double startTime, double endTime, int siblings = 1) - { - ManiaHitObject newObject; - - if (startTime == endTime) - { - newObject = new Note - { - StartTime = startTime, - Samples = originalObject.Samples, - Column = column - }; - } - else - { - newObject = new HoldNote - { - StartTime = startTime, - Samples = originalObject.Samples, - Column = column, - Duration = endTime - startTime - }; - } - - // Todo: Consider siblings and write sample volumes (probably at ManiaHitObject level) - - objectList.Add(newObject); - } - /// /// Retrieves the sample info list at a point in time. /// /// The time to retrieve the sample info list from. - /// /// private SampleInfoList sampleInfoListAt(double time) { @@ -502,33 +461,5 @@ namespace osu.Game.Rulesets.Mania.Beatmaps int index = (int)(segmentTime == 0 ? 0 : (time - originalObject.StartTime) / segmentTime); return curveData.RepeatSamples[index]; } - - private double? _conversionDifficulty; - /// - /// A difficulty factor used for various conversion methods from osu!stable. - /// - private double conversionDifficulty - { - get - { - if (_conversionDifficulty != null) - return _conversionDifficulty.Value; - - HitObject lastObject = Beatmap.HitObjects.LastOrDefault(); - HitObject firstObject = Beatmap.HitObjects.FirstOrDefault(); - - double drainTime = (lastObject?.StartTime ?? 0) - (firstObject?.StartTime ?? 0); - drainTime -= Beatmap.EventInfo.TotalBreakTime; - - if (drainTime == 0) - drainTime = 10000; - - BeatmapDifficulty difficulty = Beatmap.BeatmapInfo.Difficulty; - _conversionDifficulty = ((difficulty.DrainRate + MathHelper.Clamp(difficulty.ApproachRate, 4, 7)) / 1.5 + Beatmap.HitObjects.Count / drainTime * 9f) / 38f * 5f / 1.15; - _conversionDifficulty = Math.Min(_conversionDifficulty.Value, 12); - - return _conversionDifficulty.Value; - } - } } } diff --git a/osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs index 1acf2fbec2..0a85b8c8af 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs @@ -9,7 +9,6 @@ using osu.Game.Rulesets.Objects.Types; using System; using System.Collections.Generic; using osu.Game.Rulesets.Mania.MathUtils; -using osu.Game.Beatmaps.Timing; namespace osu.Game.Rulesets.Mania.Beatmaps { @@ -18,15 +17,8 @@ namespace osu.Game.Rulesets.Mania.Beatmaps /// internal class LegacyConverter { - private const int max_previous_note_times = 7; - private readonly FastRandom random; - private readonly List previousNoteTimes; - private readonly bool[] previousNotes; - private readonly double lastNoteTime; - private readonly float lastNotePosition; - private ObjectList lastRow = new ObjectList(); private readonly int availableColumns; @@ -44,9 +36,6 @@ namespace osu.Game.Rulesets.Mania.Beatmaps availableColumns = (int)Math.Round(beatmap.BeatmapInfo.Difficulty.CircleSize); localXDivisor = 512.0f / availableColumns; - - previousNoteTimes = new List(max_previous_note_times); - previousNotes = new bool[availableColumns]; } public IEnumerable Convert(HitObject original) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/ObjectConversion.cs b/osu.Game.Rulesets.Mania/Beatmaps/ObjectConversion.cs index 42510e8e7b..83c0af9d46 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/ObjectConversion.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/ObjectConversion.cs @@ -5,6 +5,10 @@ using OpenTK; using osu.Game.Beatmaps; using osu.Game.Rulesets.Mania.MathUtils; using System; +using System.Linq; +using osu.Game.Database; +using osu.Game.Rulesets.Mania.Objects; +using osu.Game.Rulesets.Objects; namespace osu.Game.Rulesets.Mania.Beatmaps { @@ -73,5 +77,71 @@ namespace osu.Game.Rulesets.Mania.Beatmaps return 3; return val >= 1 - p2 ? 2 : 1; } + + /// + /// Constructs and adds a note to an object list. + /// + /// The list to add to. + /// The original hit object (used for samples). + /// The column to add the note to. + /// The start time of the note. + /// The end time of the note (set to for a non-hold note). + /// The number of children alongside this note (these will not be generated, but are used for volume calculations). + protected void Add(ObjectList objectList, HitObject originalObject, int column, double startTime, double endTime, int siblings = 1) + { + ManiaHitObject newObject; + + if (startTime == endTime) + { + newObject = new Note + { + StartTime = startTime, + Samples = originalObject.Samples, + Column = column + }; + } + else + { + newObject = new HoldNote + { + StartTime = startTime, + Samples = originalObject.Samples, + Column = column, + Duration = endTime - startTime + }; + } + + // Todo: Consider siblings and write sample volumes (probably at ManiaHitObject level) + + objectList.Add(newObject); + } + + private double? conversionDifficulty; + /// + /// A difficulty factor used for various conversion methods from osu!stable. + /// + protected double ConversionDifficulty + { + get + { + if (conversionDifficulty != null) + return conversionDifficulty.Value; + + HitObject lastObject = Beatmap.HitObjects.LastOrDefault(); + HitObject firstObject = Beatmap.HitObjects.FirstOrDefault(); + + double drainTime = (lastObject?.StartTime ?? 0) - (firstObject?.StartTime ?? 0); + drainTime -= Beatmap.EventInfo.TotalBreakTime; + + if (drainTime == 0) + drainTime = 10000; + + BeatmapDifficulty difficulty = Beatmap.BeatmapInfo.Difficulty; + conversionDifficulty = ((difficulty.DrainRate + MathHelper.Clamp(difficulty.ApproachRate, 4, 7)) / 1.5 + Beatmap.HitObjects.Count / drainTime * 9f) / 38f * 5f / 1.15; + conversionDifficulty = Math.Min(conversionDifficulty.Value, 12); + + return conversionDifficulty.Value; + } + } } } From 1fa1897d71122d08ad93e8a82be35af6a87d0485 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 18 May 2017 15:05:45 +0900 Subject: [PATCH 281/329] Define the concept of patterns + additional comments. --- ...Converter.cs => LegacyBeatmapConverter.cs} | 25 +- .../Beatmaps/ManiaBeatmapConverter.cs | 2 +- .../Legacy/DistanceObjectPatternGenerator.cs} | 218 +++++++++--------- .../Legacy/PatternGenerator.cs} | 73 ++---- .../Legacy/PatternType.cs} | 7 +- .../{ObjectList.cs => Patterns/Pattern.cs} | 31 +-- .../Beatmaps/Patterns/PatternGenerator.cs | 89 +++++++ .../osu.Game.Rulesets.Mania.csproj | 11 +- 8 files changed, 255 insertions(+), 201 deletions(-) rename osu.Game.Rulesets.Mania/Beatmaps/{LegacyConverter.cs => LegacyBeatmapConverter.cs} (83%) rename osu.Game.Rulesets.Mania/Beatmaps/{DistanceObjectConversion.cs => Patterns/Legacy/DistanceObjectPatternGenerator.cs} (58%) rename osu.Game.Rulesets.Mania/Beatmaps/{ObjectConversion.cs => Patterns/Legacy/PatternGenerator.cs} (59%) rename osu.Game.Rulesets.Mania/Beatmaps/{LegacyConvertType.cs => Patterns/Legacy/PatternType.cs} (85%) rename osu.Game.Rulesets.Mania/Beatmaps/{ObjectList.cs => Patterns/Pattern.cs} (62%) create mode 100644 osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs diff --git a/osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/LegacyBeatmapConverter.cs similarity index 83% rename from osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs rename to osu.Game.Rulesets.Mania/Beatmaps/LegacyBeatmapConverter.cs index 0a85b8c8af..4108ba7809 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/LegacyConverter.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/LegacyBeatmapConverter.cs @@ -1,32 +1,33 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK; +using System; +using System.Collections.Generic; using osu.Game.Beatmaps; +using osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy; +using osu.Game.Rulesets.Mania.MathUtils; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Types; -using System; -using System.Collections.Generic; -using osu.Game.Rulesets.Mania.MathUtils; +using OpenTK; namespace osu.Game.Rulesets.Mania.Beatmaps { /// /// Special converter used for converting from osu!stable beatmaps. /// - internal class LegacyConverter + internal class LegacyBeatmapConverter { private readonly FastRandom random; - private ObjectList lastRow = new ObjectList(); + private Patterns.Pattern lastPattern = new Patterns.Pattern(); private readonly int availableColumns; private readonly float localXDivisor; private readonly Beatmap beatmap; - public LegacyConverter(Beatmap beatmap) + public LegacyBeatmapConverter(Beatmap beatmap) { this.beatmap = beatmap; @@ -93,10 +94,10 @@ namespace osu.Game.Rulesets.Mania.Beatmaps var distanceData = original as IHasDistance; var positionData = original as IHasPosition; - ObjectConversion conversion = null; + Patterns.PatternGenerator conversion = null; if (distanceData != null) - conversion = new DistanceObjectConversion(original, lastRow, random, beatmap); + conversion = new DistanceObjectPatternGenerator(random, original, beatmap, lastPattern); else if (endTimeData != null) { // Spinner @@ -109,12 +110,12 @@ namespace osu.Game.Rulesets.Mania.Beatmaps if (conversion == null) yield break; - ObjectList newRow = conversion.Generate(); + Patterns.Pattern newPattern = conversion.Generate(); - foreach (ManiaHitObject obj in newRow.HitObjects) + foreach (ManiaHitObject obj in newPattern.HitObjects) yield return obj; - lastRow = newRow; + lastPattern = newPattern; } private int getColumn(float position) => MathHelper.Clamp((int)Math.Floor(position / localXDivisor), 0, availableColumns - 1); diff --git a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs index 37150adb66..aea77cd2b5 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs @@ -19,7 +19,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps protected override Beatmap ConvertBeatmap(Beatmap original) { // Todo: This should be cased when we get better conversion methods - var converter = new LegacyConverter(original); + var converter = new LegacyBeatmapConverter(original); return new Beatmap { diff --git a/osu.Game.Rulesets.Mania/Beatmaps/DistanceObjectConversion.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs similarity index 58% rename from osu.Game.Rulesets.Mania/Beatmaps/DistanceObjectConversion.cs rename to osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs index 59d4a7a80c..03240a2be4 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/DistanceObjectConversion.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs @@ -1,50 +1,49 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using osu.Game.Beatmaps; -using osu.Game.Beatmaps.Timing; -using osu.Game.Rulesets.Objects; -using osu.Game.Rulesets.Objects.Types; using System; -using osu.Game.Rulesets.Mania.MathUtils; using System.Linq; using osu.Game.Audio; +using osu.Game.Beatmaps; +using osu.Game.Beatmaps.Timing; +using osu.Game.Rulesets.Mania.MathUtils; +using osu.Game.Rulesets.Objects; +using osu.Game.Rulesets.Objects.Types; -namespace osu.Game.Rulesets.Mania.Beatmaps +namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy { - internal class DistanceObjectConversion : ObjectConversion + /// + /// A pattern generator for IHasDistance hit objects. + /// + internal class DistanceObjectPatternGenerator : PatternGenerator { /// /// Base osu! slider scoring distance. /// private const float osu_base_scoring_distance = 100; - private readonly HitObject originalObject; - private readonly double endTime; private readonly int repeatCount; - private LegacyConvertType convertType; + private PatternType convertType; - public DistanceObjectConversion(HitObject originalObject, ObjectList previousObjects, FastRandom random, Beatmap beatmap) - : base(previousObjects, random, beatmap) + public DistanceObjectPatternGenerator(FastRandom random, HitObject hitObject, Beatmap beatmap, Pattern previousPattern) + : base(random, hitObject, beatmap, previousPattern) { - this.originalObject = originalObject; - ControlPoint overridePoint; - ControlPoint controlPoint = Beatmap.TimingInfo.TimingPointAt(originalObject.StartTime, out overridePoint); + ControlPoint controlPoint = Beatmap.TimingInfo.TimingPointAt(hitObject.StartTime, out overridePoint); - convertType = LegacyConvertType.None; + convertType = PatternType.None; if ((overridePoint ?? controlPoint)?.KiaiMode == false) - convertType = LegacyConvertType.LowProbability; + convertType = PatternType.LowProbability; - var distanceData = originalObject as IHasDistance; - var repeatsData = originalObject as IHasRepeats; + var distanceData = hitObject as IHasDistance; + var repeatsData = hitObject as IHasRepeats; repeatCount = repeatsData?.RepeatCount ?? 1; - double speedAdjustment = beatmap.TimingInfo.SpeedMultiplierAt(originalObject.StartTime); - double speedAdjustedBeatLength = beatmap.TimingInfo.BeatLengthAt(originalObject.StartTime) * speedAdjustment; + double speedAdjustment = beatmap.TimingInfo.SpeedMultiplierAt(hitObject.StartTime); + double speedAdjustedBeatLength = beatmap.TimingInfo.BeatLengthAt(hitObject.StartTime) * speedAdjustment; // The true distance, accounting for any repeats. This ends up being the drum roll distance later double distance = distanceData.Distance * repeatCount; @@ -54,73 +53,73 @@ namespace osu.Game.Rulesets.Mania.Beatmaps // The duration of the osu! hit object double osuDuration = distance / osuVelocity; - endTime = originalObject.StartTime + osuDuration; + endTime = hitObject.StartTime + osuDuration; } - public override ObjectList Generate() + public override Pattern Generate() { double segmentDuration = endTime / repeatCount; if (repeatCount > 1) { if (segmentDuration <= 90) - return generateRandomHoldNotes(originalObject.StartTime, endTime, 1); + return generateRandomHoldNotes(HitObject.StartTime, endTime, 1); if (segmentDuration <= 120) { - convertType |= LegacyConvertType.ForceNotStack; - return generateRandomNotes(originalObject.StartTime, segmentDuration, repeatCount); + convertType |= PatternType.ForceNotStack; + return generateRandomNotes(HitObject.StartTime, segmentDuration, repeatCount); } if (segmentDuration <= 160) - return generateStair(originalObject.StartTime, segmentDuration, repeatCount); + return generateStair(HitObject.StartTime, segmentDuration); if (segmentDuration <= 200 && ConversionDifficulty > 3) - return generateRandomMultipleNotes(originalObject.StartTime, segmentDuration, repeatCount); + return generateRandomMultipleNotes(HitObject.StartTime, segmentDuration, repeatCount); - double duration = endTime - originalObject.StartTime; + double duration = endTime - HitObject.StartTime; if (duration >= 4000) - return generateNRandomNotes(originalObject.StartTime, endTime, 0.23, 0, 0); + return generateNRandomNotes(HitObject.StartTime, endTime, 0.23, 0, 0); if (segmentDuration > 400 && duration < 4000 && repeatCount < AvailableColumns - 1 - RandomStart) - return generateTiledHoldNotes(originalObject.StartTime, segmentDuration, repeatCount); + return generateTiledHoldNotes(HitObject.StartTime, segmentDuration, repeatCount); - return generateHoldAndNormalNotes(originalObject.StartTime, segmentDuration); + return generateHoldAndNormalNotes(HitObject.StartTime, segmentDuration); } if (segmentDuration <= 110) { - if (PreviousObjects.ColumnsFilled < AvailableColumns) - convertType |= LegacyConvertType.ForceNotStack; + if (PreviousPattern.ColumnsFilled < AvailableColumns) + convertType |= PatternType.ForceNotStack; else - convertType &= ~LegacyConvertType.ForceNotStack; - return generateRandomNotes(originalObject.StartTime, segmentDuration, segmentDuration < 80 ? 0 : 1); + convertType &= ~PatternType.ForceNotStack; + return generateRandomNotes(HitObject.StartTime, segmentDuration, segmentDuration < 80 ? 0 : 1); } if (ConversionDifficulty > 6.5) { - if ((convertType & LegacyConvertType.LowProbability) > 0) - return generateNRandomNotes(originalObject.StartTime, endTime, 0.78, 0.3, 0); - return generateNRandomNotes(originalObject.StartTime, endTime, 0.85, 0.36, 0.03); + if ((convertType & PatternType.LowProbability) > 0) + return generateNRandomNotes(HitObject.StartTime, endTime, 0.78, 0.3, 0); + return generateNRandomNotes(HitObject.StartTime, endTime, 0.85, 0.36, 0.03); } if (ConversionDifficulty > 4) { - if ((convertType & LegacyConvertType.LowProbability) > 0) - return generateNRandomNotes(originalObject.StartTime, endTime, 0.43, 0.08, 0); - return generateNRandomNotes(originalObject.StartTime, endTime, 0.56, 0.18, 0); + if ((convertType & PatternType.LowProbability) > 0) + return generateNRandomNotes(HitObject.StartTime, endTime, 0.43, 0.08, 0); + return generateNRandomNotes(HitObject.StartTime, endTime, 0.56, 0.18, 0); } if (ConversionDifficulty > 2.5) { - if ((convertType & LegacyConvertType.LowProbability) > 0) - return generateNRandomNotes(originalObject.StartTime, endTime, 0.3, 0, 0); - return generateNRandomNotes(originalObject.StartTime, endTime, 0.37, 0.08, 0); + if ((convertType & PatternType.LowProbability) > 0) + return generateNRandomNotes(HitObject.StartTime, endTime, 0.3, 0, 0); + return generateNRandomNotes(HitObject.StartTime, endTime, 0.37, 0.08, 0); } - if ((convertType & LegacyConvertType.LowProbability) > 0) - return generateNRandomNotes(originalObject.StartTime, endTime, 0.17, 0, 0); - return generateNRandomNotes(originalObject.StartTime, endTime, 0.27, 0, 0); + if ((convertType & PatternType.LowProbability) > 0) + return generateNRandomNotes(HitObject.StartTime, endTime, 0.17, 0, 0); + return generateNRandomNotes(HitObject.StartTime, endTime, 0.27, 0, 0); } /// @@ -129,34 +128,34 @@ namespace osu.Game.Rulesets.Mania.Beatmaps /// Start time of each hold note. /// End time of the hold notes. /// Number of hold notes. - /// The containing the hit objects. - private ObjectList generateRandomHoldNotes(double startTime, double endTime, int noteCount) + /// The containing the hit objects. + private Pattern generateRandomHoldNotes(double startTime, double endTime, int noteCount) { // - - - - // ■ - ■ ■ // □ - □ □ // ■ - ■ ■ - var newObjects = new ObjectList(); + var pattern = new Pattern(); - int usableColumns = AvailableColumns - RandomStart - PreviousObjects.ColumnsFilled; + int usableColumns = AvailableColumns - RandomStart - PreviousPattern.ColumnsFilled; int nextColumn = Random.Next(RandomStart, AvailableColumns); for (int i = 0; i < Math.Min(usableColumns, noteCount); i++) { - while (newObjects.IsFilled(nextColumn) || PreviousObjects.IsFilled(nextColumn)) //find available column + while (pattern.IsFilled(nextColumn) || PreviousPattern.IsFilled(nextColumn)) //find available column nextColumn = Random.Next(RandomStart, AvailableColumns); - Add(newObjects, originalObject, nextColumn, startTime, endTime, noteCount); + AddToPattern(pattern, HitObject, nextColumn, startTime, endTime, noteCount); } // This is can't be combined with the above loop due to RNG for (int i = 0; i < noteCount - usableColumns; i++) { - while (newObjects.IsFilled(nextColumn)) + while (pattern.IsFilled(nextColumn)) nextColumn = Random.Next(RandomStart, AvailableColumns); - Add(newObjects, originalObject, nextColumn, startTime, endTime, noteCount); + AddToPattern(pattern, HitObject, nextColumn, startTime, endTime, noteCount); } - return newObjects; + return pattern; } /// @@ -165,8 +164,8 @@ namespace osu.Game.Rulesets.Mania.Beatmaps /// The start time. /// The separation of notes between rows. /// The number of rows. - /// The containing the hit objects. - private ObjectList generateRandomNotes(double startTime, double separationTime, int repeatCount) + /// The containing the hit objects. + private Pattern generateRandomNotes(double startTime, double separationTime, int repeatCount) { // - - - - // x - - - @@ -174,19 +173,19 @@ namespace osu.Game.Rulesets.Mania.Beatmaps // - - - x // x - - - - var newObjects = new ObjectList(); + var pattern = new Pattern(); - int nextColumn = GetColumn((originalObject as IHasXPosition)?.X ?? 0, true); - if ((convertType & LegacyConvertType.ForceNotStack) > 0 && PreviousObjects.ColumnsFilled < AvailableColumns) + int nextColumn = GetColumn((HitObject as IHasXPosition)?.X ?? 0, true); + if ((convertType & PatternType.ForceNotStack) > 0 && PreviousPattern.ColumnsFilled < AvailableColumns) { - while (PreviousObjects.IsFilled(nextColumn)) + while (PreviousPattern.IsFilled(nextColumn)) nextColumn = Random.Next(RandomStart, AvailableColumns); } int lastColumn = nextColumn; for (int i = 0; i <= repeatCount; i++) { - Add(newObjects, originalObject, nextColumn, startTime, startTime); + AddToPattern(pattern, HitObject, nextColumn, startTime, startTime); while (nextColumn == lastColumn) nextColumn = Random.Next(RandomStart, AvailableColumns); @@ -194,7 +193,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps startTime += separationTime; } - return newObjects; + return pattern; } /// @@ -202,9 +201,8 @@ namespace osu.Game.Rulesets.Mania.Beatmaps /// /// The start time. /// The separation of notes between rows. - /// The number of rows/notes. - /// The containing the hit objects. - private ObjectList generateStair(double startTime, double separationTime, int repeatCount) + /// The containing the hit objects. + private Pattern generateStair(double startTime, double separationTime) { // - - - - // x - - - @@ -215,14 +213,14 @@ namespace osu.Game.Rulesets.Mania.Beatmaps // - x - - // x - - - - var newObjects = new ObjectList(); + var pattern = new Pattern(); - int column = GetColumn((originalObject as IHasXPosition)?.X ?? 0, true); + int column = GetColumn((HitObject as IHasXPosition)?.X ?? 0, true); bool increasing = Random.NextDouble() > 0.5; for (int i = 0; i <= repeatCount; i++) { - Add(newObjects, originalObject, column, startTime, startTime); + AddToPattern(pattern, HitObject, column, startTime, startTime); startTime += separationTime; // Check if we're at the borders of the stage, and invert the pattern if so @@ -248,7 +246,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps } } - return newObjects; + return pattern; } /// @@ -257,8 +255,8 @@ namespace osu.Game.Rulesets.Mania.Beatmaps /// The start time. /// The separation of notes between rows. /// The number of rows. - /// The containing the hit objects. - private ObjectList generateRandomMultipleNotes(double startTime, double separationTime, int repeatCount) + /// The containing the hit objects. + private Pattern generateRandomMultipleNotes(double startTime, double separationTime, int repeatCount) { // - - - - // x - - @@ -266,15 +264,15 @@ namespace osu.Game.Rulesets.Mania.Beatmaps // - - - x // x - x - - var newObjects = new ObjectList(); + var pattern = new Pattern(); bool legacy = AvailableColumns >= 4 && AvailableColumns <= 8; int interval = Random.Next(1, AvailableColumns - (legacy ? 1 : 0)); - int nextColumn = GetColumn((originalObject as IHasXPosition)?.X ?? 0, true); + int nextColumn = GetColumn((HitObject as IHasXPosition)?.X ?? 0, true); for (int i = 0; i <= repeatCount; i++) { - Add(newObjects, originalObject, nextColumn, startTime, startTime, 2); + AddToPattern(pattern, HitObject, nextColumn, startTime, startTime, 2); nextColumn += interval; if (nextColumn >= AvailableColumns - RandomStart) @@ -283,13 +281,13 @@ namespace osu.Game.Rulesets.Mania.Beatmaps // If we're in 2K, let's not add many consecutive doubles if (AvailableColumns > 2) - Add(newObjects, originalObject, nextColumn, startTime, startTime, 2); + AddToPattern(pattern, HitObject, nextColumn, startTime, startTime, 2); nextColumn = Random.Next(RandomStart, AvailableColumns); startTime += separationTime; } - return newObjects; + return pattern; } /// @@ -300,8 +298,8 @@ namespace osu.Game.Rulesets.Mania.Beatmaps /// The probability required for 2 hold notes to be generated. /// The probability required for 3 hold notes to be generated. /// The probability required for 4 hold notes to be generated. - /// The containing the hit objects. - private ObjectList generateNRandomNotes(double startTime, double endTime, double p2, double p3, double p4) + /// The containing the hit objects. + private Pattern generateNRandomNotes(double startTime, double endTime, double p2, double p3, double p4) { // - - - - // ■ - ■ ■ @@ -334,8 +332,8 @@ namespace osu.Game.Rulesets.Mania.Beatmaps Func isDoubleSample = sample => sample.Name == SampleInfo.HIT_CLAP && sample.Name == SampleInfo.HIT_FINISH; - bool canGenerateTwoNotes = (convertType & LegacyConvertType.LowProbability) == 0; - canGenerateTwoNotes &= originalObject.Samples.Any(isDoubleSample) || sampleInfoListAt(originalObject.StartTime).Any(isDoubleSample); + bool canGenerateTwoNotes = (convertType & PatternType.LowProbability) == 0; + canGenerateTwoNotes &= HitObject.Samples.Any(isDoubleSample) || sampleInfoListAt(HitObject.StartTime).Any(isDoubleSample); if (canGenerateTwoNotes) p2 = 1; @@ -349,8 +347,8 @@ namespace osu.Game.Rulesets.Mania.Beatmaps /// The first hold note start time. /// The separation time between hold notes. /// The amount of hold notes. - /// The containing the hit objects. - private ObjectList generateTiledHoldNotes(double startTime, double separationTime, int noteCount) + /// The containing the hit objects. + private Pattern generateTiledHoldNotes(double startTime, double separationTime, int noteCount) { // - - - - // ■ ■ ■ ■ @@ -361,27 +359,27 @@ namespace osu.Game.Rulesets.Mania.Beatmaps // □ ■ - - // ■ - - - - var newObjects = new ObjectList(); + var pattern = new Pattern(); int columnRepeat = Math.Min(noteCount, AvailableColumns); - int nextColumn = GetColumn((originalObject as IHasXPosition)?.X ?? 0, true); - if ((convertType & LegacyConvertType.ForceNotStack) > 0 && PreviousObjects.ColumnsFilled < AvailableColumns) + int nextColumn = GetColumn((HitObject as IHasXPosition)?.X ?? 0, true); + if ((convertType & PatternType.ForceNotStack) > 0 && PreviousPattern.ColumnsFilled < AvailableColumns) { - while (PreviousObjects.IsFilled(nextColumn)) + while (PreviousPattern.IsFilled(nextColumn)) nextColumn = Random.Next(RandomStart, AvailableColumns); } for (int i = 0; i < columnRepeat; i++) { - while (newObjects.IsFilled(nextColumn)) + while (pattern.IsFilled(nextColumn)) nextColumn = Random.Next(RandomStart, AvailableColumns); - Add(newObjects, originalObject, nextColumn, startTime, endTime, noteCount); + AddToPattern(pattern, HitObject, nextColumn, startTime, endTime, noteCount); startTime += separationTime; } - return newObjects; + return pattern; } /// @@ -389,8 +387,8 @@ namespace osu.Game.Rulesets.Mania.Beatmaps /// /// The start time of notes. /// The separation time between notes. - /// The containing the hit objects. - private ObjectList generateHoldAndNormalNotes(double startTime, double separationTime) + /// The containing the hit objects. + private Pattern generateHoldAndNormalNotes(double startTime, double separationTime) { // - - - - // ■ x x - @@ -398,17 +396,17 @@ namespace osu.Game.Rulesets.Mania.Beatmaps // ■ x - x // ■ - x x - var newObjects = new ObjectList(); + var pattern = new Pattern(); - int holdColumn = GetColumn((originalObject as IHasXPosition)?.X ?? 0, true); - if ((convertType & LegacyConvertType.ForceNotStack) > 0 && PreviousObjects.ColumnsFilled < AvailableColumns) + int holdColumn = GetColumn((HitObject as IHasXPosition)?.X ?? 0, true); + if ((convertType & PatternType.ForceNotStack) > 0 && PreviousPattern.ColumnsFilled < AvailableColumns) { - while (PreviousObjects.IsFilled(holdColumn)) + while (PreviousPattern.IsFilled(holdColumn)) holdColumn = Random.Next(RandomStart, AvailableColumns); } // Create the hold note - Add(newObjects, originalObject, holdColumn, startTime, separationTime * repeatCount); + AddToPattern(pattern, HitObject, holdColumn, startTime, separationTime * repeatCount); int noteCount = 1; if (ConversionDifficulty > 6.5) @@ -422,26 +420,26 @@ namespace osu.Game.Rulesets.Mania.Beatmaps bool ignoreHead = !sampleInfoListAt(startTime).Any(s => s.Name == SampleInfo.HIT_WHISTLE || s.Name == SampleInfo.HIT_FINISH || s.Name == SampleInfo.HIT_CLAP); int nextColumn = Random.Next(RandomStart, AvailableColumns); - var tempObjects = new ObjectList(); + var rowPattern = new Pattern(); for (int i = 0; i <= repeatCount; i++) { - if (!(ignoreHead && startTime == originalObject.StartTime)) + if (!(ignoreHead && startTime == HitObject.StartTime)) { for (int j = 0; j < noteCount; j++) { - while (tempObjects.IsFilled(nextColumn) || nextColumn == holdColumn) + while (rowPattern.IsFilled(nextColumn) || nextColumn == holdColumn) nextColumn = Random.Next(RandomStart, AvailableColumns); - Add(tempObjects, originalObject, nextColumn, startTime, startTime, noteCount + 1); + AddToPattern(rowPattern, HitObject, nextColumn, startTime, startTime, noteCount + 1); } } - newObjects.Add(tempObjects); - tempObjects.Clear(); + pattern.Add(rowPattern); + rowPattern.Clear(); startTime += separationTime; } - return newObjects; + return pattern; } /// @@ -451,14 +449,14 @@ namespace osu.Game.Rulesets.Mania.Beatmaps /// private SampleInfoList sampleInfoListAt(double time) { - var curveData = originalObject as IHasCurve; + var curveData = HitObject as IHasCurve; if (curveData == null) - return originalObject.Samples; + return HitObject.Samples; - double segmentTime = (curveData.EndTime - originalObject.StartTime) / repeatCount; + double segmentTime = (curveData.EndTime - HitObject.StartTime) / repeatCount; - int index = (int)(segmentTime == 0 ? 0 : (time - originalObject.StartTime) / segmentTime); + int index = (int)(segmentTime == 0 ? 0 : (time - HitObject.StartTime) / segmentTime); return curveData.RepeatSamples[index]; } } diff --git a/osu.Game.Rulesets.Mania/Beatmaps/ObjectConversion.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs similarity index 59% rename from osu.Game.Rulesets.Mania/Beatmaps/ObjectConversion.cs rename to osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs index 83c0af9d46..ad07c03b96 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/ObjectConversion.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs @@ -1,42 +1,39 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK; -using osu.Game.Beatmaps; -using osu.Game.Rulesets.Mania.MathUtils; using System; using System.Linq; +using osu.Game.Beatmaps; using osu.Game.Database; -using osu.Game.Rulesets.Mania.Objects; +using osu.Game.Rulesets.Mania.MathUtils; using osu.Game.Rulesets.Objects; +using OpenTK; -namespace osu.Game.Rulesets.Mania.Beatmaps +namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy { - internal abstract class ObjectConversion + /// + /// A pattern generator for legacy hit objects. + /// + internal abstract class PatternGenerator : Patterns.PatternGenerator { - protected readonly int AvailableColumns; + /// + /// The column index at which to start generating random notes. + /// protected readonly int RandomStart; - protected ObjectList PreviousObjects; + /// + /// The random number generator to use. + /// protected readonly FastRandom Random; - protected readonly Beatmap Beatmap; - protected ObjectConversion(ObjectList previousObjects, FastRandom random, Beatmap beatmap) + protected PatternGenerator(FastRandom random, HitObject hitObject, Beatmap beatmap, Pattern previousPattern) + : base(hitObject, beatmap, previousPattern) { - PreviousObjects = previousObjects; Random = random; - Beatmap = beatmap; - AvailableColumns = (int)Math.Round(beatmap.BeatmapInfo.Difficulty.CircleSize); RandomStart = AvailableColumns == 8 ? 1 : 0; } - /// - /// Generates a new object list filled with converted hit objects. - /// - /// The containing the hit objects. - public abstract ObjectList Generate(); - /// /// Converts an x-position into a column. /// @@ -78,44 +75,6 @@ namespace osu.Game.Rulesets.Mania.Beatmaps return val >= 1 - p2 ? 2 : 1; } - /// - /// Constructs and adds a note to an object list. - /// - /// The list to add to. - /// The original hit object (used for samples). - /// The column to add the note to. - /// The start time of the note. - /// The end time of the note (set to for a non-hold note). - /// The number of children alongside this note (these will not be generated, but are used for volume calculations). - protected void Add(ObjectList objectList, HitObject originalObject, int column, double startTime, double endTime, int siblings = 1) - { - ManiaHitObject newObject; - - if (startTime == endTime) - { - newObject = new Note - { - StartTime = startTime, - Samples = originalObject.Samples, - Column = column - }; - } - else - { - newObject = new HoldNote - { - StartTime = startTime, - Samples = originalObject.Samples, - Column = column, - Duration = endTime - startTime - }; - } - - // Todo: Consider siblings and write sample volumes (probably at ManiaHitObject level) - - objectList.Add(newObject); - } - private double? conversionDifficulty; /// /// A difficulty factor used for various conversion methods from osu!stable. diff --git a/osu.Game.Rulesets.Mania/Beatmaps/LegacyConvertType.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternType.cs similarity index 85% rename from osu.Game.Rulesets.Mania/Beatmaps/LegacyConvertType.cs rename to osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternType.cs index 086bc89292..d4957d41a9 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/LegacyConvertType.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternType.cs @@ -3,10 +3,13 @@ using System; -namespace osu.Game.Rulesets.Mania.Beatmaps +namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy { + /// + /// The type of pattern to generate. Used for legacy patterns. + /// [Flags] - internal enum LegacyConvertType + internal enum PatternType { None = 0, /// diff --git a/osu.Game.Rulesets.Mania/Beatmaps/ObjectList.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Pattern.cs similarity index 62% rename from osu.Game.Rulesets.Mania/Beatmaps/ObjectList.cs rename to osu.Game.Rulesets.Mania/Beatmaps/Patterns/Pattern.cs index 13bb32a113..cbde1f0f53 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/ObjectList.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Pattern.cs @@ -1,56 +1,59 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using osu.Framework.Extensions.IEnumerableExtensions; -using osu.Game.Rulesets.Mania.Objects; using System.Collections.Generic; using System.Linq; +using osu.Framework.Extensions.IEnumerableExtensions; +using osu.Game.Rulesets.Mania.Objects; -namespace osu.Game.Rulesets.Mania.Beatmaps +namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns { - internal class ObjectList + /// + /// Creates a pattern containing hit objects. + /// + internal class Pattern { private readonly List hitObjects = new List(); /// - /// All the hit objects contained in this list. + /// All the hit objects contained in this pattern. /// public IEnumerable HitObjects => hitObjects; /// - /// Whether a column of this list has been taken. + /// Whether this pattern already contains a hit object in a code. /// /// The column index. - /// Whether the column already contains a hit object. + /// Whether this pattern already contains a hit object in public bool IsFilled(int column) => hitObjects.Exists(h => h.Column == column); /// - /// Amount of columns taken up by hit objects in this list. + /// Amount of columns taken up by hit objects in this pattern. /// public int ColumnsFilled => HitObjects.GroupBy(h => h.Column).Count(); /// - /// Adds a hit object to this list. + /// Adds a hit object to this pattern. /// /// The hit object to add. public void Add(ManiaHitObject hitObject) => hitObjects.Add(hitObject); /// - /// Copies hit object from another list to this one. + /// Copies hit object from another pattern to this one. /// - /// The other list. - public void Add(ObjectList other) + /// The other pattern. + public void Add(Pattern other) { other.HitObjects.ForEach(Add); } /// - /// Clears this list. + /// Clears this pattern, removing all hit objects. /// public void Clear() => hitObjects.Clear(); /// - /// Removes a hit object from this list. + /// Removes a hit object from this pattern. /// /// The hit object to remove. public bool Remove(ManiaHitObject hitObject) => hitObjects.Remove(hitObject); diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs new file mode 100644 index 0000000000..81aeb48c01 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs @@ -0,0 +1,89 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using osu.Game.Beatmaps; +using osu.Game.Rulesets.Mania.Objects; +using osu.Game.Rulesets.Objects; + +namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns +{ + /// + /// Generator to create a pattern from a hit object. + /// + internal abstract class PatternGenerator + { + /// + /// The number of columns available to create the pattern. + /// + protected readonly int AvailableColumns; + + /// + /// The last pattern. + /// + protected readonly Pattern PreviousPattern; + + /// + /// The hit object to create the pattern for. + /// + protected readonly HitObject HitObject; + + /// + /// The beatmap which is a part of. + /// + protected readonly Beatmap Beatmap; + + protected PatternGenerator(HitObject hitObject, Beatmap beatmap, Pattern previousPattern) + { + PreviousPattern = previousPattern; + HitObject = hitObject; + Beatmap = beatmap; + + AvailableColumns = (int)Math.Round(beatmap.BeatmapInfo.Difficulty.CircleSize); + } + + /// + /// Generates the pattern for , filled with hit objects. + /// + /// The containing the hit objects. + public abstract Pattern Generate(); + + /// + /// Constructs and adds a note to a pattern. + /// + /// The pattern to add to. + /// The original hit object (used for samples). + /// The column to add the note to. + /// The start time of the note. + /// The end time of the note (set to for a non-hold note). + /// The number of children alongside this note (these will not be generated, but are used for volume calculations). + protected void AddToPattern(Pattern pattern, HitObject originalObject, int column, double startTime, double endTime, int siblings = 1) + { + ManiaHitObject newObject; + + if (startTime == endTime) + { + newObject = new Note + { + StartTime = startTime, + Samples = originalObject.Samples, + Column = column + }; + } + else + { + newObject = new HoldNote + { + StartTime = startTime, + Samples = originalObject.Samples, + Column = column, + Duration = endTime - startTime + }; + } + + // Todo: Consider siblings and write sample volumes (probably at ManiaHitObject level) + + pattern.Add(newObject); + } + } +} diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index 3d93dd3068..9de9cd703f 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -47,12 +47,13 @@ - - - - + + + + + - + From 164a1bb743f9c8bbf7ec2998199a0b431259fa9b Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 18 May 2017 15:35:16 +0900 Subject: [PATCH 282/329] Remove distance object pattern generator for now (next PR). --- .../Beatmaps/LegacyBeatmapConverter.cs | 16 +- .../Legacy/DistanceObjectPatternGenerator.cs | 463 ------------------ .../osu.Game.Rulesets.Mania.csproj | 1 - 3 files changed, 3 insertions(+), 477 deletions(-) delete mode 100644 osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs diff --git a/osu.Game.Rulesets.Mania/Beatmaps/LegacyBeatmapConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/LegacyBeatmapConverter.cs index 4108ba7809..4a98751b9d 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/LegacyBeatmapConverter.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/LegacyBeatmapConverter.cs @@ -4,8 +4,6 @@ using System; using System.Collections.Generic; using osu.Game.Beatmaps; -using osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy; -using osu.Game.Rulesets.Mania.MathUtils; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Types; @@ -18,10 +16,6 @@ namespace osu.Game.Rulesets.Mania.Beatmaps /// internal class LegacyBeatmapConverter { - private readonly FastRandom random; - - private Patterns.Pattern lastPattern = new Patterns.Pattern(); - private readonly int availableColumns; private readonly float localXDivisor; @@ -31,10 +25,6 @@ namespace osu.Game.Rulesets.Mania.Beatmaps { this.beatmap = beatmap; - int seed = (int)Math.Round(beatmap.BeatmapInfo.Difficulty.DrainRate + beatmap.BeatmapInfo.Difficulty.CircleSize) - * 20 + (int)(beatmap.BeatmapInfo.Difficulty.OverallDifficulty * 41.2) + (int)Math.Round(beatmap.BeatmapInfo.Difficulty.ApproachRate); - random = new FastRandom(seed); - availableColumns = (int)Math.Round(beatmap.BeatmapInfo.Difficulty.CircleSize); localXDivisor = 512.0f / availableColumns; } @@ -97,7 +87,9 @@ namespace osu.Game.Rulesets.Mania.Beatmaps Patterns.PatternGenerator conversion = null; if (distanceData != null) - conversion = new DistanceObjectPatternGenerator(random, original, beatmap, lastPattern); + { + // Slider + } else if (endTimeData != null) { // Spinner @@ -114,8 +106,6 @@ namespace osu.Game.Rulesets.Mania.Beatmaps foreach (ManiaHitObject obj in newPattern.HitObjects) yield return obj; - - lastPattern = newPattern; } private int getColumn(float position) => MathHelper.Clamp((int)Math.Floor(position / localXDivisor), 0, availableColumns - 1); diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs deleted file mode 100644 index 03240a2be4..0000000000 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs +++ /dev/null @@ -1,463 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using System; -using System.Linq; -using osu.Game.Audio; -using osu.Game.Beatmaps; -using osu.Game.Beatmaps.Timing; -using osu.Game.Rulesets.Mania.MathUtils; -using osu.Game.Rulesets.Objects; -using osu.Game.Rulesets.Objects.Types; - -namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy -{ - /// - /// A pattern generator for IHasDistance hit objects. - /// - internal class DistanceObjectPatternGenerator : PatternGenerator - { - /// - /// Base osu! slider scoring distance. - /// - private const float osu_base_scoring_distance = 100; - - private readonly double endTime; - private readonly int repeatCount; - - private PatternType convertType; - - public DistanceObjectPatternGenerator(FastRandom random, HitObject hitObject, Beatmap beatmap, Pattern previousPattern) - : base(random, hitObject, beatmap, previousPattern) - { - ControlPoint overridePoint; - ControlPoint controlPoint = Beatmap.TimingInfo.TimingPointAt(hitObject.StartTime, out overridePoint); - - convertType = PatternType.None; - if ((overridePoint ?? controlPoint)?.KiaiMode == false) - convertType = PatternType.LowProbability; - - var distanceData = hitObject as IHasDistance; - var repeatsData = hitObject as IHasRepeats; - - repeatCount = repeatsData?.RepeatCount ?? 1; - - double speedAdjustment = beatmap.TimingInfo.SpeedMultiplierAt(hitObject.StartTime); - double speedAdjustedBeatLength = beatmap.TimingInfo.BeatLengthAt(hitObject.StartTime) * speedAdjustment; - - // The true distance, accounting for any repeats. This ends up being the drum roll distance later - double distance = distanceData.Distance * repeatCount; - - // The velocity of the osu! hit object - calculated as the velocity of a slider - double osuVelocity = osu_base_scoring_distance * beatmap.BeatmapInfo.Difficulty.SliderMultiplier / speedAdjustedBeatLength; - // The duration of the osu! hit object - double osuDuration = distance / osuVelocity; - - endTime = hitObject.StartTime + osuDuration; - } - - public override Pattern Generate() - { - double segmentDuration = endTime / repeatCount; - - if (repeatCount > 1) - { - if (segmentDuration <= 90) - return generateRandomHoldNotes(HitObject.StartTime, endTime, 1); - - if (segmentDuration <= 120) - { - convertType |= PatternType.ForceNotStack; - return generateRandomNotes(HitObject.StartTime, segmentDuration, repeatCount); - } - - if (segmentDuration <= 160) - return generateStair(HitObject.StartTime, segmentDuration); - - if (segmentDuration <= 200 && ConversionDifficulty > 3) - return generateRandomMultipleNotes(HitObject.StartTime, segmentDuration, repeatCount); - - double duration = endTime - HitObject.StartTime; - if (duration >= 4000) - return generateNRandomNotes(HitObject.StartTime, endTime, 0.23, 0, 0); - - if (segmentDuration > 400 && duration < 4000 && repeatCount < AvailableColumns - 1 - RandomStart) - return generateTiledHoldNotes(HitObject.StartTime, segmentDuration, repeatCount); - - return generateHoldAndNormalNotes(HitObject.StartTime, segmentDuration); - } - - if (segmentDuration <= 110) - { - if (PreviousPattern.ColumnsFilled < AvailableColumns) - convertType |= PatternType.ForceNotStack; - else - convertType &= ~PatternType.ForceNotStack; - return generateRandomNotes(HitObject.StartTime, segmentDuration, segmentDuration < 80 ? 0 : 1); - } - - if (ConversionDifficulty > 6.5) - { - if ((convertType & PatternType.LowProbability) > 0) - return generateNRandomNotes(HitObject.StartTime, endTime, 0.78, 0.3, 0); - return generateNRandomNotes(HitObject.StartTime, endTime, 0.85, 0.36, 0.03); - } - - if (ConversionDifficulty > 4) - { - if ((convertType & PatternType.LowProbability) > 0) - return generateNRandomNotes(HitObject.StartTime, endTime, 0.43, 0.08, 0); - return generateNRandomNotes(HitObject.StartTime, endTime, 0.56, 0.18, 0); - } - - if (ConversionDifficulty > 2.5) - { - if ((convertType & PatternType.LowProbability) > 0) - return generateNRandomNotes(HitObject.StartTime, endTime, 0.3, 0, 0); - return generateNRandomNotes(HitObject.StartTime, endTime, 0.37, 0.08, 0); - } - - if ((convertType & PatternType.LowProbability) > 0) - return generateNRandomNotes(HitObject.StartTime, endTime, 0.17, 0, 0); - return generateNRandomNotes(HitObject.StartTime, endTime, 0.27, 0, 0); - } - - /// - /// Generates random hold notes that start at an span the same amount of rows. - /// - /// Start time of each hold note. - /// End time of the hold notes. - /// Number of hold notes. - /// The containing the hit objects. - private Pattern generateRandomHoldNotes(double startTime, double endTime, int noteCount) - { - // - - - - - // ■ - ■ ■ - // □ - □ □ - // ■ - ■ ■ - - var pattern = new Pattern(); - - int usableColumns = AvailableColumns - RandomStart - PreviousPattern.ColumnsFilled; - int nextColumn = Random.Next(RandomStart, AvailableColumns); - for (int i = 0; i < Math.Min(usableColumns, noteCount); i++) - { - while (pattern.IsFilled(nextColumn) || PreviousPattern.IsFilled(nextColumn)) //find available column - nextColumn = Random.Next(RandomStart, AvailableColumns); - AddToPattern(pattern, HitObject, nextColumn, startTime, endTime, noteCount); - } - - // This is can't be combined with the above loop due to RNG - for (int i = 0; i < noteCount - usableColumns; i++) - { - while (pattern.IsFilled(nextColumn)) - nextColumn = Random.Next(RandomStart, AvailableColumns); - AddToPattern(pattern, HitObject, nextColumn, startTime, endTime, noteCount); - } - - return pattern; - } - - /// - /// Generates random notes, with one note per row and no stacking. - /// - /// The start time. - /// The separation of notes between rows. - /// The number of rows. - /// The containing the hit objects. - private Pattern generateRandomNotes(double startTime, double separationTime, int repeatCount) - { - // - - - - - // x - - - - // - - x - - // - - - x - // x - - - - - var pattern = new Pattern(); - - int nextColumn = GetColumn((HitObject as IHasXPosition)?.X ?? 0, true); - if ((convertType & PatternType.ForceNotStack) > 0 && PreviousPattern.ColumnsFilled < AvailableColumns) - { - while (PreviousPattern.IsFilled(nextColumn)) - nextColumn = Random.Next(RandomStart, AvailableColumns); - } - - int lastColumn = nextColumn; - for (int i = 0; i <= repeatCount; i++) - { - AddToPattern(pattern, HitObject, nextColumn, startTime, startTime); - while (nextColumn == lastColumn) - nextColumn = Random.Next(RandomStart, AvailableColumns); - - lastColumn = nextColumn; - startTime += separationTime; - } - - return pattern; - } - - /// - /// Generates a stair of notes, with one note per row. - /// - /// The start time. - /// The separation of notes between rows. - /// The containing the hit objects. - private Pattern generateStair(double startTime, double separationTime) - { - // - - - - - // x - - - - // - x - - - // - - x - - // - - - x - // - - x - - // - x - - - // x - - - - - var pattern = new Pattern(); - - int column = GetColumn((HitObject as IHasXPosition)?.X ?? 0, true); - bool increasing = Random.NextDouble() > 0.5; - - for (int i = 0; i <= repeatCount; i++) - { - AddToPattern(pattern, HitObject, column, startTime, startTime); - startTime += separationTime; - - // Check if we're at the borders of the stage, and invert the pattern if so - if (increasing) - { - if (column >= AvailableColumns - 1) - { - increasing = false; - column--; - } - else - column++; - } - else - { - if (column <= RandomStart) - { - increasing = true; - column++; - } - else - column--; - } - } - - return pattern; - } - - /// - /// Generates random notes with 1-2 notes per row and no stacking. - /// - /// The start time. - /// The separation of notes between rows. - /// The number of rows. - /// The containing the hit objects. - private Pattern generateRandomMultipleNotes(double startTime, double separationTime, int repeatCount) - { - // - - - - - // x - - - // - x x - - // - - - x - // x - x - - - var pattern = new Pattern(); - - bool legacy = AvailableColumns >= 4 && AvailableColumns <= 8; - int interval = Random.Next(1, AvailableColumns - (legacy ? 1 : 0)); - - int nextColumn = GetColumn((HitObject as IHasXPosition)?.X ?? 0, true); - for (int i = 0; i <= repeatCount; i++) - { - AddToPattern(pattern, HitObject, nextColumn, startTime, startTime, 2); - - nextColumn += interval; - if (nextColumn >= AvailableColumns - RandomStart) - nextColumn = nextColumn - AvailableColumns - RandomStart + (legacy ? 1 : 0); - nextColumn += RandomStart; - - // If we're in 2K, let's not add many consecutive doubles - if (AvailableColumns > 2) - AddToPattern(pattern, HitObject, nextColumn, startTime, startTime, 2); - - nextColumn = Random.Next(RandomStart, AvailableColumns); - startTime += separationTime; - } - - return pattern; - } - - /// - /// Generates random hold notes. The amount of hold notes generated is determined by probabilities. - /// - /// The hold note start time. - /// The hold note end time. - /// The probability required for 2 hold notes to be generated. - /// The probability required for 3 hold notes to be generated. - /// The probability required for 4 hold notes to be generated. - /// The containing the hit objects. - private Pattern generateNRandomNotes(double startTime, double endTime, double p2, double p3, double p4) - { - // - - - - - // ■ - ■ ■ - // □ - □ □ - // ■ - ■ ■ - - switch (AvailableColumns) - { - case 2: - p2 = 0; - p3 = 0; - p4 = 0; - break; - case 3: - p2 = Math.Max(p2, 0.1); - p3 = 0; - p4 = 0; - break; - case 4: - p2 = Math.Max(p2, 0.3); - p3 = Math.Max(p3, 0.04); - p4 = 0; - break; - case 5: - p2 = Math.Max(p2, 0.34); - p3 = Math.Max(p3, 0.1); - p4 = Math.Max(p4, 0.03); - break; - } - - Func isDoubleSample = sample => sample.Name == SampleInfo.HIT_CLAP && sample.Name == SampleInfo.HIT_FINISH; - - bool canGenerateTwoNotes = (convertType & PatternType.LowProbability) == 0; - canGenerateTwoNotes &= HitObject.Samples.Any(isDoubleSample) || sampleInfoListAt(HitObject.StartTime).Any(isDoubleSample); - - if (canGenerateTwoNotes) - p2 = 1; - - return generateRandomHoldNotes(startTime, endTime, GetRandomNoteCount(p2, p3, p4)); - } - - /// - /// Generates tiled hold notes. You can think of this as a stair of hold notes. - /// - /// The first hold note start time. - /// The separation time between hold notes. - /// The amount of hold notes. - /// The containing the hit objects. - private Pattern generateTiledHoldNotes(double startTime, double separationTime, int noteCount) - { - // - - - - - // ■ ■ ■ ■ - // □ □ □ □ - // □ □ □ □ - // □ □ □ ■ - // □ □ ■ - - // □ ■ - - - // ■ - - - - - var pattern = new Pattern(); - - int columnRepeat = Math.Min(noteCount, AvailableColumns); - - int nextColumn = GetColumn((HitObject as IHasXPosition)?.X ?? 0, true); - if ((convertType & PatternType.ForceNotStack) > 0 && PreviousPattern.ColumnsFilled < AvailableColumns) - { - while (PreviousPattern.IsFilled(nextColumn)) - nextColumn = Random.Next(RandomStart, AvailableColumns); - } - - for (int i = 0; i < columnRepeat; i++) - { - while (pattern.IsFilled(nextColumn)) - nextColumn = Random.Next(RandomStart, AvailableColumns); - - AddToPattern(pattern, HitObject, nextColumn, startTime, endTime, noteCount); - startTime += separationTime; - } - - return pattern; - } - - /// - /// Generates a hold note alongside normal notes. - /// - /// The start time of notes. - /// The separation time between notes. - /// The containing the hit objects. - private Pattern generateHoldAndNormalNotes(double startTime, double separationTime) - { - // - - - - - // ■ x x - - // ■ - x x - // ■ x - x - // ■ - x x - - var pattern = new Pattern(); - - int holdColumn = GetColumn((HitObject as IHasXPosition)?.X ?? 0, true); - if ((convertType & PatternType.ForceNotStack) > 0 && PreviousPattern.ColumnsFilled < AvailableColumns) - { - while (PreviousPattern.IsFilled(holdColumn)) - holdColumn = Random.Next(RandomStart, AvailableColumns); - } - - // Create the hold note - AddToPattern(pattern, HitObject, holdColumn, startTime, separationTime * repeatCount); - - int noteCount = 1; - if (ConversionDifficulty > 6.5) - noteCount = GetRandomNoteCount(0.63, 0); - else if (ConversionDifficulty > 4) - noteCount = GetRandomNoteCount(AvailableColumns < 6 ? 0.12 : 0.45, 0); - else if (ConversionDifficulty > 2.5) - noteCount = GetRandomNoteCount(AvailableColumns < 6 ? 0 : 0.24, 0); - noteCount = Math.Min(AvailableColumns - 1, noteCount); - - bool ignoreHead = !sampleInfoListAt(startTime).Any(s => s.Name == SampleInfo.HIT_WHISTLE || s.Name == SampleInfo.HIT_FINISH || s.Name == SampleInfo.HIT_CLAP); - int nextColumn = Random.Next(RandomStart, AvailableColumns); - - var rowPattern = new Pattern(); - for (int i = 0; i <= repeatCount; i++) - { - if (!(ignoreHead && startTime == HitObject.StartTime)) - { - for (int j = 0; j < noteCount; j++) - { - while (rowPattern.IsFilled(nextColumn) || nextColumn == holdColumn) - nextColumn = Random.Next(RandomStart, AvailableColumns); - AddToPattern(rowPattern, HitObject, nextColumn, startTime, startTime, noteCount + 1); - } - } - - pattern.Add(rowPattern); - rowPattern.Clear(); - - startTime += separationTime; - } - - return pattern; - } - - /// - /// Retrieves the sample info list at a point in time. - /// - /// The time to retrieve the sample info list from. - /// - private SampleInfoList sampleInfoListAt(double time) - { - var curveData = HitObject as IHasCurve; - - if (curveData == null) - return HitObject.Samples; - - double segmentTime = (curveData.EndTime - HitObject.StartTime) / repeatCount; - - int index = (int)(segmentTime == 0 ? 0 : (time - HitObject.StartTime) / segmentTime); - return curveData.RepeatSamples[index]; - } - } -} diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index 9de9cd703f..ea65588a81 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -47,7 +47,6 @@ - From af34777f44b93c4c23e2214dd352f2b6647ed8d6 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 18 May 2017 17:00:11 +0900 Subject: [PATCH 283/329] Trim whitespace. --- osu.Game.Rulesets.Mania/Beatmaps/LegacyBeatmapConverter.cs | 2 +- osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/LegacyBeatmapConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/LegacyBeatmapConverter.cs index 4a98751b9d..ceb83be7ca 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/LegacyBeatmapConverter.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/LegacyBeatmapConverter.cs @@ -17,7 +17,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps internal class LegacyBeatmapConverter { private readonly int availableColumns; - private readonly float localXDivisor; + private readonly float localXDivisor; private readonly Beatmap beatmap; diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs index 81aeb48c01..6ccd39c6ac 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs @@ -27,7 +27,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns /// The hit object to create the pattern for. /// protected readonly HitObject HitObject; - + /// /// The beatmap which is a part of. /// From 873ff344874d16bcf7494450ba0a7b13e5b9022c Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 18 May 2017 17:43:59 +0900 Subject: [PATCH 284/329] This function can't be used for all pattern generations. So let's not use it. --- .../Beatmaps/Patterns/PatternGenerator.cs | 38 ------------------- 1 file changed, 38 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs index 6ccd39c6ac..558d64080b 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs @@ -47,43 +47,5 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns /// /// The containing the hit objects. public abstract Pattern Generate(); - - /// - /// Constructs and adds a note to a pattern. - /// - /// The pattern to add to. - /// The original hit object (used for samples). - /// The column to add the note to. - /// The start time of the note. - /// The end time of the note (set to for a non-hold note). - /// The number of children alongside this note (these will not be generated, but are used for volume calculations). - protected void AddToPattern(Pattern pattern, HitObject originalObject, int column, double startTime, double endTime, int siblings = 1) - { - ManiaHitObject newObject; - - if (startTime == endTime) - { - newObject = new Note - { - StartTime = startTime, - Samples = originalObject.Samples, - Column = column - }; - } - else - { - newObject = new HoldNote - { - StartTime = startTime, - Samples = originalObject.Samples, - Column = column, - Duration = endTime - startTime - }; - } - - // Todo: Consider siblings and write sample volumes (probably at ManiaHitObject level) - - pattern.Add(newObject); - } } } From afd3eb4b8d53e020d1b971c4cd76d234fd0c683a Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 18 May 2017 18:04:32 +0900 Subject: [PATCH 285/329] Implement things a bit more to remove warnings. --- .../Beatmaps/LegacyBeatmapConverter.cs | 113 +++++++++++------- .../Beatmaps/Patterns/PatternGenerator.cs | 1 - osu.Game/Beatmaps/Events/EventInfo.cs | 7 ++ 3 files changed, 78 insertions(+), 43 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/LegacyBeatmapConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/LegacyBeatmapConverter.cs index ceb83be7ca..3aa88af62d 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/LegacyBeatmapConverter.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/LegacyBeatmapConverter.cs @@ -7,7 +7,8 @@ using osu.Game.Beatmaps; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Types; -using OpenTK; +using osu.Game.Rulesets.Mania.Beatmaps.Patterns; +using osu.Game.Rulesets.Mania.MathUtils; namespace osu.Game.Rulesets.Mania.Beatmaps { @@ -16,17 +17,18 @@ namespace osu.Game.Rulesets.Mania.Beatmaps /// internal class LegacyBeatmapConverter { - private readonly int availableColumns; - private readonly float localXDivisor; + private Pattern lastPattern = new Pattern(); + private readonly FastRandom random; private readonly Beatmap beatmap; public LegacyBeatmapConverter(Beatmap beatmap) { this.beatmap = beatmap; - availableColumns = (int)Math.Round(beatmap.BeatmapInfo.Difficulty.CircleSize); - localXDivisor = 512.0f / availableColumns; + int seed = (int)Math.Round(beatmap.BeatmapInfo.Difficulty.DrainRate + beatmap.BeatmapInfo.Difficulty.CircleSize) + * 20 + (int)(beatmap.BeatmapInfo.Difficulty.OverallDifficulty * 41.2) + (int)Math.Round(beatmap.BeatmapInfo.Difficulty.ApproachRate); + random = new FastRandom(seed); } public IEnumerable Convert(HitObject original) @@ -38,44 +40,32 @@ namespace osu.Game.Rulesets.Mania.Beatmaps yield break; } - if (beatmap.BeatmapInfo.RulesetID == 3) - yield return generateSpecific(original); - else + IEnumerable objects = null; + switch (beatmap.BeatmapInfo.RulesetID) { - foreach (ManiaHitObject c in generateConverted(original)) - yield return c; + default: + objects = generateConverted(original); + break; + case 3: + objects = generateSpecific(original); + break; } + + if (objects == null) + yield break; + + foreach (ManiaHitObject obj in objects) + yield return obj; } - private ManiaHitObject generateSpecific(HitObject original) + private IEnumerable generateSpecific(HitObject original) { - var endTimeData = original as IHasEndTime; - var positionData = original as IHasXPosition; + var generator = new SpecificPatternGenerator(random, original, beatmap, lastPattern); - int column = getColumn(positionData?.X ?? 0); + Pattern newPattern = generator.Generate(); + lastPattern = newPattern; - if (endTimeData != null) - { - return new HoldNote - { - StartTime = original.StartTime, - Samples = original.Samples, - Duration = endTimeData.Duration, - Column = column, - }; - } - - if (positionData != null) - { - return new Note - { - StartTime = original.StartTime, - Samples = original.Samples, - Column = column - }; - } - - return null; + return newPattern.HitObjects; } private IEnumerable generateConverted(HitObject original) @@ -84,7 +74,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps var distanceData = original as IHasDistance; var positionData = original as IHasPosition; - Patterns.PatternGenerator conversion = null; + PatternGenerator conversion = null; if (distanceData != null) { @@ -100,14 +90,53 @@ namespace osu.Game.Rulesets.Mania.Beatmaps } if (conversion == null) - yield break; + return new ManiaHitObject[0]; - Patterns.Pattern newPattern = conversion.Generate(); + Pattern newPattern = conversion.Generate(); + lastPattern = newPattern; - foreach (ManiaHitObject obj in newPattern.HitObjects) - yield return obj; + return newPattern.HitObjects; } - private int getColumn(float position) => MathHelper.Clamp((int)Math.Floor(position / localXDivisor), 0, availableColumns - 1); + /// + /// A pattern generator for mania-specific beatmaps. + /// + private class SpecificPatternGenerator : Patterns.Legacy.PatternGenerator + { + public SpecificPatternGenerator(FastRandom random, HitObject hitObject, Beatmap beatmap, Pattern previousPattern) + : base(random, hitObject, beatmap, previousPattern) + { + } + + public override Pattern Generate() + { + var endTimeData = HitObject as IHasEndTime; + var positionData = HitObject as IHasXPosition; + + var pattern = new Pattern(); + + if (endTimeData != null) + { + pattern.Add(new HoldNote + { + StartTime = HitObject.StartTime, + Samples = HitObject.Samples, + Duration = endTimeData.Duration, + Column = GetColumn(positionData?.X ?? 0), + }); + } + else if (positionData != null) + { + pattern.Add(new Note + { + StartTime = HitObject.StartTime, + Samples = HitObject.Samples, + Column = GetColumn(positionData?.X ?? 0) + }); + } + + return pattern; + } + } } } diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs index 558d64080b..dda4d07182 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs @@ -3,7 +3,6 @@ using System; using osu.Game.Beatmaps; -using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Objects; namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns diff --git a/osu.Game/Beatmaps/Events/EventInfo.cs b/osu.Game/Beatmaps/Events/EventInfo.cs index 646dea898e..3ba3d5ba03 100644 --- a/osu.Game/Beatmaps/Events/EventInfo.cs +++ b/osu.Game/Beatmaps/Events/EventInfo.cs @@ -22,5 +22,12 @@ namespace osu.Game.Beatmaps.Events /// Total duration of all breaks. /// public double TotalBreakTime => Breaks.Sum(b => b.Duration); + + /// + /// Retrieves the active background at a time. + /// + /// The time to retrieve the background at. + /// The background. + public BackgroundEvent BackgroundAt(double time) => Backgrounds.FirstOrDefault(b => b.StartTime <= time); } } From af129b3eaba1233654e87b6de4185876933ba033 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 18 May 2017 18:13:08 +0900 Subject: [PATCH 286/329] Add siblings, will be used in generator branches. --- osu.Game.Rulesets.Mania/Objects/ManiaHitObject.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/osu.Game.Rulesets.Mania/Objects/ManiaHitObject.cs b/osu.Game.Rulesets.Mania/Objects/ManiaHitObject.cs index 93aaa94f45..f6eb4aea2c 100644 --- a/osu.Game.Rulesets.Mania/Objects/ManiaHitObject.cs +++ b/osu.Game.Rulesets.Mania/Objects/ManiaHitObject.cs @@ -9,5 +9,11 @@ namespace osu.Game.Rulesets.Mania.Objects public abstract class ManiaHitObject : HitObject, IHasColumn { public int Column { get; set; } + + /// + /// The number of other that start at + /// the same time as this hit object. + /// + public int Siblings { get; set; } } } From c80e2e8f0a16840448874d861790db4ba59c765c Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 18 May 2017 18:46:50 +0900 Subject: [PATCH 287/329] Attempt to solve warnings... --- .../Beatmaps/LegacyBeatmapConverter.cs | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/LegacyBeatmapConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/LegacyBeatmapConverter.cs index 3aa88af62d..e3045df185 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/LegacyBeatmapConverter.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/LegacyBeatmapConverter.cs @@ -40,7 +40,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps yield break; } - IEnumerable objects = null; + IEnumerable objects; switch (beatmap.BeatmapInfo.RulesetID) { default: @@ -74,7 +74,9 @@ namespace osu.Game.Rulesets.Mania.Beatmaps var distanceData = original as IHasDistance; var positionData = original as IHasPosition; - PatternGenerator conversion = null; + // Following lines currently commented out to appease resharper + + //PatternGenerator conversion = null; if (distanceData != null) { @@ -89,13 +91,13 @@ namespace osu.Game.Rulesets.Mania.Beatmaps // Circle } - if (conversion == null) - return new ManiaHitObject[0]; + //if (conversion == null) + return null; - Pattern newPattern = conversion.Generate(); - lastPattern = newPattern; + //Pattern newPattern = conversion.Generate(); + //lastPattern = newPattern; - return newPattern.HitObjects; + //return newPattern.HitObjects; } /// @@ -113,6 +115,8 @@ namespace osu.Game.Rulesets.Mania.Beatmaps var endTimeData = HitObject as IHasEndTime; var positionData = HitObject as IHasXPosition; + int column = GetColumn(positionData?.X ?? 0); + var pattern = new Pattern(); if (endTimeData != null) @@ -122,7 +126,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps StartTime = HitObject.StartTime, Samples = HitObject.Samples, Duration = endTimeData.Duration, - Column = GetColumn(positionData?.X ?? 0), + Column = column, }); } else if (positionData != null) @@ -131,7 +135,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps { StartTime = HitObject.StartTime, Samples = HitObject.Samples, - Column = GetColumn(positionData?.X ?? 0) + Column = column }); } From 4e8ead9cf450e47713e39b16cf2050e59254cbe4 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 18 May 2017 19:05:03 +0900 Subject: [PATCH 288/329] Fix possible nullref. --- osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs index 3c31c6b854..b699758c3e 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs @@ -49,7 +49,7 @@ namespace osu.Game.Rulesets.Mania.UI return t; }); - double lastObjectTime = (Objects.Last() as IHasEndTime)?.EndTime ?? Objects.Last().StartTime; + double lastObjectTime = (Objects.LastOrDefault() as IHasEndTime)?.EndTime ?? Objects.LastOrDefault()?.StartTime ?? double.MaxValue; // Perform some post processing of the timing changes timingChanges = timingChanges From f112546085499eccd445624ad45f8ab8a064135b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 18 May 2017 19:39:40 +0900 Subject: [PATCH 289/329] Don't load a mode when opening TestCaseHitObjects --- osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs index dceb7a9cff..8c913ae95e 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs @@ -129,8 +129,6 @@ namespace osu.Desktop.VisualTests.Tests }; Add(clockAdjustContainer); - - load(mode); } private int depth; From 9cd41c0e87894a2c70db18ef539211eb5cfbe60d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 18 May 2017 19:40:20 +0900 Subject: [PATCH 290/329] Spinner design refresh --- .../Objects/Drawables/DrawableSpinner.cs | 138 ++++++++++++------ .../Objects/Drawables/Pieces/CirclePiece.cs | 1 - .../Drawables/Pieces/SpinnerBackground.cs | 46 +++++- .../Objects/Drawables/Pieces/SpinnerDisc.cs | 138 +++++------------- .../Objects/Drawables/Pieces/SpinnerTicks.cs | 71 +++++++++ .../osu.Game.Rulesets.Osu.csproj | 5 +- 6 files changed, 249 insertions(+), 150 deletions(-) create mode 100644 osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerTicks.cs diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs index a8ff231cc7..642f088445 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs @@ -1,15 +1,16 @@ // 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.Containers; -using osu.Framework.MathUtils; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces; using OpenTK; using OpenTK.Graphics; -using osu.Game.Rulesets.Osu.UI; +using osu.Game.Graphics; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Allocation; +using osu.Game.Screens.Ranking; namespace osu.Game.Rulesets.Osu.Objects.Drawables { @@ -18,9 +19,18 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables private readonly Spinner spinner; private readonly SpinnerDisc disc; + private readonly SpinnerTicks ticks; + + private readonly Container mainContainer; + private readonly SpinnerBackground background; private readonly Container circleContainer; - private readonly DrawableHitCircle circle; + private readonly CirclePiece circle; + + private readonly TextAwesome symbol; + + private Color4 normalColour; + private Color4 completeColour; public DrawableSpinner(Spinner s) : base(s) { @@ -29,57 +39,84 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables Origin = Anchor.Centre; Position = s.Position; - //take up full playfield. - Size = new Vector2(OsuPlayfield.BASE_SIZE.X); + RelativeSizeAxes = Axes.Both; + + // we are slightly bigger than our parent, to clip the top and bottom of the circle + Height = 1.2f; spinner = s; Children = new Drawable[] { - background = new SpinnerBackground - { - Alpha = 0, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - DiscColour = Color4.Black - }, - disc = new SpinnerDisc - { - Alpha = 0, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - DiscColour = AccentColour - }, circleContainer = new Container { AutoSizeAxes = Axes.Both, Anchor = Anchor.Centre, Origin = Anchor.Centre, - Children = new [] + Children = new Drawable[] { - circle = new DrawableHitCircle(s) + circle = new CirclePiece { - Interactive = false, Position = Vector2.Zero, Anchor = Anchor.Centre, + }, + new RingPiece(), + symbol = new TextAwesome + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + UseFullGlyphHeight = true, + TextSize = 48, + Icon = FontAwesome.fa_asterisk, + Shadow = false, } } - } + }, + mainContainer = new AspectContainer + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Y, + Children = new Drawable[] + { + background = new SpinnerBackground + { + Alpha = 0.2f, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + }, + disc = new SpinnerDisc(spinner) + { + Scale = Vector2.Zero, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + }, + circleContainer.CreateProxy(), + ticks = new SpinnerTicks + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + }, + } + }, }; - - background.Scale = scaleToCircle; - disc.Scale = scaleToCircle; } + public float Progress => MathHelper.Clamp(disc.RotationAbsolute / 360 / spinner.SpinsRequired, 0, 1); + protected override void CheckJudgement(bool userTriggered) { if (Time.Current < HitObject.StartTime) return; - disc.ScaleTo(Interpolation.ValueAt(Math.Sqrt(Progress), scaleToCircle, Vector2.One, 0, 1), 100); - - if (Progress >= 1) + if (Progress >= 1 && !disc.Complete) + { disc.Complete = true; + disc.FadeAccent(completeColour, 500); + background.FadeAccent(completeColour, 500); + circle.FadeColour(completeColour, 500); + } + if (!userTriggered && Time.Current >= spinner.EndTime) { if (Progress >= 1) @@ -106,26 +143,45 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables } } - private Vector2 scaleToCircle => circle.Scale * circle.DrawWidth / DrawWidth * 0.95f; + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + normalColour = colours.BlueDark; + completeColour = colours.YellowLight.Opacity(0.8f); - public float Progress => MathHelper.Clamp(disc.RotationAbsolute / 360 / spinner.SpinsRequired, 0, 1); + disc.AccentColour = normalColour; + background.AccentColour = normalColour; + circle.Colour = normalColour; + } + + protected override void UpdateAfterChildren() + { + base.UpdateAfterChildren(); + + circle.Rotation = disc.Rotation; + ticks.Rotation = disc.Rotation; + + float relativeCircleScale = spinner.Scale * circle.DrawHeight / mainContainer.DrawHeight; + disc.ScaleTo(relativeCircleScale + (1 - relativeCircleScale) * Progress, 200, EasingTypes.OutQuint); + + symbol.RotateTo(disc.Rotation / 2, 500, EasingTypes.OutQuint); + } protected override void UpdatePreemptState() { base.UpdatePreemptState(); - circleContainer.ScaleTo(1, 400, EasingTypes.OutElastic); + circleContainer.ScaleTo(spinner.Scale * 0.3f); + circleContainer.ScaleTo(spinner.Scale, TIME_PREEMPT / 1.4f, EasingTypes.OutQuint); - background.Delay(TIME_PREEMPT - 500); + disc.RotateTo(-720); + symbol.RotateTo(-720); - background.ScaleTo(scaleToCircle * 1.2f, 400, EasingTypes.OutQuint); - background.FadeIn(200); + mainContainer.ScaleTo(0); + mainContainer.ScaleTo(spinner.Scale * circle.DrawHeight / DrawHeight * 1.4f, TIME_PREEMPT - 150, EasingTypes.OutQuint); - background.Delay(400); - background.ScaleTo(1, 250, EasingTypes.OutQuint); - - disc.Delay(TIME_PREEMPT - 50); - disc.FadeIn(200); + mainContainer.Delay(TIME_PREEMPT - 150); + mainContainer.ScaleTo(1, 500, EasingTypes.OutQuint); } protected override void UpdateCurrentState(ArmedState state) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/CirclePiece.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/CirclePiece.cs index 9a90c07517..3004dafda7 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/CirclePiece.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/CirclePiece.cs @@ -16,7 +16,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces { private readonly Sprite disc; - public Func Hit; public CirclePiece() diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerBackground.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerBackground.cs index 72024bbe99..b3ce075575 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerBackground.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerBackground.cs @@ -1,10 +1,54 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using OpenTK.Graphics; +using osu.Framework.Allocation; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics; + namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces { - public class SpinnerBackground : SpinnerDisc + public class SpinnerBackground : CircularContainer, IHasAccentColour { public override bool HandleInput => false; + + protected Sprite Disc; + + public Color4 AccentColour + { + get { return Disc.Colour; } + set { Disc.Colour = value; } + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Glow, + Radius = 14, + Colour = colours.BlueLight.Opacity(0.3f), + }; + } + + public SpinnerBackground() + { + RelativeSizeAxes = Axes.Both; + Masking = true; + + Children = new Drawable[] + { + Disc = new Box + { + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + Alpha = 1, + }, + }; + } } } diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerDisc.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerDisc.cs index 71adba74c7..2d50754b4f 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerDisc.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerDisc.cs @@ -2,13 +2,8 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Linq; -using osu.Framework.Allocation; -using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; -using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transforms; using osu.Framework.Input; using osu.Game.Graphics; @@ -17,104 +12,31 @@ using OpenTK.Graphics; namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces { - public class SpinnerDisc : CircularContainer + public class SpinnerDisc : CircularContainer, IHasAccentColour { - protected Sprite Disc; + private readonly Spinner spinner; - public SRGBColour DiscColour + public Color4 AccentColour { - get { return Disc.Colour; } - set { Disc.Colour = value; } + get { return background.AccentColour; } + set { background.AccentColour = value; } } - private Color4 completeColour; + private readonly SpinnerBackground background; - [BackgroundDependencyLoader] - private void load(OsuColour colours) + private const float idle_alpha = 0.1f; + private const float tracking_alpha = 0.3f; + + public SpinnerDisc(Spinner s) { - completeColour = colours.YellowLight.Opacity(0.8f); - Masking = true; - } + spinner = s; - private class SpinnerBorder : Container - { - public SpinnerBorder() - { - Origin = Anchor.Centre; - Anchor = Anchor.Centre; - RelativeSizeAxes = Axes.Both; - - layout(); - } - - private int lastLayoutDotCount; - private void layout() - { - int count = (int)(MathHelper.Pi * ScreenSpaceDrawQuad.Width / 9); - - if (count == lastLayoutDotCount) return; - - lastLayoutDotCount = count; - - while (Children.Count() < count) - { - Add(new CircularContainer - { - Colour = Color4.White, - RelativePositionAxes = Axes.Both, - Masking = true, - Origin = Anchor.Centre, - Size = new Vector2(1 / ScreenSpaceDrawQuad.Width * 2000), - Children = new[] - { - new Box - { - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - RelativeSizeAxes = Axes.Both, - } - } - }); - } - - var size = new Vector2(1 / ScreenSpaceDrawQuad.Width * 2000); - - int i = 0; - foreach (var d in Children) - { - d.Size = size; - d.Position = new Vector2( - 0.5f + (float)Math.Sin((float)i / count * 2 * MathHelper.Pi) / 2, - 0.5f + (float)Math.Cos((float)i / count * 2 * MathHelper.Pi) / 2 - ); - - i++; - } - } - - protected override void Update() - { - base.Update(); - layout(); - } - } - - public SpinnerDisc() - { AlwaysReceiveInput = true; - RelativeSizeAxes = Axes.Both; Children = new Drawable[] { - Disc = new Box - { - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - RelativeSizeAxes = Axes.Both, - Alpha = 0.2f, - }, - new SpinnerBorder() + background = new SpinnerBackground { Alpha = idle_alpha }, }; } @@ -125,10 +47,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces set { if (value == tracking) return; - tracking = value; - Disc.FadeTo(tracking ? 0.5f : 0.2f, 100); + background.FadeTo(tracking ? tracking_alpha : idle_alpha, 100); } } @@ -139,31 +60,28 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces set { if (value == complete) return; - complete = value; - Disc.FadeColour(completeColour, 200); - updateCompleteTick(); } } protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) { - Tracking = true; + Tracking |= state.Mouse.HasMainButtonPressed; return base.OnMouseDown(state, args); } protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) { - Tracking = false; + Tracking &= state.Mouse.HasMainButtonPressed; return base.OnMouseUp(state, args); } protected override bool OnMouseMove(InputState state) { Tracking |= state.Mouse.HasMainButtonPressed; - mousePosition = state.Mouse.Position; + mousePosition = Parent.ToLocalSpace(state.Mouse.NativeState.Position); return base.OnMouseMove(state); } @@ -177,13 +95,24 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces private bool updateCompleteTick() => completeTick != (completeTick = (int)(RotationAbsolute / 360)); + private bool rotationTransferred; + protected override void Update() { base.Update(); var thisAngle = -(float)MathHelper.RadiansToDegrees(Math.Atan2(mousePosition.X - DrawSize.X / 2, mousePosition.Y - DrawSize.Y / 2)); - if (tracking) + + bool validAndTracking = tracking && spinner.StartTime <= Time.Current && spinner.EndTime > Time.Current; + + if (validAndTracking) { + if (!rotationTransferred) + { + currentRotation = Rotation * 2; + rotationTransferred = true; + } + if (thisAngle - lastAngle > 180) lastAngle += 360; else if (lastAngle - thisAngle > 180) @@ -192,17 +121,18 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces currentRotation += thisAngle - lastAngle; RotationAbsolute += Math.Abs(thisAngle - lastAngle); } + lastAngle = thisAngle; if (Complete && updateCompleteTick()) { - Disc.Flush(flushType: typeof(TransformAlpha)); - Disc.FadeTo(0.75f, 30, EasingTypes.OutExpo); - Disc.Delay(30); - Disc.FadeTo(0.5f, 250, EasingTypes.OutQuint); + background.Flush(flushType: typeof(TransformAlpha)); + background.FadeTo(0.75f, 60, EasingTypes.OutExpo); + background.Delay(60); + background.FadeTo(0.5f, 250, EasingTypes.OutQuint); } - RotateTo(currentRotation, 100, EasingTypes.OutExpo); + RotateTo(currentRotation / 2, validAndTracking ? 500 : 1500, EasingTypes.OutExpo); } } } diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerTicks.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerTicks.cs new file mode 100644 index 0000000000..d08051eed6 --- /dev/null +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerTicks.cs @@ -0,0 +1,71 @@ +// 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.Allocation; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics; +using OpenTK; +using OpenTK.Graphics; + +namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces +{ + public class SpinnerTicks : Container + { + private Color4 glowColour; + + public SpinnerTicks() + { + Origin = Anchor.Centre; + Anchor = Anchor.Centre; + RelativeSizeAxes = Axes.Both; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + glowColour = colours.BlueDarker.Opacity(0.4f); + layout(); + } + + private void layout() + { + const int count = 18; + + for (int i = 0; i < count; i++) + { + Add(new Container + { + Colour = Color4.Black, + Alpha = 0.4f, + EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Glow, + Radius = 20, + Colour = glowColour, + }, + RelativePositionAxes = Axes.Both, + Masking = true, + CornerRadius = 5, + Size = new Vector2(60, 10), + Origin = Anchor.Centre, + Position = new Vector2( + 0.5f + (float)Math.Sin((float)i / count * 2 * MathHelper.Pi) / 2 * 0.9f, + 0.5f + (float)Math.Cos((float)i / count * 2 * MathHelper.Pi) / 2 * 0.9f + ), + Rotation = -(float)i / count * 360 + 90, + Children = new[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + } + } + }); + } + } + } +} \ No newline at end of file diff --git a/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj b/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj index 8974b1bcbd..b91bdc6a78 100644 --- a/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj +++ b/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj @@ -64,6 +64,7 @@ + @@ -103,9 +104,7 @@ - - - +