chiark / gitweb /
replace almost all writes to yohoho log with writes to our debug log
[jarrg-ian.git] / src / winsetup.nsi
1 !include FileFunc.nsh
2 !insertmacro GetParent
3
4 Name "JARRG"
5 OutFile "jarrg-setup.exe"
6 InstallDir "$LOCALAPPDATA\JARRG"
7 RequestExecutionLevel user
8
9 var YPPDIR
10 var YPPUNINST
11 var JRE
12
13 Page directory
14 Page instfiles
15
16 UninstPage instfiles
17
18 Section ""
19 Call FindJRE
20 Call CheckYPP
21 Call CopyJRE
22 Call YPPShortcuts
23 WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\JARRG" \
24 "DisplayName" "JARRG - Java Pirate Commodity Trader with Bleach"
25 WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\JARRG" \
26 "UninstallString" "$\"$INSTDIR\uninstall-jarrg.exe$\""
27 WriteUninstaller "$INSTDIR\uninstall-jarrg.exe"
28 SectionEnd
29
30 Section "un."
31 RMDir /r $INSTDIR\jre
32 Delete $INSTDIR\uninstall-jarrg.exe
33 RMDIR $INSTDIR
34
35 Delete "$SMPROGRAMS\JARRG.lnk"
36 Delete "$SMPROGRAMS\JARRG Control Panel.lnk"
37 Delete "$DESKTOP\JARRG.lnk"
38
39 DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\JARRG"
40
41 SectionEnd
42
43 Function CheckYPP
44 ClearErrors
45 ReadRegStr $YPPUNINST HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Puzzle Pirates" "UninstallString" 
46 IfErrors 0 YPPFound
47 Abort "Couldn't find YPP installation.  Bailing out."
48 YPPFound:
49 ${GetParent} $YPPUNINST $YPPDIR
50 IfFileExists $YPPDIR\java 0 NoYPPJ15
51 Abort "YPP currently using internal Java 1.5.  You will need to uninstall Puzzle Pirates and then reinstall it before rerunning this installer."
52 NoYPPJ15:
53 IfFileExists $YPPDIR\java_vm 0 NOYPPJ16
54 Abort "YPP currently using internal Java 1.6.  You will need to uninstall Puzzle Pirates and then reinstall it before rerunning this installer."
55 NoYPPJ16:
56 DetailPrint "Found YPP in $YPPDIR"
57 FunctionEnd
58
59 Function FindJRE
60 ClearErrors
61 ReadRegStr $R1 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" "CurrentVersion"
62 ReadRegStr $R0 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment\$R1" "JavaHome"
63 IfErrors 0 JreFound
64 Abort "Couldn't find your Sun Java VM.  Bailing out."
65 JreFound:
66 StrCpy $JRE $R0
67 DetailPrint "Found Java in $JRE"
68 FunctionEnd
69
70 Function CopyJRE
71 CreateDirectory $INSTDIR\jre
72 CopyFiles $JRE\*.* $INSTDIR\jre
73 File /oname=$INSTDIR\jre\lib\ext\Jarrg-Uploader.jar Jarrg-Uploader.jar
74 File /oname=$INSTDIR\jre\lib\ext\Jarrg-ControlPanel.jar Jarrg-ControlPanel.jar
75 File /oname=$INSTDIR\jre\lib\accessibility.properties accessibility.properties
76 FunctionEnd
77
78 Function YPPShortcuts
79 SetOutPath $YPPDIR
80 CreateShortCut "$DESKTOP\JARRG.lnk" "$INSTDIR\jre\bin\javaw.exe" \
81 "-jar getdown-dop.jar ." "$YPPDIR\app_icon.ico" 0 SW_SHOWNORMAL
82 CreateShortCut "$SMPROGRAMS\JARRG.lnk" "$INSTDIR\jre\bin\javaw.exe" \
83 "-jar getdown-dop.jar ." "$YPPDIR\app_icon.ico" 0 SW_SHOWNORMAL
84 CreateShortCut "$SMPROGRAMS\JARRG Control Panel.lnk" \
85 "$INSTDIR\jre\bin\javaw.exe" "com.tedpearson.ypp.market.ControlPanel"
86 FunctionEnd