Skip to content

Commit da0e0c3

Browse files
authored
将最低所需 Java 版本提升至 17 (#14)
1 parent d057239 commit da0e0c3

4 files changed

Lines changed: 11 additions & 5 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
99

1010
set(CMAKE_WIN32_EXECUTABLE ON)
1111

12+
set(HMCL_EXPECTED_JAVA_MAJOR_VERSION 17)
13+
1214
add_compile_definitions(UNICODE _UNICODE)
1315
add_compile_definitions(WINVER=0x0601 _WIN32_WINNT=0x0601) # Windows 7
1416

HMCL/config.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
#pragma once
22

33
#define HMCL_LAUNCHER_VERSION L"@PROJECT_VERSION@"
4+
#define HMCL_EXPECTED_JAVA_MAJOR_VERSION @HMCL_EXPECTED_JAVA_MAJOR_VERSION@
5+
#define HMCL_EXPECTED_JAVA_MAJOR_VERSION_STR "@HMCL_EXPECTED_JAVA_MAJOR_VERSION@"
6+

HMCL/i18n.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
#include "i18n.h"
44

5+
#include "config.h"
6+
57
HLI18N HLI18N::Instance() {
68
HLI18N i18n = {.errorSelfPath = L"Failed to get the exe path.",
79
.errorInvalidHMCLJavaHome =
810
L"The Java path specified by HMCL_JAVA_HOME is invalid. Please update it to a valid Java "
911
"installation path or remove this environment variable.",
1012
.errorJavaNotFound =
11-
L"HMCL requires Java 11 or later to run,\n"
13+
L"HMCL requires Java " HMCL_EXPECTED_JAVA_MAJOR_VERSION_STR " or later to run,\n"
1214
L"Click 'OK' to start downloading java.\n"
1315
L"Please restart HMCL after installing Java."};
1416

@@ -17,7 +19,7 @@ HLI18N HLI18N::Instance() {
1719
i18n.errorSelfPath = L"获取程序路径失败。";
1820
i18n.errorInvalidHMCLJavaHome = L"HMCL_JAVA_HOME 所指向的 Java 路径无效,请更新或删除该变量。\n";
1921
i18n.errorJavaNotFound =
20-
L"HMCL 需要 Java 11 或更高版本才能运行,点击“确定”开始下载 Java。\n"
22+
L"HMCL 需要 Java " HMCL_EXPECTED_JAVA_MAJOR_VERSION_STR " 或更高版本才能运行,点击“确定”开始下载 Java。\n"
2123
L"请在安装 Java 完成后重新启动 HMCL。";
2224
}
2325
return i18n;

HMCL/java.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
#include <unordered_set>
99
#include <vector>
1010

11+
#include "config.h"
1112
#include "path.h"
1213

13-
constexpr std::uint16_t HL_EXPECTED_JAVA_MAJOR_VERSION = 11;
14-
1514
struct HLJavaVersion {
1615
static HLJavaVersion INVALID;
1716

@@ -26,7 +25,7 @@ struct HLJavaVersion {
2625
std::strong_ordering operator<=>(const HLJavaVersion &other) const = default;
2726

2827
[[nodiscard]] bool IsAcceptable() const {
29-
return major >= HL_EXPECTED_JAVA_MAJOR_VERSION;
28+
return major >= HMCL_EXPECTED_JAVA_MAJOR_VERSION;
3029
}
3130

3231
[[nodiscard]] std::wstring ToWString() const {

0 commit comments

Comments
 (0)