Skip to content

Commit

Permalink
Rename the remaining part.
Browse files Browse the repository at this point in the history
  • Loading branch information
andy840119 committed Jul 5, 2024
1 parent 3010dd6 commit 93c217a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ private void load(OsuColour colours)
_ => throw new ArgumentOutOfRangeException(nameof(fontFormat)),
};

// todo : might apply translate.
// todo : might apply translation.
badgeText.Text = fontFormat.ToString();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public static class KaraokeSettingsSubsectionStrings
public static LocalisableString PreferLanguage => new TranslatableString(getKey(@"prefer_language"), @"Prefer language");

/// <summary>
/// "Select prefer translate language."
/// "Select prefer translation language."
/// </summary>
public static LocalisableString PreferLanguageTooltip => new TranslatableString(getKey(@"prefer_language_tooltip"), @"Select prefer translate language.");
public static LocalisableString PreferTranslationLanguageTooltip => new TranslatableString(getKey(@"prefer_language_tooltip"), @"Select prefer translation language.");

/// <summary>
/// "Microphone device"
Expand Down
46 changes: 23 additions & 23 deletions osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableLyric.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ namespace osu.Game.Rulesets.Karaoke.Objects.Drawables;
public partial class DrawableLyric : DrawableKaraokeHitObject
{
private Container<DrawableKaraokeSpriteText> lyricPieces = null!;
private OsuSpriteText translateText = null!;
private OsuSpriteText translationText = null!;

private readonly BindableBool useTranslateBindable = new();
private readonly BindableBool useTranslationBindable = new();
private readonly Bindable<CultureInfo> preferLanguageBindable = new();

private readonly Bindable<FontUsage> mainFontUsageBindable = new();
private readonly Bindable<FontUsage> rubyFontUsageBindable = new();
private readonly Bindable<int> rubyMarginBindable = new();
private readonly Bindable<FontUsage> romanisationFontUsageBindable = new();
private readonly Bindable<int> romanisationMarginBindable = new();
private readonly Bindable<FontUsage> translateFontUsageBindable = new();
private readonly Bindable<FontUsage> translationFontUsageBindable = new();

private readonly IBindableDictionary<Singer, SingerState[]> singersBindable = new BindableDictionary<Singer, SingerState[]>();
private readonly BindableDictionary<CultureInfo, string> translateTextBindable = new();
private readonly BindableDictionary<CultureInfo, string> translationTextBindable = new();

public event Action<DrawableLyric>? OnLyricStart;
public event Action<DrawableLyric>? OnLyricEnd;
Expand All @@ -61,14 +61,14 @@ private void load(KaraokeRulesetConfigManager? config)
{
AutoSizeAxes = Axes.Both,
});
AddInternal(translateText = new OsuSpriteText
AddInternal(translationText = new OsuSpriteText
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.TopLeft,
});

useTranslateBindable.BindValueChanged(_ => applyTranslate(), true);
preferLanguageBindable.BindValueChanged(_ => applyTranslate(), true);
useTranslationBindable.BindValueChanged(_ => applyTranslation(), true);
preferLanguageBindable.BindValueChanged(_ => applyTranslation(), true);

if (config != null)
{
Expand All @@ -77,19 +77,19 @@ private void load(KaraokeRulesetConfigManager? config)
config.BindWith(KaraokeRulesetSetting.RubyMargin, rubyMarginBindable);
config.BindWith(KaraokeRulesetSetting.RomanisationFont, romanisationFontUsageBindable);
config.BindWith(KaraokeRulesetSetting.RomanisationMargin, romanisationMarginBindable);
config.BindWith(KaraokeRulesetSetting.TranslationFont, translateFontUsageBindable);
config.BindWith(KaraokeRulesetSetting.TranslationFont, translationFontUsageBindable);
}

mainFontUsageBindable.BindValueChanged(_ => updateLyricFontInfo());
rubyFontUsageBindable.BindValueChanged(_ => updateLyricFontInfo());
rubyMarginBindable.BindValueChanged(_ => updateLyricFontInfo());
romanisationFontUsageBindable.BindValueChanged(_ => updateLyricFontInfo());
romanisationMarginBindable.BindValueChanged(_ => updateLyricFontInfo());
translateFontUsageBindable.BindValueChanged(_ => updateLyricFontInfo());
translationFontUsageBindable.BindValueChanged(_ => updateLyricFontInfo());

// property in hitobject.
singersBindable.BindCollectionChanged((_, _) => { updateFontStyle(); });
translateTextBindable.BindCollectionChanged((_, _) => { applyTranslate(); });
translationTextBindable.BindCollectionChanged((_, _) => { applyTranslation(); });
}

public void ChangeDisplayType(LyricDisplayType lyricDisplayType)
Expand All @@ -104,11 +104,11 @@ public void ChangeDisplayProperty(LyricDisplayProperty lyricDisplayProperty)

public void ChangePreferTranslationLanguage(CultureInfo? language)
{
if (language != null && translateTextBindable.TryGetValue(language, out string? translate))
translateText.Text = translate;
if (language != null && translationTextBindable.TryGetValue(language, out string? translation))
translationText.Text = translation;
else
{
translateText.Text = string.Empty;
translationText.Text = string.Empty;
}
}

Expand All @@ -121,15 +121,15 @@ protected override void OnApply()
ApplySkin(CurrentSkin, false);

singersBindable.BindTo(HitObject.SingersBindable);
translateTextBindable.BindTo(HitObject.TranslationsBindable);
translationTextBindable.BindTo(HitObject.TranslationsBindable);
}

protected override void OnFree()
{
base.OnFree();

singersBindable.UnbindFrom(HitObject.SingersBindable);
translateTextBindable.UnbindFrom(HitObject.TranslationsBindable);
translationTextBindable.UnbindFrom(HitObject.TranslationsBindable);
}

protected override void ApplySkin(ISkinSource skin, bool allowFallback)
Expand Down Expand Up @@ -164,19 +164,19 @@ private void updateLyricFontInfo()
lyricFontInfo?.ApplyTo(this);
}

private void applyTranslate()
private void applyTranslation()
{
var language = preferLanguageBindable.Value;
bool needTranslate = useTranslateBindable.Value;
bool useTranslation = useTranslationBindable.Value;

if (!needTranslate || language == null)
if (!useTranslation || language == null)
{
translateText.Text = string.Empty;
translationText.Text = string.Empty;
}
else
{
if (translateTextBindable.TryGetValue(language, out string? translate))
translateText.Text = translate;
if (translationTextBindable.TryGetValue(language, out string? translation))
translationText.Text = translation;
}
}

Expand Down Expand Up @@ -216,8 +216,8 @@ public void ApplyToLyricPieces(Action<DrawableKaraokeSpriteText> action)
action?.Invoke(lyricPiece);
}

public void ApplyToTranslateText(Action<OsuSpriteText> action)
public void ApplyToTranslationText(Action<OsuSpriteText> action)
{
action?.Invoke(translateText);
action?.Invoke(translationText);
}
}
4 changes: 2 additions & 2 deletions osu.Game.Rulesets.Karaoke/Skinning/Elements/LyricFontInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ public void ApplyTo(Drawable d)
l.BottomTextMargin = RomanisationMargin;
});

// Apply translate font.
drawableLyric.ApplyToTranslateText(text =>
// Apply translation font.
drawableLyric.ApplyToTranslationText(text =>
{
text.Font = getFont(KaraokeRulesetSetting.TranslationFont);
});
Expand Down

0 comments on commit 93c217a

Please sign in to comment.