diff --git a/source-code/source/plugins/Launcher/Resources.restext b/source-code/source/plugins/Launcher/Resources.restext index 7e85d54..af16108 100644 --- a/source-code/source/plugins/Launcher/Resources.restext +++ b/source-code/source/plugins/Launcher/Resources.restext @@ -148,6 +148,8 @@ USE_DIVAHOOK_BAT_NAME=Use divahook.bat USE_DIVAHOOK_BAT_HINT=Launches divahook.bat intead of diva.exe. DARK_LAUNCHER_NAME=Dark Launcher DARK_LAUNCHER_HINT=Sets the dark colour scheme in the launcher. +LAUNCHER_LANGUAGE_NAME=Launcher Language: +LAUNCHER_LANGUAGE_HINT=Sets the Language of the launcher. NO_GPU_DIALOG_NAME=Disable GPU Warning NO_GPU_DIALOG_HINT=Disables the warning dialog for unsupported GPUs. diff --git a/source-code/source/plugins/Launcher/Resources.zh-Hans.restext b/source-code/source/plugins/Launcher/Resources.zh-Hans.restext index 5d514b5..4467cc3 100644 --- a/source-code/source/plugins/Launcher/Resources.zh-Hans.restext +++ b/source-code/source/plugins/Launcher/Resources.zh-Hans.restext @@ -166,6 +166,8 @@ USE_DIVAHOOK_BAT_NAME=使用 divahook.bat USE_DIVAHOOK_BAT_HINT=启动 divahook.bat 而非 diva.exe DARK_LAUNCHER_NAME=暗黑模式 DARK_LAUNCHER_HINT=启用启动器自带的暗黑主题 +LAUNCHER_LANGUAGE_NAME=启动器语言 +LAUNCHER_LANGUAGE_HINT=设置启动器语言。 NO_GPU_DIALOG_NAME=停用 GPU 警告信息 NO_GPU_DIALOG_HINT=停用对于不支持的 GPU 的警告信息 diff --git a/source-code/source/plugins/Launcher/framework.h b/source-code/source/plugins/Launcher/framework.h index 5dd2ecc..a7862fa 100644 --- a/source-code/source/plugins/Launcher/framework.h +++ b/source-code/source/plugins/Launcher/framework.h @@ -65,6 +65,9 @@ LPCWSTR KEYCONFIG_SECTION = L"keyconfig"; int nSkipLauncher = GetPrivateProfileIntW(LAUNCHER_SECTION, L"skip", FALSE, CONFIG_FILE); int nNoGPUDialog = GetPrivateProfileIntW(LAUNCHER_SECTION, L"no_gpu_dialog", FALSE, CONFIG_FILE); +int nLanguage = GetPrivateProfileIntW(LAUNCHER_SECTION, L"launcher_language", FALSE, CONFIG_FILE); + +std::vector languages = std::vector({ L"Automatic", L"en", L"zh-Hans" }); void SetBackCol(Control^ elem, System::Drawing::Color color, System::Windows::Forms::FlatStyle cbxStyle) { @@ -281,6 +284,7 @@ ConfigOptionBase* optionsArray[] = { new OptionMetaSpacer(8), new BooleanOption(L"dark_launcher", LAUNCHER_SECTION, CONFIG_FILE, L"DARK_LAUNCHER_NAME", L"DARK_LAUNCHER_HINT", false, false), + new DropdownOption(L"launcher_language",LAUNCHER_SECTION,CONFIG_FILE, L"LAUNCHER_LANGUAGE_NAME",L"LAUNCHER_LANGUAGE_HINT", 0, languages), //new BooleanOption(L"acrylic_blur", LAUNCHER_SECTION, CONFIG_FILE, L"ACRYLIC_BLUR_NAME", L"ACRYLIC_BLUR_HINT", false, false), new BooleanOption(L"no_gpu_dialog", LAUNCHER_SECTION, CONFIG_FILE, L"NO_GPU_DIALOG_NAME", L"NO_GPU_DIALOG_HINT", false, false), }; diff --git a/source-code/source/plugins/Launcher/ui.h b/source-code/source/plugins/Launcher/ui.h index 1b708c6..aaed38e 100644 --- a/source-code/source/plugins/Launcher/ui.h +++ b/source-code/source/plugins/Launcher/ui.h @@ -21,6 +21,8 @@ namespace Launcher { using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; + using namespace System::Threading; + using namespace System::Globalization; using namespace msclr::interop; HWND hWnd; @@ -34,13 +36,12 @@ namespace Launcher { public: ui(void) { + SetLanguage(); + InitializeComponent(); hWnd = (HWND)Control::Handle.ToPointer(); - this->ClientSize = Drawing::Size(444, 323); - TabPadding^ tabpad = gcnew TabPadding(tabControl); - // if components.ini has no section name, add one if (!IsLineInFile("[components]", COMPONENTS_FILE)) { @@ -59,7 +60,19 @@ namespace Launcher { PrependFile("[keyconfig]\n", KEYCONFIG_FILE); } + // trick Optimus into switching to the NVIDIA GPU + if (cuInit != NULL) cuInit(0); + int argc = 1; + char* argv[1] = { (char*)"" }; + + glutInit(&argc, argv); + + addOptions(); + updateStyle(); + } + + void addOptions() { this->panel_ScreenRes->SuspendLayout(); // populate options (patches) from array in framework @@ -202,21 +215,11 @@ namespace Launcher { this->panel_Custom->PerformLayout(); - // trick Optimus into switching to the NVIDIA GPU - if (cuInit != NULL) cuInit(0); - - int argc = 1; - char* argv[1] = { (char*)"" }; - - updateLagCompMsec(); - updateStyle(); - scanModpacks(); - glutInit(&argc, argv); int window = glutCreateWindow("glut"); // a context must be created to use glGetString glutHideWindow(); @@ -471,6 +474,26 @@ namespace Launcher { tabPage_Modpacks->Enabled = false; } + void updateLanguage() { + int language = GetPrivateProfileIntW(LAUNCHER_SECTION, L"launcher_language", FALSE, CONFIG_FILE); + if (nLanguage == language) + return; + nLanguage = language; + + SetLanguage(); + + this->Controls->Clear(); + this->InitializeComponent(); + this->addOptions(); + } + + void SetLanguage() { + if (nLanguage == 0) { + Thread::CurrentThread->CurrentUICulture = gcnew CultureInfo(GetUserDefaultLCID()); + } else if (nLanguage <= languages.size() - 1) { + Thread::CurrentThread->CurrentUICulture = CultureInfo::CreateSpecificCulture(gcnew String(languages[nLanguage])); + } + } private: @@ -1340,9 +1363,8 @@ private: System::Void button_github_Click(System::Object^ sender, System::EventA } private: System::Void button_Apply_Click(System::Object^ sender, System::EventArgs^ e) { SaveSettings(); + updateLanguage(); updateStyle(); - //ShowWindow(hWnd, SW_HIDE); - //ShowWindow(hWnd, SW_SHOW); } private: System::Void Ui_KeyDown(System::Object^ sender, System::Windows::Forms::KeyEventArgs^ e) { if (e->KeyCode == Keys::Escape) this->Close();