installer.nsi 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284
  1. ; Panda3D installation script for the Nullsoft Installation System (NSIS).
  2. ; Jon Parise <[email protected]>
  3. ; with Ben Johnson <[email protected]>
  4. ; with Jason Pratt <[email protected]>
  5. ; mangled by Josh Yelon <[email protected]>
  6. ; Heavily restructured by rdb
  7. ; Caller needs to define these variables:
  8. ;
  9. ; COMPRESSOR - either zlib or lzma
  10. ; TITLE - title (eg. "Panda3D SDK 1.9.0")
  11. ; INSTALLDIR - default install location (eg. "C:\Panda3D-1.9.0-x64")
  12. ; OUTFILE - where to put the output file (eg. "..\nsis-output.exe")
  13. ;
  14. ; BUILT - location of panda install tree.
  15. ; SOURCE - location of the panda source-tree if available, OR location of panda install tree.
  16. ; PYVER - version of Python that Panda was built with (ie, "2.7")
  17. ; REGVIEW - either 32 or 64, depending on the build architecture.
  18. ;
  19. Name "${TITLE}"
  20. InstallDir "${INSTALLDIR}"
  21. OutFile "${OUTFILE}"
  22. RequestExecutionLevel user
  23. SetCompress auto
  24. SetCompressor ${COMPRESSOR}
  25. !include "MUI2.nsh"
  26. !include "Sections.nsh"
  27. !include "WinMessages.nsh"
  28. !include "WordFunc.nsh"
  29. !include "x64.nsh"
  30. !define MUI_WELCOMEFINISHPAGE_BITMAP "panda-install.bmp"
  31. !define MUI_UNWELCOMEFINISHPAGE_BITMAP "panda-install.bmp"
  32. !define MUI_ABORTWARNING
  33. !define MUI_FINISHPAGE_NOREBOOTSUPPORT
  34. !define MUI_FINISHPAGE_RUN
  35. !define MUI_FINISHPAGE_RUN_FUNCTION runFunction
  36. !define MUI_FINISHPAGE_RUN_TEXT "Visit the Panda3D Manual"
  37. !insertmacro MUI_PAGE_WELCOME
  38. !insertmacro MUI_PAGE_LICENSE "${SOURCE}/doc/LICENSE"
  39. !insertmacro MUI_PAGE_DIRECTORY
  40. !define MUI_PAGE_CUSTOMFUNCTION_LEAVE ConfirmPythonSelection
  41. !insertmacro MUI_PAGE_COMPONENTS
  42. !insertmacro MUI_PAGE_INSTFILES
  43. !insertmacro MUI_PAGE_FINISH
  44. !insertmacro MUI_UNPAGE_WELCOME
  45. !insertmacro MUI_UNPAGE_CONFIRM
  46. !insertmacro MUI_UNPAGE_INSTFILES
  47. !insertmacro MUI_UNPAGE_FINISH
  48. !insertmacro MUI_LANGUAGE "English"
  49. ShowInstDetails hide
  50. ShowUninstDetails hide
  51. LicenseData "${SOURCE}/doc/LICENSE"
  52. InstType "Full (Recommended)"
  53. InstType "Minimal"
  54. LangString DESC_SecCore ${LANG_ENGLISH} "The Panda3D core libraries, configuration files and models/textures that are needed to use Panda3D."
  55. LangString DESC_SecOpenGL ${LANG_ENGLISH} "The OpenGL graphics back-end is the most well-supported renderer."
  56. LangString DESC_SecDirect3D9 ${LANG_ENGLISH} "The optional Direct3D 9 renderer."
  57. LangString DESC_SecOpenAL ${LANG_ENGLISH} "Support for playing audio via the OpenAL library. You need either OpenAL or FMOD to be able to play audio."
  58. LangString DESC_SecFMOD ${LANG_ENGLISH} "Support for decoding and playing audio via the FMOD Ex library. You need either OpenAL or FMOD to be able to play audio."
  59. LangString DESC_SecFFMpeg ${LANG_ENGLISH} "Support for decoding video and audio via the FFMpeg library. Without this option, Panda3D will only be able to play .wav and .ogg audio files."
  60. LangString DESC_SecBullet ${LANG_ENGLISH} "Support for the Bullet physics engine."
  61. LangString DESC_SecODE ${LANG_ENGLISH} "Support for the Open Dynamics Engine to implement physics."
  62. LangString DESC_SecPhysX ${LANG_ENGLISH} "Support for NVIDIA PhysX to implement physics."
  63. LangString DESC_SecRocket ${LANG_ENGLISH} "Support for the libRocket GUI library. This is an optional library that offers an HTML/CSS-like approach to creating user interfaces."
  64. LangString DESC_SecTools ${LANG_ENGLISH} "Useful tools and model converters to help with Panda3D development. Recommended."
  65. LangString DESC_SecPyBindings ${LANG_ENGLISH} "Contains the Python modules that allow use of Panda3D using Python. These will only work with a ${REGVIEW}-bit version of Python ${PYVER}."
  66. LangString DESC_SecPython ${LANG_ENGLISH} "Contains a ${REGVIEW}-bit copy of Python ${PYVER} preconfigured to make use of Panda3D."
  67. LangString DESC_SecHeadersLibs ${LANG_ENGLISH} "Headers and libraries needed for C++ development with Panda3D."
  68. LangString DESC_SecSamples ${LANG_ENGLISH} "The sample programs demonstrate how to make Python applications with Panda3D."
  69. LangString DESC_SecMaxPlugins ${LANG_ENGLISH} "Plug-ins for Autodesk 3ds Max (${REGVIEW}-bit) that can be used to export models to Panda3D."
  70. LangString DESC_SecMayaPlugins ${LANG_ENGLISH} "Plug-ins and scripts for Autodesk Maya (${REGVIEW}-bit) that can be used to export models to Panda3D."
  71. var READABLE
  72. var MANPAGE
  73. ; See http://nsis.sourceforge.net/Check_if_a_file_exists_at_compile_time for documentation
  74. !macro !defineifexist _VAR_NAME _FILE_NAME
  75. !tempfile _TEMPFILE
  76. !ifdef NSIS_WIN32_MAKENSIS
  77. ; Windows - cmd.exe
  78. !system 'if exist "${_FILE_NAME}" echo !define ${_VAR_NAME} > "${_TEMPFILE}"'
  79. !else
  80. ; Posix - sh
  81. !system 'if [ -e "${_FILE_NAME}" ]; then echo "!define ${_VAR_NAME}" > "${_TEMPFILE}"; fi'
  82. !endif
  83. !include '${_TEMPFILE}'
  84. !delfile '${_TEMPFILE}'
  85. !undef _TEMPFILE
  86. !macroend
  87. !insertmacro !defineifexist HAVE_GL "${BUILT}\bin\libpandagl.dll"
  88. !insertmacro !defineifexist HAVE_DX9 "${BUILT}\bin\libpandadx9.dll"
  89. !insertmacro !defineifexist HAVE_OPENAL "${BUILT}\bin\libp3openal_audio.dll"
  90. !insertmacro !defineifexist HAVE_FMOD "${BUILT}\bin\libp3fmod_audio.dll"
  91. !insertmacro !defineifexist HAVE_FFMPEG "${BUILT}\bin\libp3ffmpeg.dll"
  92. !insertmacro !defineifexist HAVE_BULLET "${BUILT}\bin\libpandabullet.dll"
  93. !insertmacro !defineifexist HAVE_ODE "${BUILT}\bin\libpandaode.dll"
  94. !insertmacro !defineifexist HAVE_PHYSX "${BUILT}\bin\libpandaphysx.dll"
  95. !insertmacro !defineifexist HAVE_ROCKET "${BUILT}\bin\libp3rocket.dll"
  96. !insertmacro !defineifexist HAVE_PYTHON "${BUILT}\python"
  97. !insertmacro !defineifexist HAVE_SAMPLES "${SOURCE}\samples"
  98. !insertmacro !defineifexist HAVE_MAX_PLUGINS "${BUILT}\plugins\*.dlo"
  99. !insertmacro !defineifexist HAVE_MAYA_PLUGINS "${BUILT}\plugins\*.mll"
  100. Function runFunction
  101. ExecShell "open" "$SMPROGRAMS\${TITLE}\Panda3D Manual.lnk"
  102. FunctionEnd
  103. Function .onInit
  104. ${If} ${REGVIEW} = 64
  105. ${AndIfNot} ${RunningX64}
  106. MessageBox MB_OK|MB_ICONEXCLAMATION "You are attempting to install the 64-bit version of Panda3D on a 32-bit version of Windows. Please download and install the 32-bit version of Panda3D instead."
  107. Abort
  108. ${EndIf}
  109. FunctionEnd
  110. SectionGroup "Panda3D Libraries"
  111. Section "Core Libraries" SecCore
  112. SectionIn 1 2 RO
  113. SetShellVarContext current
  114. SetOverwrite try
  115. SetDetailsPrint both
  116. DetailPrint "Installing Panda3D libraries..."
  117. SetDetailsPrint listonly
  118. SetOutPath "$INSTDIR"
  119. File /nonfatal "${BUILT}\LICENSE"
  120. File /nonfatal "${BUILT}\ReleaseNotes"
  121. File /nonfatal "${BUILT}\pandaIcon.ico"
  122. SetOutPath $INSTDIR\etc
  123. File /r "${BUILT}\etc\*"
  124. SetOutPath $INSTDIR\bin
  125. File /r /x api-ms-win-*.dll /x ucrtbase.dll /x libpandagl.dll /x libpandadx9.dll /x cgD3D*.dll /x python*.dll /x libpandaode.dll /x libp3fmod_audio.dll /x fmodex*.dll /x libp3ffmpeg.dll /x av*.dll /x postproc*.dll /x swscale*.dll /x swresample*.dll /x NxCharacter*.dll /x cudart*.dll /x PhysX*.dll /x libpandaphysx.dll /x libp3rocket.dll /x boost_python*.dll /x Rocket*.dll /x _rocket*.pyd /x libpandabullet.dll /x OpenAL32.dll /x *_oal.dll /x libp3openal_audio.dll "${BUILT}\bin\*.dll"
  126. File /nonfatal /r "${BUILT}\bin\Microsoft.*.manifest"
  127. ; Before Windows 10, we need these stubs for the UCRT as well.
  128. ReadRegDWORD $0 HKLM "Software\Microsoft\Windows NT\CurrentVersion" "CurrentMajorVersionNumber"
  129. ${If} $0 < 10
  130. ClearErrors
  131. File /nonfatal /r "${BUILT}\bin\api-ms-win-*.dll"
  132. File /nonfatal "${BUILT}\bin\ucrtbase.dll"
  133. ${Endif}
  134. SetDetailsPrint both
  135. DetailPrint "Installing models..."
  136. SetDetailsPrint listonly
  137. SetOutPath $INSTDIR\models
  138. File /r /x CVS "${BUILT}\models\*"
  139. SetDetailsPrint both
  140. DetailPrint "Installing optional components..."
  141. SetDetailsPrint listonly
  142. RMDir /r "$SMPROGRAMS\${TITLE}"
  143. CreateDirectory "$SMPROGRAMS\${TITLE}"
  144. SectionEnd
  145. !ifdef HAVE_GL
  146. Section "OpenGL" SecOpenGL
  147. SectionIn 1 2 RO
  148. SetOutPath "$INSTDIR\bin"
  149. File "${BUILT}\bin\libpandagl.dll"
  150. SectionEnd
  151. !endif
  152. !ifdef HAVE_DX9
  153. Section "Direct3D 9" SecDirect3D9
  154. SectionIn 1
  155. SetOutPath "$INSTDIR\bin"
  156. File "${BUILT}\bin\libpandadx9.dll"
  157. File /nonfatal /r "${BUILT}\bin\cgD3D9.dll"
  158. SectionEnd
  159. !endif
  160. !ifdef HAVE_OPENAL
  161. Section "OpenAL Audio" SecOpenAL
  162. SectionIn 1 2
  163. SetOutPath "$INSTDIR\bin"
  164. File "${BUILT}\bin\libp3openal_audio.dll"
  165. File /nonfatal /r "${BUILT}\bin\OpenAL32.dll"
  166. File /nonfatal /r "${BUILT}\bin\*_oal.dll"
  167. SectionEnd
  168. !endif
  169. !ifdef HAVE_FMOD
  170. Section "FMOD Audio" SecFMOD
  171. SectionIn 1
  172. SetOutPath "$INSTDIR\bin"
  173. File "${BUILT}\bin\libp3fmod_audio.dll"
  174. File /r "${BUILT}\bin\fmodex*.dll"
  175. SectionEnd
  176. !endif
  177. !ifdef HAVE_FFMPEG
  178. Section "FFMpeg" SecFFMpeg
  179. SectionIn 1
  180. SetOutPath "$INSTDIR\bin"
  181. File "${BUILT}\bin\libp3ffmpeg.dll"
  182. File /nonfatal /r "${BUILT}\bin\av*.dll"
  183. File /nonfatal /r "${BUILT}\bin\swscale*.dll"
  184. File /nonfatal /r "${BUILT}\bin\swresample*.dll"
  185. File /nonfatal /r "${BUILT}\bin\postproc*.dll"
  186. SectionEnd
  187. !endif
  188. !ifdef HAVE_BULLET
  189. Section "Bullet Physics" SecBullet
  190. SectionIn 1
  191. SetOutPath "$INSTDIR\bin"
  192. File "${BUILT}\bin\libpandabullet.dll"
  193. SectionEnd
  194. !endif
  195. !ifdef HAVE_ODE
  196. Section "ODE Physics" SecODE
  197. SectionIn 1
  198. SetOutPath "$INSTDIR\bin"
  199. File "${BUILT}\bin\libpandaode.dll"
  200. SectionEnd
  201. !endif
  202. !ifdef HAVE_PHYSX
  203. Section "NVIDIA PhysX" SecPhysX
  204. SectionIn 1
  205. SetOutPath "$INSTDIR\bin"
  206. File "${BUILT}\bin\libpandaphysx.dll"
  207. File /nonfatal /r "${BUILT}\bin\PhysX*.dll"
  208. File /nonfatal /r "${BUILT}\bin\NxCharacter*.dll"
  209. File /nonfatal /r "${BUILT}\bin\cudart*.dll"
  210. SectionEnd
  211. !endif
  212. !ifdef HAVE_ROCKET
  213. Section "libRocket GUI" SecRocket
  214. SectionIn 1
  215. SetOutPath "$INSTDIR\bin"
  216. File "${BUILT}\bin\libp3rocket.dll"
  217. File /nonfatal /r "${BUILT}\bin\Rocket*.dll"
  218. File /nonfatal /r "${BUILT}\bin\_rocket*.pyd"
  219. File /nonfatal /r "${BUILT}\bin\boost_python*.dll"
  220. SectionEnd
  221. !endif
  222. SectionGroupEnd
  223. Section "Tools and utilities" SecTools
  224. SectionIn 1 2
  225. SetDetailsPrint both
  226. DetailPrint "Installing utilities..."
  227. SetDetailsPrint listonly
  228. SetOutPath "$INSTDIR\bin"
  229. File /r "${BUILT}\bin\*.exe"
  230. File /nonfatal /r "${BUILT}\bin\*.p3d"
  231. SetOutPath "$INSTDIR\NSIS"
  232. File /r /x CVS "${NSISDIR}\*"
  233. WriteRegStr HKCU "Software\Classes\Panda3D.Model" "" "Panda3D model/animation"
  234. WriteRegStr HKCU "Software\Classes\Panda3D.Model\DefaultIcon" "" "$INSTDIR\bin\pview.exe"
  235. WriteRegStr HKCU "Software\Classes\Panda3D.Model\shell" "" "open"
  236. WriteRegStr HKCU "Software\Classes\Panda3D.Model\shell\open\command" "" '"$INSTDIR\bin\pview.exe" -l "%1"'
  237. WriteRegStr HKCU "Software\Classes\Panda3D.Model\shell\compress" "" "Compress to .pz"
  238. WriteRegStr HKCU "Software\Classes\Panda3D.Model\shell\compress\command" "" '"$INSTDIR\bin\pzip.exe" "%1"'
  239. WriteRegStr HKCU "Software\Classes\Panda3D.Compressed" "" "Compressed file"
  240. WriteRegStr HKCU "Software\Classes\Panda3D.Compressed\DefaultIcon" "" "$INSTDIR\bin\pzip.exe"
  241. WriteRegStr HKCU "Software\Classes\Panda3D.Compressed\shell" "" "open"
  242. WriteRegStr HKCU "Software\Classes\Panda3D.Compressed\shell\open\command" "" '"$INSTDIR\bin\pview.exe" -l "%1"'
  243. WriteRegStr HKCU "Software\Classes\Panda3D.Compressed\shell\decompress" "" "Decompress"
  244. WriteRegStr HKCU "Software\Classes\Panda3D.Compressed\shell\decompress\command" "" '"$INSTDIR\bin\punzip.exe" "%1"'
  245. WriteRegStr HKCU "Software\Classes\Panda3D.Multifile" "" "Panda3D Multifile"
  246. WriteRegStr HKCU "Software\Classes\Panda3D.Multifile\DefaultIcon" "" "$INSTDIR\bin\multify.exe"
  247. WriteRegStr HKCU "Software\Classes\Panda3D.Multifile\shell" "" "open"
  248. WriteRegStr HKCU "Software\Classes\Panda3D.Multifile\shell\extract" "" "Extract here"
  249. WriteRegStr HKCU "Software\Classes\Panda3D.Multifile\shell\extract\command" "" '"$INSTDIR\bin\multify.exe" -xf "%1"'
  250. SectionEnd
  251. SectionGroup "Python support"
  252. Section "Python bindings" SecPyBindings
  253. SectionIn 1 2
  254. SetDetailsPrint both
  255. DetailPrint "Installing Panda3D Python modules..."
  256. SetDetailsPrint listonly
  257. SetOutPath "$INSTDIR\bin"
  258. File /nonfatal /r "${BUILT}\bin\*.pyd"
  259. SetOutPath $INSTDIR\direct\directscripts
  260. File /r /x CVS /x Opt?-Win32 "${BUILT}\direct\directscripts\*"
  261. SetOutPath $INSTDIR\direct\filter
  262. File /r /x CVS /x Opt?-Win32 "${BUILT}\direct\filter\*.sha"
  263. SetOutPath $INSTDIR\direct
  264. File /r /x CVS /x Opt?-Win32 "${BUILT}\direct\*.py"
  265. Delete "$INSTDIR\panda3d.py"
  266. Delete "$INSTDIR\panda3d.pyc"
  267. Delete "$INSTDIR\panda3d.pyo"
  268. SetOutPath $INSTDIR\pandac
  269. File /r "${BUILT}\pandac\*.py"
  270. SetOutPath $INSTDIR\panda3d
  271. File /r "${BUILT}\panda3d\*.py"
  272. File /r /x bullet.pyd /x ode.pyd /x physx.pyd /x rocket.pyd "${BUILT}\panda3d\*.pyd"
  273. !ifdef HAVE_BULLET
  274. SectionGetFlags ${SecBullet} $R0
  275. IntOp $R0 $R0 & ${SF_SELECTED}
  276. StrCmp $R0 ${SF_SELECTED} 0 SkipBulletPyd
  277. File /nonfatal /r "${BUILT}\panda3d\bullet.pyd"
  278. SkipBulletPyd:
  279. !endif
  280. !ifdef HAVE_ODE
  281. SectionGetFlags ${SecODE} $R0
  282. IntOp $R0 $R0 & ${SF_SELECTED}
  283. StrCmp $R0 ${SF_SELECTED} 0 SkipODEPyd
  284. File /nonfatal /r "${BUILT}\panda3d\ode.pyd"
  285. SkipODEPyd:
  286. !endif
  287. !ifdef HAVE_PHYSX
  288. SectionGetFlags ${SecPhysX} $R0
  289. IntOp $R0 $R0 & ${SF_SELECTED}
  290. StrCmp $R0 ${SF_SELECTED} 0 SkipPhysXPyd
  291. File /nonfatal /r "${BUILT}\panda3d\physx.pyd"
  292. SkipPhysXPyd:
  293. !endif
  294. !ifdef HAVE_ROCKET
  295. SectionGetFlags ${SecRocket} $R0
  296. IntOp $R0 $R0 & ${SF_SELECTED}
  297. StrCmp $R0 ${SF_SELECTED} 0 SkipRocketPyd
  298. File /nonfatal /r "${BUILT}\panda3d\rocket.pyd"
  299. SkipRocketPyd:
  300. !endif
  301. SetOutPath $INSTDIR\pandac\input
  302. File /r "${BUILT}\pandac\input\*"
  303. SetOutPath $INSTDIR\Pmw
  304. File /r /x CVS "${BUILT}\Pmw\*"
  305. !ifdef REGVIEW
  306. SetRegView ${REGVIEW}
  307. !endif
  308. ; Check for a system-wide Python installation.
  309. ; We could check for a user installation of Python as well, but there
  310. ; is no distinction between 64-bit and 32-bit regviews in HKCU, so we
  311. ; can't guess whether it might be a compatible version.
  312. ReadRegStr $0 HKLM "Software\Python\PythonCore\${PYVER}\InstallPath" ""
  313. StrCmp $0 "$INSTDIR\python" SkipExternalPth 0
  314. StrCmp $0 "" SkipExternalPth 0
  315. IfFileExists "$0\ppython.exe" SkipExternalPth 0
  316. IfFileExists "$0\python.exe" 0 SkipExternalPth
  317. ; We're pretty sure this Python build is of the right architecture.
  318. MessageBox MB_YESNO|MB_ICONQUESTION \
  319. "Your system already has a copy of Python ${PYVER} installed in:$\r$\n$0$\r$\nWould you like to configure it to be able to use the Panda3D libraries?$\r$\nIf you choose no, you will only be able to use Panda3D's own copy of Python." \
  320. IDYES WriteExternalPth IDNO SkipExternalPth
  321. WriteExternalPth:
  322. FileOpen $1 "$0\Lib\site-packages\panda.pth" w
  323. FileWrite $1 "$INSTDIR$\r$\n"
  324. FileWrite $1 "$INSTDIR\bin$\r$\n"
  325. FileClose $1
  326. SkipExternalPth:
  327. SectionEnd
  328. !ifdef HAVE_PYTHON
  329. Section "Python ${PYVER}" SecPython
  330. SectionIn 1 2
  331. !ifdef REGVIEW
  332. SetRegView ${REGVIEW}
  333. !endif
  334. SetDetailsPrint both
  335. DetailPrint "Installing Python ${PYVER} (${REGVIEW}-bit)..."
  336. SetDetailsPrint listonly
  337. SetOutPath "$INSTDIR\bin"
  338. File /nonfatal "${BUILT}\bin\python*.dll"
  339. SetOutPath "$INSTDIR\python"
  340. File /r /x *.pdb "${BUILT}\python\*"
  341. SetDetailsPrint both
  342. DetailPrint "Adding registry keys for Python..."
  343. SetDetailsPrint listonly
  344. ; Check if a copy of Python is installed for this user.
  345. ReadRegStr $0 HKCU "Software\Python\PythonCore\${PYVER}\InstallPath" ""
  346. StrCmp "$0" "$INSTDIR\python" RegPath 0
  347. StrCmp "$0" "" SkipFileCheck 0
  348. IfFileExists "$0\python.exe" AskRegPath 0
  349. SkipFileCheck:
  350. ; Check if a system-wide copy of Python is installed.
  351. ReadRegStr $0 HKLM "Software\Python\PythonCore\${PYVER}\InstallPath" ""
  352. StrCmp "$0" "$INSTDIR\python" RegPath 0
  353. StrCmp "$0" "" RegPath 0
  354. IfFileExists "$0\python.exe" AskRegPath RegPath
  355. AskRegPath:
  356. MessageBox MB_YESNO|MB_ICONQUESTION \
  357. "You already have a copy of Python ${PYVER} installed in:$\r$\n$0$\r$\n$\r$\nPanda3D installs its own copy of Python ${PYVER}, which will install alongside your existing copy. Would you like to make Panda's copy the default Python for your user account?" \
  358. IDNO SkipRegPath
  359. RegPath:
  360. WriteRegStr HKCU "Software\Python\PythonCore\${PYVER}\InstallPath" "" "$INSTDIR\python"
  361. SkipRegPath:
  362. SectionEnd
  363. !endif
  364. SectionGroupEnd
  365. Function ConfirmPythonSelection
  366. ; Check the current state of the "Python" section selection.
  367. SectionGetFlags ${SecPython} $R0
  368. IntOp $R1 $R0 & ${SF_SELECTED}
  369. ; Is the "Python" selection deselected?
  370. StrCmp $R1 ${SF_SELECTED} SkipCheck 0
  371. ; Maybe the user just doesn't want Python support at all?
  372. SectionGetFlags ${SecPyBindings} $R1
  373. IntOp $R1 $R1 & ${SF_SELECTED}
  374. StrCmp $R1 ${SF_SELECTED} 0 SkipCheck
  375. !ifdef REGVIEW
  376. SetRegView ${REGVIEW}
  377. !endif
  378. ; Check for a user installation of Python.
  379. ReadRegStr $0 HKCU "Software\Python\PythonCore\${PYVER}\InstallPath" ""
  380. StrCmp $0 "$INSTDIR\python" CheckSystemWidePython 0
  381. StrCmp $0 "" CheckSystemWidePython 0
  382. IfFileExists "$0\ppython.exe" CheckSystemWidePython 0
  383. IfFileExists "$0\python.exe" SkipCheck CheckSystemWidePython
  384. ; Check for a system-wide Python installation.
  385. CheckSystemWidePython:
  386. ReadRegStr $0 HKLM "Software\Python\PythonCore\${PYVER}\InstallPath" ""
  387. StrCmp $0 "$INSTDIR\python" AskConfirmation 0
  388. StrCmp $0 "" AskConfirmation 0
  389. IfFileExists "$0\ppython.exe" AskConfirmation 0
  390. IfFileExists "$0\python.exe" SkipCheck AskConfirmation
  391. ; No compatible Python version found (that wasn't shipped as part
  392. ; of a different Panda3D build.) Ask the user if he's sure about this.
  393. AskConfirmation:
  394. MessageBox MB_YESNO|MB_ICONQUESTION \
  395. "You do not appear to have a ${REGVIEW}-bit version of Python ${PYVER} installed. Are you sure you don't want Panda to install a compatible copy of Python?$\r$\n$\r$\nIf you choose Yes, you will not be able to do Python development with Panda3D until you install a ${REGVIEW}-bit version of Python ${PYVER} and manually configure it to be able to use Panda3D." \
  396. IDYES SkipCheck
  397. ; User clicked no, so re-enable the select box and abort.
  398. IntOp $R0 $R0 | ${SF_SELECTED}
  399. SectionSetFlags ${SecPython} $R0
  400. Abort
  401. SkipCheck:
  402. FunctionEnd
  403. Section "C++ support" SecHeadersLibs
  404. SectionIn 1
  405. SetDetailsPrint both
  406. DetailPrint "Installing header files..."
  407. SetDetailsPrint listonly
  408. SetOutPath $INSTDIR\include
  409. File /r /x *.exp "${BUILT}\include\*"
  410. SetDetailsPrint both
  411. DetailPrint "Installing library archives..."
  412. SetDetailsPrint listonly
  413. SetOutPath $INSTDIR\lib
  414. File /r /x *.exp "${BUILT}\lib\*"
  415. SectionEnd
  416. !ifdef HAVE_SAMPLES
  417. Section "Sample programs" SecSamples
  418. SectionIn 1
  419. ; Necessary for proper start menu shortcut installation
  420. SetShellVarContext current
  421. SetDetailsPrint both
  422. DetailPrint "Installing sample programs..."
  423. SetDetailsPrint listonly
  424. SetOutPath $INSTDIR\samples
  425. File /nonfatal /r /x CVS "${SOURCE}\samples\*"
  426. SetDetailsPrint both
  427. DetailPrint "Creating shortcuts..."
  428. SetDetailsPrint listonly
  429. SetOutPath $INSTDIR
  430. WriteINIStr $INSTDIR\Website.url "InternetShortcut" "URL" "https://www.panda3d.org/"
  431. WriteINIStr $INSTDIR\Manual.url "InternetShortcut" "URL" "https://www.panda3d.org/manual/index.php"
  432. WriteINIStr $INSTDIR\Samples.url "InternetShortcut" "URL" "https://www.panda3d.org/manual/index.php/Sample_Programs_in_the_Distribution"
  433. SetOutPath $INSTDIR
  434. CreateShortCut "$SMPROGRAMS\${TITLE}\Panda3D Manual.lnk" "$INSTDIR\Manual.url" "" "$INSTDIR\pandaIcon.ico" 0 "" "" "Panda3D Manual"
  435. CreateShortCut "$SMPROGRAMS\${TITLE}\Panda3D Website.lnk" "$INSTDIR\Website.url" "" "$INSTDIR\pandaIcon.ico" 0 "" "" "Panda3D Website"
  436. CreateShortCut "$SMPROGRAMS\${TITLE}\Sample Program Manual.lnk" "$INSTDIR\Samples.url" "" "$INSTDIR\pandaIcon.ico" 0 "" "" "Sample Program Manual"
  437. FindFirst $0 $1 $INSTDIR\samples\*
  438. loop:
  439. StrCmp $1 "" done
  440. StrCmp $1 "." next
  441. StrCmp $1 ".." next
  442. FindFirst $2 $3 $INSTDIR\samples\$1\*.py
  443. StrCmp $3 "" next
  444. Push $1
  445. Push "-"
  446. Push " "
  447. Call StrRep
  448. Call Capitalize
  449. Pop $R0
  450. StrCpy $READABLE $R0
  451. Push $1
  452. Push "-"
  453. Push "_"
  454. Call StrRep
  455. Pop $R0
  456. StrCpy $MANPAGE $R0
  457. DetailPrint "Creating shortcuts for sample program $READABLE"
  458. CreateDirectory "$SMPROGRAMS\${TITLE}\Sample Programs\$READABLE"
  459. SetOutPath $INSTDIR\samples\$1
  460. WriteINIStr $INSTDIR\samples\$1\ManualPage.url "InternetShortcut" "URL" "https://www.panda3d.org/wiki/index.php/Sample_Programs:_$MANPAGE"
  461. CreateShortCut "$SMPROGRAMS\${TITLE}\Sample Programs\$READABLE\Manual Page.lnk" "$INSTDIR\samples\$1\ManualPage.url" "" "$INSTDIR\pandaIcon.ico" 0 "" "" "Manual Entry on this Sample Program"
  462. CreateShortCut "$SMPROGRAMS\${TITLE}\Sample Programs\$READABLE\View Source Code.lnk" "$INSTDIR\samples\$1"
  463. iloop:
  464. StrCmp $3 "" idone
  465. CreateShortCut "$SMPROGRAMS\${TITLE}\Sample Programs\$READABLE\Run $3.lnk" "$INSTDIR\python\python.exe" "-E $3" "$INSTDIR\pandaIcon.ico" 0 SW_SHOWMINIMIZED "" "Run $3"
  466. CreateShortCut "$INSTDIR\samples\$1\Run $3.lnk" "$INSTDIR\python\python.exe" "-E $3" "$INSTDIR\pandaIcon.ico" 0 SW_SHOWMINIMIZED "" "Run $3"
  467. FindNext $2 $3
  468. goto iloop
  469. idone:
  470. next:
  471. FindNext $0 $1
  472. Goto loop
  473. done:
  474. SectionEnd
  475. !endif
  476. !ifdef HAVE_MAX_PLUGINS
  477. Section "3ds Max plug-ins" SecMaxPlugins
  478. SectionIn 1 3
  479. SetDetailsPrint both
  480. DetailPrint "Installing Autodesk 3ds Max plug-ins..."
  481. SetDetailsPrint listonly
  482. SetOutPath $INSTDIR\plugins
  483. File /nonfatal /r "${BUILT}\plugins\*.dle"
  484. File /nonfatal /r "${BUILT}\plugins\*.dlo"
  485. File /nonfatal /r "${BUILT}\plugins\*.ms"
  486. File "${SOURCE}\doc\INSTALLING-PLUGINS.TXT"
  487. SectionEnd
  488. !endif
  489. !ifdef HAVE_MAYA_PLUGINS
  490. Section "Maya plug-ins" SecMayaPlugins
  491. SectionIn 1 3
  492. SetDetailsPrint both
  493. DetailPrint "Installing Autodesk Maya plug-ins..."
  494. SetDetailsPrint listonly
  495. SetOutPath $INSTDIR\plugins
  496. File /nonfatal /r "${BUILT}\plugins\*.mll"
  497. File /nonfatal /r "${BUILT}\plugins\*.mel"
  498. File "${SOURCE}\doc\INSTALLING-PLUGINS.TXT"
  499. SectionEnd
  500. !endif
  501. Section -post
  502. !ifdef REGVIEW
  503. SetRegView ${REGVIEW}
  504. !endif
  505. ; Run eggcacher. We can't do this in SecCore because we haven't
  506. ; installed eggcacher at that point yet.
  507. SetDetailsPrint both
  508. DetailPrint "Preloading .egg files into the model cache..."
  509. SetDetailsPrint listonly
  510. SetOutPath $INSTDIR
  511. nsExec::ExecToLog '"$INSTDIR\python\python.exe" -m direct.directscripts.eggcacher --concise models samples'
  512. Pop $0
  513. DetailPrint "Command returned exit status $0"
  514. SetDetailsPrint both
  515. DetailPrint "Writing the uninstaller ..."
  516. SetDetailsPrint listonly
  517. Delete "$INSTDIR\uninst.exe"
  518. WriteUninstaller "$INSTDIR\uninst.exe"
  519. WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${TITLE}" "DisplayName" "${TITLE}"
  520. WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${TITLE}" "UninstallString" '"$INSTDIR\uninst.exe"'
  521. SetOutPath $INSTDIR
  522. CreateShortcut "$SMPROGRAMS\${TITLE}\Uninstall ${TITLE}.lnk" "$INSTDIR\uninst.exe" ""
  523. SetDetailsPrint both
  524. DetailPrint "Registering file type associations..."
  525. SetDetailsPrint listonly
  526. ; Even though we need the runtime to run these, we might as well tell
  527. ; Windows what this kind of file is.
  528. WriteRegStr HKCU "Software\Classes\.p3d" "" "Panda3D applet"
  529. WriteRegStr HKCU "Software\Classes\.p3d" "Content Type" "application/x-panda3d"
  530. WriteRegStr HKCU "Software\Classes\.p3d" "PerceivedType" "application"
  531. ; Register various model files
  532. WriteRegStr HKCU "Software\Classes\.egg" "" "Panda3D.Model"
  533. WriteRegStr HKCU "Software\Classes\.egg" "Content Type" "application/x-egg"
  534. WriteRegStr HKCU "Software\Classes\.egg" "PerceivedType" "gamemedia"
  535. WriteRegStr HKCU "Software\Classes\.bam" "" "Panda3D.Model"
  536. WriteRegStr HKCU "Software\Classes\.bam" "Content Type" "application/x-bam"
  537. WriteRegStr HKCU "Software\Classes\.bam" "PerceivedType" "gamemedia"
  538. WriteRegStr HKCU "Software\Classes\.pz" "" "Panda3D.Compressed"
  539. WriteRegStr HKCU "Software\Classes\.pz" "PerceivedType" "compressed"
  540. WriteRegStr HKCU "Software\Classes\.mf" "" "Panda3D.Multifile"
  541. WriteRegStr HKCU "Software\Classes\.mf" "PerceivedType" "compressed"
  542. WriteRegStr HKCU "Software\Classes\.prc" "" "inifile"
  543. WriteRegStr HKCU "Software\Classes\.prc" "Content Type" "text/plain"
  544. WriteRegStr HKCU "Software\Classes\.prc" "PerceivedType" "text"
  545. ; For convenience, if nobody registered .pyd, we will.
  546. ReadRegStr $0 HKCR "Software\Classes\.pyd" ""
  547. StrCmp $0 "" 0 +2
  548. WriteRegStr HKCU "Software\Classes\.pyd" "" "dllfile"
  549. SetDetailsPrint both
  550. DetailPrint "Adding directories to system PATH..."
  551. SetDetailsPrint listonly
  552. # Add the "bin" directory to the PATH.
  553. Push "$INSTDIR\python"
  554. Call RemoveFromPath
  555. Push "$INSTDIR\python\Scripts"
  556. Call RemoveFromPath
  557. Push "$INSTDIR\bin"
  558. Call RemoveFromPath
  559. Push "$INSTDIR\python;$INSTDIR\python\Scripts;$INSTDIR\bin"
  560. Call AddToPath
  561. # This is needed for the environment variable changes to take effect.
  562. DetailPrint "Broadcasting WM_WININICHANGE message..."
  563. SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=500
  564. # Now dump the log to disk.
  565. StrCpy $0 "$INSTDIR\install.log"
  566. Push $0
  567. Call DumpLog
  568. SectionEnd
  569. Section Uninstall
  570. SetDetailsPrint listonly
  571. SetShellVarContext current
  572. !ifdef REGVIEW
  573. SetRegView ${REGVIEW}
  574. !endif
  575. SetDetailsPrint both
  576. DetailPrint "Removing registry entries..."
  577. SetDetailsPrint listonly
  578. DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${TITLE}"
  579. DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${TITLE}"
  580. ReadRegStr $0 HKCU "Software\Classes\Panda3D.Model\DefaultIcon" ""
  581. StrCmp $0 "$INSTDIR\bin\pview.exe" 0 +3
  582. DeleteRegKey HKCU "Software\Classes\Panda3D.Model\DefaultIcon"
  583. DeleteRegKey HKCU "Software\Classes\Panda3D.Model\shell"
  584. ReadRegStr $0 HKCU "Software\Classes\Panda3D.Compressed\DefaultIcon" ""
  585. StrCmp $0 "$INSTDIR\bin\pzip.exe" 0 +3
  586. DeleteRegKey HKCU "Software\Classes\Panda3D.Compressed\DefaultIcon"
  587. DeleteRegKey HKCU "Software\Classes\Panda3D.Compressed\shell"
  588. ReadRegStr $0 HKCU "Software\Classes\Panda3D.Multifile\DefaultIcon" ""
  589. StrCmp $0 "$INSTDIR\bin\multify.exe" 0 +3
  590. DeleteRegKey HKCU "Software\Classes\Panda3D.Multifile\DefaultIcon"
  591. DeleteRegKey HKCU "Software\Classes\Panda3D.Multifile\shell"
  592. ReadRegStr $0 HKLM "Software\Python\PythonCore\${PYVER}\InstallPath" ""
  593. StrCmp $0 "$INSTDIR\python" 0 +2
  594. DeleteRegKey HKLM "Software\Python\PythonCore\${PYVER}"
  595. ReadRegStr $0 HKCU "Software\Python\PythonCore\${PYVER}\InstallPath" ""
  596. StrCmp $0 "$INSTDIR\python" 0 +2
  597. DeleteRegKey HKCU "Software\Python\PythonCore\${PYVER}"
  598. SetDetailsPrint both
  599. DetailPrint "Deleting files..."
  600. SetDetailsPrint listonly
  601. Delete "$INSTDIR\uninst.exe"
  602. RMDir /r "$INSTDIR"
  603. SetDetailsPrint both
  604. DetailPrint "Removing Start Menu entries..."
  605. SetDetailsPrint listonly
  606. SetShellVarContext current
  607. RMDir /r "$SMPROGRAMS\${TITLE}"
  608. SetShellVarContext all
  609. RMDir /r "$SMPROGRAMS\${TITLE}"
  610. SetDetailsPrint both
  611. DetailPrint "Removing entries from PATH..."
  612. SetDetailsPrint listonly
  613. Push "$INSTDIR\python"
  614. Call un.RemoveFromPath
  615. Push "$INSTDIR\python\Scripts"
  616. Call un.RemoveFromPath
  617. Push "$INSTDIR\bin"
  618. Call un.RemoveFromPath
  619. # This is needed for the environment variable changes to take effect.
  620. DetailPrint "Broadcasting WM_WININICHANGE message..."
  621. SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=500
  622. SectionEnd
  623. !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
  624. !insertmacro MUI_DESCRIPTION_TEXT ${SecCore} $(DESC_SecCore)
  625. !ifdef HAVE_GL
  626. !insertmacro MUI_DESCRIPTION_TEXT ${SecOpenGL} $(DESC_SecOpenGL)
  627. !endif
  628. !ifdef HAVE_DX9
  629. !insertmacro MUI_DESCRIPTION_TEXT ${SecDirect3D9} $(DESC_SecDirect3D9)
  630. !endif
  631. !ifdef HAVE_OPENAL
  632. !insertmacro MUI_DESCRIPTION_TEXT ${SecOpenAL} $(DESC_SecOpenAL)
  633. !endif
  634. !ifdef HAVE_FMOD
  635. !insertmacro MUI_DESCRIPTION_TEXT ${SecFMOD} $(DESC_SecFMOD)
  636. !endif
  637. !ifdef HAVE_FFMPEG
  638. !insertmacro MUI_DESCRIPTION_TEXT ${SecFFMpeg} $(DESC_SecFFMpeg)
  639. !endif
  640. !ifdef HAVE_BULLET
  641. !insertmacro MUI_DESCRIPTION_TEXT ${SecBullet} $(DESC_SecBullet)
  642. !endif
  643. !ifdef HAVE_ODE
  644. !insertmacro MUI_DESCRIPTION_TEXT ${SecODE} $(DESC_SecODE)
  645. !endif
  646. !ifdef HAVE_PHYSX
  647. !insertmacro MUI_DESCRIPTION_TEXT ${SecPhysX} $(DESC_SecPhysX)
  648. !endif
  649. !ifdef HAVE_ROCKET
  650. !insertmacro MUI_DESCRIPTION_TEXT ${SecRocket} $(DESC_SecRocket)
  651. !endif
  652. !insertmacro MUI_DESCRIPTION_TEXT ${SecTools} $(DESC_SecTools)
  653. !insertmacro MUI_DESCRIPTION_TEXT ${SecPyBindings} $(DESC_SecPyBindings)
  654. !ifdef HAVE_PYTHON
  655. !insertmacro MUI_DESCRIPTION_TEXT ${SecPython} $(DESC_SecPython)
  656. !endif
  657. !insertmacro MUI_DESCRIPTION_TEXT ${SecHeadersLibs} $(DESC_SecHeadersLibs)
  658. !ifdef HAVE_SAMPLES
  659. !insertmacro MUI_DESCRIPTION_TEXT ${SecSamples} $(DESC_SecSamples)
  660. !endif
  661. !ifdef HAVE_MAX_PLUGINS
  662. !insertmacro MUI_DESCRIPTION_TEXT ${SecMaxPlugins} $(DESC_SecMaxPlugins)
  663. !endif
  664. !ifdef HAVE_MAYA_PLUGINS
  665. !insertmacro MUI_DESCRIPTION_TEXT ${SecMayaPlugins} $(DESC_SecMayaPlugins)
  666. !endif
  667. !insertmacro MUI_FUNCTION_DESCRIPTION_END
  668. # --[ Utility Functions ]------------------------------------------------------
  669. ; From: http://nsis.sourceforge.net/archive/viewpage.php?pageid=91
  670. Function IsNT
  671. Push $0
  672. ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
  673. StrCmp $0 "" 0 IsNT_yes
  674. ; we are not NT.
  675. Pop $0
  676. Push 0
  677. Return
  678. IsNT_yes:
  679. ; NT!!!
  680. Pop $0
  681. Push 1
  682. FunctionEnd
  683. ; From: http://nsis.sourceforge.net/archive/viewpage.php?pageid=91
  684. Function un.IsNT
  685. Push $0
  686. ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
  687. StrCmp $0 "" 0 unIsNT_yes
  688. ; we are not NT.
  689. Pop $0
  690. Push 0
  691. Return
  692. unIsNT_yes:
  693. ; NT!!!
  694. Pop $0
  695. Push 1
  696. FunctionEnd
  697. ; From: http://nsis.sourceforge.net/archive/viewpage.php?pageid=91
  698. Function StrStr
  699. Push $0
  700. Exch
  701. Pop $0 ; $0 now have the string to find
  702. Push $1
  703. Exch 2
  704. Pop $1 ; $1 now have the string to find in
  705. Exch
  706. Push $2
  707. Push $3
  708. Push $4
  709. Push $5
  710. StrCpy $2 -1
  711. StrLen $3 $0
  712. StrLen $4 $1
  713. IntOp $4 $4 - $3
  714. unStrStr_loop:
  715. IntOp $2 $2 + 1
  716. IntCmp $2 $4 0 0 unStrStrReturn_notFound
  717. StrCpy $5 $1 $3 $2
  718. StrCmp $5 $0 unStrStr_done unStrStr_loop
  719. unStrStrReturn_notFound:
  720. StrCpy $2 -1
  721. unStrStr_done:
  722. Pop $5
  723. Pop $4
  724. Pop $3
  725. Exch $2
  726. Exch 2
  727. Pop $0
  728. Pop $1
  729. FunctionEnd
  730. ; From: http://nsis.sourceforge.net/archive/viewpage.php?pageid=91
  731. Function un.StrStr
  732. Push $0
  733. Exch
  734. Pop $0 ; $0 now have the string to find
  735. Push $1
  736. Exch 2
  737. Pop $1 ; $1 now have the string to find in
  738. Exch
  739. Push $2
  740. Push $3
  741. Push $4
  742. Push $5
  743. StrCpy $2 -1
  744. StrLen $3 $0
  745. StrLen $4 $1
  746. IntOp $4 $4 - $3
  747. unStrStr_loop:
  748. IntOp $2 $2 + 1
  749. IntCmp $2 $4 0 0 unStrStrReturn_notFound
  750. StrCpy $5 $1 $3 $2
  751. StrCmp $5 $0 unStrStr_done unStrStr_loop
  752. unStrStrReturn_notFound:
  753. StrCpy $2 -1
  754. unStrStr_done:
  755. Pop $5
  756. Pop $4
  757. Pop $3
  758. Exch $2
  759. Exch 2
  760. Pop $0
  761. Pop $1
  762. FunctionEnd
  763. ; Capitalizes the first letter of every word.
  764. Function Capitalize
  765. Exch $R0
  766. Push $0
  767. Push $1
  768. Push $2
  769. StrCpy $0 0
  770. capNext:
  771. ; Grab the next character.
  772. StrCpy $1 $R0 1 $0
  773. StrCmp $1 '' end
  774. ; Capitalize it.
  775. ${StrFilter} '$1' '+eng' '' '' $1
  776. ${StrFilter} '$1' '+rus' '' '' $1
  777. ; Splice it into the string.
  778. StrCpy $2 $R0 $0
  779. IntOp $0 $0 + 1
  780. StrCpy $R0 $R0 '' $0
  781. StrCpy $R0 '$2$1$R0'
  782. ; Keep looping through the characters until we find a
  783. ; delimiter or reach the end of the string.
  784. loop:
  785. StrCpy $1 $R0 1 $0
  786. IntOp $0 $0 + 1
  787. StrCmp $1 '' end
  788. StrCmp $1 ' ' capNext
  789. StrCmp $1 '_' capNext
  790. StrCmp $1 '-' capNext
  791. StrCmp $1 '(' capNext
  792. StrCmp $1 '[' capNext
  793. Goto loop
  794. end:
  795. Pop $2
  796. Pop $1
  797. Pop $0
  798. Exch $R0
  799. FunctionEnd
  800. ; From: http://nsis.sourceforge.net/archive/viewpage.php?pageid=91
  801. ; Commentary and smarter ';' checking by Jon Parise <[email protected]>
  802. Function AddToPath
  803. Exch $0
  804. Push $1
  805. Push $2
  806. Push $3
  807. Call IsNT
  808. Pop $1
  809. DetailPrint "Adding to PATH: $0"
  810. StrCmp $1 1 AddToPath_NT
  811. ; We're not on NT, so modify the AUTOEXEC.BAT file.
  812. StrCpy $1 $WINDIR 2
  813. FileOpen $1 "$1\autoexec.bat" a
  814. FileSeek $1 0 END
  815. GetFullPathName /SHORT $0 $0
  816. FileWrite $1 "$\r$\nSET PATH=%PATH%;$0$\r$\n"
  817. FileClose $1
  818. Goto AddToPath_done
  819. AddToPath_NT:
  820. ClearErrors
  821. ReadRegStr $1 HKCU "Environment" "PATH"
  822. ; If we reached an error, WATCH OUT. Either this means that
  823. ; the registry key did not exist, or that it didn't fit in
  824. ; NSIS' string limit. If the latter, we have to be very
  825. ; careful not to overwrite the user's PATH.
  826. IfErrors AddToPath_Error
  827. DetailPrint "Current PATH value is set to $1"
  828. StrCmp $1 "" AddToPath_NTAddPath
  829. ; Pull off the last character of the PATH string. If it's a semicolon,
  830. ; we don't need to add another one, so jump to the section where we
  831. ; append the new PATH component(s).
  832. StrCpy $2 $1 1 -1
  833. StrCmp $2 ";" AddToPath_NTAddPath AddToPath_NTAddSemi
  834. AddToPath_Error:
  835. DetailPrint "Encountered error reading PATH variable."
  836. ; Does the variable exist? If it doesn't, then the
  837. ; error happened because we need to create the
  838. ; variable. If it does, then we failed to read it
  839. ; because we reached NSIS' string limit.
  840. StrCpy $3 0
  841. AddToPath_loop:
  842. EnumRegValue $4 HKCU "Environment" $3
  843. StrCmp $4 "PATH" AddToPath_ExceedLimit
  844. StrCmp $4 "" AddToPath_NTAddPath
  845. IntOp $3 $3 + 1
  846. Goto AddToPath_loop
  847. AddToPath_ExceedLimit:
  848. MessageBox MB_ABORTRETRYIGNORE|MB_ICONEXCLAMATION "Your PATH environment variable is too long! Please remove extraneous entries before proceeding. Panda3D needs to add the following the PATH so that the Panda3D utilities and libraries can be located correctly.$\n$\n$0$\n$\nIf you wish to add Panda3D to the path yourself, choose Ignore." IDIGNORE AddToPath_done IDRETRY AddToPath_NT
  849. SetDetailsPrint both
  850. DetailPrint "Cannot append to PATH - variable is likely too long."
  851. SetDetailsPrint listonly
  852. Abort
  853. AddToPath_NTAddSemi:
  854. StrCpy $1 "$1;"
  855. Goto AddToPath_NTAddPath
  856. AddToPath_NTAddPath:
  857. StrCpy $0 "$1$0"
  858. WriteRegExpandStr HKCU "Environment" "PATH" $0
  859. AddToPath_done:
  860. Pop $3
  861. Pop $2
  862. Pop $1
  863. Pop $0
  864. FunctionEnd
  865. ; From: http://nsis.sourceforge.net/archive/viewpage.php?pageid=91
  866. Function RemoveFromPath
  867. Exch $0
  868. Push $1
  869. Push $2
  870. Push $3
  871. Push $4
  872. Push $5
  873. Call IsNT
  874. Pop $1
  875. DetailPrint "Removing from PATH: $0"
  876. StrCmp $1 1 unRemoveFromPath_NT
  877. ; Not on NT
  878. StrCpy $1 $WINDIR 2
  879. FileOpen $1 "$1\autoexec.bat" r
  880. GetTempFileName $4
  881. FileOpen $2 $4 w
  882. GetFullPathName /SHORT $0 $0
  883. StrCpy $0 "SET PATH=%PATH%;$0"
  884. SetRebootFlag true
  885. Goto unRemoveFromPath_dosLoop
  886. unRemoveFromPath_dosLoop:
  887. FileRead $1 $3
  888. StrCmp $3 "$0$\r$\n" unRemoveFromPath_dosLoop
  889. StrCmp $3 "$0$\n" unRemoveFromPath_dosLoop
  890. StrCmp $3 "$0" unRemoveFromPath_dosLoop
  891. StrCmp $3 "" unRemoveFromPath_dosLoopEnd
  892. FileWrite $2 $3
  893. Goto unRemoveFromPath_dosLoop
  894. unRemoveFromPath_dosLoopEnd:
  895. FileClose $2
  896. FileClose $1
  897. StrCpy $1 $WINDIR 2
  898. Delete "$1\autoexec.bat"
  899. CopyFiles /SILENT $4 "$1\autoexec.bat"
  900. Delete $4
  901. Goto unRemoveFromPath_done
  902. unRemoveFromPath_NT:
  903. Push $0
  904. StrLen $2 $0
  905. ReadRegStr $1 HKCU "Environment" "PATH"
  906. Push $1
  907. Push $0
  908. Call StrStr ; Find $0 in $1
  909. Pop $0 ; pos of our dir
  910. IntCmp $0 -1 unRemoveFromPath_NT_System
  911. ; else, it is in path
  912. StrCpy $3 $1 $0 ; $3 now has the part of the path before our dir
  913. IntOp $2 $2 + $0 ; $2 now contains the pos after our dir in the path (';')
  914. IntOp $2 $2 + 1 ; $2 now containts the pos after our dir and the semicolon.
  915. StrLen $0 $1
  916. StrCpy $1 $1 $0 $2
  917. StrCpy $3 "$3$1"
  918. WriteRegExpandStr HKCU "Environment" "PATH" $3
  919. unRemoveFromPath_NT_System:
  920. Pop $0
  921. StrLen $2 $0
  922. ReadRegStr $1 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH"
  923. Push $1
  924. Push $0
  925. Call StrStr ; Find $0 in $1
  926. Pop $0 ; pos of our dir
  927. IntCmp $0 -1 unRemoveFromPath_done
  928. ; else, it is in path
  929. StrCpy $3 $1 $0 ; $3 now has the part of the path before our dir
  930. IntOp $2 $2 + $0 ; $2 now contains the pos after our dir in the path (';')
  931. IntOp $2 $2 + 1 ; $2 now containts the pos after our dir and the semicolon.
  932. StrLen $0 $1
  933. StrCpy $1 $1 $0 $2
  934. StrCpy $3 "$3$1"
  935. WriteRegExpandStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH" $3
  936. unRemoveFromPath_done:
  937. Pop $5
  938. Pop $4
  939. Pop $3
  940. Pop $2
  941. Pop $1
  942. Pop $0
  943. FunctionEnd
  944. ; From: http://nsis.sourceforge.net/archive/viewpage.php?pageid=91
  945. Function un.RemoveFromPath
  946. Exch $0
  947. Push $1
  948. Push $2
  949. Push $3
  950. Push $4
  951. Push $5
  952. Call un.IsNT
  953. Pop $1
  954. StrCmp $1 1 unRemoveFromPath_NT
  955. ; Not on NT
  956. StrCpy $1 $WINDIR 2
  957. FileOpen $1 "$1\autoexec.bat" r
  958. GetTempFileName $4
  959. FileOpen $2 $4 w
  960. GetFullPathName /SHORT $0 $0
  961. StrCpy $0 "SET PATH=%PATH%;$0"
  962. SetRebootFlag true
  963. Goto unRemoveFromPath_dosLoop
  964. unRemoveFromPath_dosLoop:
  965. FileRead $1 $3
  966. StrCmp $3 "$0$\r$\n" unRemoveFromPath_dosLoop
  967. StrCmp $3 "$0$\n" unRemoveFromPath_dosLoop
  968. StrCmp $3 "$0" unRemoveFromPath_dosLoop
  969. StrCmp $3 "" unRemoveFromPath_dosLoopEnd
  970. FileWrite $2 $3
  971. Goto unRemoveFromPath_dosLoop
  972. unRemoveFromPath_dosLoopEnd:
  973. FileClose $2
  974. FileClose $1
  975. StrCpy $1 $WINDIR 2
  976. Delete "$1\autoexec.bat"
  977. CopyFiles /SILENT $4 "$1\autoexec.bat"
  978. Delete $4
  979. Goto unRemoveFromPath_done
  980. unRemoveFromPath_NT:
  981. Push $0
  982. StrLen $2 $0
  983. ReadRegStr $1 HKCU "Environment" "PATH"
  984. Push $1
  985. Push $0
  986. Call un.StrStr ; Find $0 in $1
  987. Pop $0 ; pos of our dir
  988. IntCmp $0 -1 unRemoveFromPath_NT_System
  989. ; else, it is in path
  990. StrCpy $3 $1 $0 ; $3 now has the part of the path before our dir
  991. IntOp $2 $2 + $0 ; $2 now contains the pos after our dir in the path (';')
  992. IntOp $2 $2 + 1 ; $2 now containts the pos after our dir and the semicolon.
  993. StrLen $0 $1
  994. StrCpy $1 $1 $0 $2
  995. StrCpy $3 "$3$1"
  996. WriteRegExpandStr HKCU "Environment" "PATH" $3
  997. unRemoveFromPath_NT_System:
  998. Pop $0
  999. StrLen $2 $0
  1000. ReadRegStr $1 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH"
  1001. Push $1
  1002. Push $0
  1003. Call un.StrStr ; Find $0 in $1
  1004. Pop $0 ; pos of our dir
  1005. IntCmp $0 -1 unRemoveFromPath_done
  1006. ; else, it is in path
  1007. StrCpy $3 $1 $0 ; $3 now has the part of the path before our dir
  1008. IntOp $2 $2 + $0 ; $2 now contains the pos after our dir in the path (';')
  1009. IntOp $2 $2 + 1 ; $2 now containts the pos after our dir and the semicolon.
  1010. StrLen $0 $1
  1011. StrCpy $1 $1 $0 $2
  1012. StrCpy $3 "$3$1"
  1013. WriteRegExpandStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH" $3
  1014. unRemoveFromPath_done:
  1015. Pop $5
  1016. Pop $4
  1017. Pop $3
  1018. Pop $2
  1019. Pop $1
  1020. Pop $0
  1021. FunctionEnd
  1022. Function StrRep
  1023. ;Written by dirtydingus 2003-02-20 04:30:09
  1024. ; USAGE
  1025. ;Push String to do replacement in (haystack)
  1026. ;Push String to replace (needle)
  1027. ;Push Replacement
  1028. ;Call StrRep
  1029. ;Pop $R0 result
  1030. ;StrCpy $Result STR $R0
  1031. Exch $R4 ; $R4 = Replacement String
  1032. Exch
  1033. Exch $R3 ; $R3 = String to replace (needle)
  1034. Exch 2
  1035. Exch $R1 ; $R1 = String to do replacement in (haystack)
  1036. Push $R2 ; Replaced haystack
  1037. Push $R5 ; Len (needle)
  1038. Push $R6 ; len (haystack)
  1039. Push $R7 ; Scratch reg
  1040. StrCpy $R2 ""
  1041. StrLen $R5 $R3
  1042. StrLen $R6 $R1
  1043. loop:
  1044. StrCpy $R7 $R1 $R5
  1045. StrCmp $R7 $R3 found
  1046. StrCpy $R7 $R1 1 ; - optimization can be removed if U know len needle=1
  1047. StrCpy $R2 "$R2$R7"
  1048. StrCpy $R1 $R1 $R6 1
  1049. StrCmp $R1 "" done loop
  1050. found:
  1051. StrCpy $R2 "$R2$R4"
  1052. StrCpy $R1 $R1 $R6 $R5
  1053. StrCmp $R1 "" done loop
  1054. done:
  1055. StrCpy $R3 $R2
  1056. Pop $R7
  1057. Pop $R6
  1058. Pop $R5
  1059. Pop $R2
  1060. Pop $R1
  1061. Pop $R4
  1062. Exch $R3
  1063. FunctionEnd
  1064. !define LVM_GETITEMCOUNT 0x1004
  1065. !define LVM_GETITEMTEXT 0x102D
  1066. Function DumpLog
  1067. Exch $5
  1068. Push $0
  1069. Push $1
  1070. Push $2
  1071. Push $3
  1072. Push $4
  1073. Push $6
  1074. FindWindow $0 "#32770" "" $HWNDPARENT
  1075. GetDlgItem $0 $0 1016
  1076. StrCmp $0 0 exit
  1077. FileOpen $5 $5 "w"
  1078. StrCmp $5 "" exit
  1079. SendMessage $0 ${LVM_GETITEMCOUNT} 0 0 $6
  1080. System::Alloc ${NSIS_MAX_STRLEN}
  1081. Pop $3
  1082. StrCpy $2 0
  1083. System::Call "*(i, i, i, i, i, i, i, i, i) i \
  1084. (0, 0, 0, 0, 0, r3, ${NSIS_MAX_STRLEN}) .r1"
  1085. loop: StrCmp $2 $6 done
  1086. System::Call "User32::SendMessageA(i, i, i, i) i \
  1087. ($0, ${LVM_GETITEMTEXT}, $2, r1)"
  1088. System::Call "*$3(&t${NSIS_MAX_STRLEN} .r4)"
  1089. FileWrite $5 "$4$\r$\n"
  1090. IntOp $2 $2 + 1
  1091. Goto loop
  1092. done:
  1093. FileClose $5
  1094. System::Free $1
  1095. System::Free $3
  1096. exit:
  1097. Pop $6
  1098. Pop $4
  1099. Pop $3
  1100. Pop $2
  1101. Pop $1
  1102. Pop $0
  1103. Exch $5
  1104. FunctionEnd