Skip to content

Commit

Permalink
Use badge if in small size.
Browse files Browse the repository at this point in the history
  • Loading branch information
andy840119 committed Dec 6, 2020
1 parent e44b1f7 commit 10f5b92
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 47 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) andy840119 <[email protected]>. 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;
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using osu.Game.Graphics;
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;
Expand Down Expand Up @@ -76,7 +77,9 @@ protected override Drawable CreateContent()
{
new Container
{
// 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
Expand All @@ -93,12 +96,19 @@ protected override Drawable CreateContent()
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
Spacing = new Vector2(5),
Children = new []
Children = new Drawable[]
{
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 }
}
}
},
Expand Down
12 changes: 10 additions & 2 deletions osu.Game.Rulesets.Karaoke/Objects/Lyric.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,21 @@ public int LayoutIndex
[JsonIgnore]
public readonly Bindable<string> TranslateTextBindable = new Bindable<string>();

public CultureInfo Language { get; set; }

/// <summary>
/// Translates
/// </summary>
public IDictionary<int, string> Translates { get; set; } = new Dictionary<int, string>();


[JsonIgnore]
public readonly Bindable<CultureInfo> LanguageBindable = new Bindable<CultureInfo>();

public CultureInfo Language
{
get => LanguageBindable.Value;
set => LanguageBindable.Value = value;
}

/// <summary>
/// Display target translate
/// </summary>
Expand Down

0 comments on commit 10f5b92

Please sign in to comment.