From 46847c8a84d417166d413bce2a43718346ebe419 Mon Sep 17 00:00:00 2001 From: Simon Clitherow Date: Mon, 21 Apr 2008 15:53:32 +0000 Subject: Bug fix for 8634, 6708, and 5989 This replaces the hard-coded '%PROFILE%\Application Data\..." path with the correct language-dependant CSIDL_APPDATA. PLEASE NOTE! Checks for the previous location have now been REMOVED. Any data saved in the old hard-coded location will no longer be found by Blender (this will only affect users of non-english windows.) The installer has been updated to help the user to migrate their data to the new location of their choice, if necessary. Order of preference for .blender on windows is now the following: 1) %HOME% environment var 2) Installation Directory (location of blender.exe) 3) "Current User" (CSIDL_APPDATA) 4) "All Users" (CSIDL_COMMON_APPDATA) --- release/windows/installer/00.sconsblender.nsi | 282 ++++++++++++-------------- release/windows/installer/data.ini | 34 ---- 2 files changed, 135 insertions(+), 181 deletions(-) delete mode 100644 release/windows/installer/data.ini (limited to 'release/windows') diff --git a/release/windows/installer/00.sconsblender.nsi b/release/windows/installer/00.sconsblender.nsi index 5875be289b6..c4e504a5bff 100644 --- a/release/windows/installer/00.sconsblender.nsi +++ b/release/windows/installer/00.sconsblender.nsi @@ -7,8 +7,10 @@ ; !include "MUI.nsh" +!include "WinVer.nsh" !include "FileFunc.nsh" !include "WordFunc.nsh" +!include "nsDialogs.nsh" SetCompressor /SOLID lzma @@ -29,7 +31,9 @@ Name "Blender VERSION" !insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_PAGE_DIRECTORY -Page custom DataLocation +Page custom DataLocation DataLocationOnLeave +Page custom AppDataChoice AppDataChoiceOnLeave +Page custom PreMigrateUserSettings MigrateUserSettings !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_FINISH @@ -66,101 +70,13 @@ Caption "Blender VERSION Installer" OutFile "DISTDIR\..\blender-VERSION-windows.exe" InstallDir "$PROGRAMFILES\Blender Foundation\Blender" -BrandingText "http://www.blender.org/bf" +BrandingText "http://www.blender.org" ComponentText "This will install Blender VERSION on your computer." DirText "Use the field below to specify the folder where you want Blender to be copied to. To specify a different folder, type a new name or use the Browse button to select an existing folder." SilentUnInstall normal -; GetWindowsVersion -; -; Based on Yazno's function, http://yazno.tripod.com/powerpimpit/ -; Updated by Joost Verburg -; -; Returns on top of stack -; -; Windows Version (95, 98, ME, NT x.x, 2000, XP, 2003) -; or -; '' (Unknown Windows Version) -; -; Usage: -; Call GetWindowsVersion -; Pop $R0 -; ; at this point $R0 is "NT 4.0" or whatnot - -Function GetWindowsVersion - - Push $R0 - Push $R1 - - ReadRegStr $R0 HKLM \ - "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion - - IfErrors 0 lbl_winnt - - ; we are not NT - ReadRegStr $R0 HKLM \ - "SOFTWARE\Microsoft\Windows\CurrentVersion" VersionNumber - - StrCpy $R1 $R0 1 - StrCmp $R1 '4' 0 lbl_error - - StrCpy $R1 $R0 3 - - StrCmp $R1 '4.0' lbl_win32_95 - StrCmp $R1 '4.9' lbl_win32_ME lbl_win32_98 - - lbl_win32_95: - StrCpy $R0 '95' - Goto lbl_done - - lbl_win32_98: - StrCpy $R0 '98' - Goto lbl_done - - lbl_win32_ME: - StrCpy $R0 'ME' - Goto lbl_done - - lbl_winnt: - - StrCpy $R1 $R0 1 - - StrCmp $R1 '3' lbl_winnt_x - StrCmp $R1 '4' lbl_winnt_x - - StrCpy $R1 $R0 3 - - StrCmp $R1 '5.0' lbl_winnt_2000 - StrCmp $R1 '5.1' lbl_winnt_XP - StrCmp $R1 '5.2' lbl_winnt_2003 lbl_error - - lbl_winnt_x: - StrCpy $R0 "NT $R0" 6 - Goto lbl_done - - lbl_winnt_2000: - Strcpy $R0 '2000' - Goto lbl_done - - lbl_winnt_XP: - Strcpy $R0 'XP' - Goto lbl_done - - lbl_winnt_2003: - Strcpy $R0 '2003' - Goto lbl_done - - lbl_error: - Strcpy $R0 '' - lbl_done: - - Pop $R1 - Exch $R0 - -FunctionEnd - # Uses $0 Function openLinkNewWindow Push $3 @@ -196,22 +112,74 @@ Function openLinkNewWindow FunctionEnd Var BLENDERHOME -Var winversion Var DLL_found +Var PREVHOME + +Function SetWinXPPathCurrentUser + SetShellVarContext current + StrCpy $BLENDERHOME "$APPDATA\Blender Foundation\Blender" +FunctionEnd -Function SetWinXPPath - StrCpy $BLENDERHOME "$PROFILE\Application Data\Blender Foundation\Blender" +Function SetWinXPPathAllUsers + SetShellVarContext all + StrCpy $BLENDERHOME "$APPDATA\Blender Foundation\Blender" FunctionEnd Function SetWin9xPath StrCpy $BLENDERHOME $INSTDIR FunctionEnd -Function .onInit - Call GetWindowsVersion - Pop $R0 - Strcpy $winversion $R0 - !insertmacro MUI_INSTALLOPTIONS_EXTRACT_AS "RELDIR\data.ini" "data.ini" +; custom controls +Var HWND + +Var HWND_APPDATA +Var HWND_INSTDIR +Var HWND_HOMEDIR + +Var HWND_BUTTON_YES +Var HWND_BUTTON_NO + +Var SETUSERCONTEXT + +Function PreMigrateUserSettings + StrCpy $PREVHOME "$PROFILE\Application Data\Blender Foundation\Blender" + StrCpy $0 "$PROFILE\Application Data\Blender Foundation\Blender\.blender" + + IfFileExists $0 0 nochange + + StrCmp $BLENDERHOME $PREVHOME nochange + + nsDialogs::Create /NOUNLOAD 1018 + Pop $HWND + + ${If} $HWND == error + Abort + ${EndIf} + + ${NSD_CreateLabel} 0 0 100% 12u "You have existing settings at:" + ${NSD_CreateLabel} 0 20 100% 12u $PREVHOME + ${NSD_CreateLabel} 0 40 100% 12u "Do you wish to migrate this data to:" + ${NSD_CreateLabel} 0 60 100% 12u $BLENDERHOME + ${NSD_CreateLabel} 0 80 100% 12u "Please note: If you choose no, Blender will not be able to use these files!" + ${NSD_CreateRadioButton} 0 100 100% 12u "Yes" + Pop $HWND_BUTTON_YES + ${NSD_CreateRadioButton} 0 120 100% 12u "No" + Pop $HWND_BUTTON_NO + + SendMessage $HWND_BUTTON_YES ${BM_SETCHECK} 1 0 + + nsDialogs::Show + nochange: + +FunctionEnd + +Function MigrateUserSettings + ${NSD_GetState} $HWND_BUTTON_YES $R0 + ${If} $R0 == "1" + CreateDirectory $BLENDERHOME + CopyFiles $PREVHOME\*.* $BLENDERHOME + ;RMDir /r $PREVHOME + ${EndIf} FunctionEnd !define DLL_VER "8.00.50727.42" @@ -271,70 +239,90 @@ Function PythonInstall Call openLinkNewWindow FunctionEnd -Var HWND -Var DLGITEM -Var is2KXP - Function DataLocation - !insertmacro MUI_HEADER_TEXT "$(TEXT_IO_TITLE)" "" - - ; Set default choice - !insertmacro MUI_INSTALLOPTIONS_WRITE "data.ini" "Field 3" "State" 1 - - StrCpy $R1 $winversion 2 - StrCmp $R1 "NT" do_win2kxp - StrCmp $winversion "2000" do_win2kxp - StrCmp $winversion "XP" do_win2kxp - StrCmp $winversion "2003" do_win2kxp + nsDialogs::Create /NOUNLOAD 1018 + Pop $HWND - ;else... - Strcpy $is2KXP "false" - - Goto continue - - do_win2kXP: - Strcpy $is2KXP "true" - - continue: + ${If} $HWND == error + Abort + ${EndIf} - !insertmacro MUI_INSTALLOPTIONS_INITDIALOG "data.ini" - Pop $HWND + ${NSD_CreateLabel} 0 0 100% 12u "Please specify where you wish to install Blender's user data files." + ${NSD_CreateRadioButton} 0 20 100% 12u "Use the Application Data directory (Requires Windows 2000 or better)" + Pop $HWND_APPDATA + ${NSD_CreateRadioButton} 0 50 100% 12u "Use the installation directory (ie. location chosen to install blender.exe)." + Pop $HWND_INSTDIR + ${NSD_CreateRadioButton} 0 80 100% 12u "I have defined a %HOME% variable, please install files here." + Pop $HWND_HOMEDIR - Strcmp $is2KXP "true" do_dlg + ${If} ${AtMostWinME} + GetDlgItem $0 $HWND $HWND_APPDATA + EnableWindow $0 0 + SendMessage $HWND_INSTDIR ${BM_SETCHECK} 1 0 + ${Else} + SendMessage $HWND_APPDATA ${BM_SETCHECK} 1 0 + ${EndIf} - ; Disable App Data option on Win9x + nsDialogs::Show - GetDlgItem $DLGITEM $HWND 1201 - EnableWindow $DLGITEM 0 +FunctionEnd + +Function DataLocationOnLeave + StrCpy $SETUSERCONTEXT "false" + ${NSD_GetState} $HWND_APPDATA $R0 + ${If} $R0 == "1" + StrCpy $SETUSERCONTEXT "true" + ${Else} + ${NSD_GetState} $HWND_INSTDIR $R0 + ${If} $R0 == "1" + Call SetWin9xPath + ${Else} + ${NSD_GetState} $HWND_HOMEDIR $R0 + ${If} $R0 == "1" + ReadEnvStr $BLENDERHOME "HOME" + ${EndIf} + ${EndIf} + ${EndIf} +FunctionEnd + +Var HWND_APPDATA_CURRENT +Var HWND_APPDATA_ALLUSERS + +Function AppDataChoice + StrCmp $SETUSERCONTEXT "false" skip - do_dlg: + nsDialogs::Create /NOUNLOAD 1018 + Pop $HWND - !insertmacro MUI_INSTALLOPTIONS_SHOW - !insertmacro MUI_INSTALLOPTIONS_READ $R0 "data.ini" "Field 2" "State" ; App Dir - Strcmp $R0 1 do_app_data - !insertmacro MUI_INSTALLOPTIONS_READ $R0 "data.ini" "Field 3" "State" ; Inst Dir - Strcmp $R0 1 do_inst_path - !insertmacro MUI_INSTALLOPTIONS_READ $R0 "data.ini" "Field 4" "State" ; Home Dir - Strcmp $R0 1 do_home_path + ${NSD_CreateLabel} 0 0 100% 12u "Please choose which Application Data directory to use." + ${NSD_CreateRadioButton} 0 40 100% 12u "Current User" + Pop $HWND_APPDATA_CURRENT + ${NSD_CreateRadioButton} 0 70 100% 12u "All Users" + Pop $HWND_APPDATA_ALLUSERS - Goto end + SendMessage $HWND_APPDATA_CURRENT ${BM_SETCHECK} 1 0 - do_app_data: - Call SetWinXPPath - Goto end - do_home_path: - ReadEnvStr $BLENDERHOME "HOME" - Goto end - do_inst_path: - Call SetWin9xPath - end: + StrCmp $SETUSERCONTEXT "true" 0 skip ; show dialog if we need to set context, otherwise skip it + nsDialogs::Show +skip: + +FunctionEnd + +Function AppDataChoiceOnLeave + StrCmp $SETUSERCONTEXT "false" skip + ${NSD_GetState} $HWND_APPDATA_CURRENT $R0 + ${If} $R0 == "1" + Call SetWinXPPathCurrentUser + ${Else} + Call SetWinXPPathAllUsers + ${EndIf} +skip: + FunctionEnd Section "Blender-VERSION (required)" SecCopyUI SectionIn RO - -; Sets $BLENDERHOME to suit Windows version... ; Set output path to the installation directory. SetOutPath $INSTDIR diff --git a/release/windows/installer/data.ini b/release/windows/installer/data.ini deleted file mode 100644 index d29efcc3fc9..00000000000 --- a/release/windows/installer/data.ini +++ /dev/null @@ -1,34 +0,0 @@ -[Settings] -NumFields=4 - -[Field 1] -Type=label -Text=Please specify where you wish to install Blender's User Data files. -Left=0 -Right=-1 -Top=0 -Bottom=10 - -[Field 2] -Type=RadioButton -Text=Use Application Data Directory (Win2k/XP only) -Left=0 -Right=-1 -Top=20 -Bottom=30 - -[Field 3] -Type=RadioButton -Text=Use Installation Directory (ie. location chosen to install blender.exe). -Left=0 -Right=-1 -Top=40 -Bottom=50 - -[Field 4] -Type=RadioButton -Text=I have defined a %HOME% variable, please install files here. -Left=0 -Right=-1 -Top=60 -Bottom=70 -- cgit v1.2.3