Subversion Repositories Games.Rick Dangerous

Rev

Rev 9 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 pmbaty 1
!include "MUI2.nsh"
2
!include "FileFunc.nsh"
3
 
4
!define PRODUCT_NAME "Rick Dangerous"
5
!define PUBLISHER "Pierre-Marie Baty"
6
!define PUBLISHER_WEBSITE "http://www.pmbaty.com/rick/"
9 pmbaty 7
!define INSTALLER_SRC "Z:\Documents\Mes projets\Rick Dangerous"
2 pmbaty 8
 
9
Name "${PRODUCT_NAME}"
10
BrandingText "${PRODUCT_NAME} by ${PUBLISHER} - ${PUBLISHER_WEBSITE}"
11
 
12
SetCompressor lzma
13
RequestExecutionLevel user
14
 
15
AllowRootDirInstall true
16
InstallDir "$LOCALAPPDATA\${PRODUCT_NAME}"
17
 
18
!define MUI_ICON "${INSTALLER_SRC}\installer\installer.ico"
19
!define MUI_HEADERIMAGE
20
!define MUI_HEADERIMAGE_BITMAP "${INSTALLER_SRC}\installer\installer.bmp"
21
!define MUI_ABORTWARNING
22
 
23
!insertmacro MUI_PAGE_LICENSE "${INSTALLER_SRC}\installer\License.txt"
24
!insertmacro MUI_PAGE_DIRECTORY
25
 
26
Var STR_HAYSTACK
27
Var STR_NEEDLE
28
Var STR_CONTAINS_VAR_1
29
Var STR_CONTAINS_VAR_2
30
Var STR_CONTAINS_VAR_3
31
Var STR_CONTAINS_VAR_4
32
Var STR_RETURN_VAR
33
 
34
Function StrContains
35
		Exch $STR_NEEDLE
36
		Exch 1
37
		Exch $STR_HAYSTACK
38
		StrCpy $STR_RETURN_VAR ""
39
		StrCpy $STR_CONTAINS_VAR_1 -1
40
		StrLen $STR_CONTAINS_VAR_2 $STR_NEEDLE
41
		StrLen $STR_CONTAINS_VAR_4 $STR_HAYSTACK
42
	loop:
43
		IntOp $STR_CONTAINS_VAR_1 $STR_CONTAINS_VAR_1 + 1
44
		StrCpy $STR_CONTAINS_VAR_3 $STR_HAYSTACK $STR_CONTAINS_VAR_2 $STR_CONTAINS_VAR_1
45
		StrCmp $STR_CONTAINS_VAR_3 $STR_NEEDLE found
46
		StrCmp $STR_CONTAINS_VAR_1 $STR_CONTAINS_VAR_4 done
47
		Goto loop
48
	found:
49
		StrCpy $STR_RETURN_VAR $STR_NEEDLE
50
		Goto done
51
	done:
52
		Pop $STR_NEEDLE
53
		Exch $STR_RETURN_VAR  
54
FunctionEnd
55
!macro _StrContainsConstructor OUT NEEDLE HAYSTACK
56
		Push `${HAYSTACK}`
57
		Push `${NEEDLE}`
58
		Call StrContains
59
		Pop `${OUT}`
60
!macroend
61
 
62
!define StrContains '!insertmacro "_StrContainsConstructor"'
63
 
64
Function .onVerifyInstDir
65
		Push $R0
66
		Push $R1
67
		${StrContains} $0 "Program Files" "$INSTDIR"
68
		StrCmp $0 "Program Files" pathbad
69
		StrCpy $R0 "$INSTDIR"
70
	loop:
71
		StrLen $R1 "$R0"
72
		StrCmp $R1 0 pathbad
73
		IfFileExists "$R0" 0 parentLoop
74
		${GetFileAttributes} "$R0" "DIRECTORY" $R1
75
		StrCmp $R1 0 parentLoop
76
		${GetFileAttributes} "$R0" "READONLY" $R1
77
		StrCmp $R1 1 pathbad
78
		ClearErrors
79
		IfFileExists "$R0\.nsis_test_dir" pathgood 0
80
		CreateDirectory "$R0\.nsis_test_dir"
81
		IfErrors pathbad 0
82
		RMDir "$R0\.nsis_test_dir"
83
		Goto pathgood
84
	parentLoop:
85
		${GetParent} "$R0" "$R0"
86
		Goto loop
87
	pathbad:
88
		Abort
89
	pathgood:
90
		Pop $R1
91
		Pop $R0
92
FunctionEnd
93
 
94
;!insertmacro MUI_PAGE_COMPONENTS
95
!insertmacro MUI_PAGE_INSTFILES
96
AutoCloseWindow true
97
 
98
!insertmacro MUI_UNPAGE_CONFIRM
99
!insertmacro MUI_UNPAGE_INSTFILES
100
 
101
!insertmacro MUI_LANGUAGE "English"
102
!insertmacro MUI_LANGUAGE "French"
103
 
104
Section ""
105
	SetOutPath "$INSTDIR"
106
 
107
	; deploy our files
108
	File /r "${INSTALLER_SRC}\sounds"
109
	File "${INSTALLER_SRC}\${PRODUCT_NAME}.exe"
9 pmbaty 110
	File "${INSTALLER_SRC}\SDL2.dll"
2 pmbaty 111
	File "${INSTALLER_SRC}\Rick Dangerous Paper Toy.pdf"
112
 
113
	; create Start menu shortcuts
114
	CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\${PRODUCT_NAME}.exe" "" "" "" "" "" "Start a Rick Dangerous game"
115
	CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}"
116
	CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME}.lnk" "$INSTDIR\${PRODUCT_NAME}.exe" "" "" "" "" "" "Start a Rick Dangerous game"
117
	CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Rick Dangerous Paper Toy.lnk" "$INSTDIR\Rick Dangerous Paper Toy.pdf" "" "" "" "" "" "Build your own Rick Dangerous 3D paper toy!"
4 pmbaty 118
	CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Online Help (incl. how to play).lnk" "http://www.pmbaty.com/rick/" "" "" "" "" "" "Visit the website to learn how to play"
2 pmbaty 119
 
120
	; create a proper uninstaller
121
	WriteUninstaller $INSTDIR\uninstall.exe
122
	WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "DisplayName" "${PRODUCT_NAME}"
123
	WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "DisplayIcon" "$INSTDIR\${PRODUCT_NAME}.exe,0"
124
	WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\""
125
	WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S"
126
	WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "Publisher" "${PUBLISHER}"
127
	WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "NoModify" 1
128
	WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "NoRepair" 1
129
	${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
130
	IntFmt $0 "0x%08X" $0
131
	WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "EstimatedSize" "$0"
132
SectionEnd
133
 
134
Section "Uninstall"
135
	Delete "$DESKTOP\${PRODUCT_NAME}.lnk"
136
	RMDir /r "$SMPROGRAMS\${PRODUCT_NAME}"
137
	RMDir /r "$INSTDIR"
138
 
139
	DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
140
SectionEnd