Rev 118 | Rev 132 | 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}" | 
        ||
| 22 | pmbaty | 10 | OutFile "C:\Users\Pierre-Marie Baty\Documents\Mes projets\www.pmbaty.com\chess\Chess Giants Installer.exe"  | 
        
| 19 | pmbaty | 11 | BrandingText "${PRODUCT_NAME} by ${PUBLISHER} - ${PUBLISHER_WEBSITE}" | 
        
| 1 | pmbaty | 12 | |
| 13 | SetCompressor lzma  | 
        ||
| 14 | RequestExecutionLevel user  | 
        ||
| 15 | |||
| 16 | AllowRootDirInstall true  | 
        ||
| 19 | pmbaty | 17 | InstallDir "$LOCALAPPDATA\${PRODUCT_NAME}" | 
        
| 1 | pmbaty | 18 | |
| 19 | pmbaty | 19 | !define MUI_ICON "${INSTALLER_SRC}\resource\installer.ico" | 
        
| 1 | pmbaty | 20 | !define MUI_HEADERIMAGE  | 
        
| 19 | pmbaty | 21 | !define MUI_HEADERIMAGE_BITMAP "${INSTALLER_SRC}\resource\installer.bmp" | 
        
| 1 | pmbaty | 22 | !define MUI_ABORTWARNING  | 
        
| 23 | |||
| 24 | !insertmacro MUI_PAGE_LICENSE "${INSTALLER_SRC}\License.txt" | 
        ||
| 25 | !insertmacro MUI_PAGE_DIRECTORY  | 
        ||
| 76 | pmbaty | 26 | |
| 27 | Var STR_HAYSTACK  | 
        ||
| 28 | Var STR_NEEDLE  | 
        ||
| 29 | Var STR_CONTAINS_VAR_1  | 
        ||
| 30 | Var STR_CONTAINS_VAR_2  | 
        ||
| 31 | Var STR_CONTAINS_VAR_3  | 
        ||
| 32 | Var STR_CONTAINS_VAR_4  | 
        ||
| 33 | Var STR_RETURN_VAR  | 
        ||
| 34 | |||
| 35 | Function StrContains  | 
        ||
| 36 | Exch $STR_NEEDLE  | 
        ||
| 37 | Exch 1  | 
        ||
| 38 | Exch $STR_HAYSTACK  | 
        ||
| 39 | StrCpy $STR_RETURN_VAR ""  | 
        ||
| 40 | StrCpy $STR_CONTAINS_VAR_1 -1  | 
        ||
| 41 | StrLen $STR_CONTAINS_VAR_2 $STR_NEEDLE  | 
        ||
| 42 | StrLen $STR_CONTAINS_VAR_4 $STR_HAYSTACK  | 
        ||
| 43 | loop:  | 
        ||
| 44 | IntOp $STR_CONTAINS_VAR_1 $STR_CONTAINS_VAR_1 + 1  | 
        ||
| 45 | StrCpy $STR_CONTAINS_VAR_3 $STR_HAYSTACK $STR_CONTAINS_VAR_2 $STR_CONTAINS_VAR_1  | 
        ||
| 46 | StrCmp $STR_CONTAINS_VAR_3 $STR_NEEDLE found  | 
        ||
| 47 | StrCmp $STR_CONTAINS_VAR_1 $STR_CONTAINS_VAR_4 done  | 
        ||
| 48 | Goto loop  | 
        ||
| 49 | found:  | 
        ||
| 50 | StrCpy $STR_RETURN_VAR $STR_NEEDLE  | 
        ||
| 51 | Goto done  | 
        ||
| 52 | done:  | 
        ||
| 53 | Pop $STR_NEEDLE  | 
        ||
| 54 | Exch $STR_RETURN_VAR  | 
        ||
| 55 | FunctionEnd  | 
        ||
| 56 | !macro _StrContainsConstructor OUT NEEDLE HAYSTACK  | 
        ||
| 57 | 		Push `${HAYSTACK}` | 
        ||
| 58 | 		Push `${NEEDLE}` | 
        ||
| 59 | Call StrContains  | 
        ||
| 60 | 		Pop `${OUT}` | 
        ||
| 61 | !macroend  | 
        ||
| 62 | |||
| 63 | !define StrContains '!insertmacro "_StrContainsConstructor"'  | 
        ||
| 64 | |||
| 65 | Function .onVerifyInstDir  | 
        ||
| 66 | Push $R0  | 
        ||
| 67 | Push $R1  | 
        ||
| 68 | 		${StrContains} $0 "Program Files" "$INSTDIR" | 
        ||
| 69 | StrCmp $0 "Program Files" pathbad  | 
        ||
| 70 | StrCpy $R0 "$INSTDIR"  | 
        ||
| 71 | loop:  | 
        ||
| 72 | StrLen $R1 "$R0"  | 
        ||
| 73 | StrCmp $R1 0 pathbad  | 
        ||
| 74 | IfFileExists "$R0" 0 parentLoop  | 
        ||
| 75 | 		${GetFileAttributes} "$R0" "DIRECTORY" $R1 | 
        ||
| 76 | StrCmp $R1 0 parentLoop  | 
        ||
| 77 | 		${GetFileAttributes} "$R0" "READONLY" $R1 | 
        ||
| 78 | StrCmp $R1 1 pathbad  | 
        ||
| 79 | ClearErrors  | 
        ||
| 80 | IfFileExists "$R0\.nsis_test_dir" pathgood 0  | 
        ||
| 81 | CreateDirectory "$R0\.nsis_test_dir"  | 
        ||
| 82 | IfErrors pathbad 0  | 
        ||
| 83 | RMDir "$R0\.nsis_test_dir"  | 
        ||
| 84 | Goto pathgood  | 
        ||
| 85 | parentLoop:  | 
        ||
| 86 | 		${GetParent} "$R0" "$R0" | 
        ||
| 87 | Goto loop  | 
        ||
| 88 | pathbad:  | 
        ||
| 89 | Abort  | 
        ||
| 90 | pathgood:  | 
        ||
| 91 | Pop $R1  | 
        ||
| 92 | Pop $R0  | 
        ||
| 93 | FunctionEnd  | 
        ||
| 94 | |||
| 1 | pmbaty | 95 | ;!insertmacro MUI_PAGE_COMPONENTS  | 
        
| 96 | !insertmacro MUI_PAGE_INSTFILES  | 
        ||
| 73 | pmbaty | 97 | AutoCloseWindow true  | 
        
| 1 | pmbaty | 98 | |
| 99 | !insertmacro MUI_UNPAGE_CONFIRM  | 
        ||
| 100 | !insertmacro MUI_UNPAGE_INSTFILES  | 
        ||
| 101 | |||
| 102 | !insertmacro MUI_LANGUAGE "English"  | 
        ||
| 103 | !insertmacro MUI_LANGUAGE "French"  | 
        ||
| 104 | |||
| 105 | Section ""  | 
        ||
| 106 | SetOutPath "$INSTDIR"  | 
        ||
| 107 | |||
| 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 | |
| 124 | 	CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\${PRODUCT_NAME}.exe" "" "" "" "" "" "Start a chess game" | 
        ||
| 125 | 	CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}" | 
        ||
| 126 | 	CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME}.lnk" "$INSTDIR\${PRODUCT_NAME}.exe" "" "" "" "" "" "Start a chess game" | 
        ||
| 29 | pmbaty | 127 | 	CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Documentation (English).lnk" "$INSTDIR\Chess Giants (English).html" "" "" "" "" "" "Read the software documentation in English" | 
        
| 128 | 	CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Documentation (Français).lnk" "$INSTDIR\Chess Giants (French).html" "" "" "" "" "" "Read the software documentation in French" | 
        ||
| 1 | pmbaty | 129 | |
| 130 | WriteRegStr HKCU "Software\Classes\.pgn" "" "ChessGiantsPGN"  | 
        ||
| 131 | WriteRegStr HKCU "Software\Classes\ChessGiantsPGN" "" "Portable Game Notation"  | 
        ||
| 132 | ;	WriteRegStr HKCU "Software\Classes\ChessGiantsPGN\DefaultIcon" "" "$INSTDIR\${PRODUCT_NAME}.exe,1" | 
        ||
| 133 | 	WriteRegStr HKCU "Software\Classes\ChessGiantsPGN\shell\open\command" "" '"$INSTDIR\${PRODUCT_NAME}.exe" "%1"' | 
        ||
| 134 | |||
| 135 | WriteRegStr HKCU "Software\Classes\.fen" "" "ChessGiantsFEN"  | 
        ||
| 136 | WriteRegStr HKCU "Software\Classes\ChessGiantsFEN" "" "Forsyth-Edwards Notation"  | 
        ||
| 137 | ;	WriteRegStr HKCU "Software\Classes\ChessGiantsFEN\DefaultIcon" "" "$INSTDIR\${PRODUCT_NAME}.exe,1" | 
        ||
| 138 | 	WriteRegStr HKCU "Software\Classes\ChessGiantsFEN\shell\open\command" "" '"$INSTDIR\${PRODUCT_NAME}.exe" "%1"' | 
        ||
| 139 | |||
| 140 | WriteUninstaller $INSTDIR\uninstall.exe  | 
        ||
| 141 | 	WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "DisplayName" "${PRODUCT_NAME}" | 
        ||
| 55 | pmbaty | 142 | 	WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "DisplayIcon" "$INSTDIR\${PRODUCT_NAME}.exe,0" | 
        
| 1 | pmbaty | 143 | 	WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\"" | 
        
| 144 | 	WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S" | 
        ||
| 145 | 	WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "Publisher" "${PUBLISHER}" | 
        ||
| 146 | 	WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "NoModify" 1 | 
        ||
| 147 | 	WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "NoRepair" 1 | 
        ||
| 148 | 	${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2 | 
        ||
| 149 | IntFmt $0 "0x%08X" $0  | 
        ||
| 150 | 	WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "EstimatedSize" "$0" | 
        ||
| 73 | pmbaty | 151 | |
| 152 | 	Exec '"$WINDIR\explorer.exe" "$INSTDIR\${PRODUCT_NAME}.exe"' | 
        ||
| 1 | pmbaty | 153 | SectionEnd  | 
        
| 14 | pmbaty | 154 | |
| 1 | pmbaty | 155 | Section "Uninstall"  | 
        
| 156 | DeleteRegKey HKCU "Software\Classes\.pgn"  | 
        ||
| 157 | DeleteRegKey HKCU "Software\Classes\ChessGiantsPGN"  | 
        ||
| 158 | DeleteRegKey HKCU "Software\Classes\.fen"  | 
        ||
| 159 | DeleteRegKey HKCU "Software\Classes\ChessGiantsFEN"  | 
        ||
| 160 | |||
| 161 | 	Delete "$DESKTOP\${PRODUCT_NAME}.lnk" | 
        ||
| 162 | 	RMDir /r "$SMPROGRAMS\${PRODUCT_NAME}" | 
        ||
| 163 | RMDir /r "$INSTDIR"  | 
        ||
| 164 | |||
| 165 | 	DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" | 
        ||
| 166 | SectionEnd  |