1SetCompressor /SOLID lzma
2
3!include x64.nsh
4!include MUI2.nsh
5
6Name "Dune Legacy"
7BrandingText " http://dunelegacy.sourceforge.net"
8!define INSTALLATIONNAME "Dune Legacy"
9OutFile "Dune Legacy Setup.exe"
10InstallDir "$PROGRAMFILES\${INSTALLATIONNAME}"
11
12RequestExecutionLevel admin
13
14!define MUI_ICON "dunelegacy.ico"
15!define MUI_WELCOMEFINISHPAGE_BITMAP "nsis-background1.bmp"
16!define MUI_UNWELCOMEFINISHPAGE_BITMAP "nsis-background1.bmp"
17!define MUI_HEADERIMAGE
18!define MUI_HEADERIMAGE_BITMAP "nsis-background2.bmp"
19
20!insertmacro MUI_PAGE_WELCOME
21!insertmacro MUI_PAGE_LICENSE "COPYING"
22
23!define MUI_DIRECTORYPAGE_VARIABLE $INSTDIR
24!insertmacro MUI_PAGE_DIRECTORY
25
26VAR DunePAKDirectory
27!define MUI_DIRECTORYPAGE_VARIABLE $DunePAKDirectory
28!define MUI_PAGE_HEADER_TEXT $(PAGE_HEADER_TEXT)
29!define MUI_PAGE_HEADER_SUBTEXT $(PAGE_HEADER_SUBTEXT)
30!define MUI_DIRECTORYPAGE_TEXT_TOP $(DIRECTORYPAGE_TEXT_TOP)
31!define MUI_DIRECTORYPAGE_TEXT_DESTINATION $(DIRECTORYPAGE_TEXT_DESTINATION)
32!define MUI_PAGE_CUSTOMFUNCTION_PRE OnDunePakDirectorySelectionPre
33!define MUI_PAGE_CUSTOMFUNCTION_LEAVE OnDunePakDirectorySelectionLeave
34!insertmacro MUI_PAGE_DIRECTORY
35
36!insertmacro MUI_PAGE_INSTFILES
37!insertmacro MUI_PAGE_FINISH
38
39!insertmacro MUI_UNPAGE_WELCOME
40!insertmacro MUI_UNPAGE_CONFIRM
41!insertmacro MUI_UNPAGE_INSTFILES
42!insertmacro MUI_UNPAGE_FINISH
43
44
45!insertmacro MUI_LANGUAGE "English"
46!insertmacro MUI_LANGUAGE "German"
47
48; English
49LangString PAGE_HEADER_TEXT ${LANG_ENGLISH} "Dune II Pak-Files"
50LangString PAGE_HEADER_SUBTEXT ${LANG_ENGLISH} "Choose the directory where the installer can copy the Dune II Pak-Files from."
51LangString DIRECTORYPAGE_TEXT_TOP ${LANG_ENGLISH} "Dune Legacy needs the PAK-Files from original Dune II. These files can be found in the Dune II folder. The installer will copy the following files from there to the Dune Legacy folder:$\n$\tHARK.PAK$\t$\tSCENARIO.PAK$\t$\tINTRO.PAK$\n$\tATRE.PAK$\t$\tMENTAT.PAK$\t$\tINTROVOC.PAK$\n$\tORDOS.PAK$\t$\tVOC.PAK$\t$\tSOUND.PAK$\n$\tENGLISH.PAK$\t$\tMERC.PAK$\t$\tGERMAN.PAK (if available)$\n$\tDUNE.PAK$\t$\tFINALE.PAK$\t$\tFRENCH.PAK (if available)"
52LangString DIRECTORYPAGE_TEXT_DESTINATION ${LANG_ENGLISH} "Dune II Pak-Files Directory"
53LangString UNINSTALL_NAME ${LANG_ENGLISH} "Uninstall Dune Legacy"
54
55; German
56LangString PAGE_HEADER_TEXT ${LANG_GERMAN} "Dune II Pak-Dateien"
57LangString PAGE_HEADER_SUBTEXT ${LANG_GERMAN} "W�hlen Sie das Verzeichnis aus, von dem der Installer die Dune II Pak-Dateien kopieren kann."
58LangString DIRECTORYPAGE_TEXT_TOP ${LANG_GERMAN} "Dune Legacy ben�tigt die PAK-Dateien des Originalspiels, welche im Dune II Verzeichnis liegen. Die folgenden Dateien werden von dort in das Dune Legacy Verzeichnis kopiert:$\n$\tHARK.PAK$\t$\tSCENARIO.PAK$\t$\tINTRO.PAK$\n$\tATRE.PAK$\t$\tMENTAT.PAK$\t$\tINTROVOC.PAK$\n$\tORDOS.PAK$\t$\tVOC.PAK$\t$\tSOUND.PAK$\n$\tENGLISH.PAK$\t$\tMERC.PAK$\t$\tGERMAN.PAK (falls vorhanden)$\n$\tDUNE.PAK$\t$\tFINALE.PAK$\t$\tFRENCH.PAK (falls vorhanden)"
59LangString DIRECTORYPAGE_TEXT_DESTINATION ${LANG_GERMAN} "Verzeichnis mit Dune II Pak-Dateien"
60LangString UNINSTALL_NAME ${LANG_GERMAN} "Dune Legacy deinstallieren"
61
62Function .onInit
63  ${If} ${RunningX64}
64    ${DisableX64FSRedirection}
65    SetRegView 64
66    StrCpy $INSTDIR "$PROGRAMFILES64\${INSTALLATIONNAME}"
67  ${EndIf}
68FunctionEnd
69
70Function un.onInit
71  ${If} ${RunningX64}
72    ${DisableX64FSRedirection}
73    SetRegView 64
74    StrCpy $INSTDIR "$PROGRAMFILES64\${INSTALLATIONNAME}"
75  ${EndIf}
76FunctionEnd
77
78Function OnDunePakDirectorySelectionPre
79  IfFileExists "$INSTDIR\HARK.PAK" 0 FileNotFound
80  IfFileExists "$INSTDIR\ATRE.PAK" 0 FileNotFound
81  IfFileExists "$INSTDIR\ORDOS.PAK" 0 FileNotFound
82  IfFileExists "$INSTDIR\ENGLISH.PAK" 0 FileNotFound
83  IfFileExists "$INSTDIR\DUNE.PAK" 0 FileNotFound
84  IfFileExists "$INSTDIR\SCENARIO.PAK" 0 FileNotFound
85  IfFileExists "$INSTDIR\MENTAT.PAK" 0 FileNotFound
86  IfFileExists "$INSTDIR\VOC.PAK" 0 FileNotFound
87  IfFileExists "$INSTDIR\MERC.PAK" 0 FileNotFound
88  IfFileExists "$INSTDIR\FINALE.PAK" 0 FileNotFound
89  IfFileExists "$INSTDIR\INTRO.PAK" 0 FileNotFound
90  IfFileExists "$INSTDIR\INTROVOC.PAK" 0 FileNotFound
91  IfFileExists "$INSTDIR\SOUND.PAK" 0 FileNotFound
92
93  Abort
94
95FileNotFound:
96
97FunctionEnd
98
99Function OnDunePakDirectorySelectionLeave
100  IfFileExists "$DunePAKDirectory\HARK.PAK" 0 FileNotFound
101  IfFileExists "$DunePAKDirectory\ATRE.PAK" 0 FileNotFound
102  IfFileExists "$DunePAKDirectory\ORDOS.PAK" 0 FileNotFound
103  IfFileExists "$DunePAKDirectory\ENGLISH.PAK" 0 FileNotFound
104  IfFileExists "$DunePAKDirectory\DUNE.PAK" 0 FileNotFound
105  IfFileExists "$DunePAKDirectory\SCENARIO.PAK" 0 FileNotFound
106  IfFileExists "$DunePAKDirectory\MENTAT.PAK" 0 FileNotFound
107  IfFileExists "$DunePAKDirectory\VOC.PAK" 0 FileNotFound
108  IfFileExists "$DunePAKDirectory\MERC.PAK" 0 FileNotFound
109  IfFileExists "$DunePAKDirectory\FINALE.PAK" 0 FileNotFound
110  IfFileExists "$DunePAKDirectory\INTRO.PAK" 0 FileNotFound
111  IfFileExists "$DunePAKDirectory\INTROVOC.PAK" 0 FileNotFound
112  IfFileExists "$DunePAKDirectory\SOUND.PAK" 0 FileNotFound
113
114  CreateDirectory "$INSTDIR"
115
116  CopyFiles /SILENT /FILESONLY "$DunePAKDirectory\HARK.PAK" "$INSTDIR" 424
117  CopyFiles /SILENT /FILESONLY "$DunePAKDirectory\ATRE.PAK" "$INSTDIR" 402
118  CopyFiles /SILENT /FILESONLY "$DunePAKDirectory\ORDOS.PAK" "$INSTDIR" 452
119  CopyFiles /SILENT /FILESONLY "$DunePAKDirectory\ENGLISH.PAK" "$INSTDIR" 88
120  CopyFiles /SILENT /FILESONLY "$DunePAKDirectory\DUNE.PAK" "$INSTDIR" 399
121  CopyFiles /SILENT /FILESONLY "$DunePAKDirectory\SCENARIO.PAK" "$INSTDIR" 310
122  CopyFiles /SILENT /FILESONLY "$DunePAKDirectory\MENTAT.PAK" "$INSTDIR" 561
123  CopyFiles /SILENT /FILESONLY "$DunePAKDirectory\VOC.PAK" "$INSTDIR" 257
124  CopyFiles /SILENT /FILESONLY "$DunePAKDirectory\MERC.PAK" "$INSTDIR" 45
125  CopyFiles /SILENT /FILESONLY "$DunePAKDirectory\FINALE.PAK" "$INSTDIR" 569
126  CopyFiles /SILENT /FILESONLY "$DunePAKDirectory\INTRO.PAK" "$INSTDIR" 1196
127  CopyFiles /SILENT /FILESONLY "$DunePAKDirectory\INTROVOC.PAK" "$INSTDIR" 953
128  CopyFiles /SILENT /FILESONLY "$DunePAKDirectory\SOUND.PAK" "$INSTDIR" 1280
129
130  IfFileExists "$DunePAKDirectory\GERMAN.PAK" 0 +2
131    CopyFiles /SILENT /FILESONLY "$DunePAKDirectory\GERMAN.PAK" "$INSTDIR"
132
133  IfFileExists "$DunePAKDirectory\FRENCH.PAK" 0 +2
134    CopyFiles /SILENT /FILESONLY "$DunePAKDirectory\FRENCH.PAK" "$INSTDIR"
135
136  Return
137
138  FileNotFound:
139    MessageBox MB_OK 'Cannot find the needed PAK-Files in "$DunePAKDirectory"'
140    Abort
141FunctionEnd
142
143
144Section ""
145  SetOutPath $INSTDIR\maps\singleplayer
146  File "data\maps\singleplayer\*.ini"
147
148  SetOutPath $INSTDIR\maps\multiplayer
149  File "data\maps\multiplayer\*.ini"
150
151  SetOutPath $INSTDIR\locale
152  File "data\locale\*.po"
153
154  SetOutPath $INSTDIR
155  ${If} ${RunningX64}
156    File build\x64\dunelegacy.exe
157    File build\x64\SDL2.dll
158    File build\x64\SDL2_mixer.dll
159    File build\x64\libogg-0.dll
160    File build\x64\libvorbis-0.dll
161    File build\x64\libvorbisfile-3.dll
162    File build\x64\libmodplug-1.dll
163    File build\x64\libFLAC-8.dll
164    File build\x64\smpeg2.dll
165  ${Else}
166    File build\x86\dunelegacy.exe
167    File build\x86\SDL2.dll
168    File build\x86\SDL2_mixer.dll
169    File build\x86\libogg-0.dll
170    File build\x86\libvorbis-0.dll
171    File build\x86\libvorbisfile-3.dll
172    File build\x86\libmodplug-1.dll
173    File build\x86\libFLAC-8.dll
174    File build\x86\smpeg2.dll
175  ${EndIf}
176  File data\LEGACY.PAK
177  File data\OPENSD2.PAK
178  File data\GFXHD.PAK
179  File data\Dune2-Versions.txt
180
181  File COPYING
182  Push "$INSTDIR\COPYING"
183  Push "$INSTDIR\License.txt"
184  Call unix2dos
185
186  File AUTHORS
187  Push "$INSTDIR\AUTHORS"
188  Push "$INSTDIR\Authors.txt"
189  Call unix2dos
190
191  File README
192  Push "$INSTDIR\README"
193  Push "$INSTDIR\Readme.txt"
194  Call unix2dos
195
196  WriteUninstaller $INSTDIR\uninstall.exe
197  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${INSTALLATIONNAME}" "DisplayName" "${INSTALLATIONNAME}"
198  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${INSTALLATIONNAME}" "UninstallString" '"$INSTDIR\uninstall.exe"'
199  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${INSTALLATIONNAME}" "DisplayIcon" '"$INSTDIR\dunelegacy.exe",0'
200  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${INSTALLATIONNAME}" "NoModify" 1
201  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${INSTALLATIONNAME}" "NoRepair" 1
202SectionEnd
203
204Section "Start Menu Shortcuts"
205  CreateDirectory "$SMPROGRAMS\${INSTALLATIONNAME}"
206  CreateShortCut "$SMPROGRAMS\${INSTALLATIONNAME}\Dune Legacy.lnk" "$INSTDIR\dunelegacy.exe" "" "$INSTDIR\dunelegacy.exe" 0
207  CreateShortCut "$SMPROGRAMS\${INSTALLATIONNAME}\Readme.lnk" "$INSTDIR\Readme.txt"
208  CreateShortCut "$SMPROGRAMS\${INSTALLATIONNAME}\License.lnk" "$INSTDIR\License.txt"
209
210  WriteINIStr "$INSTDIR\Dune Legacy Website.URL" "InternetShortcut" "URL" "http://dunelegacy.sourceforge.net/"
211  CreateShortCut "$SMPROGRAMS\${INSTALLATIONNAME}\Dune Legacy Website.lnk" "$INSTDIR\Dune Legacy Website.URL"
212
213  CreateShortCut "$SMPROGRAMS\${INSTALLATIONNAME}\$(UNINSTALL_NAME).lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
214SectionEnd
215
216Section "Uninstall"
217  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${INSTALLATIONNAME}"
218  RMDir /r "$INSTDIR"
219
220  Delete "$SMPROGRAMS\${INSTALLATIONNAME}\*.*"
221  RMDir "$SMPROGRAMS\${INSTALLATIONNAME}"
222SectionEnd
223
224
225Function unix2dos
226    ; strips all CRs
227    ; and then converts all LFs into CRLFs
228    ; (this is roughly equivalent to "cat file | dos2unix | unix2dos")
229    ;
230    ; usage:
231    ;    Push "infile"
232    ;    Push "outfile"
233    ;    Call unix2dos
234    ;
235    ; beware that this function destroys $0 $1 $2
236
237    ClearErrors
238
239    Pop $2
240    FileOpen $1 $2 w
241
242    Pop $2
243    FileOpen $0 $2 r
244
245    Push $2 ; save name for deleting
246
247    IfErrors unix2dos_done
248
249    ; $0 = file input (opened for reading)
250    ; $1 = file output (opened for writing)
251
252unix2dos_loop:
253    ; read a byte (stored in $2)
254    FileReadByte $0 $2
255    IfErrors unix2dos_done ; EOL
256    ; skip CR
257    StrCmp $2 13 unix2dos_loop
258    ; if LF write an extra CR
259    StrCmp $2 10 unix2dos_cr unix2dos_write
260
261unix2dos_cr:
262    FileWriteByte $1 13
263
264unix2dos_write:
265    ; write byte
266    FileWriteByte $1 $2
267    ; read next byte
268    Goto unix2dos_loop
269
270unix2dos_done:
271
272    ; close files
273    FileClose $0
274    FileClose $1
275
276    ; delete original
277    Pop $0
278    Delete $0
279
280FunctionEnd
281
282