diff --git a/.vscode/launch.json b/.vscode/launch.json index f1682a2ce2..b981556649 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -2,13 +2,25 @@ "version": "0.2.0", "configurations": [ { - "name": "Launch", + "name": "Launch VisualTests", "type": "mono", "request": "launch", "program": "${workspaceRoot}/osu.Desktop.VisualTests/bin/Debug/osu!.exe", "args": [], "cwd": "${workspaceRoot}", - "preLaunchTask": "", + "preLaunchTask": "build", + "runtimeExecutable": null, + "env": {}, + "externalConsole": false + }, + { + "name": "Launch Desktop", + "type": "mono", + "request": "launch", + "program": "${workspaceRoot}/osu.Desktop/bin/Debug/osu!.exe", + "args": [], + "cwd": "${workspaceRoot}", + "preLaunchTask": "build", "runtimeExecutable": null, "env": {}, "externalConsole": false diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md new file mode 100644 index 0000000000..ff930b07a3 --- /dev/null +++ b/ISSUE_TEMPLATE.md @@ -0,0 +1,9 @@ +osu!lazer is currently in early stages of development and is not yet ready for end users. Please avoid creating issues or bugs if you do not personally intend to fix them. Some acceptable topics include: + +- Discussions about technical design decisions +- Bugs that you have found and are personally willing and able to fix +- TODO lists of smaller tasks around larger features + +Basically, issues are not a place for you to get help. They are a place for developers to collaborate on the game. + +If your issue qualifies, replace this text with a detailed description of your issue with as much relevant information as you can provide. diff --git a/README.md b/README.md index 6b719f3140..885c7c7722 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,10 @@ Rhythm is just a *click* away. The future of osu! and the beginning of an open era! +# Status + +This is still heavily under development and is not intended for end-user use. This repository is intended for developer collaboration. You're welcome to try and use it but please do not submit bug reports without a patch. Please do not ask for help building or using this software. + # Requirements - A desktop platform which can compile .NET 4.5. diff --git a/osu-framework b/osu-framework index cea7e88cad..f2eec2adf5 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit cea7e88cad687a6a6613655ddd74be3f15bf49db +Subproject commit f2eec2adf590d60e91dda77de6f11d757ad6055f diff --git a/osu-resources b/osu-resources index e24414a277..7c42cf0a56 160000 --- a/osu-resources +++ b/osu-resources @@ -1 +1 @@ -Subproject commit e24414a277e407ae2438e4b6d9fa9c7992dd6485 +Subproject commit 7c42cf0a565ca125edcf335fabcb2ba3961d202d diff --git a/osu.Desktop.VisualTests/Tests/TestCaseKeyCounter.cs b/osu.Desktop.VisualTests/Tests/TestCaseKeyCounter.cs index f7cbc1252e..e83cda77ee 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseKeyCounter.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseKeyCounter.cs @@ -5,6 +5,14 @@ using osu.Framework.GameModes.Testing; using osu.Framework.Graphics; using osu.Game.Graphics.UserInterface; using OpenTK.Input; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.UserInterface; +using osu.Framework.Configuration; +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.MathUtils; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Transformations; namespace osu.Desktop.VisualTests.Tests { @@ -18,22 +26,68 @@ namespace osu.Desktop.VisualTests.Tests { base.Reset(); - Children = new[] + KeyCounterCollection kc = new KeyCounterCollection { - new KeyCounterCollection + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + IsCounting = true, + Children = new KeyCounter[] { - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - IsCounting = true, - Children = new KeyCounter[] - { - new KeyCounterKeyboard(@"Z", Key.Z), - new KeyCounterKeyboard(@"X", Key.X), - new KeyCounterMouse(@"M1", MouseButton.Left), - new KeyCounterMouse(@"M2", MouseButton.Right), - }, + new KeyCounterKeyboard(@"Z", Key.Z), + new KeyCounterKeyboard(@"X", Key.X), + new KeyCounterMouse(@"M1", MouseButton.Left), + new KeyCounterMouse(@"M2", MouseButton.Right), }, }; + BindableInt bindable = new BindableInt { MinValue = 0, MaxValue = 200, Default = 50 }; + bindable.ValueChanged += delegate { kc.FadeTime = bindable.Value; }; + AddButton("Add Random", () => + { + Key key = (Key)((int)Key.A + RNG.Next(26)); + kc.Add(new KeyCounterKeyboard(key.ToString(), key)); + }); + ButtonsContainer.Add(new SpriteText { Text = "FadeTime" }); + ButtonsContainer.Add(new TestSliderBar + { + Width = 150, + Height = 10, + SelectionColor = Color4.Orange, + Bindable = bindable + }); + Add(kc); + } + private class TestSliderBar : SliderBar where T : struct + { + public Color4 Color + { + get { return Box.Colour; } + set { Box.Colour = value; } + } + + public Color4 SelectionColor + { + get { return SelectionBox.Colour; } + set { SelectionBox.Colour = value; } + } + + protected readonly Box SelectionBox; + protected readonly Box Box; + + public TestSliderBar() + { + Children = new Drawable[] + { + Box = new Box { RelativeSizeAxes = Axes.Both }, + SelectionBox = new Box { RelativeSizeAxes = Axes.Both } + }; + } + + protected override void UpdateValue(float value) + { + SelectionBox.ScaleTo( + new Vector2(value, 1), + 300, EasingTypes.OutQuint); + } } } } diff --git a/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs b/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs index a291f4f65f..adfa2556a0 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs @@ -49,12 +49,12 @@ namespace osu.Desktop.VisualTests.Tests { return new BeatmapSetInfo { - BeatmapSetID = 1234 + i, + OnlineBeatmapSetID = 1234 + i, Hash = "d8e8fca2dc0f896fd7cb4cb0031ba249", Path = string.Empty, Metadata = new BeatmapMetadata { - BeatmapSetID = 1234 + i, + OnlineBeatmapSetID = 1234 + i, Artist = "MONACA", Title = "Black Song", Author = "Some Guy", @@ -63,7 +63,7 @@ namespace osu.Desktop.VisualTests.Tests { new BeatmapInfo { - BeatmapID = 1234 + i, + OnlineBeatmapID = 1234 + i, Mode = PlayMode.Osu, Path = "normal.osu", Version = "Normal", @@ -74,7 +74,7 @@ namespace osu.Desktop.VisualTests.Tests }, new BeatmapInfo { - BeatmapID = 1235 + i, + OnlineBeatmapID = 1235 + i, Mode = PlayMode.Osu, Path = "hard.osu", Version = "Hard", @@ -85,7 +85,7 @@ namespace osu.Desktop.VisualTests.Tests }, new BeatmapInfo { - BeatmapID = 1236 + i, + OnlineBeatmapID = 1236 + i, Mode = PlayMode.Osu, Path = "insane.osu", Version = "Insane", diff --git a/osu.Game.Modes.Osu/Objects/Drawables/DrawableHitCircle.cs b/osu.Game.Modes.Osu/Objects/Drawables/DrawableHitCircle.cs index ccbfbb1db3..5143bd4af8 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/DrawableHitCircle.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/DrawableHitCircle.cs @@ -42,6 +42,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables Colour = osuObject.Colour, Hit = () => { + if (Judgement.Result.HasValue) return false; + ((PositionalJudgementInfo)Judgement).PositionOffset = Vector2.Zero; //todo: set to correct value UpdateJudgement(true); return true; @@ -134,7 +136,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables FadeOut(TIME_FADEOUT / 5); break; case ArmedState.Hit: - const double flash_in = 30; + const double flash_in = 40; flash.FadeTo(0.8f, flash_in); flash.Delay(flash_in); diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/Triangles.cs b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/Triangles.cs index 95f25c43d1..2025934e71 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/Triangles.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/Triangles.cs @@ -13,6 +13,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces { public class Triangles : Container { + public override bool HandleInput => false; + protected override void LoadComplete() { base.LoadComplete(); diff --git a/osu.Game.Modes.Osu/Objects/SliderCurve.cs b/osu.Game.Modes.Osu/Objects/SliderCurve.cs index 961658112f..1c2ef3a604 100644 --- a/osu.Game.Modes.Osu/Objects/SliderCurve.cs +++ b/osu.Game.Modes.Osu/Objects/SliderCurve.cs @@ -101,9 +101,11 @@ namespace osu.Game.Modes.Osu.Objects cumulativeLength.Add(l); } + //TODO: Figure out if the following code is needed in some cases. Judging by the map + // "Transform" http://osu.ppy.sh/s/484689 it seems like we should _not_ be doing this. // Lengthen slider curves that are too short compared to what's // in the .osu file. - if (l < Length && calculatedPath.Count > 1) + /*if (l < Length && calculatedPath.Count > 1) { Vector2 diff = calculatedPath[calculatedPath.Count - 1] - calculatedPath[calculatedPath.Count - 2]; double d = diff.Length; @@ -113,7 +115,7 @@ namespace osu.Game.Modes.Osu.Objects calculatedPath[calculatedPath.Count - 1] += diff * (float)((Length - l) / d); cumulativeLength[calculatedPath.Count - 1] = Length; - } + }*/ } public void Calculate() diff --git a/osu.Game.Tests/Beatmaps/Formats/OsuLegacyDecoderTest.cs b/osu.Game.Tests/Beatmaps/Formats/OsuLegacyDecoderTest.cs index d52eace965..9a988d6eff 100644 --- a/osu.Game.Tests/Beatmaps/Formats/OsuLegacyDecoderTest.cs +++ b/osu.Game.Tests/Beatmaps/Formats/OsuLegacyDecoderTest.cs @@ -23,7 +23,8 @@ namespace osu.Game.Tests.Beatmaps.Formats OsuLegacyDecoder.Register(); Ruleset.Register(new OsuRuleset()); } - [Test] + + [Test] public void TestDecodeMetadata() { var decoder = new OsuLegacyDecoder(); @@ -31,7 +32,7 @@ namespace osu.Game.Tests.Beatmaps.Formats { var beatmap = decoder.Decode(new StreamReader(stream)); var meta = beatmap.BeatmapInfo.Metadata; - Assert.AreEqual(241526, meta.BeatmapSetID); + Assert.AreEqual(241526, meta.OnlineBeatmapSetID); Assert.AreEqual("Soleily", meta.Artist); Assert.AreEqual("Soleily", meta.ArtistUnicode); Assert.AreEqual("03. Renatus - Soleily 192kbps.mp3", meta.AudioFile); @@ -125,7 +126,8 @@ namespace osu.Game.Tests.Beatmaps.Formats } } - [Test] public void TestDecodeHitObjects() + [Test] + public void TestDecodeHitObjects() { var decoder = new OsuLegacyDecoder(); using (var stream = Resource.OpenResource("Soleily - Renatus (Gamu) [Insane].osu")) diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs index 37d89b6497..165181a332 100644 --- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs @@ -83,7 +83,7 @@ namespace osu.Game.Tests.Beatmaps.IO Action waitAction = () => { while ((resultSets = osu.Dependencies.Get() - .Query().Where(s => s.BeatmapSetID == 241526)).Count() != 1) + .Query().Where(s => s.OnlineBeatmapSetID == 241526)).Count() != 1) Thread.Sleep(1); }; @@ -100,7 +100,7 @@ namespace osu.Game.Tests.Beatmaps.IO waitAction = () => { while ((resultBeatmaps = osu.Dependencies.Get() - .Query().Where(s => s.BeatmapSetID == 241526 && s.BaseDifficultyID > 0)).Count() != 12) + .Query().Where(s => s.OnlineBeatmapSetID == 241526 && s.BaseDifficultyID > 0)).Count() != 12) Thread.Sleep(1); }; @@ -113,7 +113,7 @@ namespace osu.Game.Tests.Beatmaps.IO Assert.IsTrue(set.Beatmaps.Count == resultBeatmaps.Count()); foreach (BeatmapInfo b in resultBeatmaps) - Assert.IsTrue(set.Beatmaps.Any(c => c.BeatmapID == b.BeatmapID)); + Assert.IsTrue(set.Beatmaps.Any(c => c.OnlineBeatmapID == b.OnlineBeatmapID)); Assert.IsTrue(set.Beatmaps.Count > 0); diff --git a/osu.Game.Tests/Beatmaps/IO/OszArchiveReaderTest.cs b/osu.Game.Tests/Beatmaps/IO/OszArchiveReaderTest.cs index 1343ae7241..a09d0c2f86 100644 --- a/osu.Game.Tests/Beatmaps/IO/OszArchiveReaderTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/OszArchiveReaderTest.cs @@ -52,7 +52,7 @@ namespace osu.Game.Tests.Beatmaps.IO { var reader = new OszArchiveReader(osz); var meta = reader.ReadMetadata(); - Assert.AreEqual(241526, meta.BeatmapSetID); + Assert.AreEqual(241526, meta.OnlineBeatmapSetID); Assert.AreEqual("Soleily", meta.Artist); Assert.AreEqual("Soleily", meta.ArtistUnicode); Assert.AreEqual("03. Renatus - Soleily 192kbps.mp3", meta.AudioFile); @@ -65,7 +65,8 @@ namespace osu.Game.Tests.Beatmaps.IO Assert.AreEqual("Renatus", meta.TitleUnicode); } } - [Test] + + [Test] public void TestReadFile() { using (var osz = Resource.OpenResource("Beatmaps.241526 Soleily - Renatus.osz")) diff --git a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs index 3f5fe58ab5..7799095a77 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Linq; using osu.Framework; using osu.Framework.Graphics; +using osu.Framework.Graphics.Transformations; using osu.Game.Database; namespace osu.Game.Beatmaps.Drawables @@ -19,12 +20,16 @@ namespace osu.Game.Beatmaps.Drawables /// public Action SelectionChanged; + /// + /// Fires when one of our difficulties is clicked when already selected. Should start playing the map. + /// + public Action StartRequested; + public BeatmapSetHeader Header; private BeatmapGroupState state; public List BeatmapPanels; - private WorkingBeatmap beatmap; public BeatmapGroupState State { @@ -48,16 +53,14 @@ namespace osu.Game.Beatmaps.Drawables SelectedPanel.State = PanelSelectedState.NotSelected; foreach (BeatmapPanel panel in BeatmapPanels) - panel.FadeOut(250); + panel.FadeOut(300, EasingTypes.OutQuint); break; } } } - public BeatmapGroup(WorkingBeatmap beatmap) + public BeatmapGroup(WorkingBeatmap beatmap, BeatmapSetInfo set = null) { - this.beatmap = beatmap; - Header = new BeatmapSetHeader(beatmap) { GainedSelection = headerGainedSelection, @@ -68,6 +71,7 @@ namespace osu.Game.Beatmaps.Drawables { Alpha = 0, GainedSelection = panelGainedSelection, + StartRequested = p => { StartRequested?.Invoke(p.Beatmap); }, RelativeSizeAxes = Axes.X, }).ToList(); } diff --git a/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs b/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs index 72d1e2f05d..ed5db58418 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs @@ -1,62 +1,70 @@ -//Copyright (c) 2007-2016 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.Colour; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Textures; -using osu.Framework.MathUtils; -using osu.Game.Database; -using osu.Game.Graphics; -using osu.Game.Graphics.Backgrounds; -using osu.Game.Graphics.UserInterface; -using OpenTK; -using OpenTK.Graphics; - -namespace osu.Game.Beatmaps.Drawables -{ - class BeatmapPanel : Panel - { - public BeatmapInfo Beatmap; - private Sprite background; - - public Action GainedSelection; +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - Color4 deselectedColour = new Color4(20, 43, 51, 255); +using System; +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.Graphics.Textures; +using osu.Framework.MathUtils; +using osu.Game.Database; +using osu.Game.Graphics; +using osu.Game.Graphics.Backgrounds; +using osu.Game.Graphics.UserInterface; +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Input; + +namespace osu.Game.Beatmaps.Drawables +{ + class BeatmapPanel : Panel + { + public BeatmapInfo Beatmap; + private Sprite background; + + public Action GainedSelection; + public Action StartRequested; protected override void Selected() { base.Selected(); GainedSelection?.Invoke(this); - background.ColourInfo = ColourInfo.GradientVertical( - new Color4(20, 43, 51, 255), + background.ColourInfo = ColourInfo.GradientVertical( + new Color4(20, 43, 51, 255), new Color4(40, 86, 102, 255)); - } - + } + protected override void Deselected() { base.Deselected(); - background.Colour = deselectedColour; - } - - public BeatmapPanel(BeatmapInfo beatmap) + background.Colour = new Color4(20, 43, 51, 255); + } + + protected override bool OnClick(InputState state) + { + if (State == PanelSelectedState.Selected) + StartRequested?.Invoke(this); + + return base.OnClick(state); + } + + public BeatmapPanel(BeatmapInfo beatmap) { Beatmap = beatmap; - Height *= 0.60f; - - Children = new Drawable[] - { - background = new Box - { - RelativeSizeAxes = Axes.Both, - }, - new Triangles + Height *= 0.60f; + + Children = new Drawable[] + { + background = new Box + { + RelativeSizeAxes = Axes.Both, + }, + new Triangles { // The border is drawn in the shader of the children. Being additive, triangles would over-emphasize // the border wherever they cross it, and thus they get their own masking container without a border. @@ -64,70 +72,70 @@ namespace osu.Game.Beatmaps.Drawables CornerRadius = Content.CornerRadius, RelativeSizeAxes = Axes.Both, BlendingMode = BlendingMode.Additive, - Colour = deselectedColour, - }, - new FlowContainer - { - Padding = new MarginPadding(5), - Direction = FlowDirection.HorizontalOnly, - AutoSizeAxes = Axes.Both, + Colour = new Color4(20, 43, 51, 255), + }, + new FlowContainer + { + Padding = new MarginPadding(5), + Direction = FlowDirection.HorizontalOnly, + AutoSizeAxes = Axes.Both, Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - Children = new Drawable[] - { - new DifficultyIcon(FontAwesome.fa_dot_circle_o, new Color4(159, 198, 0, 255)) + Origin = Anchor.CentreLeft, + Children = new Drawable[] + { + new DifficultyIcon(FontAwesome.fa_dot_circle_o, new Color4(159, 198, 0, 255)) { Scale = new Vector2(1.8f), Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, - }, - new FlowContainer - { - Padding = new MarginPadding { Left = 5 }, - Spacing = new Vector2(0, 5), - Direction = FlowDirection.VerticalOnly, - AutoSizeAxes = Axes.Both, - Children = new Drawable[] - { - new FlowContainer - { - Direction = FlowDirection.HorizontalOnly, - AutoSizeAxes = Axes.Both, - Spacing = new Vector2(4, 0), - Children = new[] - { - new SpriteText - { - Font = @"Exo2.0-Medium", - Text = beatmap.Version, - TextSize = 20, - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft - }, - new SpriteText - { - Font = @"Exo2.0-Medium", - Text = "mapped by", - TextSize = 16, - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft - }, - new SpriteText - { - Font = @"Exo2.0-MediumItalic", - Text = $"{(beatmap.Metadata ?? beatmap.BeatmapSet.Metadata).Author}", - TextSize = 16, - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft - }, - } - }, - new StarCounter { Count = beatmap.BaseDifficulty?.OverallDifficulty ?? 5, StarSize = 8 } - } - } - } - } - }; + }, + new FlowContainer + { + Padding = new MarginPadding { Left = 5 }, + Spacing = new Vector2(0, 5), + Direction = FlowDirection.VerticalOnly, + AutoSizeAxes = Axes.Both, + Children = new Drawable[] + { + new FlowContainer + { + Direction = FlowDirection.HorizontalOnly, + AutoSizeAxes = Axes.Both, + Spacing = new Vector2(4, 0), + Children = new[] + { + new SpriteText + { + Font = @"Exo2.0-Medium", + Text = beatmap.Version, + TextSize = 20, + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft + }, + new SpriteText + { + Font = @"Exo2.0-Medium", + Text = "mapped by", + TextSize = 16, + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft + }, + new SpriteText + { + Font = @"Exo2.0-MediumItalic", + Text = $"{(beatmap.Metadata ?? beatmap.BeatmapSet.Metadata).Author}", + TextSize = 16, + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft + }, + } + }, + new StarCounter { Count = beatmap.BaseDifficulty?.OverallDifficulty ?? 5, StarSize = 8 } + } + } + } + } + }; } - } -} + } +} diff --git a/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs b/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs index 7234e2ad8b..99942de133 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs @@ -1,74 +1,74 @@ -//Copyright (c) 2007-2016 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.Configuration; -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.Configuration; -using osu.Game.Graphics; -using OpenTK; -using OpenTK.Graphics; - +//Copyright (c) 2007-2016 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.Configuration; +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.Configuration; +using osu.Game.Graphics; +using OpenTK; +using OpenTK.Graphics; + namespace osu.Game.Beatmaps.Drawables { - class BeatmapSetHeader : Panel - { - public Action GainedSelection; - private SpriteText title, artist; - private OsuConfigManager config; - private Bindable preferUnicode; - private WorkingBeatmap beatmap; - - public BeatmapSetHeader(WorkingBeatmap beatmap) - { - this.beatmap = beatmap; - - Children = new Drawable[] - { + class BeatmapSetHeader : Panel + { + public Action GainedSelection; + private SpriteText title, artist; + private OsuConfigManager config; + private Bindable preferUnicode; + private WorkingBeatmap beatmap; + + public BeatmapSetHeader(WorkingBeatmap beatmap) + { + this.beatmap = beatmap; + + Children = new Drawable[] + { new PanelBackground(beatmap) { RelativeSizeAxes = Axes.Both, }, - new FlowContainer - { - Direction = FlowDirection.VerticalOnly, - Padding = new MarginPadding { Top = 5, Left = 18, Right = 10, Bottom = 10 }, - AutoSizeAxes = Axes.Both, - Children = new[] - { - title = new SpriteText - { - Font = @"Exo2.0-BoldItalic", - Text = beatmap.BeatmapSetInfo.Metadata.Title, - TextSize = 22, - Shadow = true, - }, - artist = new SpriteText - { - Margin = new MarginPadding { Top = -1 }, - Font = @"Exo2.0-SemiBoldItalic", - Text = beatmap.BeatmapSetInfo.Metadata.Artist, - TextSize = 17, - Shadow = true, - }, - new FlowContainer - { - Margin = new MarginPadding { Top = 5 }, - AutoSizeAxes = Axes.Both, - Children = new[] - { - new DifficultyIcon(FontAwesome.fa_dot_circle_o, new Color4(159, 198, 0, 255)), - new DifficultyIcon(FontAwesome.fa_dot_circle_o, new Color4(246, 101, 166, 255)), - } - } - } - } - }; + new FlowContainer + { + Direction = FlowDirection.VerticalOnly, + Padding = new MarginPadding { Top = 5, Left = 18, Right = 10, Bottom = 10 }, + AutoSizeAxes = Axes.Both, + Children = new[] + { + title = new SpriteText + { + Font = @"Exo2.0-BoldItalic", + Text = beatmap.BeatmapSetInfo.Metadata.Title, + TextSize = 22, + Shadow = true, + }, + artist = new SpriteText + { + Margin = new MarginPadding { Top = -1 }, + Font = @"Exo2.0-SemiBoldItalic", + Text = beatmap.BeatmapSetInfo.Metadata.Artist, + TextSize = 17, + Shadow = true, + }, + new FlowContainer + { + Margin = new MarginPadding { Top = 5 }, + AutoSizeAxes = Axes.Both, + Children = new[] + { + new DifficultyIcon(FontAwesome.fa_dot_circle_o, new Color4(159, 198, 0, 255)), + new DifficultyIcon(FontAwesome.fa_dot_circle_o, new Color4(246, 101, 166, 255)), + } + } + } + } + }; } protected override void LoadComplete() @@ -81,8 +81,8 @@ namespace osu.Game.Beatmaps.Drawables { base.Selected(); GainedSelection?.Invoke(this); - } - + } + [BackgroundDependencyLoader] private void load(OsuConfigManager config) { @@ -90,31 +90,32 @@ namespace osu.Game.Beatmaps.Drawables preferUnicode = config.GetBindable(OsuConfig.ShowUnicode); preferUnicode.ValueChanged += preferUnicode_changed; - preferUnicode_changed(preferUnicode, null); + preferUnicode_changed(preferUnicode, null); } - private void preferUnicode_changed(object sender, EventArgs e) - { - title.Text = config.GetUnicodeString(beatmap.BeatmapSetInfo.Metadata.Title, beatmap.BeatmapSetInfo.Metadata.TitleUnicode); - artist.Text = config.GetUnicodeString(beatmap.BeatmapSetInfo.Metadata.Artist, beatmap.BeatmapSetInfo.Metadata.ArtistUnicode); + + private void preferUnicode_changed(object sender, EventArgs e) + { + title.Text = config.GetUnicodeString(beatmap.BeatmapSetInfo.Metadata.Title, beatmap.BeatmapSetInfo.Metadata.TitleUnicode); + artist.Text = config.GetUnicodeString(beatmap.BeatmapSetInfo.Metadata.Artist, beatmap.BeatmapSetInfo.Metadata.ArtistUnicode); } protected override void Dispose(bool isDisposing) - { - if (preferUnicode != null) + { + if (preferUnicode != null) preferUnicode.ValueChanged -= preferUnicode_changed; base.Dispose(isDisposing); - } - + } + class PanelBackground : BufferedContainer - { - private readonly WorkingBeatmap working; - - public PanelBackground(WorkingBeatmap working) - { - this.working = working; - - CacheDrawnFrameBuffer = true; - + { + private readonly WorkingBeatmap working; + + public PanelBackground(WorkingBeatmap working) + { + this.working = working; + + CacheDrawnFrameBuffer = true; + Children = new[] { new FlowContainer @@ -128,34 +129,37 @@ namespace osu.Game.Beatmaps.Drawables Children = new[] { // The left half with no gradient applied - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black, - Width = 0.4f, + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black, + Width = 0.4f, }, // Piecewise-linear gradient with 3 segments to make it appear smoother new Box { RelativeSizeAxes = Axes.Both, - ColourInfo = ColourInfo.GradientHorizontal(Color4.Black, new Color4(0f, 0f, 0f, 0.9f)), + ColourInfo = ColourInfo.GradientHorizontal( + Color4.Black, new Color4(0f, 0f, 0f, 0.9f)), Width = 0.05f, }, new Box { RelativeSizeAxes = Axes.Both, - ColourInfo = ColourInfo.GradientHorizontal(new Color4(0f, 0f, 0f, 0.9f), new Color4(0f, 0f, 0f, 0.1f)), + ColourInfo = ColourInfo.GradientHorizontal( + new Color4(0f, 0f, 0f, 0.9f), new Color4(0f, 0f, 0f, 0.1f)), Width = 0.2f, }, new Box { RelativeSizeAxes = Axes.Both, - ColourInfo = ColourInfo.GradientHorizontal(new Color4(0f, 0f, 0f, 0.1f), new Color4(0, 0, 0, 0)), + ColourInfo = ColourInfo.GradientHorizontal( + new Color4(0f, 0f, 0f, 0.1f), new Color4(0, 0, 0, 0)), Width = 0.05f, }, } - }, - }; + }, + }; } [BackgroundDependencyLoader] @@ -172,6 +176,6 @@ namespace osu.Game.Beatmaps.Drawables ForceRedraw(); }); } - } + } } } \ No newline at end of file diff --git a/osu.Game/Beatmaps/Drawables/Panel.cs b/osu.Game/Beatmaps/Drawables/Panel.cs index f97a5260d8..ff89e5882d 100644 --- a/osu.Game/Beatmaps/Drawables/Panel.cs +++ b/osu.Game/Beatmaps/Drawables/Panel.cs @@ -8,6 +8,7 @@ using osu.Framework.Graphics.Transformations; using osu.Framework.Input; using OpenTK; using OpenTK.Graphics; +using osu.Game.Graphics; namespace osu.Game.Beatmaps.Drawables { @@ -98,7 +99,7 @@ namespace osu.Game.Beatmaps.Drawables Type = EdgeEffectType.Shadow, Offset = new Vector2(1), Radius = 10, - Colour = new Color4(0, 0, 0, 100), + Colour = Color4.Black.Opacity(100), }; } diff --git a/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs b/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs index 83cd60eca3..cd55f36ae3 100644 --- a/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs +++ b/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.IO; using osu.Game.Modes.Objects; using OpenTK.Graphics; +using osu.Game.Graphics; namespace osu.Game.Beatmaps.Formats { @@ -44,11 +45,11 @@ namespace osu.Game.Beatmaps.Formats public virtual void ApplyColours(Beatmap b) { - List colours = b.ComboColors ?? new List() { + List colours = b.ComboColors ?? new List { new Color4(17, 136, 170, 255), - new Color4(102,136,0, 255), - new Color4(204,102,0, 255), - new Color4(121,9,13, 255), + new Color4(102, 136, 0, 255), + new Color4(204, 102, 0, 255), + new Color4(121, 9, 13, 255), }; if (colours.Count == 0) return; diff --git a/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs b/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs index 12a26dafa8..33a39ca3b5 100644 --- a/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs +++ b/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs @@ -26,6 +26,10 @@ namespace osu.Game.Beatmaps.Formats AddDecoder(@"osu file format v11"); AddDecoder(@"osu file format v10"); AddDecoder(@"osu file format v9"); + AddDecoder(@"osu file format v8"); + AddDecoder(@"osu file format v7"); + AddDecoder(@"osu file format v6"); + AddDecoder(@"osu file format v5"); // TODO: Not sure how far back to go, or differences between versions } @@ -132,11 +136,11 @@ namespace osu.Game.Beatmaps.Formats beatmap.BeatmapInfo.Metadata.Tags = val; break; case @"BeatmapID": - beatmap.BeatmapInfo.BeatmapID = int.Parse(val); + beatmap.BeatmapInfo.OnlineBeatmapID = int.Parse(val); break; case @"BeatmapSetID": - beatmap.BeatmapInfo.BeatmapSetID = int.Parse(val); - metadata.BeatmapSetID = int.Parse(val); + beatmap.BeatmapInfo.OnlineBeatmapSetID = int.Parse(val); + metadata.OnlineBeatmapSetID = int.Parse(val); break; } } diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index 4c9848363b..9184607398 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -67,6 +67,7 @@ namespace osu.Game.Beatmaps set { lock (beatmapLock) beatmap = value; } } + private ArchiveReader trackReader; private AudioTrack track; private object trackLock = new object(); public AudioTrack Track @@ -79,12 +80,11 @@ namespace osu.Game.Beatmaps try { - using (var reader = GetReader()) - { - var trackData = reader?.GetStream(BeatmapInfo.Metadata.AudioFile); - if (trackData != null) - track = new AudioTrackBass(trackData); - } + //store a reference to the reader as we may continue accessing the stream in the background. + trackReader = GetReader(); + var trackData = trackReader?.GetStream(BeatmapInfo.Metadata.AudioFile); + if (trackData != null) + track = new AudioTrackBass(trackData); } catch { } diff --git a/osu.Game/Database/BeatmapDatabase.cs b/osu.Game/Database/BeatmapDatabase.cs index 896e742989..eda5f1b9a3 100644 --- a/osu.Game/Database/BeatmapDatabase.cs +++ b/osu.Game/Database/BeatmapDatabase.cs @@ -69,7 +69,8 @@ namespace osu.Game.Database using (var reader = ArchiveReader.GetReader(storage, path)) metadata = reader.ReadMetadata(); - if (connection.Table().Count(b => b.BeatmapSetID == metadata.BeatmapSetID) != 0) + if (metadata.OnlineBeatmapSetID.HasValue && + connection.Table().Count(b => b.OnlineBeatmapSetID == metadata.OnlineBeatmapSetID) != 0) return; // TODO: Update this beatmap instead if (File.Exists(path)) // Not always the case, i.e. for LegacyFilesystemReader @@ -86,7 +87,7 @@ namespace osu.Game.Database } var beatmapSet = new BeatmapSetInfo { - BeatmapSetID = metadata.BeatmapSetID, + OnlineBeatmapSetID = metadata.OnlineBeatmapSetID, Beatmaps = new List(), Path = path, Hash = hash, @@ -139,18 +140,18 @@ namespace osu.Game.Database public BeatmapSetInfo GetBeatmapSet(int id) { - return Query().FirstOrDefault(s => s.BeatmapSetID == id); + return Query().FirstOrDefault(s => s.OnlineBeatmapSetID == id); } public WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo, WorkingBeatmap previous = null) { - var beatmapSetInfo = Query().FirstOrDefault(s => s.BeatmapSetID == beatmapInfo.BeatmapSetID); + var beatmapSetInfo = Query().FirstOrDefault(s => s.ID == beatmapInfo.BeatmapSetInfoID); //we need metadata GetChildren(beatmapSetInfo); if (beatmapSetInfo == null) - throw new InvalidOperationException($@"Beatmap set {beatmapInfo.BeatmapSetID} is not in the local database."); + throw new InvalidOperationException($@"Beatmap set {beatmapInfo.BeatmapSetInfoID} is not in the local database."); if (beatmapInfo.Metadata == null) beatmapInfo.Metadata = beatmapSetInfo.Metadata; diff --git a/osu.Game/Database/BeatmapInfo.cs b/osu.Game/Database/BeatmapInfo.cs index be47891016..ef5f00b634 100644 --- a/osu.Game/Database/BeatmapInfo.cs +++ b/osu.Game/Database/BeatmapInfo.cs @@ -13,11 +13,15 @@ namespace osu.Game.Database { public class BeatmapInfo : IEquatable { - [PrimaryKey] - public int BeatmapID { get; set; } + [PrimaryKey, AutoIncrement] + public int ID { get; set; } + + public int? OnlineBeatmapID { get; set; } = null; + + public int? OnlineBeatmapSetID { get; set; } = null; [ForeignKey(typeof(BeatmapSetInfo))] - public int BeatmapSetID { get; set; } + public int BeatmapSetInfoID { get; set; } [ManyToOne] public BeatmapSetInfo BeatmapSet { get; set; } @@ -71,7 +75,7 @@ namespace osu.Game.Database public bool Equals(BeatmapInfo other) { - return BeatmapID == other?.BeatmapID; + return ID == other?.ID; } public bool AudioEquals(BeatmapInfo other) => other != null && diff --git a/osu.Game/Database/BeatmapMetadata.cs b/osu.Game/Database/BeatmapMetadata.cs index 45b7b8de0f..e0d2f0c5f7 100644 --- a/osu.Game/Database/BeatmapMetadata.cs +++ b/osu.Game/Database/BeatmapMetadata.cs @@ -9,8 +9,9 @@ namespace osu.Game.Database { [PrimaryKey, AutoIncrement] public int ID { get; set; } - - public int BeatmapSetID { get; set; } + + public int? OnlineBeatmapSetID { get; set; } = null; + public string Title { get; set; } public string TitleUnicode { get; set; } public string Artist { get; set; } diff --git a/osu.Game/Database/BeatmapSetInfo.cs b/osu.Game/Database/BeatmapSetInfo.cs index 0a83753963..60637f8736 100644 --- a/osu.Game/Database/BeatmapSetInfo.cs +++ b/osu.Game/Database/BeatmapSetInfo.cs @@ -10,20 +10,22 @@ namespace osu.Game.Database { public class BeatmapSetInfo { - [PrimaryKey] - public int BeatmapSetID { get; set; } - + [PrimaryKey, AutoIncrement] + public int ID { get; set; } + + public int? OnlineBeatmapSetID { get; set; } = null; + [OneToOne(CascadeOperations = CascadeOperation.All)] - public BeatmapMetadata Metadata { get; set; } - - [NotNull, ForeignKey(typeof(BeatmapMetadata))] + public BeatmapMetadata Metadata { get; set; } + + [NotNull, ForeignKey(typeof(BeatmapMetadata))] public int BeatmapMetadataID { get; set; } - [OneToMany(CascadeOperations = CascadeOperation.All)] - public List Beatmaps { get; set; } - - public string Hash { get; set; } - + [OneToMany(CascadeOperations = CascadeOperation.All)] + public List Beatmaps { get; set; } + + public string Hash { get; set; } + public string Path { get; set; } } } diff --git a/osu.Game/Graphics/Backgrounds/Triangles.cs b/osu.Game/Graphics/Backgrounds/Triangles.cs index 34e65f0b2a..b68b5ebc4a 100644 --- a/osu.Game/Graphics/Backgrounds/Triangles.cs +++ b/osu.Game/Graphics/Backgrounds/Triangles.cs @@ -15,6 +15,8 @@ namespace osu.Game.Graphics.Backgrounds { public class Triangles : Container { + public override bool HandleInput => false; + public Triangles() { Alpha = 0.3f; diff --git a/osu.Game/Graphics/OsuColour.cs b/osu.Game/Graphics/OsuColour.cs new file mode 100644 index 0000000000..1ab5ec8f7c --- /dev/null +++ b/osu.Game/Graphics/OsuColour.cs @@ -0,0 +1,61 @@ +using System; +using OpenTK.Graphics; +using osu.Framework.Graphics.Colour; + +namespace osu.Game.Graphics +{ + public static class OsuColourExtensions + { + public static Color4 Opacity(this Color4 color, float a) => new Color4(color.R, color.G, color.B, a); + public static Color4 Opacity(this Color4 color, byte a) => new Color4(color.R, color.G, color.B, a / 255f); + } + + public class OsuColour + { + public static Color4 Gray(float amt) => new Color4(amt, amt, amt, 1f); + public static Color4 Gray(byte amt) => new Color4(amt, amt, amt, 255); + + private static Color4 FromHex(string hex) + { + return new Color4( + Convert.ToByte(hex.Substring(0, 2), 16), + Convert.ToByte(hex.Substring(2, 2), 16), + Convert.ToByte(hex.Substring(4, 2), 16), + 255); + } + + // 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 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 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 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 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 Color4 Red = FromHex(@"fc4549"); + } +} diff --git a/osu.Game/Graphics/UserInterface/BackButton.cs b/osu.Game/Graphics/UserInterface/BackButton.cs index ade6cedc58..2f9a026b8f 100644 --- a/osu.Game/Graphics/UserInterface/BackButton.cs +++ b/osu.Game/Graphics/UserInterface/BackButton.cs @@ -34,55 +34,6 @@ namespace osu.Game.Graphics.UserInterface public BackButton() { Size = size_retracted; - - Children = new Drawable[] - { - new Container - { - RelativeSizeAxes = Axes.Both, - Width = 0.4f, - Children = new Drawable[] - { - leftBox = new Box - { - RelativeSizeAxes = Axes.Both, - Colour = new Color4(195, 40, 140, 255), - Shear = new Vector2(shear, 0), - }, - icon = new TextAwesome - { - Anchor = Anchor.Centre, - TextSize = 25, - Icon = FontAwesome.fa_osu_left_o - }, - } - }, - new Container - { - Origin = Anchor.TopRight, - Anchor = Anchor.TopRight, - RelativeSizeAxes = Axes.Both, - Width = 0.6f, - Children = new Drawable[] - { - rightBox = new Box - { - Colour = new Color4(238, 51, 153, 255), - Origin = Anchor.TopLeft, - Anchor = Anchor.TopLeft, - RelativeSizeAxes = Axes.Both, - Shear = new Vector2(shear, 0), - EdgeSmoothness = new Vector2(1.5f, 0), - }, - new SpriteText - { - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - Text = @"Back", - } - } - } - }; } public override bool Contains(Vector2 screenSpacePos) => leftBox.Contains(screenSpacePos) || rightBox.Contains(screenSpacePos); @@ -140,9 +91,57 @@ namespace osu.Game.Graphics.UserInterface } [BackgroundDependencyLoader] - private void load(AudioManager audio) + private void load(AudioManager audio, OsuColour colours) { sampleClick = audio.Sample.Get(@"Menu/menuback"); + Children = new Drawable[] + { + new Container + { + RelativeSizeAxes = Axes.Both, + Width = 0.4f, + Children = new Drawable[] + { + leftBox = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = colours.PinkDark, + Shear = new Vector2(shear, 0), + }, + icon = new TextAwesome + { + Anchor = Anchor.Centre, + TextSize = 25, + Icon = FontAwesome.fa_osu_left_o + }, + } + }, + new Container + { + Origin = Anchor.TopRight, + Anchor = Anchor.TopRight, + RelativeSizeAxes = Axes.Both, + Width = 0.6f, + Children = new Drawable[] + { + rightBox = new Box + { + Colour = colours.Pink, + Origin = Anchor.TopLeft, + Anchor = Anchor.TopLeft, + RelativeSizeAxes = Axes.Both, + Shear = new Vector2(shear, 0), + EdgeSmoothness = new Vector2(1.5f, 0), + }, + new SpriteText + { + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Text = @"Back", + } + } + } + }; } protected override bool OnClick(InputState state) @@ -151,7 +150,7 @@ namespace osu.Game.Graphics.UserInterface { RelativeSizeAxes = Axes.Both, Shear = new Vector2(shear, 0), - Colour = new Color4(255, 255, 255, 128), + Colour = Color4.White.Opacity(0.5f), }; Add(flash); diff --git a/osu.Game/Graphics/UserInterface/OsuButton.cs b/osu.Game/Graphics/UserInterface/OsuButton.cs index 476895e0b2..2afcf56140 100644 --- a/osu.Game/Graphics/UserInterface/OsuButton.cs +++ b/osu.Game/Graphics/UserInterface/OsuButton.cs @@ -3,6 +3,7 @@ using System; using OpenTK.Graphics; +using osu.Framework.Allocation; using osu.Framework.Graphics.UserInterface; namespace osu.Game.Graphics.UserInterface @@ -12,7 +13,12 @@ namespace osu.Game.Graphics.UserInterface public OsuButton() { Height = 25; - Colour = new Color4(14, 132, 165, 255); + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + Colour = colours.BlueDark; } } } \ No newline at end of file diff --git a/osu.Game/Graphics/UserInterface/StarCounter.cs b/osu.Game/Graphics/UserInterface/StarCounter.cs index 097362bc77..fa8ca7e5a9 100644 --- a/osu.Game/Graphics/UserInterface/StarCounter.cs +++ b/osu.Game/Graphics/UserInterface/StarCounter.cs @@ -35,7 +35,7 @@ namespace osu.Game.Graphics.UserInterface protected set; } - private double animationDelay => 150; + private double animationDelay => 80; private double scalingDuration => 500; private EasingTypes scalingEasing => EasingTypes.OutElasticHalf; diff --git a/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs index 94694b8d5e..7ce71acf3e 100644 --- a/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs @@ -44,6 +44,8 @@ namespace osu.Game.Modes.Objects.Drawables UpdateState(state); + Expire(); + if (State == ArmedState.Hit) PlaySample(); } @@ -75,6 +77,8 @@ namespace osu.Game.Modes.Objects.Drawables //force application of the state that was set before we loaded. UpdateState(State); + + Expire(true); } /// diff --git a/osu.Game/Modes/Objects/HitObject.cs b/osu.Game/Modes/Objects/HitObject.cs index 71839e7036..b2043fa94c 100644 --- a/osu.Game/Modes/Objects/HitObject.cs +++ b/osu.Game/Modes/Objects/HitObject.cs @@ -4,6 +4,7 @@ using osu.Game.Beatmaps; using osu.Game.Beatmaps.Samples; using OpenTK.Graphics; +using osu.Game.Graphics; namespace osu.Game.Modes.Objects { diff --git a/osu.Game/Online/Chat/Drawables/ChatLine.cs b/osu.Game/Online/Chat/Drawables/ChatLine.cs index 454f7beed7..2dd3425bda 100644 --- a/osu.Game/Online/Chat/Drawables/ChatLine.cs +++ b/osu.Game/Online/Chat/Drawables/ChatLine.cs @@ -35,7 +35,7 @@ namespace osu.Game.Online.Chat.Drawables { Text = Message.Timestamp.LocalDateTime.ToLongTimeString(), TextSize = text_size, - Colour = new Color4(128, 128, 128, 255) + Colour = Color4.Gray }, new SpriteText { diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 7c1f620c93..d29fe0032c 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -13,6 +13,7 @@ using osu.Game.Beatmaps; using osu.Game.Beatmaps.IO; using osu.Game.Configuration; using osu.Game.Database; +using osu.Game.Graphics; using osu.Game.Graphics.Cursor; using osu.Game.Graphics.Processing; using osu.Game.Online.API; @@ -41,6 +42,7 @@ namespace osu.Game Dependencies.Cache(this); Dependencies.Cache(Config); Dependencies.Cache(new BeatmapDatabase(Host.Storage, Host)); + Dependencies.Cache(new OsuColour()); //this completely overrides the framework default. will need to change once we make a proper FontStore. Dependencies.Cache(Fonts = new FontStore { ScaleAdjust = 0.01f }, true); diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index 22f7a3a78f..17a1a2604a 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -13,6 +13,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transformations; using osu.Framework.Threading; +using osu.Game.Graphics; using osu.Game.Online.API; using osu.Game.Online.API.Requests; using osu.Game.Online.Chat; @@ -45,7 +46,7 @@ namespace osu.Game.Overlays { Depth = float.MaxValue, RelativeSizeAxes = Axes.Both, - Colour = new Color4(0.1f, 0.1f, 0.1f, 0.4f), + Colour = OsuColour.Gray(0.1f).Opacity(0.4f), }, content = new Container { diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index c69624bfda..5052840848 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -56,7 +56,7 @@ namespace osu.Game.Overlays EdgeEffect = new EdgeEffect { Type = EdgeEffectType.Shadow, - Colour = new Color4(0, 0, 0, 40), + Colour = Color4.Black.Opacity(40), Radius = 5, }; @@ -65,7 +65,31 @@ namespace osu.Game.Overlays Origin = Anchor.TopRight; Position = start_position; Margin = new MarginPadding(10); + } + protected override bool OnDragStart(InputState state) => true; + + protected override bool OnDrag(InputState state) + { + Vector2 change = (state.Mouse.Position - state.Mouse.PositionMouseDown.Value); + + // Diminish the drag distance as we go further to simulate "rubber band" feeling. + change *= (float)Math.Pow(change.Length, 0.7f) / change.Length; + + MoveTo(start_position + change); + return base.OnDrag(state); + } + + protected override bool OnDragEnd(InputState state) + { + MoveTo(start_position, 800, EasingTypes.OutElastic); + return base.OnDragEnd(state); + } + + [BackgroundDependencyLoader] + private void load(OsuGameBase osuGame, BeatmapDatabase beatmaps, AudioManager audio, + TextureStore textures, OsuColour colours) + { Children = new Drawable[] { title = new SpriteText @@ -171,34 +195,11 @@ namespace osu.Game.Overlays Origin = Anchor.BottomCentre, Anchor = Anchor.BottomCentre, Height = 10, - Colour = new Color4(255, 204, 34, 255), + Colour = colours.Yellow, SeekRequested = seek } }; - } - - protected override bool OnDragStart(InputState state) => true; - - protected override bool OnDrag(InputState state) - { - Vector2 change = (state.Mouse.Position - state.Mouse.PositionMouseDown.Value); - - // Diminish the drag distance as we go further to simulate "rubber band" feeling. - change *= (float)Math.Pow(change.Length, 0.7f) / change.Length; - - MoveTo(start_position + change); - return base.OnDrag(state); - } - - protected override bool OnDragEnd(InputState state) - { - MoveTo(start_position, 800, EasingTypes.OutElastic); - return base.OnDragEnd(state); - } - - [BackgroundDependencyLoader] - private void load(OsuGameBase osuGame, BeatmapDatabase beatmaps, AudioManager audio, TextureStore textures) - { + this.beatmaps = beatmaps; trackManager = osuGame.Audio.Track; config = osuGame.Config; @@ -318,7 +319,7 @@ namespace osu.Game.Overlays { Task.Run(() => { - if (beatmap.Beatmap == null) + if (beatmap?.Beatmap == null) //todo: we may need to display some default text here (currently in the constructor). return; @@ -393,7 +394,7 @@ namespace osu.Game.Overlays { sprite = new Sprite { - Colour = new Color4(150, 150, 150, 255), + Colour = OsuColour.Gray(150), FillMode = FillMode.Fill, }, new Box @@ -402,7 +403,7 @@ namespace osu.Game.Overlays Height = 50, Origin = Anchor.BottomCentre, Anchor = Anchor.BottomCentre, - Colour = new Color4(0, 0, 0, 127) + Colour = Color4.Black.Opacity(0.5f) } }; } diff --git a/osu.Game/Overlays/Options/CheckBoxOption.cs b/osu.Game/Overlays/Options/CheckBoxOption.cs index 2ea176378c..310d33580d 100644 --- a/osu.Game/Overlays/Options/CheckBoxOption.cs +++ b/osu.Game/Overlays/Options/CheckBoxOption.cs @@ -16,6 +16,7 @@ using osu.Framework.Graphics.UserInterface; using OpenTK; using OpenTK.Graphics; using osu.Framework.Input; +using osu.Game.Graphics; namespace osu.Game.Overlays.Options { @@ -140,26 +141,13 @@ namespace osu.Game.Overlays.Options private Box fill; const float border_width = 3; - - Color4 hoverColour = new Color4(255, 221, 238, 255); - Color4 defaultColour = new Color4(255, 102, 170, 255); - Color4 glowColour = new Color4(187, 17, 119, 0); + private Color4 glowingColour, idleColour; public Light() { Size = new Vector2(40, 12); - Masking = true; - - Colour = defaultColour; - - EdgeEffect = new EdgeEffect - { - Colour = glowColour, - Type = EdgeEffectType.Glow, - Radius = 10, - Roundness = 8, - }; + Masking = true; CornerRadius = Height / 2; Masking = true; @@ -176,19 +164,33 @@ namespace osu.Game.Overlays.Options }; } + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + Colour = idleColour = colours.Pink; + + EdgeEffect = new EdgeEffect + { + Colour = glowingColour = colours.PinkDarker, + Type = EdgeEffectType.Glow, + Radius = 10, + Roundness = 8, + }; + } + public bool Glowing { set { if (value) { - FadeColour(hoverColour, 500, EasingTypes.OutQuint); + FadeColour(glowingColour, 500, EasingTypes.OutQuint); FadeGlowTo(1, 500, EasingTypes.OutQuint); } else { FadeGlowTo(0, 500); - FadeColour(defaultColour, 500); + FadeColour(idleColour, 500); } } } diff --git a/osu.Game/Overlays/Options/DropdownOption.cs b/osu.Game/Overlays/Options/DropdownOption.cs index 3cdc6da2ab..6262673734 100644 --- a/osu.Game/Overlays/Options/DropdownOption.cs +++ b/osu.Game/Overlays/Options/DropdownOption.cs @@ -1,9 +1,11 @@ using System; +using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Reflection; using OpenTK; using OpenTK.Graphics; +using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -11,6 +13,7 @@ using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; using osu.Game.Configuration; +using osu.Game.Graphics; namespace osu.Game.Overlays.Options { @@ -68,9 +71,6 @@ namespace osu.Game.Overlays.Options Direction = FlowDirection.VerticalOnly; RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; - var items = typeof(T).GetFields().Where(f => !f.IsSpecialName).Zip( - (T[])Enum.GetValues(typeof(T)), (a, b) => new Tuple( - a.GetCustomAttribute()?.Description ?? a.Name, b)); Children = new Drawable[] { text = new SpriteText { Alpha = 0 }, @@ -78,7 +78,7 @@ namespace osu.Game.Overlays.Options { Margin = new MarginPadding { Top = 5 }, RelativeSizeAxes = Axes.X, - Items = items.Select(item => new StyledDropDownMenuItem(item.Item1, item.Item2)) + Items = (T[])Enum.GetValues(typeof(T)), } }; dropdown.ValueChanged += Dropdown_ValueChanged; @@ -92,6 +92,17 @@ namespace osu.Game.Overlays.Options { return new StyledDropDownComboBox(); } + + protected override IEnumerable> GetDropDownItems(IEnumerable values) + { + return values.Select(v => + { + var field = typeof(U).GetField(Enum.GetName(typeof(U), v)); + return new StyledDropDownMenuItem( + field.GetCustomAttribute()?.Description ?? field.Name, v); + }); + + } public StyledDropDownMenu() { @@ -101,7 +112,7 @@ namespace osu.Game.Overlays.Options protected override void AnimateOpen() { - foreach (StyledDropDownMenuItem child in DropDownList.Children) + foreach (StyledDropDownMenuItem child in DropDownItemsContainer.Children) { child.FadeIn(200); child.ResizeTo(new Vector2(1, 24), 200); @@ -111,7 +122,7 @@ namespace osu.Game.Overlays.Options protected override void AnimateClose() { - foreach (StyledDropDownMenuItem child in DropDownList.Children) + foreach (StyledDropDownMenuItem child in DropDownItemsContainer.Children) { child.ResizeTo(new Vector2(1, 0), 200); child.FadeOut(200); @@ -121,12 +132,35 @@ namespace osu.Game.Overlays.Options private class StyledDropDownComboBox : DropDownComboBox { - protected override Color4 BackgroundColour => new Color4(255, 255, 255, 100); - protected override Color4 BackgroundColourHover => Color4.HotPink; + private SpriteText label; + protected override string Label + { + get { return label.Text; } + set { label.Text = value; } + } public StyledDropDownComboBox() { Foreground.Padding = new MarginPadding(4); + + Children = new[] + { + label = new SpriteText(), + new TextAwesome + { + Icon = FontAwesome.fa_chevron_down, + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + Margin = new MarginPadding { Right = 4 }, + } + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + BackgroundColour = Color4.Black.Opacity(0.5f); + BackgroundColourHover = colours.PinkDarker; } } @@ -137,29 +171,36 @@ namespace osu.Game.Overlays.Options AutoSizeAxes = Axes.None; Height = 0; Foreground.Padding = new MarginPadding(2); + + Children = new[] + { + new FlowContainer + { + Direction = FlowDirection.HorizontalOnly, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Children = new Drawable[] + { + new TextAwesome + { + Icon = FontAwesome.fa_chevron_right, + Colour = Color4.Black, + Margin = new MarginPadding { Right = 3 }, + Origin = Anchor.CentreLeft, + Anchor = Anchor.CentreLeft, + }, + new SpriteText { Text = text } + } + } + }; } - protected override void OnSelectChange() + [BackgroundDependencyLoader] + private void load(OsuColour colours) { - if (!IsLoaded) - return; - - FormatBackground(); - FormatCaret(); - FormatLabel(); - } - - protected override void FormatCaret() - { - (Caret as SpriteText).Text = IsSelected ? @"+" : @"-"; - } - - protected override void FormatLabel() - { - if (IsSelected) - (Label as SpriteText).Text = @"*" + Value + @"*"; - else - (Label as SpriteText).Text = Value.ToString(); + BackgroundColour = Color4.Black.Opacity(0.5f); + BackgroundColourHover = colours.PinkDarker; + BackgroundColourSelected = Color4.Black.Opacity(0.5f); } } } diff --git a/osu.Game/Overlays/Options/Input/MouseOptions.cs b/osu.Game/Overlays/Options/Input/MouseOptions.cs index 9d0823ce07..56b34c5396 100644 --- a/osu.Game/Overlays/Options/Input/MouseOptions.cs +++ b/osu.Game/Overlays/Options/Input/MouseOptions.cs @@ -20,7 +20,6 @@ namespace osu.Game.Overlays.Options.Input { Children = new Drawable[] { - new SpriteText { Text = "Sensitivity: TODO slider" }, new SliderOption { LabelText = "Sensitivity", diff --git a/osu.Game/Overlays/Options/OptionsSection.cs b/osu.Game/Overlays/Options/OptionsSection.cs index 256d5c8218..5a5f22275b 100644 --- a/osu.Game/Overlays/Options/OptionsSection.cs +++ b/osu.Game/Overlays/Options/OptionsSection.cs @@ -3,6 +3,7 @@ using OpenTK; using OpenTK.Graphics; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; @@ -19,14 +20,16 @@ namespace osu.Game.Overlays.Options public abstract FontAwesome Icon { get; } public abstract string Header { get; } + private SpriteText headerLabel; + public OptionsSection() { Margin = new MarginPadding { Top = 20 }; - - const int headerSize = 26, headerMargin = 25; - const int borderSize = 2; AutoSizeAxes = Axes.Y; RelativeSizeAxes = Axes.X; + + const int headerSize = 26, headerMargin = 25; + const int borderSize = 2; AddInternal(new Drawable[] { new Box @@ -48,10 +51,9 @@ namespace osu.Game.Overlays.Options AutoSizeAxes = Axes.Y, Children = new[] { - new SpriteText + headerLabel = new SpriteText { TextSize = headerSize, - Colour = new Color4(247, 198, 35, 255), Text = Header, }, content = new FlowContainer @@ -66,5 +68,11 @@ namespace osu.Game.Overlays.Options }, }); } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + headerLabel.Colour = colours.Pink; + } } } \ No newline at end of file diff --git a/osu.Game/Overlays/Options/SidebarButton.cs b/osu.Game/Overlays/Options/SidebarButton.cs index a1edc997a1..da2704ee60 100644 --- a/osu.Game/Overlays/Options/SidebarButton.cs +++ b/osu.Game/Overlays/Options/SidebarButton.cs @@ -4,6 +4,7 @@ using System; using OpenTK; using OpenTK.Graphics; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -55,44 +56,49 @@ namespace osu.Game.Overlays.Options RelativeSizeAxes = Axes.X; Children = new Drawable[] { - backgroundBox = new Box + backgroundBox = new Box + { + RelativeSizeAxes = Axes.Both, + BlendingMode = BlendingMode.Additive, + Colour = OsuColour.Gray(60), + Alpha = 0, + }, + new Container + { + Width = OptionsSidebar.default_width, + RelativeSizeAxes = Axes.Y, + Children = new[] { - RelativeSizeAxes = Axes.Both, - BlendingMode = BlendingMode.Additive, - Colour = new Color4(60, 60, 60, 255), - Alpha = 0, - }, - new Container - { - Width = OptionsSidebar.default_width, - RelativeSizeAxes = Axes.Y, - Children = new[] + drawableIcon = new TextAwesome { - drawableIcon = new TextAwesome - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - }, - } - }, - headerText = new SpriteText - { - Position = new Vector2(OptionsSidebar.default_width + 10, 0), - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - }, - selectionIndicator = new Box - { - Alpha = 0, - RelativeSizeAxes = Axes.Y, - Width = 5, - Anchor = Anchor.CentreRight, - Origin = Anchor.CentreRight, - Colour = new Color4(247, 198, 35, 255) + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + }, } + }, + headerText = new SpriteText + { + Position = new Vector2(OptionsSidebar.default_width + 10, 0), + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + }, + selectionIndicator = new Box + { + Alpha = 0, + RelativeSizeAxes = Axes.Y, + Width = 5, + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + } }; } + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + selectionIndicator.Colour = colours.Pink; + } + protected override bool OnClick(InputState state) { Action?.Invoke(); diff --git a/osu.Game/Overlays/Options/SkinSection.cs b/osu.Game/Overlays/Options/SkinSection.cs index de88570a0e..f9f7587e72 100644 --- a/osu.Game/Overlays/Options/SkinSection.cs +++ b/osu.Game/Overlays/Options/SkinSection.cs @@ -62,7 +62,6 @@ namespace osu.Game.Overlays.Options LabelText = "Always use skin cursor", Bindable = config.GetBindable(OsuConfig.UseSkinCursor) }, - new SpriteText { Text = "Cursor size: TODO slider" }, new SliderOption { LabelText = "Cursor size", diff --git a/osu.Game/Overlays/Options/SliderOption.cs b/osu.Game/Overlays/Options/SliderOption.cs index d00eeebe35..e2e387d348 100644 --- a/osu.Game/Overlays/Options/SliderOption.cs +++ b/osu.Game/Overlays/Options/SliderOption.cs @@ -1,53 +1,172 @@ -using System; +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using OpenTK; +using OpenTK.Input; using OpenTK.Graphics; +using osu.Framework.Allocation; +using osu.Framework.Audio; +using osu.Framework.Audio.Sample; 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.Transformations; using osu.Framework.Graphics.UserInterface; +using osu.Framework.Input; +using osu.Game.Graphics; +using System.Linq; -namespace osu.Game.Overlays.Options -{ - public class SliderOption : FlowContainer where T : struct, - IComparable, IFormattable, IConvertible, IComparable, IEquatable - { - private SliderBar slider; - private SpriteText text; - - public string LabelText - { - get { return text.Text; } - set - { - text.Text = value; - text.Alpha = string.IsNullOrEmpty(value) ? 0 : 1; - } - } - - public BindableNumber Bindable - { - get { return slider.Bindable; } - set { slider.Bindable = value; } - } - - public SliderOption() - { - Direction = FlowDirection.VerticalOnly; - RelativeSizeAxes = Axes.X; - AutoSizeAxes = Axes.Y; - Children = new Drawable[] - { - text = new SpriteText { Alpha = 0 }, - slider = new SliderBar - { - Margin = new MarginPadding { Top = 5 }, - Height = 10, - RelativeSizeAxes = Axes.X, - Color = Color4.White, - SelectionColor = new Color4(255, 102, 170, 255), - } - }; - } - } -} \ No newline at end of file +namespace osu.Game.Overlays.Options +{ + public class SliderOption : FlowContainer where T : struct + { + private SliderBar slider; + private SpriteText text; + + public string LabelText + { + get { return text.Text; } + set + { + text.Text = value; + text.Alpha = string.IsNullOrEmpty(value) ? 0 : 1; + } + } + + public BindableNumber Bindable + { + get { return slider.Bindable; } + set { slider.Bindable = value; } + } + + public SliderOption() + { + Direction = FlowDirection.VerticalOnly; + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + Children = new Drawable[] + { + text = new SpriteText { Alpha = 0 }, + slider = new OsuSliderBar + { + Margin = new MarginPadding { Top = 5 }, + RelativeSizeAxes = Axes.X, + } + }; + } + + private class OsuSliderBar : SliderBar where U : struct + { + private AudioSample sample; + private double lastSampleTime; + + private Container nub; + private Box leftBox, rightBox; + + private float innerWidth + { + get + { + return DrawWidth - Height; + } + } + + public OsuSliderBar() + { + Height = 22; + Padding = new MarginPadding { Left = Height / 2, Right = Height / 2 }; + Children = new Drawable[] + { + leftBox = new Box + { + Height = 2, + RelativeSizeAxes = Axes.None, + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + }, + rightBox = new Box + { + Height = 2, + RelativeSizeAxes = Axes.None, + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + Alpha = 0.5f, + }, + nub = new Container + { + Width = Height, + Height = Height, + CornerRadius = Height / 2, + Origin = Anchor.TopCentre, + AutoSizeAxes = Axes.None, + RelativeSizeAxes = Axes.None, + Masking = true, + BorderThickness = 3, + Children = new[] + { + new Box + { + RelativeSizeAxes = Axes.Both + } + } + } + }; + } + + [BackgroundDependencyLoader] + private void load(AudioManager audio, OsuColour colours) + { + sample = audio.Sample.Get(@"Sliderbar/sliderbar"); + leftBox.Colour = colours.Pink; + rightBox.Colour = colours.Pink; + nub.BorderColour = colours.Pink; + (nub.Children.First() as Box).Colour = colours.Pink.Opacity(0); + } + + private void playSample() + { + if (Clock == null || Clock.CurrentTime - lastSampleTime <= 50) + return; + lastSampleTime = Clock.CurrentTime; + sample.Frequency.Value = 1 + NormalizedValue * 0.2f; + sample.Play(); + } + + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + if (args.Key == Key.Left || args.Key == Key.Right) + playSample(); + return base.OnKeyDown(state, args); + } + + protected override bool OnClick(InputState state) + { + playSample(); + return base.OnClick(state); + } + + protected override bool OnDrag(InputState state) + { + playSample(); + return base.OnDrag(state); + } + + protected override void Update() + { + base.Update(); + leftBox.Scale = new Vector2(MathHelper.Clamp( + nub.DrawPosition.X - nub.DrawWidth / 2 + 2, 0, innerWidth), 1); + rightBox.Scale = new Vector2(MathHelper.Clamp( + innerWidth - nub.DrawPosition.X - nub.DrawWidth / 2 + 2, 0, innerWidth), 1); + } + + protected override void UpdateValue(float value) + { + nub.MoveToX(innerWidth * value); + } + } + } +} diff --git a/osu.Game/Overlays/OptionsOverlay.cs b/osu.Game/Overlays/OptionsOverlay.cs index 33677799f1..0767a70739 100644 --- a/osu.Game/Overlays/OptionsOverlay.cs +++ b/osu.Game/Overlays/OptionsOverlay.cs @@ -23,6 +23,7 @@ using osu.Game.Overlays.Options.Graphics; using osu.Game.Overlays.Options.Input; using osu.Game.Overlays.Options.Online; using System; +using osu.Game.Graphics; namespace osu.Game.Overlays { @@ -45,6 +46,13 @@ namespace osu.Game.Overlays private float lastKnownScroll; public OptionsOverlay() + { + RelativeSizeAxes = Axes.Y; + AutoSizeAxes = Axes.X; + } + + [BackgroundDependencyLoader(permitNulls: true)] + private void load(OsuGame game, OsuColour colours) { sections = new OptionsSection[] { @@ -58,10 +66,6 @@ namespace osu.Game.Overlays new OnlineSection(), new MaintenanceSection(), }; - - RelativeSizeAxes = Axes.Y; - AutoSizeAxes = Axes.X; - Children = new Drawable[] { new Box @@ -94,7 +98,7 @@ namespace osu.Game.Overlays }, new SpriteText { - Colour = new Color4(255, 102, 170, 255), + Colour = colours.Pink, Text = "Change the way osu! behaves", TextSize = 18, Margin = new MarginPadding { Left = CONTENT_MARGINS, Bottom = 30 }, @@ -123,11 +127,7 @@ namespace osu.Game.Overlays ).ToArray() } }; - } - - [BackgroundDependencyLoader(permitNulls: true)] - private void load(OsuGame game) - { + scrollContainer.Padding = new MarginPadding { Top = game?.Toolbar.DrawHeight ?? 0 }; } diff --git a/osu.Game/Overlays/Toolbar/Toolbar.cs b/osu.Game/Overlays/Toolbar/Toolbar.cs index df6168b6c5..783f7b65da 100644 --- a/osu.Game/Overlays/Toolbar/Toolbar.cs +++ b/osu.Game/Overlays/Toolbar/Toolbar.cs @@ -66,7 +66,7 @@ namespace osu.Game.Overlays.Toolbar solidBackground = new Box { RelativeSizeAxes = Axes.Both, - Colour = new Color4(0.1f, 0.1f, 0.1f, 1), + Colour = OsuColour.Gray(0.1f), Alpha = alpha_normal, }, gradientBackground = new Box @@ -75,7 +75,8 @@ namespace osu.Game.Overlays.Toolbar Anchor = Anchor.BottomLeft, Alpha = 0, Height = 90, - ColourInfo = ColourInfo.GradientVertical(new Color4(0.1f, 0.1f, 0.1f, 0.5f), new Color4(0.1f, 0.1f, 0.1f, 0f)), + ColourInfo = ColourInfo.GradientVertical( + OsuColour.Gray(0.1f).Opacity(0.5f), OsuColour.Gray(0.1f).Opacity(0)), }, new FlowContainer { diff --git a/osu.Game/Overlays/Toolbar/ToolbarButton.cs b/osu.Game/Overlays/Toolbar/ToolbarButton.cs index 80b2fcdb42..47f2df8d3f 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarButton.cs @@ -70,7 +70,7 @@ namespace osu.Game.Overlays.Toolbar HoverBackground = new Box { RelativeSizeAxes = Axes.Both, - Colour = new Color4(80, 80, 80, 180), + Colour = OsuColour.Gray(80).Opacity(180), BlendingMode = BlendingMode.Additive, Alpha = 0, }, @@ -144,7 +144,7 @@ namespace osu.Game.Overlays.Toolbar { Action?.Invoke(); sampleClick.Play(); - HoverBackground.FlashColour(new Color4(255, 255, 255, 100), 500, EasingTypes.OutQuint); + HoverBackground.FlashColour(Color4.White.Opacity(100), 500, EasingTypes.OutQuint); return true; } @@ -174,7 +174,7 @@ namespace osu.Game.Overlays.Toolbar new Box { RelativeSizeAxes = Axes.Both, - Colour = new Color4(30, 30, 30, 255) + Colour = OsuColour.Gray(30) }, new Triangles { diff --git a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs index 22c214d82f..68ae31e934 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs @@ -13,6 +13,7 @@ using osu.Game.Graphics.Backgrounds; using osu.Game.Modes; using OpenTK; using OpenTK.Graphics; +using osu.Game.Graphics; namespace osu.Game.Overlays.Toolbar { diff --git a/osu.Game/Overlays/Toolbar/ToolbarOverlayToggleButton.cs b/osu.Game/Overlays/Toolbar/ToolbarOverlayToggleButton.cs index b72a358456..3e8a1831aa 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarOverlayToggleButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarOverlayToggleButton.cs @@ -17,6 +17,7 @@ using osu.Game.Configuration; using osu.Game.Online.API; using OpenTK; using OpenTK.Graphics; +using osu.Game.Graphics; namespace osu.Game.Overlays.Toolbar { @@ -41,7 +42,7 @@ namespace osu.Game.Overlays.Toolbar Add(StateBackground = new Box { RelativeSizeAxes = Axes.Both, - Colour = new Color4(150, 150, 150, 180), + Colour = OsuColour.Gray(150).Opacity(180), BlendingMode = BlendingMode.Additive, Depth = 2, Alpha = 0, diff --git a/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs b/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs index 09708fc403..e093dbeca0 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs @@ -16,6 +16,7 @@ using osu.Game.Configuration; using osu.Game.Online.API; using OpenTK; using OpenTK.Graphics; +using osu.Game.Graphics; namespace osu.Game.Overlays.Toolbar { @@ -73,7 +74,7 @@ namespace osu.Game.Overlays.Toolbar { Type = EdgeEffectType.Shadow, Radius = 4, - Colour = new Color4(0, 0, 0, 0.1f), + Colour = Color4.Black.Opacity(0.1f), }; Masking = true; diff --git a/osu.Game/Screens/Menu/Button.cs b/osu.Game/Screens/Menu/Button.cs index 28158457dd..719d75b018 100644 --- a/osu.Game/Screens/Menu/Button.cs +++ b/osu.Game/Screens/Menu/Button.cs @@ -64,7 +64,7 @@ namespace osu.Game.Screens.Menu EdgeEffect = new EdgeEffect { Type = EdgeEffectType.Shadow, - Colour = new Color4(0, 0, 0, 0.2f), + Colour = Color4.Black.Opacity(0.2f), Roundness = 5, Radius = 8, }, diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index 6e15d458c1..8825f9474b 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -72,7 +72,7 @@ namespace osu.Game.Screens.Menu { RelativeSizeAxes = Axes.Both, Size = new Vector2(2, 1), - Colour = new Color4(50, 50, 50, 255), + Colour = OsuColour.Gray(50), Anchor = Anchor.Centre, Origin = Anchor.Centre, }, diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 7e6f5d2b55..67f7e99a75 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -21,6 +21,9 @@ using OpenTK; using osu.Framework.GameModes; using osu.Game.Modes.UI; using osu.Game.Screens.Ranking; +using osu.Game.Configuration; +using osu.Framework.Configuration; +using System; namespace osu.Game.Screens.Play { @@ -42,10 +45,12 @@ namespace osu.Game.Screens.Play private ScoreProcessor scoreProcessor; private HitRenderer hitRenderer; + private Bindable dimLevel; [BackgroundDependencyLoader] private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuGameBase game) { + dimLevel = game.Config.GetBindable(OsuConfig.DimLevel); try { if (Beatmap == null) @@ -145,8 +150,22 @@ namespace osu.Game.Screens.Play base.OnEntering(last); (Background as BackgroundModeBeatmap)?.BlurTo(Vector2.Zero, 1000); + Background?.FadeTo((100f- dimLevel)/100, 1000); Content.Alpha = 0; + dimLevel.ValueChanged += dimChanged; + } + + protected override bool OnExiting(GameMode next) + { + dimLevel.ValueChanged -= dimChanged; + Background?.FadeTo(1f, 200); + return base.OnExiting(next); + } + + private void dimChanged(object sender, EventArgs e) + { + Background?.FadeTo((100f - dimLevel) / 100, 800); } class PlayerInputManager : UserInputManager @@ -158,25 +177,39 @@ namespace osu.Game.Screens.Play bool leftViaKeyboard; bool rightViaKeyboard; + Bindable mouseDisabled; + + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) + { + mouseDisabled = config.GetBindable(OsuConfig.MouseDisableButtons) + ?? new Bindable(false); + } protected override void TransformState(InputState state) { base.TransformState(state); - MouseState mouse = (MouseState)state.Mouse; - if (state.Keyboard != null) { leftViaKeyboard = state.Keyboard.Keys.Contains(Key.Z); rightViaKeyboard = state.Keyboard.Keys.Contains(Key.X); } - + + MouseState mouse = (MouseState)state.Mouse; if (state.Mouse != null) { - if (leftViaKeyboard) mouse.ButtonStates.Find(s => s.Button == MouseButton.Left).State = true; - if (rightViaKeyboard) mouse.ButtonStates.Find(s => s.Button == MouseButton.Right).State = true; + if (mouseDisabled.Value) + { + mouse.ButtonStates.Find(s => s.Button == MouseButton.Left).State = false; + mouse.ButtonStates.Find(s => s.Button == MouseButton.Right).State = false; + } + + if (leftViaKeyboard) + mouse.ButtonStates.Find(s => s.Button == MouseButton.Left).State = true; + if (rightViaKeyboard) + mouse.ButtonStates.Find(s => s.Button == MouseButton.Right).State = true; } - } } } diff --git a/osu.Game/Screens/Select/BeatmapInfoWedge.cs b/osu.Game/Screens/Select/BeatmapInfoWedge.cs index e4aa8f27b9..aad2982544 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedge.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedge.cs @@ -14,6 +14,7 @@ using osu.Game.Beatmaps; using osu.Game.Database; using osu.Framework.Graphics.Colour; using osu.Game.Beatmaps.Drawables; +using osu.Game.Graphics; namespace osu.Game.Screens.Select { @@ -61,6 +62,7 @@ namespace osu.Game.Screens.Select (beatmapInfoContainer = new BufferedContainer { Depth = newDepth, + PixelSnapping = true, CacheDrawnFrameBuffer = true, Shear = -Shear, RelativeSizeAxes = Axes.Both, @@ -79,7 +81,7 @@ namespace osu.Game.Screens.Select new Container { RelativeSizeAxes = Axes.Both, - ColourInfo = ColourInfo.GradientVertical(Color4.White, new Color4(1f, 1f, 1f, 0.3f)), + ColourInfo = ColourInfo.GradientVertical(Color4.White, Color4.White.Opacity(0.3f)), Children = new [] { // Zoomed-in and cropped beatmap background @@ -92,53 +94,53 @@ namespace osu.Game.Screens.Select }, }, // Text for beatmap info - new FlowContainer - { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - Direction = FlowDirection.VerticalOnly, - Margin = new MarginPadding { Top = 10, Left = 25, Right = 10, Bottom = 40 }, - AutoSizeAxes = Axes.Both, - Children = new[] - { - new SpriteText - { - Font = @"Exo2.0-MediumItalic", - Text = beatmapSetInfo.Metadata.Artist + " -- " + beatmapSetInfo.Metadata.Title, - TextSize = 28, - Shadow = true, - }, - new SpriteText - { - Font = @"Exo2.0-MediumItalic", - Text = beatmapInfo.Version, - TextSize = 17, - Shadow = true, - }, - new FlowContainer + new FlowContainer + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Direction = FlowDirection.VerticalOnly, + Margin = new MarginPadding { Top = 10, Left = 25, Right = 10, Bottom = 40 }, + AutoSizeAxes = Axes.Both, + Children = new[] + { + new SpriteText + { + Font = @"Exo2.0-MediumItalic", + Text = beatmapSetInfo.Metadata.Artist + " -- " + beatmapSetInfo.Metadata.Title, + TextSize = 28, + Shadow = true, + }, + new SpriteText + { + Font = @"Exo2.0-MediumItalic", + Text = beatmapInfo.Version, + TextSize = 17, + Shadow = true, + }, + new FlowContainer { Margin = new MarginPadding { Top = 10 }, Direction = FlowDirection.HorizontalOnly, AutoSizeAxes = Axes.Both, Children = new [] { - new SpriteText - { - Font = @"Exo2.0-Medium", - Text = "mapped by ", - TextSize = 15, - Shadow = true, + new SpriteText + { + Font = @"Exo2.0-Medium", + Text = "mapped by ", + TextSize = 15, + Shadow = true, }, - new SpriteText - { - Font = @"Exo2.0-Bold", - Text = beatmapSetInfo.Metadata.Author, - TextSize = 15, - Shadow = true, + new SpriteText + { + Font = @"Exo2.0-Bold", + Text = beatmapSetInfo.Metadata.Author, + TextSize = 15, + Shadow = true, }, } - } - } + } + } } } }).Preload(game, delegate(Drawable d) diff --git a/osu.Game/Screens/Select/CarouselContainer.cs b/osu.Game/Screens/Select/CarouselContainer.cs index 2c59639ce7..144e4cabba 100644 --- a/osu.Game/Screens/Select/CarouselContainer.cs +++ b/osu.Game/Screens/Select/CarouselContainer.cs @@ -1,19 +1,21 @@ //Copyright (c) 2007-2016 ppy Pty Ltd . //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK; -using osu.Framework.Caching; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Transformations; -using osu.Game.Database; -using System; -using System.Collections.Generic; -using System.Linq; -using osu.Framework.Extensions.IEnumerableExtensions; -using osu.Framework.Lists; -using osu.Game.Beatmaps.Drawables; +using OpenTK; +using osu.Framework.Caching; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Transformations; +using osu.Game.Database; +using System; +using System.Collections.Generic; +using System.Linq; +using osu.Framework.Extensions.IEnumerableExtensions; +using osu.Framework.Lists; +using osu.Game.Beatmaps.Drawables; using osu.Framework.Timing; +using osu.Framework.Input; +using OpenTK.Input; namespace osu.Game.Screens.Select { @@ -244,5 +246,47 @@ namespace osu.Game.Screens.Select updatePanel(p, halfHeight); } } + + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + int direction = 0; + bool skipDifficulties = false; + + switch (args.Key) + { + case Key.Up: + direction = -1; + break; + case Key.Down: + direction = 1; + break; + case Key.Left: + direction = -1; + skipDifficulties = true; + break; + case Key.Right: + direction = 1; + skipDifficulties = true; + break; + } + + if (direction != 0) + { + int index = SelectedGroup.BeatmapPanels.IndexOf(SelectedPanel) + direction; + + if (!skipDifficulties && index >= 0 && index < SelectedGroup.BeatmapPanels.Count) + //changing difficulty panel, not set. + SelectGroup(SelectedGroup, SelectedGroup.BeatmapPanels[index]); + else + { + index = (groups.IndexOf(SelectedGroup) + direction + groups.Count) % groups.Count; + SelectBeatmap(groups[index].BeatmapPanels.First().Beatmap); + } + + return true; + } + + return base.OnKeyDown(state, args); + } } } diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 9d2debb8aa..e0860fda4c 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -28,6 +28,9 @@ using osu.Framework.Audio.Sample; using osu.Framework.Graphics.Transformations; using osu.Game.Beatmaps.Drawables; using osu.Game.Graphics.Containers; +using osu.Framework.Input; +using OpenTK.Input; +using osu.Game.Graphics; namespace osu.Game.Screens.Select { @@ -60,7 +63,7 @@ namespace osu.Game.Screens.Select { RelativeSizeAxes = Axes.Both, Size = new Vector2(1, 0.5f), - Colour = new Color4(0, 0, 0, 0.5f), + Colour = Color4.Black.Opacity(0.5f), Shear = new Vector2(0.15f, 0), EdgeSmoothness = new Vector2(2, 0), }, @@ -70,7 +73,7 @@ namespace osu.Game.Screens.Select RelativePositionAxes = Axes.Y, Size = new Vector2(1, -0.5f), Position = new Vector2(0, 1), - Colour = new Color4(0, 0, 0, 0.5f), + Colour = Color4.Black.Opacity(0.5f), Shear = new Vector2(-0.15f, 0), EdgeSmoothness = new Vector2(2, 0), }, @@ -78,7 +81,34 @@ namespace osu.Game.Screens.Select } } - public PlaySongSelect() + Player player; + + private void start() + { + if (player != null) + return; + + //in the future we may want to move this logic to a PlayerLoader gamemode or similar, so we can rely on the SongSelect transition + //and provide a better loading experience (at the moment song select is still accepting input during preload). + player = new Player + { + BeatmapInfo = carousel.SelectedGroup.SelectedPanel.Beatmap, + PreferredPlayMode = playMode.Value + }; + + player.Preload(Game, delegate + { + if (!Push(player)) + { + player = null; + //error occured? + } + }); + } + + [BackgroundDependencyLoader(permitNulls: true)] + private void load(BeatmapDatabase beatmaps, AudioManager audio, BaseGame game, + OsuGame osuGame, OsuColour colours) { const float carouselWidth = 640; const float bottomToolHeight = 50; @@ -124,7 +154,7 @@ namespace osu.Game.Screens.Select { RelativeSizeAxes = Axes.Both, Size = Vector2.One, - Colour = new Color4(0, 0, 0, 0.5f), + Colour = Color4.Black.Opacity(0.5f), }, new BackButton { @@ -140,21 +170,13 @@ namespace osu.Game.Screens.Select RelativeSizeAxes = Axes.Y, Width = 100, Text = "Play", - Colour = new Color4(238, 51, 153, 255), - Action = () => Push(new Player - { - BeatmapInfo = carousel.SelectedGroup.SelectedPanel.Beatmap, - PreferredPlayMode = playMode.Value - }) + Colour = colours.Pink, + Action = start }, } } }; - } - - [BackgroundDependencyLoader(permitNulls: true)] - private void load(BeatmapDatabase beatmaps, AudioManager audio, BaseGame game, OsuGame osuGame) - { + if (osuGame != null) { playMode = osuGame.PlayMode; @@ -190,15 +212,14 @@ namespace osu.Game.Screens.Select Content.FadeInFromZero(250); - beatmapInfoWedge.MoveTo(wedged_container_start_position + new Vector2(-100, 50)); - beatmapInfoWedge.RotateTo(10); - - beatmapInfoWedge.MoveTo(wedged_container_start_position, 800, EasingTypes.OutQuint); - beatmapInfoWedge.RotateTo(0, 800, EasingTypes.OutQuint); + beatmapInfoWedge.MoveToX(wedged_container_start_position.X - 50); + beatmapInfoWedge.MoveToX(wedged_container_start_position.X, 800, EasingTypes.OutQuint); } protected override void OnResuming(GameMode last) { + player = null; + changeBackground(Beatmap); ensurePlayingSelected(); base.OnResuming(last); @@ -279,44 +300,53 @@ namespace osu.Game.Screens.Select /// private void selectionChanged(BeatmapGroup group, BeatmapInfo beatmap) { + bool beatmapSetChange = false; + if (!beatmap.Equals(Beatmap?.BeatmapInfo)) { - if (beatmap.BeatmapSetID == Beatmap?.BeatmapInfo.BeatmapSetID) + if (beatmap.BeatmapSetInfoID == Beatmap?.BeatmapInfo.BeatmapSetInfoID) sampleChangeDifficulty.Play(); else + { sampleChangeBeatmap.Play(); - + beatmapSetChange = true; + } Beatmap = database.GetWorkingBeatmap(beatmap, Beatmap); } - - ensurePlayingSelected(); + ensurePlayingSelected(beatmapSetChange); } - private async Task ensurePlayingSelected() + private void ensurePlayingSelected(bool preview = false) { - AudioTrack track = null; + AudioTrack track = Beatmap?.Track; - await Task.Run(() => track = Beatmap?.Track); - - Schedule(delegate + if (track != null) { - if (track != null) - { - trackManager.SetExclusive(track); - track.Start(); - } - }); + trackManager.SetExclusive(track); + if (preview) + track.Seek(Beatmap.Beatmap.Metadata.PreviewTime); + track.Start(); + } } private void addBeatmapSet(BeatmapSetInfo beatmapSet, BaseGame game) { - beatmapSet = database.GetWithChildren(beatmapSet.BeatmapSetID); - beatmapSet.Beatmaps.ForEach(b => database.GetChildren(b)); + beatmapSet = database.GetWithChildren(beatmapSet.ID); + beatmapSet.Beatmaps.ForEach(b => + { + database.GetChildren(b); + if (b.Metadata == null) b.Metadata = beatmapSet.Metadata; + }); + beatmapSet.Beatmaps = beatmapSet.Beatmaps.OrderBy(b => b.BaseDifficulty.OverallDifficulty).ToList(); - var beatmap = database.GetWorkingBeatmap(beatmapSet.Beatmaps.FirstOrDefault()); + var beatmap = new WorkingBeatmap(beatmapSet.Beatmaps.FirstOrDefault(), beatmapSet, database); - var group = new BeatmapGroup(beatmap) { SelectionChanged = selectionChanged }; + var group = new BeatmapGroup(beatmap) + { + SelectionChanged = selectionChanged, + StartRequested = b => start() + }; //for the time being, let's completely load the difficulty panels in the background. //this likely won't scale so well, but allows us to completely async the loading flow. @@ -343,5 +373,17 @@ namespace osu.Game.Screens.Select addBeatmapSet(beatmapSet, game); } } + + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + switch (args.Key) + { + case Key.Enter: + start(); + return true; + } + + return base.OnKeyDown(state, args); + } } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index a15cd5db7d..a4da659718 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -231,6 +231,7 @@ +