From 7a3289b1d20bcdda746d0f6c283a435a45c9f0c6 Mon Sep 17 00:00:00 2001 From: Cyano Hao Date: Sat, 30 Mar 2024 00:00:09 +0800 Subject: [PATCH] add compact os integration (#343) --- platform/windows/installer-scripts/lang.nsh | 6 ++++++ platform/windows/installer-scripts/redpanda.nsi | 8 ++++++++ platform/windows/installer-scripts/utils.nsh | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/platform/windows/installer-scripts/lang.nsh b/platform/windows/installer-scripts/lang.nsh index 16d2fb1c..d571fe69 100644 --- a/platform/windows/installer-scripts/lang.nsh +++ b/platform/windows/installer-scripts/lang.nsh @@ -7,9 +7,11 @@ LangString MessageSectionMinGW64 1033 "The ${MINGW64_COMPILER_NAME} compiler and LangString MessageSectionLangs 1033 "The Red Panda C++ interface translated to different languages (other than English which is built-in)" LangString MessageSectionAssocs 1033 "Use Red Panda C++ as the default application for opening these types of files" LangString MessageSectionShortcuts 1033 "Create shortcuts to Red Panda C++ in various folders" +LangString MessageSectionCompress 1033 "Compress the Red Panda C++ installation directory (requires Windows 10 or later)" LangString MessageSectionConfig 1033 "Remove all leftover configuration files from previous installs" LangString MessageUninstallText 1033 "This program will uninstall Red Panda C++, continue?" LangString MessageUninstallExisting 1033 " Red Panda C++ is already installed. $\n$\nClick OK to remove the previous version or Cancel to cancel the installation." +LangString MessageCompressing 1033 "Compressing the Red Panda C++ installation directory..." LangString MessageRemoveConfig 1033 "Do you want to remove all the remaining configuration files?" LangString SectionMainName 1033 "Program files (required)" LangString SectionIconsName 1033 "Icon files" @@ -22,6 +24,7 @@ LangString SectionAssocExtNameEnd 1033 "files to Red Panda C++" LangString SectionShortcutsName 1033 "Shortcuts" LangString SectionMenuLaunchName 1033 "Create Start Menu shortcuts" LangString SectionDesktopLaunchName 1033 "Create Desktop shortcut" +LangString SectionCompressName 1033 "Compress installation directory" LangString SectionConfigName 1033 "Remove old configuration files" LangString ErrorArchMismatch 1033 "Architecture mismatch. This package is for ${ARCH}, but the operating system is $osArch." @@ -38,9 +41,11 @@ LangString MessageSectionMinGW64 2052 "${MINGW64_COMPILER_NAME} 编译器和相 LangString MessageSectionLangs 2052 "小熊猫C++翻译文件" LangString MessageSectionAssocs 2052 "使用小熊猫C++打开这些文件" LangString MessageSectionShortcuts 2052 "开始菜单和快捷方式" +LangString MessageSectionCompress 2052 "压缩小熊猫 C++ 安装目录(需要 Windows 10 或更高版本)" LangString MessageSectionConfig 2052 "删除之前安装遗留的所有配置文件" LangString MessageUninstallText 2052 "将要删除小熊猫C++, 是否继续?" LangString MessageUninstallExisting 2052 "本机上已经安装了旧版本小熊猫C++. $\n$\n点击'确定'以将其删除并继续,或者'取消'中止安装。" +LangString MessageCompressing 2052 "正在压缩小熊猫 C++ 安装目录..." LangString MessageRemoveConfig 2052 "你想要删除所有的配置文件吗?" LangString SectionMainName 2052 "程序文件 (必须)" LangString SectionIconsName 2052 "图标文件" @@ -53,6 +58,7 @@ LangString SectionAssocExtNameEnd 2052 "文件关联到小熊猫C++" LangString SectionShortcutsName 2052 "快捷方式" LangString SectionMenuLaunchName 2052 "创建开始菜单程序项" LangString SectionDesktopLaunchName 2052 "创建桌面快捷方式" +LangString SectionCompressName 2052 "压缩安装目录" LangString SectionConfigName 2052 "删除原有配置文件" LangString ErrorArchMismatch 2052 "架构不匹配。此软件包适用于 ${ARCH},但操作系统是 $osArch。" diff --git a/platform/windows/installer-scripts/redpanda.nsi b/platform/windows/installer-scripts/redpanda.nsi index a8c94876..3d7f5278 100644 --- a/platform/windows/installer-scripts/redpanda.nsi +++ b/platform/windows/installer-scripts/redpanda.nsi @@ -243,6 +243,11 @@ SectionEnd SubSectionEnd +Section "$(SectionCompressName)" SectionCompress + DetailPrint "$(MessageCompressing)" + ExecWait '$SYSDIR\compact.exe /C /S /F /EXE:XPRESS16K "$INSTDIR\*"' +SectionEnd + Section "$(SectionConfigName)" SectionConfig SectionIn 3 @@ -262,6 +267,7 @@ SectionEnd !endif !insertmacro MUI_DESCRIPTION_TEXT ${SectionShortcuts} "$(MessageSectionShortcuts)" !insertmacro MUI_DESCRIPTION_TEXT ${SectionAssocs} "$(MessageSectionAssocs)" +!insertmacro MUI_DESCRIPTION_TEXT ${SectionCompress} "$(MessageSectionCompress)" !insertmacro MUI_DESCRIPTION_TEXT ${SectionConfig} "$(MessageSectionConfig)" !insertmacro MUI_FUNCTION_DESCRIPTION_END @@ -288,6 +294,7 @@ FunctionEnd Function .onSelChange !insertmacro SectionAction_CheckMingw64 + !insertmacro SectionAction_CheckCompress FunctionEnd Function myGuiInit @@ -307,6 +314,7 @@ Function myGuiInit !endif !insertmacro SectionAction_CheckMingw64 + !insertmacro SectionAction_CheckCompress FunctionEnd Function un.onInit diff --git a/platform/windows/installer-scripts/utils.nsh b/platform/windows/installer-scripts/utils.nsh index dfab15ca..afdd1477 100644 --- a/platform/windows/installer-scripts/utils.nsh +++ b/platform/windows/installer-scripts/utils.nsh @@ -67,3 +67,10 @@ Var /GLOBAL sectionDepTemp ${EndIf} !endif !macroend + +!macro SectionAction_CheckCompress + ; compact os is available since windows 10 + ${IfNot} ${AtLeastBuild} 10240 + !insertmacro DisableSection ${SectionCompress} + ${EndIf} +!macroend