Added checkboxes in directory page. Reordered functions

This commit is contained in:
Bosmanfrx 2013-01-29 13:30:40 +01:00
parent e3ef6d7073
commit fa9af8c74e

View File

@ -38,16 +38,60 @@ NSIS_SCRIPT_TEMPLATE = r"""
VIAddVersionKey /LANG=$${LANG_POLISH} "ProductName" "Syncplay"
VIAddVersionKey /LANG=$${LANG_POLISH} "FileVersion" "$version.0"
VIAddVersionKey /LANG=$${LANG_POLISH} "LegalCopyright" "Syncplay"
VIAddVersionKey /LANG=$${LANG_POLISH} "FileDescription" "Syncplay"
VIAddVersionKey /LANG=$${LANG_POLISH} "FileDescription" "Syncplay"
LangString ^Associate $${LANG_ENGLISH} "Associate Syncplay with multimedia files."
LangString ^VLC $${LANG_ENGLISH} "Install Syncplay interface for VLC (requires VLC 2.0.X)"
LangString ^Shortcut $${LANG_ENGLISH} "Create Shortcuts in following locations:"
LangString ^StartMenu $${LANG_ENGLISH} "Start Menu"
LangString ^Desktop $${LANG_ENGLISH} "Desktop"
LangString ^QuickLaunchBar $${LANG_ENGLISH} "Quick Launch Bar"
LangString ^Associate $${LANG_POLISH} "Skojarz Syncplaya z multimediami"
LangString ^VLC $${LANG_POLISH} "Zainstaluj interface Syncplaya dla VLC(wymaga VLC 2.0.X)"
LangString ^Shortcut $${LANG_POLISH} "Utworz skroty w nastepujacych miejscach:"
LangString ^StartMenu $${LANG_POLISH} "Menu Start"
LangString ^Desktop $${LANG_POLISH} "Pulpit"
LangString ^QuickLaunchBar $${LANG_POLISH} "Pasek szybkiego uruchamiania"
PageEx license
LicenseData resources\license.txt
PageExEnd
Page directory
Page custom DirectoryCustom DirectoryCustomLeave
Page instFiles
UninstPage uninstConfirm
UninstPage instFiles
Var Dialog
Var Syncplay_Icon
Var Syncplay_Icon_Handle
Var CheckBox_Associate
Var CheckBox_VLC
Var CheckBox_StartMenuShortcut
Var CheckBox_DesktopShortcut
Var CheckBox_QuickLaunchShortcut
Var CheckBox_Associate_State
Var CheckBox_VLC_State
Var CheckBox_StartMenuShortcut_State
Var CheckBox_DesktopShortcut_State
Var CheckBox_QuickLaunchShortcut_State
Var Button_Browse
Var Directory
Var GroupBox_DirSub
Var Label_Text
Var Label_Shortcut
Var Label_Size
Var Label_Space
Var Text_Directory
Var Size
Var SizeHex
Var AvailibleSpace
Var AvailibleSpaceGiB
Var Drive
Var VLC_Directory
Var VLC_Version
!macro APP_ASSOCIATE EXT FileCLASS DESCRIPTION COMMANDTEXT COMMAND
WriteRegStr HKCR ".$${EXT}" "" "$${FileCLASS}"
@ -64,6 +108,180 @@ NSIS_SCRIPT_TEMPLATE = r"""
DeleteRegKey HKCR `$${FileCLASS}`
!macroend
;Prevents from running more than one instance of installer and sets default state of checkboxes
Function .onInit
System::Call 'kernel32::CreateMutexA(i 0, i 0, t "myMutex") i .r1 ?e'
Pop $$R0
StrCmp $$R0 0 +3
MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running."
Abort
StrCpy $$CheckBox_Associate_State $${BST_CHECKED}
StrCpy $$CheckBox_StartMenuShortcut_State $${BST_CHECKED}
Call GetSize
Call DriveSpace
Call Language
FunctionEnd
;Language selection dialog
Function Language
Push ""
Push $${LANG_ENGLISH}
Push English
Push $${LANG_POLISH}
Push Polski
Push A ; A means auto count languages
LangDLL::LangDialog "Installer Language" "Please select the language of the installer"
Pop $$LANGUAGE
StrCmp $$LANGUAGE "cancel" 0 +2
Abort
FunctionEnd
Function DirectoryCustom
nsDialogs::Create 1018
Pop $$Dialog
GetFunctionAddress $$R8 DirectoryCustomLeave
nsDialogs::OnBack $$R8
$${NSD_CreateIcon} 0u 0u 22u 20u ""
Pop $$Syncplay_Icon
$${NSD_SetIconFromInstaller} $$Syncplay_Icon $$Syncplay_Icon_Handle
$${NSD_CreateLabel} 25u 0u 241u 34u "$$(^DirText)"
Pop $$Label_Text
$${NSD_CreateText} 8u 38u 187u 12u "$$INSTDIR"
Pop $$Text_Directory
$${NSD_SetFocus} $$Text_Directory
$${NSD_CreateBrowseButton} 202u 37u 55u 14u "$$(^BrowseBtn)"
Pop $$Button_Browse
$${NSD_OnClick} $$Button_Browse DirectoryBrowseDialog
$${NSD_CreateGroupBox} 1u 27u 264u 30u "$$(^DirSubText)"
Pop $$GroupBox_DirSub
$${NSD_CreateLabel} 0u 111u 265u 8u "$$(^SpaceRequired)$$SizeMB"
Pop $$Label_Size
$${NSD_CreateLabel} 0u 122u 265u 8u "$$(^SpaceAvailable)$$AvailibleSpaceGiB.$$AvailibleSpaceGB"
Pop $$Label_Space
$${NSD_CreateCheckBox} 8u 59u 187u 10u "$$(^Associate)"
Pop $$CheckBox_Associate
$${NSD_CreateCheckBox} 8u 72u 250u 10u "$$(^VLC)"
Pop $$CheckBox_VLC
$${NSD_CreateLabel} 8u 85u 187u 10u "$$(^Shortcut)"
Pop $$Label_Shortcut
$${NSD_CreateCheckbox} 8u 98u 50u 10u "$$(^StartMenu)"
Pop $$CheckBox_StartMenuShortcut
$${NSD_CreateCheckbox} 68u 98u 50u 10u "$$(^Desktop)"
Pop $$CheckBox_DesktopShortcut
$${NSD_CreateCheckbox} 128u 98u 150u 10u "$$(^QuickLaunchBar)"
Pop $$CheckBox_QuickLaunchShortcut
$${If} $$CheckBox_Associate_State == $${BST_CHECKED}
$${NSD_Check} $$CheckBox_Associate
$${EndIf}
$${If} $$CheckBox_VLC_State == $${BST_CHECKED}
$${NSD_Check} $$CheckBox_VLC
$${EndIf}
$${If} $$CheckBox_StartMenuShortcut_State == $${BST_CHECKED}
$${NSD_Check} $$CheckBox_StartMenuShortcut
$${EndIf}
$${If} $$CheckBox_DesktopShortcut_State == $${BST_CHECKED}
$${NSD_Check} $$CheckBox_DesktopShortcut
$${EndIf}
$${If} $$CheckBox_QuickLaunchShortcut_State == $${BST_CHECKED}
$${NSD_Check} $$CheckBox_QuickLaunchShortcut
$${EndIf}
ReadRegStr $$VLC_Version HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VLC media player" "VersionMajor"
$${If} $$VLC_Version != "2"
EnableWindow $$CheckBox_VLC 0
$${EndIf}
nsDialogs::Show
$${NSD_FreeIcon} $$Syncplay_Icon_Handle
FunctionEnd
Function DirectoryCustomLeave
$${NSD_GetState} $$CheckBox_Associate $$CheckBox_Associate_State
$${NSD_GetState} $$CheckBox_VLC $$CheckBox_VLC_State
$${NSD_GetState} $$CheckBox_StartMenuShortcut $$CheckBox_StartMenuShortcut_State
$${NSD_GetState} $$CheckBox_DesktopShortcut $$CheckBox_DesktopShortcut_State
$${NSD_GetState} $$CheckBox_QuickLaunchShortcut $$CheckBox_QuickLaunchShortcut_State
FunctionEnd
Function DirectoryBrowseDialog
nsDialogs::SelectFolderDialog $$(^DirBrowseText)
Pop $$Directory
$${If} $$Directory != error
StrCpy $$INSTDIR $$Directory
$${NSD_SetText} $$Text_Directory $$INSTDIR
Call DriveSpace
$${NSD_SetText} $$Label_Space "$$(^SpaceAvailable)$$AvailibleSpaceGiB.$$AvailibleSpaceGB"
$${EndIf}
Abort
FunctionEnd
;Calculates size of installation files
Function GetSize
$${GetSize} "$$PROGRAMFILES\Syncplay" "/S=0K" $$Size $$1 $$2
IntFmt $$SizeHex "0x%08X" $$Size
IntOp $$Size $$Size / 1024
FunctionEnd
;Calculates Free Space on HDD
Function DriveSpace
StrCpy $$Drive $$INSTDIR 1
$${DriveSpace} "$$Drive:\" "/D=F /S=M" $$AvailibleSpace
IntOp $$AvailibleSpaceGiB $$AvailibleSpace / 1024
IntOp $$AvailibleSpace $$AvailibleSpace % 1024
IntOp $$AvailibleSpace $$AvailibleSpace / 102
FunctionEnd
Function InstallOptions
$${If} $$CheckBox_Associate_State == $${BST_CHECKED}
Call Associate
DetailPrint "Associated Syncplay with multimedia files"
$${EndIf}
$${If} $$CheckBox_StartMenuShortcut_State == $${BST_CHECKED}
CreateDirectory $$SMPROGRAMS\Syncplay
CreateShortCut "$$SMPROGRAMS\Syncplay\Syncplay.lnk" "$$INSTDIR\Syncplay.exe" ""
CreateShortCut "$$SMPROGRAMS\Syncplay\Uninstall.lnk" "$$INSTDIR\Uninstall.exe" ""
WriteINIStr "$$SMPROGRAMS\Syncplay\SyncplayWebsite.url" "InternetShortcut" "URL" "http://syncplay.pl"
$${EndIf}
$${If} $$CheckBox_DesktopShortcut_State == $${BST_CHECKED}
CreateShortCut "$$DESKTOP\Syncplay.lnk" "$$INSTDIR\Syncplay.exe" ""
$${EndIf}
$${If} $$CheckBox_QuickLaunchShortcut_State == $${BST_CHECKED}
CreateShortCut "$$QUICKLAUNCH\Syncplay.lnk" "$$INSTDIR\Syncplay.exe" ""
$${EndIf}
$${If} $$CheckBox_VLC_State == $${BST_CHECKED}
ReadRegStr $$VLC_Directory HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VLC media player" "InstallLocation"
SetOutPath $$VLC_Directory\lua\intf
File resources\syncplay.lua
$${EndIf}
FunctionEnd
;Associates extensions with Syncplay
Function Associate
!insertmacro APP_ASSOCIATE "mkv" "Syncplay.mkv" "$$INSTDIR\Syncplay.exe,%1%" \
@ -87,10 +305,10 @@ NSIS_SCRIPT_TEMPLATE = r"""
FunctionEnd
Function WriteRegistry
$${GetSize} "$$INSTDIR" "/S=0K" $$0 $$1 $$2
IntFmt $$0 "0x%08X" $$0
Call GetSize
WriteRegStr HKLM SOFTWARE\Syncplay "Install_Dir" "$$INSTDIR"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Syncplay" "DisplayName" "Syncplay"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Syncplay" "InstallLocation" "$$INSTDIR"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Syncplay" "UninstallString" '"$$INSTDIR\uninstall.exe"'
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Syncplay" "DisplayIcon" "$$INSTDIR\resources\icon.ico"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Syncplay" "Publisher" "Syncplay"
@ -98,7 +316,7 @@ NSIS_SCRIPT_TEMPLATE = r"""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Syncplay" "URLInfoAbout" "http://syncplay.pl/"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Syncplay" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Syncplay" "NoRepair" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Syncplay" "EstimatedSize" "$$0"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Syncplay" "EstimatedSize" "$$SizeHex"
FunctionEnd
Function un.AssociateDel
@ -113,30 +331,17 @@ NSIS_SCRIPT_TEMPLATE = r"""
!insertmacro APP_UNASSOCIATE "wmv" "Syncplay.wmv"
FunctionEnd
;Prevents from running more than one instance of installer
Function .onInit
System::Call 'kernel32::CreateMutexA(i 0, i 0, t "myMutex") i .r1 ?e'
Pop $$R0
StrCmp $$R0 0 +3
MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running."
Abort
Call Language
Function un.InstallOptions
Delete $$SMPROGRAMS\Syncplay\Syncplay.lnk
Delete $$SMPROGRAMS\Syncplay\Uninstall.lnk
Delete $$SMPROGRAMS\Syncplay\SyncplayWebsite.url
RMDir $$SMPROGRAMS\Syncplay
Delete $$DESKTOP\Syncplay.lnk
Delete $$QUICKLAUNCH\Syncplay.lnk
ReadRegStr $$VLC_Directory HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VLC media player" "InstallLocation"
Delete $$VLC_Directory\lua\intf\syncplay.lua
FunctionEnd
;Language selection dialog
Function Language
Push ""
Push $${LANG_ENGLISH}
Push English
Push $${LANG_POLISH}
Push Polski
Push A ; A means auto count languages
LangDLL::LangDialog "Installer Language" "Please select the language of the installer"
Pop $$LANGUAGE
StrCmp $$LANGUAGE "cancel" 0 +2
Abort
FunctionEnd
Section "Install"
SetOverwrite on
SetOutPath $$INSTDIR
@ -144,19 +349,20 @@ NSIS_SCRIPT_TEMPLATE = r"""
$installFiles
Call Associate
Call InstallOptions
Call WriteRegistry
SectionEnd
Section "Uninstall"
Call un.AssociateDel
Call un.InstallOptions
$uninstallFiles
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Syncplay"
DeleteRegKey HKLM SOFTWARE\Syncplay
Delete $$INSTDIR\uninstall.exe
RMDir $$INSTDIR\resources
RMDir $$INSTDIR\lib
RMDir $$INSTDIR
RMDir $$INSTDIR
SectionEnd
"""