1;NSIS Modern User Interface 2;Welcome/Finish Page Example Script 3;Written by Joost Verburg 4 5;-------------------------------- 6;Include Modern UI 7 8 !include "MUI.nsh" 9 10;-------------------------------- 11;General 12 13 ;Name and file 14 Name "Brutal Chess" 15 OutFile "brutalchess.exe" 16 17 ;Default installation folder 18 InstallDir "$PROGRAMFILES\Brutal Chess" 19 20 ;Get installation folder from registry if available 21 InstallDirRegKey HKCU "Software\Brutal Chess" "" 22 23 BrandingText " " 24 25 RequestExecutionLevel admin 26 27;-------------------------------- 28;Variables 29 30 Var MUI_TEMP 31 Var STARTMENU_FOLDER 32; Var WIN_VERSION 33 34 35;-------------------------------- 36;Interface Settings 37 38 !define MUI_ABORTWARNING 39 40;-------------------------------- 41;Pages 42 43 !insertmacro MUI_PAGE_WELCOME 44 !insertmacro MUI_PAGE_LICENSE "gpl.txt" 45 !insertmacro MUI_PAGE_DIRECTORY 46 47 ;Start Menu Folder Page Configuration 48 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU" 49 !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\Brutal Chess" 50 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder" 51 52 !insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER 53 54 55 !insertmacro MUI_PAGE_INSTFILES 56 !insertmacro MUI_PAGE_FINISH 57 58 !insertmacro MUI_UNPAGE_WELCOME 59 !insertmacro MUI_UNPAGE_CONFIRM 60 !insertmacro MUI_UNPAGE_INSTFILES 61 !insertmacro MUI_UNPAGE_FINISH 62 63;-------------------------------- 64;Languages 65 66 !insertmacro MUI_LANGUAGE "English" 67 68;-------------------------------- 69;Installer Sections 70 71Section "Dummy Section" SecDummy 72 73 SetOutPath "$INSTDIR\bin" 74 75 File "Release\brutalchess.exe" 76 File "C:\WINDOWS\System32\SDL.dll" 77 File "C:\WINDOWS\System32\SDL_image.dll" 78 File "C:\WINDOWS\System32\jpeg.dll" 79 File "C:\WINDOWS\System32\libpng12.dll" 80 File "C:\WINDOWS\System32\libtiff.dll" 81 File "C:\WINDOWS\System32\zlib1.dll" 82 File "C:\WINDOWS\System32\freetype6.dll" 83 84 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application 85 86 ;Create shortcuts 87 CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER" 88 CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Brutal Chess.lnk" "$INSTDIR\bin\brutalchess.exe" 89 CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\Uninstall.exe" 90 91 !insertmacro MUI_STARTMENU_WRITE_END 92 93 94 ;Make sure the installer works on Win98+ 95 ;Check for NT based system 96; ReadRegStr $WIN_VERSION HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion 97 98 ;Pre NT systems didn't have SxS assemblies 99; IfErrors lbl_SxS_no 100 101 ;Windows XP, 2003, and Vista are only versions with SxS support 102; StrCmp $WIN_VERSION '5.1' lbl_SxS_yes ;XP 103; StrCmp $WIN_VERSION '5.2' lbl_SxS_yes ;2003 104; StrCmp $WIN_VERSION '6.0' lbl_SxS_yes ;Vista 105 106; lbl_SxS_no: 107 SetOutPath "$INSTDIR\bin\" 108; Goto lbl_cpy_dll 109 110; lbl_SxS_yes: 111; SetOutPath "$INSTDIR\bin\Microsoft.VC80.CRT" 112; File "C:\Program Files\Microsoft Visual Studio 8\VC\redist\x86\Microsoft.VC80.CRT\Microsoft.VC80.CRT.manifest" 113 114 ;Copy the dlls to the system specific directory already set 115; lbl_cpy_dll: 116 File "C:\Program Files\Microsoft Visual Studio 8\VC\redist\x86\Microsoft.VC80.CRT\msvcm80.dll" 117 File "C:\Program Files\Microsoft Visual Studio 8\VC\redist\x86\Microsoft.VC80.CRT\msvcp80.dll" 118 File "C:\Program Files\Microsoft Visual Studio 8\VC\redist\x86\Microsoft.VC80.CRT\msvcr80.dll" 119 120 121 ;Setup all the Brutal Chess Resources 122 SetOutPath "$INSTDIR\models" 123 124 File "models\pawn.obj" 125 File "models\rook.obj" 126 File "models\bishop.obj" 127 File "models\king.obj" 128 File "models\knight.obj" 129 File "models\queen.obj" 130 131 SetOutPath "$INSTDIR\art" 132 File "art\brutalchesslogo.png" 133 File "art\marblehugeblack.png" 134 File "art\marblehugewhite.png" 135 136 SetOutPath "$INSTDIR\fonts" 137 File "fonts\ZEROES__.TTF" 138 139 ;Store installation folder 140 WriteRegStr HKCU "Software\Brutal Chess" "" $INSTDIR 141 142 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Brutal Chess" \ 143 "DisplayName" "Brutal Chess" 144 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Brutal Chess" \ 145 "UninstallString" "$INSTDIR\uninstall.exe" 146 147 SetOutPath "$INSTDIR" 148 149 ;Install all the docs 150 File /oname=ChangeLog.txt "ChangeLog" 151 File /oname=LICENSE.txt "COPYING" 152 File /oname=NEWS.txt "NEWS" 153 File /oname=README.txt "README" 154 155 ;Create uninstaller 156 WriteUninstaller "$INSTDIR\Uninstall.exe" 157 158SectionEnd 159 160Section "Quick Launch icon" SecQuick 161 SetOutPath "$INSTDIR\bin" 162 StrCmp $QUICKLAUNCH $TEMP +2 163 CreateShortcut "$QUICKLAUNCH\Brutal Chess.lnk" "$INSTDIR\bin\brutalchess.exe" 164SectionEnd 165 166;-------------------------------- 167;Descriptions 168 169 ;Language strings 170 LangString DESC_SecDummy ${LANG_ENGLISH} "The core program" 171 172 ;Assign language strings to sections 173 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN 174 !insertmacro MUI_DESCRIPTION_TEXT ${SecDummy} $(DESC_SecDummy) 175 !insertmacro MUI_FUNCTION_DESCRIPTION_END 176 177;-------------------------------- 178;Uninstaller Section 179 180Section "Uninstall" 181 182 ;Delete the application and all of our dlls 183 Delete "$INSTDIR\bin\brutalchess.exe" 184 Delete "$INSTDIR\bin\stdout.txt" 185 Delete "$INSTDIR\bin\stderr.txt" 186 Delete "$INSTDIR\bin\SDL.dll" 187 Delete "$INSTDIR\bin\SDL_image.dll" 188 Delete "$INSTDIR\bin\jpeg.dll" 189 Delete "$INSTDIR\bin\libpng12.dll" 190 Delete "$INSTDIR\bin\libtiff.dll" 191 Delete "$INSTDIR\bin\zlib1.dll" 192 Delete "$INSTDIR\bin\freetype6.dll" 193 Delete "$INSTDIR\bin\msvcm80.dll" 194 Delete "$INSTDIR\bin\msvcp80.dll" 195 Delete "$INSTDIR\bin\msvcr80.dll" 196 197; Delete "$INSTDIR\bin\Microsoft.VC80.CRT\Microsoft.VC80.CRT.manifest" 198; Delete "$INSTDIR\bin\Microsoft.VC80.CRT\msvcm80.dll" 199; Delete "$INSTDIR\bin\Microsoft.VC80.CRT\msvcp80.dll" 200; Delete "$INSTDIR\bin\Microsoft.VC80.CRT\msvcr80.dll" 201 202 Delete "$INSTDIR\models\pawn.obj" 203 Delete "$INSTDIR\models\rook.obj" 204 Delete "$INSTDIR\models\bishop.obj" 205 Delete "$INSTDIR\models\king.obj" 206 Delete "$INSTDIR\models\knight.obj" 207 Delete "$INSTDIR\models\queen.obj" 208 209 Delete "$INSTDIR\art\brutalchesslogo.png" 210 Delete "$INSTDIR\art\marblehugeblack.png" 211 Delete "$INSTDIR\art\marblehugewhite.png" 212 213 Delete "$INSTDIR\fonts\ZEROES__.TTF" 214 215 Delete "$INSTDIR\ChangeLog.txt" 216 Delete "$INSTDIR\LICENSE.txt" 217 Delete "$INSTDIR\NEWS.txt" 218 Delete "$INSTDIR\README.txt" 219 220 Delete "$INSTDIR\Uninstall.exe" 221 222; RMDir "$INSTDIR\bin\Microsoft.VC80.CRT\" 223 RMDir "$INSTDIR\bin" 224 RMDir "$INSTDIR\art" 225 RMDir "$INSTDIR\fonts" 226 RMDir "$INSTDIR\models" 227 RMDir "$INSTDIR" 228 229 230 !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP 231 232 Delete "$SMPROGRAMS\$MUI_TEMP\Brutal Chess.lnk" 233 Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk" 234 Delete "$QUICKLAUNCH\Brutal Chess.lnk" 235 236 ;Delete empty start menu parent diretories 237 StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP" 238 239 startMenuDeleteLoop: 240 ClearErrors 241 RMDir $MUI_TEMP 242 GetFullPathName $MUI_TEMP "$MUI_TEMP\.." 243 244 IfErrors startMenuDeleteLoopDone 245 246 StrCmp $MUI_TEMP $SMPROGRAMS startMenuDeleteLoopDone startMenuDeleteLoop 247 startMenuDeleteLoopDone: 248 249 DeleteRegKey /ifempty HKCU "Software\Brutal Chess" 250 251 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Brutal Chess" 252 253SectionEnd 254