From 2059f04b4a59258f57407e2f240b2fc21fbb218f Mon Sep 17 00:00:00 2001 From: Pd233 Date: Mon, 15 Jan 2024 16:16:18 +0800 Subject: [PATCH] i18n & fix bugs --- src/LipUI/Language/en-US/Resources.resw | 87 +++++++++++++++++++ src/LipUI/Language/zh-CN/Resources.resw | 87 +++++++++++++++++++ src/LipUI/LipUI.csproj | 2 +- src/LipUI/MainWindow.xaml | 2 +- src/LipUI/Models/Config.cs | 9 +- src/LipUI/Models/Plugin/PluginSystem.cs | 6 +- .../Modules/BdsPropertiesEditorPage.xaml.cs | 5 +- .../LipExecutionPanelPage.xaml.cs | 4 + .../LipInstallerView.xaml.cs | 2 +- .../ModuleManager/ModuleManagerPage.xaml | 6 +- .../Pages/Settings/GeneralSettingsView.xaml | 48 +++++++++- .../Settings/GeneralSettingsView.xaml.cs | 42 +++++++++ .../Settings/PersonalizationSettingsView.xaml | 24 ++--- .../PersonalizationSettingsView.xaml.cs | 18 ++-- src/LipUI/Pages/Settings/SettingsPage.xaml | 4 +- src/LipUI/Pages/Settings/SettingsPage.xaml.cs | 2 +- src/LipUI/Pages/ToothInfoPage.xaml | 5 +- 17 files changed, 310 insertions(+), 43 deletions(-) diff --git a/src/LipUI/Language/en-US/Resources.resw b/src/LipUI/Language/en-US/Resources.resw index c8593fe..21ef2bb 100644 --- a/src/LipUI/Language/en-US/Resources.resw +++ b/src/LipUI/Language/en-US/Resources.resw @@ -117,6 +117,12 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Restart + + + Need to restart application. + Search @@ -126,6 +132,21 @@ Disagree + + GitHub API + + + Github proxy + + + Lip Index API + + + Lip path + + + General settings + No description @@ -144,6 +165,9 @@ Unknown Lip path! + + Unknown server path! + Cancel @@ -165,6 +189,15 @@ Update + + Modules + + + Plugins + + + UI Plugins + Allowlist @@ -183,9 +216,63 @@ Module manager + + More + Lip index + + Acrylic + + + Mica + + + None + + + Transparent + + + Background + + + Background color + + + Background color secondary + + + Clear image + + + Dark + + + Default + + + Enable background image + + + Light + + + Luminosity opacity + + + Navigation view content background color + + + Navigation view content border color + + + Select image + + + Personalization + Unknown server path! diff --git a/src/LipUI/Language/zh-CN/Resources.resw b/src/LipUI/Language/zh-CN/Resources.resw index 105d357..16b3d8e 100644 --- a/src/LipUI/Language/zh-CN/Resources.resw +++ b/src/LipUI/Language/zh-CN/Resources.resw @@ -117,6 +117,12 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 立即重启 + + + 需要重启应用 + 搜索 @@ -126,6 +132,21 @@ 不同意 + + GitHub API + + + Github代理 + + + Lip Index API + + + Lip路径 + + + 常规 + 无描述 @@ -144,6 +165,9 @@ 未知的Lip路径! + + 未知的服务器路径! + 取消 @@ -165,6 +189,15 @@ 更新 + + 组件 + + + 插件 + + + UI插件 + 白名单 @@ -183,9 +216,63 @@ 组件管理 + + 更多 + 包索引 + + 亚克力 + + + 云母 + + + + + + 透明 + + + 背景 + + + 背景颜色 + + + 二级背景颜色 + + + 清除图片 + + + 深色 + + + 默认 + + + 启用背景图片 + + + 浅色 + + + 不透明度 + + + 导航视图内容背景颜色 + + + 导航视图内容边框颜色 + + + 选择图片 + + + 个性化 + 未知的服务器路径! diff --git a/src/LipUI/LipUI.csproj b/src/LipUI/LipUI.csproj index 5a47b0a..86126e0 100644 --- a/src/LipUI/LipUI.csproj +++ b/src/LipUI/LipUI.csproj @@ -1,7 +1,7 @@  - + None true WinExe diff --git a/src/LipUI/MainWindow.xaml b/src/LipUI/MainWindow.xaml index 460f560..0a582db 100644 --- a/src/LipUI/MainWindow.xaml +++ b/src/LipUI/MainWindow.xaml @@ -93,7 +93,7 @@ diff --git a/src/LipUI/Models/Config.cs b/src/LipUI/Models/Config.cs index 211d37c..fb5e42d 100644 --- a/src/LipUI/Models/Config.cs +++ b/src/LipUI/Models/Config.cs @@ -45,6 +45,9 @@ public class GeneralSetting [JsonPropertyName("github_api")] public string GithubApiKey { get; set; } = string.Empty; + + [JsonPropertyName("github_proxy")] + public string GithubProxy { get; set; } = string.Empty; } public class PersonalizationSetting @@ -88,15 +91,15 @@ public class PersonalizationSetting [JsonPropertyName("personalization_settings")] public PersonalizationSetting PersonalizationSettings { get; set; } + [JsonPropertyName("plugin_enable_info")] + public Dictionary PluginEanbleInfo { get; set; } + [JsonPropertyName("servers")] public List ServerInstances { get; set; } [JsonPropertyName("selected_server")] public ServerInstance? SelectedServer { get; set; } - [JsonPropertyName("plugin_enable_info")] - public Dictionary PluginEanbleInfo { get; set; } - public Config() { ServerInstances = new(); diff --git a/src/LipUI/Models/Plugin/PluginSystem.cs b/src/LipUI/Models/Plugin/PluginSystem.cs index 8d3c6c1..bfa8d21 100644 --- a/src/LipUI/Models/Plugin/PluginSystem.cs +++ b/src/LipUI/Models/Plugin/PluginSystem.cs @@ -69,6 +69,7 @@ public static async ValueTask LoadAsync() var types = from type in Assembly.GetExecutingAssembly().GetTypes() where type.IsAssignableTo(typeof(ILipuiPlugin)) && type.GetCustomAttribute() is not null select type; + pluginTypes.AddRange(types); foreach (var file in dirInfo.EnumerateFiles()) @@ -165,15 +166,16 @@ public static string GetPluginEnabledConfigKey(ILipuiPlugin plugin) private static async ValueTask EnablePlugins(IEnumerable plugins) { + var enableInfo = Main.Config.PluginEanbleInfo; + Main.Config.PluginEanbleInfo = new(); foreach (var plugin in plugins) { var key = GetPluginEnabledConfigKey(plugin); try { - if (Main.Config.PluginEanbleInfo.TryGetValue(key, out bool enable) is false) + if (enableInfo.TryGetValue(key, out bool enable) is false) { enable = plugin.DefaultEnabled; - Main.Config.PluginEanbleInfo.Add(key, enable); } if (enable) diff --git a/src/LipUI/Pages/Home/Modules/BdsPropertiesEditorPage.xaml.cs b/src/LipUI/Pages/Home/Modules/BdsPropertiesEditorPage.xaml.cs index e907088..a5cc606 100644 --- a/src/LipUI/Pages/Home/Modules/BdsPropertiesEditorPage.xaml.cs +++ b/src/LipUI/Pages/Home/Modules/BdsPropertiesEditorPage.xaml.cs @@ -70,7 +70,7 @@ private async void Page_Loaded(object sender, RoutedEventArgs e) if (Server is null) { await Task.Delay(500); - await ShowInfoBarAsync("propertiesEditor$nullServerPath".GetLocalized(), severity: InfoBarSeverity.Error); + ShowInfoBar("propertiesEditor$nullServerPath".GetLocalized(), severity: InfoBarSeverity.Error); Frame.TryGoBack(); return; }; @@ -130,7 +130,8 @@ private async void LoadPropertiesAndCreateUI() } catch (Exception ex) { - await ShowInfoBarAsync(ex); + ShowInfoBar(ex); + await Task.Delay(1000); Frame.TryGoBack(); return; } diff --git a/src/LipUI/Pages/LipExecutionPanel/LipExecutionPanelPage.xaml.cs b/src/LipUI/Pages/LipExecutionPanel/LipExecutionPanelPage.xaml.cs index 868de35..65923cc 100644 --- a/src/LipUI/Pages/LipExecutionPanel/LipExecutionPanelPage.xaml.cs +++ b/src/LipUI/Pages/LipExecutionPanel/LipExecutionPanelPage.xaml.cs @@ -119,9 +119,13 @@ public void Run() await InternalServices.ShowInfoBarAsync( "infobar$error".GetLocalized(), + Main.Config.SelectedServer is null ? + "lipExecution$nullServerPath".GetLocalized() : "lipExecution$nullLipPath".GetLocalized(), InfoBarSeverity.Error); + page.Frame.TryGoBack(); + return; } diff --git a/src/LipUI/Pages/LipExecutionPanel/LipInstallerView.xaml.cs b/src/LipUI/Pages/LipExecutionPanel/LipInstallerView.xaml.cs index 623d0a9..6a92c6c 100644 --- a/src/LipUI/Pages/LipExecutionPanel/LipInstallerView.xaml.cs +++ b/src/LipUI/Pages/LipExecutionPanel/LipInstallerView.xaml.cs @@ -91,7 +91,7 @@ private async ValueTask DownloadLipPortable(InstallerInfo info) catch (Exception ex) { await InternalServices.ShowInfoBarAsync(ex, severity: InfoBarSeverity.Warning); - response = await client.GetAsync($"https://github.moeyy.xyz/{info.AssetUrl}"); + response = await client.GetAsync($"{Main.Config.GeneralSettings.GithubProxy}/{info.AssetUrl}"); } var input = await response.Content.ReadAsStreamAsync(); diff --git a/src/LipUI/Pages/ModuleManager/ModuleManagerPage.xaml b/src/LipUI/Pages/ModuleManager/ModuleManagerPage.xaml index 7531542..aec2b74 100644 --- a/src/LipUI/Pages/ModuleManager/ModuleManagerPage.xaml +++ b/src/LipUI/Pages/ModuleManager/ModuleManagerPage.xaml @@ -34,7 +34,7 @@ + x:Uid="moduleManager$plugins"/> @@ -50,7 +50,7 @@ + x:Uid="moduleManager$UIplugins"/> @@ -66,7 +66,7 @@ + x:Uid="moduleManager$modules"/> diff --git a/src/LipUI/Pages/Settings/GeneralSettingsView.xaml b/src/LipUI/Pages/Settings/GeneralSettingsView.xaml index 20908e4..c791d70 100644 --- a/src/LipUI/Pages/Settings/GeneralSettingsView.xaml +++ b/src/LipUI/Pages/Settings/GeneralSettingsView.xaml @@ -17,14 +17,16 @@ Spacing="8"> + Background="{ThemeResource LayerOnAcrylicFillColorDefault}" + Loading="GithubProxyInput_Loading" + TextChanged="GithubProxyInput_TextChanged"/> @@ -33,14 +35,52 @@ Spacing="8"> + Background="{ThemeResource LayerOnAcrylicFillColorDefault}" + Loading="LipIndexApiInput_Loading" + TextChanged="LipIndexApiInput_TextChanged"/> + + + + + + + + + + + + + + + + diff --git a/src/LipUI/Pages/Settings/GeneralSettingsView.xaml.cs b/src/LipUI/Pages/Settings/GeneralSettingsView.xaml.cs index 0941fc0..fb54f5c 100644 --- a/src/LipUI/Pages/Settings/GeneralSettingsView.xaml.cs +++ b/src/LipUI/Pages/Settings/GeneralSettingsView.xaml.cs @@ -1,3 +1,5 @@ +using LipUI.Models; +using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; // To learn more about WinUI, the WinUI project structure, @@ -11,4 +13,44 @@ public GeneralSettingsView() { InitializeComponent(); } + + private void GithubProxyInput_TextChanged(object sender, TextChangedEventArgs e) + { + Main.Config.GeneralSettings.GithubProxy = GithubProxyInput.Text; + } + + private void LipIndexApiInput_TextChanged(object sender, TextChangedEventArgs e) + { + Main.Config.GeneralSettings.LipIndexApiKey = LipIndexApiInput.Text; + } + + private void LipPathInput_TextChanged(object sender, TextChangedEventArgs e) + { + Main.Config.GeneralSettings.LipPath = LipPathInput.Text; + } + + private void GithubApiInput_TextChanged(object sender, TextChangedEventArgs e) + { + Main.Config.GeneralSettings.GithubApiKey = GithubApiInput.Text; + } + + private void GithubProxyInput_Loading(FrameworkElement sender, object args) + { + GithubProxyInput.Text = Main.Config.GeneralSettings.GithubProxy; + } + + private void LipIndexApiInput_Loading(FrameworkElement sender, object args) + { + LipIndexApiInput.Text = Main.Config.GeneralSettings.LipIndexApiKey; + } + + private void GithubApiInput_Loading(FrameworkElement sender, object args) + { + GithubApiInput.Text = Main.Config.GeneralSettings.GithubApiKey; + } + + private void LipPathInput_Loading(FrameworkElement sender, object args) + { + LipPathInput.Text = Main.Config.GeneralSettings.LipPath; + } } diff --git a/src/LipUI/Pages/Settings/PersonalizationSettingsView.xaml b/src/LipUI/Pages/Settings/PersonalizationSettingsView.xaml index 38f39e9..5227f8b 100644 --- a/src/LipUI/Pages/Settings/PersonalizationSettingsView.xaml +++ b/src/LipUI/Pages/Settings/PersonalizationSettingsView.xaml @@ -64,7 +64,7 @@ @@ -78,7 +78,7 @@ Width="256"> @@ -151,7 +151,7 @@ + x:Uid="personalizationSettings$backgroundColor"/> @@ -172,7 +172,7 @@ + x:Uid="personalizationSettings$navViewBackgroundColor"/> @@ -193,7 +193,7 @@ + x:Uid="personalizationSettings$navViewBorderColor"/> @@ -214,7 +214,7 @@ + x:Uid="personalizationSettings$backgroundColorSecondary"/> @@ -228,7 +228,7 @@ Background="{StaticResource LayerOnMicaBaseAltFillColorDefault}"> @@ -244,12 +244,12 @@