Improved clean-up code.
[mplayer-setup-win32.git] / MPUI_Setup.nsi
blobf393a38a50650cbe71d2a12ec9576af83027d7c5
1 ; ///////////////////////////////////////////////////////////////////////////////
2 ; // MPlayer for Windows - Install Script
3 ; // Copyright (C) 2004-2024 LoRd_MuldeR <MuldeR2@GMX.de>
4 ; //
5 ; // This program is free software; you can redistribute it and/or modify
6 ; // it under the terms of the GNU General Public License as published by
7 ; // the Free Software Foundation; either version 2 of the License, or
8 ; // (at your option) any later version.
9 ; //
10 ; // This program is distributed in the hope that it will be useful,
11 ; // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ; // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ; // GNU General Public License for more details.
14 ; //
15 ; // You should have received a copy of the GNU General Public License along
16 ; // with this program; if not, write to the Free Software Foundation, Inc.,
17 ; // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 ; //
19 ; // http://www.gnu.org/licenses/gpl-2.0.txt
20 ; ///////////////////////////////////////////////////////////////////////////////
23 ;--------------------------------------------------------------------------------
24 ; BASIC DEFINES
25 ;--------------------------------------------------------------------------------
27 !ifndef NSIS_UNICODE
28 !error "NSIS_UNICODE is undefined, please compile with Unicode NSIS !!!"
29 !endif
31 !ifndef MPLAYER_BUILDNO
32 !error "MPLAYER_BUILDNO is not defined !!!"
33 !endif
35 !ifndef MPLAYER_REVISION
36 !error "MPLAYER_REVISION is not defined !!!"
37 !endif
39 !ifndef MPLAYER_DATE
40 !error "MPLAYER_DATE is not defined !!!"
41 !endif
43 !ifndef SMPLAYER_VERSION
44 !error "SMPLAYER_VERSION is not defined !!!"
45 !endif
47 !ifndef MPUI_VERSION
48 !error "MPUI_VERSION is not defined !!!"
49 !endif
51 !ifndef CODECS_DATE
52 !error "CODECS_DATE is not defined !!!"
53 !endif
55 !ifndef MPLAYER_OUTFILE
56 !error "MPLAYER_OUTFILE is not defined !!!"
57 !endif
59 !ifndef UPX_PATH
60 !error "UPX_PATH is not defined !!!"
61 !endif
63 ; UUID
64 !define MPlayerRegPath "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{97D341C8-B0D1-4E4A-A49A-C30B52F168E9}"
66 ; Web-Site
67 !define MPlayerWebSite "http://mplayerhq.hu/"
70 ;--------------------------------------------------------------------------------
71 ; INSTALLER ATTRIBUTES
72 ;--------------------------------------------------------------------------------
74 RequestExecutionLevel admin
75 ShowInstDetails show
76 ShowUninstDetails show
78 Name "$(MPLAYER_LANG_MPLAYER_WIN32) ${MPLAYER_DATE} (Build #${MPLAYER_BUILDNO})"
79 Caption "$(MPLAYER_LANG_MPLAYER_WIN32) ${MPLAYER_DATE} (Build #${MPLAYER_BUILDNO})"
80 BrandingText "MPlayer-Win32 (Build #${MPLAYER_BUILDNO})"
81 InstallDir "$PROGRAMFILES\MPlayer for Windows"
82 InstallDirRegKey HKLM "${MPlayerRegPath}" "InstallLocation"
83 OutFile "${MPLAYER_OUTFILE}"
86 ;--------------------------------------------------------------------------------
87 ; COMPRESSOR
88 ;--------------------------------------------------------------------------------
90 SetCompressor /SOLID /FINAL LZMA
91 SetCompressorDictSize 112
93 !tempfile PACKHDRTEMP
94 !packhdr "${PACKHDRTEMP}" '"Utils\MT.exe" -manifest "Resources\Setup.manifest" -outputresource:"${PACKHDRTEMP};1"'
96 !packhdr "$%TEMP%\exehead.tmp" '"${UPX_PATH}\upx.exe" --brute "$%TEMP%\exehead.tmp"'
99 ;--------------------------------------------------------------------------------
100 ; RESERVE FILES
101 ;--------------------------------------------------------------------------------
103 ReserveFile "${NSISDIR}\Plugins\Aero.dll"
104 ReserveFile "${NSISDIR}\Plugins\Banner.dll"
105 ReserveFile "${NSISDIR}\Plugins\CPUFeatures.dll"
106 ReserveFile "${NSISDIR}\Plugins\InstallOptions.dll"
107 ReserveFile "${NSISDIR}\Plugins\LangDLL.dll"
108 ReserveFile "${NSISDIR}\Plugins\LockedList.dll"
109 ReserveFile "${NSISDIR}\Plugins\LockedList64.dll"
110 ReserveFile "${NSISDIR}\Plugins\nsDialogs.dll"
111 ReserveFile "${NSISDIR}\Plugins\nsExec.dll"
112 ReserveFile "${NSISDIR}\Plugins\StartMenu.dll"
113 ReserveFile "${NSISDIR}\Plugins\StdUtils.dll"
114 ReserveFile "${NSISDIR}\Plugins\System.dll"
115 ReserveFile "${NSISDIR}\Plugins\UserInfo.dll"
116 ReserveFile "Dialogs\Page_CPU.ini"
117 ReserveFile "Resources\Splash.gif"
120 ;--------------------------------------------------------------------------------
121 ; INCLUDES
122 ;--------------------------------------------------------------------------------
124 !include `MUI2.nsh`
125 !include `InstallOptions.nsh`
126 !include `WinVer.nsh`
127 !include `x64.nsh`
128 !include `StrFunc.nsh`
129 !include `StdUtils.nsh`
130 !include `CPUFeatures.nsh`
131 !include `MPUI_Common.nsh`
133 ; Enable functions
134 ${StrRep}
137 ;--------------------------------------------------------------------------------
138 ; GLOBAL VARIABLES
139 ;--------------------------------------------------------------------------------
141 Var StartMenuFolder
142 Var DetectedCPUType
143 Var DetectedCPUCores
144 Var SelectedCPUType
145 Var SelectedTweaks
146 Var NotUpdateInstall
149 ;--------------------------------------------------------------------------------
150 ; VERSION INFO
151 ;--------------------------------------------------------------------------------
153 !searchreplace PRODUCT_VERSION_DATE "${MPLAYER_DATE}" "-" "."
154 VIProductVersion "${PRODUCT_VERSION_DATE}.${MPLAYER_BUILDNO}"
156 VIAddVersionKey "Author" "LoRd_MuldeR <mulder2@gmx.de>"
157 VIAddVersionKey "Comments" "This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version."
158 VIAddVersionKey "CompanyName" "Free Software Foundation"
159 VIAddVersionKey "FileDescription" "MPlayer for Windows (Build #${MPLAYER_BUILDNO})"
160 VIAddVersionKey "FileVersion" "${PRODUCT_VERSION_DATE}.${MPLAYER_BUILDNO}"
161 VIAddVersionKey "LegalCopyright" "Copyright 2000-2018 The MPlayer Project"
162 VIAddVersionKey "LegalTrademarks" "GNU"
163 VIAddVersionKey "OriginalFilename" "MPUI-Setup.exe"
164 VIAddVersionKey "ProductName" "MPlayer for Windows"
165 VIAddVersionKey "ProductVersion" "Build #${MPLAYER_BUILDNO} (${MPLAYER_DATE})"
166 VIAddVersionKey "Website" "${MPlayerWebSite}"
169 ;--------------------------------------------------------------------------------
170 ; MUI2 INTERFACE SETTINGS
171 ;--------------------------------------------------------------------------------
173 !define MUI_ABORTWARNING
174 !define MUI_STARTMENUPAGE_REGISTRY_ROOT HKLM
175 !define MUI_STARTMENUPAGE_REGISTRY_KEY "${MPlayerRegPath}"
176 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "StartmenuFolder"
177 !define MUI_LANGDLL_REGISTRY_ROOT HKLM
178 !define MUI_LANGDLL_REGISTRY_KEY "${MPlayerRegPath}"
179 !define MUI_LANGDLL_REGISTRY_VALUENAME "SetupLanguage"
180 !define MUI_STARTMENUPAGE_DEFAULTFOLDER "MPlayer for Windows"
181 !define MUI_FINISHPAGE_NOAUTOCLOSE
182 !define MUI_UNFINISHPAGE_NOAUTOCLOSE
183 !define MUI_FINISHPAGE_RUN
184 !define MUI_FINISHPAGE_RUN_FUNCTION RunAppFunction
185 !define MUI_FINISHPAGE_SHOWREADME
186 !define MUI_FINISHPAGE_SHOWREADME_FUNCTION ShowReadmeFunction
187 !define MUI_FINISHPAGE_LINK ${MPlayerWebSite}
188 !define MUI_FINISHPAGE_LINK_LOCATION ${MPlayerWebSite}
189 !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\orange-install.ico"
190 !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\orange-uninstall.ico"
191 !define MUI_WELCOMEFINISHPAGE_BITMAP "Artwork\wizard.bmp"
192 !define MUI_UNWELCOMEFINISHPAGE_BITMAP "Artwork\wizard-un.bmp"
193 !define MUI_HEADERIMAGE
194 !define MUI_HEADERIMAGE_BITMAP "Artwork\header.bmp"
195 !define MUI_HEADERIMAGE_UNBITMAP "Artwork\header-un.bmp"
196 !define MUI_LANGDLL_ALLLANGUAGES
197 !define MUI_CUSTOMFUNCTION_GUIINIT MyGuiInit
198 !define MUI_CUSTOMFUNCTION_UNGUIINIT un.MyGuiInit
199 !define MUI_LANGDLL_ALWAYSSHOW
200 !define MUI_COMPONENTSPAGE_SMALLDESC
203 ;--------------------------------------------------------------------------------
204 ; MUI2 PAGE SETUP
205 ;--------------------------------------------------------------------------------
207 ; Installer
208 !define MUI_WELCOMEPAGE_TITLE_3LINES
209 !define MUI_FINISHPAGE_TITLE_3LINES
210 !insertmacro MUI_PAGE_WELCOME
211 !insertmacro MUI_PAGE_LICENSE "Docs\License.txt"
212 !define MUI_PAGE_CUSTOMFUNCTION_SHOW CheckForUpdate
213 !insertmacro MUI_PAGE_DIRECTORY
214 !insertmacro MUI_PAGE_COMPONENTS
215 !insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder
216 Page Custom SelectCPUPage_Show SelectCPUPage_Validate
217 Page Custom SetTweaksPage_Show
218 Page Custom LockedListPage_Show
219 !insertmacro MUI_PAGE_INSTFILES
220 !insertmacro MUI_PAGE_FINISH
222 ; Un-Installer
223 !define MUI_WELCOMEPAGE_TITLE_3LINES
224 !define MUI_FINISHPAGE_TITLE_3LINES
225 !insertmacro MUI_UNPAGE_WELCOME
226 !insertmacro MUI_UNPAGE_CONFIRM
227 UninstPage Custom un.LockedListPage_Show
228 !insertmacro MUI_UNPAGE_INSTFILES
229 !insertmacro MUI_UNPAGE_FINISH
232 ;--------------------------------------------------------------------------------
233 ; LANGUAGE
234 ;--------------------------------------------------------------------------------
236 !insertmacro MUI_LANGUAGE "English"
237 !insertmacro MUI_LANGUAGE "German"
239 ; Translation files
240 !include "Language\MPUI_EN.nsh"
241 !include "Language\MPUI_DE.nsh"
244 ;--------------------------------------------------------------------------------
245 ; INSTALL TYPES
246 ;--------------------------------------------------------------------------------
248 InstType "$(MPLAYER_LANG_INSTTYPE_COMPLETE)"
249 InstType "$(MPLAYER_LANG_INSTTYPE_MINIMAL)"
252 ;--------------------------------------------------------------------------------
253 ; INITIALIZATION
254 ;--------------------------------------------------------------------------------
256 Function .onInit
257 StrCpy $SelectedCPUType 0
258 StrCpy $DetectedCPUType 0
259 StrCpy $DetectedCPUCores 0
260 StrCpy $SelectedTweaks 1
261 StrCpy $NotUpdateInstall 1
263 InitPluginsDir
265 ; --------
267 System::Call 'kernel32::CreateMutexA(i 0, i 0, t "{B800490C-C100-4B12-9F09-1A54DF063049}") i .r1 ?e'
268 Pop $0
269 ${If} $0 <> 0
270 MessageBox MB_ICONSTOP|MB_TOPMOST "Oups, the installer is already running!"
271 Quit
272 ${EndIf}
274 ; --------
276 # Running on Windows NT family?
277 ${IfNot} ${IsNT}
278 MessageBox MB_TOPMOST|MB_ICONSTOP "Sorry, this application does *not* support Windows 9x or Windows ME!"
279 ExecShell "open" "http://windows.microsoft.com/"
280 Quit
281 ${EndIf}
283 # Running on Windows XP or later?
284 ${If} ${AtMostWin2000}
285 MessageBox MB_TOPMOST|MB_ICONSTOP "Sorry, but your operating system is *not* supported anymore.$\nInstallation will be aborted!$\n$\nThe minimum required platform is Windows XP."
286 ExecShell "open" "http://windows.microsoft.com/"
287 Quit
288 ${EndIf}
290 ; --------
292 UserInfo::GetAccountType
293 Pop $0
294 ${If} $0 != "Admin"
295 MessageBox MB_ICONSTOP|MB_TOPMOST "Your system requires administrative permissions in order to install this software."
296 SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
297 Quit
298 ${EndIf}
300 ; --------
302 !insertmacro MUI_LANGDLL_DISPLAY
304 !insertmacro INSTALLOPTIONS_EXTRACT_AS "Dialogs\Page_CPU.ini" "Page_CPU.ini"
305 !insertmacro INSTALLOPTIONS_EXTRACT_AS "Dialogs\Page_Tweaks.ini" "Page_Tweaks.ini"
307 !ifdef PRE_RELEASE
308 ${IfCmd} MessageBox MB_TOPMOST|MB_ICONEXCLAMATION|MB_OKCANCEL|MB_DEFBUTTON2 "Note: This is an early pre-release version for test only!" IDCANCEL ${||} Quit ${|}
309 !endif
311 ; --------
313 ${IfNot} ${Silent}
314 File "/oname=$PLUGINSDIR\Splash.gif" "Resources\Splash.gif"
315 newadvsplash::show 3000 1000 500 -1 /NOCANCEL "$PLUGINSDIR\Splash.gif"
316 Delete /REBOOTOK "$PLUGINSDIR\Splash.gif"
317 ${EndIf}
318 FunctionEnd
320 Function un.onInit
321 InitPluginsDir
323 System::Call 'kernel32::CreateMutexA(i 0, i 0, t "{B800490C-C100-4B12-9F09-1A54DF063049}") i .r1 ?e'
324 Pop $0
325 ${If} $0 <> 0
326 MessageBox MB_ICONSTOP|MB_TOPMOST "Sorry, the un-installer is already running!"
327 Quit
328 ${EndIf}
330 ; --------
332 UserInfo::GetAccountType
333 Pop $0
334 ${If} $0 != "Admin"
335 MessageBox MB_ICONSTOP|MB_TOPMOST "Your system requires administrative permissions in order to un-install this software."
336 SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
337 Quit
338 ${EndIf}
340 ; --------
342 !insertmacro MUI_LANGDLL_DISPLAY
343 FunctionEnd
346 ;--------------------------------------------------------------------------------
347 ; GUI INITIALIZATION
348 ;--------------------------------------------------------------------------------
350 Function MyGuiInit
351 StrCpy $0 $HWNDPARENT
352 System::Call "user32::SetWindowPos(i r0, i -1, i 0, i 0, i 0, i 0, i 3)"
353 Aero::Apply
354 FunctionEnd
356 Function un.MyGuiInit
357 StrCpy $0 $HWNDPARENT
358 System::Call "user32::SetWindowPos(i r0, i -1, i 0, i 0, i 0, i 0, i 3)"
359 Aero::Apply
360 FunctionEnd
363 ;--------------------------------------------------------------------------------
364 ; INSTALL SECTIONS
365 ;--------------------------------------------------------------------------------
367 Section "-Check Current Version"
368 ${StdUtils.TestParameter} $0 "Update"
369 ${IfNot} "$0" == "true"
370 ${AndIf} ${FileExists} "$INSTDIR\MPlayer.exe"
371 ${AndIf} ${FileExists} "$INSTDIR\version.tag"
372 ReadINIStr $0 "$INSTDIR\version.tag" "mplayer_version" "build_no"
373 ${If} $0 > ${MPLAYER_BUILDNO}
374 MessageBox MB_OK|MB_ICONEXCLAMATION|MB_TOPMOST "$(MPLAYER_LANG_CAN_NOT_UPDATE)"
375 Quit
376 ${EndIf}
377 ${EndIf}
378 SectionEnd
380 Section "-Clean Up"
381 ${PrintProgress} "$(MPLAYER_LANG_STATUS_INST_CLEAN)"
383 SetShellVarContext all
384 SetOutPath "$INSTDIR"
386 ; Uninstall old version (aka "Setup v1")
387 ClearErrors
388 ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{DB9E4EAB-2717-499F-8D56-4CC8A644AB60}" "InstallLocation"
389 ${IfNot} ${Errors}
390 MessageBox MB_ICONINFORMATION|MB_OK "$(MPLAYER_LANG_UNINSTALL_OLDVER)"
391 File "/oname=$PLUGINSDIR\Uninstall-V1.exe" "Resources\Uninstall-V1.exe"
392 HideWindow
393 ExecWait '"$PLUGINSDIR\Uninstall-V1.exe" _?=$0'
394 Delete /REBOOTOK "$PLUGINSDIR\Uninstall-V1.exe"
395 BringToFront
396 ${EndIf}
398 ; Clean registry
399 DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{DB9E4EAB-2717-499F-8D56-4CC8A644AB60}"
400 DeleteRegKey HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{DB9E4EAB-2717-499F-8D56-4CC8A644AB60}"
401 DeleteRegValue HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" "MPlayerForWindows_UpdateReminder"
402 DeleteRegValue HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" "MPlayerForWindows_UpdateReminder"
404 ; Make sure MPlayer isn't running
405 ${Do}
406 ClearErrors
407 Delete "$INSTDIR\MPlayer.exe"
408 Delete "$INSTDIR\SMPlayer.exe"
409 Delete "$INSTDIR\MPUI.exe"
410 ${If} ${Errors}
411 ${IfCmd} MessageBox MB_TOPMOST|MB_ICONEXCLAMATION|MB_OKCANCEL "$(MPLAYER_LANG_STILL_RUNNING)" IDCANCEL ${||} Abort ${|}
412 ${Else}
413 ${Break}
414 ${EndIf}
415 ${Loop}
417 ; Clean the install folder
418 Delete "$INSTDIR\*.exe"
419 Delete "$INSTDIR\*.dll"
420 Delete "$INSTDIR\*.ini"
421 Delete "$INSTDIR\*.txt"
422 Delete "$INSTDIR\*.html"
423 Delete "$INSTDIR\*.htm"
424 Delete "$INSTDIR\*.ass"
425 Delete "$INSTDIR\*.m3u8"
426 Delete "$INSTDIR\*.tag"
428 RMDir /r "$INSTDIR\bearer"
429 RMDir /r "$INSTDIR\codecs"
430 RMDir /r "$INSTDIR\fonts"
431 RMDir /r "$INSTDIR\iconengines"
432 RMDir /r "$INSTDIR\imageformats"
433 RMDir /r "$INSTDIR\legal_stuff"
434 RMDir /r "$INSTDIR\locale"
435 RMDir /r "$INSTDIR\mplayer"
436 RMDir /r "$INSTDIR\platforms"
437 RMDir /r "$INSTDIR\shortcuts"
438 RMDir /r "$INSTDIR\styles"
439 RMDir /r "$INSTDIR\themes"
440 RMDir /r "$INSTDIR\translations"
442 ; Now deal with Virtual Store
443 ${GetVirtualStorePath} $0 "$INSTDIR"
444 ${If} ${FileExists} "$0\*.*"
445 RMDir /r "$0"
446 ${EndIf}
447 SectionEnd
449 Section "!MPlayer r${MPLAYER_REVISION}" SECID_MPLAYER
450 SectionIn 1 2 RO
451 ${PrintProgress} "$(MPLAYER_LANG_STATUS_INST_MPLAYER)"
452 SetOutPath "$INSTDIR"
454 ; Detect
455 ${If} ${Silent}
456 Call DetectCPUType
457 StrCpy $SelectedCPUType $DetectedCPUType
458 ${EndIf}
460 ; MPlayer.exe
461 ${Select} $SelectedCPUType
462 ${Case} "2"
463 DetailPrint "$(MPLAYER_LANG_SELECTED_TYPE): x64 (x86-64)"
464 File "Builds\MPlayer-x86_64\MPlayer.exe"
465 ${Case} "3"
466 DetailPrint "$(MPLAYER_LANG_SELECTED_TYPE): core2"
467 File "Builds\MPlayer-core2\MPlayer.exe"
468 ${Case} "4"
469 DetailPrint "$(MPLAYER_LANG_SELECTED_TYPE): corei7"
470 File "Builds\MPlayer-corei7\MPlayer.exe"
471 ${Case} "5"
472 DetailPrint "$(MPLAYER_LANG_SELECTED_TYPE): k8-sse3"
473 File "Builds\MPlayer-k8-sse3\MPlayer.exe"
474 ${Case} "6"
475 DetailPrint "$(MPLAYER_LANG_SELECTED_TYPE): generic"
476 File "Builds\MPlayer-generic\MPlayer.exe"
477 ${CaseElse}
478 MessageBox MB_TOPMOST|MB_ICONEXCLAMATION|MB_OK "Internal error: Invalid CPU type selection detected!"
479 Abort
480 ${EndSelect}
482 ; Utilities
483 File ".Compile\Updater.exe"
484 File "Resources\AppRegGUI.exe"
486 ; Other MPlayer-related files
487 File "Builds\MPlayer-generic\*.dll"
488 ${ExtractSubDir} "Builds\MPlayer-generic" "mplayer"
489 ${ExtractSubDir} "Builds\MPlayer-generic" "fonts"
491 ; Documents
492 SetOutPath "$INSTDIR"
493 File "GPL.txt"
494 File "/oname=Manual.html" "Builds\MPlayer-generic\MPlayer.man.html"
495 File "Docs\Readme.html"
496 SetOutPath "$INSTDIR\legal_stuff"
497 File "Docs\legal_stuff\*.txt"
499 ; Write version tag
500 ${Do}
501 ClearErrors
502 Delete "$INSTDIR\version.tag"
503 ${If} ${Errors}
504 ${IfCmd} MessageBox MB_TOPMOST|MB_ICONEXCLAMATION|MB_OKCANCEL "$(MPLAYER_LANG_TAG_WRITE)" IDCANCEL ${||} Abort ${|}
505 ${Else}
506 ${Break}
507 ${EndIf}
508 ${Loop}
509 WriteINIStr "$INSTDIR\version.tag" "mplayer_version" "build_no" "${MPLAYER_BUILDNO}"
510 WriteINIStr "$INSTDIR\version.tag" "mplayer_version" "pkg_date" "${MPLAYER_DATE}"
511 SetFileAttributes "$INSTDIR\version.tag" FILE_ATTRIBUTE_READONLY
513 ; Set file access rights
514 ${MakePathPublic} "$INSTDIR"
515 ${MakeFilePublic} "$INSTDIR\mplayer\config"
516 ${MakeFilePublic} "$INSTDIR\fonts\fonts.conf"
517 SectionEnd
519 Section "!MPUI $(MPLAYER_LANG_FRONT_END) v${MPUI_VERSION}" SECID_MPUI
520 SectionIn 1 2
521 ${PrintProgress} "$(MPLAYER_LANG_STATUS_INST_MPUI)"
523 ; Extract files
524 SetOutPath "$INSTDIR"
525 File "MPUI\MPUI.exe"
527 ; Extract locales
528 SetOutPath "$INSTDIR\locale"
529 File "MPUI\locale\*.txt"
531 ; Set file access rights
532 ${MakeFilePublic} "$INSTDIR\MPUI.ini"
534 ; Setup initial config
535 ClearErrors
536 WriteINIStr "$INSTDIR\MPUI.ini" "MPUI" "Params" "-vo direct3d -lavdopts threads=$DetectedCPUCores"
537 WriteINIStr "$INSTDIR\MPUI.ini" "MPUI" "Locale" "$(MPLAYER_LANG_MPUI_DEFAULT_LANGUAGE)"
538 ${If} ${Errors}
539 ${IfCmd} MessageBox MB_TOPMOST|MB_ICONSTOP|MB_DEFBUTTON2|MB_OKCANCEL "$(MPLAYER_LANG_CONFIG_MPUI)" IDCANCEL ${||} Abort ${|}
540 ${EndIf}
541 SectionEnd
543 Section "!SMPlayer $(MPLAYER_LANG_FRONT_END) v${SMPLAYER_VERSION}" SECID_SMPLAYER
544 SectionIn 1
545 ${PrintProgress} "$(MPLAYER_LANG_STATUS_INST_SMPLAYER)"
547 ; SMPlayer program files
548 SetOutPath "$INSTDIR"
549 File "SMPlayer\smplayer.exe"
550 File "SMPlayer\yt-dlp_x86.exe"
551 File "SMPlayer\*.dll"
553 ; Additional SMPlayer files
554 ${ExtractSubDir} "SMPlayer" "bearer"
555 ${ExtractSubDir} "SMPlayer" "iconengines"
556 ${ExtractSubDir} "SMPlayer" "imageformats"
557 ${ExtractSubDir} "SMPlayer" "platforms"
558 ${ExtractSubDir} "SMPlayer" "shortcuts"
559 ${ExtractSubDir} "SMPlayer" "styles"
560 ${ExtractSubDir} "SMPlayer" "themes"
561 ${ExtractSubDir} "SMPlayer" "translations"
563 ; Set file access rights
564 ${MakeFilePublic} "$INSTDIR\SMPlayer.ini"
565 ${MakeFilePublic} "$INSTDIR\SMPlayer_files.ini"
566 ${MakeFilePublic} "$INSTDIR\player_info.ini"
567 ${MakeFilePublic} "$INSTDIR\playlist.ini"
568 ${MakeFilePublic} "$INSTDIR\favorites.m3u8"
569 ${MakeFilePublic} "$INSTDIR\radio.m3u8"
570 ${MakeFilePublic} "$INSTDIR\tv.m3u8"
571 ${MakeFilePublic} "$INSTDIR\styles.ass"
572 ${MakeFilePublic} "$INSTDIR\shortcuts\default.keys"
574 ; Setup initial config
575 ${StrRep} $0 "$INSTDIR\MPlayer.exe" "\" "/"
576 ${StrRep} $1 "$INSTDIR\yt-dlp_x86.exe" "\" "/"
577 ClearErrors
578 WriteINIStr "$INSTDIR\SMPlayer.ini" "%General" "autosync" "true"
579 WriteINIStr "$INSTDIR\SMPlayer.ini" "%General" "autosync_factor" "30"
580 WriteINIStr "$INSTDIR\SMPlayer.ini" "%General" "config_version" "5"
581 WriteINIStr "$INSTDIR\SMPlayer.ini" "%General" "driver\vo" "direct3d"
582 WriteINIStr "$INSTDIR\SMPlayer.ini" "%General" "file_settings_method" "normal"
583 WriteINIStr "$INSTDIR\SMPlayer.ini" "%General" "mplayer_bin" "$0"
584 WriteINIStr "$INSTDIR\SMPlayer.ini" "%General" "osd" "1"
585 WriteINIStr "$INSTDIR\SMPlayer.ini" "%General" "use_audio_equalizer" "false"
586 WriteINIStr "$INSTDIR\SMPlayer.ini" "%General" "use_scaletempo" "0"
587 WriteINIStr "$INSTDIR\SMPlayer.ini" "advanced" "mplayer_additional_options" ""
588 WriteINIStr "$INSTDIR\SMPlayer.ini" "gui" "gui" "DefaultGUI"
589 WriteINIStr "$INSTDIR\SMPlayer.ini" "gui" "iconset" "Numix-remix"
590 WriteINIStr "$INSTDIR\SMPlayer.ini" "gui" "qt_style" "WindowsVista"
591 WriteINIStr "$INSTDIR\SMPlayer.ini" "mplayer_info" "is_mplayer2" "false"
592 WriteINIStr "$INSTDIR\SMPlayer.ini" "mplayer_info" "mplayer_detected_version" "${MPLAYER_REVISION}"
593 WriteINIStr "$INSTDIR\SMPlayer.ini" "mplayer_info" "mplayer_user_supplied_version" "-1"
594 WriteINIStr "$INSTDIR\SMPlayer.ini" "performance" "frame_drop" "true"
595 WriteINIStr "$INSTDIR\SMPlayer.ini" "performance" "priority" "1"
596 WriteINIStr "$INSTDIR\SMPlayer.ini" "performance" "threads" "$DetectedCPUCores"
597 WriteINIStr "$INSTDIR\SMPlayer.ini" "smplayer" "check_for_new_version" "false"
598 WriteINIStr "$INSTDIR\SMPlayer.ini" "smplayer" "check_if_upgraded" "false"
599 WriteINIStr "$INSTDIR\SMPlayer.ini" "streaming" "streaming\youtube\ytdl_bin" "$1"
600 WriteINIStr "$INSTDIR\SMPlayer.ini" "update_checker" "enabled" "false"
602 ${If} ${Errors}
603 ${IfCmd} MessageBox MB_TOPMOST|MB_ICONSTOP|MB_DEFBUTTON2|MB_OKCANCEL "$(MPLAYER_LANG_CONFIG_SMPLAYER)" IDCANCEL ${||} Abort ${|}
604 ${EndIf}
605 SectionEnd
607 Section "!$(MPLAYER_LANG_BIN_CODECS) (${CODECS_DATE})"
608 SectionIn 1
609 ${If} $SelectedCPUType > 2
610 ${PrintProgress} "$(MPLAYER_LANG_STATUS_INST_CODECS)"
611 SetOutPath "$INSTDIR\codecs"
612 File "Codecs\*.0"
613 File "Codecs\*.acm"
614 File "Codecs\*.ax"
615 File "Codecs\*.dll"
616 File "Codecs\*.qtx"
617 File "Codecs\*.so"
618 File "Codecs\*.vwp"
619 File "Codecs\*.xa"
620 ${EndIf}
621 SectionEnd
623 Section "-Write Uninstaller"
624 ${PrintProgress} "$(MPLAYER_LANG_STATUS_MAKEUNINST)"
625 WriteUninstaller "$INSTDIR\Uninstall.exe"
626 SectionEnd
628 Section "-Create Shortcuts"
629 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
630 ${PrintProgress} "$(MPLAYER_LANG_STATUS_SHORTCUTS)"
631 CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
633 SetShellVarContext current
634 Delete "$SMPROGRAMS\$StartMenuFolder\*.lnk"
635 Delete "$SMPROGRAMS\$StartMenuFolder\*.pif"
636 Delete "$SMPROGRAMS\$StartMenuFolder\*.url"
638 SetShellVarContext all
639 Delete "$SMPROGRAMS\$StartMenuFolder\*.lnk"
640 Delete "$SMPROGRAMS\$StartMenuFolder\*.pif"
641 Delete "$SMPROGRAMS\$StartMenuFolder\*.url"
643 ${If} ${FileExists} "$INSTDIR\MPUI.exe"
644 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\MPUI.lnk" "$INSTDIR\MPUI.exe"
645 CreateShortCut "$DESKTOP\MPUI.lnk" "$INSTDIR\MPUI.exe"
646 ${EndIf}
647 ${If} ${FileExists} "$INSTDIR\SMPlayer.exe"
648 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\SMPlayer.lnk" "$INSTDIR\SMPlayer.exe"
649 CreateShortCut "$DESKTOP\SMPlayer.lnk" "$INSTDIR\SMPlayer.exe"
650 ${EndIf}
652 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(MPLAYER_LANG_SHORTCUT_UPDATE).lnk" "$INSTDIR\Updater.exe" "/L=$LANGUAGE"
653 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(MPLAYER_LANG_SHORTCUT_README).lnk" "$INSTDIR\Readme.html"
654 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(MPLAYER_LANG_SHORTCUT_MANUAL).lnk" "$INSTDIR\Manual.html"
656 ${If} ${AtLeastWinVista}
657 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(MPLAYER_LANG_SHORTCUT_APPREG).lnk" "$INSTDIR\AppRegGUI.exe"
658 ${EndIf}
660 ${CreateWebLink} "$SMPROGRAMS\$StartMenuFolder\$(MPLAYER_LANG_SHORTCUT_SITE_MULDERS).url" "http://muldersoft.com/"
661 ${CreateWebLink} "$SMPROGRAMS\$StartMenuFolder\$(MPLAYER_LANG_SHORTCUT_SITE_MPWIN32).url" "http://oss.netfarm.it/mplayer-win32.php"
662 ${CreateWebLink} "$SMPROGRAMS\$StartMenuFolder\$(MPLAYER_LANG_SHORTCUT_SITE_MPLAYER).url" "http://www.mplayerhq.hu/"
664 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\SMPlayer.lnk"
665 ${StdUtils.InvokeShellVerb} $R1 "$SMPROGRAMS\$StartMenuFolder" "SMPlayer.lnk" ${StdUtils.Const.ShellVerb.PinToTaskbar}
666 DetailPrint 'Pin: "$SMPROGRAMS\$StartMenuFolder\SMPlayer.lnk" -> $R1'
667 ${EndIf}
668 !insertmacro MUI_STARTMENU_WRITE_END
669 SectionEnd
671 Section "-ApplyTweaks"
672 ${PrintProgress} "$(MPLAYER_LANG_STATUS_TWEAKS)"
673 DetailPrint "$(MPLAYER_LANG_APPLYING_TWEAKS)"
675 IntOp $0 $SelectedTweaks & 1
676 ${If} $0 <> 0
677 ${AndIf} ${FileExists} "$INSTDIR\SMPlayer.ini"
678 DetailPrint "SMPlayer: Enable tweak 'gui=SkinGUI'"
679 WriteINIStr "$INSTDIR\SMPlayer.ini" "gui" "gui" "SkinGUI"
680 WriteINIStr "$INSTDIR\SMPlayer.ini" "gui" "qt_style" "Fusion"
681 WriteINIStr "$INSTDIR\SMPlayer.ini" "gui" "iconset" "Modern"
682 ${EndIf}
684 IntOp $0 $SelectedTweaks & 2
685 ${If} $0 <> 0
686 ${AndIf} ${FileExists} "$INSTDIR\MPUI.ini"
687 DetailPrint "MPUI: Enable tweak '-vo gl'"
688 WriteINIStr "$INSTDIR\MPUI.ini" "MPUI" "Params" "-vo gl -lavdopts threads=$DetectedCPUCores"
689 ${EndIf}
690 ${If} $0 <> 0
691 ${AndIf} ${FileExists} "$INSTDIR\SMPlayer.ini"
692 DetailPrint "SMPlayer: Enable tweak '-vo gl'"
693 WriteINIStr "$INSTDIR\SMPlayer.ini" "%General" "driver\vo" "gl"
694 ${EndIf}
696 IntOp $0 $SelectedTweaks & 4
697 ${If} $0 <> 0
698 ${AndIf} ${FileExists} "$INSTDIR\MPUI.ini"
699 DetailPrint "MPUI: Enable tweak '-af volnorm=2'"
700 ReadINIStr $1 "$INSTDIR\MPUI.ini" "MPUI" "Params"
701 WriteINIStr "$INSTDIR\MPUI.ini" "MPUI" "Params" "$1 -af volnorm=2"
702 ${EndIf}
703 ${If} $0 <> 0
704 ${AndIf} ${FileExists} "$INSTDIR\SMPlayer.ini"
705 DetailPrint "SMPlayer: Enable tweak 'initial_volnorm=true'"
706 WriteINIStr "$INSTDIR\SMPlayer.ini" "defaults" "initial_volnorm" "true"
707 ${EndIf}
708 SectionEnd
710 Section "$(MPLAYER_LANG_COMPRESS_FILES)"
711 SectionIn 1 2
712 ${PrintProgress} "$(MPLAYER_LANG_STATUS_INST_COMPRESS)"
714 File "/oname=$PLUGINSDIR\UPX.exe" "${UPX_PATH}\UPX.exe"
716 ${PackAll} "$INSTDIR" "*.exe"
717 ${PackAll} "$INSTDIR" "*.dll"
718 ${PackAll} "$INSTDIR\codecs" "*.acm"
719 ${PackAll} "$INSTDIR\codecs" "*.ax"
720 ${PackAll} "$INSTDIR\codecs" "*.dll"
721 ${PackAll} "$INSTDIR\codecs" "*.qtx"
723 Delete "$PLUGINSDIR\UPX.exe"
724 SectionEnd
726 Section "-Update Font Cache"
727 ${PrintProgress} "$(MPLAYER_LANG_STATUS_INST_FONTCACHE)"
729 SetShellVarContext current
730 Delete "$APPDATA\fontconfig\cache\*.*"
731 Delete "$LOCALAPPDATA\fontconfig\cache\*.*"
733 SetShellVarContext all
734 Delete "$APPDATA\fontconfig\cache\*.*"
735 Delete "$LOCALAPPDATA\fontconfig\cache\*.*"
737 File "/oname=$PLUGINSDIR\Sample.avi" "Resources\Sample.avi"
738 DetailPrint "$(MPLAYER_LANG_UPDATING_FONTCACHE)"
739 NsExec::Exec '"$INSTDIR\MPlayer.exe" -fontconfig -ass -vo null -ao null "$PLUGINSDIR\Sample.avi"'
740 Delete "Resources\Sample.avi"
741 SectionEnd
743 Section "-Update Registry"
744 ${PrintProgress} "$(MPLAYER_LANG_STATUS_REGISTRY)"
745 DetailPrint "$(MPLAYER_LANG_WRITING_REGISTRY)"
747 ; Clean up
748 DeleteRegKey HKLM "${MPlayerRegPath}"
749 DeleteRegKey HKCU "${MPlayerRegPath}"
750 DeleteRegValue HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" "MPlayerForWindows_AutoUpdateV2"
751 DeleteRegValue HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" "MPlayerForWindows_AutoUpdateV2"
753 ; Uninstaller
754 WriteRegStr HKLM "${MPlayerRegPath}" "InstallLocation" "$INSTDIR"
755 WriteRegStr HKLM "${MPlayerRegPath}" "UninstallString" '"$INSTDIR\Uninstall.exe"'
756 WriteRegStr HKLM "${MPlayerRegPath}" "DisplayName" "$(MPLAYER_LANG_MPLAYER_WIN32)"
757 WriteRegStr HKLM "${MPlayerRegPath}" "DisplayIcon" "$INSTDIR\MPlayer.exe,0"
758 WriteRegStr HKLM "${MPlayerRegPath}" "DisplayVersion" "${MPLAYER_DATE}"
759 WriteRegStr HKLM "${MPlayerRegPath}" "URLInfoAbout" "http://muldersoft.com/"
760 WriteRegStr HKLM "${MPlayerRegPath}" "URLUpdateInfo" "http://muldersoft.com/"
761 WriteRegStr HKLM "${MPlayerRegPath}" "Publisher" "The MPlayer Team"
762 WriteRegDWORD HKLM "${MPlayerRegPath}" "NoModify" 1
763 WriteRegDWORD HKLM "${MPlayerRegPath}" "NoRepair" 1
765 ; Shell
766 DeleteRegKey HKCR "MPlayerForWindowsV2.File"
767 DeleteRegKey HKLM "SOFTWARE\Classes\MPlayerForWindowsV2.File"
768 DeleteRegKey HKCU "SOFTWARE\Classes\MPlayerForWindowsV2.File"
769 ${If} ${FileExists} "$INSTDIR\MPUI.exe"
770 WriteRegStr HKLM "SOFTWARE\Classes\MPlayerForWindowsV2.File\shell\open\command" "" '"$INSTDIR\MPUI.exe" "%1"'
771 WriteRegStr HKLM "SOFTWARE\Classes\MPlayerForWindowsV2.File\DefaultIcon" "" "$INSTDIR\MPUI.exe,0"
772 ${EndIf}
773 ${If} ${FileExists} "$INSTDIR\SMPlayer.exe"
774 WriteRegStr HKLM "SOFTWARE\Classes\MPlayerForWindowsV2.File\shell\open\command" "" '"$INSTDIR\SMPlayer.exe" "%1"'
775 WriteRegStr HKLM "SOFTWARE\Classes\MPlayerForWindowsV2.File\DefaultIcon" "" "$INSTDIR\SMPlayer.exe,1"
776 ${EndIf}
778 ; Register App
779 DeleteRegValue HKCU "SOFTWARE\RegisteredApplications" "MPlayerForWindowsV2"
780 WriteRegStr HKLM "SOFTWARE\RegisteredApplications" "MPlayerForWindowsV2" "${MPlayerRegPath}\Capabilities"
782 ; Capabilities
783 WriteRegStr HKLM "${MPlayerRegPath}\Capabilities" "ApplicationName" "$(MPLAYER_LANG_MPLAYER_WIN32)"
784 WriteRegStr HKLM "${MPlayerRegPath}\Capabilities" "ApplicationDescription" "$(MPLAYER_LANG_MPLAYER_WIN32)"
785 WriteRegStr HKLM "${MPlayerRegPath}\Capabilities" "ApplicationDescription" "$(MPLAYER_LANG_MPLAYER_WIN32)"
787 ; File Associations
788 ${RegisterFileExtCapability} "256"
789 ${RegisterFileExtCapability} "3GP"
790 ${RegisterFileExtCapability} "AAC"
791 ${RegisterFileExtCapability} "ASF"
792 ${RegisterFileExtCapability} "AVI"
793 ${RegisterFileExtCapability} "BIN"
794 ${RegisterFileExtCapability} "DAT"
795 ${RegisterFileExtCapability} "DIVX"
796 ${RegisterFileExtCapability} "EVO"
797 ${RegisterFileExtCapability} "FLV"
798 ${RegisterFileExtCapability} "M2V"
799 ${RegisterFileExtCapability} "M2TS"
800 ${RegisterFileExtCapability} "M4A"
801 ${RegisterFileExtCapability} "MKA"
802 ${RegisterFileExtCapability} "MKV"
803 ${RegisterFileExtCapability} "MOV"
804 ${RegisterFileExtCapability} "MP2"
805 ${RegisterFileExtCapability} "MP3"
806 ${RegisterFileExtCapability} "MP4"
807 ${RegisterFileExtCapability} "MPEG"
808 ${RegisterFileExtCapability} "MPG"
809 ${RegisterFileExtCapability} "MPV"
810 ${RegisterFileExtCapability} "NSV"
811 ${RegisterFileExtCapability} "OGG"
812 ${RegisterFileExtCapability} "OGM"
813 ${RegisterFileExtCapability} "RM"
814 ${RegisterFileExtCapability} "RMVB"
815 ${RegisterFileExtCapability} "TS"
816 ${RegisterFileExtCapability} "VOB"
817 ${RegisterFileExtCapability} "WAV"
818 ${RegisterFileExtCapability} "WEBM"
819 ${RegisterFileExtCapability} "WMV"
821 ; Reset auto update interval
822 DeleteRegValue HKLM "${MPlayerRegPath}" "LastUpdateCheck"
823 DeleteRegValue HKCU "${MPlayerRegPath}" "LastUpdateCheck"
824 SectionEnd
826 Section "$(MPLAYER_LANG_INST_AUTOUPDATE)" SECID_AUTOUPDATE
827 SectionIn 1 2
828 DetailPrint "$(MPLAYER_LANG_SCHEDULE_UPDATE)"
829 WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" "MPlayerForWindows_AutoUpdateV2" '"$INSTDIR\Updater.exe" /L=$LANGUAGE /AutoCheck'
830 SectionEnd
832 Section "-Protect Files"
833 SetFileAttributes "$INSTDIR\AppRegGUI.exe" FILE_ATTRIBUTE_READONLY
834 SetFileAttributes "$INSTDIR\mplayer.exe" FILE_ATTRIBUTE_READONLY
835 SetFileAttributes "$INSTDIR\MPUI.exe" FILE_ATTRIBUTE_READONLY
836 SetFileAttributes "$INSTDIR\smplayer.exe" FILE_ATTRIBUTE_READONLY
837 SetFileAttributes "$INSTDIR\Updater.exe" FILE_ATTRIBUTE_READONLY
839 SetFileAttributes "$INSTDIR\dsnative.dll" FILE_ATTRIBUTE_READONLY
840 SetFileAttributes "$INSTDIR\libeay32.dll" FILE_ATTRIBUTE_READONLY
841 SetFileAttributes "$INSTDIR\libgcc_s_dw2-1.dll" FILE_ATTRIBUTE_READONLY
842 SetFileAttributes "$INSTDIR\libstdc++-6.dll" FILE_ATTRIBUTE_READONLY
843 SetFileAttributes "$INSTDIR\libwinpthread-1.dll" FILE_ATTRIBUTE_READONLY
844 SetFileAttributes "$INSTDIR\Qt5Core.dll" FILE_ATTRIBUTE_READONLY
845 SetFileAttributes "$INSTDIR\Qt5Gui.dll" FILE_ATTRIBUTE_READONLY
846 SetFileAttributes "$INSTDIR\Qt5Network.dll" FILE_ATTRIBUTE_READONLY
847 SetFileAttributes "$INSTDIR\Qt5Script.dll" FILE_ATTRIBUTE_READONLY
848 SetFileAttributes "$INSTDIR\Qt5Widgets.dll" FILE_ATTRIBUTE_READONLY
849 SetFileAttributes "$INSTDIR\Qt5Xml.dll" FILE_ATTRIBUTE_READONLY
850 SetFileAttributes "$INSTDIR\ssleay32.dll" FILE_ATTRIBUTE_READONLY
851 SetFileAttributes "$INSTDIR\zlib1.dll" FILE_ATTRIBUTE_READONLY
852 SectionEnd
854 Section "-Finished"
855 ${PrintStatus} "$(MUI_TEXT_FINISH_TITLE)"
856 SectionEnd
859 ;--------------------------------------------------------------------------------
860 ; UN-INSTALL SECTIONS
861 ;--------------------------------------------------------------------------------
863 Section "Uninstall"
864 SetOutPath "$TEMP"
865 ${PrintProgress} "$(MPLAYER_LANG_STATUS_UNINSTALL)"
867 ; Validate uninstall path
868 ${IfThen} "$INSTDIR" == "" ${|} Abort ${|}
869 StrCpy $0 "$INSTDIR" "" -2
870 ${IfThen} $0 == ":\" ${|} Abort ${|}
872 ; Startmenu
873 !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
874 ${IfNot} "$StartMenuFolder" == ""
875 SetShellVarContext current
876 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\SMPlayer.lnk"
877 ${StdUtils.InvokeShellVerb} $R1 "$SMPROGRAMS\$StartMenuFolder" "SMPlayer.lnk" ${StdUtils.Const.ShellVerb.UnpinFromTaskbar}
878 DetailPrint 'Unpin: "$SMPROGRAMS\$StartMenuFolder\SMPlayer.lnk" -> $R1'
879 ${EndIf}
880 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\*.*"
881 Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.lnk"
882 Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.url"
883 Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.pif"
884 RMDir "$SMPROGRAMS\$StartMenuFolder"
885 ${EndIf}
886 SetShellVarContext all
887 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\SMPlayer.lnk"
888 ${StdUtils.InvokeShellVerb} $R1 "$SMPROGRAMS\$StartMenuFolder" "SMPlayer.lnk" ${StdUtils.Const.ShellVerb.UnpinFromTaskbar}
889 DetailPrint 'Unpin: "$SMPROGRAMS\$StartMenuFolder\SMPlayer.lnk" -> $R1'
890 ${EndIf}
891 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\*.*"
892 Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.lnk"
893 Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.url"
894 Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.pif"
895 RMDir "$SMPROGRAMS\$StartMenuFolder"
896 ${EndIf}
897 ${EndIf}
899 ; Desktop icons
900 Delete /REBOOTOK "$DESKTOP\MPUI.lnk"
901 Delete /REBOOTOK "$DESKTOP\SMPlayer.lnk"
903 ; Files
904 RMDir /r "$INSTDIR"
906 ; Virtual Store
907 ${GetVirtualStorePath} $0 "$INSTDIR"
908 ${If} ${FileExists} "$0\*.*"
909 RMDir /r "$0"
910 ${EndIf}
912 ; Registry Keys
913 DeleteRegKey HKLM "${MPlayerRegPath}"
914 DeleteRegKey HKCU "${MPlayerRegPath}"
915 DeleteRegValue HKLM "SOFTWARE\RegisteredApplications" "MPlayerForWindowsV2"
916 DeleteRegValue HKCU "SOFTWARE\RegisteredApplications" "MPlayerForWindowsV2"
918 ; Auto Update
919 DeleteRegValue HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" "MPlayerForWindows_AutoUpdateV2"
920 DeleteRegValue HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" "MPlayerForWindows_AutoUpdateV2"
922 ; Shell
923 DeleteRegKey HKCR "MPlayerForWindowsV2.File"
924 DeleteRegKey HKLM "SOFTWARE\Classes\MPlayerForWindowsV2.File"
925 DeleteRegKey HKCU "SOFTWARE\Classes\MPlayerForWindowsV2.File"
927 ${PrintStatus} "$(MUI_UNTEXT_FINISH_TITLE)"
928 SectionEnd
931 ;--------------------------------------------------------------------------------
932 ; SECTION SELECTION CHANGED
933 ;--------------------------------------------------------------------------------
935 Function .onSelChange
936 ${IfNot} ${SectionIsSelected} ${SECID_MPUI}
937 ${AndIfNot} ${SectionIsSelected} ${SECID_SMPLAYER}
938 MessageBox MB_TOPMOST|MB_ICONEXCLAMATION "$(MPLAYER_LANG_SELCHANGE)"
939 SectionGetFlags ${SECID_MPUI} $0
940 IntOp $0 $0 | ${SF_SELECTED}
941 SectionSetFlags ${SECID_MPUI} $0
942 ${EndIf}
944 ${IfNot} ${SectionIsSelected} ${SECID_AUTOUPDATE}
945 StrCpy $0 "nope"
946 ${IfCmd} MessageBox MB_TOPMOST|MB_ICONEXCLAMATION|MB_YESNO|MB_DEFBUTTON2 "$(MPLAYER_LANG_SEL_AUTOUPDATE)" IDNO ${||} StrCpy $0 "ok" ${|}
947 ${If} "$0" == "ok"
948 SectionGetFlags ${SECID_AUTOUPDATE} $0
949 IntOp $0 $0 | ${SF_SELECTED}
950 SectionSetFlags ${SECID_AUTOUPDATE} $0
951 ${EndIf}
952 ${EndIf}
953 FunctionEnd
956 ;--------------------------------------------------------------------------------
957 ; LOCKED-LIST PLUGIN
958 ;--------------------------------------------------------------------------------
960 !macro LockedListPage_Function
961 !insertmacro MUI_HEADER_TEXT "$(MPLAYER_LANG_LOCKEDLIST_HEADER)" "$(MPLAYER_LANG_LOCKEDLIST_TEXT)"
963 InitPluginsDir
964 File /oname=$PLUGINSDIR\LockedList64.dll `${NSISDIR}\Plugins\LockedList64.dll`
966 LockedList::AddModule "\MPlayer.exe"
967 LockedList::AddModule "\SMPlayer.exe"
968 LockedList::AddModule "\MPUI.exe"
969 LockedList::AddModule "${NSISDIR}\Qt5Core.dll"
971 LockedList::Dialog /autonext /ignore "$(MPLAYER_LANG_IGNORE)" /heading "$(MPLAYER_LANG_LOCKEDLIST_HEADING)" /noprograms "$(MPLAYER_LANG_LOCKEDLIST_NOPROG)" /searching "$(MPLAYER_LANG_LOCKEDLIST_SEARCH)" /colheadings "$(MPLAYER_LANG_LOCKEDLIST_COLHDR1)" "$(MPLAYER_LANG_LOCKEDLIST_COLHDR2)"
972 Pop $R0
973 !macroend
975 Function LockedListPage_Show
976 !insertmacro LockedListPage_Function
977 FunctionEnd
979 Function un.LockedListPage_Show
980 !insertmacro LockedListPage_Function
981 FunctionEnd
984 ;--------------------------------------------------------------------------------
985 ; CUSTOME PAGE: CPU SELECTOR
986 ;--------------------------------------------------------------------------------
988 Function SelectCPUPage_Show
989 ; Detect CPU type, if not detected yet
990 ${If} $DetectedCPUType < 2
991 ${OrIf} $DetectedCPUType > 6
992 Call DetectCPUType
993 !insertmacro INSTALLOPTIONS_READ $0 "Page_CPU.ini" "Field $DetectedCPUType" "Text"
994 !insertmacro INSTALLOPTIONS_WRITE "Page_CPU.ini" "Field $DetectedCPUType" "Text" "$0 <-- recommended"
995 ${EndIf}
997 ; Make sure the current selection is valid
998 ${IfThen} $SelectedCPUType < 2 ${|} StrCpy $SelectedCPUType $DetectedCPUType ${|}
999 ${IfThen} $SelectedCPUType > 6 ${|} StrCpy $SelectedCPUType $DetectedCPUType ${|}
1001 ; Disable 64-Bit build on the 32-Bit system
1002 ${IfNot} ${RunningX64}
1003 !insertmacro INSTALLOPTIONS_WRITE "Page_CPU.ini" "Field 2" "Flags" "DISABLED"
1004 ${IfThen} $SelectedCPUType < 3 ${|} StrCpy $SelectedCPUType 3 ${|}
1005 ${EndIf}
1007 ; Translate
1008 !insertmacro INSTALLOPTIONS_WRITE "Page_CPU.ini" "Field 1" "Text" "$(MPLAYER_LANG_SELECT_CPU_TYPE)"
1009 !insertmacro INSTALLOPTIONS_WRITE "Page_CPU.ini" "Field 7" "Text" "$(MPLAYER_LANG_SELECT_CPU_HINT)"
1011 ; Apply current selection to dialog
1012 ${For} $0 2 6
1013 ${If} $0 == $SelectedCPUType
1014 !insertmacro INSTALLOPTIONS_WRITE "Page_CPU.ini" "Field $0" "State" "1"
1015 ${Else}
1016 !insertmacro INSTALLOPTIONS_WRITE "Page_CPU.ini" "Field $0" "State" "0"
1017 ${EndIf}
1018 ${Next}
1020 ; Display dialog
1021 !insertmacro MUI_HEADER_TEXT "$(MPLAYER_LANG_SELECT_CPU_HEAD)" "$(MPLAYER_LANG_SELECT_CPU_TEXT)"
1022 !insertmacro INSTALLOPTIONS_DISPLAY "Page_CPU.ini"
1024 ; Read new selection from dialog
1025 StrCpy $SelectedCPUType 0
1026 ${For} $0 2 6
1027 !insertmacro INSTALLOPTIONS_READ $1 "Page_CPU.ini" "Field $0" "State"
1028 ${IfThen} $1 == 1 ${|} StrCpy $SelectedCPUType $0 ${|}
1029 ${Next}
1030 FunctionEnd
1032 Function SelectCPUPage_Validate
1033 ; Read new selection from dialog
1034 StrCpy $2 0
1035 ${For} $0 2 6
1036 !insertmacro INSTALLOPTIONS_READ $1 "Page_CPU.ini" "Field $0" "State"
1037 ${IfThen} $1 == 1 ${|} StrCpy $2 $0 ${|}
1038 ${Next}
1040 ; Validate selection
1041 ${If} $2 < 2
1042 ${OrIf} $2 > 6
1043 MessageBox MB_ICONSTOP "Oups, invalid selection detected!"
1044 Abort
1045 ${EndIf}
1047 ; Make sure we cannot select 64-Bit on the 32-Bit system
1048 ${IfNot} ${RunningX64}
1049 ${AndIf} $2 < 3
1050 MessageBox MB_ICONSTOP "Oups, invalid selection detected!"
1051 Abort
1052 ${EndIf}
1053 FunctionEnd
1055 Function DetectCPUType
1056 StrCpy $DetectedCPUType 6 ;generic
1057 StrCpy $DetectedCPUCores 2
1059 ${IfNot} ${Silent}
1060 Banner::show /NOUNLOAD "$(MPLAYER_LANG_DETECTING)"
1061 ${EndIf}
1063 ${CPUFeatures.GetCount} $0
1064 ${IfNot} $0 == "error"
1065 StrCpy $DetectedCPUCores $0
1066 ${EndIf}
1068 ; Debug Code
1069 !ifdef CPU_DETECT_DEBUG
1070 ${CPUFeatures.GetVendor} $0
1071 ${CPUFeatures.CheckFeature} "MMX1" $1
1072 ${CPUFeatures.CheckFeature} "3DNOW" $2
1073 ${CPUFeatures.CheckFeature} "SSE3" $3
1074 ${CPUFeatures.CheckFeature} "SSSE3" $4
1075 ${CPUFeatures.CheckFeature} "SSE4.2" $5
1076 ${CPUFeatures.CheckFeature} "AVX1" $6
1077 ${CPUFeatures.CheckFeature} "FMA4" $7
1078 StrCpy $9 `Vendor = $0`
1079 StrCpy $9 `$9$\n"MMX1" = $1`
1080 StrCpy $9 `$9$\n"3DNOW" = $2`
1081 StrCpy $9 `$9$\n"SSE3" = $3`
1082 StrCpy $9 `$9$\n"SSSE3" = $4`
1083 StrCpy $9 `$9$\n"SSE4.2" = $5`
1084 StrCpy $9 `$9$\n"AVX1" = $6`
1085 StrCpy $9 `$9$\n"FMA4" = $7`
1086 MessageBox MB_TOPMOST `$9`
1087 !endif
1089 ; Make sure we have at least MMX
1090 ${IfNot} ${CPUSupports} "MMX1"
1091 Banner::destroy
1092 Return
1093 ${EndIf}
1095 ${If} ${RunningX64}
1096 ; On 64-Bit system we prefer the x64 build
1097 StrCpy $DetectedCPUType 2
1098 ${Else}
1099 ; Select the "best" model for Intel's
1100 ${If} ${CPUIsIntel}
1101 ; Core2 (SSE3 + SSSE3)
1102 ${If} ${CPUSupportsAll} "SSE3,SSSE3"
1103 StrCpy $DetectedCPUType 3
1104 ${EndIf}
1105 ; Nehalem (SSE3 + SSSE3 + SSE4.2)
1106 ${If} ${CPUSupportsAll} "SSE3,SSSE3,SSE4.2"
1107 StrCpy $DetectedCPUType 4
1108 ${EndIf}
1109 ${EndIf}
1110 ; Select the "best" model for AMD's
1111 ${If} ${CPUIsAMD}
1112 ; K8+SSE3 (3DNow! + SSE3)
1113 ${If} ${CPUSupportsAll} "3DNOW,SSE3"
1114 StrCpy $DetectedCPUType 5
1115 ${EndIf}
1116 ${EndIf}
1117 ${EndIf}
1119 Banner::destroy
1120 FunctionEnd
1123 ;--------------------------------------------------------------------------------
1124 ; CUSTOME PAGE: TWEAKS
1125 ;--------------------------------------------------------------------------------
1127 Function SetTweaksPage_Show
1128 ; Apply current selection to dialog
1129 StrCpy $0 1
1130 ${For} $1 2 4
1131 IntOp $2 $0 & $SelectedTweaks
1132 ${If} $2 <> 0
1133 !insertmacro INSTALLOPTIONS_WRITE "Page_Tweaks.ini" "Field $1" "State" "1"
1134 ${Else}
1135 !insertmacro INSTALLOPTIONS_WRITE "Page_Tweaks.ini" "Field $1" "State" "0"
1136 ${EndIf}
1137 IntOp $0 $0 << 1
1138 ${Next}
1140 ; Translate
1141 !insertmacro INSTALLOPTIONS_WRITE "Page_Tweaks.ini" "Field 1" "Text" "$(MPLAYER_LANG_TWEAKS_HINT)"
1142 !insertmacro INSTALLOPTIONS_WRITE "Page_Tweaks.ini" "Field 2" "Text" "$(MPLAYER_LANG_TWEAKS_SKINNEDUI)"
1143 !insertmacro INSTALLOPTIONS_WRITE "Page_Tweaks.ini" "Field 3" "Text" "$(MPLAYER_LANG_TWEAKS_OPENGL)"
1144 !insertmacro INSTALLOPTIONS_WRITE "Page_Tweaks.ini" "Field 4" "Text" "$(MPLAYER_LANG_TWEAKS_VOLNORM)"
1146 ; Display dialog
1147 !insertmacro MUI_HEADER_TEXT "$(MPLAYER_LANG_TWEAKS_HEAD)" "$(MPLAYER_LANG_TWEAKS_TEXT)"
1148 !insertmacro INSTALLOPTIONS_DISPLAY "Page_Tweaks.ini"
1150 ; Read new selection from dialog
1151 StrCpy $0 1
1152 StrCpy $SelectedTweaks 0
1153 ${For} $1 2 4
1154 !insertmacro INSTALLOPTIONS_READ $2 "Page_Tweaks.ini" "Field $1" "State"
1155 ${IfThen} $2 = 1 ${|} IntOp $SelectedTweaks $SelectedTweaks | $0 ${|}
1156 IntOp $0 $0 << 1
1157 ${Next}
1158 FunctionEnd
1161 ;--------------------------------------------------------------------------------
1162 ; CHECK FOR UPDATE MODE
1163 ;--------------------------------------------------------------------------------
1165 !macro SetControlEnabled item_id enable
1166 FindWindow $0 "#32770" "" $HWNDPARENT
1167 ${IfNot} $0 == 0
1168 GetDlgItem $1 $0 ${item_id}
1169 EnableWindow $1 ${enable}
1170 ${EndIf}
1171 !macroend
1173 !macro SkipToNextPage
1174 GetDlgItem $0 $HWNDPARENT 1
1175 System::Call "User32::PostMessage(i $HWNDPARENT, i ${WM_COMMAND}, i 1, i $R0)"
1176 !macroend
1178 !macro EnablePathEditable flag show_msg
1179 !insertmacro SetControlEnabled 1019 ${flag}
1180 !insertmacro SetControlEnabled 1001 ${flag}
1181 ${IfNot} $NotUpdateInstall = ${flag}
1182 !if ${show_msg} == 1
1183 MessageBox MB_OK|MB_ICONINFORMATION "$(MPLAYER_LANG_FORCE_UPDATE)" /SD IDOK
1184 !endif
1185 StrCpy $NotUpdateInstall ${flag}
1186 !insertmacro SkipToNextPage
1187 ${EndIf}
1188 !macroend
1190 Function CheckForUpdate
1191 ${StdUtils.TestParameter} $0 "Update"
1192 ${If} "$0" == "true"
1193 !insertmacro EnablePathEditable 0 0
1194 Return
1195 ${EndIf}
1197 ${If} ${FileExists} "$INSTDIR\MPlayer.exe"
1198 ${If} $NotUpdateInstall = 1
1199 ${AndIf} ${FileExists} "$INSTDIR\version.tag"
1200 ReadINIStr $0 "$INSTDIR\version.tag" "mplayer_version" "build_no"
1201 ${If} $0 > ${MPLAYER_BUILDNO}
1202 MessageBox MB_OK|MB_ICONEXCLAMATION "$(MPLAYER_LANG_CAN_NOT_UPDATE)"
1203 Quit
1204 ${EndIf}
1205 ${If} $0 = ${MPLAYER_BUILDNO}
1206 ${IfCmd} MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(MPLAYER_LANG_CONFIRM_UPDATE)" /SD IDYES IDNO ${||} Quit ${|}
1207 ${EndIf}
1208 ${EndIf}
1209 !insertmacro EnablePathEditable 0 1
1210 Return
1211 ${EndIf}
1213 !insertmacro EnablePathEditable 1 0
1214 FunctionEnd
1217 ;--------------------------------------------------------------------------------
1218 ; FINISHED
1219 ;--------------------------------------------------------------------------------
1221 Function RunAppFunction
1222 !insertmacro DisableNextButton $R0
1223 ${If} ${FileExists} "$INSTDIR\SMPlayer.exe"
1224 ${StdUtils.ExecShellAsUser} $R0 "$INSTDIR\SMPlayer.exe" "open" "https://www.youtube.com/watch?v=SkVqJ1SGeL0"
1225 ${Else}
1226 ${StdUtils.ExecShellAsUser} $R0 "$INSTDIR\MPUI.exe" "open" "http://www.caminandes.com/download/03_caminandes_llamigos_1080p.mp4"
1227 ${EndIf}
1228 FunctionEnd
1230 Function ShowReadmeFunction
1231 !insertmacro DisableNextButton $R0
1232 ${StdUtils.ExecShellAsUser} $R0 "$INSTDIR\Readme.html" "open" ""
1233 FunctionEnd
1235 Function .onInstSuccess
1236 ${StdUtils.ExecShellAsUser} $R0 "$SMPROGRAMS\$StartMenuFolder" "explore" ""
1237 FunctionEnd
1240 ### EOF ###