aboutsummaryrefslogtreecommitdiffstats
path: root/Installer/UltraStarDeluxe.nsi
blob: 296977f4e308b6c67defe23900c1924c336b1abc (plain) (blame)
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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
; --------------------------------------------------------------
; UltraStar Deluxe - Installation Wizard with NSIS (USDXIWWNSIS) 
; --------------------------------------------------------------

!include "MUI.nsh"	; Include the macros for the Modern User Interface
!include "LogicLib.nsh"
!include ".\settings\GameExplorer.nsh"
!include ".\settings\functions.nsh"
!include "WinVer.nsh"

!define icon_inst ".\icons\ustar.ico"		; Icon for Installation
!define icon_uninst ".\icons\uninstall.ico"	; Icon for Uninstallation

SetCompress Auto
SetCompressor /SOLID lzma
SetCompressorDictSize 32
SetDatablockOptimize On

; XPStyle on

; ------------------------------------------------------
; Declaration of Variables (See .\settings\variables.nsh)
; ------------------------------------------------------

!include ".\settings\variables.nsh"

!addPluginDir "..\InstallerDependencies\plugins\"

; -------------------------------
; Strings for Installation Wizard
; -------------------------------

!define MUI_WELCOMEPAGE_TITLE "$(wp_title)"

!define MUI_WELCOMEPAGE_TEXT "$(wp_text)" 
;!define MUI_FINISHPAGE_SHOWREADME_TEXT "$(fp_showreadme)"
!define MUI_FINISHPAGE_LINK "$(fp_link)"
!define MUI_UNCONFIRMPAGE_TEXT_TOP "UltraStar Deluxe - $(sm_uninstall)"

!define MUI_LICENSEPAGE_RADIOBUTTONS
!define MUI_WELCOMEPAGE_TITLE_3LINES

!define MUI_FINISHPAGE_TITLE_3LINES

!define MUI_FINISHPAGE_RUN "$INSTDIR\${exe}.exe"
!define MUI_FINISHPAGE_RUN_NOTCHECKED			
 
;!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\ReadMe.txt"

!define MUI_FINISHPAGE_LINK_LOCATION "${homepage}"
!define MUI_FINISHPAGE_NOREBOOTSUPPORT
!define MUI_FINISHPAGE_TEXT_LARGE
!define MUI_FINISHPAGE_TEXT "$(fp_text)"

!define MUI_UNFINISHPAGE_LINK_LOCATION "${forum}"

!define MUI_COMPONENTSPAGE_SMALLDESC

; The other (multi) language Strings are at the bottom of this file

; --------------------------------------------------
; Begin of the installation wizard
; --------------------------------------------------

Name "${p_name} V.${version}"
Brandingtext "${p_name} Installation"
OutFile "Install ${p_name} V.${version}.exe"
!define ins_name "Install ${p_name} V.${version}.exe"

InstallDir "$PROGRAMFILES\${p_name}"

ShowInstDetails show
ShowUnInstDetails show

!define PRODUCT_NAME "${p_name}"
!define PRODUCT_VERSION "${version}"
!define PRODUCT_PUBLISHER "${publisher}"
!define PRODUCT_WEB_SITE "${homepage}"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
!define PRODUCT_STARTMENU_REGVAL "NSIS:StartMenuDir"

; Modern User Interface (MUI) Stuff

!define MUI_ICON "${icon_inst}"		; Icon for Installation
!define MUI_UNICON "${icon_uninst}"	; Icon for Uninstallation

!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "${bmp_header}" 		 ; Header Bitmap of the installation (Size: 150x57 px)
!define MUI_HEADERIMAGE_UNBITMAP "${bmp_header}"	 ; Header Bitmap of the uninstallation (Size: 150x57 px)
!define MUI_WELCOMEFINISHPAGE_BITMAP "${bmp_side}"	 ; Left Side Bitmap of Welcome & Finish Page while Installation (Size: 164x314 px)
!define MUI_UNWELCOMEFINISHPAGE_BITMAP "${bmp_side}"	 ; Left Side Bitmap of Welcome & Finish Page while Uninstallation (Size: 164x314 px)
!define MUI_BGCOLOR "FFFFFF"				 ; RGB Background color (for header, welcome & finish page)
!define MUI_WELCOMEFINISHPAGE_INI "${mui_ini}"		 ; Installation Options for Welcome & Finish Page (Installation)
!define MUI_UNWELCOMEFINISHPAGE_INI "${mui_ini}"	 ; Installation Options for Welcome & Finish Page (Uninstallation)
!define MUI_LICENSEPAGE_BGCOLOR "${license_bgcolor}"	 ; Background Color of Licence agreement
!define MUI_COMPONENTSPAGE_CHECKBITMAP "${bmp_check}" 	 ; Bitmap of Checks at Components Selection Page
!define MUI_DIRECTORYPAGE_BGCOLOR "${directory_bgcolor}" ; RGB Background Color for Directory textbox
!define MUI_STARTMENUPAGE_BGCOLOR "${smp_bgcolor}"	 ; RGB Background of Startmenu List and Textbox
;!define MUI_INSTFILESPAGE_COLORS "${dets_bgcolor}"	 ; Background Color of Details Screen while files are being extracted


!define MUI_LANGDLL_WINDOWTITLE "USdx In-/Uninstaller: Choose language"
!define MUI_LANGDLL_ALWAYSSHOW

!define MUI_FINISHPAGE_NOAUTOCLOSE			 ; Allows user to check the log file of installation (Comment out if unwanted)
!define MUI_UNFINISHPAGE_NOAUTOCLOSE			 ; Allows user to check the log file of uninstallation (Comment out if unwanted)

!define MUI_ABORTWARNING
!define MUI_ABORTWARNING_TEXT $(str_abort)		 ; Abort Warning message
!define MUI_ABORTWARNING_CANCEL_DEFAULT			 ; Default: Cancel abort (Comment out if unwanted)

!define MUI_FINISHPAGE_SHOWREADME
!define MUI_FINISHPAGE_SHOWREADME_TEXT $(sc_desktop)
!define MUI_FINISHPAGE_SHOWREADME_FUNCTION CreateDesktopShortCuts

; --------------------------------------------------
; Begin of the installation routine
; --------------------------------------------------

; Pages for MUI Installation

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "${file_license}"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY


; Start menu page

var ICONS_GROUP
!define MUI_STARTMENUPAGE_NODISABLE
!define MUI_STARTMENUPAGE_DEFAULTFOLDER "UltraStar Deluxe"
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${PRODUCT_STARTMENU_REGVAL}"
!insertmacro MUI_PAGE_STARTMENU Application $ICONS_GROUP

!insertmacro MUI_PAGE_INSTFILES
Page custom Settings

; USDX Settings Page

Function Settings

!insertmacro MUI_HEADER_TEXT "$(Settings_TITLE)" "$(Settings_SUBTITLE)"
   
   !insertmacro MUI_INSTALLOPTIONS_DISPLAY "Settings-$LANGUAGE"

; Get all the variables:

var /GLOBAL fullscreen
var /GLOBAL language2
var /GLOBAL resolution
var /GLOBAL tabs
var /GLOBAL animations
  !insertmacro MUI_INSTALLOPTIONS_READ $fullscreen "Settings-$LANGUAGE" "Field 6" "State"
  !insertmacro MUI_INSTALLOPTIONS_READ $language2 "Settings-$LANGUAGE" "Field 7" "State"
  !insertmacro MUI_INSTALLOPTIONS_READ $resolution "Settings-$LANGUAGE" "Field 8" "State"
  !insertmacro MUI_INSTALLOPTIONS_READ $tabs "Settings-$LANGUAGE" "Field 9" "State"
  !insertmacro MUI_INSTALLOPTIONS_READ $animations "Settings-$LANGUAGE" "Field 10" "State"

; Write all variables to config.ini

FileOpen $0 '$INSTDIR\config.ini' w
FileWrite $0 '[Game]$\r$\n'
FileClose $0

${If} $language2 != ""

${WriteToConfig} "Language=$language2$\r$\n" "$INSTDIR\config.ini"

${EndIf}

${If} $tabs != ""

${WriteToConfig} "Tabs=$tabs$\r$\n" "$INSTDIR\config.ini"

${EndIf}

${WriteToConfig} "[Graphics]$\r$\n" "$INSTDIR\config.ini"

${If} $fullscreen != ""

${WriteToConfig} "FullScreen=$fullscreen$\r$\n" "$INSTDIR\config.ini"

${EndIf}

${If} $resolution != ""

${WriteToConfig} "Resolution=$resolution$\r$\n" "$INSTDIR\config.ini"

${EndIf}

${WriteToConfig} "[Advanced]$\r$\n" "$INSTDIR\config.ini"

; Animations On / Off Tasks

${If} $animations == "Off"

${WriteToConfig} "LoadAnimation=Off$\r$\n" "$INSTDIR\config.ini"

${WriteToConfig} "EffectSing=Off$\r$\n" "$INSTDIR\config.ini"

${WriteToConfig} "ScreenFade=Off$\r$\n" "$INSTDIR\config.ini"

${EndIf}


FunctionEnd ;Custom page end

!insertmacro MUI_PAGE_FINISH

; Pages for MUI Uninstallation

!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES

; Language files

!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "German"

; Finish Page

!insertmacro MUI_UNPAGE_FINISH

; ---------------------------------------------------------
; Section1: Main components of UltraStar Deluxe
; ---------------------------------------------------------

LangString DESC_Section1 ${LANG_ENGLISH} "${eng_sec1_desc}"	; Adds the description to section1
LangString DESC_Section1 ${LANG_GERMAN} "${ger_sec1_desc}"

LangString sec1 ${LANG_ENGLISH} "${eng_sec1}"			; Name of section1
LangString sec1 ${LANG_GERMAN} "${ger_sec1}"

Section $(sec1) Section1
  SectionIn RO			; readonly
  SetOutPath $INSTDIR
  SetOverwrite try

!include ".\settings\files_in.nsh"

; Create shortcuts

  SetOutPath "$INSTDIR"

  !insertmacro MUI_STARTMENU_WRITE_BEGIN Application

  SetShellVarContext all
  SetOutPath "$INSTDIR"

  CreateDirectory "${p_name}"
  CreateDirectory "$SMPROGRAMS\$ICONS_GROUP"
  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\$(sm_website).lnk" "http://www.ultrastardeluxe.org/"
  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\$(sm_uninstall).lnk" "$INSTDIR\Uninstall.exe"
  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\$(sm_shortcut).lnk" "$INSTDIR\${exe}.exe"
  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\$(sm_readme).lnk" "$INSTDIR\ReadMe.txt"
  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\$(sm_license).lnk" "$INSTDIR\License.txt"
  !insertmacro MUI_STARTMENU_WRITE_END

; WINDOWS VISTA GAME EXPLORER 

${If} ${AtLeastWinVista}

${GameExplorer_GenerateGUID}
Pop $0

${GameExplorer_AddGame} all "${gdf_path}" $WINDIR $INSTDIR\${exe}.exe $0

CreateDirectory $APPDATA\Microsoft\Windows\GameExplorer\$0\PlayTasks\1
CreateShortcut "$APPDATA\Microsoft\Windows\GameExplorer\$0\PlayTasks\1\Benchmark.lnk" \
  "$INSTDIR\${exe}.exe" "-Benchmark"

CreateDirectory $APPDATA\Microsoft\Windows\GameExplorer\$0\PlayTasks\2
CreateShortcut "$APPDATA\Microsoft\Windows\GameExplorer\$0\PlayTasks\2\Joypad.lnk" \
  "$INSTDIR\${exe}.exe" "-Joypad"

CreateDirectory $APPDATA\Microsoft\Windows\GameExplorer\$0\PlayTasks\3
CreateShortcut "$APPDATA\Microsoft\Windows\GameExplorer\$0\PlayTasks\3\Fullscreen.lnk" \
  "$INSTDIR\${exe}.exe" "-FullScreen"

CreateDirectory $APPDATA\Microsoft\Windows\GameExplorer\$0\PlayTasks\3
CreateShortcut "$APPDATA\Microsoft\Windows\GameExplorer\$0\PlayTasks\3\Dual Screen.lnk" \
  "$INSTDIR\${exe}.exe" "-Screen 2"

CreateDirectory $APPDATA\Microsoft\Windows\GameExplorer\$0\SupportTasks\0
CreateShortcut "$APPDATA\Microsoft\Windows\GameExplorer\$0\SupportTasks\0\Support Forum.lnk" \
  "http://forum.ultrastardeluxe.org"

${EndIf}

; Create Uninstaller:

  WriteUninstaller "$INSTDIR\Uninstall.exe"

  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "${p_name}"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\Uninstall.exe"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"

SectionEnd

; ---------------------------------------------------------
; Section2: Example Song "Dead Smiling Pirates"
; ---------------------------------------------------------

LangString DESC_g2Section1 ${LANG_ENGLISH} "${eng_g2Section1_desc}"
LangString DESC_g2Section1 ${LANG_GERMAN} "${ger_g2Section1_desc}"

LangString DESC_g2Section2 ${LANG_ENGLISH} "${eng_g2Section2_desc}"
LangString DESC_g2Section2 ${LANG_GERMAN} "${ger_g2Section2_desc}"

LangString sec2 ${LANG_ENGLISH} "${eng_sec2}"
LangString sec2 ${LANG_GERMAN} "${ger_sec2}"

SectionGroup $(sec2) Section2

Section /o "Dead Smiling Pirates - I 18" g2Section1
  AddSize 2816
  SetOverwrite try
  SetOutPath "$INSTDIR"
  CreateDirectory "$INSTDIR\Songs\Dead Smiling Pirates - I 18 [DEMO]"
  SetOutPath "$INSTDIR\Songs\Dead Smiling Pirates - I 18 [DEMO]\"

; Download song:
NSISdl::download /TIMEOUT=30000 ${demosong} $TEMP\Song-I-18.zip

Pop $R0 ;Get the return value
  StrCmp $R0 "success" dlok
    MessageBox MB_OK|MB_ICONEXCLAMATION "Download Error, click OK to Continue" /SD IDOK
dlok:
nsisunz::Unzip "$TEMP\Song-I-18.zip" "$INSTDIR\Songs\Dead Smiling Pirates - I 18 [DEMO]\"

Delete "$TEMP\Song-I-18.zip"

  SetOutPath "$INSTDIR"

SectionEnd

Section /o "Steven Dunston - Northern Star" g2Section2
  AddSize 3769
  SetOverwrite try
  SetOutPath "$INSTDIR"
  CreateDirectory "$INSTDIR\Songs\Steven Dunston - Northern Star [DEMO]"
  SetOutPath "$INSTDIR\Songs\Steven Dunston - Northern Star [DEMO]\"

; Download song:
NSISdl::download /TIMEOUT=30000 ${demosong2} $TEMP\Song-Northern-Star.zip

Pop $R0 ;Get the return value
  StrCmp $R0 "success" dlok
    MessageBox MB_OK|MB_ICONEXCLAMATION "Download Error, click OK to Continue" /SD IDOK
dlok:
nsisunz::Unzip "$TEMP\Song-Northern-Star.zip" "$INSTDIR\Songs\Steven Dunston - Northern Star [DEMO]\"

Delete "$TEMP\Song-Northern-Star.zip"

  SetOutPath "$INSTDIR"

SectionEnd

SectionGroupEnd

; ---------------------------------------------------------
; Section3: Optional Themes
; ---------------------------------------------------------

LangString DESC_Section3 ${LANG_ENGLISH} "${eng_sec3_desc}"
LangString DESC_Section3 ${LANG_GERMAN} "${ger_sec3_desc}"

LangString DESC_g1Sec1 ${LANG_ENGLISH} "${eng_g1Sec1_desc}"
LangString DESC_g1Sec1 ${LANG_GERMAN} "${ger_g1Sec1_desc}"

LangString DESC_g1Sec2 ${LANG_ENGLISH} "${eng_g1Sec2_desc}"
LangString DESC_g1Sec2 ${LANG_GERMAN} "${ger_g1Sec2_desc}"

LangString DESC_g1Sec3 ${LANG_ENGLISH} "${eng_g1Sec3_desc}"
LangString DESC_g1Sec3 ${LANG_GERMAN} "${ger_g1Sec3_desc}"

LangString sec_group ${LANG_ENGLISH} "${eng_sec3}"
LangString sec_group ${LANG_GERMAN} "${ger_sec3}"

SectionGroup $(sec_group) Section3

 Section /o "Orange" g1Sec1

; Download theme orange:
NSISdl::download /TIMEOUT=30000 ${dl_orange} $TEMP\Theme-Orange.zip

Pop $R0 ;Get the return value
  StrCmp $R0 "success" dlok
    MessageBox MB_OK|MB_ICONEXCLAMATION "Download Error, click OK to Continue" /SD IDOK
dlok:
nsisunz::Unzip "$TEMP\Theme-Orange.zip" "$INSTDIR\"

Delete "$TEMP\Theme-Orange.zip"

  SetOutPath "$INSTDIR"

SectionEnd

 Section /o "Streetlight" g1Sec2

; Download theme Streetlight:
NSISdl::download /TIMEOUT=30000 ${dl_streetlight} $TEMP\Theme-Streetlight.zip

Pop $R0 ;Get the return value
  StrCmp $R0 "success" dlok
    MessageBox MB_OK|MB_ICONEXCLAMATION "Download Error, click OK to Continue" /SD IDOK
dlok:
nsisunz::Unzip "$TEMP\Theme-Streetlight.zip" "$INSTDIR\"

Delete "$TEMP\Theme-Streetlight.zip"

  SetOutPath "$INSTDIR"

SectionEnd

 Section /o "Vistar" g1Sec3

; Download theme Vistar:
NSISdl::download /TIMEOUT=30000 ${dl_vistar} $TEMP\Theme-Vistar.zip

Pop $R0 ;Get the return value
  StrCmp $R0 "success" dlok
    MessageBox MB_OK|MB_ICONEXCLAMATION "Download Error, click OK to Continue" /SD IDOK
dlok:
nsisunz::Unzip "$TEMP\Theme-Vistar.zip" "$INSTDIR\"

Delete "$TEMP\Theme-Vistar.zip"

  SetOutPath "$INSTDIR"


SectionEnd


SectionGroupEnd

; ---------------------------------------------------------
; Section4: Uninstallation Wizard
; ---------------------------------------------------------

Section Uninstall
 !insertmacro MUI_STARTMENU_GETFOLDER "Application" $ICONS_GROUP

 !include ".\settings\optional\opt_uninstall.nsh"
 !include ".\settings\files_un.nsh"

 DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"

; Unregister from Windows Vista Game Explorer

${If} ${AtLeastWinVista}

${GameExplorer_RemoveGame} $0

${EndIf}

SectionEnd

!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
  !insertmacro MUI_DESCRIPTION_TEXT ${Section1} $(DESC_Section1)

;  !insertmacro MUI_DESCRIPTION_TEXT ${Section2} $(DESC_Section2)
;  !insertmacro MUI_DESCRIPTION_TEXT ${Section3} $(DESC_Section3)

  !insertmacro MUI_DESCRIPTION_TEXT ${g1Sec1} $(DESC_g1Sec1)
  !insertmacro MUI_DESCRIPTION_TEXT ${g1Sec2} $(DESC_g1Sec2)
  !insertmacro MUI_DESCRIPTION_TEXT ${g1Sec3} $(DESC_g1Sec3)

  !insertmacro MUI_DESCRIPTION_TEXT ${g2Section1} $(DESC_g2Section1)
  !insertmacro MUI_DESCRIPTION_TEXT ${g2Section2} $(DESC_g2Section2)

!insertmacro MUI_FUNCTION_DESCRIPTION_END

; -----------------------------------------------------------------------
; Language Strings for Installation / Uninstallation Wizard
; can be found at .\settings\langstrings.nsh
; -----------------------------------------------------------------------

!include .\settings\langstrings.nsh

; ------------------------------------------------------------------
; Functions for the beginning of the installation and uninstallation
; ------------------------------------------------------------------

; Function for Installation

Function .onInit

   System::Call 'kernel32::CreateMutexA(i 0, i 0, t "USdx Installer.exe") ?e'
 
  Pop $R0
 
  StrCmp $R0 0 +3
    MessageBox MB_OK "The installer is already running."
    Abort
  
  !insertmacro MUI_LANGDLL_DISPLAY

  ReadRegStr $R0 HKLM \
  "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \
  "UninstallString"
  StrCmp $R0 "" done
 
  MessageBox MB_YESNO|MB_ICONEXCLAMATION \
  "${PRODUCT_NAME} is already installed. $\n$\nAre you sure you want to \
  install it again?" \
  IDYES done
  Abort

  
done:

     !insertmacro MUI_INSTALLOPTIONS_EXTRACT_AS ".\settings\settings-1031.ini" "Settings-1031"
     !insertmacro MUI_INSTALLOPTIONS_EXTRACT_AS ".\settings\settings-1033.ini" "Settings-1033"

FunctionEnd

; Function for Uninstallation

Function un.onInit

	${nsProcess::FindProcess} "USdx.exe" $R0
	StrCmp $R0 0 0 +2
	MessageBox MB_YESNO|MB_ICONEXCLAMATION 'UltraStar Deluxe cannot be uninstalled while its running! Do you want to close it?' IDYES closeit IDNO end

	closeit:
	${nsProcess::KillProcess} "USdx.exe" $R0
	goto continue

	end: 
	${nsProcess::Unload}
	Abort

	continue:
   	!insertmacro MUI_LANGDLL_DISPLAY

FunctionEnd