为字体和主题支持翻译

This commit is contained in:
ZouJin 2024-03-30 17:59:45 +08:00
parent 07196d20e9
commit 86f30dcc7b
7 changed files with 113 additions and 54 deletions

View File

@ -1,4 +1,5 @@
using LinePutScript; using LinePutScript;
using LinePutScript.Localization.WPF;
using System.IO; using System.IO;
using System.Windows.Media; using System.Windows.Media;
@ -9,6 +10,22 @@ namespace VPet_Simulator.Windows.Interface
/// </summary> /// </summary>
public class Theme public class Theme
{ {
private string transname = null;
/// <summary>
/// 名字 (翻译)
/// </summary>
public string TranslateName
{
get
{
if (transname == null)
{
transname = LocalizeCore.Translate(Name);
}
return transname;
}
}
public string Name; public string Name;
public string xName; public string xName;
public string Image; public string Image;
@ -31,7 +48,25 @@ namespace VPet_Simulator.Windows.Interface
/// </summary> /// </summary>
public class IFont public class IFont
{ {
/// <summary>
/// 字体名字
/// </summary>
public string Name; public string Name;
private string transname = null;
/// <summary>
/// 名字 (翻译)
/// </summary>
public string TranslateName
{
get
{
if (transname == null)
{
transname = LocalizeCore.Translate(Name);
}
return transname;
}
}
public string Path; public string Path;
public IFont(FileInfo path) public IFont(FileInfo path)
{ {

View File

@ -304,8 +304,8 @@ namespace VPet_Simulator.Windows
if (authtype != "FAIL") if (authtype != "FAIL")
authtype = "[认证]".Translate(); authtype = "[认证]".Translate();
} }
else if (!(certificate.Subject.Contains("Microsoft Corporation") && else if (!(certificate.Issuer.Contains("Microsoft Corporation") || certificate.Issuer.Contains(".NET Foundation Projects"))
certificate.Issuer.Contains("Microsoft Corporation")) && !IsPassMOD(mw)) && !IsPassMOD(mw))
{//不是通过模组,不加载 {//不是通过模组,不加载
SuccessLoad = false; SuccessLoad = false;
continue; continue;

View File

@ -96,7 +96,7 @@ namespace VPet_Simulator.Windows
/// <param name="themename">主题名称</param> /// <param name="themename">主题名称</param>
public void LoadTheme(string themename) public void LoadTheme(string themename)
{ {
Theme ctheme = Themes.Find(x => x.Name == themename || x.xName == themename); Theme ctheme = Themes.Find(x => x.xName == themename);
if (ctheme == null) if (ctheme == null)
{ {
return; return;
@ -152,8 +152,9 @@ namespace VPet_Simulator.Windows
{ {
return; return;
} }
Application.Current.Resources["MainFont"] = cfont.Font; var font = cfont.Font;
Panuon.WPF.UI.GlobalSettings.Setting.FontFamily = cfont.Font; Application.Current.Resources["MainFont"] = font;
Panuon.WPF.UI.GlobalSettings.Setting.FontFamily = font;
} }
public List<Food> Foods { get; } = new List<Food>(); public List<Food> Foods { get; } = new List<Food>();

View File

@ -145,16 +145,16 @@ namespace VPet_Simulator.Windows
foreach (var v in mw.Fonts) foreach (var v in mw.Fonts)
{ {
FontBox.Items.Add(v.Name); FontBox.Items.Add(v.TranslateName);
} }
FontBox.SelectedItem = mw.Set.Font; FontBox.SelectedIndex = mw.Fonts.FindIndex(x => x.Name == mw.Set.Font);
foreach (var v in mw.Themes) foreach (var v in mw.Themes)
{ {
ThemeBox.Items.Add(v.Name); ThemeBox.Items.Add(v.TranslateName);
} }
if (mw.Theme != null) if (mw.Theme != null)
ThemeBox.SelectedItem = mw.Theme.Name; ThemeBox.SelectedItem = mw.Theme.TranslateName;
VoiceCatchSilder.Value = mw.Set.MusicCatch; VoiceCatchSilder.Value = mw.Set.MusicCatch;
VoiceMaxSilder.Value = mw.Set.MusicMax; VoiceMaxSilder.Value = mw.Set.MusicMax;
@ -487,8 +487,7 @@ namespace VPet_Simulator.Windows
{ {
if (!AllowChange) if (!AllowChange)
return; return;
string str = (string)(ThemeBox.SelectedItem); mw.LoadTheme(mw.Themes[ThemeBox.SelectedIndex].xName);
mw.LoadTheme(str);
mw.Set.Theme = mw.Theme.xName; mw.Set.Theme = mw.Theme.xName;
} }
@ -496,7 +495,7 @@ namespace VPet_Simulator.Windows
{ {
if (!AllowChange) if (!AllowChange)
return; return;
string str = (string)(FontBox.SelectedItem); string str = mw.Fonts[FontBox.SelectedIndex].Name;
mw.LoadFont(str); mw.LoadFont(str);
mw.Set.Font = str; mw.Set.Font = str;
} }

View File

@ -68,3 +68,11 @@ theme#Theme:|
详细内容信息#Details:| 详细内容信息#Details:|
详细描述\reg:报错详细信息#Details\reg:Error details:| 详细描述\reg:报错详细信息#Details\reg:Error details:|
是否上传当前游戏存档#Do you want to upload the current game archive?:| 是否上传当前游戏存档#Do you want to upload the current game archive?:|
Alibaba PuHuiTi Regular#Alibaba PuHuiTi Regular:|
HarmonyOS Sans#HarmonyOS Sans:|
MiSans Regular#MiSans Regular:|
OPPOSans R#OPPOSans R:|
凤凰点阵体 12px#Phoenix 12px:|
得意黑#DeYi Black:|
原版默认#Original Default:|
混色紫#Mixed Purple:|

View File

@ -68,3 +68,11 @@ theme#主题:|
详细内容信息#详细内容信息:| 详细内容信息#详细内容信息:|
详细描述\reg:报错详细信息#详细描述\reg:报错详细信息:| 详细描述\reg:报错详细信息#详细描述\reg:报错详细信息:|
是否上传当前游戏存档#是否上传当前游戏存档:| 是否上传当前游戏存档#是否上传当前游戏存档:|
Alibaba PuHuiTi Regular#Alibaba PuHuiTi Regular:|
HarmonyOS Sans#HarmonyOS Sans:|
MiSans Regular#MiSans Regular:|
OPPOSans R#OPPOSans R:|
凤凰点阵体 12px#凤凰点阵体 12px:|
得意黑#得意黑:|
原版默认#原版默认:|
混色紫#混色紫:|

View File

@ -68,3 +68,11 @@ theme#主題:|
详细内容信息#詳細內容信息:| 详细内容信息#詳細內容信息:|
详细描述\reg:报错详细信息#詳細描述\reg:報錯詳細信息:| 详细描述\reg:报错详细信息#詳細描述\reg:報錯詳細信息:|
是否上传当前游戏存档#是否上傳目前遊戲存檔:| 是否上传当前游戏存档#是否上傳目前遊戲存檔:|
Alibaba PuHuiTi Regular#Alibaba PuHuiTi Regular:|
HarmonyOS Sans#HarmonyOS Sans:|
MiSans Regular#MiSans Regular:|
OPPOSans R#OPPOSans R:|
凤凰点阵体 12px#鳳凰點陣體 12px:|
得意黑#得意黑:|
原版默认#原版默認:|
混色紫#混色紫:|