Revision: 14503 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14503 Author: aphex Date: 2008-04-21 17:53:32 +0200 (Mon, 21 Apr 2008)
Log Message: ----------- 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) Modified Paths: -------------- trunk/blender/release/windows/installer/00.sconsblender.nsi trunk/blender/source/blender/blenlib/intern/util.c Removed Paths: ------------- trunk/blender/release/windows/installer/data.ini Modified: trunk/blender/release/windows/installer/00.sconsblender.nsi =================================================================== --- trunk/blender/release/windows/installer/00.sconsblender.nsi 2008-04-21 10:15:01 UTC (rev 14502) +++ trunk/blender/release/windows/installer/00.sconsblender.nsi 2008-04-21 15:53:32 UTC (rev 14503) @@ -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 @@ !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 @@ 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,24 +112,76 @@ FunctionEnd Var BLENDERHOME -Var winversion Var DLL_found +Var PREVHOME -Function SetWinXPPath - StrCpy $BLENDERHOME "$PROFILE\Application Data\Blender Foundation\Blender" +Function SetWinXPPathCurrentUser + SetShellVarContext current + StrCpy $BLENDERHOME "$APPDATA\Blender Foundation\Blender" FunctionEnd +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" !define DLL_VER2 "7.10.3052.4" @@ -271,70 +239,90 @@ 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 + nsDialogs::Create /NOUNLOAD 1018 + Pop $HWND - StrCpy $R1 $winversion 2 - StrCmp $R1 "NT" do_win2kxp - StrCmp $winversion "2000" do_win2kxp - StrCmp $winversion "XP" do_win2kxp - StrCmp $winversion "2003" do_win2kxp + ${If} $HWND == error + Abort + ${EndIf} - ;else... - Strcpy $is2KXP "false" + ${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 + + ${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} + + nsDialogs::Show + +FunctionEnd - Goto continue +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 - do_win2kXP: - Strcpy $is2KXP "true" - - continue: +Var HWND_APPDATA_CURRENT +Var HWND_APPDATA_ALLUSERS + +Function AppDataChoice + StrCmp $SETUSERCONTEXT "false" skip - !insertmacro MUI_INSTALLOPTIONS_INITDIALOG "data.ini" + nsDialogs::Create /NOUNLOAD 1018 Pop $HWND - Strcmp $is2KXP "true" do_dlg + ${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 - ; Disable App Data option on Win9x + SendMessage $HWND_APPDATA_CURRENT ${BM_SETCHECK} 1 0 - GetDlgItem $DLGITEM $HWND 1201 - EnableWindow $DLGITEM 0 + StrCmp $SETUSERCONTEXT "true" 0 skip ; show dialog if we need to set context, otherwise skip it + nsDialogs::Show - do_dlg: - - !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 - - Goto end - - do_app_data: - Call SetWinXPPath - Goto end - do_home_path: - ReadEnvStr $BLENDERHOME "HOME" - Goto end - do_inst_path: - Call SetWin9xPath - end: - +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 Deleted: trunk/blender/release/windows/installer/data.ini =================================================================== --- trunk/blender/release/windows/installer/data.ini 2008-04-21 10:15:01 UTC (rev 14502) +++ trunk/blender/release/windows/installer/data.ini 2008-04-21 15:53:32 UTC (rev 14503) @@ -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 Modified: trunk/blender/source/blender/blenlib/intern/util.c =================================================================== --- trunk/blender/source/blender/blenlib/intern/util.c 2008-04-21 10:15:01 UTC (rev 14502) +++ trunk/blender/source/blender/blenlib/intern/util.c 2008-04-21 15:53:32 UTC (rev 14503) @@ -65,6 +65,14 @@ #endif #ifdef WIN32 + +#ifdef _WIN32_IE +#undef _WIN32_IE +#endif +#define _WIN32_IE 0x0501 +#include <windows.h> +#include <shlobj.h> + #include "BLI_winstuff.h" /* for duplicate_defgroup */ @@ -1167,6 +1175,8 @@ #else /* Windows */ char * ret; static char dir[512]; + static char appdatapath[MAXPATHLEN]; + HRESULT hResult; /* Check for %HOME% env var */ @@ -1188,9 +1198,36 @@ /* add user profile support for WIN 2K / NT */ + hResult = SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, appdatapath); + + if (hResult == S_OK) + { + if (BLI_exists(appdatapath)) { /* from fop, also below... */ @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs