Check installed version. Abort if installed version is newer than setup version....
[mplayer-setup-win32.git] / MPUI_Setup.nsi
blob2fc35ca47ee845f6b0694a72b62d0cd5c349f984
1 ; ///////////////////////////////////////////////////////////////////////////////
2 ; // MPlayer for Windows - Install Script
3 ; // Copyright (C) 2004-2018 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 ${If} ${FileExists} "$INSTDIR\version.tag"
369 ReadINIStr $0 "$INSTDIR\version.tag" "mplayer_version" "build_no"
370 ${If} $0 > ${MPLAYER_BUILDNO}
371 MessageBox MB_OK|MB_ICONEXCLAMATION|MB_TOPMOST "$(MPLAYER_LANG_CAN_NOT_UPDATE)"
372 Quit
373 ${EndIf}
374 ${EndIf}
375 SectionEnd
377 Section "-Clean Up"
378 ${PrintProgress} "$(MPLAYER_LANG_STATUS_INST_CLEAN)"
380 SetShellVarContext all
381 SetOutPath "$INSTDIR"
383 ; Uninstall old version (aka "Setup v1")
384 ClearErrors
385 ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{DB9E4EAB-2717-499F-8D56-4CC8A644AB60}" "InstallLocation"
386 ${IfNot} ${Errors}
387 MessageBox MB_ICONINFORMATION|MB_OK "$(MPLAYER_LANG_UNINSTALL_OLDVER)"
388 File "/oname=$PLUGINSDIR\Uninstall-V1.exe" "Resources\Uninstall-V1.exe"
389 HideWindow
390 ExecWait '"$PLUGINSDIR\Uninstall-V1.exe" _?=$0'
391 Delete /REBOOTOK "$PLUGINSDIR\Uninstall-V1.exe"
392 BringToFront
393 ${EndIf}
395 ; Clean registry
396 DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{DB9E4EAB-2717-499F-8D56-4CC8A644AB60}"
397 DeleteRegKey HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{DB9E4EAB-2717-499F-8D56-4CC8A644AB60}"
398 DeleteRegValue HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" "MPlayerForWindows_UpdateReminder"
399 DeleteRegValue HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" "MPlayerForWindows_UpdateReminder"
401 ; Make sure MPlayer isn't running
402 ${Do}
403 ClearErrors
404 Delete "$INSTDIR\MPlayer.exe"
405 Delete "$INSTDIR\SMPlayer.exe"
406 Delete "$INSTDIR\MPUI.exe"
407 ${If} ${Errors}
408 ${IfCmd} MessageBox MB_TOPMOST|MB_ICONEXCLAMATION|MB_OKCANCEL "$(MPLAYER_LANG_STILL_RUNNING)" IDCANCEL ${||} Abort ${|}
409 ${Else}
410 ${Break}
411 ${EndIf}
412 ${Loop}
414 ; Clean the install folder
415 Delete "$INSTDIR\*.exe"
416 Delete "$INSTDIR\*.dll"
417 Delete "$INSTDIR\*.ini"
418 Delete "$INSTDIR\*.txt"
419 Delete "$INSTDIR\*.html"
420 Delete "$INSTDIR\*.htm"
421 Delete "$INSTDIR\*.ass"
422 Delete "$INSTDIR\*.m3u8"
423 Delete "$INSTDIR\*.tag"
425 RMDir /r "$INSTDIR\codecs"
426 RMDir /r "$INSTDIR\fonts"
427 RMDir /r "$INSTDIR\imageformats"
428 RMDir /r "$INSTDIR\legal_stuff"
429 RMDir /r "$INSTDIR\locale"
430 RMDir /r "$INSTDIR\mplayer"
431 RMDir /r "$INSTDIR\platforms"
432 RMDir /r "$INSTDIR\shortcuts"
433 RMDir /r "$INSTDIR\themes"
434 RMDir /r "$INSTDIR\translations"
436 ; Now deal with Virtual Store
437 ${GetVirtualStorePath} $0 "$INSTDIR"
438 ${If} ${FileExists} "$0\*.*"
439 RMDir /r "$0"
440 ${EndIf}
441 SectionEnd
443 Section "!MPlayer r${MPLAYER_REVISION}" SECID_MPLAYER
444 SectionIn 1 2 RO
445 ${PrintProgress} "$(MPLAYER_LANG_STATUS_INST_MPLAYER)"
446 SetOutPath "$INSTDIR"
448 ; Detect
449 ${If} ${Silent}
450 Call DetectCPUType
451 StrCpy $SelectedCPUType $DetectedCPUType
452 ${EndIf}
454 ; MPlayer.exe
455 ${Select} $SelectedCPUType
456 ${Case} "2"
457 DetailPrint "$(MPLAYER_LANG_SELECTED_TYPE): core2"
458 File "Builds\MPlayer-core2\MPlayer.exe"
459 ${Case} "3"
460 DetailPrint "$(MPLAYER_LANG_SELECTED_TYPE): corei7"
461 File "Builds\MPlayer-corei7\MPlayer.exe"
462 ${Case} "4"
463 DetailPrint "$(MPLAYER_LANG_SELECTED_TYPE): k8-sse3"
464 File "Builds\MPlayer-k8-sse3\MPlayer.exe"
465 ${Case} "5"
466 DetailPrint "$(MPLAYER_LANG_SELECTED_TYPE): generic"
467 File "Builds\MPlayer-generic\MPlayer.exe"
468 ${CaseElse}
469 MessageBox MB_TOPMOST|MB_ICONEXCLAMATION|MB_OK "Internal error: Invalid CPU type selection detected!"
470 Abort
471 ${EndSelect}
473 ; Utilities
474 File ".Compile\Updater.exe"
475 File "Resources\AppRegGUI.exe"
477 ; Other MPlayer-related files
478 File "Builds\MPlayer-generic\*.dll"
479 ${ExtractSubDir} "Builds\MPlayer-generic" "mplayer"
480 ${ExtractSubDir} "Builds\MPlayer-generic" "fonts"
482 ; Documents
483 SetOutPath "$INSTDIR"
484 File "GPL.txt"
485 File "/oname=Manual.html" "Builds\MPlayer-generic\MPlayer.man.html"
486 File "Docs\Readme.html"
487 SetOutPath "$INSTDIR\legal_stuff"
488 File "Docs\legal_stuff\*.txt"
490 ; Write version tag
491 ${Do}
492 ClearErrors
493 Delete "$INSTDIR\version.tag"
494 ${If} ${Errors}
495 ${IfCmd} MessageBox MB_TOPMOST|MB_ICONEXCLAMATION|MB_OKCANCEL "$(MPLAYER_LANG_TAG_WRITE)" IDCANCEL ${||} Abort ${|}
496 ${Else}
497 ${Break}
498 ${EndIf}
499 ${Loop}
500 WriteINIStr "$INSTDIR\version.tag" "mplayer_version" "build_no" "${MPLAYER_BUILDNO}"
501 WriteINIStr "$INSTDIR\version.tag" "mplayer_version" "pkg_date" "${MPLAYER_DATE}"
502 SetFileAttributes "$INSTDIR\version.tag" FILE_ATTRIBUTE_READONLY
504 ; Set file access rights
505 ${MakePathPublic} "$INSTDIR"
506 ${MakeFilePublic} "$INSTDIR\mplayer\config"
507 ${MakeFilePublic} "$INSTDIR\fonts\fonts.conf"
508 SectionEnd
510 Section "!MPUI $(MPLAYER_LANG_FRONT_END) v${MPUI_VERSION}" SECID_MPUI
511 SectionIn 1 2
512 ${PrintProgress} "$(MPLAYER_LANG_STATUS_INST_MPUI)"
514 ; Extract files
515 SetOutPath "$INSTDIR"
516 File "MPUI\MPUI.exe"
518 ; Extract locales
519 SetOutPath "$INSTDIR\locale"
520 File "MPUI\locale\*.txt"
522 ; Set file access rights
523 ${MakeFilePublic} "$INSTDIR\MPUI.ini"
525 ; Setup initial config
526 ClearErrors
527 WriteINIStr "$INSTDIR\MPUI.ini" "MPUI" "Params" "-vo direct3d -lavdopts threads=$DetectedCPUCores"
528 WriteINIStr "$INSTDIR\MPUI.ini" "MPUI" "Locale" "$(MPLAYER_LANG_MPUI_DEFAULT_LANGUAGE)"
529 ${If} ${Errors}
530 ${IfCmd} MessageBox MB_TOPMOST|MB_ICONSTOP|MB_DEFBUTTON2|MB_OKCANCEL "$(MPLAYER_LANG_CONFIG_MPUI)" IDCANCEL ${||} Abort ${|}
531 ${EndIf}
532 SectionEnd
534 Section "!SMPlayer $(MPLAYER_LANG_FRONT_END) v${SMPLAYER_VERSION}" SECID_SMPLAYER
535 SectionIn 1
536 ${PrintProgress} "$(MPLAYER_LANG_STATUS_INST_SMPLAYER)"
538 ; SMPlayer program files
539 SetOutPath "$INSTDIR"
540 File "SMPlayer\*.exe"
541 File "SMPlayer\*.dll"
543 ; Additional SMPlayer files
544 ${ExtractSubDir} "SMPlayer" "imageformats"
545 ${ExtractSubDir} "SMPlayer" "platforms"
546 ${ExtractSubDir} "SMPlayer" "shortcuts"
547 ${ExtractSubDir} "SMPlayer" "themes"
548 ${ExtractSubDir} "SMPlayer" "translations"
550 ; Set file access rights
551 ${MakeFilePublic} "$INSTDIR\SMPlayer.ini"
552 ${MakeFilePublic} "$INSTDIR\SMPlayer_files.ini"
553 ${MakeFilePublic} "$INSTDIR\player_info.ini"
554 ${MakeFilePublic} "$INSTDIR\playlist.ini"
555 ${MakeFilePublic} "$INSTDIR\favorites.m3u8"
556 ${MakeFilePublic} "$INSTDIR\radio.m3u8"
557 ${MakeFilePublic} "$INSTDIR\tv.m3u8"
558 ${MakeFilePublic} "$INSTDIR\styles.ass"
559 ${MakeFilePublic} "$INSTDIR\shortcuts\default.keys"
561 ; Setup initial config
562 ${StrRep} $0 "$INSTDIR\MPlayer.exe" "\" "/"
563 ClearErrors
564 WriteINIStr "$INSTDIR\SMPlayer.ini" "%General" "autosync" "true"
565 WriteINIStr "$INSTDIR\SMPlayer.ini" "%General" "autosync_factor" "30"
566 WriteINIStr "$INSTDIR\SMPlayer.ini" "%General" "config_version" "5"
567 WriteINIStr "$INSTDIR\SMPlayer.ini" "%General" "driver\vo" "direct3d"
568 WriteINIStr "$INSTDIR\SMPlayer.ini" "%General" "file_settings_method" "normal"
569 WriteINIStr "$INSTDIR\SMPlayer.ini" "%General" "mplayer_bin" "$0"
570 WriteINIStr "$INSTDIR\SMPlayer.ini" "%General" "osd" "1"
571 WriteINIStr "$INSTDIR\SMPlayer.ini" "%General" "use_audio_equalizer" "false"
572 WriteINIStr "$INSTDIR\SMPlayer.ini" "%General" "use_scaletempo" "0"
573 WriteINIStr "$INSTDIR\SMPlayer.ini" "advanced" "mplayer_additional_options" ""
574 WriteINIStr "$INSTDIR\SMPlayer.ini" "gui" "gui" "DefaultGUI"
575 WriteINIStr "$INSTDIR\SMPlayer.ini" "gui" "iconset" "Numix-remix"
576 WriteINIStr "$INSTDIR\SMPlayer.ini" "gui" "qt_style" "WindowsVista"
577 WriteINIStr "$INSTDIR\SMPlayer.ini" "mplayer_info" "is_mplayer2" "false"
578 WriteINIStr "$INSTDIR\SMPlayer.ini" "mplayer_info" "mplayer_detected_version" "${MPLAYER_REVISION}"
579 WriteINIStr "$INSTDIR\SMPlayer.ini" "mplayer_info" "mplayer_user_supplied_version" "-1"
580 WriteINIStr "$INSTDIR\SMPlayer.ini" "performance" "frame_drop" "true"
581 WriteINIStr "$INSTDIR\SMPlayer.ini" "performance" "priority" "1"
582 WriteINIStr "$INSTDIR\SMPlayer.ini" "performance" "threads" "$DetectedCPUCores"
583 WriteINIStr "$INSTDIR\SMPlayer.ini" "smplayer" "check_for_new_version" "false"
584 WriteINIStr "$INSTDIR\SMPlayer.ini" "smplayer" "check_if_upgraded" "false"
585 WriteINIStr "$INSTDIR\SMPlayer.ini" "update_checker" "enabled" "false"
587 ${If} ${Errors}
588 ${IfCmd} MessageBox MB_TOPMOST|MB_ICONSTOP|MB_DEFBUTTON2|MB_OKCANCEL "$(MPLAYER_LANG_CONFIG_SMPLAYER)" IDCANCEL ${||} Abort ${|}
589 ${EndIf}
590 SectionEnd
592 Section "!$(MPLAYER_LANG_BIN_CODECS) (${CODECS_DATE})"
593 SectionIn 1
594 ${PrintProgress} "$(MPLAYER_LANG_STATUS_INST_CODECS)"
596 SetOutPath "$INSTDIR\codecs"
598 File "Codecs\*.0"
599 File "Codecs\*.acm"
600 File "Codecs\*.ax"
601 File "Codecs\*.dll"
602 File "Codecs\*.qtx"
603 File "Codecs\*.so"
604 File "Codecs\*.vwp"
605 File "Codecs\*.xa"
606 SectionEnd
608 Section "-Write Uninstaller"
609 ${PrintProgress} "$(MPLAYER_LANG_STATUS_MAKEUNINST)"
610 WriteUninstaller "$INSTDIR\Uninstall.exe"
611 SectionEnd
613 Section "-Create Shortcuts"
614 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
615 ${PrintProgress} "$(MPLAYER_LANG_STATUS_SHORTCUTS)"
616 CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
618 SetShellVarContext current
619 Delete "$SMPROGRAMS\$StartMenuFolder\*.lnk"
620 Delete "$SMPROGRAMS\$StartMenuFolder\*.pif"
621 Delete "$SMPROGRAMS\$StartMenuFolder\*.url"
623 SetShellVarContext all
624 Delete "$SMPROGRAMS\$StartMenuFolder\*.lnk"
625 Delete "$SMPROGRAMS\$StartMenuFolder\*.pif"
626 Delete "$SMPROGRAMS\$StartMenuFolder\*.url"
628 ${If} ${FileExists} "$INSTDIR\MPUI.exe"
629 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\MPUI.lnk" "$INSTDIR\MPUI.exe"
630 CreateShortCut "$DESKTOP\MPUI.lnk" "$INSTDIR\MPUI.exe"
631 ${EndIf}
632 ${If} ${FileExists} "$INSTDIR\SMPlayer.exe"
633 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\SMPlayer.lnk" "$INSTDIR\SMPlayer.exe"
634 CreateShortCut "$DESKTOP\SMPlayer.lnk" "$INSTDIR\SMPlayer.exe"
635 ${EndIf}
637 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(MPLAYER_LANG_SHORTCUT_UPDATE).lnk" "$INSTDIR\Updater.exe" "/L=$LANGUAGE"
638 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(MPLAYER_LANG_SHORTCUT_README).lnk" "$INSTDIR\Readme.html"
639 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(MPLAYER_LANG_SHORTCUT_MANUAL).lnk" "$INSTDIR\Manual.html"
641 ${If} ${AtLeastWinVista}
642 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(MPLAYER_LANG_SHORTCUT_APPREG).lnk" "$INSTDIR\AppRegGUI.exe"
643 ${EndIf}
645 ${CreateWebLink} "$SMPROGRAMS\$StartMenuFolder\$(MPLAYER_LANG_SHORTCUT_SITE_MULDERS).url" "http://muldersoft.com/"
646 ${CreateWebLink} "$SMPROGRAMS\$StartMenuFolder\$(MPLAYER_LANG_SHORTCUT_SITE_MPWIN32).url" "http://oss.netfarm.it/mplayer-win32.php"
647 ${CreateWebLink} "$SMPROGRAMS\$StartMenuFolder\$(MPLAYER_LANG_SHORTCUT_SITE_MPLAYER).url" "http://www.mplayerhq.hu/"
649 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\SMPlayer.lnk"
650 ${StdUtils.InvokeShellVerb} $R1 "$SMPROGRAMS\$StartMenuFolder" "SMPlayer.lnk" ${StdUtils.Const.ShellVerb.PinToTaskbar}
651 DetailPrint 'Pin: "$SMPROGRAMS\$StartMenuFolder\SMPlayer.lnk" -> $R1'
652 ${EndIf}
653 !insertmacro MUI_STARTMENU_WRITE_END
654 SectionEnd
656 Section "-ApplyTweaks"
657 ${PrintProgress} "$(MPLAYER_LANG_STATUS_TWEAKS)"
658 DetailPrint "$(MPLAYER_LANG_APPLYING_TWEAKS)"
660 IntOp $0 $SelectedTweaks & 1
661 ${If} $0 != 0
662 ${If} ${FileExists} "$INSTDIR\SMPlayer.ini"
663 WriteINIStr "$INSTDIR\SMPlayer.ini" "gui" "gui" "SkinGUI"
664 WriteINIStr "$INSTDIR\SMPlayer.ini" "gui" "qt_style" "Fusion"
665 WriteINIStr "$INSTDIR\SMPlayer.ini" "gui" "iconset" "Modern"
666 ${EndIf}
667 ${EndIf}
669 IntOp $0 $SelectedTweaks & 2
670 ${If} $0 != 0
671 ${If} ${FileExists} "$INSTDIR\MPUI.ini"
672 WriteINIStr "$INSTDIR\MPUI.ini" "MPUI" "Params" "-vo gl:yuv=3 -lavdopts threads=$DetectedCPUCores"
673 ${EndIf}
674 ${If} ${FileExists} "$INSTDIR\SMPlayer.ini"
675 WriteINIStr "$INSTDIR\SMPlayer.ini" "%General" "driver\vo" "gl:yuv=3"
676 ${EndIf}
677 ${EndIf}
679 IntOp $0 $SelectedTweaks & 4
680 ${If} $0 != 0
681 ${If} ${FileExists} "$INSTDIR\MPUI.ini"
682 ReadINIStr $1 "$INSTDIR\MPUI.ini" "MPUI" "Params"
683 WriteINIStr "$INSTDIR\MPUI.ini" "MPUI" "Params" "$1 -af volnorm=2"
684 ${EndIf}
685 ${If} ${FileExists} "$INSTDIR\SMPlayer.ini"
686 WriteINIStr "$INSTDIR\SMPlayer.ini" "defaults" "initial_volnorm" "true"
687 ${EndIf}
688 ${EndIf}
689 SectionEnd
691 Section "$(MPLAYER_LANG_COMPRESS_FILES)"
692 SectionIn 1 2
693 ${PrintProgress} "$(MPLAYER_LANG_STATUS_INST_COMPRESS)"
695 File "/oname=$PLUGINSDIR\UPX.exe" "${UPX_PATH}\UPX.exe"
697 ${PackAll} "$INSTDIR" "*.exe"
698 ${PackAll} "$INSTDIR" "*.dll"
699 ${PackAll} "$INSTDIR\codecs" "*.acm"
700 ${PackAll} "$INSTDIR\codecs" "*.ax"
701 ${PackAll} "$INSTDIR\codecs" "*.dll"
702 ${PackAll} "$INSTDIR\codecs" "*.qtx"
704 Delete "$PLUGINSDIR\UPX.exe"
705 SectionEnd
707 Section "-Update Font Cache"
708 ${PrintProgress} "$(MPLAYER_LANG_STATUS_INST_FONTCACHE)"
710 SetShellVarContext current
711 Delete "$APPDATA\fontconfig\cache\*.*"
712 Delete "$LOCALAPPDATA\fontconfig\cache\*.*"
714 SetShellVarContext all
715 Delete "$APPDATA\fontconfig\cache\*.*"
716 Delete "$LOCALAPPDATA\fontconfig\cache\*.*"
718 File "/oname=$PLUGINSDIR\Sample.avi" "Resources\Sample.avi"
719 DetailPrint "$(MPLAYER_LANG_UPDATING_FONTCACHE)"
720 NsExec::Exec '"$INSTDIR\MPlayer.exe" -fontconfig -ass -vo null -ao null "$PLUGINSDIR\Sample.avi"'
721 Delete "Resources\Sample.avi"
722 SectionEnd
724 Section "-Update Registry"
725 ${PrintProgress} "$(MPLAYER_LANG_STATUS_REGISTRY)"
726 DetailPrint "$(MPLAYER_LANG_WRITING_REGISTRY)"
728 ; Clean up
729 DeleteRegKey HKLM "${MPlayerRegPath}"
730 DeleteRegKey HKCU "${MPlayerRegPath}"
731 DeleteRegValue HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" "MPlayerForWindows_AutoUpdateV2"
732 DeleteRegValue HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" "MPlayerForWindows_AutoUpdateV2"
734 ; Uninstaller
735 WriteRegStr HKLM "${MPlayerRegPath}" "InstallLocation" "$INSTDIR"
736 WriteRegStr HKLM "${MPlayerRegPath}" "UninstallString" '"$INSTDIR\Uninstall.exe"'
737 WriteRegStr HKLM "${MPlayerRegPath}" "DisplayName" "$(MPLAYER_LANG_MPLAYER_WIN32)"
738 WriteRegStr HKLM "${MPlayerRegPath}" "DisplayIcon" "$INSTDIR\MPlayer.exe,0"
739 WriteRegStr HKLM "${MPlayerRegPath}" "DisplayVersion" "${MPLAYER_DATE}"
740 WriteRegStr HKLM "${MPlayerRegPath}" "URLInfoAbout" "http://muldersoft.com/"
741 WriteRegStr HKLM "${MPlayerRegPath}" "URLUpdateInfo" "http://muldersoft.com/"
742 WriteRegStr HKLM "${MPlayerRegPath}" "Publisher" "The MPlayer Team"
743 WriteRegDWORD HKLM "${MPlayerRegPath}" "NoModify" 1
744 WriteRegDWORD HKLM "${MPlayerRegPath}" "NoRepair" 1
746 ; Shell
747 DeleteRegKey HKCR "MPlayerForWindowsV2.File"
748 DeleteRegKey HKLM "SOFTWARE\Classes\MPlayerForWindowsV2.File"
749 DeleteRegKey HKCU "SOFTWARE\Classes\MPlayerForWindowsV2.File"
750 ${If} ${FileExists} "$INSTDIR\MPUI.exe"
751 WriteRegStr HKLM "SOFTWARE\Classes\MPlayerForWindowsV2.File\shell\open\command" "" '"$INSTDIR\MPUI.exe" "%1"'
752 WriteRegStr HKLM "SOFTWARE\Classes\MPlayerForWindowsV2.File\DefaultIcon" "" "$INSTDIR\MPUI.exe,0"
753 ${EndIf}
754 ${If} ${FileExists} "$INSTDIR\SMPlayer.exe"
755 WriteRegStr HKLM "SOFTWARE\Classes\MPlayerForWindowsV2.File\shell\open\command" "" '"$INSTDIR\SMPlayer.exe" "%1"'
756 WriteRegStr HKLM "SOFTWARE\Classes\MPlayerForWindowsV2.File\DefaultIcon" "" "$INSTDIR\SMPlayer.exe,1"
757 ${EndIf}
759 ; Register App
760 DeleteRegValue HKCU "SOFTWARE\RegisteredApplications" "MPlayerForWindowsV2"
761 WriteRegStr HKLM "SOFTWARE\RegisteredApplications" "MPlayerForWindowsV2" "${MPlayerRegPath}\Capabilities"
763 ; Capabilities
764 WriteRegStr HKLM "${MPlayerRegPath}\Capabilities" "ApplicationName" "$(MPLAYER_LANG_MPLAYER_WIN32)"
765 WriteRegStr HKLM "${MPlayerRegPath}\Capabilities" "ApplicationDescription" "$(MPLAYER_LANG_MPLAYER_WIN32)"
766 WriteRegStr HKLM "${MPlayerRegPath}\Capabilities" "ApplicationDescription" "$(MPLAYER_LANG_MPLAYER_WIN32)"
768 ; File Associations
769 ${RegisterFileExtCapability} "256"
770 ${RegisterFileExtCapability} "3GP"
771 ${RegisterFileExtCapability} "AAC"
772 ${RegisterFileExtCapability} "ASF"
773 ${RegisterFileExtCapability} "AVI"
774 ${RegisterFileExtCapability} "BIN"
775 ${RegisterFileExtCapability} "DAT"
776 ${RegisterFileExtCapability} "DIVX"
777 ${RegisterFileExtCapability} "EVO"
778 ${RegisterFileExtCapability} "FLV"
779 ${RegisterFileExtCapability} "M2V"
780 ${RegisterFileExtCapability} "M2TS"
781 ${RegisterFileExtCapability} "M4A"
782 ${RegisterFileExtCapability} "MKA"
783 ${RegisterFileExtCapability} "MKV"
784 ${RegisterFileExtCapability} "MOV"
785 ${RegisterFileExtCapability} "MP2"
786 ${RegisterFileExtCapability} "MP3"
787 ${RegisterFileExtCapability} "MP4"
788 ${RegisterFileExtCapability} "MPEG"
789 ${RegisterFileExtCapability} "MPG"
790 ${RegisterFileExtCapability} "MPV"
791 ${RegisterFileExtCapability} "NSV"
792 ${RegisterFileExtCapability} "OGG"
793 ${RegisterFileExtCapability} "OGM"
794 ${RegisterFileExtCapability} "RM"
795 ${RegisterFileExtCapability} "RMVB"
796 ${RegisterFileExtCapability} "TS"
797 ${RegisterFileExtCapability} "VOB"
798 ${RegisterFileExtCapability} "WAV"
799 ${RegisterFileExtCapability} "WEBM"
800 ${RegisterFileExtCapability} "WMV"
802 ; Reset auto update interval
803 DeleteRegValue HKLM "${MPlayerRegPath}" "LastUpdateCheck"
804 DeleteRegValue HKCU "${MPlayerRegPath}" "LastUpdateCheck"
805 SectionEnd
807 Section "$(MPLAYER_LANG_INST_AUTOUPDATE)" SECID_AUTOUPDATE
808 SectionIn 1 2
809 DetailPrint "$(MPLAYER_LANG_SCHEDULE_UPDATE)"
810 WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" "MPlayerForWindows_AutoUpdateV2" '"$INSTDIR\Updater.exe" /L=$LANGUAGE /AutoCheck'
811 SectionEnd
813 Section "-Protect Files"
814 SetFileAttributes "$INSTDIR\AppRegGUI.exe" FILE_ATTRIBUTE_READONLY
815 SetFileAttributes "$INSTDIR\mplayer.exe" FILE_ATTRIBUTE_READONLY
816 SetFileAttributes "$INSTDIR\MPUI.exe" FILE_ATTRIBUTE_READONLY
817 SetFileAttributes "$INSTDIR\smplayer.exe" FILE_ATTRIBUTE_READONLY
818 SetFileAttributes "$INSTDIR\Updater.exe" FILE_ATTRIBUTE_READONLY
820 SetFileAttributes "$INSTDIR\dsnative.dll" FILE_ATTRIBUTE_READONLY
821 SetFileAttributes "$INSTDIR\libeay32.dll" FILE_ATTRIBUTE_READONLY
822 SetFileAttributes "$INSTDIR\libgcc_s_dw2-1.dll" FILE_ATTRIBUTE_READONLY
823 SetFileAttributes "$INSTDIR\libstdc++-6.dll" FILE_ATTRIBUTE_READONLY
824 SetFileAttributes "$INSTDIR\libwinpthread-1.dll" FILE_ATTRIBUTE_READONLY
825 SetFileAttributes "$INSTDIR\Qt5Core.dll" FILE_ATTRIBUTE_READONLY
826 SetFileAttributes "$INSTDIR\Qt5Gui.dll" FILE_ATTRIBUTE_READONLY
827 SetFileAttributes "$INSTDIR\Qt5Network.dll" FILE_ATTRIBUTE_READONLY
828 SetFileAttributes "$INSTDIR\Qt5Script.dll" FILE_ATTRIBUTE_READONLY
829 SetFileAttributes "$INSTDIR\Qt5Widgets.dll" FILE_ATTRIBUTE_READONLY
830 SetFileAttributes "$INSTDIR\Qt5Xml.dll" FILE_ATTRIBUTE_READONLY
831 SetFileAttributes "$INSTDIR\ssleay32.dll" FILE_ATTRIBUTE_READONLY
832 SetFileAttributes "$INSTDIR\zlib1.dll" FILE_ATTRIBUTE_READONLY
833 SectionEnd
835 Section "-Finished"
836 ${PrintStatus} "$(MUI_TEXT_FINISH_TITLE)"
837 SectionEnd
840 ;--------------------------------------------------------------------------------
841 ; UN-INSTALL SECTIONS
842 ;--------------------------------------------------------------------------------
844 Section "Uninstall"
845 SetOutPath "$TEMP"
846 ${PrintProgress} "$(MPLAYER_LANG_STATUS_UNINSTALL)"
848 ; Validate uninstall path
849 ${IfThen} "$INSTDIR" == "" ${|} Abort ${|}
850 StrCpy $0 "$INSTDIR" "" -2
851 ${IfThen} $0 == ":\" ${|} Abort ${|}
853 ; Startmenu
854 !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
855 ${IfNot} "$StartMenuFolder" == ""
856 SetShellVarContext current
857 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\SMPlayer.lnk"
858 ${StdUtils.InvokeShellVerb} $R1 "$SMPROGRAMS\$StartMenuFolder" "SMPlayer.lnk" ${StdUtils.Const.ShellVerb.UnpinFromTaskbar}
859 DetailPrint 'Unpin: "$SMPROGRAMS\$StartMenuFolder\SMPlayer.lnk" -> $R1'
860 ${EndIf}
861 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\*.*"
862 Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.lnk"
863 Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.url"
864 Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.pif"
865 RMDir "$SMPROGRAMS\$StartMenuFolder"
866 ${EndIf}
867 SetShellVarContext all
868 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\SMPlayer.lnk"
869 ${StdUtils.InvokeShellVerb} $R1 "$SMPROGRAMS\$StartMenuFolder" "SMPlayer.lnk" ${StdUtils.Const.ShellVerb.UnpinFromTaskbar}
870 DetailPrint 'Unpin: "$SMPROGRAMS\$StartMenuFolder\SMPlayer.lnk" -> $R1'
871 ${EndIf}
872 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\*.*"
873 Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.lnk"
874 Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.url"
875 Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.pif"
876 RMDir "$SMPROGRAMS\$StartMenuFolder"
877 ${EndIf}
878 ${EndIf}
880 ; Desktop icons
881 Delete /REBOOTOK "$DESKTOP\MPUI.lnk"
882 Delete /REBOOTOK "$DESKTOP\SMPlayer.lnk"
884 ; Files
885 RMDir /r "$INSTDIR"
887 ; Virtual Store
888 ${GetVirtualStorePath} $0 "$INSTDIR"
889 ${If} ${FileExists} "$0\*.*"
890 RMDir /r "$0"
891 ${EndIf}
893 ; Registry Keys
894 DeleteRegKey HKLM "${MPlayerRegPath}"
895 DeleteRegKey HKCU "${MPlayerRegPath}"
896 DeleteRegValue HKLM "SOFTWARE\RegisteredApplications" "MPlayerForWindowsV2"
897 DeleteRegValue HKCU "SOFTWARE\RegisteredApplications" "MPlayerForWindowsV2"
899 ; Auto Update
900 DeleteRegValue HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" "MPlayerForWindows_AutoUpdateV2"
901 DeleteRegValue HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" "MPlayerForWindows_AutoUpdateV2"
903 ; Shell
904 DeleteRegKey HKCR "MPlayerForWindowsV2.File"
905 DeleteRegKey HKLM "SOFTWARE\Classes\MPlayerForWindowsV2.File"
906 DeleteRegKey HKCU "SOFTWARE\Classes\MPlayerForWindowsV2.File"
908 ${PrintStatus} "$(MUI_UNTEXT_FINISH_TITLE)"
909 SectionEnd
912 ;--------------------------------------------------------------------------------
913 ; SECTION SELECTION CHANGED
914 ;--------------------------------------------------------------------------------
916 Function .onSelChange
917 ${IfNot} ${SectionIsSelected} ${SECID_MPUI}
918 ${AndIfNot} ${SectionIsSelected} ${SECID_SMPLAYER}
919 MessageBox MB_TOPMOST|MB_ICONEXCLAMATION "$(MPLAYER_LANG_SELCHANGE)"
920 SectionGetFlags ${SECID_MPUI} $0
921 IntOp $0 $0 | ${SF_SELECTED}
922 SectionSetFlags ${SECID_MPUI} $0
923 ${EndIf}
925 ${IfNot} ${SectionIsSelected} ${SECID_AUTOUPDATE}
926 StrCpy $0 "nope"
927 ${IfCmd} MessageBox MB_TOPMOST|MB_ICONEXCLAMATION|MB_YESNO|MB_DEFBUTTON2 "$(MPLAYER_LANG_SEL_AUTOUPDATE)" IDNO ${||} StrCpy $0 "ok" ${|}
928 ${If} "$0" == "ok"
929 SectionGetFlags ${SECID_AUTOUPDATE} $0
930 IntOp $0 $0 | ${SF_SELECTED}
931 SectionSetFlags ${SECID_AUTOUPDATE} $0
932 ${EndIf}
933 ${EndIf}
934 FunctionEnd
937 ;--------------------------------------------------------------------------------
938 ; LOCKED-LIST PLUGIN
939 ;--------------------------------------------------------------------------------
941 !macro LockedListPage_Function
942 !insertmacro MUI_HEADER_TEXT "$(MPLAYER_LANG_LOCKEDLIST_HEADER)" "$(MPLAYER_LANG_LOCKEDLIST_TEXT)"
944 InitPluginsDir
945 File /oname=$PLUGINSDIR\LockedList64.dll `${NSISDIR}\Plugins\LockedList64.dll`
947 LockedList::AddModule "\MPlayer.exe"
948 LockedList::AddModule "\SMPlayer.exe"
949 LockedList::AddModule "\MPUI.exe"
950 LockedList::AddModule "${NSISDIR}\Qt5Core.dll"
952 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)"
953 Pop $R0
954 !macroend
956 Function LockedListPage_Show
957 !insertmacro LockedListPage_Function
958 FunctionEnd
960 Function un.LockedListPage_Show
961 !insertmacro LockedListPage_Function
962 FunctionEnd
965 ;--------------------------------------------------------------------------------
966 ; CUSTOME PAGE: CPU SELECTOR
967 ;--------------------------------------------------------------------------------
969 Function SelectCPUPage_Show
970 ; Detect CPU type, if not detected yet
971 ${If} $DetectedCPUType < 2
972 ${OrIf} $DetectedCPUType > 5
973 Call DetectCPUType
974 !insertmacro INSTALLOPTIONS_READ $0 "Page_CPU.ini" "Field $DetectedCPUType" "Text"
975 !insertmacro INSTALLOPTIONS_WRITE "Page_CPU.ini" "Field $DetectedCPUType" "Text" "$0 <---"
976 ${EndIf}
978 ; Make sure the current selection is valid
979 ${IfThen} $SelectedCPUType < 2 ${|} StrCpy $SelectedCPUType $DetectedCPUType ${|}
980 ${IfThen} $SelectedCPUType > 5 ${|} StrCpy $SelectedCPUType $DetectedCPUType ${|}
982 ; Translate
983 !insertmacro INSTALLOPTIONS_WRITE "Page_CPU.ini" "Field 1" "Text" "$(MPLAYER_LANG_SELECT_CPU_TYPE)"
984 !insertmacro INSTALLOPTIONS_WRITE "Page_CPU.ini" "Field 6" "Text" "$(MPLAYER_LANG_SELECT_CPU_HINT)"
986 ; Apply current selection to dialog
987 ${For} $0 2 5
988 ${If} $0 == $SelectedCPUType
989 !insertmacro INSTALLOPTIONS_WRITE "Page_CPU.ini" "Field $0" "State" "1"
990 ${Else}
991 !insertmacro INSTALLOPTIONS_WRITE "Page_CPU.ini" "Field $0" "State" "0"
992 ${EndIf}
993 ${Next}
995 ; Display dialog
996 !insertmacro MUI_HEADER_TEXT "$(MPLAYER_LANG_SELECT_CPU_HEAD)" "$(MPLAYER_LANG_SELECT_CPU_TEXT)"
997 !insertmacro INSTALLOPTIONS_DISPLAY "Page_CPU.ini"
999 ; Read new selection from dialog
1000 StrCpy $SelectedCPUType 0
1001 ${For} $0 2 5
1002 !insertmacro INSTALLOPTIONS_READ $1 "Page_CPU.ini" "Field $0" "State"
1003 ${IfThen} $1 == 1 ${|} StrCpy $SelectedCPUType $0 ${|}
1004 ${Next}
1005 FunctionEnd
1007 Function SelectCPUPage_Validate
1008 ; Read new selection from dialog
1009 StrCpy $2 0
1010 ${For} $0 2 5
1011 !insertmacro INSTALLOPTIONS_READ $1 "Page_CPU.ini" "Field $0" "State"
1012 ${IfThen} $1 == 1 ${|} StrCpy $2 $0 ${|}
1013 ${Next}
1015 ; Validate selection
1016 ${If} $2 < 2
1017 ${OrIf} $2 > 5
1018 MessageBox MB_ICONSTOP "Oups, invalid selection detected!"
1019 Abort
1020 ${EndIf}
1021 FunctionEnd
1023 Function DetectCPUType
1024 StrCpy $DetectedCPUType 5 ;generic
1025 StrCpy $DetectedCPUCores 2
1027 ${IfNot} ${Silent}
1028 Banner::show /NOUNLOAD "$(MPLAYER_LANG_DETECTING)"
1029 ${EndIf}
1031 ${CPUFeatures.GetCount} $0
1032 ${IfNot} $0 == "error"
1033 StrCpy $DetectedCPUCores $0
1034 ${EndIf}
1036 ; Debug Code
1037 !ifdef CPU_DETECT_DEBUG
1038 ${CPUFeatures.GetVendor} $0
1039 ${CPUFeatures.CheckFeature} "MMX1" $1
1040 ${CPUFeatures.CheckFeature} "3DNOW" $2
1041 ${CPUFeatures.CheckFeature} "SSE3" $3
1042 ${CPUFeatures.CheckFeature} "SSSE3" $4
1043 ${CPUFeatures.CheckFeature} "SSE4.2" $5
1044 ${CPUFeatures.CheckFeature} "AVX1" $6
1045 ${CPUFeatures.CheckFeature} "FMA4" $7
1046 StrCpy $9 `Vendor = $0`
1047 StrCpy $9 `$9$\n"MMX1" = $1`
1048 StrCpy $9 `$9$\n"3DNOW" = $2`
1049 StrCpy $9 `$9$\n"SSE3" = $3`
1050 StrCpy $9 `$9$\n"SSSE3" = $4`
1051 StrCpy $9 `$9$\n"SSE4.2" = $5`
1052 StrCpy $9 `$9$\n"AVX1" = $6`
1053 StrCpy $9 `$9$\n"FMA4" = $7`
1054 MessageBox MB_TOPMOST `$9`
1055 !endif
1057 ; Make sure we have at least MMX
1058 ${IfNot} ${CPUSupports} "MMX1"
1059 Banner::destroy
1060 Return
1061 ${EndIf}
1063 ; Select the "best" model for Intel's
1064 ${If} ${CPUIsIntel}
1065 ; Core2 (SSE3 + SSSE3)
1066 ${If} ${CPUSupportsAll} "SSE3,SSSE3"
1067 StrCpy $DetectedCPUType 2 ;
1068 ${EndIf}
1069 ; Nehalem (SSE3 + SSSE3 + SSE4.2)
1070 ${If} ${CPUSupportsAll} "SSE3,SSSE3,SSE4.2"
1071 StrCpy $DetectedCPUType 3
1072 ${EndIf}
1073 ${EndIf}
1075 ; Select the "best" model for AMD's
1076 ${If} ${CPUIsAMD}
1077 ; K8+SSE3 (3DNow! + SSE3)
1078 ${If} ${CPUSupportsAll} "3DNOW,SSE3"
1079 StrCpy $DetectedCPUType 4
1080 ${EndIf}
1081 ; Bulldozer (SSE3 + SSSE3 + SSE4.2 + AVX + FMA4)
1082 ;${If} ${CPUSupportsAll} "SSE3,SSSE3,SSE4.2,AVX1,FMA4"
1083 ; StrCpy $DetectedCPUType 5 #5 is now generic, as 'bdver1' build got dropped
1084 ;${EndIf}
1085 ${EndIf}
1087 Banner::destroy
1088 FunctionEnd
1091 ;--------------------------------------------------------------------------------
1092 ; CUSTOME PAGE: TWEAKS
1093 ;--------------------------------------------------------------------------------
1095 Function SetTweaksPage_Show
1096 ; Apply current selection to dialog
1097 StrCpy $0 1
1098 ${For} $1 2 4
1099 IntOp $2 $0 & $SelectedTweaks
1100 ${If} $2 != 0
1101 !insertmacro INSTALLOPTIONS_WRITE "Page_Tweaks.ini" "Field $1" "State" "1"
1102 ${Else}
1103 !insertmacro INSTALLOPTIONS_WRITE "Page_Tweaks.ini" "Field $1" "State" "0"
1104 ${EndIf}
1105 IntOp $0 $0 << 1
1106 ${Next}
1108 ; Translate
1109 !insertmacro INSTALLOPTIONS_WRITE "Page_Tweaks.ini" "Field 1" "Text" "$(MPLAYER_LANG_TWEAKS_HINT)"
1110 !insertmacro INSTALLOPTIONS_WRITE "Page_Tweaks.ini" "Field 2" "Text" "$(MPLAYER_LANG_TWEAKS_SKINNEDUI)"
1111 !insertmacro INSTALLOPTIONS_WRITE "Page_Tweaks.ini" "Field 3" "Text" "$(MPLAYER_LANG_TWEAKS_OPENGL)"
1112 !insertmacro INSTALLOPTIONS_WRITE "Page_Tweaks.ini" "Field 4" "Text" "$(MPLAYER_LANG_TWEAKS_VOLNORM)"
1114 ; Display dialog
1115 !insertmacro MUI_HEADER_TEXT "$(MPLAYER_LANG_TWEAKS_HEAD)" "$(MPLAYER_LANG_TWEAKS_TEXT)"
1116 !insertmacro INSTALLOPTIONS_DISPLAY "Page_Tweaks.ini"
1118 ; Read new selection from dialog
1119 StrCpy $0 1
1120 ${For} $1 2 4
1121 !insertmacro INSTALLOPTIONS_READ $2 "Page_Tweaks.ini" "Field $1" "State"
1122 ${IfThen} $2 == 1 ${|} IntOp $SelectedTweaks $SelectedTweaks | $0 ${|}
1123 IntOp $0 $0 << 1
1124 ${Next}
1125 FunctionEnd
1128 ;--------------------------------------------------------------------------------
1129 ; CHECK FOR UPDATE MODE
1130 ;--------------------------------------------------------------------------------
1132 !macro SetControlEnabled item_id enable
1133 FindWindow $0 "#32770" "" $HWNDPARENT
1134 ${IfNot} $0 == 0
1135 GetDlgItem $1 $0 ${item_id}
1136 EnableWindow $1 ${enable}
1137 ${EndIf}
1138 !macroend
1140 !macro SkipToNextPage
1141 GetDlgItem $0 $HWNDPARENT 1
1142 System::Call "User32::PostMessage(i $HWNDPARENT, i ${WM_COMMAND}, i 1, i $R0)"
1143 !macroend
1145 !macro EnablePathEditable flag show_msg
1146 !insertmacro SetControlEnabled 1019 ${flag}
1147 !insertmacro SetControlEnabled 1001 ${flag}
1148 ${IfNot} $NotUpdateInstall == ${flag}
1149 !if ${show_msg} == 1
1150 MessageBox MB_OK|MB_ICONINFORMATION "$(MPLAYER_LANG_FORCE_UPDATE)" /SD IDOK
1151 !endif
1152 StrCpy $NotUpdateInstall ${flag}
1153 !insertmacro SkipToNextPage
1154 ${EndIf}
1155 !macroend
1157 Function CheckForUpdate
1158 ${StdUtils.GetParameter} $0 "Update" "?"
1159 ${IfNot} "$0" == "?"
1160 !insertmacro EnablePathEditable 0 0
1161 Return
1162 ${EndIf}
1164 ${If} ${FileExists} "$INSTDIR\MPlayer.exe"
1165 ${If} ${FileExists} "$INSTDIR\version.tag"
1166 ReadINIStr $0 "$INSTDIR\version.tag" "mplayer_version" "build_no"
1167 ${If} $0 > ${MPLAYER_BUILDNO}
1168 MessageBox MB_OK|MB_ICONEXCLAMATION "$(MPLAYER_LANG_CAN_NOT_UPDATE)"
1169 Quit
1170 ${EndIf}
1171 ${If} $0 = ${MPLAYER_BUILDNO}
1172 ${IfCmd} MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(MPLAYER_LANG_CONFIRM_UPDATE)" /SD IDYES IDNO ${||} Quit ${|}
1173 ${EndIf}
1174 ${EndIf}
1175 !insertmacro EnablePathEditable 0 1
1176 Return
1177 ${EndIf}
1179 !insertmacro EnablePathEditable 1 0
1180 FunctionEnd
1183 ;--------------------------------------------------------------------------------
1184 ; FINISHED
1185 ;--------------------------------------------------------------------------------
1187 Function RunAppFunction
1188 !insertmacro DisableNextButton $R0
1189 ${If} ${FileExists} "$INSTDIR\SMPlayer.exe"
1190 ${StdUtils.ExecShellAsUser} $R0 "$INSTDIR\SMPlayer.exe" "open" "http://lounge-office.rautemusik.fm/"
1191 ${Else}
1192 ${StdUtils.ExecShellAsUser} $R0 "$INSTDIR\MPUI.exe" "open" "http://lounge-office.rautemusik.fm/"
1193 ${EndIf}
1194 FunctionEnd
1196 Function ShowReadmeFunction
1197 !insertmacro DisableNextButton $R0
1198 ${StdUtils.ExecShellAsUser} $R0 "$INSTDIR\Readme.html" "open" ""
1199 FunctionEnd
1201 Function .onInstSuccess
1202 ${StdUtils.ExecShellAsUser} $R0 "$SMPROGRAMS\$StartMenuFolder" "explore" ""
1203 FunctionEnd
1206 ### EOF ###