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