mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2024-12-15 06:50:12 +08:00
Import error messages
This commit is contained in:
parent
20ddf60c48
commit
48785e93f0
@ -8,9 +8,9 @@ $chinese = [System.Globalization.CultureInfo]::CurrentCulture.Name -eq 'zh-CN'
|
|||||||
[Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
|
[Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
|
||||||
|
|
||||||
$result = if ($chinese) {
|
$result = if ($chinese) {
|
||||||
[System.Windows.Forms.MessageBox]::Show('HMCL 需要 Java 运行时环境才能正常运行,是否自动下载安装 Java?', 'HMCL', [System.Windows.Forms.MessageBoxButtons]::YesNo)
|
[System.Windows.Forms.MessageBox]::Show("HMCL 需要 Java 运行时环境才能正常运行,是否自动下载安装 Java?", '未能在这台电脑上找到 Java', [System.Windows.Forms.MessageBoxButtons]::YesNo)
|
||||||
} else {
|
} else {
|
||||||
[System.Windows.Forms.MessageBox]::Show('Running HMCL requires a Java runtime environment. Do you want to download and install Java automatically?', 'HMCL', [System.Windows.Forms.MessageBoxButtons]::YesNo)
|
[System.Windows.Forms.MessageBox]::Show("Running HMCL requires a Java runtime environment. `nDo you want to download and install Java automatically?", 'Java not found', [System.Windows.Forms.MessageBoxButtons]::YesNo)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($result -ne [System.Windows.Forms.DialogResult]::Yes) {
|
if ($result -ne [System.Windows.Forms.DialogResult]::Yes) {
|
||||||
@ -92,7 +92,18 @@ $form.Controls.Add($layout)
|
|||||||
[System.ComponentModel.AsyncCompletedEventHandler]$downloadFileCompletedEventHandler = {
|
[System.ComponentModel.AsyncCompletedEventHandler]$downloadFileCompletedEventHandler = {
|
||||||
param($sender, [System.ComponentModel.AsyncCompletedEventArgs]$CompletedEventArgs)
|
param($sender, [System.ComponentModel.AsyncCompletedEventArgs]$CompletedEventArgs)
|
||||||
if (!$form.IsDisposed) {
|
if (!$form.IsDisposed) {
|
||||||
$form.DialogResult = [System.Windows.Forms.DialogResult]::OK
|
if ($CompletedEventArgs.Cancelled) {
|
||||||
|
$form.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
|
||||||
|
} elseif ($CompletedEventArgs.Error -ne $null) {
|
||||||
|
if ($chinese) {
|
||||||
|
[System.Windows.Forms.MessageBox]::Show($CompletedEventArgs.Error.Message, '下载失败', [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Exclamation)
|
||||||
|
} else {
|
||||||
|
[System.Windows.Forms.MessageBox]::Show($CompletedEventArgs.Error.Message, 'Download failed', [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Exclamation)
|
||||||
|
}
|
||||||
|
$form.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
|
||||||
|
} else {
|
||||||
|
$form.DialogResult = [System.Windows.Forms.DialogResult]::OK
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define ERROR_PROMPT L"Java installation cannot be found in this computer, please download it from https://www.microsoft.com/openjdk \n" \
|
#define ERROR_PROMPT L"Java installation cannot be found in this computer,\n"\
|
||||||
L"未能在这台电脑上找到Java,请从 https://www.microsoft.com/openjdk 下载安装Java"
|
L"please download it from %s.\n"\
|
||||||
|
L"Click 'OK' to go to the download page."
|
||||||
|
|
||||||
|
#define ERROR_PROMPT_ZH L"未能在这台电脑上找到 Java,请从 %s 下载安装 Java。\n"\
|
||||||
|
L"点击“确定”立即前往下载页面。"
|
@ -67,6 +67,15 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
|||||||
exeName = exeName.substr(last_slash + 1);
|
exeName = exeName.substr(last_slash + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool useChinese;
|
||||||
|
{
|
||||||
|
LCID lcid = GetUserDefaultUILanguage();
|
||||||
|
WCHAR nameBuffer[LOCALE_NAME_MAX_LENGTH];
|
||||||
|
useChinese = (LCIDToLocaleName(lcid, nameBuffer, LOCALE_NAME_MAX_LENGTH, 0) != 0)
|
||||||
|
&& (lstrcmp(nameBuffer, L"zh-CN") == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
OSVERSIONINFOEX osvi;
|
OSVERSIONINFOEX osvi;
|
||||||
DWORDLONG dwlConditionMask = 0;
|
DWORDLONG dwlConditionMask = 0;
|
||||||
int op = VER_GREATER_EQUAL;
|
int op = VER_GREATER_EQUAL;
|
||||||
@ -191,7 +200,16 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
|||||||
}
|
}
|
||||||
|
|
||||||
error:
|
error:
|
||||||
MessageBox(NULL, ERROR_PROMPT, L"Error", MB_ICONERROR | MB_OK);
|
LPCWSTR downloadLink = isWin7OrLater && (isX64 || isARM64) ? L"https://www.microsoft.com/openjdk" : L"https://java.com";
|
||||||
ShellExecute(0, 0, L"https://www.microsoft.com/openjdk", 0, 0, SW_SHOW);
|
|
||||||
|
WCHAR errorPrompt[180];
|
||||||
|
{
|
||||||
|
LPCWSTR errorPromptFormat = useChinese ? ERROR_PROMPT_ZH : ERROR_PROMPT;
|
||||||
|
wsprintf(errorPrompt, errorPromptFormat, downloadLink);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IDOK == MessageBox(NULL, errorPrompt, L"Error", MB_ICONERROR | MB_OKCANCEL)) {
|
||||||
|
ShellExecute(0, 0, downloadLink, 0, 0, SW_SHOW);
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user