diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Components/Badges/LanguageInfoBadge.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Components/Badges/LanguageInfoBadge.cs new file mode 100644 index 000000000..1cbb890ac --- /dev/null +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Components/Badges/LanguageInfoBadge.cs @@ -0,0 +1,32 @@ +// Copyright (c) andy840119 . Licensed under the GPL Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Allocation; +using osu.Game.Graphics; +using osu.Game.Rulesets.Karaoke.Objects; + +namespace osu.Game.Rulesets.Karaoke.Edit.Lyrics.Components.Badges +{ + public class LanguageInfoBadge : Badge + { + public LanguageInfoBadge(Lyric lyric) + : base(lyric) + { + lyric.LanguageBindable.BindValueChanged(value => + { + var language = value.NewValue; + + if (language == null) + BadgeText = "None"; + else + BadgeText = language.DisplayName; + }, true); + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + BadgeColour = colours.BlueDarker; + } + } +} diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Components/Badges/TimeInfoBadge.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Components/Badges/TimeInfoBadge.cs deleted file mode 100644 index a80ef30f2..000000000 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Components/Badges/TimeInfoBadge.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) andy840119 . Licensed under the GPL Licence. -// See the LICENCE file in the repository root for full licence text. - -using System; -using osu.Framework.Allocation; -using osu.Framework.Input.Events; -using osu.Framework.Timing; -using osu.Game.Graphics; -using osu.Game.Rulesets.Karaoke.Objects; - -namespace osu.Game.Rulesets.Karaoke.Edit.Lyrics.Components.Badges -{ - public class TimeInfoBadge : Badge - { - [Resolved] - private IAdjustableClock adjustableClock { get; set; } - - public TimeInfoBadge(Lyric lyric) - : base(lyric) - { - lyric.StartTimeBindable.BindValueChanged(value => { changeTime(); }, true); - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - BadgeColour = colours.Gray7; - } - - protected override bool OnClick(ClickEvent e) - { - adjustableClock.Seek(Lyric.StartTime); - return base.OnClick(e); - } - - private void changeTime() - { - BadgeText = $"{getTime(Lyric.StartTime)} - {getTime(Lyric.EndTime)}"; - - static string getTime(double time) => TimeSpan.FromMilliseconds(time).ToString(@"mm\:ss\:fff"); - } - } -} diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Components/Infos/TimeInfoContainer.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Components/Infos/TimeInfoContainer.cs new file mode 100644 index 000000000..219fbd5ea --- /dev/null +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Components/Infos/TimeInfoContainer.cs @@ -0,0 +1,49 @@ +// Copyright (c) andy840119 . Licensed under the GPL Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Game.Extensions; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Game.Rulesets.Karaoke.Objects; + +namespace osu.Game.Rulesets.Karaoke.Edit.Lyrics.Components.Infos +{ + public class TimeInfoContainer : Container + { + private readonly Box background; + private readonly OsuSpriteText timeRange; + + public TimeInfoContainer(Lyric lyric) + { + Children = new Drawable[] + { + background = new Box + { + RelativeSizeAxes = Axes.Both + }, + timeRange = new OsuSpriteText + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + Font = OsuFont.GetFont(size: 16, fixedWidth: true), + Padding = new MarginPadding(10), + } + }; + + // todo : might move to another function for updating time. + var startTime = lyric.StartTime.ToEditorFormattedString(); + var endTime = lyric.EndTime.ToEditorFormattedString(); + timeRange.Text = startTime + " - " + endTime; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + background.Colour = colours.Gray4; + } + } +} diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/DrawableLyricEditList.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/DrawableLyricEditList.cs index 75e8fc983..50ccfe878 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/DrawableLyricEditList.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/DrawableLyricEditList.cs @@ -8,6 +8,8 @@ namespace osu.Game.Rulesets.Karaoke.Edit.Lyrics { public class DrawableLyricEditList : OsuRearrangeableListContainer { + public const int SPACING = 2; + protected override OsuRearrangeableListItem CreateOsuDrawable(Lyric item) => new DrawableLyricEditListItem(item); } diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/DrawableLyricEditListItem.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/DrawableLyricEditListItem.cs index b05e1b1bd..055f88b12 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/DrawableLyricEditListItem.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/DrawableLyricEditListItem.cs @@ -10,6 +10,7 @@ using osu.Game.Graphics.Containers; using osu.Game.Rulesets.Karaoke.Edit.Lyrics.Components; using osu.Game.Rulesets.Karaoke.Edit.Lyrics.Components.Badges; +using osu.Game.Rulesets.Karaoke.Edit.Lyrics.Components.Infos; using osu.Game.Rulesets.Karaoke.Objects; using osuTK; @@ -17,6 +18,11 @@ namespace osu.Game.Rulesets.Karaoke.Edit.Lyrics { public class DrawableLyricEditListItem : OsuRearrangeableListItem { + private const int continuous_spacing = 20; + private const int info_part_spacing = 200; + private const int min_height = 75; + private const int max_height = 120; + private Box background; private Box dragAlert; private Box headerBackground; @@ -28,12 +34,21 @@ public DrawableLyricEditListItem(Lyric item) protected override Drawable CreateContent() { + // todo : need to refactor this part. + var isContinuous = Model.LayoutIndex == -1; + var continuousSpacing = isContinuous ? continuous_spacing : 0; + return new Container { Masking = true, CornerRadius = 5, AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, + Margin = new MarginPadding + { + Left = continuousSpacing, + Top = DrawableLyricEditList.SPACING, + }, Children = new Drawable[] { background = new Box @@ -50,33 +65,51 @@ protected override Drawable CreateContent() { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, + ColumnDimensions = new[] + { + new Dimension(GridSizeMode.Absolute, info_part_spacing - continuousSpacing), + new Dimension(GridSizeMode.Distributed) + }, + RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize, minSize: min_height, maxSize: max_height) }, Content = new[] { new[] { new Container { - RelativeSizeAxes = Axes.Both, + // todo : cannot use relative size to both because it will cause size cannot roll-back if make lyric smaller. + RelativeSizeAxes = Axes.X, + Height = min_height, Children = new Drawable[] { headerBackground = new Box { - RelativeSizeAxes = Axes.Both, + RelativeSizeAxes = Axes.X, + Height = max_height, Alpha = 0.7f }, new BadgeFillFlowContainer { Direction = FillDirection.Vertical, - AutoSizeAxes = Axes.Both, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, Anchor = Anchor.TopRight, Origin = Anchor.TopRight, Spacing = new Vector2(5), - Padding = new MarginPadding(10), - Children = new Badge[] + Children = new Drawable[] { - new TimeInfoBadge(Model), - new StyleInfoBadge(Model), - new LayoutInfoBadge(Model), + new TimeInfoContainer(Model) + { + RelativeSizeAxes = Axes.X, + Height = 36, + }, + + // todo : in small display size use badge. + // in larger size should use real icon. + new LanguageInfoBadge(Model) + { + Margin = new MarginPadding{ Right = 5 } + } } }, } @@ -87,9 +120,7 @@ protected override Drawable CreateContent() RelativeSizeAxes = Axes.X, } } - }, - ColumnDimensions = new[] { new Dimension(GridSizeMode.Absolute, 200) }, - RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) } + } } } }; @@ -118,9 +149,9 @@ protected override void OnDragEnd(DragEndEvent e) base.OnDragEnd(e); } - public class BadgeFillFlowContainer : FillFlowContainer + public class BadgeFillFlowContainer : FillFlowContainer { - public override void Add(Badge drawable) + public override void Add(Drawable drawable) { drawable.Anchor = Anchor.TopRight; drawable.Origin = Anchor.TopRight; diff --git a/osu.Game.Rulesets.Karaoke/Edit/Translate/TranslateEditSection.cs b/osu.Game.Rulesets.Karaoke/Edit/Translate/TranslateEditSection.cs index 4ad3cf62b..6be984596 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Translate/TranslateEditSection.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Translate/TranslateEditSection.cs @@ -10,6 +10,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Game.Beatmaps; +using osu.Game.Extensions; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; @@ -167,8 +168,8 @@ private Drawable[][] createContent(EditorBeatmap editorBeatmap, Bindable TranslateTextBindable = new Bindable(); - public CultureInfo Language { get; set; } - /// /// Translates /// public IDictionary Translates { get; set; } = new Dictionary(); + [JsonIgnore] + public readonly Bindable LanguageBindable = new Bindable(); + + /// + /// Language + /// + public CultureInfo Language + { + get => LanguageBindable.Value; + set => LanguageBindable.Value = value; + } + /// /// Display target translate ///