From e2a3bbd9119f57faeeb30a6630fe6a2ec616692c Mon Sep 17 00:00:00 2001 From: LanZhan Date: Tue, 28 Apr 2026 01:14:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=AD=97=E5=8F=B7=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E3=80=81=E5=85=A8=E5=B1=80=E6=AD=8C=E8=AF=8D=E5=81=8F?= =?UTF-8?q?=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- UntamedMusicPlayer/Helpers/FontHelper.cs | 83 ++++++++ .../LyricRenderer/LyricManager.cs | 95 ++++++--- .../Messages/LyricOffsetChangeMessage.cs | 6 + UntamedMusicPlayer/Models/FontInfo.cs | 9 +- UntamedMusicPlayer/Models/Settings.cs | 43 ++++ UntamedMusicPlayer/Strings/ar/Resources.resw | 191 +++++++++++++----- UntamedMusicPlayer/Strings/bn/Resources.resw | 35 +++- UntamedMusicPlayer/Strings/de/Resources.resw | 35 +++- UntamedMusicPlayer/Strings/en/Resources.resw | 37 +++- UntamedMusicPlayer/Strings/es/Resources.resw | 35 +++- UntamedMusicPlayer/Strings/fr/Resources.resw | 35 +++- UntamedMusicPlayer/Strings/hi/Resources.resw | 35 +++- UntamedMusicPlayer/Strings/id/Resources.resw | 35 +++- UntamedMusicPlayer/Strings/ja/Resources.resw | 191 +++++++++++++----- UntamedMusicPlayer/Strings/ko/Resources.resw | 35 +++- UntamedMusicPlayer/Strings/pt/Resources.resw | 35 +++- UntamedMusicPlayer/Strings/ru/Resources.resw | 35 +++- .../Strings/zh-Hans/Resources.resw | 35 +++- .../Strings/zh-Hant/Resources.resw | 35 +++- UntamedMusicPlayer/UntamedMusicPlayer.csproj | 2 +- .../ViewModels/SettingsViewModel.cs | 69 ++++--- UntamedMusicPlayer/Views/LyricPage.xaml | 1 + UntamedMusicPlayer/Views/SettingsPage.xaml | 57 ++++-- 23 files changed, 897 insertions(+), 272 deletions(-) create mode 100644 UntamedMusicPlayer/Helpers/FontHelper.cs create mode 100644 UntamedMusicPlayer/Messages/LyricOffsetChangeMessage.cs diff --git a/UntamedMusicPlayer/Helpers/FontHelper.cs b/UntamedMusicPlayer/Helpers/FontHelper.cs new file mode 100644 index 0000000..2816af4 --- /dev/null +++ b/UntamedMusicPlayer/Helpers/FontHelper.cs @@ -0,0 +1,83 @@ +using System.Globalization; +using Microsoft.Graphics.Canvas.Text; +using Microsoft.UI.Text; +using Microsoft.UI.Xaml.Media; +using UntamedMusicPlayer.Models; +using Windows.UI.Text; +using ZLinq; + +namespace UntamedMusicPlayer.Helpers; + +public static class FontHelper +{ + private static List? _systemFontFamilies; + private static List? _FontWeights; + + public static List GetSystemFontFamilies() + { + if (_systemFontFamilies is not null) + { + return _systemFontFamilies; + } + var language = new string[] { CultureInfo.CurrentUICulture.Name.ToLowerInvariant() }; + var names = CanvasTextFormat.GetSystemFontFamilies(); + var displayNames = CanvasTextFormat.GetSystemFontFamilies(language); + var list = new List(); + for (var i = 0; i < names.Length; i++) + { + list.Add( + new FontFamilyInfo + { + Name = names[i], + DisplayName = displayNames[i], + FontFamily = new FontFamily(names[i]), + } + ); + } + _systemFontFamilies = [.. list.AsValueEnumerable().OrderBy(f => f.Name)]; + return _systemFontFamilies; + } + + public static List GetFontWeights() + { + if (_FontWeights is not null) + { + return _FontWeights; + } + var names = "Settings_FontWeights".GetLocalized().Split(", "); + _FontWeights = + [ + new() { DisplayName = names[0], FontWeight = FontWeights.Thin }, + new() { DisplayName = names[1], FontWeight = FontWeights.ExtraLight }, + new() { DisplayName = names[2], FontWeight = FontWeights.Light }, + new() { DisplayName = names[3], FontWeight = FontWeights.SemiLight }, + new() { DisplayName = names[4], FontWeight = FontWeights.Normal }, + new() { DisplayName = names[5], FontWeight = FontWeights.Medium }, + new() { DisplayName = names[6], FontWeight = FontWeights.SemiBold }, + new() { DisplayName = names[7], FontWeight = FontWeights.Bold }, + new() { DisplayName = names[8], FontWeight = FontWeights.ExtraBold }, + new() { DisplayName = names[9], FontWeight = FontWeights.Black }, + new() { DisplayName = names[10], FontWeight = FontWeights.ExtraBlack }, + ]; + return _FontWeights; + } + + public static FontWeight ConvertToFontWeight(ushort weight) + { + return weight switch + { + 100 => FontWeights.Thin, + 200 => FontWeights.ExtraLight, + 300 => FontWeights.Light, + 350 => FontWeights.SemiLight, + 400 => FontWeights.Normal, + 500 => FontWeights.Medium, + 600 => FontWeights.SemiBold, + 700 => FontWeights.Bold, + 800 => FontWeights.ExtraBold, + 900 => FontWeights.Black, + 950 => FontWeights.ExtraBlack, + _ => FontWeights.Normal, + }; + } +} diff --git a/UntamedMusicPlayer/LyricRenderer/LyricManager.cs b/UntamedMusicPlayer/LyricRenderer/LyricManager.cs index 80e664e..d8cfbab 100644 --- a/UntamedMusicPlayer/LyricRenderer/LyricManager.cs +++ b/UntamedMusicPlayer/LyricRenderer/LyricManager.cs @@ -3,6 +3,7 @@ using CommunityToolkit.Mvvm.Messaging; using Microsoft.UI.Dispatching; using UntamedMusicPlayer.Helpers; using UntamedMusicPlayer.Messages; +using UntamedMusicPlayer.Models; using UntamedMusicPlayer.Playback; namespace UntamedMusicPlayer.LyricRenderer; @@ -10,6 +11,7 @@ namespace UntamedMusicPlayer.LyricRenderer; public sealed partial class LyricManager : ObservableRecipient, IRecipient, + IRecipient, IDisposable { private readonly DispatcherQueue _dispatcher = DispatcherQueue.GetForCurrentThread(); @@ -28,9 +30,25 @@ public sealed partial class LyricManager public partial string CurrentLyricContent { get; set; } = ""; /// - /// 歌词偏移毫秒数,正数表示歌词显示延后,负数表示歌词显示提前 + /// 全局歌词偏移毫秒数,正数表示歌词显示延后,负数表示歌词显示提前 /// - public double LyricAdjustMilliseconds { get; set; } = 0; + private double _globalLyricOffset = Settings.GlobalLyricOffset; + + /// + /// 是否已手动调整(手动调整后将脱离全局偏移控制) + /// + private bool _isManuallyAdjusted = false; + + /// + /// 手动调整的歌词偏移毫秒数 + /// + private double _manualLyricOffset = 0; + + /// + /// 总偏移毫秒数 + /// + private double TotalLyricOffset => + _isManuallyAdjusted ? _manualLyricOffset : _globalLyricOffset; /// /// 歌词偏移显示字符串 @@ -47,7 +65,8 @@ public sealed partial class LyricManager public LyricManager(SharedPlaybackState state) : base(StrongReferenceMessenger.Default) { - Messenger.Register(this); + Messenger.Register(this); + Messenger.Register(this); _state = state; } @@ -59,6 +78,15 @@ public sealed partial class LyricManager } } + public void Receive(LyricOffsetChangeMessage message) + { + _globalLyricOffset = message.OffsetMilliseconds; + if (!_isManuallyAdjusted) + { + UpdateLyricAdjustDisplay(); + } + } + /// /// 获取当前歌曲歌词 /// @@ -73,6 +101,9 @@ public sealed partial class LyricManager { CurrentLyricSlices = slices; CurrentLyricIndex = 0; + _isManuallyAdjusted = false; + _manualLyricOffset = 0; + UpdateLyricAdjustDisplay(); if (CurrentLyricSlices.Count > 0) { @@ -94,9 +125,10 @@ public sealed partial class LyricManager /// public int GetCurrentLyricIndex(double currentTime) { + var offset = TotalLyricOffset; for (var i = 0; i < CurrentLyricSlices.Count; i++) { - if (CurrentLyricSlices[i].StartTime > currentTime) + if (CurrentLyricSlices[i].StartTime + offset > currentTime) { return i > 0 ? i - 1 : 0; } @@ -139,38 +171,35 @@ public sealed partial class LyricManager }); } - public async Task AddLyricAdjust() + public Task AddLyricAdjust() { - LyricAdjustMilliseconds += 300; - LyricAdjustDisplayStr = - LyricAdjustMilliseconds == 0 - ? "0.0s" - : $"{(LyricAdjustMilliseconds > 0 ? "+" : "-")}{Math.Abs(LyricAdjustMilliseconds) / 1000:F1}s"; - await Task.Run(() => + if (!_isManuallyAdjusted) { - foreach (var slice in CurrentLyricSlices) - { - slice.StartTime += 300; - slice.EndTime += 300; - } - }); + _manualLyricOffset = _globalLyricOffset; + _isManuallyAdjusted = true; + } + _manualLyricOffset += 300; + UpdateLyricAdjustDisplay(); + return Task.CompletedTask; } - public async Task SubtractLyricAdjust() + public Task SubtractLyricAdjust() { - LyricAdjustMilliseconds -= 300; - LyricAdjustDisplayStr = - LyricAdjustMilliseconds == 0 - ? "0.0s" - : $"{(LyricAdjustMilliseconds > 0 ? "+" : "-")}{Math.Abs(LyricAdjustMilliseconds) / 1000:F1}s"; - await Task.Run(() => + if (!_isManuallyAdjusted) { - foreach (var slice in CurrentLyricSlices) - { - slice.StartTime = Math.Max(0, slice.StartTime - 300); - slice.EndTime = Math.Max(0, slice.EndTime - 300); - } - }); + _manualLyricOffset = _globalLyricOffset; + _isManuallyAdjusted = true; + } + _manualLyricOffset -= 300; + UpdateLyricAdjustDisplay(); + return Task.CompletedTask; + } + + private void UpdateLyricAdjustDisplay() + { + var total = TotalLyricOffset; + LyricAdjustDisplayStr = + total == 0 ? "0.0s" : $"{(total > 0 ? "+" : "-")}{Math.Abs(total) / 1000:F1}s"; } /// @@ -182,8 +211,9 @@ public sealed partial class LyricManager { CurrentLyricIndex = 0; CurrentLyricContent = ""; - LyricAdjustMilliseconds = 0; - LyricAdjustDisplayStr = "0.0s"; + _isManuallyAdjusted = false; + _manualLyricOffset = 0; + UpdateLyricAdjustDisplay(); CurrentLyricSlices.Clear(); }); } @@ -191,6 +221,7 @@ public sealed partial class LyricManager public void Dispose() { Messenger.Unregister(this); + Messenger.Unregister(this); GC.SuppressFinalize(this); } } diff --git a/UntamedMusicPlayer/Messages/LyricOffsetChangeMessage.cs b/UntamedMusicPlayer/Messages/LyricOffsetChangeMessage.cs new file mode 100644 index 0000000..0797727 --- /dev/null +++ b/UntamedMusicPlayer/Messages/LyricOffsetChangeMessage.cs @@ -0,0 +1,6 @@ +namespace UntamedMusicPlayer.Messages; + +public sealed class LyricOffsetChangeMessage(int offsetMilliseconds) +{ + public int OffsetMilliseconds { get; } = offsetMilliseconds; +} diff --git a/UntamedMusicPlayer/Models/FontInfo.cs b/UntamedMusicPlayer/Models/FontInfo.cs index ffd5a65..833eec2 100644 --- a/UntamedMusicPlayer/Models/FontInfo.cs +++ b/UntamedMusicPlayer/Models/FontInfo.cs @@ -1,10 +1,17 @@ using Microsoft.UI.Xaml.Media; +using Windows.UI.Text; namespace UntamedMusicPlayer.Models; -public sealed class FontInfo +public sealed class FontFamilyInfo { public string Name { get; set; } = null!; public string DisplayName { get; set; } = null!; public FontFamily FontFamily { get; set; } = null!; } + +public sealed class FontWeightInfo +{ + public string DisplayName { get; set; } = null!; + public FontWeight FontWeight { get; set; } +} diff --git a/UntamedMusicPlayer/Models/Settings.cs b/UntamedMusicPlayer/Models/Settings.cs index aa29cff..b7fca38 100644 --- a/UntamedMusicPlayer/Models/Settings.cs +++ b/UntamedMusicPlayer/Models/Settings.cs @@ -1,7 +1,10 @@ +using Microsoft.UI.Text; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Media; using UntamedMusicPlayer.Contracts.Services; +using UntamedMusicPlayer.Helpers; using Windows.UI; +using Windows.UI.Text; namespace UntamedMusicPlayer.Models; @@ -93,6 +96,38 @@ public static class Settings } public static double LyricPageNotCurrentFontSize { get; set; } + /// + /// 歌词字重 + /// + public static FontWeight LyricPageFontWeight + { + get; + set + { + if (field != value) + { + field = value; + _localSettingsService.SaveSettingAsync(nameof(LyricPageFontWeight), value.Weight); + } + } + } + + /// + /// 全局歌词时间偏移 + /// + public static int GlobalLyricOffset + { + get; + set + { + if (field != value) + { + field = value; + _localSettingsService.SaveSettingAsync(nameof(GlobalLyricOffset), value); + } + } + } + /// /// 应用主题 /// @@ -269,6 +304,14 @@ public static class Settings await _localSettingsService.ReadSettingAsync(nameof(FontFamily)) ?? "Microsoft YaHei" ); + var fontWeight = await _localSettingsService.ReadSettingAsync( + nameof(LyricPageFontWeight) + ); + LyricPageFontWeight = + fontWeight == 0 ? FontWeights.Normal : FontHelper.ConvertToFontWeight(fontWeight); + GlobalLyricOffset = await _localSettingsService.ReadSettingAsync( + nameof(GlobalLyricOffset) + ); var themeName = await _localSettingsService.ReadSettingAsync(nameof(Theme)); Theme = Enum.TryParse(themeName, out var cacheTheme) ? cacheTheme diff --git a/UntamedMusicPlayer/Strings/ar/Resources.resw b/UntamedMusicPlayer/Strings/ar/Resources.resw index 3464e78..a2d2b4b 100644 --- a/UntamedMusicPlayer/Strings/ar/Resources.resw +++ b/UntamedMusicPlayer/Strings/ar/Resources.resw @@ -1,52 +1,110 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx @@ -116,9 +174,6 @@ مواقع مكتبة الموسيقى - - معاينة كلمات الأغنية - لا توجد مجلدات مدرجة في هذه المكتبة. @@ -497,12 +552,9 @@ اختر مادة - + عائلة خطوط الكلمات - - حجم خط الكلمات - اختر عائلة الخطوط @@ -983,4 +1035,31 @@ إبطاء كلمات الأغنية بمقدار 0.3 ثانية + + حجم الخط + + + معاينة + + + عائلة فونت + + + أوفست الكلمات العالمية + + + القيم السلبية ستدفع الكلمات إلى الأمام، بينما القيم الإيجابية ستؤخرها + + + ميلي ثانية + + + رفيع ,خفيف للغاية ,خفيف ,خفيف شبه ,عادي ,متوسط ,شبه عريض ,عريض ,عريض للغاية ,أسود ,أسود للغاية + + + اختر وزن الخط + + + وزن الخط + \ No newline at end of file diff --git a/UntamedMusicPlayer/Strings/bn/Resources.resw b/UntamedMusicPlayer/Strings/bn/Resources.resw index 1160d83..76fbe9e 100644 --- a/UntamedMusicPlayer/Strings/bn/Resources.resw +++ b/UntamedMusicPlayer/Strings/bn/Resources.resw @@ -116,9 +116,6 @@ সঙ্গীত গ্রন্থাগারের অবস্থান - - লিরিক প্রিভিউ - এই লাইব্রেরিতে কোন ফোল্ডার অন্তর্ভুক্ত নেই। @@ -497,12 +494,9 @@ একটি উপাদান চয়ন করুন - + লিরিক ফন্ট-ফ্যামিলি - - লিরিক ফন্ট-আকার - একটি ফন্ট-পরিবার চয়ন করুন @@ -983,4 +977,31 @@ গানের কথা 0.3 সেকেন্ড ধীর করুন + + ফন্টের আকার + + + পূর্বরূপ + + + ফন্ট পরিবার + + + গ্লোবাল লিরিক অফসেট + + + নেতিবাচক মানগুলি গানের কথাকে এগিয়ে নিয়ে যাবে, যখন ইতিবাচক মানগুলি তাদের বিলম্বিত করবে + + + মিলিসেকেন্ড + + + পাতলা, অতিরিক্ত আলো, হালকা, আধা হালকা, নিয়মিত, মাঝারি, আধা বোল্ড, গাঢ়, অতিরিক্ত গাঢ়, কালো, অতিরিক্ত কালো + + + একটি ফন্ট-ওজন চয়ন করুন + + + ফন্টের ওজন + \ No newline at end of file diff --git a/UntamedMusicPlayer/Strings/de/Resources.resw b/UntamedMusicPlayer/Strings/de/Resources.resw index ae89517..a6ef7bb 100644 --- a/UntamedMusicPlayer/Strings/de/Resources.resw +++ b/UntamedMusicPlayer/Strings/de/Resources.resw @@ -116,9 +116,6 @@ Standorte für Musikbibliotheken - - Lyric-Vorschau - In dieser Bibliothek sind keine Ordner enthalten. @@ -497,12 +494,9 @@ Wählen Sie ein Material aus - + Lyrische Schriftfamilie - - Lyric-Schriftgröße - Wählen Sie eine Schriftartfamilie @@ -983,4 +977,31 @@ Verlangsamen Sie die Texte um 0,3 Sekunden + + Schriftgröße + + + Vorschau + + + Schriftartfamilie + + + Globaler lyrischer Offset + + + Negative Werte bringen den Text voran, während positive Werte sie verzögern + + + Millisekunden + + + Dünn, Extra Leicht, Leicht, Halbleicht, Normal, Mittel, Halb Kräftig, Kräftig, Extra Kräftig, Schwarz, Extra Schwarz + + + Wählen Sie eine Schriftstärke + + + Schriftstärke + \ No newline at end of file diff --git a/UntamedMusicPlayer/Strings/en/Resources.resw b/UntamedMusicPlayer/Strings/en/Resources.resw index df2cb76..5e36f81 100644 --- a/UntamedMusicPlayer/Strings/en/Resources.resw +++ b/UntamedMusicPlayer/Strings/en/Resources.resw @@ -174,9 +174,6 @@ Music library locations - - Lyric preview - No folders are included in this library. @@ -555,11 +552,8 @@ Choose a material - - Lyric font-family - - - Lyric font-size + + Lyric font Choose a font-family @@ -1041,4 +1035,31 @@ Slow down lyrics by 0.3s + + Size + + + Preview + + + Family + + + Global Lyric Offset + + + Negative values will advance the lyrics, while positive values will delay them + + + ms + + + Thin, Extra Light, Light, Semi Light, Regular, Medium, Semi Bold, Bold, Extra Bold, Black, Extra Black + + + Choose a font-weight + + + Weight + \ No newline at end of file diff --git a/UntamedMusicPlayer/Strings/es/Resources.resw b/UntamedMusicPlayer/Strings/es/Resources.resw index d66ddec..dce8960 100644 --- a/UntamedMusicPlayer/Strings/es/Resources.resw +++ b/UntamedMusicPlayer/Strings/es/Resources.resw @@ -116,9 +116,6 @@ Ubicaciones de la biblioteca musical - - Avance de la letra - No se incluyen carpetas en esta biblioteca. @@ -497,12 +494,9 @@ Elige un material - + Familia de fuentes líricas - - Tamaño de fuente de la letra - Elige una familia de fuentes @@ -983,4 +977,31 @@ Ralentiza la letra en 0,3 segundos + + Tamaño de fuente + + + Avance + + + Familia de fuentes + + + Offset lírico global + + + Los valores negativos avanzan la letra, mientras que los positivos la retrasan + + + milisegundos + + + Fino, Extra Claro, Ligero, Semi Claro, Normal, Medio, Semi Negrita, Negrita, Extra Negro, Extra Negro + + + Elige un grosor de fuente + + + Grosor de fuente + \ No newline at end of file diff --git a/UntamedMusicPlayer/Strings/fr/Resources.resw b/UntamedMusicPlayer/Strings/fr/Resources.resw index 5980346..d8b5894 100644 --- a/UntamedMusicPlayer/Strings/fr/Resources.resw +++ b/UntamedMusicPlayer/Strings/fr/Resources.resw @@ -116,9 +116,6 @@ Emplacements de la bibliothèque musicale - - Aperçu des paroles - Aucun dossier n’est inclus dans cette bibliothèque. @@ -497,12 +494,9 @@ Choisissez un matériau - + Famille de polices lyriques - - Taille de police des paroles - Choisissez une famille de polices @@ -983,4 +977,31 @@ Ralentissez les paroles de 0,3 s + + Taille de police + + + Aperçu + + + Famille de polices + + + Décalage lyrique global + + + Les valeurs négatives feront avancer les paroles, tandis que les valeurs positives les retarderont + + + Millisecondes + + + Léger, Extra Léger, Léger, Semi-Léger, Régulier, Moyen, Semi-Grasset, Gras, Extra Gros, Noir, Extra Noir + + + Choisissez un poids de police + + + Épaisseur de police + \ No newline at end of file diff --git a/UntamedMusicPlayer/Strings/hi/Resources.resw b/UntamedMusicPlayer/Strings/hi/Resources.resw index 6ae9a8a..3fd0995 100644 --- a/UntamedMusicPlayer/Strings/hi/Resources.resw +++ b/UntamedMusicPlayer/Strings/hi/Resources.resw @@ -116,9 +116,6 @@ संगीत पुस्तकालय स्थान - - गीत पूर्वावलोकन - इस लायब्रेरी में कोई फ़ोल्डर शामिल नहीं हैं. @@ -497,12 +494,9 @@ एक सामग्री चुनें - + गीत फ़ॉन्ट-परिवार - - गीत फ़ॉन्ट-आकार - कोई फ़ॉन्ट-परिवार चुनें @@ -983,4 +977,31 @@ गीत को 0.3s से धीमा करें + + फ़ॉन्ट आकार + + + पूर्वसमीक्षा + + + फ़ॉन्ट परिवार + + + वैश्विक गीत ऑफसेट + + + नकारात्मक मूल्य गीत को आगे बढ़ाएंगे, जबकि सकारात्मक मूल्य उनमें देरी करेंगे + + + मिलीसेकंड + + + पतला, अतिरिक्त प्रकाश, प्रकाश, अर्ध प्रकाश, नियमित, मध्यम, अर्ध बोल्ड, बोल्ड, अतिरिक्त बोल्ड, काला, अतिरिक्त काला + + + फ़ॉन्ट-वेट चुनें + + + फ़ॉन्ट वजन + \ No newline at end of file diff --git a/UntamedMusicPlayer/Strings/id/Resources.resw b/UntamedMusicPlayer/Strings/id/Resources.resw index 51c5ff8..278bf26 100644 --- a/UntamedMusicPlayer/Strings/id/Resources.resw +++ b/UntamedMusicPlayer/Strings/id/Resources.resw @@ -116,9 +116,6 @@ Lokasi perpustakaan musik - - Pratinjau lirik - Tidak ada folder yang disertakan dalam perpustakaan ini. @@ -497,12 +494,9 @@ Pilih bahan - + Keluarga font lirik - - Ukuran font lirik - Pilih keluarga font @@ -983,4 +977,31 @@ Perlambat lirik sebesar 0,3 detik + + Ukuran font + + + Pratinjau + + + Keluarga font + + + Offset Lirik Global + + + Nilai negatif akan memajukan lirik, sedangkan nilai positif akan menundanya + + + milidetik + + + Tipis, Ekstra Ringan, Ringan, Semi Ringan, Biasa, Sedang, Semi Tebal, Tebal, Ekstra Tebal, Hitam, Ekstra Hitam + + + Pilih bobot font + + + Berat font + \ No newline at end of file diff --git a/UntamedMusicPlayer/Strings/ja/Resources.resw b/UntamedMusicPlayer/Strings/ja/Resources.resw index 35fedad..9de4611 100644 --- a/UntamedMusicPlayer/Strings/ja/Resources.resw +++ b/UntamedMusicPlayer/Strings/ja/Resources.resw @@ -1,52 +1,110 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx @@ -116,9 +174,6 @@ 音楽ライブラリーの所在地 - - 歌詞プレビュー - このライブラリにはフォルダは含まれていません。 @@ -497,12 +552,9 @@ 素材を選びましょう - + リリックフォントファミリー - - リリックフォントサイズ - フォントファミリーを選ぶ @@ -983,4 +1035,31 @@ 歌詞を0.3秒遅くする + + フォントサイズ + + + プレビュー + + + フォントファミリー + + + グローバル・リリック・オフセット + + + マイナスは歌詞を進め、ポジティブな方は歌詞を遅らせます + + + ミリ秒単位 + + + 薄め, エクストラライト, ライト, セミライト, レギュラー, ミディアム, セミボールド, ボールド, エクストラボールド, ブラック, エクストラブラック + + + フォントの太さを選ぶ + + + フォントの太さ + \ No newline at end of file diff --git a/UntamedMusicPlayer/Strings/ko/Resources.resw b/UntamedMusicPlayer/Strings/ko/Resources.resw index 862083b..a15f24e 100644 --- a/UntamedMusicPlayer/Strings/ko/Resources.resw +++ b/UntamedMusicPlayer/Strings/ko/Resources.resw @@ -116,9 +116,6 @@ 음악 도서관 위치 - - 가사 미리보기 - 이 라이브러리에는 폴더가 포함되어 있지 않습니다. @@ -497,12 +494,9 @@ 재료를 선택하세요 - + 서정형 폰트 계열 - - 가사 글꼴 크기 - 폰트 계열 선택 @@ -983,4 +977,31 @@ 가사 속도를 0.3초 늦춰 + + 글꼴 크기 + + + 미리보기 + + + 폰트 계열 + + + 글로벌 가사 상쇄 + + + 음수치는 가사를 진행시키고, 음수치는 가사를 지연시킵니다 + + + 밀리초 + + + 씬, 엑스트라 라이트, 라이트, 세미 라이트, 레귤러, 미디엄, 세미 볼드, 볼드, 엑스트라 볼드, 블랙, 엑스트라 블랙 + + + 글꼴 굵기 선택 + + + 폰트 굵기 + \ No newline at end of file diff --git a/UntamedMusicPlayer/Strings/pt/Resources.resw b/UntamedMusicPlayer/Strings/pt/Resources.resw index bb510c3..30edf2a 100644 --- a/UntamedMusicPlayer/Strings/pt/Resources.resw +++ b/UntamedMusicPlayer/Strings/pt/Resources.resw @@ -116,9 +116,6 @@ Localizações da biblioteca musical - - Prévia da letra - Nenhuma pasta está incluída nesta biblioteca. @@ -497,12 +494,9 @@ Escolha um material - + Família de fontes líricas - - Tamanho da fonte da letra - Escolha uma família de fontes @@ -983,4 +977,31 @@ Letra de desaceleração em 0,3s + + Tamanho da fonte + + + Prévia + + + Família de fontes + + + Offset Lírico Global + + + Valores negativos vão avançar a letra, enquanto valores positivos vão atrasá-las + + + milissegundos + + + Fino, Extra Claro, Leve, Semi Claro, Normal, Médio, Semi Ogrito, Ogrito, Extra Ogrito, Preto, Preto Extra + + + Escolha um peso de fonte + + + Peso da fonte + \ No newline at end of file diff --git a/UntamedMusicPlayer/Strings/ru/Resources.resw b/UntamedMusicPlayer/Strings/ru/Resources.resw index 30b7e09..e075eb1 100644 --- a/UntamedMusicPlayer/Strings/ru/Resources.resw +++ b/UntamedMusicPlayer/Strings/ru/Resources.resw @@ -116,9 +116,6 @@ Расположение музыкальных библиотек - - Превью текста песен - В этой библиотеке нет папок. @@ -497,12 +494,9 @@ Выберите материал - + Лирическое семейство шрифтов - - Размер шрифта текста - Выберите семейство шрифтов @@ -983,4 +977,31 @@ Замедлите текст на 0,3 секунды + + Размер шрифта + + + Превью + + + Семейство шрифтов + + + Глобальный лирический офсет + + + Отрицательные значения продвигают текст, а положительные — задерживают их + + + миллисекунды + + + Тонкая, Extra Light, Light, Semi Light, Regular, Medium, Semi Bold, Bold, Extra Bold, Black, Extra Black + + + Выберите вес шрифта + + + Вес шрифта + \ No newline at end of file diff --git a/UntamedMusicPlayer/Strings/zh-Hans/Resources.resw b/UntamedMusicPlayer/Strings/zh-Hans/Resources.resw index da2ea21..c145fa3 100644 --- a/UntamedMusicPlayer/Strings/zh-Hans/Resources.resw +++ b/UntamedMusicPlayer/Strings/zh-Hans/Resources.resw @@ -174,9 +174,6 @@ 音乐库位置 - - 歌词预览 - 此库中不包含任何文件夹 @@ -555,12 +552,9 @@ 选择一个材质 - + 歌词字体 - - 歌词字号 - 选择一种字体 @@ -1041,4 +1035,31 @@ 歌词延后 0.3 秒 + + 字号 + + + 预览 + + + 字体系列 + + + 全局歌词时间偏移 + + + 负值使歌词提前出现,正值使歌词延后出现 + + + 毫秒 + + + 极细, 特细, 细, 次细, 标准, 中等, 半粗, 粗体, 特粗, 浓体, 特黑 + + + 选择一个字重 + + + 字重 + \ No newline at end of file diff --git a/UntamedMusicPlayer/Strings/zh-Hant/Resources.resw b/UntamedMusicPlayer/Strings/zh-Hant/Resources.resw index fd33452..df8e3c3 100644 --- a/UntamedMusicPlayer/Strings/zh-Hant/Resources.resw +++ b/UntamedMusicPlayer/Strings/zh-Hant/Resources.resw @@ -174,9 +174,6 @@ 音樂庫位置 - - 歌詞預覽 - 此庫中不包含任何資料夾 @@ -555,12 +552,9 @@ 選擇一個材質 - + 歌詞字體 - - 歌詞字型大小 - 選擇一種字體 @@ -1041,4 +1035,31 @@ 歌詞延遲 0.3 秒 + + 字號 + + + 預覽 + + + 字體系列 + + + 全局歌詞時間偏移 + + + 負值會推進歌詞,正面值則會延遲歌詞 + + + 毫秒 + + + 極細, 特細, 細, 次細, 標準, 中等, 半粗, 粗體, 特粗, 濃體, 特黑 + + + 選擇一個字重 + + + 字重 + \ No newline at end of file diff --git a/UntamedMusicPlayer/UntamedMusicPlayer.csproj b/UntamedMusicPlayer/UntamedMusicPlayer.csproj index 403b105..260e8b3 100644 --- a/UntamedMusicPlayer/UntamedMusicPlayer.csproj +++ b/UntamedMusicPlayer/UntamedMusicPlayer.csproj @@ -41,7 +41,7 @@ - + diff --git a/UntamedMusicPlayer/ViewModels/SettingsViewModel.cs b/UntamedMusicPlayer/ViewModels/SettingsViewModel.cs index 71dadbe..c8349cc 100644 --- a/UntamedMusicPlayer/ViewModels/SettingsViewModel.cs +++ b/UntamedMusicPlayer/ViewModels/SettingsViewModel.cs @@ -1,11 +1,9 @@ using System.Diagnostics; -using System.Globalization; using System.Reflection; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using CommunityToolkit.Mvvm.Messaging; using Microsoft.Extensions.Logging; -using Microsoft.Graphics.Canvas.Text; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Media; @@ -18,6 +16,7 @@ using UntamedMusicPlayer.Services; using Windows.ApplicationModel; using Windows.Storage; using Windows.UI; +using Windows.UI.Text; using ZLinq; namespace UntamedMusicPlayer.ViewModels; @@ -82,10 +81,12 @@ public sealed partial class SettingsViewModel /// /// 字体列表 /// - public List FontFamilies { get; set; } = []; + public List FontFamilies { get; set; } = FontHelper.GetSystemFontFamilies(); public double[] FontSizes { get; set; } = [30, 35, 40, 45, 50, 55, 60, 65, 70, 75]; + public List FontWeights { get; set; } = FontHelper.GetFontWeights(); + /// /// 选中的字体 /// @@ -121,6 +122,26 @@ public sealed partial class SettingsViewModel Messenger.Send(new FontSizeChangeMessage()); } + /// + /// 选中的字重 + /// + [ObservableProperty] + public partial FontWeight SelectedFontWeight { get; set; } = Settings.LyricPageFontWeight; + + partial void OnSelectedFontWeightChanged(FontWeight value) + { + Settings.LyricPageFontWeight = value; + } + + [ObservableProperty] + public partial int GlobalLyricOffset { get; set; } = Settings.GlobalLyricOffset; + + partial void OnGlobalLyricOffsetChanged(int value) + { + Settings.GlobalLyricOffset = value; + Messenger.Send(new LyricOffsetChangeMessage(value)); + } + /// /// 深浅色主题 /// @@ -226,7 +247,6 @@ public sealed partial class SettingsViewModel EmptyFolderMessageVisibility = Data.MusicLibrary.Folders.Count > 0 ? Visibility.Collapsed : Visibility.Visible; LoadSongDownloadLocationAsync(); - LoadFonts(); IsExportPlaylistsButtonEnabled = Data.PlaylistLibrary.Playlists.Count > 0; Data.SettingsViewModel = this; } @@ -499,7 +519,7 @@ public sealed partial class SettingsViewModel public void FontFamilyComboBox_SelectionChanged(object _, SelectionChangedEventArgs e) { - if (e.AddedItems.Count > 0 && e.AddedItems[0] is FontInfo selectedFont) + if (e.AddedItems.Count > 0 && e.AddedItems[0] is FontFamilyInfo selectedFont) { SelectedFontFamily = new FontFamily(selectedFont.Name); } @@ -513,6 +533,14 @@ public sealed partial class SettingsViewModel } } + public void FontWeightComboBox_SelectionChanged(object _, SelectionChangedEventArgs e) + { + if (e.AddedItems.Count > 0 && e.AddedItems[0] is FontWeightInfo selectedWeight) + { + SelectedFontWeight = selectedWeight.FontWeight; + } + } + public void ComboBox_TextSubmitted(ComboBox sender, ComboBoxTextSubmittedEventArgs args) { if (double.TryParse(args.Text, out var fontSize)) @@ -530,26 +558,6 @@ public sealed partial class SettingsViewModel (sender as ComboBox)!.SelectedIndex = SelectedMaterial; } - public void LoadFonts() - { - var language = new string[] { CultureInfo.CurrentUICulture.Name.ToLowerInvariant() }; - var names = CanvasTextFormat.GetSystemFontFamilies(); - var displayNames = CanvasTextFormat.GetSystemFontFamilies(language); - var list = new List(); - for (var i = 0; i < names.Length; i++) - { - list.Add( - new FontInfo - { - Name = names[i], - DisplayName = displayNames[i], - FontFamily = new FontFamily(names[i]), - } - ); - } - FontFamilies = [.. list.AsValueEnumerable().OrderBy(f => f.Name)]; - } - public void FontFamilyComboBox_Loaded(object sender, RoutedEventArgs _) { var selectedFontName = SelectedFontFamily.Source; @@ -573,6 +581,17 @@ public sealed partial class SettingsViewModel } } + public void FontWeightComboBox_Loaded(object sender, RoutedEventArgs _) + { + var selectedItem = FontWeights.FirstOrDefault(weight => + weight.FontWeight.Weight == SelectedFontWeight.Weight + ); + if (selectedItem is not null) + { + (sender as ComboBox)!.SelectedItem = selectedItem; + } + } + public void OpenLoggingFolderButton_Click(object _1, RoutedEventArgs _2) { var logFolder = LoggingService.GetLogFolderPath(); diff --git a/UntamedMusicPlayer/Views/LyricPage.xaml b/UntamedMusicPlayer/Views/LyricPage.xaml index 298a3f5..86c7bf7 100644 --- a/UntamedMusicPlayer/Views/LyricPage.xaml +++ b/UntamedMusicPlayer/Views/LyricPage.xaml @@ -45,6 +45,7 @@ Margin="{x:Bind Margin, Mode=OneWay}" FontFamily="{x:Bind model:Settings.FontFamily}" FontSize="{x:Bind FontSize, Mode=OneWay}" + FontWeight="{x:Bind model:Settings.LyricPageFontWeight}" Opacity="{x:Bind Opacity, Mode=OneWay}" SizeChanged="TextBlock_SizeChanged" Text="{x:Bind Content}" diff --git a/UntamedMusicPlayer/Views/SettingsPage.xaml b/UntamedMusicPlayer/Views/SettingsPage.xaml index c95fd9f..fbe71a0 100644 --- a/UntamedMusicPlayer/Views/SettingsPage.xaml +++ b/UntamedMusicPlayer/Views/SettingsPage.xaml @@ -26,9 +26,12 @@ - + + + + @@ -170,34 +173,56 @@ - - - - - + + + + + + + + + + + FontSize="{x:Bind ViewModel.SelectedCurrentFontSize, Mode=OneWay}" + FontWeight="{x:Bind ViewModel.SelectedFontWeight, Mode=OneWay}"/> + + + + + + +