放弃 HMCLauncher 与 Windows XP 的兼容性 (#2644)

* 放弃 HMCLauncher 与 Windows XP 的兼容性

* update

* Delete unused code

* Disable automatic updates on Windows XP/Vista
This commit is contained in:
Glavo
2024-01-21 00:06:25 +08:00
committed by GitHub
parent 931808d808
commit 89b5b64943
8 changed files with 55 additions and 36 deletions

View File

@@ -34,6 +34,7 @@ import org.jackhuang.hmcl.util.TaskCancellationAction;
import org.jackhuang.hmcl.util.io.FileUtils; import org.jackhuang.hmcl.util.io.FileUtils;
import org.jackhuang.hmcl.util.io.JarUtils; import org.jackhuang.hmcl.util.io.JarUtils;
import org.jackhuang.hmcl.util.platform.JavaVersion; import org.jackhuang.hmcl.util.platform.JavaVersion;
import org.jackhuang.hmcl.util.platform.OperatingSystem;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
@@ -51,7 +52,8 @@ import static org.jackhuang.hmcl.util.Logging.LOG;
import static org.jackhuang.hmcl.util.i18n.I18n.i18n; import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
public final class UpdateHandler { public final class UpdateHandler {
private UpdateHandler() {} private UpdateHandler() {
}
/** /**
* @return whether to exit * @return whether to exit
@@ -71,6 +73,11 @@ public final class UpdateHandler {
} }
if (args.length == 2 && args[0].equals("--apply-to")) { if (args.length == 2 && args[0].equals("--apply-to")) {
if (OperatingSystem.CURRENT_OS == OperatingSystem.WINDOWS && !OperatingSystem.isWindows7OrLater()) {
SwingUtils.showErrorDialog(i18n("fatal.apply_update_need_win7", Metadata.PUBLISH_URL));
return true;
}
try { try {
applyUpdate(Paths.get(args[1])); applyUpdate(Paths.get(args[1]));
} catch (IOException e) { } catch (IOException e) {
@@ -91,6 +98,11 @@ public final class UpdateHandler {
public static void updateFrom(RemoteVersion version) { public static void updateFrom(RemoteVersion version) {
checkFxUserThread(); checkFxUserThread();
if (OperatingSystem.CURRENT_OS == OperatingSystem.WINDOWS && !OperatingSystem.isWindows7OrLater()) {
Controllers.dialog(i18n("fatal.apply_update_need_win7", Metadata.PUBLISH_URL), i18n("message.error"), MessageType.ERROR);
return;
}
Controllers.dialog(new UpgradeDialog(version, () -> { Controllers.dialog(new UpgradeDialog(version, () -> {
Path downloaded; Path downloaded;
try { try {

View File

@@ -379,6 +379,9 @@ fatal.apply_update_failure=We are sorry, but Hello Minecraft! Launcher is unable
\n\ \n\
You can update manually by downloading a newer version of the launcher from %s.\n\ You can update manually by downloading a newer version of the launcher from %s.\n\
If the problem persists, please consider reporting this to us. If the problem persists, please consider reporting this to us.
fatal.apply_update_need_win7=Hello Minecraft! Launcher cannot automatically update on Windows XP/Vista.\n\
\n\
You can update manually by downloading a newer version of the launcher from %s.
fatal.samba=If you launched HMCL from a Samba network drive, some features might not be working. Please try updating your Java version or copy and run the launcher in a local folder. fatal.samba=If you launched HMCL from a Samba network drive, some features might not be working. Please try updating your Java version or copy and run the launcher in a local folder.
fatal.illegal_char=Your user path contains an illegal character '\=', you will not be able to use authlib-injector or change the skin of your offline account. fatal.illegal_char=Your user path contains an illegal character '\=', you will not be able to use authlib-injector or change the skin of your offline account.
fatal.unsupported_platform=Minecraft is not yet fully supported for your platform, so you may experience missing functionality,\nor even be unable to launch the game.\n\ fatal.unsupported_platform=Minecraft is not yet fully supported for your platform, so you may experience missing functionality,\nor even be unable to launch the game.\n\

View File

@@ -365,6 +365,7 @@ fatal.config_loading_failure.unix=Hello Minecraft! Launcher 無法載入設定
fatal.mac_app_translocation=由於 macOS 的安全機制Hello Minecraft! Launcher 被系統隔離至臨時資料夾中。\n請將Hello Minecraft! Launcher 移動到其他資料夾後再嘗試啟動,否則你的設定和遊戲數據可能會在重啟後遺失。\n是否繼續啟動 fatal.mac_app_translocation=由於 macOS 的安全機制Hello Minecraft! Launcher 被系統隔離至臨時資料夾中。\n請將Hello Minecraft! Launcher 移動到其他資料夾後再嘗試啟動,否則你的設定和遊戲數據可能會在重啟後遺失。\n是否繼續啟動
fatal.migration_requires_manual_reboot=Hello Minecraft! Launcher 即將升級完成,請重新開啟 Hello Minecraft! Launcher。 fatal.migration_requires_manual_reboot=Hello Minecraft! Launcher 即將升級完成,請重新開啟 Hello Minecraft! Launcher。
fatal.apply_update_failure=我們很抱歉 Hello Minecraft! Launcher 無法自動完成升級程式,因為出現了一些問題。\n但你依然可以從 %s 處手動下載 Hello Minecraft! Launcher 來完成升級。\n你可以訪問 https://docs.hmcl.net/help.html 網頁進行迴響。 fatal.apply_update_failure=我們很抱歉 Hello Minecraft! Launcher 無法自動完成升級程式,因為出現了一些問題。\n但你依然可以從 %s 處手動下載 Hello Minecraft! Launcher 來完成升級。\n你可以訪問 https://docs.hmcl.net/help.html 網頁進行迴響。
fatal.apply_update_need_win7=Hello Minecraft! Launcher 無法在 Windows XP/Vista 上進行自動更新,請從 %s 處手動下載 Hello Minecraft! Launcher 來完成升級。
fatal.samba=如果您正在通過 Samba 共亯的資料夾中運行 Hello Minecraft! Launcher啟動器可能無法正常工作請嘗試更新您的 Java 或在本地資料夾內運行 HMCL。 fatal.samba=如果您正在通過 Samba 共亯的資料夾中運行 Hello Minecraft! Launcher啟動器可能無法正常工作請嘗試更新您的 Java 或在本地資料夾內運行 HMCL。
fatal.illegal_char=由於您的用戶資料夾路徑中存在非法字元‘=’,您將無法使用外置登入帳戶以及離線登入更換皮膚功能。 fatal.illegal_char=由於您的用戶資料夾路徑中存在非法字元‘=’,您將無法使用外置登入帳戶以及離線登入更換皮膚功能。
fatal.unsupported_platform=Minecraft 尚未你您的平臺提供完善支持,所以可能影響遊戲體驗或無法啟動遊戲。\n若無法啟動 Minecraft 1.17 及以上版本,可以嘗試在版本設定中打開“使用 OpenGL 軟渲染器”選項,使用 CPU 渲染以獲得更好的相容性。 fatal.unsupported_platform=Minecraft 尚未你您的平臺提供完善支持,所以可能影響遊戲體驗或無法啟動遊戲。\n若無法啟動 Minecraft 1.17 及以上版本,可以嘗試在版本設定中打開“使用 OpenGL 軟渲染器”選項,使用 CPU 渲染以獲得更好的相容性。

View File

@@ -367,6 +367,7 @@ fatal.config_loading_failure.unix=Hello Minecraft! Launcher 无法加载配置
fatal.mac_app_translocation=由于 macOS 的安全机制Hello Minecraft! Launcher 被系统隔离至临时文件夹中。\n请将 Hello Minecraft! Launcher 移动到其他文件夹后再尝试启动,否则你的设置和游戏数据可能会在重启后丢失。\n你可以访问 https://docs.hmcl.net/help.html 页面寻求帮助。\n是否继续启动 fatal.mac_app_translocation=由于 macOS 的安全机制Hello Minecraft! Launcher 被系统隔离至临时文件夹中。\n请将 Hello Minecraft! Launcher 移动到其他文件夹后再尝试启动,否则你的设置和游戏数据可能会在重启后丢失。\n你可以访问 https://docs.hmcl.net/help.html 页面寻求帮助。\n是否继续启动
fatal.migration_requires_manual_reboot=Hello Minecraft! Launcher 即将完成升级,请重新打开 Hello Minecraft! Launcher。\n如遇到问题你可以访问 https://docs.hmcl.net/help.html 页面寻求帮助。 fatal.migration_requires_manual_reboot=Hello Minecraft! Launcher 即将完成升级,请重新打开 Hello Minecraft! Launcher。\n如遇到问题你可以访问 https://docs.hmcl.net/help.html 页面寻求帮助。
fatal.apply_update_failure=我们很抱歉 Hello Minecraft! Launcher 无法自动完成升级,因为出现了一些问题。\n但你依可以从 %s 处手动下载 Hello Minecraft! Launcher 来完成升级\n你可以访问 https://docs.hmcl.net/help.html 网页进行反馈。 fatal.apply_update_failure=我们很抱歉 Hello Minecraft! Launcher 无法自动完成升级,因为出现了一些问题。\n但你依可以从 %s 处手动下载 Hello Minecraft! Launcher 来完成升级\n你可以访问 https://docs.hmcl.net/help.html 网页进行反馈。
fatal.apply_update_need_win7=Hello Minecraft! Launcher 无法在 Windows XP/Vista 上进行自动更新,请从 %s 处手动下载 Hello Minecraft! Launcher 来完成升级。
fatal.samba=如果你正在通过 Samba 共享的文件夹中运行 Hello Minecraft! Launcher启动器可能无法正常工作。请尝试更新你的 Java 或在本地文件夹内运行 Hello Minecraft! Launcher。\n你可以访问 https://docs.hmcl.net/help.html 页面寻求帮助。 fatal.samba=如果你正在通过 Samba 共享的文件夹中运行 Hello Minecraft! Launcher启动器可能无法正常工作。请尝试更新你的 Java 或在本地文件夹内运行 Hello Minecraft! Launcher。\n你可以访问 https://docs.hmcl.net/help.html 页面寻求帮助。
fatal.illegal_char=由于你的用户文件夹路径中存在非法字符‘=’,你将无法使用外置登录账户以及离线登录更换皮肤功能。\n你可以访问 https://docs.hmcl.net/help.html 页面寻求帮助。 fatal.illegal_char=由于你的用户文件夹路径中存在非法字符‘=’,你将无法使用外置登录账户以及离线登录更换皮肤功能。\n你可以访问 https://docs.hmcl.net/help.html 页面寻求帮助。
fatal.unsupported_platform=Minecraft 尚未为您的平台提供完善支持,所以可能影响游戏体验或无法启动游戏。\n若无法启动 Minecraft 1.17 及以上版本,可以尝试在版本设置中打开“使用 OpenGL 软渲染器”选项,使用 CPU 渲染以获得更好的兼容性。\n如遇到问题你可以点击右上角帮助按钮进行求助。 fatal.unsupported_platform=Minecraft 尚未为您的平台提供完善支持,所以可能影响游戏体验或无法启动游戏。\n若无法启动 Minecraft 1.17 及以上版本,可以尝试在版本设置中打开“使用 OpenGL 软渲染器”选项,使用 CPU 渲染以获得更好的兼容性。\n如遇到问题你可以点击右上角帮助按钮进行求助。

View File

@@ -227,6 +227,30 @@ public enum OperatingSystem {
return UNKNOWN; return UNKNOWN;
} }
public static boolean isWindows7OrLater() {
if (CURRENT_OS != WINDOWS) {
return false;
}
int major;
int dotIndex = SYSTEM_VERSION.indexOf('.');
try {
if (dotIndex < 0) {
major = Integer.parseInt(SYSTEM_VERSION);
} else {
major = Integer.parseInt(SYSTEM_VERSION.substring(0, dotIndex));
}
} catch (NumberFormatException ignored) {
return false;
}
// Windows XP: NT 5.1~5.2
// Windows Vista: NT 6.0
// Windows 7: NT 6.1
return major >= 6 && !SYSTEM_VERSION.startsWith("6.0");
}
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static Optional<PhysicalMemoryStatus> getPhysicalMemoryStatus() { public static Optional<PhysicalMemoryStatus> getPhysicalMemoryStatus() {
if (CURRENT_OS == LINUX) { if (CURRENT_OS == LINUX) {

View File

@@ -23,33 +23,33 @@
<ProjectGuid>{672B1019-E741-4C0D-A986-627E2ACE157B}</ProjectGuid> <ProjectGuid>{672B1019-E741-4C0D-A986-627E2ACE157B}</ProjectGuid>
<Keyword>Win32Proj</Keyword> <Keyword>Win32Proj</Keyword>
<RootNamespace>HMCL</RootNamespace> <RootNamespace>HMCL</RootNamespace>
<WindowsTargetPlatformVersion>10.0.18362.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>HMCLauncher</ProjectName> <ProjectName>HMCLauncher</ProjectName>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141_xp</PlatformToolset> <PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141_xp</PlatformToolset> <PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset> <PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141_xp</PlatformToolset> <PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>

View File

@@ -75,23 +75,6 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
bool useChinese = GetUserDefaultUILanguage() == 2052; // zh-CN bool useChinese = GetUserDefaultUILanguage() == 2052; // zh-CN
OSVERSIONINFOEX osvi;
DWORDLONG dwlConditionMask = 0;
int op = VER_GREATER_EQUAL;
// Initialize the OSVERSIONINFOEX structure.
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
osvi.dwMajorVersion = 6;
osvi.dwMinorVersion = 1;
// Initialize the condition mask.
VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, op);
VER_SET_CONDITION(dwlConditionMask, VER_MINORVERSION, op);
// Try downloading Java on Windows 7 or later
bool isWin7OrLater = VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION, dwlConditionMask);
SYSTEM_INFO systemInfo; SYSTEM_INFO systemInfo;
GetNativeSystemInfo(&systemInfo); GetNativeSystemInfo(&systemInfo);
// TODO: check whether the bundled JRE is valid. // TODO: check whether the bundled JRE is valid.
@@ -156,19 +139,14 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
FindJavaInDirAndLaunchJVM(hmclJavaDir, workdir, exeName, jvmOptions); FindJavaInDirAndLaunchJVM(hmclJavaDir, workdir, exeName, jvmOptions);
} }
error:
LPCWSTR downloadLink; LPCWSTR downloadLink;
if (isWin7OrLater) { if (isARM64) {
if (isARM64) { downloadLink = L"https://docs.hmcl.net/downloads/windows/arm64.html";
downloadLink = L"https://docs.hmcl.net/downloads/windows/arm64.html"; } if (isX64) {
} if (isX64) { downloadLink = L"https://docs.hmcl.net/downloads/windows/x86_64.html";
downloadLink = L"https://docs.hmcl.net/downloads/windows/x86_64.html";
} else {
downloadLink = L"https://docs.hmcl.net/downloads/windows/x86.html";
}
} else { } else {
downloadLink = L"https://docs.hmcl.net/downloads/java.html"; downloadLink = L"https://docs.hmcl.net/downloads/windows/x86.html";
} }
if (IDOK == MessageBox(NULL, useChinese ? ERROR_PROMPT_ZH : ERROR_PROMPT, useChinese ? ERROR_TITLE_ZH : ERROR_TITLE, MB_ICONWARNING | MB_OKCANCEL)) { if (IDOK == MessageBox(NULL, useChinese ? ERROR_PROMPT_ZH : ERROR_PROMPT, useChinese ? ERROR_TITLE_ZH : ERROR_TITLE, MB_ICONWARNING | MB_OKCANCEL)) {

View File

@@ -1,8 +1,8 @@
#pragma once #pragma once
// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。 // Windows 7
// 如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h并将 #define WINVER 0x0601
// 将 _WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。 #define _WIN32_WINNT 0x0601
#include <SDKDDKVer.h> #include <SDKDDKVer.h>