From 0cf474382ec3a667c86b27b32a1f0f34d029741b Mon Sep 17 00:00:00 2001 From: neon-nyan Date: Mon, 25 Apr 2022 12:39:21 +0700 Subject: [PATCH] Add local commit --- .../Properties/launchSettings.json | 2 +- .../InstallManagement/InstallManagement.cs | 38 ++++++- CollapseLauncher/CollapseLauncher.csproj | 2 +- .../Pages/Dialogs/SimpleDialogs.cs | 48 ++++++++- CollapseLauncher/Pages/HomePage.Variable.cs | 3 + CollapseLauncher/Pages/HomePage.xaml.cs | 102 +++++++++++++----- CollapseLauncher/Pages/SettingsPage.xaml | 2 +- CollapseLauncher/Pages/SettingsPage.xaml.cs | 22 +++- .../Preset/Classes/PresetConfigClasses.cs | 82 +++++++++++++- .../ClassStruct/Class/RegionResource.cs | 1 + 10 files changed, 256 insertions(+), 46 deletions(-) diff --git a/CollapseLauncher.Updater/Properties/launchSettings.json b/CollapseLauncher.Updater/Properties/launchSettings.json index 60349e705..1020b7f72 100644 --- a/CollapseLauncher.Updater/Properties/launchSettings.json +++ b/CollapseLauncher.Updater/Properties/launchSettings.json @@ -7,7 +7,7 @@ }, "CollapseLauncher.ReindexPreview": { "commandName": "Project", - "commandLineArgs": "reindex C:\\myGit\\CollapseLauncher-ReleaseRepo\\preview 1.0.12.0", + "commandLineArgs": "reindex C:\\myGit\\CollapseLauncher-ReleaseRepo\\preview 1.0.13.0", "nativeDebugging": true }, "CollapseLauncher.ReindexStable": { diff --git a/CollapseLauncher/Classes/InstallManagement/InstallManagement.cs b/CollapseLauncher/Classes/InstallManagement/InstallManagement.cs index 3aa257afc..a8d614081 100644 --- a/CollapseLauncher/Classes/InstallManagement/InstallManagement.cs +++ b/CollapseLauncher/Classes/InstallManagement/InstallManagement.cs @@ -93,14 +93,29 @@ private void ApplyParameter() CanSkipExtract = File.Exists(Path.Combine(GameDirPath, "@NoExtraction")); } - public void AddDownloadProperty(string URL, string OutputPath, string OutputDir, string RemoteHash) => DownloadProperty.Add(new DownloadAddressProperty + public void AddDownloadProperty(string URL, string OutputPath, string OutputDir, string RemoteHash, long RemoteRequiredSize) => DownloadProperty.Add(new DownloadAddressProperty { URL = URL, Output = OutputPath, DirectoryOutput = OutputDir, RemoteHash = RemoteHash, + RemoteRequiredSize = RemoteRequiredSize }); + public async Task CheckDriveFreeSpace(UIElement Content) + { + DriveInfo _DriveInfo = new DriveInfo(GameDirPath); + long RequiredSpace = DownloadProperty.Sum(x => x.RemoteRequiredSize) - DownloadProperty.Sum(x => GetExistingPartialDownloadLength(x.Output)); + long DiskSpace = new DriveInfo(GameDirPath).TotalFreeSpace; + + if (DiskSpace < RequiredSpace) + { + await Dialog_InsufficientDriveSpace(Content, DiskSpace, RequiredSpace, _DriveInfo.Name); + throw new IOException($"Free Space on {_DriveInfo.Name} is sufficient! (Free space: {DiskSpace}, Req. Space: {RequiredSpace}, Drive: {_DriveInfo.Name}). Cancelling the task!"); + } + } + + public void StartDownload() { DownloadStopwatch = Stopwatch.StartNew(); @@ -589,14 +604,25 @@ private void BuildPersistentManifest(in List Entries, // Build data_versions (silence) ManifestPath = Path.Combine(GameDirPath, $"{ExecutablePrefix}_Data\\Persistent\\silence_data_versions"); ParentURL = $"{QueryProperty.ClientDesignDataSilURL}/AssetBundles"; - using (FileStream fs = new FileStream(ManifestPath + "_persist", FileMode.Create, FileAccess.Write)) - new HttpClientHelper(false).DownloadFile(ParentURL + "/data_versions", fs, Token); - - BuildManifestPersistentList(ManifestPath + "_persist", Entries, ref HashtableManifest, $"{ExecutablePrefix}_Data\\Persistent\\AssetBundles", "", ParentURL); + // Remove read-only and system attribute from silence_data_version that was set by game. + try + { + if (File.Exists(ManifestPath + "_persist")) + { + FileInfo _file = new FileInfo(ManifestPath + "_persist"); + _file.IsReadOnly = false; + } + using (FileStream fs = new FileStream(ManifestPath + "_persist", FileMode.Create, FileAccess.Write)) + new HttpClientHelper(false).DownloadFile(ParentURL + "/data_versions", fs, Token); + + BuildManifestPersistentList(ManifestPath + "_persist", Entries, ref HashtableManifest, $"{ExecutablePrefix}_Data\\Persistent\\AssetBundles", "", ParentURL); + } + catch { } // Build data_versions ManifestPath = Path.Combine(GameDirPath, $"{ExecutablePrefix}_Data\\Persistent\\data_versions"); ParentURL = $"{QueryProperty.ClientDesignDataURL}/AssetBundles"; + if (File.Exists(ManifestPath + "_persist")) File.Delete(ManifestPath + "_persist"); using (FileStream fs = new FileStream(ManifestPath + "_persist", FileMode.Create, FileAccess.Write)) new HttpClientHelper(false).DownloadFile(ParentURL + "/data_versions", fs, Token); @@ -606,6 +632,7 @@ private void BuildPersistentManifest(in List Entries, ManifestPath = Path.Combine(GameDirPath, $"{ExecutablePrefix}_Data\\Persistent\\res_versions"); ParentURL = $"{QueryProperty.ClientGameResURL}/StandaloneWindows64"; ParentAudioURL = $"{QueryProperty.ClientAudioAssetsURL}/StandaloneWindows64"; + if (File.Exists(ManifestPath + "_persist")) File.Delete(ManifestPath + "_persist"); using (FileStream fs = new FileStream(ManifestPath + "_persist", FileMode.Create, FileAccess.Write)) new HttpClientHelper(false).DownloadFile(ParentURL + "/release_res_versions_external", fs, Token); @@ -820,6 +847,7 @@ public class DownloadAddressProperty public string Output; public string DirectoryOutput; public long RemoteSize; + public long RemoteRequiredSize; public long LocalSize; public long LocalUncompressedSize; public bool IsCorrupted = false; diff --git a/CollapseLauncher/CollapseLauncher.csproj b/CollapseLauncher/CollapseLauncher.csproj index 0e8ca9902..861710a67 100644 --- a/CollapseLauncher/CollapseLauncher.csproj +++ b/CollapseLauncher/CollapseLauncher.csproj @@ -12,7 +12,7 @@ true None true - 1.0.12.0 + 1.0.13.0 Debug;Release;Publish icon.ico diff --git a/CollapseLauncher/Pages/Dialogs/SimpleDialogs.cs b/CollapseLauncher/Pages/Dialogs/SimpleDialogs.cs index 480b828e8..1bcc51b97 100644 --- a/CollapseLauncher/Pages/Dialogs/SimpleDialogs.cs +++ b/CollapseLauncher/Pages/Dialogs/SimpleDialogs.cs @@ -1,4 +1,6 @@ using System; +using System.Collections; +using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.UI.Xaml; @@ -67,6 +69,33 @@ await SpawnDialog( null ); + public static async Task Dialog_ChooseAudioLanguage(UIElement Content, List langlist) + { + // Default: 2 (Japanese) + int index = 2; + StackPanel Panel = new StackPanel(); + ComboBox LangBox = new ComboBox() + { + PlaceholderText = "Select your Audio Language", + Width = 256, + ItemsSource = langlist, + SelectedIndex = index, + HorizontalAlignment = HorizontalAlignment.Center, + }; + Panel.Children.Add(new TextBlock() + { + Text = $"Before you install the game, you need to choose which audio language you want to use (Default: Japanese):", + TextWrapping = TextWrapping.Wrap, + Margin = new Thickness(0,0,0,16) + }); + Panel.Children.Add(LangBox); + await SpawnDialog("Choose Audio Language", Panel, Content, null, "Next", null); + + index = LangBox.SelectedIndex; + + return index; + } + public static async Task Dialog_AdditionalDownloadNeeded(UIElement Content, long fileSize) => await SpawnDialog( "Additional Download is Needed", @@ -241,14 +270,27 @@ public static async Task Dialog_ExistingDownload(UIElement await SpawnDialog( "Resume Download?", string.Format("You have downloaded {0}/{1} of the game previously.\r\n\r\nDo you want to continue?", - ConverterTool.SummarizeSizeSimple(partialLength), - ConverterTool.SummarizeSizeSimple(contentLength)), + SummarizeSizeSimple(partialLength), + SummarizeSizeSimple(contentLength)), Content, null, "Yes, Resume", "No, Start from Beginning" ); + public static async Task Dialog_InsufficientDriveSpace(UIElement Content, long DriveFreeSpace, long RequiredSpace, string DriveLetter) => + await SpawnDialog( + "Disk space is insufficient", + string.Format("You don't have enough free space to install this game on your {2} drive!\r\n\r\nFree Space: {0}\r\nRequired Space: {1}.\r\n\r\nPlease make sure you have enough disk space before installing.", + SummarizeSizeSimple(DriveFreeSpace), + SummarizeSizeSimple(RequiredSpace), + DriveLetter), + Content, + null, + "Okay", + null + ); + public static async Task Dialog_RelocateFolder(UIElement Content) => await SpawnDialog( "Relocate App Data Folder", @@ -284,7 +326,7 @@ await SpawnDialog( ); public static async Task SpawnDialog( - string title, string content, UIElement Content, + string title, object content, UIElement Content, string closeText = null, string primaryText = null, string secondaryText = null, ContentDialogButton defaultButton = ContentDialogButton.Primary) => await new ContentDialog diff --git a/CollapseLauncher/Pages/HomePage.Variable.cs b/CollapseLauncher/Pages/HomePage.Variable.cs index 62dd0448b..3c3568a48 100644 --- a/CollapseLauncher/Pages/HomePage.Variable.cs +++ b/CollapseLauncher/Pages/HomePage.Variable.cs @@ -24,11 +24,14 @@ public struct AdditionalFile string GameZipPath; string GameZipRemoteHash; string GameZipLocalHash; + long GameZipSize; + long GameZipRequiredSize; string GameZipVoiceUrl; string GameZipVoicePath; string GameZipVoiceRemoteHash; long GameZipVoiceSize; + long GameZipVoiceRequiredSize; RegionResourceVersion VoicePackFile = new RegionResourceVersion(); InstallManagement InstallTool; diff --git a/CollapseLauncher/Pages/HomePage.xaml.cs b/CollapseLauncher/Pages/HomePage.xaml.cs index 35efe07f7..88176ae37 100644 --- a/CollapseLauncher/Pages/HomePage.xaml.cs +++ b/CollapseLauncher/Pages/HomePage.xaml.cs @@ -358,6 +358,11 @@ private async void InstallGameDialog(object sender, RoutedEventArgs e) } MainFrameChanger.ChangeMainFrame(typeof(HomePage)); } + catch (IOException ex) + { + LogWriteLine($"Installation cancelled for region {CurrentRegion.ZoneName} because of IO Error!\r\n{ex}", Hi3Helper.LogType.Warning, true); + MainFrameChanger.ChangeMainFrame(typeof(HomePage)); + } catch (TaskCanceledException) { LogWriteLine($"Installation cancelled for region {CurrentRegion.ZoneName}"); @@ -385,7 +390,9 @@ private async Task StartInstallationProcedure(string destinationFolder) if (string.IsNullOrEmpty(GameDirPath)) throw new OperationCanceledException(); - TryAddVoicePack(GetUpdateDiffs()); + // await TryAddVoicePack(GetUpdateDiffs()); + await TrySetVoicePack(GetUpdateDiffs()); + CurrentRegion.SetVoiceLanguageID(VoicePackFile.languageID ?? 2); if (IsGameHasVoicePack) { @@ -393,6 +400,7 @@ private async Task StartInstallationProcedure(string destinationFolder) GameZipVoicePath = Path.Combine(GameDirPath, Path.GetFileName(GameZipVoiceUrl)); GameZipVoiceRemoteHash = VoicePackFile.md5.ToLower(); GameZipVoiceSize = VoicePackFile.package_size; + GameZipVoiceRequiredSize = VoicePackFile.size; } while (!await DownloadGameClient(GameDirPath)) @@ -425,23 +433,8 @@ private void ApplyGameConfig(string destinationFolder) gameIni.Profile["launcher"]["game_install_path"] = destinationFolder.Replace('\\', '/'); SaveGameProfile(); PrepareGameConfig(); - // GamePkgVersionVerification(); - } - - private void GamePkgVersionVerification() - { - string GamePath = NormalizePath(gameIni.Profile["launcher"]["game_install_path"].ToString()); - string PkgVersionPath = Path.Combine(GamePath, "pkg_version"); - - string[] PkgVersionData = File.ReadAllLines(PkgVersionPath); - int PkgVersionDataCount = PkgVersionData.Length - 1; - - PkgVersionProperties pkgVersionProperties; - - for (int i = 0; i < PkgVersionDataCount; i++) - { - pkgVersionProperties = JsonConvert.DeserializeObject(PkgVersionData[i]); - } + if (IsGameHasVoicePack && (CurrentRegion.IsGenshin ?? false)) + CurrentRegion.SetVoiceLanguageID(VoicePackFile.languageID ?? 2); } /* @@ -522,6 +515,7 @@ private async Task DownloadGameClient(string destinationFolder) GameZipUrl = regionResourceProp.data.game.latest.path; GameZipRemoteHash = regionResourceProp.data.game.latest.md5.ToLower(); GameZipPath = Path.Combine(destinationFolder, Path.GetFileName(GameZipUrl)); + GameZipRequiredSize = regionResourceProp.data.game.latest.size; DispatcherQueue.TryEnqueue(() => { @@ -549,9 +543,9 @@ private async Task DownloadGameClient(string destinationFolder) CurrentRegion.GetRegServerNameID(), Path.GetFileNameWithoutExtension(CurrentRegion.GameExecutableName)); - InstallTool.AddDownloadProperty(GameZipUrl, GameZipPath, GameDirPath, GameZipRemoteHash); + InstallTool.AddDownloadProperty(GameZipUrl, GameZipPath, GameDirPath, GameZipRemoteHash, GameZipRequiredSize); if (IsGameHasVoicePack) - InstallTool.AddDownloadProperty(GameZipVoiceUrl, GameZipVoicePath, GameDirPath, GameZipVoiceRemoteHash); + InstallTool.AddDownloadProperty(GameZipVoiceUrl, GameZipVoicePath, GameDirPath, GameZipVoiceRemoteHash, GameZipVoiceRequiredSize); ProgressStatusGrid.Visibility = Visibility.Visible; UpdateGameBtn.Visibility = Visibility.Collapsed; @@ -561,6 +555,7 @@ private async Task DownloadGameClient(string destinationFolder) InstallTool.InstallProgressChanged += InstallToolProgress; bool RetryRoutine = true; + await InstallTool.CheckDriveFreeSpace(Content); await InstallTool.CheckExistingDownloadAsync(Content); while (RetryRoutine) @@ -1287,9 +1282,11 @@ private async void UpdateGameDialog(object sender, RoutedEventArgs e) GameZipUrl = diff.path; GameZipRemoteHash = diff.md5.ToLower(); GameZipPath = Path.Combine(GameDirPath, Path.GetFileName(GameZipUrl)); - InstallTool.AddDownloadProperty(GameZipUrl, GameZipPath, GameDirPath, GameZipRemoteHash); + GameZipRequiredSize = diff.size; - TryAddVoicePack(GetUpdateDiffs(false)); + InstallTool.AddDownloadProperty(GameZipUrl, GameZipPath, GameDirPath, GameZipRemoteHash, GameZipRequiredSize); + + await TryAddVoicePack(GetUpdateDiffs(false)); if (IsGameHasVoicePack) { @@ -1297,7 +1294,8 @@ private async void UpdateGameDialog(object sender, RoutedEventArgs e) GameZipVoiceRemoteHash = VoicePackFile.md5; GameZipVoicePath = Path.Combine(GameDirPath, Path.GetFileName(GameZipVoiceUrl)); GameZipVoiceSize = VoicePackFile.package_size; - InstallTool.AddDownloadProperty(GameZipVoiceUrl, GameZipVoicePath, GameDirPath, GameZipVoiceRemoteHash); + GameZipVoiceRequiredSize = VoicePackFile.size; + InstallTool.AddDownloadProperty(GameZipVoiceUrl, GameZipVoicePath, GameDirPath, GameZipVoiceRemoteHash, GameZipVoiceRequiredSize); } try @@ -1310,6 +1308,7 @@ private async void UpdateGameDialog(object sender, RoutedEventArgs e) InstallTool.InstallProgressChanged += InstallToolProgress; bool RetryRoutine = true; + await InstallTool.CheckDriveFreeSpace(Content); await InstallTool.CheckExistingDownloadAsync(Content); while (RetryRoutine) @@ -1323,7 +1322,12 @@ private async void UpdateGameDialog(object sender, RoutedEventArgs e) ApplyGameConfig(GameDirPath); MainFrameChanger.ChangeMainFrame(typeof(HomePage)); - OverlapFrame.Navigate(typeof(HomePage), null, new DrillInNavigationTransitionInfo()); + // OverlapFrame.Navigate(typeof(HomePage), null, new DrillInNavigationTransitionInfo()); + } + catch (IOException ex) + { + MainFrameChanger.ChangeMainFrame(typeof(HomePage)); + LogWriteLine($"Update cancelled because of IO Error!\r\n{ex}", Hi3Helper.LogType.Warning); } catch (OperationCanceledException) { @@ -1684,19 +1688,63 @@ public void ApplyDeltaPatch(string GamePath) File.Delete(patchListPath); } - private void TryAddVoicePack(in RegionResourceVersion diffVer) + private async Task TryAddVoicePack(RegionResourceVersion diffVer) + { + int langID; + if (diffVer.voice_packs != null + && diffVer.voice_packs.Count > 0) + { + IsGameHasVoicePack = true; + VoicePackFile = diffVer.voice_packs[langID = CurrentRegion.GetVoiceLanguageID()]; + VoicePackFile.languageID = langID; + return; + } + LogWriteLine($"This {CurrentRegion.ProfileName} region doesn't have Voice Pack"); + IsGameHasVoicePack = false; + } + + private async Task TrySetVoicePack(RegionResourceVersion diffVer) { + int langID; if (diffVer.voice_packs != null && diffVer.voice_packs.Count > 0) { IsGameHasVoicePack = true; - VoicePackFile = diffVer.voice_packs[CurrentRegion.GetVoiceLanguageID()]; + VoicePackFile = diffVer.voice_packs[langID = await Dialog_ChooseAudioLanguage(Content, EnumerateAudioLanguageString(diffVer))]; + VoicePackFile.languageID = langID; return; } LogWriteLine($"This {CurrentRegion.ProfileName} region doesn't have Voice Pack"); IsGameHasVoicePack = false; } + private List EnumerateAudioLanguageString(RegionResourceVersion diffVer) + { + List value = new List(); + foreach (RegionResourceVersion Entry in diffVer.voice_packs) + { + switch (Entry.language) + { + case "en-us": + value.Add("English (US)"); + break; + case "ja-jp": + value.Add("Japanese"); + break; + case "zh-cn": + value.Add("Chinese (Simplified)"); + break; + case "ko-kr": + value.Add("Korean"); + break; + default: + value.Add(Entry.language); + break; + } + } + return value; + } + private async void PredownloadDialog(object sender, RoutedEventArgs e) { PauseDownloadPreBtn.Visibility = Visibility.Visible; @@ -1708,7 +1756,7 @@ private async void PredownloadDialog(object sender, RoutedEventArgs e) GameZipUrl = diffVer.path; GameZipRemoteHash = diffVer.md5.ToLower(); - TryAddVoicePack(diffVer); + await TryAddVoicePack(diffVer); if (IsGameHasVoicePack) { diff --git a/CollapseLauncher/Pages/SettingsPage.xaml b/CollapseLauncher/Pages/SettingsPage.xaml index 0f3cecd61..f9e637eee 100644 --- a/CollapseLauncher/Pages/SettingsPage.xaml +++ b/CollapseLauncher/Pages/SettingsPage.xaml @@ -59,7 +59,7 @@ - + This thread will handle extraction/verification process while installing/repairing the game. diff --git a/CollapseLauncher/Pages/SettingsPage.xaml.cs b/CollapseLauncher/Pages/SettingsPage.xaml.cs index 4010f8359..2e8b40ecf 100644 --- a/CollapseLauncher/Pages/SettingsPage.xaml.cs +++ b/CollapseLauncher/Pages/SettingsPage.xaml.cs @@ -19,6 +19,7 @@ public sealed partial class SettingsPage : Page public SettingsPage() { this.InitializeComponent(); + LoadAppConfig(); this.DataContext = this; string Version = $" {Assembly.GetExecutingAssembly().GetName().Version}"; @@ -137,16 +138,31 @@ private void LauncherUpdateInvoker_UpdateEvent(object sender, LauncherUpdateProp }); } + bool IsFirstChangeThemeSelection = false; private void ChangeThemeSelection(object sender, SelectionChangedEventArgs e) { SetAppConfigValue("ThemeMode", Enum.GetName(typeof(AppThemeMode), (sender as RadioButtons).SelectedIndex)); if (AppConfig.IsAppThemeNeedRestart) AppThemeSelectionWarning.Visibility = Visibility.Visible; - AppConfig.IsAppThemeNeedRestart = true; + if (IsFirstChangeThemeSelection) + AppConfig.IsAppThemeNeedRestart = true; + IsFirstChangeThemeSelection = true; } - private void ChangeDownloadThreadsValue(NumberBox sender, NumberBoxValueChangedEventArgs args) => SetAppConfigValue("DownloadThread", double.IsNaN(sender.Value) ? 8 : sender.Value); - private void ChangeExtractThreadsValue(NumberBox sender, NumberBoxValueChangedEventArgs args) => SetAppConfigValue("ExtractionThread", double.IsNaN(sender.Value) ? 0 : sender.Value); + bool IsFirstDownloadThreadsValue = false; + private void ChangeDownloadThreadsValue(NumberBox sender, NumberBoxValueChangedEventArgs args) + { + if (IsFirstDownloadThreadsValue) + SetAppConfigValue("DownloadThread", (int)(double.IsNaN(sender.Value) ? 0 : sender.Value)); + IsFirstDownloadThreadsValue = true; + } + bool IsFirstExtractThreadsValue = false; + private void ChangeExtractThreadsValue(NumberBox sender, NumberBoxValueChangedEventArgs args) + { + if (IsFirstExtractThreadsValue) + SetAppConfigValue("ExtractionThread", (int)(double.IsNaN(sender.Value) ? 0 : sender.Value)); + IsFirstExtractThreadsValue = true; + } } } diff --git a/Hi3HelperCore/Classes/Preset/Classes/PresetConfigClasses.cs b/Hi3HelperCore/Classes/Preset/Classes/PresetConfigClasses.cs index 802623c51..d9e2f69d5 100644 --- a/Hi3HelperCore/Classes/Preset/Classes/PresetConfigClasses.cs +++ b/Hi3HelperCore/Classes/Preset/Classes/PresetConfigClasses.cs @@ -112,11 +112,32 @@ public int GetVoiceLanguageID() } catch { - LogWriteLine($"Voice Language ID registry on \u001b[32;1m{Path.GetFileName(ConfigRegistryLocation)}\u001b[0m doesn't exist. Fallback value will be used (1 / en-us).", LogType.Warning); - return 1; + LogWriteLine($"Voice Language ID registry on \u001b[32;1m{Path.GetFileName(ConfigRegistryLocation)}\u001b[0m doesn't exist. Fallback value will be used (2 / ja-jp).", LogType.Warning); + return 2; } } + // WARNING!!! + // This feature is only available for Genshin. + public void SetVoiceLanguageID(int LangID) + { + string regValue; + RegistryKey keys; + GeneralDataProp initValue = new GeneralDataProp(); + try + { + keys = Registry.CurrentUser.OpenSubKey(ConfigRegistryLocation, true); + regValue = Encoding.UTF8.GetString((byte[])keys.GetValue("GENERAL_DATA_h2389025596", "{}", RegistryValueOptions.None)).Replace("\0", string.Empty); + initValue = JsonConvert.DeserializeObject(regValue); + } + catch + { + keys = Registry.CurrentUser.CreateSubKey(ConfigRegistryLocation); + } + initValue.deviceVoiceLanguageType = LangID; + keys.SetValue("GENERAL_DATA_h2389025596", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(initValue, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Include }) + '\0')); + } + // WARNING!!! // This feature is only available for Genshin. public int GetRegServerNameID() @@ -142,9 +163,60 @@ public int GetRegServerNameID() // This feature is only available for Genshin. class GeneralDataProp { - public int deviceLanguageType { get; set; } - public int deviceVoiceLanguageType { get; set; } - public ServerRegionID selectedServerName { get; set; } + public string deviceUUID { get; set; } = ""; + public string userLocalDataVersionId { get; set; } = ""; + public int deviceLanguageType { get; set; } = 1; + public int deviceVoiceLanguageType { get; set; } = 2; + public ServerRegionID? selectedServerName { get; set; } = ServerRegionID.os_asia; + public int localLevelIndex { get; set; } = 0; + public string deviceID { get; set; } = ""; + public string targetUID { get; set; } = ""; + public string curAccountName { get; set; } = ""; + public string uiSaveData { get; set; } = ""; + public string inputData { get; set; } = ""; + // Initialize 60 fps limit if it's blank + public string graphicsData { get; set; } = "{\"customVolatileGrades\":[{\"key\":1,\"value\":2}]"; + public string globalPerfData { get; set; } = ""; + public int miniMapConfig { get; set; } = 1; + public bool enableCameraSlope { get; set; } = true; + public bool enableCameraCombatLock { get; set; } = true; + public bool completionPkg { get; set; } = false; + public bool completionPlayGoPkg { get; set; } = false; + public bool onlyPlayWithPSPlayer { get; set; } = false; + public bool needPlayGoFullPkgPatch { get; set; } = false; + public bool resinNotification { get; set; } = true; + public bool exploreNotification { get; set; } = true; + public int volumeGlobal { get; set; } = 10; + public int volumeSFX { get; set; } = 10; + public int volumeMusic { get; set; } = 10; + public int volumeVoice { get; set; } = 10; + public int audioAPI { get; set; } = -1; + public int audioDynamicRange { get; set; } = 0; + // Use Surround by default if it's blank + public int audioOutput { get; set; } = 1; + public bool _audioSuccessInit { get; set; } = true; + public bool enableAudioChangeAndroidMinimumBufferCapacity { get; set; } = true; + public int audioAndroidMiniumBufferCapacity { get; set; } = 2 << 10; + public bool motionBlur { get; set; } = true; + public bool gyroAiming { get; set; } = false; + public bool firstHDRSetting { get; set; } = true; + public double maxLuminosity { get; set; } = 0.0f; + public double uiPaperWhite { get; set; } = 0.0f; + public double scenePaperWhite { get; set; } = 0.0f; + public double gammaValue { get; set; } = 2.200000047683716f; + public IEnumerable _overrideControllerMapKeyList { get; set; } = new List(); + public IEnumerable _overrideControllerMapValueList { get; set; } = new List(); + public int lastSeenPreDownloadTime { get; set; } = 0; + public bool mtrCached { get; set; } = false; + public bool mtrIsOpen { get; set; } = false; + public int mtrMaxTTL { get; set; } = 0x20; + public int mtrTimeOut { get; set; } = 0x1388; + public int mtrTraceCount { get; set; } = 5; + public int mtrAbortTimeOutCount { get; set; } = 3; + public int mtrAutoTraceInterval { get; set; } = 0; + public int mtrTraceCDEachReason { get; set; } = 0x258; + public IEnumerable _customDataKeyList { get; set; } = new List(); + public IEnumerable _customDataValueList { get; set; } = new List(); } void SetFallbackGameFolder(string a, bool tryFallback = false) diff --git a/Hi3HelperCore/Classes/Shared/ClassStruct/Class/RegionResource.cs b/Hi3HelperCore/Classes/Shared/ClassStruct/Class/RegionResource.cs index 0159ea4cb..198ef7276 100644 --- a/Hi3HelperCore/Classes/Shared/ClassStruct/Class/RegionResource.cs +++ b/Hi3HelperCore/Classes/Shared/ClassStruct/Class/RegionResource.cs @@ -29,6 +29,7 @@ public class RegionResourceVersion public long package_size { get; set; } public string md5 { get; set; } public string language { get; set; } + public int? languageID { get; set; } public bool is_recommended_update { get; set; } public string entry { get; set; } public List voice_packs { get; set; }