1 Unicode true 2 SetCompressor /SOLID lzma 3 4 !define MULTIUSER_EXECUTIONLEVEL Highest 5 !define MULTIUSER_MUI 6 !define MULTIUSER_INSTALLMODE_COMMANDLINE 7 !define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY "Software\Battle for Wesnoth\%version" 8 !define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME "" 9 !define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY "Software\Battle for Wesnoth\%version" 10 !define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME "" 11 !define MULTIUSER_INSTALLMODE_INSTDIR "Battle for Wesnoth %version" 12 !include "MultiUser.nsh" 13 !include "MUI2.nsh" 14 !include "LogicLib.nsh" 15 !include "WinVer.nsh" 16 17;-------------------------------- 18;General 19 20 ;Name and file 21 Name $(LWesnoth) 22 OutFile "wesnoth-%version-win32.exe" 23 24;-------------------------------- 25;Variables 26 27 Var StartMenuFolder 28 29;-------------------------------- 30;Interface Settings 31 32 !define MUI_WELCOMEFINISHPAGE_BITMAP packaging\windows\WindowsInstallerGraphic.bmp 33 !define MUI_ABORTWARNING 34 !define MUI_WELCOMEPAGE_TITLE_3LINES 35 !define MUI_FINISHPAGE_TITLE_3LINES 36 !define MUI_LICENSEPAGE_TEXT_BOTTOM " " 37 !define MUI_LICENSEPAGE_BUTTON $(^NextBtn) 38 !define MUI_COMPONENTSPAGE_NODESC 39 40;-------------------------------- 41;Language Selection Dialog Settings 42 43 ;Remember the installer language 44 !define MUI_LANGDLL_REGISTRY_ROOT "SHCTX" 45 !define MUI_LANGDLL_REGISTRY_KEY "Software\Battle for Wesnoth\%version" 46 !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language" 47 48;-------------------------------- 49;Pages 50 51 !insertmacro MUI_PAGE_WELCOME 52 !insertmacro MUI_PAGE_LICENSE $(MUILicense) 53 !insertmacro MULTIUSER_PAGE_INSTALLMODE 54 !insertmacro MUI_PAGE_DIRECTORY 55 56 ;Start Menu Folder Page Configuration 57 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "SHCTX" 58 !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\Battle for Wesnoth\%version" 59 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder" 60 !define MUI_STARTMENUPAGE_DEFAULTFOLDER "Battle for Wesnoth %version" 61 62 !insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder 63 64 !insertmacro MUI_PAGE_INSTFILES 65 66 !insertmacro MUI_PAGE_FINISH 67 68 !insertmacro MUI_UNPAGE_CONFIRM 69 !insertmacro MUI_UNPAGE_COMPONENTS 70 !insertmacro MUI_UNPAGE_INSTFILES 71 72;-------------------------------- 73;Languages 74 !include "packaging\windows\translations.nsh" 75 76;-------------------------------- 77;Reserve Files 78 79 ;If you are using solid compression, files that are required before 80 ;the actual installation should be stored first in the data block, 81 ;because this will make your installer start faster. 82 83 !insertmacro MUI_RESERVEFILE_LANGDLL 84 ReserveFile /plugin "${NSISDIR}\Plugins\x86-unicode\*.dll" 85 86;-------------------------------- 87;Installer Sections 88 89Section "Battle for Wesnoth" BfWSection 90 91 SectionIn RO 92 93 SetOutPath "$INSTDIR\manual" 94 File /r /x .* doc\manual\*.html 95 File /r /x .* doc\manual\styles 96 File /r /x .* doc\manual\images 97 98 SetOutPath "$INSTDIR" 99 File packaging\windows\wesnoth_editor-icon.ico 100 101 File "/oname=README.txt" README.md 102 File "/oname=copyright.txt" copyright 103 File "/oname=COPYING.txt" COPYING 104 File "/oname=changelog.txt" changelog.md 105 File "/oname=players_changelog.txt" players_changelog.md 106 File cwesnoth.cmd 107 108 %NSIS_INSTALL_FILES 109 110 SetOutPath "$INSTDIR" 111 112 ;Store installation folder 113 WriteRegStr SHCTX "Software\Battle for Wesnoth\%version" "" $INSTDIR 114 115 ;Create uninstaller 116 WriteUninstaller "$INSTDIR\Uninstall.exe" 117 118 ;Add uninstall information 119 WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Battle for Wesnoth %version" "DisplayName" "Battle for Wesnoth %version" 120 WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Battle for Wesnoth %version" "DisplayIcon" "$\"$INSTDIR\wesnoth.exe$\"" 121 WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Battle for Wesnoth %version" "UninstallString" "$\"$INSTDIR\Uninstall.exe$\"" 122 WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Battle for Wesnoth %version" "QuietUninstallString" "$\"$INSTDIR\Uninstall.exe$\" /S" 123 WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Battle for Wesnoth %version" "URLInfoAbout" "www.wesnoth.org" 124 WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Battle for Wesnoth %version" "DisplayVersion" "%version" 125 WriteRegDWORD SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Battle for Wesnoth %version" "NoModify" 1 126 WriteRegDWORD SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Battle for Wesnoth %version" "NoRepair" 1 127 128 Call StartMenuShortcuts 129 130SectionEnd 131 132;-------------------------------- 133;Installer Functions 134 135Function .onInit 136 137 !insertmacro MULTIUSER_INIT 138 !insertmacro MUI_LANGDLL_DISPLAY 139 140FunctionEnd 141 142Function StartMenuShortcuts 143 144 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application 145 146 ; Create shortcuts 147 CreateDirectory "$SMPROGRAMS\$StartMenuFolder" 148 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Battle for Wesnoth.lnk" "$INSTDIR\wesnoth.exe" 149 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Battle for Wesnoth (with console).lnk" "$INSTDIR\cwesnoth.cmd" "" "$INSTDIR\wesnoth.exe" 150 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Manual.lnk" "$INSTDIR\manual\manual.$(LCode).html" 151 152 ${If} ${IsNT} 153 ${AndIf} ${AtMostWin7} 154 ; Win7 or lower has collapsed start menu folders, activate additional shortcuts. 155 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Map editor.lnk" "$INSTDIR\wesnoth.exe" "-e" "$INSTDIR\wesnoth_editor-icon.ico" 156 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\Uninstall.exe" 157 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Changelog.lnk" "$INSTDIR\changelog.txt" 158 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Player's changelog.lnk" "$INSTDIR\players_changelog.txt" 159 ${EndIf} 160 161 StrCpy $0 "$SMPROGRAMS\$StartMenuFolder\desktop.ini" 162 ; Create desktop.ini file (allows to display localized start menu entries) 163 ${IfNot} ${FileExists} $0 164 FileOpen $9 $0 w 165 FileWriteUTF16LE $9 ${U+FEFF} ; UTF16 BOM to enforce encoding 166 FileClose $9 167 ${EndIf} 168 169 ; Add translations to desktop.ini 170 ${If} $StartMenuFolder == "Battle for Wesnoth %version" 171 WriteIniStr $0 ".ShellClassInfo" "LocalizedResourceName" "$(LWesnoth) %version" 172 ${EndIf} 173 WriteIniStr $0 "LocalizedFileNames" "Battle for Wesnoth.lnk" "$(LWesnoth)" 174 WriteIniStr $0 "LocalizedFileNames" "Battle for Wesnoth (with console).lnk" "$(LWesnoth) (with console)" 175 WriteIniStr $0 "LocalizedFileNames" "Manual.lnk" "$(LManual)" 176 WriteIniStr $0 "LocalizedFileNames" "Map editor.lnk" "$(LEditor)" 177 178 SetFileAttributes "$SMPROGRAMS\$StartMenuFolder" SYSTEM 179 SetFileAttributes $0 HIDDEN|SYSTEM 180 181 !insertmacro MUI_STARTMENU_WRITE_END 182 183FunctionEnd 184 185;-------------------------------- 186;Uninstaller Section 187 188Section "un.$(LWesnoth)" un.BfW 189 SectionIn RO # read only (mandatory) 190 191 %NSIS_UNINSTALL_FILES 192 Delete "$INSTDIR\wesnoth_editor-icon.ico" 193 RMDir /r "$INSTDIR\manual" 194 Delete $INSTDIR\std*.txt 195 Delete $INSTDIR\README.txt 196 Delete $INSTDIR\copyright.txt 197 Delete $INSTDIR\COPYING.txt 198 Delete $INSTDIR\changelog.txt 199 Delete $INSTDIR\players_changelog.txt 200 Delete $INSTDIR\cwesnoth.cmd 201 202 Delete "$INSTDIR\Uninstall.exe" 203 204 RMDir "$INSTDIR" 205 206 !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder 207 208; If we created desktop.ini it'll start with a blank line 209 FileOpen $9 "$SMPROGRAMS\$StartMenuFolder\desktop.ini" r 210 FileReadUTF16LE $9 $1 211 FileClose $9 212 DetailPrint $1 213 ${If} $1 == "$\r$\n" 214 Delete "$SMPROGRAMS\$StartMenuFolder\desktop.ini" 215 ${EndIf} 216 217 Delete "$SMPROGRAMS\$StartMenuFolder\License.lnk" 218 Delete "$SMPROGRAMS\$StartMenuFolder\Player's changelog.lnk" 219 Delete "$SMPROGRAMS\$StartMenuFolder\Changelog.lnk" 220 Delete "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" 221 Delete "$SMPROGRAMS\$StartMenuFolder\Manual.lnk" 222 Delete "$SMPROGRAMS\$StartMenuFolder\Multiplayer server.lnk" 223 Delete "$SMPROGRAMS\$StartMenuFolder\Map editor.lnk" 224 Delete "$SMPROGRAMS\$StartMenuFolder\Battle for Wesnoth (with console).lnk" 225 Delete "$SMPROGRAMS\$StartMenuFolder\Battle for Wesnoth.lnk" 226 RMDir "$SMPROGRAMS\$StartMenuFolder" 227 228 DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Battle for Wesnoth %version" 229 DeleteRegKey /ifempty SHCTX "Software\Battle for Wesnoth\%version" 230 DeleteRegKey /ifempty SHCTX "Software\Battle for Wesnoth" 231 232SectionEnd 233 234Section /o "un.$(LUserdata)" un.Userdata # optional 235 RMDir /r "$DOCUMENTS\My Games\Wesnoth%version_major" 236SectionEnd 237 238;-------------------------------- 239;Uninstaller Functions 240 241Function un.onInit 242 243 !insertmacro MULTIUSER_UNINIT 244 !insertmacro MUI_UNGETLANGUAGE 245 246FunctionEnd 247