File: enigma.nsi.in

package info (click to toggle)
enigma 1.20-dfsg.1-2.2
  • links: PTS
  • area: main
  • in suites: bullseye, sid
  • size: 64,696 kB
  • sloc: xml: 153,614; cpp: 63,581; ansic: 31,088; sh: 4,825; makefile: 1,858; yacc: 288; perl: 84; sed: 16
file content (329 lines) | stat: -rw-r--r-- 12,406 bytes parent folder | download | duplicates (4)
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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
;Based on: NSIS Modern User Interface - "Multilingual Example Script" Written by Joost Verburg

;===================================================
;Include Modern UI
  !include "MUI.nsh"
;Include NSIS Logic Library
  !include 'LogicLib.nsh'
;Include Word Functions Header
  !include "WordFunc.nsh"
  !insertmacro WordReplace
  !insertmacro WordAdd
  !insertmacro un.WordReplace
  !insertmacro un.WordAdd

;===================================================
;General

  !define NAME "Enigma"
  !define COMPANY "Enigma Devel"
  !define WEBSITE "http://www.nongnu.org/enigma"
  !define VERSION "@VERSION@"
  !define VERSION4 "${VERSION}.0.0" ; x.x.x.x
  !define LEGALCOPYRIGHT "Program is under GPL license"
  !define INSTALLER_REGISTRY_ROOT "HKLM"
  !define INSTALLER_REGISTRY_KEY "Software\Enigma"

  ; Source directory
  !define SDIR ".\"

  ;Name and file
  Name "${NAME} ${VERSION}"
  OutFile "Enigma-${VERSION}.exe"
  SetCompressor /SOLID lzma

  ;Default installation folder
  InstallDir "$PROGRAMFILES\Enigma"
  ;InstallDirRegKey ${INSTALLER_REGISTRY_ROOT} ${INSTALLER_REGISTRY_KEY} "Install_Dir" ; this is handled with in .oninit
  
  ;Vista redirects $SMPROGRAMS to all users without this
  RequestExecutionLevel admin

;===================================================
;Variables

  Var MUI_TEMP
  Var STARTMENU_FOLDER

;===================================================
;Interface Settings

  !define MUI_ABORTWARNING
  !define MUI_WELCOMEFINISHPAGE_BITMAP "enigma-inst-welcome.bmp" ;164x314 bmp
  !define MUI_UNWELCOMEFINISHPAGE_BITMAP "enigma-inst-welcome.bmp"
  ; !define MUI_TEXT_WELCOME_INFO_TEXT "text"
  !define MUI_WELCOMEPAGE_TEXT "$(ProgramDesc)\r\n\r\n$(^ClickNext)"
  !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install-blue-full.ico"
  !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall-blue-full.ico"

;===================================================
;Language Selection Dialog Settings

  ;Remember the installer language
  !define MUI_LANGDLL_REGISTRY_ROOT ${INSTALLER_REGISTRY_ROOT}
  !define MUI_LANGDLL_REGISTRY_KEY ${INSTALLER_REGISTRY_KEY}
  !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
  !define MUI_LANGDLL_ALWAYSSHOW

;===================================================
;Pages

  !define MUI_PAGE_CUSTOMFUNCTION_PRE WelcomePagePre ; hack for link on welcomepage
  !define MUI_PAGE_CUSTOMFUNCTION_SHOW WelcomePageShow
  !insertmacro MUI_PAGE_WELCOME
  ; !insertmacro MUI_PAGE_COMPONENTS ; There's currently only 1 component, so we don't need this
  
  !define MUI_PAGE_CUSTOMFUNCTION_LEAVE DirectoryPageLeave
  !insertmacro MUI_PAGE_DIRECTORY
  
  ;Start Menu Folder Page Configuration
  !define MUI_STARTMENUPAGE_REGISTRY_ROOT "${INSTALLER_REGISTRY_ROOT}"
  !define MUI_STARTMENUPAGE_REGISTRY_KEY "${INSTALLER_REGISTRY_KEY}"
  !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
  !define MUI_STARTMENUPAGE_DEFAULTFOLDER "Enigma"
  
  !insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER

  ;Page that asks for creating an icon on the desktop
  Page custom CustomOptionsPage

  !insertmacro MUI_PAGE_INSTFILES

  ;finish page configuration
  !define MUI_FINISHPAGE_RUN enigma.exe
  ;MUI_FINISHPAGE_RUN_TEXT "text"
  !define MUI_FINISHPAGE_RUN_NOTCHECKED

  !insertmacro MUI_PAGE_FINISH
  
  !insertmacro MUI_UNPAGE_WELCOME
  ; !insertmacro MUI_UNPAGE_CONFIRM
  !insertmacro MUI_UNPAGE_DIRECTORY
  UninstPage custom Un.CustomOptionsPage
  !insertmacro MUI_UNPAGE_INSTFILES
  !insertmacro MUI_UNPAGE_FINISH

;===================================================
;Languages

  !include "enigma-inst-lang.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.
  
  ReserveFile "enigma-inst-welcome.bmp"
  ReserveFile "enigma-inst-opt.ini"
  !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
  !insertmacro MUI_RESERVEFILE_LANGDLL

;===================================================
;Installer Sections

Section "Enigma"
SectionIn RO
  ; install for all users
  SetShellVarContext all
  ; Set output path to the installation directory.
  SetOutPath $INSTDIR
  RMDir /r "$INSTDIR" ; delete the inst. dir. with all its contents
  ; Add files
  File /r "${SDIR}\data"
  File /r "${SDIR}\images"
  File /r "${SDIR}\manual"
  File /r "${SDIR}\reference"
  File    "${SDIR}\*.*"

  ; Write the installation path into the registry
  WriteRegStr ${INSTALLER_REGISTRY_ROOT} ${INSTALLER_REGISTRY_KEY} "LastDirectory" "$INSTDIR"
  ; Write the uninstall keys for Windows
  Var /GLOBAL UninstallRegKey
  StrCpy $UninstallRegKey "Software\Microsoft\Windows\CurrentVersion\Uninstall\Enigma"
  WriteRegStr HKLM $UninstallRegKey "DisplayName" "Enigma"
  WriteRegStr HKLM $UninstallRegKey "UninstallString" '"$INSTDIR\uninstall.exe"'
  WriteRegStr HKLM $UninstallRegKey "InstallLocation" "$INSTDIR"
  WriteRegStr HKLM $UninstallRegKey "Publisher" "${COMPANY}"
  WriteRegStr HKLM $UninstallRegKey "URLInfoAbout" "${WEBSITE}"
  WriteRegStr HKLM $UninstallRegKey "DisplayVersion" "${VERSION}"
  WriteRegDWORD HKLM $UninstallRegKey "NoModify" 1
  WriteRegDWORD HKLM $UninstallRegKey "NoRepair" 1

  WriteUninstaller "uninstall.exe"

  !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
    CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
    CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Enigma.lnk" "$INSTDIR\enigma.exe"
    CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Documentation.lnk" "$INSTDIR\index.html"
    CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\uninstall.exe"
  !insertmacro MUI_STARTMENU_WRITE_END

  ;Read a value from an InstallOptions INI file
  !insertmacro MUI_INSTALLOPTIONS_READ $R1 "enigma-inst-opt.ini" "Field 1" "State"
  
  ;Create desktop shortcut if check box was checked
  StrCmp $R1 "1" "" +2
     CreateShortCut "$DESKTOP\Enigma.lnk" "$INSTDIR\enigma.exe" "" "$INSTDIR\enigma.exe" 0

  ; the following code adds the version + inst. directory to the list of all Enigma installations
  ReadRegStr $R2 ${INSTALLER_REGISTRY_ROOT} ${INSTALLER_REGISTRY_KEY} "DirectoriesList"
  ${WordAdd} "$R2" "|" "+${VERSION}:$INSTDIR" $R3
  WriteRegStr ${INSTALLER_REGISTRY_ROOT} ${INSTALLER_REGISTRY_KEY} "DirectoriesList" $R3

SectionEnd

;===================================================
;Installer Functions

Function .onInit

  !insertmacro MUI_LANGDLL_DISPLAY
  ;Extract InstallOptions INI files
  !insertmacro MUI_INSTALLOPTIONS_EXTRACT "enigma-inst-opt.ini"

  ReadRegStr $R4 ${INSTALLER_REGISTRY_ROOT} ${INSTALLER_REGISTRY_KEY} "Install_Dir" ; key used prior to version 1.01
  ReadRegStr $R5 ${INSTALLER_REGISTRY_ROOT} ${INSTALLER_REGISTRY_KEY} "LastDirectory"

  ;Get installation folder from registry if available
  ${If} $R5 != ""
    StrCpy $INSTDIR $R5
  ${ElseIf} $R4 != ""
    StrCpy $INSTDIR $R4
  ${EndIf}

FunctionEnd

Function CustomOptionsPage
  !insertmacro MUI_INSTALLOPTIONS_WRITE "enigma-inst-opt.ini" "Field 1" "Text" $(DesktopIcon)
  !insertmacro MUI_INSTALLOPTIONS_WRITE "enigma-inst-opt.ini" "Field 2" "Text" $(^ClickInstall)
  ${WordReplace} $(^ComponentsSubCaption) ": " "" "+" $R0
  !insertmacro MUI_HEADER_TEXT $R0 "$(^ComponentsSubText2_NoInstTypes)"
  !insertmacro MUI_INSTALLOPTIONS_DISPLAY "enigma-inst-opt.ini"
FunctionEnd

Function WelcomePagePre
   !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 3" "Bottom" "175"
   !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Type" "Link"
   !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Text" "www.enigma-game.org"
   !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Left" "120"
   !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Right" "315"
   !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Top" "175"
   !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Bottom" "185"
   !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "State" ${WEBSITE}
   !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Settings" "Numfields" "4"
FunctionEnd

Function WelcomePageShow
  ; Thanks to pengyou ; Fix colors of added link control ; See http://forums.winamp.com/showthread.php?s=&threadid=205674
  Push $0
  GetDlgItem $0 $MUI_HWND 1203
  SetCtlColors $0 "0000FF" "FFFFFF"
  CreateFont $1 "$(^Font)" "$(^FontSize)" "400" /UNDERLINE
  SendMessage $0 ${WM_SETFONT} $1 1 
  Pop $0
FunctionEnd

Function DirectoryPageLeave
   IfFileExists $INSTDIR\*.* FolderExists endfunction
   FolderExists:
      IfFileExists $INSTDIR\Enigma.exe FileDoesExist FileDoesNotexist
      FileDoesExist:
        MessageBox MB_YESNO|MB_DEFBUTTON2 "$(OldInstallSure) $(OldInstallDesc) $(OldInstallDesc2)" IDYES endfunction IDNO clickno
      FileDoesNotexist:
        MessageBox MB_YESNO|MB_DEFBUTTON2 "$(OldInstallMaybe) $(OldInstallDesc)" IDYES endfunction IDNO clickno
   clickno:
    Abort
   endfunction:
FunctionEnd

;===================================================
;Uninstaller Section

Section "Uninstall"

  ; uninstall for all users
  SetShellVarContext all

  ; remove start-menu items
  !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP

  Delete "$SMPROGRAMS\$MUI_TEMP\Enigma.lnk"
  Delete "$SMPROGRAMS\$MUI_TEMP\Documentation.lnk"
  Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
  
  ;Delete empty start menu parent directories
  StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
  startMenuDeleteLoop:
	ClearErrors
    RMDir $MUI_TEMP
    GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
    IfErrors startMenuDeleteLoopDone
    StrCmp $MUI_TEMP $SMPROGRAMS startMenuDeleteLoopDone startMenuDeleteLoop
  startMenuDeleteLoopDone:

  ; remove desktop shortcut
  Delete "$DESKTOP\Enigma.lnk"

  ; read a value from an InstallOptions INI file
  !insertmacro MUI_INSTALLOPTIONS_READ $R7 "enigma-inst-opt.ini" "Field 1" "State"

  ; remove Enigma user data if check box was checked
  SetShellVarContext current ; Enigma's user data is stored for the current user
  StrCmp $R7 "1" "" +2
      RMDir /r "$APPDATA\Enigma"
  SetShellVarContext all ; get back to all users

  ; the following code removes the version + inst. directory from the list of all Enigma installations
  ReadRegStr $R8 ${INSTALLER_REGISTRY_ROOT} ${INSTALLER_REGISTRY_KEY} "DirectoriesList"
  ;MessageBox MB_OK "R8: $R8"
  ${un.WordAdd} "$R8" "|" "-${VERSION}:$INSTDIR" $R9
  ;MessageBox MB_OK "R9: $R9"
  WriteRegStr ${INSTALLER_REGISTRY_ROOT} ${INSTALLER_REGISTRY_KEY} "DirectoriesList" $R9

  ; remove registry keys only if there's no other version of Enigma installed
  StrCmp $R9 "" nonewinst donotdelete
  nonewinst:
  ReadRegStr $R6 ${INSTALLER_REGISTRY_ROOT} ${INSTALLER_REGISTRY_KEY} "Install_Dir"
  StrCmp $R6 "" deleteit 0
  StrCmp $R6 "$INSTDIR" deleteit donotdelete
  deleteit:
  DeleteRegKey ${INSTALLER_REGISTRY_ROOT} "Software\Microsoft\Windows\CurrentVersion\Uninstall\Enigma"
  DeleteRegKey ${INSTALLER_REGISTRY_ROOT} ${INSTALLER_REGISTRY_KEY}
  donotdelete:
  
  ; remove application directory with all its contents
  RMDir /r "$INSTDIR"
SectionEnd

;===================================================
;Uninstaller Functions

Function un.onInit
  !insertmacro MUI_UNGETLANGUAGE
  ;Extract InstallOptions INI files
  !insertmacro MUI_INSTALLOPTIONS_EXTRACT "enigma-inst-opt.ini"
FunctionEnd

Function Un.CustomOptionsPage
  !insertmacro MUI_INSTALLOPTIONS_WRITE "enigma-inst-opt.ini" "Field 1" "Text" $(DeleteUserdata)
  !insertmacro MUI_INSTALLOPTIONS_WRITE "enigma-inst-opt.ini" "Field 2" "Text" $(^ClickUninstall)
  !insertmacro MUI_INSTALLOPTIONS_WRITE "enigma-inst-opt.ini" "Field 1" "State" "0" ; default: unchecked
  ${un.WordReplace} $(^UnComponentsSubCaption) ": " "" "+" $R0
  !insertmacro MUI_HEADER_TEXT $R0 "$(^UnComponentsSubText2_NoInstTypes)"
  !insertmacro MUI_INSTALLOPTIONS_DISPLAY "enigma-inst-opt.ini"
FunctionEnd

;===================================================
;Version Information

  VIProductVersion "${VERSION4}"
  VIAddVersionKey /LANG=0 "ProductName" "${NAME} ${VERSION}"
  VIAddVersionKey /LANG=0 "FileDescription" "${NAME} Installer"
  VIAddVersionKey /LANG=0 "CompanyName" "${COMPANY}"
  VIAddVersionKey /LANG=0 "FileVersion" "${VERSION}"
  VIAddVersionKey /LANG=0 "LegalCopyright" "${LEGALCOPYRIGHT}"

;===================================================