Adds the option to change the path to the wii nand root

when nand root is changed the current sysconf is saved,
and the sysconf in the new location is either loaded (if exists)
or the default sysconf is created
wii menu item is updated when the root changes
small fix to saving gamelist paths to .ini paths that are removed from the gui are now removed from the ini instead of simply changing the number of paths

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7555 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
LPFaint99 2011-05-24 19:12:18 +00:00
parent 139a518e99
commit e4fa493a27
11 changed files with 112 additions and 44 deletions

View File

@ -88,7 +88,7 @@
#define LOGS_DIR "Logs"
#define MAIL_LOGS_DIR LOGS_DIR DIR_SEP "Mail"
#define SHADERS_DIR "Shaders"
#define WII_SYSCONF_DIR WII_USER_DIR DIR_SEP "shared2" DIR_SEP "sys"
#define WII_SYSCONF_DIR "shared2" DIR_SEP "sys"
// Filenames
// Files in the directory returned by GetUserPath(D_CONFIG_IDX)

View File

@ -620,7 +620,7 @@ std::string GetSysDirectory()
// Returns a string with a Dolphin data dir or file in the user's home
// directory. To be used in "multi-user" mode (that is, installed).
std::string &GetUserPath(const unsigned int DirIDX)
std::string &GetUserPath(const unsigned int DirIDX, const std::string &newPath)
{
static std::string paths[NUM_PATH_INDICES];
@ -638,8 +638,8 @@ std::string &GetUserPath(const unsigned int DirIDX)
INFO_LOG(COMMON, "GetUserPath: Setting user directory to %s:", paths[D_USER_IDX].c_str());
paths[D_GCUSER_IDX] = paths[D_USER_IDX] + GC_USER_DIR DIR_SEP;
paths[D_WIIUSER_IDX] = paths[D_USER_IDX] + WII_USER_DIR DIR_SEP;
paths[D_WIIROOT_IDX] = paths[D_USER_IDX] + WII_USER_DIR;
paths[D_WIIUSER_IDX] = paths[D_WIIROOT_IDX] + DIR_SEP;
paths[D_CONFIG_IDX] = paths[D_USER_IDX] + CONFIG_DIR DIR_SEP;
paths[D_GAMECONFIG_IDX] = paths[D_USER_IDX] + GAMECONFIG_DIR DIR_SEP;
paths[D_MAPS_IDX] = paths[D_USER_IDX] + MAPS_DIR DIR_SEP;
@ -657,7 +657,7 @@ std::string &GetUserPath(const unsigned int DirIDX)
paths[D_DUMPDSP_IDX] = paths[D_USER_IDX] + DUMP_DSP_DIR DIR_SEP;
paths[D_LOGS_IDX] = paths[D_USER_IDX] + LOGS_DIR DIR_SEP;
paths[D_MAILLOGS_IDX] = paths[D_USER_IDX] + MAIL_LOGS_DIR DIR_SEP;
paths[D_WIISYSCONF_IDX] = paths[D_USER_IDX] + WII_SYSCONF_DIR DIR_SEP;
paths[D_WIISYSCONF_IDX] = paths[D_WIIUSER_IDX] + WII_SYSCONF_DIR DIR_SEP;
paths[F_DOLPHINCONFIG_IDX] = paths[D_CONFIG_IDX] + DOLPHIN_CONFIG;
paths[F_DSPCONFIG_IDX] = paths[D_CONFIG_IDX] + DSP_CONFIG;
paths[F_DEBUGGERCONFIG_IDX] = paths[D_CONFIG_IDX] + DEBUGGER_CONFIG;
@ -668,6 +668,26 @@ std::string &GetUserPath(const unsigned int DirIDX)
paths[F_ARAMDUMP_IDX] = paths[D_DUMP_IDX] + ARAM_DUMP;
paths[F_GCSRAM_IDX] = paths[D_GCUSER_IDX] + GC_SRAM;
}
if (!newPath.empty())
{
if(DirIDX != D_WIIROOT_IDX)
PanicAlert("trying to change user path other than wii root");
if (!File::IsDirectory(newPath))
{
WARN_LOG(COMMON, "Invalid path specified %s, wii user path will be set to default", newPath.c_str());
paths[D_WIIROOT_IDX] = paths[D_USER_IDX] + WII_USER_DIR;
}
else
{
paths[D_WIIROOT_IDX] = newPath;
}
paths[D_WIIUSER_IDX] = paths[D_WIIROOT_IDX] + DIR_SEP;
paths[D_WIISYSCONF_IDX] = paths[D_WIIUSER_IDX] + WII_SYSCONF_DIR + DIR_SEP;
paths[F_WIISYSCONF_IDX] = paths[D_WIISYSCONF_IDX] + WII_SYSCONF;
}
return paths[DirIDX];
}

View File

@ -30,8 +30,8 @@
enum {
D_USER_IDX,
D_GCUSER_IDX,
D_WIIUSER_IDX,
D_WIIROOT_IDX,
D_WIIUSER_IDX,
D_CONFIG_IDX,
D_GAMECONFIG_IDX,
D_MAPS_IDX,
@ -130,7 +130,7 @@ bool SetCurrentDir(const std::string &directory);
// Returns a pointer to a string with a Dolphin data dir in the user's home
// directory. To be used in "multi-user" mode (that is, installed).
std::string &GetUserPath(const unsigned int DirIDX);
std::string &GetUserPath(const unsigned int DirIDX, const std::string &newPath="");
// Returns the path to where the sys file are
std::string GetSysDirectory();

View File

@ -47,6 +47,7 @@ bool SysConf::LoadFromFile(const char *filename)
// Basic check
if (!File::Exists(filename))
{
File::CreateFullPath(filename);
GenerateSysConf();
return true;
}
@ -404,6 +405,19 @@ bool SysConf::Save()
return SaveToFile(m_Filename.c_str());
}
void SysConf::UpdateLocation()
{
// if the old Wii User dir had a sysconf file save any settings that have been changed to it
if (m_IsValid)
Save();
// Clear the old filename and set the default filename to the new user path
// So that it can be generated if the file does not exist in the new location
m_Filename.clear();
m_FilenameDefault = File::GetUserPath(F_WIISYSCONF_IDX);
Reload();
}
bool SysConf::Reload()
{
if (m_IsValid)

View File

@ -177,6 +177,8 @@ public:
bool SaveToFile(const char* filename);
bool LoadFromFile(const char* filename);
bool Reload();
// This function is used when the NAND root is changed
void UpdateLocation();
private:
bool LoadFromFileInternal(FILE *fh);

View File

@ -132,16 +132,28 @@ void SConfig::SaveSettings()
ini.Set("General", "LastFilename", m_LastFilename);
// ISO folders
ini.Set("General", "GCMPathes", (int)m_ISOFolder.size());
for (size_t i = 0; i < m_ISOFolder.size(); i++)
// clear removed folders
int oldPaths,
numPaths = (int)m_ISOFolder.size();
ini.Get("General", "GCMPathes", &oldPaths, 0);
for (int i = numPaths; i < oldPaths; i++)
{
TCHAR tmp[16];
sprintf(tmp, "GCMPath%i", (int)i);
sprintf(tmp, "GCMPath%i", i);
ini.DeleteKey("General", tmp);
}
ini.Set("General", "GCMPathes", numPaths);
for (int i = 0; i < numPaths; i++)
{
TCHAR tmp[16];
sprintf(tmp, "GCMPath%i", i);
ini.Set("General", tmp, m_ISOFolder[i]);
}
ini.Set("General", "RecursiveGCMPaths", m_RecursiveISOFolder);
ini.Set("General", "NANDRoot", m_NANDPath);
// Interface
ini.Set("Interface", "ConfirmStop", m_LocalCoreStartupParameter.bConfirmStop);
@ -263,6 +275,9 @@ void SConfig::LoadSettings()
}
ini.Get("General", "RecursiveGCMPaths", &m_RecursiveISOFolder, false);
ini.Get("General", "NANDRoot", &m_NANDPath);
m_NANDPath = File::GetUserPath(D_WIIROOT_IDX, m_NANDPath);
}
{

View File

@ -43,6 +43,7 @@ struct SConfig : NonCopyable
bool m_RecursiveISOFolder;
SCoreStartupParameter m_LocalCoreStartupParameter;
std::string m_NANDPath;
std::string m_strMemoryCardA;
std::string m_strMemoryCardB;

View File

@ -179,6 +179,7 @@ EVT_BUTTON(ID_REMOVEISOPATH, CConfigMain::AddRemoveISOPaths)
EVT_FILEPICKER_CHANGED(ID_DEFAULTISO, CConfigMain::DefaultISOChanged)
EVT_DIRPICKER_CHANGED(ID_DVDROOT, CConfigMain::DVDRootChanged)
EVT_FILEPICKER_CHANGED(ID_APPLOADERPATH, CConfigMain::ApploaderPathChanged)
EVT_DIRPICKER_CHANGED(ID_NANDROOT, CConfigMain::NANDRootChanged)
EVT_CHOICE(ID_GRAPHIC_CB, CConfigMain::OnSelectionChanged)
@ -530,6 +531,7 @@ void CConfigMain::InitializeGUIValues()
DefaultISO->SetPath(wxString(startup_params.m_strDefaultGCM.c_str(), *wxConvCurrent));
DVDRoot->SetPath(wxString(startup_params.m_strDVDRoot.c_str(), *wxConvCurrent));
ApploaderPath->SetPath(wxString(startup_params.m_strApploader.c_str(), *wxConvCurrent));
NANDRoot->SetPath(wxString(SConfig::GetInstance().m_NANDPath.c_str(), *wxConvCurrent));
// video backend list
for (std::vector<VideoBackend*>::const_iterator it = g_available_video_backends.begin(); it != g_available_video_backends.end(); ++it)
@ -900,6 +902,7 @@ void CConfigMain::CreateGUIControls()
ApploaderPath = new wxFilePickerCtrl(PathsPage, ID_APPLOADERPATH, wxEmptyString, _("Choose file to use as apploader: (applies to discs constructed from directories only)"),
_("apploader (.img)") + wxString::Format(wxT("|*.img|%s"), wxGetTranslation(wxALL_FILES)),
wxDefaultPosition, wxDefaultSize, wxFLP_USE_TEXTCTRL|wxFLP_OPEN);
NANDRoot = new wxDirPickerCtrl(PathsPage, ID_NANDROOT, wxEmptyString, _("Choose a NAND root directory:"), wxDefaultPosition, wxDefaultSize, wxDIRP_USE_TEXTCTRL);
// Populate the settings
wxBoxSizer* sISOButtons = new wxBoxSizer(wxHORIZONTAL);
@ -921,6 +924,9 @@ void CConfigMain::CreateGUIControls()
sOtherPaths->Add(TEXT_BOX(PathsPage, _("Apploader:")),
wxGBPosition(2, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL|wxALL, 5);
sOtherPaths->Add(ApploaderPath, wxGBPosition(2, 1), wxDefaultSpan, wxEXPAND|wxALL, 5);
sOtherPaths->Add(TEXT_BOX(PathsPage, _("Wii NAND Root:")),
wxGBPosition(3, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL|wxALL, 5);
sOtherPaths->Add(NANDRoot, wxGBPosition(3, 1), wxDefaultSpan, wxEXPAND|wxALL, 5);
sOtherPaths->AddGrowableCol(1);
// Populate the Paths page
@ -1376,6 +1382,14 @@ void CConfigMain::ApploaderPathChanged(wxFileDirPickerEvent& WXUNUSED (event))
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strApploader = ApploaderPath->GetPath().mb_str();
}
void CConfigMain::NANDRootChanged(wxFileDirPickerEvent& WXUNUSED (event))
{
std::string NANDPath =
SConfig::GetInstance().m_NANDPath = File::GetUserPath(D_WIIROOT_IDX, std::string(NANDRoot->GetPath().mb_str()));
NANDRoot->SetPath(wxString(NANDPath.c_str(), *wxConvCurrent));
SConfig::GetInstance().m_SYSCONF->UpdateLocation();
main_frame->UpdateWiiMenuChoice();
}
// GFX backend selection
void CConfigMain::OnSelectionChanged(wxCommandEvent& ev)

View File

@ -137,6 +137,7 @@ private:
ID_DEFAULTISO,
ID_DVDROOT,
ID_APPLOADERPATH,
ID_NANDROOT,
ID_GRAPHIC_CB,
@ -244,10 +245,11 @@ private:
wxButton* AddISOPath;
wxButton* RemoveISOPath;
// DefaultISO, DVD Root, Apploader
// DefaultISO, DVD Root, Apploader, NANDPath
wxFilePickerCtrl* DefaultISO;
wxDirPickerCtrl* DVDRoot;
wxFilePickerCtrl* ApploaderPath;
wxDirPickerCtrl* NANDRoot;
// Graphics
wxChoice* GraphicSelection;
@ -301,6 +303,7 @@ private:
void DefaultISOChanged(wxFileDirPickerEvent& event);
void DVDRootChanged(wxFileDirPickerEvent& event);
void ApploaderPathChanged(wxFileDirPickerEvent& WXUNUSED (event));
void NANDRootChanged(wxFileDirPickerEvent& event);
private:
DECLARE_EVENT_TABLE();

View File

@ -139,6 +139,7 @@ public:
bool RendererHasFocus();
void DoFullscreen(bool bF);
void ToggleDisplayMode (bool bFullscreen);
void UpdateWiiMenuChoice(wxMenuItem *WiiMenuItem=NULL);
static void ConnectWiimote(int wm_idx, bool connect);
const CGameListCtrl *GetGameListCtrl() const;

View File

@ -134,7 +134,7 @@ void CFrame::CreateMenu()
emulationMenu->Append(IDM_STOP, GetMenuLabel(HK_STOP));
emulationMenu->Append(IDM_RESET, GetMenuLabel(HK_RESET));
emulationMenu->AppendSeparator();
emulationMenu->Append(IDM_TOGGLE_FULLSCREEN, GetMenuLabel(HK_FULLSCREEN));
emulationMenu->Append(IDM_TOGGLE_FULLSCREEN, GetMenuLabel(HK_FULLSCREEN));
emulationMenu->AppendSeparator();
emulationMenu->Append(IDM_RECORD, GetMenuLabel(HK_START_RECORDING));
emulationMenu->Append(IDM_PLAYRECORD, GetMenuLabel(HK_PLAY_RECORDING));
@ -192,7 +192,7 @@ void CFrame::CreateMenu()
if (g_pCodeWindow)
{
pOptionsMenu->AppendSeparator();
g_pCodeWindow->CreateMenuOptions(pOptionsMenu);
g_pCodeWindow->CreateMenuOptions(pOptionsMenu);
}
m_MenuBar->Append(pOptionsMenu, _("&Options"));
@ -205,20 +205,7 @@ void CFrame::CreateMenu()
toolsMenu->Append(IDM_NETPLAY, _("Start &NetPlay"));
toolsMenu->Append(IDM_MENU_INSTALLWAD, _("Install WAD"));
const DiscIO::INANDContentLoader & SysMenu_Loader = DiscIO::CNANDContentManager::Access().GetNANDLoader(TITLEID_SYSMENU, true);
if (SysMenu_Loader.IsValid())
{
int sysmenuVersion = SysMenu_Loader.GetTitleVersion();
char sysmenuRegion = SysMenu_Loader.GetCountryChar();
toolsMenu->Append(IDM_LOAD_WII_MENU, wxString::Format(_("Load Wii System Menu %d%c"), sysmenuVersion, sysmenuRegion));
}
else
{
toolsMenu->Append(IDM_LOAD_WII_MENU, _("Load Wii System Menu"));
toolsMenu->Enable(IDM_LOAD_WII_MENU, false);
}
UpdateWiiMenuChoice(toolsMenu->Append(IDM_LOAD_WII_MENU));
toolsMenu->Append(IDM_FIFOPLAYER, _("Fifo Player"));
@ -305,7 +292,7 @@ void CFrame::CreateMenu()
viewMenu->AppendCheckItem(IDM_LISTDRIVES, _("Show Drives"));
viewMenu->Check(IDM_LISTDRIVES, SConfig::GetInstance().m_ListDrives);
viewMenu->Append(IDM_PURGECACHE, _("Purge Cache"));
m_MenuBar->Append(viewMenu, _("&View"));
m_MenuBar->Append(viewMenu, _("&View"));
if (g_pCodeWindow) g_pCodeWindow->CreateMenu(SConfig::GetInstance().m_LocalCoreStartupParameter, m_MenuBar);
@ -471,7 +458,7 @@ void CFrame::PopulateToolbarAui(wxAuiToolBar* ToolBar)
ToolBar->AddTool(IDM_EDIT_PERSPECTIVES, _("Edit"), g_pCodeWindow->m_Bitmaps[Toolbar_GotoPC], _("Edit current perspective"));
ToolBar->SetToolDropDown(IDM_SAVE_PERSPECTIVE, true);
ToolBar->SetToolDropDown(IDM_EDIT_PERSPECTIVES, true);
ToolBar->SetToolDropDown(IDM_EDIT_PERSPECTIVES, true);
ToolBar->Realize();
}
@ -1374,19 +1361,30 @@ void CFrame::OnInstallWAD(wxCommandEvent& event)
u64 titleID = DiscIO::CNANDContentManager::Access().Install_WiiWAD(fileName);
if (titleID == TITLEID_SYSMENU)
{
const DiscIO::INANDContentLoader & SysMenu_Loader = DiscIO::CNANDContentManager::Access().GetNANDLoader(TITLEID_SYSMENU, true);
if (SysMenu_Loader.IsValid())
{
int sysmenuVersion = SysMenu_Loader.GetTitleVersion();
char sysmenuRegion = SysMenu_Loader.GetCountryChar();
UpdateWiiMenuChoice();
}
}
GetMenuBar()->FindItem(IDM_LOAD_WII_MENU)->Enable();
GetMenuBar()->FindItem(IDM_LOAD_WII_MENU)->SetItemLabel(wxString::Format(_("Load Wii System Menu %d%c"), sysmenuVersion, sysmenuRegion));
}
else
{
GetMenuBar()->FindItem(IDM_LOAD_WII_MENU)->Enable(false);
}
void CFrame::UpdateWiiMenuChoice(wxMenuItem *WiiMenuItem)
{
if (!WiiMenuItem)
{
WiiMenuItem = GetMenuBar()->FindItem(IDM_LOAD_WII_MENU);
}
const DiscIO::INANDContentLoader & SysMenu_Loader = DiscIO::CNANDContentManager::Access().GetNANDLoader(TITLEID_SYSMENU, true);
if (SysMenu_Loader.IsValid())
{
int sysmenuVersion = SysMenu_Loader.GetTitleVersion();
char sysmenuRegion = SysMenu_Loader.GetCountryChar();
WiiMenuItem->Enable();
WiiMenuItem->SetItemLabel(wxString::Format(_("Load Wii System Menu %d%c"), sysmenuVersion, sysmenuRegion));
}
else
{
WiiMenuItem->Enable(false);
WiiMenuItem->SetItemLabel(_("Load Wii System Menu"));
}
}
@ -1602,7 +1600,7 @@ void CFrame::UpdateGUI()
if (!SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDefaultGCM.empty())
{
if (m_ToolBar)
m_ToolBar->EnableTool(IDM_PLAY, true);
m_ToolBar->EnableTool(IDM_PLAY, true);
GetMenuBar()->FindItem(IDM_PLAY)->Enable(true);
}
// Prepare to load last selected file, enable play button
@ -1610,7 +1608,7 @@ void CFrame::UpdateGUI()
&& wxFileExists(wxString(SConfig::GetInstance().m_LastFilename.c_str(), wxConvUTF8)))
{
if (m_ToolBar)
m_ToolBar->EnableTool(IDM_PLAY, true);
m_ToolBar->EnableTool(IDM_PLAY, true);
GetMenuBar()->FindItem(IDM_PLAY)->Enable(true);
}
else
@ -1635,7 +1633,7 @@ void CFrame::UpdateGUI()
{
if (m_ToolBar)
m_ToolBar->EnableTool(IDM_PLAY, true);
GetMenuBar()->FindItem(IDM_PLAY)->Enable(true);
GetMenuBar()->FindItem(IDM_PLAY)->Enable(true);
}
}
}