From d62da4334eae5a8b710f189bdee3862d6563dfbf Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Fri, 17 Nov 2017 12:26:13 +0300 Subject: [PATCH 01/12] Add and place all the bottom bar objects --- .../Edit/Components/BottomBarContainer.cs | 44 +++++++++ .../Edit/Components/PlaybackContainer.cs | 9 ++ .../Edit/Components/TimeInfoContainer.cs | 9 ++ .../Timelines/Summary/SummaryTimeline.cs | 98 ++++++++----------- osu.Game/Screens/Edit/Editor.cs | 40 +++++--- osu.Game/osu.Game.csproj | 3 + 6 files changed, 130 insertions(+), 73 deletions(-) create mode 100644 osu.Game/Screens/Edit/Components/BottomBarContainer.cs create mode 100644 osu.Game/Screens/Edit/Components/PlaybackContainer.cs create mode 100644 osu.Game/Screens/Edit/Components/TimeInfoContainer.cs diff --git a/osu.Game/Screens/Edit/Components/BottomBarContainer.cs b/osu.Game/Screens/Edit/Components/BottomBarContainer.cs new file mode 100644 index 0000000000..d1813a9c7b --- /dev/null +++ b/osu.Game/Screens/Edit/Components/BottomBarContainer.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.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics; + +namespace osu.Game.Screens.Edit.Components +{ + public class BottomBarContainer : Container + { + private const float corner_radius = 5; + private const float contents_padding = 15; + + private readonly Drawable background; + private readonly Container content; + + protected override Container Content => content; + + public BottomBarContainer() + { + Masking = true; + CornerRadius = corner_radius; + + InternalChildren = new[] + { + background = new Box { RelativeSizeAxes = Axes.Both }, + content = new Container + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Horizontal = contents_padding }, + } + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + background.Colour = colours.Gray1; + } + } +} diff --git a/osu.Game/Screens/Edit/Components/PlaybackContainer.cs b/osu.Game/Screens/Edit/Components/PlaybackContainer.cs new file mode 100644 index 0000000000..aeed10357b --- /dev/null +++ b/osu.Game/Screens/Edit/Components/PlaybackContainer.cs @@ -0,0 +1,9 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Screens.Edit.Components +{ + public class PlaybackContainer : BottomBarContainer + { + } +} diff --git a/osu.Game/Screens/Edit/Components/TimeInfoContainer.cs b/osu.Game/Screens/Edit/Components/TimeInfoContainer.cs new file mode 100644 index 0000000000..739a67219d --- /dev/null +++ b/osu.Game/Screens/Edit/Components/TimeInfoContainer.cs @@ -0,0 +1,9 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Screens.Edit.Components +{ + public class TimeInfoContainer : BottomBarContainer + { + } +} diff --git a/osu.Game/Screens/Edit/Components/Timelines/Summary/SummaryTimeline.cs b/osu.Game/Screens/Edit/Components/Timelines/Summary/SummaryTimeline.cs index 4d925f7584..4543679363 100644 --- a/osu.Game/Screens/Edit/Components/Timelines/Summary/SummaryTimeline.cs +++ b/osu.Game/Screens/Edit/Components/Timelines/Summary/SummaryTimeline.cs @@ -16,83 +16,66 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary /// /// The timeline that sits at the bottom of the editor. /// - public class SummaryTimeline : CompositeDrawable + public class SummaryTimeline : BottomBarContainer { - private const float corner_radius = 5; - private const float contents_padding = 15; - public Bindable Beatmap = new Bindable(); - private readonly Drawable background; - private readonly Drawable timelineBar; public SummaryTimeline() { - Masking = true; - CornerRadius = corner_radius; - TimelinePart markerPart, controlPointPart, bookmarkPart, breakPart; - InternalChildren = new[] + Children = new[] { - background = new Box { RelativeSizeAxes = Axes.Both }, - new Container + markerPart = new MarkerPart { RelativeSizeAxes = Axes.Both }, + controlPointPart = new ControlPointPart + { + Anchor = Anchor.Centre, + Origin = Anchor.BottomCentre, + RelativeSizeAxes = Axes.Both, + Height = 0.35f + }, + bookmarkPart = new BookmarkPart + { + Anchor = Anchor.Centre, + Origin = Anchor.TopCentre, + RelativeSizeAxes = Axes.Both, + Height = 0.35f + }, + timelineBar = new Container { RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding { Left = contents_padding, Right = contents_padding }, - Children = new[] + Children = new Drawable[] { - markerPart = new MarkerPart { RelativeSizeAxes = Axes.Both }, - controlPointPart = new ControlPointPart + new Circle { - Anchor = Anchor.Centre, - Origin = Anchor.BottomCentre, - RelativeSizeAxes = Axes.Both, - Height = 0.35f + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreRight, + Size = new Vector2(5) }, - bookmarkPart = new BookmarkPart + new Box { - Anchor = Anchor.Centre, - Origin = Anchor.TopCentre, - RelativeSizeAxes = Axes.Both, - Height = 0.35f + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + RelativeSizeAxes = Axes.X, + Height = 1, + EdgeSmoothness = new Vector2(0, 1), }, - timelineBar = new Container + new Circle { - RelativeSizeAxes = Axes.Both, - Children = new Drawable[] - { - new Circle - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreRight, - Size = new Vector2(5) - }, - new Box - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - RelativeSizeAxes = Axes.X, - Height = 1, - EdgeSmoothness = new Vector2(0, 1), - }, - new Circle - { - Anchor = Anchor.CentreRight, - Origin = Anchor.CentreLeft, - Size = new Vector2(5) - }, - } + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreLeft, + Size = new Vector2(5) }, - breakPart = new BreakPart - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.Both, - Height = 0.25f - } } + }, + breakPart = new BreakPart + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + Height = 0.25f } }; @@ -105,7 +88,6 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary [BackgroundDependencyLoader] private void load(OsuColour colours) { - background.Colour = colours.Gray1; timelineBar.Colour = colours.Gray5; } } diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index 74e55e58ad..2aef9b11e2 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -17,6 +17,7 @@ using osu.Game.Graphics.UserInterface; using osu.Game.Screens.Edit.Screens; using osu.Game.Screens.Edit.Screens.Compose; using osu.Game.Screens.Edit.Screens.Design; +using osu.Game.Screens.Edit.Components; namespace osu.Game.Screens.Edit { @@ -34,7 +35,9 @@ namespace osu.Game.Screens.Edit public Editor() { EditorMenuBar menuBar; + TimeInfoContainer timeInfo; SummaryTimeline timeline; + PlaybackContainer playback; Children = new[] { @@ -84,23 +87,30 @@ namespace osu.Game.Screens.Edit new Container { RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding { Top = 5, Bottom = 5, Left = 10, Right = 10 }, - Child = new FillFlowContainer + Padding = new MarginPadding { Vertical = 5, Horizontal = 10 }, + Children = new Drawable[] { - Name = "Bottom bar", - RelativeSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Spacing = new Vector2(10, 0), - Children = new[] + timeInfo = new TimeInfoContainer { - timeline = new SummaryTimeline - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.Both, - Width = 0.65f - } - } + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + RelativeSizeAxes = Axes.Both, + Width = 0.17f + }, + timeline = new SummaryTimeline + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + Width = 0.65f + }, + playback = new PlaybackContainer + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + RelativeSizeAxes = Axes.Both, + Width = 0.17f + }, } } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 7b479bdba2..63dbb06491 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -294,6 +294,9 @@ + + + From cc04d5bc616f32046d930bf42dca434fdd097c51 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Fri, 17 Nov 2017 13:35:41 +0300 Subject: [PATCH 02/12] Add all the objects to the PlaybackContainer --- .../Edit/Components/BottomBarContainer.cs | 4 + .../Edit/Components/PlaybackContainer.cs | 161 ++++++++++++++++++ .../Timelines/Summary/SummaryTimeline.cs | 4 - osu.Game/Screens/Edit/Editor.cs | 2 + 4 files changed, 167 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Edit/Components/BottomBarContainer.cs b/osu.Game/Screens/Edit/Components/BottomBarContainer.cs index d1813a9c7b..b230032937 100644 --- a/osu.Game/Screens/Edit/Components/BottomBarContainer.cs +++ b/osu.Game/Screens/Edit/Components/BottomBarContainer.cs @@ -2,9 +2,11 @@ // 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.Graphics.Containers; using osu.Framework.Graphics.Shapes; +using osu.Game.Beatmaps; using osu.Game.Graphics; namespace osu.Game.Screens.Edit.Components @@ -14,6 +16,8 @@ namespace osu.Game.Screens.Edit.Components private const float corner_radius = 5; private const float contents_padding = 15; + public Bindable Beatmap = new Bindable(); + private readonly Drawable background; private readonly Container content; diff --git a/osu.Game/Screens/Edit/Components/PlaybackContainer.cs b/osu.Game/Screens/Edit/Components/PlaybackContainer.cs index aeed10357b..23484464bf 100644 --- a/osu.Game/Screens/Edit/Components/PlaybackContainer.cs +++ b/osu.Game/Screens/Edit/Components/PlaybackContainer.cs @@ -1,9 +1,170 @@ // 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.Audio.Track; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.UserInterface; +using osu.Framework.Input; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.UserInterface; + namespace osu.Game.Screens.Edit.Components { public class PlaybackContainer : BottomBarContainer { + private readonly IconButton playButton; + + private bool lastTrackState; + private Track track => Beatmap.Value.Track; + + public PlaybackContainer() + { + PlaybackTabControl tabs; + + Children = new Drawable[] + { + playButton = new IconButton + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.Centre, + Scale = new Vector2(1.4f), + IconScale = new Vector2(1.4f), + Icon = FontAwesome.fa_play_circle_o, + Action = play, + Padding = new MarginPadding { Left = 20 } + }, + new OsuSpriteText + { + Origin = Anchor.BottomLeft, + Text = "Playback Speed", + RelativePositionAxes = Axes.Y, + Y = 0.5f, + Padding = new MarginPadding { Left = 45 } + }, + new Container + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + RelativeSizeAxes = Axes.Both, + Height = 0.5f, + Padding = new MarginPadding { Left = 45 }, + Child = tabs = new PlaybackTabControl(), + } + }; + + tabs.AddItem(0.25); + tabs.AddItem(0.75); + tabs.AddItem(1); + + tabs.Current.ValueChanged += newValue => track.Tempo.Value = newValue; + } + + private void play() + { + if (track.IsRunning) + track.Stop(); + else + track.Start(); + } + + protected override void Update() + { + base.Update(); + + var currentTrackState = track.IsRunning; + if (currentTrackState == lastTrackState) + return; + + playButton.Icon = currentTrackState ? FontAwesome.fa_pause_circle_o : FontAwesome.fa_play_circle_o; + + lastTrackState = currentTrackState; + } + + private class PlaybackTabControl : OsuTabControl + { + protected override TabItem CreateTabItem(double value) => new PlaybackTabItem(value); + + protected override Dropdown CreateDropdown() => null; + + public PlaybackTabControl() + { + RelativeSizeAxes = Axes.Both; + TabContainer.Spacing = new Vector2(20, 0); + } + + public class PlaybackTabItem : TabItem + { + private const float fade_duration = 100; + + private readonly OsuSpriteText text; + private readonly OsuSpriteText textBold; + + public PlaybackTabItem(double value) : base(value) + { + AutoSizeAxes = Axes.X; + RelativeSizeAxes = Axes.Y; + + Children = new Drawable[] + { + text = new OsuSpriteText + { + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + Text = $"{value:P0}", + TextSize = 14, + }, + textBold = new OsuSpriteText + { + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + Text = $"{value:P0}", + TextSize = 14, + Font = @"Exo2.0-Bold", + Alpha = 0, + AlwaysPresent = true, + }, + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + text.Colour = colours.Gray5; + } + + protected override bool OnHover(InputState state) + { + if (!Active) + toBold(); + return true; + } + + protected override void OnHoverLost(InputState state) + { + if (!Active) + toNormal(); + } + + private void toBold() + { + text.FadeOut(fade_duration); + textBold.FadeIn(fade_duration); + } + + private void toNormal() + { + text.FadeIn(fade_duration); + textBold.FadeOut(fade_duration); + } + + protected override void OnActivated() => toBold(); + + protected override void OnDeactivated() => toNormal(); + } + } } } diff --git a/osu.Game/Screens/Edit/Components/Timelines/Summary/SummaryTimeline.cs b/osu.Game/Screens/Edit/Components/Timelines/Summary/SummaryTimeline.cs index 4543679363..a63d02a0a5 100644 --- a/osu.Game/Screens/Edit/Components/Timelines/Summary/SummaryTimeline.cs +++ b/osu.Game/Screens/Edit/Components/Timelines/Summary/SummaryTimeline.cs @@ -3,11 +3,9 @@ using OpenTK; using osu.Framework.Allocation; -using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Screens.Edit.Components.Timelines.Summary.Parts; @@ -18,8 +16,6 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary /// public class SummaryTimeline : BottomBarContainer { - public Bindable Beatmap = new Bindable(); - private readonly Drawable timelineBar; public SummaryTimeline() diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index 2aef9b11e2..51af6e2f5e 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -117,7 +117,9 @@ namespace osu.Game.Screens.Edit }, }; + timeInfo.Beatmap.BindTo(Beatmap); timeline.Beatmap.BindTo(Beatmap); + playback.Beatmap.BindTo(Beatmap); menuBar.Mode.ValueChanged += onModeChanged; } From 1680c0905fb06f5201561cd8c37dadbb821048a4 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Fri, 17 Nov 2017 14:02:07 +0300 Subject: [PATCH 03/12] Fix track tempo could be less than 1 on exiting the editor --- osu.Game/Screens/Edit/Editor.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index 51af6e2f5e..6865debd27 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -166,6 +166,7 @@ namespace osu.Game.Screens.Edit protected override bool OnExiting(Screen next) { Background.FadeColour(Color4.White, 500); + Beatmap.Value.Track.Tempo.Value = 1; Beatmap.Value.Track?.Start(); return base.OnExiting(next); } From 07e0aba01c1aafa7f70c0ba91caba80d9a480e52 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Fri, 17 Nov 2017 14:10:13 +0300 Subject: [PATCH 04/12] Remove using --- osu.Game/Screens/Edit/Editor.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index 6865debd27..fd85db595a 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -10,7 +10,6 @@ using osu.Framework.Graphics.Shapes; using osu.Game.Graphics; using osu.Game.Screens.Edit.Menus; using osu.Game.Screens.Edit.Components.Timelines.Summary; -using OpenTK; using osu.Framework.Allocation; using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics.UserInterface; From 7492ab6495204cac230cb7225dbc98bcf4e6327b Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Sat, 18 Nov 2017 01:48:50 +0300 Subject: [PATCH 05/12] Use GridContainer to place the bottom bar objects --- osu.Game/Screens/Edit/Editor.cs | 48 +++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index fd85db595a..c94da8c5c5 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -87,30 +87,38 @@ namespace osu.Game.Screens.Edit { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Vertical = 5, Horizontal = 10 }, - Children = new Drawable[] + Child = new GridContainer { - timeInfo = new TimeInfoContainer + RelativeSizeAxes = Axes.Both, + ColumnDimensions = new Dimension[] { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - RelativeSizeAxes = Axes.Both, - Width = 0.17f + new Dimension(GridSizeMode.Auto), + new Dimension(GridSizeMode.Relative, 0.67f), + new Dimension(GridSizeMode.Auto), }, - timeline = new SummaryTimeline + Content = new Drawable[][] { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.Both, - Width = 0.65f - }, - playback = new PlaybackContainer - { - Anchor = Anchor.CentreRight, - Origin = Anchor.CentreRight, - RelativeSizeAxes = Axes.Both, - Width = 0.17f - }, - } + new Drawable[] + { + new Container + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Right = 10 }, + Child = timeInfo = new TimeInfoContainer { RelativeSizeAxes = Axes.Both }, + }, + timeline = new SummaryTimeline + { + RelativeSizeAxes = Axes.Both, + }, + new Container + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Left = 10 }, + Child = playback = new PlaybackContainer { RelativeSizeAxes = Axes.Both }, + } + }, + } + }, } } }, From 0b8fed4e5a8e2d1d5b59b77b45a0d0abe7001f3c Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Sat, 18 Nov 2017 01:51:23 +0300 Subject: [PATCH 06/12] Remove useless Dimention params --- osu.Game/Screens/Edit/Editor.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index c94da8c5c5..be6a168982 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -92,9 +92,9 @@ namespace osu.Game.Screens.Edit RelativeSizeAxes = Axes.Both, ColumnDimensions = new Dimension[] { - new Dimension(GridSizeMode.Auto), + new Dimension(), new Dimension(GridSizeMode.Relative, 0.67f), - new Dimension(GridSizeMode.Auto), + new Dimension(), }, Content = new Drawable[][] { From 58e72631087b491fb04e6dc641568cccb3b8b53f Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Sat, 18 Nov 2017 03:09:09 +0300 Subject: [PATCH 07/12] CI fixes --- osu.Game/Screens/Edit/Editor.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index be6a168982..9093bf5629 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -90,13 +90,13 @@ namespace osu.Game.Screens.Edit Child = new GridContainer { RelativeSizeAxes = Axes.Both, - ColumnDimensions = new Dimension[] + ColumnDimensions = new[] { new Dimension(), new Dimension(GridSizeMode.Relative, 0.67f), new Dimension(), }, - Content = new Drawable[][] + Content = new[] { new Drawable[] { @@ -105,7 +105,7 @@ namespace osu.Game.Screens.Edit RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Right = 10 }, Child = timeInfo = new TimeInfoContainer { RelativeSizeAxes = Axes.Both }, - }, + }, timeline = new SummaryTimeline { RelativeSizeAxes = Axes.Both, From 34d8f94f99178ac14c34f7aff5618edcd00bb822 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Sat, 18 Nov 2017 08:24:09 +0300 Subject: [PATCH 08/12] Add track timer --- .../Edit/Components/BottomBarContainer.cs | 2 ++ .../Edit/Components/PlaybackContainer.cs | 11 +++--- .../Edit/Components/TimeInfoContainer.cs | 36 +++++++++++++++++++ 3 files changed, 43 insertions(+), 6 deletions(-) diff --git a/osu.Game/Screens/Edit/Components/BottomBarContainer.cs b/osu.Game/Screens/Edit/Components/BottomBarContainer.cs index b230032937..d65355b5f4 100644 --- a/osu.Game/Screens/Edit/Components/BottomBarContainer.cs +++ b/osu.Game/Screens/Edit/Components/BottomBarContainer.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Allocation; +using osu.Framework.Audio.Track; using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -17,6 +18,7 @@ namespace osu.Game.Screens.Edit.Components private const float contents_padding = 15; public Bindable Beatmap = new Bindable(); + protected Track Track => Beatmap.Value.Track; private readonly Drawable background; private readonly Container content; diff --git a/osu.Game/Screens/Edit/Components/PlaybackContainer.cs b/osu.Game/Screens/Edit/Components/PlaybackContainer.cs index 23484464bf..9640d91615 100644 --- a/osu.Game/Screens/Edit/Components/PlaybackContainer.cs +++ b/osu.Game/Screens/Edit/Components/PlaybackContainer.cs @@ -19,7 +19,6 @@ namespace osu.Game.Screens.Edit.Components private readonly IconButton playButton; private bool lastTrackState; - private Track track => Beatmap.Value.Track; public PlaybackContainer() { @@ -60,22 +59,22 @@ namespace osu.Game.Screens.Edit.Components tabs.AddItem(0.75); tabs.AddItem(1); - tabs.Current.ValueChanged += newValue => track.Tempo.Value = newValue; + tabs.Current.ValueChanged += newValue => Track.Tempo.Value = newValue; } private void play() { - if (track.IsRunning) - track.Stop(); + if (Track.IsRunning) + Track.Stop(); else - track.Start(); + Track.Start(); } protected override void Update() { base.Update(); - var currentTrackState = track.IsRunning; + var currentTrackState = Track.IsRunning; if (currentTrackState == lastTrackState) return; diff --git a/osu.Game/Screens/Edit/Components/TimeInfoContainer.cs b/osu.Game/Screens/Edit/Components/TimeInfoContainer.cs index 739a67219d..4a07ab4434 100644 --- a/osu.Game/Screens/Edit/Components/TimeInfoContainer.cs +++ b/osu.Game/Screens/Edit/Components/TimeInfoContainer.cs @@ -1,9 +1,45 @@ // 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.Game.Graphics.Sprites; +using System; + namespace osu.Game.Screens.Edit.Components { public class TimeInfoContainer : BottomBarContainer { + private const int count_duration = 150; + + private readonly OsuSpriteText trackTimer; + private double savedTime; + + public TimeInfoContainer() + { + Children = new Drawable[] + { + trackTimer = new OsuSpriteText + { + Origin = Anchor.BottomLeft, + RelativePositionAxes = Axes.Y, + TextSize = 22, + FixedWidth = true, + Y = 0.5f, + } + }; + } + + protected override void Update() + { + base.Update(); + + var currentTime = Track.CurrentTime; + + if (savedTime == currentTime) + return; + + trackTimer.Text = TimeSpan.FromMilliseconds(currentTime).ToString(@"mm\:ss\:fff"); + savedTime = currentTime; + } } } From 4ee3a89c129fb4bf64c6cd716e45abe17af7745f Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Sat, 18 Nov 2017 08:35:00 +0300 Subject: [PATCH 09/12] Remove using --- osu.Game/Screens/Edit/Components/PlaybackContainer.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Screens/Edit/Components/PlaybackContainer.cs b/osu.Game/Screens/Edit/Components/PlaybackContainer.cs index 9640d91615..a88983e3e4 100644 --- a/osu.Game/Screens/Edit/Components/PlaybackContainer.cs +++ b/osu.Game/Screens/Edit/Components/PlaybackContainer.cs @@ -3,7 +3,6 @@ using OpenTK; using osu.Framework.Allocation; -using osu.Framework.Audio.Track; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.UserInterface; From ecc2877be6457420e3a978428ffff5949ee5d815 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Mon, 20 Nov 2017 09:29:26 +0300 Subject: [PATCH 10/12] Fix possible null and adjust timeline width --- osu.Game/Screens/Edit/Editor.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index 9093bf5629..52baadd442 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -93,8 +93,7 @@ namespace osu.Game.Screens.Edit ColumnDimensions = new[] { new Dimension(), - new Dimension(GridSizeMode.Relative, 0.67f), - new Dimension(), + new Dimension(GridSizeMode.Relative, 0.65f), }, Content = new[] { @@ -173,8 +172,11 @@ namespace osu.Game.Screens.Edit protected override bool OnExiting(Screen next) { Background.FadeColour(Color4.White, 500); - Beatmap.Value.Track.Tempo.Value = 1; - Beatmap.Value.Track?.Start(); + if (Beatmap.Value.Track != null) + { + Beatmap.Value.Track.Tempo.Value = 1; + Beatmap.Value.Track.Start(); + } return base.OnExiting(next); } } From 0d1b5ae44f6f64529775d10fdd4adef5f5cf3d17 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 21 Nov 2017 17:51:07 +0900 Subject: [PATCH 11/12] Adjust bottom bar sizing as suggested --- osu.Game/Screens/Edit/Editor.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index 52baadd442..e2971deb75 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -92,8 +92,9 @@ namespace osu.Game.Screens.Edit RelativeSizeAxes = Axes.Both, ColumnDimensions = new[] { + new Dimension(GridSizeMode.Absolute, 220), new Dimension(), - new Dimension(GridSizeMode.Relative, 0.65f), + new Dimension(GridSizeMode.Absolute, 220) }, Content = new[] { From 41498ffad3f6b26b8ceb17696ec970ad8aa044c6 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Tue, 21 Nov 2017 12:22:19 +0300 Subject: [PATCH 12/12] Apply suggestions --- .../Screens/Edit/Components/PlaybackContainer.cs | 14 +++----------- .../Screens/Edit/Components/TimeInfoContainer.cs | 9 +-------- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/osu.Game/Screens/Edit/Components/PlaybackContainer.cs b/osu.Game/Screens/Edit/Components/PlaybackContainer.cs index a88983e3e4..a7d1db4802 100644 --- a/osu.Game/Screens/Edit/Components/PlaybackContainer.cs +++ b/osu.Game/Screens/Edit/Components/PlaybackContainer.cs @@ -17,8 +17,6 @@ namespace osu.Game.Screens.Edit.Components { private readonly IconButton playButton; - private bool lastTrackState; - public PlaybackContainer() { PlaybackTabControl tabs; @@ -32,7 +30,7 @@ namespace osu.Game.Screens.Edit.Components Scale = new Vector2(1.4f), IconScale = new Vector2(1.4f), Icon = FontAwesome.fa_play_circle_o, - Action = play, + Action = playPause, Padding = new MarginPadding { Left = 20 } }, new OsuSpriteText @@ -61,7 +59,7 @@ namespace osu.Game.Screens.Edit.Components tabs.Current.ValueChanged += newValue => Track.Tempo.Value = newValue; } - private void play() + private void playPause() { if (Track.IsRunning) Track.Stop(); @@ -73,13 +71,7 @@ namespace osu.Game.Screens.Edit.Components { base.Update(); - var currentTrackState = Track.IsRunning; - if (currentTrackState == lastTrackState) - return; - - playButton.Icon = currentTrackState ? FontAwesome.fa_pause_circle_o : FontAwesome.fa_play_circle_o; - - lastTrackState = currentTrackState; + playButton.Icon = Track.IsRunning ? FontAwesome.fa_pause_circle_o : FontAwesome.fa_play_circle_o; } private class PlaybackTabControl : OsuTabControl diff --git a/osu.Game/Screens/Edit/Components/TimeInfoContainer.cs b/osu.Game/Screens/Edit/Components/TimeInfoContainer.cs index 4a07ab4434..b9b6867ea6 100644 --- a/osu.Game/Screens/Edit/Components/TimeInfoContainer.cs +++ b/osu.Game/Screens/Edit/Components/TimeInfoContainer.cs @@ -12,7 +12,6 @@ namespace osu.Game.Screens.Edit.Components private const int count_duration = 150; private readonly OsuSpriteText trackTimer; - private double savedTime; public TimeInfoContainer() { @@ -33,13 +32,7 @@ namespace osu.Game.Screens.Edit.Components { base.Update(); - var currentTime = Track.CurrentTime; - - if (savedTime == currentTime) - return; - - trackTimer.Text = TimeSpan.FromMilliseconds(currentTime).ToString(@"mm\:ss\:fff"); - savedTime = currentTime; + trackTimer.Text = TimeSpan.FromMilliseconds(Track.CurrentTime).ToString(@"mm\:ss\:fff"); } } }