diff --git a/App.config b/App.config
index b087d5e..4275dd1 100644
--- a/App.config
+++ b/App.config
@@ -15,7 +15,7 @@
-
+
diff --git a/App.xaml.cs b/App.xaml.cs
index 39a6171..2095d82 100644
--- a/App.xaml.cs
+++ b/App.xaml.cs
@@ -1,5 +1,6 @@
using Microsoft.Win32;
using Newtonsoft.Json.Linq;
+using SevenZip;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -13,7 +14,7 @@ namespace BetterHI3Launcher
{
public partial class App : Application
{
- public static readonly LauncherVersion LocalLauncherVersion = new LauncherVersion("1.4.20230329.0");
+ public static readonly LauncherVersion LocalLauncherVersion = new LauncherVersion("1.4.20230628.0");
public static readonly string LauncherRootPath = AppDomain.CurrentDomain.BaseDirectory;
public static readonly string LocalLowPath = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}Low";
public static readonly string LauncherDataPath = Path.Combine(LocalLowPath, @"Bp\Better HI3 Launcher");
@@ -35,6 +36,7 @@ public partial class App : Application
public static readonly int ParallelDownloadSessions = 4;
public static Dictionary TextStrings = new Dictionary();
public static Mutex Mutex = null;
+ private static readonly string AssemblyTempPath = Path.GetDirectoryName(typeof(ArchiveFileInfo).Assembly.GetFile("sevenzipsharp.dll").Name);
public App() : base()
{
@@ -148,6 +150,7 @@ protected override void OnStartup(StartupEventArgs e)
LauncherLanguage = "en";
break;
}
+ SevenZipBase.SetLibraryPath(Path.Combine(AssemblyTempPath, "7zxa.dll"));
base.OnStartup(e);
}
diff --git a/BetterHI3Launcher.csproj b/BetterHI3Launcher.csproj
index 000566b..de66dc0 100644
--- a/BetterHI3Launcher.csproj
+++ b/BetterHI3Launcher.csproj
@@ -176,6 +176,7 @@
Settings.settingsTrue
+ ResXFileCodeGeneratorResources.Designer.cs
@@ -254,14 +255,14 @@
all
- 6.6.4
+ 6.7.0all2.5.2
- 7.0.1
+ 7.0.32.0.3
@@ -269,8 +270,8 @@
13.0.3
-
- 0.33.0
+
+ 1.6.1.237.0.2
@@ -315,7 +316,7 @@
1.1.1
- 2.1.1
+ 2.2.0
diff --git a/Costura64/7zxa.dll b/Costura64/7zxa.dll
new file mode 100644
index 0000000..979af37
Binary files /dev/null and b/Costura64/7zxa.dll differ
diff --git a/DialogWindow.xaml b/DialogWindow.xaml
index 70925ce..9a44b95 100644
--- a/DialogWindow.xaml
+++ b/DialogWindow.xaml
@@ -164,7 +164,7 @@
-
+
diff --git a/FodyWeavers.xml b/FodyWeavers.xml
index 5029e70..db4c839 100644
--- a/FodyWeavers.xml
+++ b/FodyWeavers.xml
@@ -1,3 +1,3 @@
-
+
\ No newline at end of file
diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
index 9274e84..38f769f 100644
--- a/MainWindow.xaml.cs
+++ b/MainWindow.xaml.cs
@@ -1,7 +1,6 @@
-using Microsoft.Win32;
-using SharpCompress.Archives;
-using SharpCompress.Common;
-using SharpCompress.Readers;
+using Hi3Helper.Http;
+using Microsoft.Win32;
+using SevenZip;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -21,7 +20,6 @@
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Shell;
-using Hi3Helper.Http;
namespace BetterHI3Launcher
{
@@ -795,13 +793,9 @@ await Task.Run(() =>
Log("success!", false);
Log("Performing update...");
File.Move(Path.Combine(App.LauncherRootPath, exe_name), Path.Combine(App.LauncherRootPath, old_exe_name));
- using(var archive = ArchiveFactory.Open(App.LauncherArchivePath))
+ using(var archive = new SevenZipExtractor(App.LauncherArchivePath))
{
- var reader = archive.ExtractAllEntries();
- while(reader.MoveToNextEntry())
- {
- reader.WriteEntryToDirectory(App.LauncherRootPath, new ExtractionOptions(){ExtractFullPath = true, Overwrite = true, PreserveFileTime = true});
- }
+ archive.ExtractArchive(App.LauncherRootPath);
}
Log("success!", false);
Dispatcher.Invoke(() => {BpUtility.RestartApp();});
@@ -1017,7 +1011,7 @@ private async void LaunchButton_Click(object sender, RoutedEventArgs e)
{
try
{
- var dialog = new DialogWindow(App.TextStrings["msgbox_install_title"], $"{App.TextStrings["msgbox_install_1_msg"]}\n{string.Format(App.TextStrings["msgbox_install_2_msg"], BpUtility.ToBytesCount((long)miHoYoVersionInfo.size))}\n{string.Format(App.TextStrings["msgbox_install_3_msg"], BpUtility.ToBytesCount((long)miHoYoVersionInfo.game.latest.size))}", DialogWindow.DialogType.Install);
+ var dialog = new DialogWindow(App.TextStrings["msgbox_install_title"], App.TextStrings["msgbox_install_1_msg"], DialogWindow.DialogType.Install);
dialog.InstallPathTextBox.Text = Path.Combine(Environment.ExpandEnvironmentVariables("%ProgramW6432%"), GameFullName);
if(dialog.ShowDialog() == false)
{
@@ -1049,13 +1043,23 @@ private async void LaunchButton_Click(object sender, RoutedEventArgs e)
}
}
+ var game_install_drive = DriveInfo.GetDrives().Where(x => x.Name == Path.GetPathRoot(GameInstallPath) && x.IsReady).FirstOrDefault();
+ if(game_install_drive == null || game_install_drive.DriveType == DriveType.CDRom)
+ {
+ new DialogWindow(App.TextStrings["msgbox_install_error_title"], App.TextStrings["msgbox_install_wrong_drive_type_msg"]).ShowDialog();
+ continue;
+ }
+
try
{
- path = GameInstallPath;
if(!Directory.Exists(GameInstallPath))
{
Directory.CreateDirectory(GameInstallPath);
}
+ if(new DirectoryInfo(GameInstallPath).Parent == null)
+ {
+ throw new Exception("Installation directory cannot be drive root");
+ }
}
catch(Exception ex)
{
@@ -1063,18 +1067,16 @@ private async void LaunchButton_Click(object sender, RoutedEventArgs e)
continue;
}
- if(new DialogWindow(App.TextStrings["msgbox_install_title"], string.Format(App.TextStrings["msgbox_install_4_msg"], GameInstallPath), DialogWindow.DialogType.Question).ShowDialog() == false)
+ long free_space_recommended = (long)miHoYoVersionInfo.size + (long)miHoYoVersionInfo.game.latest.size;
+ string install_message = $"{string.Format(App.TextStrings["msgbox_install_2_msg"], BpUtility.ToBytesCount((long)miHoYoVersionInfo.size))}" +
+ $"\n{string.Format(App.TextStrings["msgbox_install_3_msg"], BpUtility.ToBytesCount(free_space_recommended), BpUtility.ToBytesCount(game_install_drive.TotalFreeSpace))}" +
+ $"\n{string.Format(App.TextStrings["msgbox_install_4_msg"], GameInstallPath)}";
+ if(new DialogWindow(App.TextStrings["msgbox_install_title"], install_message, DialogWindow.DialogType.Question).ShowDialog() == false)
{
try{Directory.Delete(GameInstallPath);}catch{}
continue;
}
- var game_install_drive = DriveInfo.GetDrives().Where(x => x.Name == Path.GetPathRoot(GameInstallPath) && x.IsReady).FirstOrDefault();
- if(game_install_drive == null || game_install_drive.DriveType == DriveType.CDRom)
- {
- new DialogWindow(App.TextStrings["msgbox_install_error_title"], App.TextStrings["msgbox_install_wrong_drive_type_msg"]).ShowDialog();
- continue;
- }
- if(game_install_drive.TotalFreeSpace < (long)miHoYoVersionInfo.game.latest.size)
+ if(game_install_drive.TotalFreeSpace < free_space_recommended)
{
if(new DialogWindow(App.TextStrings["msgbox_install_title"], App.TextStrings["msgbox_install_little_space_msg"], DialogWindow.DialogType.Question).ShowDialog() == false)
{
@@ -1101,6 +1103,15 @@ private async void LaunchButton_Click(object sender, RoutedEventArgs e)
}
else if(Status == LauncherStatus.UpdateAvailable)
{
+ if(!File.Exists(GameExePath))
+ {
+ if(new DialogWindow(App.TextStrings["msgbox_no_game_exe_title"], App.TextStrings["msgbox_no_game_exe_msg"], DialogWindow.DialogType.Question).ShowDialog() == true)
+ {
+ ResetVersionInfo();
+ GameUpdateCheck();
+ }
+ return;
+ }
var game_install_drive = DriveInfo.GetDrives().Where(x => x.Name == Path.GetPathRoot(GameInstallPath) && x.IsReady).FirstOrDefault();
if(game_install_drive.TotalFreeSpace < (long)miHoYoVersionInfo.game.latest.size)
{
@@ -1243,11 +1254,14 @@ private async void PreloadButton_Click(object sender, RoutedEventArgs e)
}
if(Directory.GetFiles(GameInstallPath, $"{title}_tmp.*").Length == 0)
{
- if(new DialogWindow(App.TextStrings["label_pre_install"], $"{App.TextStrings["msgbox_pre_install_msg"]}\n{string.Format(App.TextStrings["msgbox_install_2_msg"], BpUtility.ToBytesCount(size))}", DialogWindow.DialogType.Question).ShowDialog() == false)
+ var game_install_drive = DriveInfo.GetDrives().Where(x => x.Name == Path.GetPathRoot(GameInstallPath) && x.IsReady).FirstOrDefault();
+ string pre_install_message = $"{App.TextStrings["msgbox_pre_install_msg"]}" +
+ $"\n{string.Format(App.TextStrings["msgbox_install_2_msg"], BpUtility.ToBytesCount(size))}" +
+ $"\n{string.Format(App.TextStrings["msgbox_install_3_msg"], BpUtility.ToBytesCount((long)miHoYoVersionInfo.game.latest.size), BpUtility.ToBytesCount(game_install_drive.TotalFreeSpace))}";
+ if(new DialogWindow(App.TextStrings["label_pre_install"], pre_install_message, DialogWindow.DialogType.Question).ShowDialog() == false)
{
return;
}
- var game_install_drive = DriveInfo.GetDrives().Where(x => x.Name == Path.GetPathRoot(GameInstallPath) && x.IsReady).FirstOrDefault();
if(game_install_drive.TotalFreeSpace < (long)miHoYoVersionInfo.pre_download_game.latest.size)
{
if(new DialogWindow(App.TextStrings["msgbox_install_title"], App.TextStrings["msgbox_install_little_space_msg"], DialogWindow.DialogType.Question).ShowDialog() == false)
diff --git a/Modules/GameCache.cs b/Modules/GameCache.cs
index 547e396..e5dad7e 100644
--- a/Modules/GameCache.cs
+++ b/Modules/GameCache.cs
@@ -1,12 +1,12 @@
using AssetsTools.NET.Extra;
using Hi3Helper.EncTool;
using Newtonsoft.Json;
-using SharpCompress.Common;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
+using System.Security.Cryptography;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Shell;
@@ -97,7 +97,7 @@ private string CalculateCRC(string path, string hash_salt)
byte[] salt = new mhyEncTool(hash_salt, OnlineVersionInfo.game_info.mirror.mihoyo.master_key.ToString()).GetSalt();
using(FileStream stream = new FileStream(path, FileMode.Open))
{
- byte[] hash = new System.Security.Cryptography.HMACSHA1(salt).ComputeHash(stream);
+ byte[] hash = new HMACSHA1(salt).ComputeHash(stream);
return BitConverter.ToString(hash).Replace("-", string.Empty);
}
}
diff --git a/Modules/GameUpdate.cs b/Modules/GameUpdate.cs
index ef08344..dbc39cb 100644
--- a/Modules/GameUpdate.cs
+++ b/Modules/GameUpdate.cs
@@ -3,9 +3,7 @@
using IniParser.Model;
using Microsoft.Win32;
using Newtonsoft.Json;
-using SharpCompress.Archives;
-using SharpCompress.Common;
-using SharpCompress.Readers;
+using SevenZip;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -13,6 +11,7 @@
using System.IO;
using System.Linq;
using System.Net;
+using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@@ -624,58 +623,44 @@ await Task.Run(() =>
{
return;
}
- var skipped_files = new List();
- using(var archive = ArchiveFactory.Open(GameArchivePath))
+ uint skipped_files = 0;
+ using(var archive = new SevenZipExtractor(GameArchivePath))
{
- int unpacked_files = 0;
- int file_count = 0;
+ uint unpacked_count = 0;
+ uint total_count = archive.FilesCount;
Log("Unpacking game archive...");
Status = LauncherStatus.Unpacking;
- foreach(var entry in archive.Entries)
+ archive.FileExtractionFinished += (sender, args) =>
{
- if(!entry.IsDirectory)
+ double progress = (unpacked_count + 1f) / total_count;
+ unpacked_count++;
+ Dispatcher.Invoke(() =>
{
- file_count++;
- }
+ DownloadProgressText.Text = string.Format(App.TextStrings["progresstext_unpacking_2"], unpacked_count, total_count, $"{progress * 100:0.00}");
+ DownloadProgressBar.Value = progress;
+ TaskbarItemInfo.ProgressValue = progress;
+ });
+ };
+ try
+ {
+ archive.ExtractArchive(GameInstallPath);
}
- var reader = archive.ExtractAllEntries();
- while(reader.MoveToNextEntry())
+ catch(IOException)
{
- try
- {
- Dispatcher.Invoke(() =>
- {
- var progress = (unpacked_files + 1f) / file_count;
- DownloadProgressText.Text = string.Format(App.TextStrings["progresstext_unpacking_2"], unpacked_files + 1, file_count, Math.Round(progress * 100, 2));
- DownloadProgressBar.Value = progress;
- TaskbarItemInfo.ProgressValue = progress;
- });
- reader.WriteEntryToDirectory(GameInstallPath, new ExtractionOptions(){ExtractFullPath = true, Overwrite = true, PreserveFileTime = true});
- if(!reader.Entry.IsDirectory)
- {
- unpacked_files++;
- }
- }
- catch(IOException)
- {
- throw;
- }
- catch(Exception ex)
- {
- if(!reader.Entry.IsDirectory)
- {
- skipped_files.Add(reader.Entry.ToString());
- file_count--;
- Log($"Failed to unpack {reader.Entry}: {ex.Message}", true, 1);
- }
- }
+ throw;
+ }
+ catch(Exception ex)
+ {
+ Log($"Failed to unpack file №{unpacked_count + 1}: {ex.Message}", true, 1);
+ skipped_files++;
+ total_count--;
}
}
- if(skipped_files.Count > 0)
+ if(skipped_files > 0)
{
DeleteFile(GameArchivePath);
- throw new ArchiveException("Game archive is corrupt");
+ throw new SevenZipArchiveException("Game archive is corrupted, please download again");
}
Log("success!", false);
DeleteFile(GameArchivePath);
diff --git a/Modules/LauncherUpdate.cs b/Modules/LauncherUpdate.cs
index df2ccb6..142b62d 100644
--- a/Modules/LauncherUpdate.cs
+++ b/Modules/LauncherUpdate.cs
@@ -1,7 +1,7 @@
using Microsoft.Win32;
-using SharpCompress.Common;
using System;
using System.IO;
+using System.Security.Cryptography;
using System.Threading;
using System.Windows;
using System.Windows.Shell;
diff --git a/TextStrings_en.cs b/TextStrings_en.cs
index 6a368c7..760caff 100644
--- a/TextStrings_en.cs
+++ b/TextStrings_en.cs
@@ -56,7 +56,7 @@ public static void TextStrings_English()
TextStrings.Add("changelogbox_1_msg", "Better HI3 Launcher has just become even better. Here's what happened:");
TextStrings.Add("changelogbox_2_msg", "Loading changelog...");
TextStrings.Add("changelogbox_3_msg", "Failed to load the changelog.");
- TextStrings.Add("aboutbox_msg", "Well it is much more advanced, isn't it? :^)\nThis project was made with hope for many captains to have a better experience with the game.\nIt is not affiliated with miHoYo and is completely open source.\nAny feedback is greatly appreciated.\nSpecial thanks to these GitHub contributors:\nSinsOfSeven - Custom resolution contribution\nProxy-E23 - Spanish language translation\nSpookyKisuy - Portuguese (Brazil) language translation\nbulawin1, Vrontis - German language translation\nKorewaLidesu - Vietnamese language translation\nSm1leAway - Serbian language translation\nVoRTeXStarz - Thai language translation\nTrilip - French language translation\nfabio-silva-pt - Portuguese (Portugal) language translation\nneon-nyan - Indonesian language translation, parallel download feature\nRinnosuke93 - Italian language translation\nMartinial - Czech language translation\nKLXLjun - Chinese (Simplified) translation");
+ TextStrings.Add("aboutbox_msg", "Well it is much more advanced, isn't it? :^)\nThis project was made with hope for many captains to have a better experience with the game.\nIt is not affiliated with HoYoverse and is completely open source.\nAny feedback is greatly appreciated.\nSpecial thanks to these GitHub contributors:\nSinsOfSeven - Custom resolution contribution\nProxy-E23 - Spanish language translation\nSpookyKisuy - Portuguese (Brazil) language translation\nbulawin1, Vrontis - German language translation\nKorewaLidesu - Vietnamese language translation\nSm1leAway - Serbian language translation\nVoRTeXStarz - Thai language translation\nTrilip - French language translation\nfabio-silva-pt - Portuguese (Portugal) language translation\nneon-nyan - Indonesian language translation, parallel download feature\nRinnosuke93 - Italian language translation\nMartinial - Czech language translation\nKLXLjun - Chinese (Simplified) translation");
TextStrings.Add("announcementbox_do_not_show", "Do not show me this next time");
TextStrings.Add("contextmenu_open_screenshots_dir", "Open screenshots directory");
TextStrings.Add("contextmenu_download_cache", "Download cache");
@@ -141,7 +141,7 @@ public static void TextStrings_English()
TextStrings.Add("msgbox_game_download_error_msg", "An error occurred while downloading game files.\nFor more information take a look at the log.");
TextStrings.Add("msgbox_game_download_error_title", "Error downloading game files");
TextStrings.Add("msgbox_game_download_mirror_error_msg", "An error occurred while downloading from the mirror.\nFor more information take a look at the log.");
- TextStrings.Add("msgbox_game_download_mirror_old_msg", "It seems like the game version on miHoYo servers is newer than the one on the mirror.\nThere is no reason to download an outdated version, ask the mirror maintainer to upload a new version.");
+ TextStrings.Add("msgbox_game_download_mirror_old_msg", "It seems like the game version on HoYoverse servers is newer than the one on the mirror.\nThere is no reason to download an outdated version, ask the mirror maintainer to upload a new version.");
TextStrings.Add("msgbox_game_download_paused_msg", "The game is not downloaded entirely yet. Changing server or mirror will reset the download progress.\nContinue?");
TextStrings.Add("msgbox_generic_error_msg", "An error occurred.\nFor more information take a look at the log.");
TextStrings.Add("msgbox_generic_error_title", "Error");
@@ -154,14 +154,14 @@ public static void TextStrings_English()
TextStrings.Add("msgbox_install_little_space_msg", "There is potentially not enough free space on selected device, it is recommended to free up some space or installation may result in failure.\nContinue?");
TextStrings.Add("msgbox_install_1_msg", "Select where would you like to install the game.");
TextStrings.Add("msgbox_install_2_msg", "Download size: {0}.");
- TextStrings.Add("msgbox_install_3_msg", "Installation size: {0}.");
+ TextStrings.Add("msgbox_install_3_msg", "Free space recommended: {0}/{1}.");
TextStrings.Add("msgbox_install_4_msg", "The game is going to be installed to:\n{0}\nContinue?");
TextStrings.Add("msgbox_install_title", "Install");
TextStrings.Add("msgbox_install_wrong_drive_type_msg", "Cannot install on selected device.");
TextStrings.Add("msgbox_language_msg", "Language is going to be changed to {0} and launcher will be restarted.\nContinue?");
TextStrings.Add("msgbox_launcher_download_error_msg", "An error occurred while downloading the launcher.\nFor more information take a look at the log.");
TextStrings.Add("msgbox_mirror_error_msg", "There is an error with the mirror. Ask the mirror maintainer to get to the bottom of this.\nMessage: {0}");
- TextStrings.Add("msgbox_mirror_info_msg", "Use this mirror only if you cannot download the game via official miHoYo servers.\nPlease note that it is updated manually.\nContinue?");
+ TextStrings.Add("msgbox_mirror_info_msg", "Use this mirror only if you cannot download the game via official HoYoverse servers.\nPlease note that it is updated manually.\nContinue?");
TextStrings.Add("msgbox_move_1_msg", "Select where would you like to move the game.");
TextStrings.Add("msgbox_move_2_msg", "The game is going to be moved to:\n{0}\nContinue?");
TextStrings.Add("msgbox_move_3_msg", "Cannot move the game inside the current game directory.");
@@ -179,7 +179,7 @@ public static void TextStrings_English()
TextStrings.Add("msgbox_no_game_exe_title", "No game executable");
TextStrings.Add("msgbox_no_screenshot_dir_msg", "There are no screenshots. Go take some!");
TextStrings.Add("msgbox_notice_title", "Notice");
- TextStrings.Add("msgbox_pre_install_msg", "You can still enter the game when pre-installing. Are you sure you want to download?\nYou can only download from the miHoYo servers.");
+ TextStrings.Add("msgbox_pre_install_msg", "You can still enter the game when pre-installing. Are you sure you want to download?\nYou can only download from HoYoverse servers.");
TextStrings.Add("msgbox_process_start_error_msg", "An error occurred while starting the process.\nFor more information take a look at the log.");
TextStrings.Add("msgbox_registry_empty_1_msg", "No value to be tweaked in registry exists.");
TextStrings.Add("msgbox_registry_empty_2_msg", "Have you run the game yet?");
diff --git a/Utility/Hi3Helper.Http b/Utility/Hi3Helper.Http
index ee0087b..87ca7ab 160000
--- a/Utility/Hi3Helper.Http
+++ b/Utility/Hi3Helper.Http
@@ -1 +1 @@
-Subproject commit ee0087b6f7db9545097cb59d29531fc2000c6bed
+Subproject commit 87ca7abcb2b03d594e4408443afdec9cc679e580