2024-03-07 10:41:18 +00:00
|
|
|
|
using System;
|
2023-12-18 14:53:56 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
2024-03-07 10:41:18 +00:00
|
|
|
|
using HKW.HKWUtils.Observable;
|
|
|
|
|
using LinePutScript.Localization.WPF;
|
|
|
|
|
using Panuon.WPF.UI;
|
2024-02-03 16:08:31 +00:00
|
|
|
|
using VPet.Solution.Models.SettingEditor;
|
|
|
|
|
using VPet.Solution.ViewModels.SettingEditor;
|
2024-03-09 18:05:27 +00:00
|
|
|
|
using VPet_Simulator.Windows;
|
2023-12-18 14:53:56 +00:00
|
|
|
|
|
|
|
|
|
namespace VPet.Solution.ViewModels;
|
|
|
|
|
|
2024-01-25 13:56:38 +00:00
|
|
|
|
public class MainWindowVM : ObservableClass<MainWindowVM>
|
|
|
|
|
{
|
2024-03-07 10:41:18 +00:00
|
|
|
|
private readonly SettingModel? _mainSetting;
|
2024-02-03 16:08:31 +00:00
|
|
|
|
|
2024-01-25 13:56:38 +00:00
|
|
|
|
public MainWindowVM()
|
|
|
|
|
{
|
|
|
|
|
LocalizeCore.StoreTranslation = true;
|
|
|
|
|
LocalizeCore.LoadDefaultCulture();
|
2024-03-07 10:41:18 +00:00
|
|
|
|
_mainSetting = SettingWindowVM.Current.ShowSettings.FirstOrDefault(m =>
|
|
|
|
|
m.Name == nameof(Setting)
|
2024-02-03 16:08:31 +00:00
|
|
|
|
);
|
2024-02-04 09:37:45 +00:00
|
|
|
|
if (string.IsNullOrWhiteSpace(_mainSetting?.GraphicsSetting?.Language))
|
2024-02-03 16:08:31 +00:00
|
|
|
|
CurrentCulture = LocalizeCore.CurrentCulture;
|
|
|
|
|
else
|
|
|
|
|
CurrentCulture = _mainSetting.GraphicsSetting.Language;
|
|
|
|
|
|
2024-01-25 13:56:38 +00:00
|
|
|
|
FirstStartFailedCommand.ExecuteCommand += FirstStartFailedCommand_ExecuteCommand;
|
|
|
|
|
OpenLocalTextCommand.ExecuteCommand += OpenLocalTextCommand_ExecuteCommand;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OpenLocalTextCommand_ExecuteCommand()
|
|
|
|
|
{
|
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
foreach (var a in LocalizeCore.StoreTranslationList)
|
|
|
|
|
sb.AppendLine(a.Replace("\r\n", "\\r\\n"));
|
|
|
|
|
MessageBoxX.Show(sb.ToString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void FirstStartFailedCommand_ExecuteCommand()
|
|
|
|
|
{
|
2024-01-25 14:40:50 +00:00
|
|
|
|
if (LocalizeCore.CurrentCulture == "zh-Hans")
|
2024-02-04 09:37:45 +00:00
|
|
|
|
HKWUtils.OpenLink("https://www.bilibili.com/read/cv26510496/");
|
2024-01-25 14:40:50 +00:00
|
|
|
|
else
|
2024-02-04 09:37:45 +00:00
|
|
|
|
HKWUtils.OpenLink(
|
|
|
|
|
"https://steamcommunity.com/games/1920960/announcements/detail/3681184905256253203"
|
|
|
|
|
);
|
2024-01-25 13:56:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region Property
|
2024-03-07 10:41:18 +00:00
|
|
|
|
public static IEnumerable<string> AvailableCultures => LocalizeCore.AvailableCultures;
|
2024-01-25 13:56:38 +00:00
|
|
|
|
#region CurrentCulture
|
|
|
|
|
private string _currentCulture = string.Empty;
|
|
|
|
|
public string CurrentCulture
|
|
|
|
|
{
|
|
|
|
|
get => _currentCulture;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
SetProperty(ref _currentCulture, value);
|
|
|
|
|
LocalizeCore.LoadCulture(_currentCulture);
|
2024-02-20 10:45:02 +00:00
|
|
|
|
if (
|
2024-03-07 10:41:18 +00:00
|
|
|
|
_mainSetting is not null
|
|
|
|
|
&& _mainSetting.GraphicsSetting.Language != _currentCulture
|
2024-02-20 10:45:02 +00:00
|
|
|
|
)
|
2024-02-03 16:08:31 +00:00
|
|
|
|
{
|
|
|
|
|
_mainSetting.GraphicsSetting.Language = _currentCulture;
|
|
|
|
|
_mainSetting.Save();
|
|
|
|
|
}
|
2024-01-25 13:56:38 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Command
|
|
|
|
|
public ObservableCommand FirstStartFailedCommand { get; } = new();
|
|
|
|
|
public ObservableCommand OpenLocalTextCommand { get; } = new();
|
|
|
|
|
#endregion
|
|
|
|
|
}
|