c151275b1fef5478c4731bb70901e513e190642c
[xboard.git] / winboard / install / installer / WinBoard-4.2.7_full.nsi
1 ; WinBoard-4.2.7 MUI
2 ;
3 ;
4
5 ;--------------------------------
6 ;Include Modern UI
7
8   !include "MUI.nsh"
9
10 ;--------------------------------
11
12 !define InstName "WinBoard"
13 !define InstVersion "4.2.7"
14 !define InstBaseDir "WinBoard-4.2.7"
15
16 ;--------------------------------
17 ; General
18 ;
19
20 Name "${InstName} ${InstVersion}"
21 Caption "WinBoard - Chessboard For Windows"
22 OutFile "WinBoard-4.2.7_full.exe"
23 InstallDir $PROGRAMFILES\${InstBaseDir}
24
25 SetCompressor lzma
26 SetDateSave on
27 SetDatablockOptimize on
28 CRCCheck on
29 SilentInstall normal
30 BGGradient 000000 4682b4 FFFFFF
31 ;XPStyle on
32
33 ;--------------------------------
34 ;Variables
35
36   Var INI_VALUE
37   Var START_MENU_FOLDER
38   Var MUI_TEMP
39
40 ;--------------------------------
41
42
43 ;!define MUI_ICON "knight.ico"
44 ;!define MUI_UNICON "wc_uninst.ico"
45 !define MUI_WELCOMEFINISHPAGE_BITMAP "welcome_chess.bmp"
46
47 ;--------------------------------
48 ;Interface Settings
49
50         !define MUI_ABORTWARNING
51         ;!define MUI_COMPONENTSPAGE_NODESC
52         !define MUI_COMPONENTSPAGE_SMALLDESC
53         !define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation of ${InstName} ${InstVersion}.\n\n\n\n\nClick Next to continue."
54         !define MUI_LICENSEPAGE_TEXT_BOTTOM "$\nPress Continue to proceed with the installation."
55         !define MUI_LICENSEPAGE_BUTTON "Continue"
56
57 ;--------------------------------
58
59 ;--------------------------------
60 ; Pages
61
62         ; Install Section
63         ;--------------------------------------------------------------------
64         !insertmacro MUI_PAGE_WELCOME
65         !insertmacro MUI_PAGE_LICENSE "..\READ_ME.txt"
66         !insertmacro MUI_PAGE_COMPONENTS
67         Page custom FileAssoc
68         !insertmacro MUI_PAGE_DIRECTORY
69         
70         ;Start Menu Folder Page Configuration
71         !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU"
72         !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\WinBoard"
73         !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
74         !insertmacro MUI_PAGE_STARTMENU Application $START_MENU_FOLDER
75         
76         !insertmacro MUI_PAGE_INSTFILES
77         !insertmacro MUI_PAGE_FINISH
78         ;--------------------------------------------------------------------
79         
80         ; Uninstall Section
81         ;
82         ;!define MUI_WELCOMEPAGE_TEXT "WARNING! THIS UNINSTALLER WILL COMPLETELY DELETE THE INSTALLATION DIRECTORY\n\n$INSTDIR !!!\n\nIF THERE ARE ANY FILES YOU WISH TO SAVE, MOVE THEM FROM THE INSTALLATION DIRECTORY FIRST!\n\n\n\nPress Next to Continue."
83         !define MUI_WELCOMEPAGE_TEXT "This will uninstall WinBoard from directory:\n\n$INSTDIR\n\n\n\nPress Next to Continue."
84         !insertmacro MUI_UNPAGE_WELCOME
85         !insertmacro MUI_UNPAGE_CONFIRM
86         !insertmacro MUI_UNPAGE_INSTFILES
87         !insertmacro MUI_UNPAGE_FINISH
88
89 ;--------------------------------
90 ;Languages
91  
92   !insertmacro MUI_LANGUAGE "English"
93
94 ;--------------------------------
95
96 ;--------------------------------
97 ;Reserve Files
98   
99   ;These files should be inserted before other files in the data block
100   ;Keep these lines before any File command
101   ;Only for solid compression (by default, solid compression is enabled for BZIP2 and LZMA)
102   
103   ReserveFile "FA.ini"
104   !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
105
106 ;--------------------------------
107
108 Section "WinBoard Core Components" Core
109
110 SectionIn 1 RO
111
112         SetOutPath $INSTDIR
113
114         File ..\bughouse.bat
115         File ..\ChangeLog
116         File ..\COPYING
117         File ..\COPYRIGHT
118         File ..\cygncurses7.dll
119         File ..\cygreadline5.dll
120         File ..\cygwin1.dll
121         File ..\FAQ.html
122         File ..\kk13.pgn
123         File ..\NEWS
124         File ..\READ_ME.txt
125         File ..\RJF60.pgn
126         File ..\timeseal.exe
127         File ..\timestamp.exe
128         File ..\winboard.exe
129         File ..\winboard.hlp
130         File ..\zippy.lines
131         File ..\zippy.README
132         
133         ;Create uninstaller
134         WriteUninstaller "$INSTDIR\UnInstall.exe"
135         
136         !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
137
138         CreateDirectory "$SMPROGRAMS\$START_MENU_FOLDER"
139         CreateShortCut "$SMPROGRAMS\$START_MENU_FOLDER\Game Viewer.lnk" "$INSTDIR\winboard.exe" "-ncp" "$INSTDIR\winboard.exe" 1
140         CreateShortCut "$SMPROGRAMS\$START_MENU_FOLDER\Game Viewer - Bobby Fischer.lnk" "$INSTDIR\winboard.exe" "-ncp -lgf RJF60.pgn" "$INSTDIR\winboard.exe" 1
141         CreateShortCut "$SMPROGRAMS\$START_MENU_FOLDER\Game Viewer - Karpov vs Kasparov.lnk" "$INSTDIR\winboard.exe" "-ncp -lgf kk13.pgn" "$INSTDIR\winboard.exe" 1
142         CreateShortCut "$SMPROGRAMS\$START_MENU_FOLDER\WinBoard Help.lnk" "$INSTDIR\winboard.hlp"
143         CreateShortCut "$SMPROGRAMS\$START_MENU_FOLDER\Frequently Asked Questions.lnk" "$INSTDIR\FAQ.html"
144         CreateShortCut "$SMPROGRAMS\$START_MENU_FOLDER\WinBoard READ_ME.lnk" "$INSTDIR\READ_ME.txt"
145         CreateShortCut "$SMPROGRAMS\$START_MENU_FOLDER\WinBoard UnInstall.lnk" "$INSTDIR\UnInstall.exe"
146         CreateShortCut "$SMPROGRAMS\$START_MENU_FOLDER\Chess Server - chessclub.com.lnk" "$INSTDIR\winboard.exe"  "-ics -icshost chessclub.com -icshelper timestamp" "$INSTDIR\winboard.exe" 0
147         CreateShortCut "$SMPROGRAMS\$START_MENU_FOLDER\Chess Server - freechess.org.lnk" "$INSTDIR\winboard.exe"  "-ics -icshost freechess.org -icshelper timeseal" "$INSTDIR\winboard.exe" 0
148         CreateShortCut "$SMPROGRAMS\$START_MENU_FOLDER\Chess Server - Other.lnk" "$INSTDIR\winboard.exe" "-ics" "$INSTDIR\winboard.exe" 0
149         CreateShortCut "$SMPROGRAMS\$START_MENU_FOLDER\WinBoard Startup Dialog.lnk" "$INSTDIR\winboard.exe" "" "$INSTDIR\winboard.exe" 2
150         
151         !insertmacro MUI_STARTMENU_WRITE_END
152
153 SectionEnd
154
155 SubSection /e "Chess Engines" Engines
156
157         Section "GNU Chess 5.0" GNUChess5
158
159                 SetOutPath "$INSTDIR"
160
161                 File ..\book.dat
162                 File ..\GNUChes5.exe
163                 File ..\gnuches5.txt
164                 File ..\gnuchess.dat
165                 File ..\gnuchess.lan
166                 File ..\gnuchess.README
167                 
168                 CreateDirectory "$SMPROGRAMS\$START_MENU_FOLDER\Chess Engines"
169
170                 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
171
172                 CreateShortCut "$SMPROGRAMS\$START_MENU_FOLDER\Chess Engines\GNU Chess 5.0 Documentation.lnk" "$INSTDIR\gnuches5.txt"
173                 CreateShortCut "$SMPROGRAMS\$START_MENU_FOLDER\Chess Engines\GNU Chess 5.0.lnk" "$INSTDIR\winboard.exe" "-cp -fcp 'GNUChes5 xboard' -scp 'GNUChes5 xboard'" "$INSTDIR\winboard.exe" 2
174                 
175                 !insertmacro MUI_STARTMENU_WRITE_END
176
177         SectionEnd
178         
179         Section "GNU Chess 4.0" GNUChess4
180         
181                 SetOutPath "$INSTDIR"
182                 
183                 File ..\gnuchesr.exe
184                 File ..\GNUChess.exe
185                 File ..\gnuchess.txt
186
187                 CreateDirectory "$SMPROGRAMS\$START_MENU_FOLDER\Chess Engines"
188
189                 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
190
191                 CreateShortCut "$SMPROGRAMS\$START_MENU_FOLDER\Chess Engines\GNU Chess 4.0 Documentation.lnk" "$INSTDIR\gnuchess.txt"
192                 CreateShortCut "$SMPROGRAMS\$START_MENU_FOLDER\Chess Engines\GNU Chess 4.0.lnk" "$INSTDIR\winboard.exe" "-cp -fcp GNUChess -scp GNUChess" "$INSTDIR\winboard.exe" 2
193                 
194                 !insertmacro MUI_STARTMENU_WRITE_END
195                 
196          SectionEnd
197
198         Section "Crafty 19.3" Crafty
199
200                 SetOutPath "$INSTDIR\Crafty"
201
202                 File ..\Crafty-WinBoard\wcrafty.exe
203                 File ..\Crafty-WinBoard\book.bin
204                 File ..\Crafty-WinBoard\books.bin
205                 File ..\Crafty-WinBoard\Crafty.rc
206                 File ..\Crafty-WinBoard\crafty.doc.txt
207                 
208                 CreateDirectory "$SMPROGRAMS\$START_MENU_FOLDER\Chess Engines"
209                 
210                 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
211
212                 CreateShortCut "$SMPROGRAMS\$START_MENU_FOLDER\Chess Engines\Crafty Documentation.lnk" "$INSTDIR\Crafty\crafty.doc.txt"
213                 CreateShortCut "$SMPROGRAMS\$START_MENU_FOLDER\Chess Engines\Crafty 19.3.lnk" "$INSTDIR\winboard.exe" "-cp -fcp Crafty\wcrafty.exe -fd Crafty -scp Crafty\wcrafty.exe -sd Crafty" "$INSTDIR\winboard.exe" 2
214
215                 !insertmacro MUI_STARTMENU_WRITE_END
216
217
218         SectionEnd
219
220 SubSectionEnd
221
222
223 ;--------------------------------
224 ;Installer Functions
225 Function .onInit
226
227   ;Extract InstallOptions INI files
228   !insertmacro MUI_INSTALLOPTIONS_EXTRACT "FA.ini"
229   
230 FunctionEnd
231
232 Function FileAssoc
233
234         !insertmacro MUI_HEADER_TEXT "Windows File Associations" "Do you want to use Winboard as your viewer for the following file types?"
235         !insertmacro MUI_INSTALLOPTIONS_DISPLAY "FA.ini"
236
237         
238         ;Read a value from an InstallOptions INI file
239
240         !insertmacro MUI_INSTALLOPTIONS_READ $INI_VALUE "FA.ini" "Field 2" "State"
241   
242         ;Display a messagebox if check box was checked
243         StrCmp $INI_VALUE "1" "" CheckFEN
244         WriteRegStr HKCR ".pgn" "" "WinBoard.PGN"
245         WriteRegStr HKCR ".pgn" "Content Type" "application/x-chess-pgn"
246         WriteRegStr HKCR "WinBoard.PGN" "" "Chess Game"
247         WriteRegStr HKCR "WinBoard.PGN\DefaultIcon" "" "$INSTDIR\WinBoard.exe,1"
248         WriteRegStr HKCR "WinBoard.PGN\Shell\Open" "" "Open"
249         WriteRegStr HKCR "WinBoard.PGN\Shell\Open\command" "" '"$INSTDIR\WinBoard.exe" -ini "$INSTDIR\WinBoard.ini" -ncp -lgf "%1"'
250         
251         CheckFEN:
252         !insertmacro MUI_INSTALLOPTIONS_READ $INI_VALUE "FA.ini" "Field 3" "State"
253   
254         ;Display a messagebox if check box was checked
255         StrCmp $INI_VALUE "1" "" Continue
256         WriteRegStr HKCR ".fen" "" "WinBoard.FEN"
257         WriteRegStr HKCR ".fen" "Content Type" "application/x-chess-fen"
258         WriteRegStr HKCR "WinBoard.FEN" "" "Chess Position"
259         WriteRegStr HKCR "WinBoard.FEN\DefaultIcon" "" "$INSTDIR\WinBoard.exe,1"
260         WriteRegStr HKCR "WinBoard.FEN\Shell\Open" "" "Open"
261         WriteRegStr HKCR "WinBoard.FEN\Shell\Open\command" "" '"$INSTDIR\WinBoard.exe" -ini "$INSTDIR\WinBoard.ini" -ncp -lpf "%1"'
262         
263         Continue:
264
265 FunctionEnd
266
267 ;--------------------------------
268 ;Descriptions
269
270   ;Language strings
271
272         LangString DESC_Core ${LANG_ENGLISH} "Winboard Core Components - Executable and Help Files"
273         LangString DESC_Engines ${LANG_ENGLISH} "Chess Engines to play against using the WinBoard Interface"
274         LangString DESC_GNUChess5 ${LANG_ENGLISH} "GNU Chess 5.0 Engine"
275         LangString DESC_GNUChess4 ${LANG_ENGLISH} "GNU Chess 4.0 Engine"
276         LangString DESC_Crafty ${LANG_ENGLISH} "Crafty 19.3 Chess Engine, by Robert Hyatt"
277
278
279   ;Assign language strings to sections
280
281   !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
282         !insertmacro MUI_DESCRIPTION_TEXT ${Core} $(DESC_Core)
283         !insertmacro MUI_DESCRIPTION_TEXT ${Engines} $(DESC_Engines)
284         !insertmacro MUI_DESCRIPTION_TEXT ${GNUChess5} $(DESC_GNUChess5)
285         !insertmacro MUI_DESCRIPTION_TEXT ${GNUChess4} $(DESC_GNUChess4)
286         !insertmacro MUI_DESCRIPTION_TEXT ${Crafty} $(DESC_Crafty)
287   !insertmacro MUI_FUNCTION_DESCRIPTION_END
288
289 ;--------------------------------
290
291 ;--------------------------------
292 ;Uninstaller Section
293
294 ; Function to delete install directory if non-empty on user request
295 Function un.ForceDirectoryDelete
296
297          MessageBox MB_YESNO "The uninstaller was unable to delete the directory '$INSTDIR'. This is usually$\r$\ndue to user-created files such as WinBoard.ini, or other configuration files. If$\r$\nyou wish to keep your old configuration files, select No.$\r$\n$\r$\nForce deletion of install directory and all files in it?" IDNO End
298          
299          RMDir /r "$INSTDIR"
300          
301          End:
302
303 FunctionEnd
304
305
306 Section "Uninstall"
307
308         Delete "$INSTDIR\bughouse.bat"
309         Delete "$INSTDIR\ChangeLog"
310         Delete "$INSTDIR\COPYING"
311         Delete "$INSTDIR\COPYRIGHT"
312         Delete "$INSTDIR\cygncurses7.dll"
313         Delete "$INSTDIR\cygreadline5.dll"
314         Delete "$INSTDIR\cygwin1.dll"
315         Delete "$INSTDIR\FAQ.html"
316         Delete "$INSTDIR\kk13.pgn"
317         Delete "$INSTDIR\NEWS"
318         Delete "$INSTDIR\READ_ME.txt"
319         Delete "$INSTDIR\RJF60.pgn"
320         Delete "$INSTDIR\timeseal.exe"
321         Delete "$INSTDIR\timestamp.exe"
322         Delete "$INSTDIR\winboard.exe"
323         Delete "$INSTDIR\winboard.hlp"
324         Delete "$INSTDIR\zippy.lines"
325         Delete "$INSTDIR\zippy.README"
326         Delete "$INSTDIR\book.dat"
327         Delete "$INSTDIR\GNUChes5.exe"
328         Delete "$INSTDIR\gnuches5.txt"
329         Delete "$INSTDIR\gnuchess.dat"
330         Delete "$INSTDIR\gnuchess.lan"
331         Delete "$INSTDIR\gnuchess.README"
332         Delete "$INSTDIR\gnuchesr.exe"
333         Delete "$INSTDIR\GNUChess.exe"
334         Delete "$INSTDIR\gnuchess.txt"
335         Delete "$INSTDIR\UnInstall.exe"
336         Delete "$INSTDIR\Crafty\wcrafty.exe"
337         Delete "$INSTDIR\Crafty\book.bin"
338         Delete "$INSTDIR\Crafty\books.bin"
339         Delete "$INSTDIR\Crafty\Crafty.rc"
340         Delete "$INSTDIR\Crafty\crafty.doc.txt"
341         RMDir "$INSTDIR\Crafty"
342         RMDir "$INSTDIR"
343
344         
345         !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
346         
347         RMDir /r "$SMPROGRAMS\$MUI_TEMP"
348         
349         ReadRegStr $1 HKCR ".pgn" ""
350         StrCmp $1 "WinBoard.PGN" "" DelFEN
351         ReadRegStr $1 HKCR "WinBoard.PGN\Shell\Open\command" ""
352         StrCmp $1 '"$INSTDIR\WinBoard.exe" -ini "$INSTDIR\WinBoard.ini" -ncp -lgf "%1"' "" DelFEN
353         DeleteRegKey HKCR ".pgn"
354         DeleteRegKey HKCR "WinBoard.PGN"
355         
356         DelFEN:
357         
358         ReadRegStr $1 HKCR ".fen" ""
359         StrCmp $1 "WinBoard.FEN" "" ContDelFEN
360         ReadRegStr $1 HKCR "WinBoard.FEN\Shell\Open\command" ""
361         StrCmp $1 '"$INSTDIR\WinBoard.exe" -ini "$INSTDIR\WinBoard.ini" -ncp -lpf "%1"' "" ContDelFEN
362         DeleteRegKey HKCR ".fen"
363         DeleteRegKey HKCR "WinBoard.FEN"
364         
365         ContDelFEN:
366         
367         DeleteRegKey HKCU "Software\WinBoard"
368         
369         
370         IfFileExists "$INSTDIR\*.*" GoDirDel Continue
371
372         GoDirDel:
373         Call un.ForceDirectoryDelete
374
375         Continue:
376
377
378 SectionEnd