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..c4e82aa0 100644 --- a/platform/windows/installer-scripts/redpanda.nsi +++ b/platform/windows/installer-scripts/redpanda.nsi @@ -130,7 +130,7 @@ SectionEnd #################################################################### # File association -SubSection "$(SectionAssocsName)" SectionAssocs +SectionGroup "$(SectionAssocsName)" SectionAssocs Section "$(SectionAssocExtNameBegin) .dev $(SectionAssocExtNameEnd)" SectionIn 1 3 @@ -219,11 +219,11 @@ Section "$(SectionAssocExtNameBegin) .hpp $(SectionAssocExtNameEnd)" ${NotifyShell_AssocChanged} SectionEnd -SubSectionEnd +SectionGroupEnd #################################################################### # Shortcuts -SubSection "$(SectionShortcutsName)" SectionShortcuts +SectionGroup "$(SectionShortcutsName)" SectionShortcuts Section "$(SectionMenuLaunchName)" SectionMenuLaunch SectionIn 1 3 @@ -241,7 +241,12 @@ Section "$(SectionDesktopLaunchName)" SectionDesktopLaunch CreateShortCut "$DESKTOP\$(MessageAppName).lnk" "$INSTDIR\RedPandaIDE.exe" SectionEnd -SubSectionEnd +SectionGroupEnd + +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 @@ -320,77 +328,27 @@ Function un.onInit !endif FunctionEnd -;http://nsis.sourceforge.net/archive/viewpage.php?pageid=202 -;After changing file associations, you can call this macro to refresh the shell immediatly. -;It calls the shell32 function SHChangeNotify. This will force windows to reload your changes from the registry. -!define SHCNE_ASSOCCHANGED 0x08000000 -!define SHCNF_IDLIST 0 - -Function un.DeleteDirIfEmpty - FindFirst $R0 $R1 "$0\*.*" - strcmp $R1 "." 0 NoDelete - FindNext $R0 $R1 - strcmp $R1 ".." 0 NoDelete - ClearErrors - FindNext $R0 $R1 - IfErrors 0 NoDelete - FindClose $R0 - Sleep 1000 - RMDir "$0" - NoDelete: - FindClose $R0 -FunctionEnd - -Function GetParent - - Exch $R0 - Push $R1 - Push $R2 - Push $R3 - - StrCpy $R1 0 - StrLen $R2 $R0 - - loop: - IntOp $R1 $R1 + 1 - IntCmp $R1 $R2 get 0 get - StrCpy $R3 $R0 1 -$R1 - StrCmp $R3 "\" get - Goto loop - - get: - StrCpy $R0 $R0 -$R1 - - Pop $R3 - Pop $R2 - Pop $R1 - Exch $R0 - -FunctionEnd +Var /GLOBAL uninstallString +Var /GLOBAL installLocation Function UninstallExisting - ReadRegStr $R0 ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "UninstallString" - - StrCmp $R0 "" done - - Push $R0 - Call GetParent - Pop $R1 - + ReadRegStr $uninstallString ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "UninstallString" + ${If} $uninstallString != "" + GetFullPathName $installLocation "$uninstallString\.." ; remove '\uninstall.exe' MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \ - "$(MessageUninstallExisting)" \ - IDOK uninst + "$(MessageUninstallExisting)" \ + /SD IDNO \ + IDOK uninst Abort - - ;Run the uninstaller - uninst: - ClearErrors - HideWindow - ClearErrors - ExecWait '"$R0" _?=$R1' - BringToFront - - done: + uninst: + ClearErrors + HideWindow + ClearErrors + ExecWait '"$uninstallString" _?=$installLocation' + Delete "$uninstallString" + RMDir "$installLocation" + BringToFront + ${EndIf} FunctionEnd #################################################################### @@ -438,8 +396,7 @@ Section "Uninstall" RMDir /r "$INSTDIR\mingw32" RMDir /r "$INSTDIR\mingw64" - StrCpy $0 "$INSTDIR" - Call un.DeleteDirIfEmpty + RMDir "$INSTDIR" ; Remove registry keys DeleteRegKey ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" 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