Subversion Repositories Games.Chess Giants

Rev

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

Rev Author Line No. Line
1 pmbaty 1
!include "MUI2.nsh"
2
!include "FileFunc.nsh"
3
 
4
!define PRODUCT_NAME "Chess Giants"
5
!define PUBLISHER "Pierre-Marie Baty"
6
!define PUBLISHER_WEBSITE "http://www.pmbaty.com/chess/"
7
!define INSTALLER_SRC "C:\Users\Pierre-Marie Baty\Documents\Mes projets\Chess Giants"
8
 
9
Name "${PRODUCT_NAME}"
19 pmbaty 10
BrandingText "${PRODUCT_NAME} by ${PUBLISHER} - ${PUBLISHER_WEBSITE}"
1 pmbaty 11
 
12
SetCompressor lzma
13
RequestExecutionLevel user
14
 
15
AllowRootDirInstall true
19 pmbaty 16
InstallDir "$LOCALAPPDATA\${PRODUCT_NAME}"
1 pmbaty 17
 
19 pmbaty 18
!define MUI_ICON "${INSTALLER_SRC}\resource\installer.ico"
1 pmbaty 19
!define MUI_HEADERIMAGE
19 pmbaty 20
!define MUI_HEADERIMAGE_BITMAP "${INSTALLER_SRC}\resource\installer.bmp"
1 pmbaty 21
!define MUI_ABORTWARNING
22
 
23
!insertmacro MUI_PAGE_LICENSE "${INSTALLER_SRC}\License.txt"
24
!insertmacro MUI_PAGE_DIRECTORY
76 pmbaty 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
 
1 pmbaty 94
;!insertmacro MUI_PAGE_COMPONENTS
95
!insertmacro MUI_PAGE_INSTFILES
73 pmbaty 96
AutoCloseWindow true
1 pmbaty 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
 
133 pmbaty 107
	; deploy our files
1 pmbaty 108
	File /r "${INSTALLER_SRC}\data"
44 pmbaty 109
	File /r "${INSTALLER_SRC}\engines"
1 pmbaty 110
	File /r "${INSTALLER_SRC}\helpfiles"
111
	File /r "${INSTALLER_SRC}\themes"
112
	File "${INSTALLER_SRC}\*.pgn"
113
	File "${INSTALLER_SRC}\${PRODUCT_NAME}.exe"
114
	File "${INSTALLER_SRC}\${PRODUCT_NAME}.exe.manifest"
29 pmbaty 115
	File "${INSTALLER_SRC}\Chess Giants (English).html"
116
	File "${INSTALLER_SRC}\Chess Giants (French).html"
1 pmbaty 117
	File "${INSTALLER_SRC}\config.ini"
118
	File "${INSTALLER_SRC}\materials.cfg"
119
	File "${INSTALLER_SRC}\d3dx9_42.dll"
120
	File "${INSTALLER_SRC}\msvcr90.dll"
117 pmbaty 121
	File "${INSTALLER_SRC}\openal32.dll"
118 pmbaty 122
	File "${INSTALLER_SRC}\wrap_oal.dll"
1 pmbaty 123
 
133 pmbaty 124
	; create Start menu shortcuts
1 pmbaty 125
	CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\${PRODUCT_NAME}.exe" "" "" "" "" "" "Start a chess game"
126
	CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}"
127
	CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME}.lnk" "$INSTDIR\${PRODUCT_NAME}.exe" "" "" "" "" "" "Start a chess game"
29 pmbaty 128
	CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Documentation (English).lnk" "$INSTDIR\Chess Giants (English).html" "" "" "" "" "" "Read the software documentation in English"
129
	CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Documentation (Français).lnk" "$INSTDIR\Chess Giants (French).html" "" "" "" "" "" "Read the software documentation in French"
1 pmbaty 130
 
133 pmbaty 131
	; associate .pgn files with Chess Giants
1 pmbaty 132
	WriteRegStr HKCU "Software\Classes\.pgn" "" "ChessGiantsPGN"
133
	WriteRegStr HKCU "Software\Classes\ChessGiantsPGN" "" "Portable Game Notation"
134
;	WriteRegStr HKCU "Software\Classes\ChessGiantsPGN\DefaultIcon" "" "$INSTDIR\${PRODUCT_NAME}.exe,1"
135
	WriteRegStr HKCU "Software\Classes\ChessGiantsPGN\shell\open\command" "" '"$INSTDIR\${PRODUCT_NAME}.exe" "%1"'
136
 
133 pmbaty 137
	; associate .fen files with Chess Giants
1 pmbaty 138
	WriteRegStr HKCU "Software\Classes\.fen" "" "ChessGiantsFEN"
139
	WriteRegStr HKCU "Software\Classes\ChessGiantsFEN" "" "Forsyth-Edwards Notation"
140
;	WriteRegStr HKCU "Software\Classes\ChessGiantsFEN\DefaultIcon" "" "$INSTDIR\${PRODUCT_NAME}.exe,1"
141
	WriteRegStr HKCU "Software\Classes\ChessGiantsFEN\shell\open\command" "" '"$INSTDIR\${PRODUCT_NAME}.exe" "%1"'
142
 
133 pmbaty 143
	; create a proper uninstaller
1 pmbaty 144
	WriteUninstaller $INSTDIR\uninstall.exe
145
	WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "DisplayName" "${PRODUCT_NAME}"
55 pmbaty 146
	WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "DisplayIcon" "$INSTDIR\${PRODUCT_NAME}.exe,0"
1 pmbaty 147
	WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\""
148
	WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S"
149
	WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "Publisher" "${PUBLISHER}"
150
	WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "NoModify" 1
151
	WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "NoRepair" 1
152
	${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
153
	IntFmt $0 "0x%08X" $0
154
	WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "EstimatedSize" "$0"
73 pmbaty 155
 
133 pmbaty 156
	; the program was installed successfully, start it and ask it to delete the installer by writing a little registry key
157
	WriteRegStr HKCU "Software\Chess Giants" "InstallerPath" "$EXEPATH"
73 pmbaty 158
	Exec '"$WINDIR\explorer.exe" "$INSTDIR\${PRODUCT_NAME}.exe"'
1 pmbaty 159
SectionEnd
14 pmbaty 160
 
1 pmbaty 161
Section "Uninstall"
162
	DeleteRegKey HKCU "Software\Classes\.pgn"
163
	DeleteRegKey HKCU "Software\Classes\ChessGiantsPGN"
164
	DeleteRegKey HKCU "Software\Classes\.fen"
165
	DeleteRegKey HKCU "Software\Classes\ChessGiantsFEN"
166
 
167
	Delete "$DESKTOP\${PRODUCT_NAME}.lnk"
168
	RMDir /r "$SMPROGRAMS\${PRODUCT_NAME}"
169
	RMDir /r "$INSTDIR"
170
 
171
	DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
172
SectionEnd