Rev 179 | 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_WEBSITE "http://www.pmbaty.com/chess/" |
||
192 | pmbaty | 6 | !define INSTALLER_SRC "Z:\Documents\Mes projets\Chess Giants" |
1 | pmbaty | 7 | |
8 | Name "${PRODUCT_NAME}" |
||
147 | pmbaty | 9 | BrandingText "${PRODUCT_NAME} - ${PUBLISHER_WEBSITE}" |
1 | pmbaty | 10 | |
11 | SetCompressor lzma |
||
12 | RequestExecutionLevel user |
||
13 | |||
14 | AllowRootDirInstall true |
||
19 | pmbaty | 15 | InstallDir "$LOCALAPPDATA\${PRODUCT_NAME}" |
1 | pmbaty | 16 | |
144 | pmbaty | 17 | !define MUI_ICON "${INSTALLER_SRC}\installer\installer.ico" |
1 | pmbaty | 18 | !define MUI_HEADERIMAGE |
144 | pmbaty | 19 | !define MUI_HEADERIMAGE_BITMAP "${INSTALLER_SRC}\installer\installer.bmp" |
20 | !define MUI_WELCOMEFINISHPAGE_BITMAP "${INSTALLER_SRC}\installer\finish.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 |
||
144 | pmbaty | 33 | Var LABEL_RESETCONFIG |
34 | Var CHECKBOX_RESETCONFIG |
||
76 | pmbaty | 35 | |
36 | Function StrContains |
||
37 | Exch $STR_NEEDLE |
||
38 | Exch 1 |
||
39 | Exch $STR_HAYSTACK |
||
40 | StrCpy $STR_RETURN_VAR "" |
||
41 | StrCpy $STR_CONTAINS_VAR_1 -1 |
||
42 | StrLen $STR_CONTAINS_VAR_2 $STR_NEEDLE |
||
43 | StrLen $STR_CONTAINS_VAR_4 $STR_HAYSTACK |
||
44 | loop: |
||
45 | IntOp $STR_CONTAINS_VAR_1 $STR_CONTAINS_VAR_1 + 1 |
||
46 | StrCpy $STR_CONTAINS_VAR_3 $STR_HAYSTACK $STR_CONTAINS_VAR_2 $STR_CONTAINS_VAR_1 |
||
47 | StrCmp $STR_CONTAINS_VAR_3 $STR_NEEDLE found |
||
48 | StrCmp $STR_CONTAINS_VAR_1 $STR_CONTAINS_VAR_4 done |
||
49 | Goto loop |
||
50 | found: |
||
51 | StrCpy $STR_RETURN_VAR $STR_NEEDLE |
||
52 | Goto done |
||
53 | done: |
||
54 | Pop $STR_NEEDLE |
||
55 | Exch $STR_RETURN_VAR |
||
56 | FunctionEnd |
||
57 | !macro _StrContainsConstructor OUT NEEDLE HAYSTACK |
||
58 | Push `${HAYSTACK}` |
||
59 | Push `${NEEDLE}` |
||
60 | Call StrContains |
||
61 | Pop `${OUT}` |
||
62 | !macroend |
||
63 | |||
64 | !define StrContains '!insertmacro "_StrContainsConstructor"' |
||
65 | |||
66 | Function .onVerifyInstDir |
||
67 | Push $R0 |
||
68 | Push $R1 |
||
69 | ${StrContains} $0 "Program Files" "$INSTDIR" |
||
70 | StrCmp $0 "Program Files" pathbad |
||
71 | StrCpy $R0 "$INSTDIR" |
||
72 | loop: |
||
73 | StrLen $R1 "$R0" |
||
74 | StrCmp $R1 0 pathbad |
||
75 | IfFileExists "$R0" 0 parentLoop |
||
76 | ${GetFileAttributes} "$R0" "DIRECTORY" $R1 |
||
77 | StrCmp $R1 0 parentLoop |
||
78 | ${GetFileAttributes} "$R0" "READONLY" $R1 |
||
79 | StrCmp $R1 1 pathbad |
||
80 | ClearErrors |
||
81 | IfFileExists "$R0\.nsis_test_dir" pathgood 0 |
||
82 | CreateDirectory "$R0\.nsis_test_dir" |
||
83 | IfErrors pathbad 0 |
||
84 | RMDir "$R0\.nsis_test_dir" |
||
85 | Goto pathgood |
||
86 | parentLoop: |
||
87 | ${GetParent} "$R0" "$R0" |
||
88 | Goto loop |
||
89 | pathbad: |
||
90 | Abort |
||
91 | pathgood: |
||
92 | Pop $R1 |
||
93 | Pop $R0 |
||
94 | FunctionEnd |
||
95 | |||
144 | pmbaty | 96 | Function MyFinishShow |
97 | ${NSD_CreateLabel} 120u 120u 60% 40u "If the program was previously installed, all your custom settings are preserved. If you want to reset them as well (for example, to fix a misconfiguration problem) then tick the following checkbox." |
||
98 | Pop $LABEL_RESETCONFIG |
||
99 | SetCtlColors $LABEL_RESETCONFIG "" "ffffff" |
||
100 | ${NSD_CreateCheckbox} 120u 165u 60% 10u "&Reset all program settings" |
||
101 | Pop $CHECKBOX_RESETCONFIG |
||
102 | SetCtlColors $CHECKBOX_RESETCONFIG "" "ffffff" |
||
103 | FunctionEnd |
||
104 | |||
105 | Function MyFinishLeave |
||
106 | ${NSD_GetState} $CHECKBOX_RESETCONFIG $0 |
||
107 | ${If} $0 <> 0 |
||
108 | ; if asked to, reset the configuration file |
||
109 | Delete "$INSTDIR\config.ini" |
||
110 | ${EndIf} |
||
111 | FunctionEnd |
||
112 | |||
1 | pmbaty | 113 | ;!insertmacro MUI_PAGE_COMPONENTS |
114 | !insertmacro MUI_PAGE_INSTFILES |
||
73 | pmbaty | 115 | AutoCloseWindow true |
1 | pmbaty | 116 | |
117 | !insertmacro MUI_UNPAGE_CONFIRM |
||
118 | !insertmacro MUI_UNPAGE_INSTFILES |
||
119 | |||
144 | pmbaty | 120 | !define MUI_FINISHPAGE_RUN "$INSTDIR\${PRODUCT_NAME}.exe" |
121 | !define MUI_PAGE_CUSTOMFUNCTION_SHOW MyFinishShow |
||
122 | !define MUI_PAGE_CUSTOMFUNCTION_LEAVE MyFinishLeave |
||
123 | !insertmacro MUI_PAGE_FINISH |
||
124 | |||
1 | pmbaty | 125 | !insertmacro MUI_LANGUAGE "English" |
126 | !insertmacro MUI_LANGUAGE "French" |
||
127 | |||
128 | Section "" |
||
129 | SetOutPath "$INSTDIR" |
||
130 | |||
144 | pmbaty | 131 | ; erase old files |
132 | RMDir /r "$INSTDIR\data" |
||
133 | RMDir /r "$INSTDIR\engines" |
||
134 | RMDir /r "$INSTDIR\helpfiles" |
||
135 | ; RMDir /r "$INSTDIR\themes"; -- keep user themes |
||
136 | |||
133 | pmbaty | 137 | ; deploy our files |
1 | pmbaty | 138 | File /r "${INSTALLER_SRC}\data" |
44 | pmbaty | 139 | File /r "${INSTALLER_SRC}\engines" |
1 | pmbaty | 140 | File /r "${INSTALLER_SRC}\helpfiles" |
141 | File /r "${INSTALLER_SRC}\themes" |
||
142 | File "${INSTALLER_SRC}\*.pgn" |
||
143 | File "${INSTALLER_SRC}\${PRODUCT_NAME}.exe" |
||
179 | pmbaty | 144 | ; File "${INSTALLER_SRC}\${PRODUCT_NAME}.exe.manifest" |
29 | pmbaty | 145 | File "${INSTALLER_SRC}\Chess Giants (English).html" |
146 | File "${INSTALLER_SRC}\Chess Giants (French).html" |
||
144 | pmbaty | 147 | ; File "${INSTALLER_SRC}\config.ini" -- config.ini shall be created on-the-fly |
148 | |||
1 | pmbaty | 149 | File "${INSTALLER_SRC}\materials.cfg" |
150 | File "${INSTALLER_SRC}\d3dx9_42.dll" |
||
151 | File "${INSTALLER_SRC}\msvcr90.dll" |
||
117 | pmbaty | 152 | File "${INSTALLER_SRC}\openal32.dll" |
118 | pmbaty | 153 | File "${INSTALLER_SRC}\wrap_oal.dll" |
1 | pmbaty | 154 | |
133 | pmbaty | 155 | ; create Start menu shortcuts |
1 | pmbaty | 156 | CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\${PRODUCT_NAME}.exe" "" "" "" "" "" "Start a chess game" |
157 | CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}" |
||
158 | CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME}.lnk" "$INSTDIR\${PRODUCT_NAME}.exe" "" "" "" "" "" "Start a chess game" |
||
29 | pmbaty | 159 | CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Documentation (English).lnk" "$INSTDIR\Chess Giants (English).html" "" "" "" "" "" "Read the software documentation in English" |
160 | CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Documentation (Français).lnk" "$INSTDIR\Chess Giants (French).html" "" "" "" "" "" "Read the software documentation in French" |
||
1 | pmbaty | 161 | |
133 | pmbaty | 162 | ; associate .pgn files with Chess Giants |
1 | pmbaty | 163 | WriteRegStr HKCU "Software\Classes\.pgn" "" "ChessGiantsPGN" |
164 | WriteRegStr HKCU "Software\Classes\ChessGiantsPGN" "" "Portable Game Notation" |
||
165 | ; WriteRegStr HKCU "Software\Classes\ChessGiantsPGN\DefaultIcon" "" "$INSTDIR\${PRODUCT_NAME}.exe,1" |
||
166 | WriteRegStr HKCU "Software\Classes\ChessGiantsPGN\shell\open\command" "" '"$INSTDIR\${PRODUCT_NAME}.exe" "%1"' |
||
167 | |||
133 | pmbaty | 168 | ; associate .fen files with Chess Giants |
1 | pmbaty | 169 | WriteRegStr HKCU "Software\Classes\.fen" "" "ChessGiantsFEN" |
170 | WriteRegStr HKCU "Software\Classes\ChessGiantsFEN" "" "Forsyth-Edwards Notation" |
||
171 | ; WriteRegStr HKCU "Software\Classes\ChessGiantsFEN\DefaultIcon" "" "$INSTDIR\${PRODUCT_NAME}.exe,1" |
||
172 | WriteRegStr HKCU "Software\Classes\ChessGiantsFEN\shell\open\command" "" '"$INSTDIR\${PRODUCT_NAME}.exe" "%1"' |
||
173 | |||
133 | pmbaty | 174 | ; create a proper uninstaller |
1 | pmbaty | 175 | WriteUninstaller $INSTDIR\uninstall.exe |
176 | WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "DisplayName" "${PRODUCT_NAME}" |
||
55 | pmbaty | 177 | WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "DisplayIcon" "$INSTDIR\${PRODUCT_NAME}.exe,0" |
1 | pmbaty | 178 | WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\"" |
179 | WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S" |
||
147 | pmbaty | 180 | WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "Publisher" "${PRODUCT_NAME}" |
1 | pmbaty | 181 | WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "NoModify" 1 |
182 | WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "NoRepair" 1 |
||
183 | ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2 |
||
184 | IntFmt $0 "0x%08X" $0 |
||
185 | WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "EstimatedSize" "$0" |
||
73 | pmbaty | 186 | |
144 | pmbaty | 187 | ; the program was installed successfully, ask it to delete the installer by writing a little registry key |
133 | pmbaty | 188 | WriteRegStr HKCU "Software\Chess Giants" "InstallerPath" "$EXEPATH" |
1 | pmbaty | 189 | SectionEnd |
14 | pmbaty | 190 | |
1 | pmbaty | 191 | Section "Uninstall" |
192 | DeleteRegKey HKCU "Software\Classes\.pgn" |
||
193 | DeleteRegKey HKCU "Software\Classes\ChessGiantsPGN" |
||
194 | DeleteRegKey HKCU "Software\Classes\.fen" |
||
195 | DeleteRegKey HKCU "Software\Classes\ChessGiantsFEN" |
||
196 | |||
197 | Delete "$DESKTOP\${PRODUCT_NAME}.lnk" |
||
198 | RMDir /r "$SMPROGRAMS\${PRODUCT_NAME}" |
||
199 | RMDir /r "$INSTDIR" |
||
200 | |||
201 | DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" |
||
202 | SectionEnd |