From 003c40d96afa7426030962015923cc86a7af96da Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Sat, 15 Jan 2011 20:35:05 +0000 Subject: [PATCH] Several bugfixes for the new portable install mode. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4212 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/gui/App.h | 2 +- pcsx2/gui/AppConfig.cpp | 25 ++++++++++++++++--- pcsx2/gui/AppConfig.h | 16 ++++++++++++ pcsx2/gui/AppUserMode.cpp | 48 ++++++++---------------------------- pcsx2/gui/MainMenuClicks.cpp | 2 ++ 5 files changed, 50 insertions(+), 43 deletions(-) diff --git a/pcsx2/gui/App.h b/pcsx2/gui/App.h index 5b5884afdf..b168b17a6c 100644 --- a/pcsx2/gui/App.h +++ b/pcsx2/gui/App.h @@ -544,7 +544,7 @@ public: bool TestUserPermissionsRights( const wxDirName& testFolder, wxString& createFailedStr, wxString& accessFailedStr ); void EstablishAppUserMode(); - wxConfigBase* ReadUserModeSettings(); + wxConfigBase* OpenInstallSettingsFile(); wxConfigBase* TestForPortableInstall(); bool HasPendingSaves() const; diff --git a/pcsx2/gui/AppConfig.cpp b/pcsx2/gui/AppConfig.cpp index 55d21931a7..07161fc367 100644 --- a/pcsx2/gui/AppConfig.cpp +++ b/pcsx2/gui/AppConfig.cpp @@ -90,8 +90,24 @@ namespace PathDefs // sub folder, in which case the approot will become "..") const wxDirName& AppRoot() { - static const wxDirName retval( L"." ); - return retval; + AffinityAssert_AllowFrom_MainUI(); + + if (UserLocalDataMode == UserLocalFolder_System) + { + static const wxDirName cwdCache( (wxDirName)Path::Normalize(wxGetCwd()) ); + return cwdCache; + } + else if (UserLocalDataMode == UserLocalFolder_Portable) + { + static const wxDirName appCache( (wxDirName) + wxFileName(wxStandardPaths::Get().GetExecutablePath()).GetPath() ); + return appCache; + } + else + pxFail( "Unimplemented user local folder mode encountered." ); + + static const wxDirName dotFail(L"."); + return dotFail; } // Specifies the main configuration folder. @@ -415,10 +431,11 @@ void App_LoadSaveInstallSettings( IniInterface& ini ) L"Custom", }; - ini.EnumEntry( L"DocumentsFolderMode", DocsFolderMode, DocsFolderModeNames, DocsFolder_User ); + ini.EnumEntry( L"DocumentsFolderMode", DocsFolderMode, DocsFolderModeNames, (UserLocalDataMode == UserLocalFolder_System) ? DocsFolder_User : DocsFolder_Custom); + + ini.Entry( L"CustomDocumentsFolder", CustomDocumentsFolder, PathDefs::AppRoot() ); ini.Entry( L"UseDefaultSettingsFolder", UseDefaultSettingsFolder, true ); - ini.Entry( L"CustomDocumentsFolder", CustomDocumentsFolder, (wxDirName)Path::Normalize(wxGetCwd()) ); ini.Entry( L"SettingsFolder", SettingsFolder, PathDefs::GetSettings() ); // "Install_Dir" conforms to the NSIS standard install directory key name. diff --git a/pcsx2/gui/AppConfig.h b/pcsx2/gui/AppConfig.h index 8a606179b7..cdeb7e5ae0 100644 --- a/pcsx2/gui/AppConfig.h +++ b/pcsx2/gui/AppConfig.h @@ -67,6 +67,22 @@ extern wxString GetVmSettingsFilename(); extern wxString GetUiSettingsFilename(); extern wxDirName GetLogFolder(); +enum UserLocalDataType +{ + // Use the system defined user local data folder (typically an area outside the user's + // documents folder, but within user read/write permissions zoning; such that it does not + // clutter user document space). + UserLocalFolder_System, + + // Uses the directory containing PCSX2.exe, or the current working directory (if the PCSX2 + // directory could not be determined). This is considered 'portable' mode, and is typically + // detected by PCSX2 on application startup, by looking for a pcsx2_portable.ini file in + // said locations. + UserLocalFolder_Portable, +}; + +extern UserLocalDataType UserLocalDataMode; + enum AspectRatioType { AspectRatio_Stretch, diff --git a/pcsx2/gui/AppUserMode.cpp b/pcsx2/gui/AppUserMode.cpp index 33e216f003..fe11117eb0 100644 --- a/pcsx2/gui/AppUserMode.cpp +++ b/pcsx2/gui/AppUserMode.cpp @@ -40,25 +40,11 @@ wxDirName InstallFolder; wxDirName PluginsFolder; wxDirName ThemesFolder; -enum UserLocalDataType -{ - // Use the system defined user local data folder (typically an area outside the user's - // documents folder, but within user read/write permissions zoning; such that it does not - // clutter user document space). - UserLocalFolder_System, - - // Uses the directory containing PCSX2.exe, or the current working directory (if the PCSX2 - // directory could not be determined). This is considered 'portable' mode, and is typically - // detected by PCSX2 on application startup, by looking for a pcsx2_portable.ini file in - // said locations. - UserLocalFolder_Portable, -}; - // The UserLocalData folder can be redefined depending on whether or not PCSX2 is in // "portable install" mode or not. when PCSX2 has been configured for portable install, the // UserLocalData folder is the current working directory. // -static UserLocalDataType UserLocalDataMode; +UserLocalDataType UserLocalDataMode; static wxFileName GetPortableIniPath() { @@ -197,10 +183,12 @@ wxConfigBase* Pcsx2App::TestForPortableInstall() } - // Success -- all user-based folders have write access. PCSX2 should be - // able to run error-free! + // Success -- all user-based folders have write access. PCSX2 should be able to run error-free! + // Force-set the custom documents mode, and set the UserLocalDataMode = UserLocalFolder_Portable; + DocsFolderMode = DocsFolder_Custom; + CustomDocumentsFolder = portableDocsFolder; return conf_portable.DetachPtr(); } @@ -223,28 +211,12 @@ void Pcsx2App::WipeUserModeSettings() wxRemoveFile(portableIniFile.GetFullPath()); } - // Remove the user-local ini entry conforming to this instance of PCSX2. + // Remove the app-local / registry entry conforming to this instance of PCSX2. // Remove this regardless if PCSX2 is in portable mode, since otherwise these settings // would be used when the user restarts PCSX2, and that might be undesirable. - wxDirName usrlocaldir = PathDefs::GetUserLocalDataDir(); - if( !usrlocaldir.Exists() ) return; - - wxString cwd( Path::Normalize( wxGetCwd() ) ); -#ifdef __WXMSW__ - cwd.MakeLower(); -#endif - u32 hashres = HashTools::Hash( (char*)cwd.c_str(), cwd.Length()*sizeof(wxChar) ); - - wxFileName usermodefile( FilenameDefs::GetUsermodeConfig() ); - usermodefile.SetPath( usrlocaldir.ToString() ); - ScopedPtr conf_usermode( OpenFileConfig( usermodefile.GetFullPath() ) ); - - FastFormatUnicode groupname; - groupname.Write( L"CWD.%08x", hashres ); - Console.WriteLn( "(UserMode) Removing entry:" ); - Console.Indent().WriteLn( L"Path: %s\nHash:%s", cwd.c_str(), groupname.c_str() ); - conf_usermode->DeleteGroup( groupname ); + ScopedPtr conf_install( OpenInstallSettingsFile() ); + conf_install->DeleteEntry(L"RunWizard"); } static void DoFirstTimeWizard() @@ -264,7 +236,7 @@ static void DoFirstTimeWizard() } } -wxConfigBase* Pcsx2App::ReadUserModeSettings() +wxConfigBase* Pcsx2App::OpenInstallSettingsFile() { // Implementation Notes: // @@ -304,7 +276,7 @@ void Pcsx2App::EstablishAppUserMode() conf_install = TestForPortableInstall(); if (!conf_install) - conf_install = ReadUserModeSettings(); + conf_install = OpenInstallSettingsFile(); conf_install->SetRecordDefaults(false); diff --git a/pcsx2/gui/MainMenuClicks.cpp b/pcsx2/gui/MainMenuClicks.cpp index 439075434b..01e8130430 100644 --- a/pcsx2/gui/MainMenuClicks.cpp +++ b/pcsx2/gui/MainMenuClicks.cpp @@ -95,6 +95,8 @@ static void WipeSettings() wxGetApp().GetRecentIsoManager().Clear(); g_Conf = new AppConfig(); sMainFrame.RemoveCdvdMenu(); + + sApp.WipeUserModeSettings(); } void MainEmuFrame::RemoveCdvdMenu()