Merge pull request #6950 from leoetlino/nand-path

Port FS, SD and dump path to onion config
This commit is contained in:
spycrab 2018-05-23 20:39:23 +02:00 committed by GitHub
commit 7620e1d5f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 57 additions and 67 deletions

View File

@ -62,12 +62,14 @@ void Load()
{ {
for (auto& layer : s_layers) for (auto& layer : s_layers)
layer.second->Load(); layer.second->Load();
InvokeConfigChangedCallbacks();
} }
void Save() void Save()
{ {
for (auto& layer : s_layers) for (auto& layer : s_layers)
layer.second->Save(); layer.second->Save();
InvokeConfigChangedCallbacks();
} }
void Init() void Init()

View File

@ -115,7 +115,6 @@ void Layer::Load()
if (m_loader) if (m_loader)
m_loader->Load(this); m_loader->Load(this);
m_is_dirty = false; m_is_dirty = false;
InvokeConfigChangedCallbacks();
} }
void Layer::Save() void Layer::Save()
@ -125,7 +124,6 @@ void Layer::Save()
m_loader->Save(this); m_loader->Save(this);
m_is_dirty = false; m_is_dirty = false;
InvokeConfigChangedCallbacks();
} }
LayerType Layer::GetLayer() const LayerType Layer::GetLayer() const

View File

@ -106,4 +106,10 @@ const ConfigInfo<std::string> MAIN_AUDIO_BACKEND{{System::Main, "DSP", "Backend"
AudioCommon::GetDefaultSoundBackend()}; AudioCommon::GetDefaultSoundBackend()};
const ConfigInfo<int> MAIN_AUDIO_VOLUME{{System::Main, "DSP", "Volume"}, 100}; const ConfigInfo<int> MAIN_AUDIO_VOLUME{{System::Main, "DSP", "Volume"}, 100};
// Main.General
const ConfigInfo<std::string> MAIN_DUMP_PATH{{System::Main, "General", "DumpPath"}, ""};
const ConfigInfo<std::string> MAIN_FS_PATH{{System::Main, "General", "NANDRootPath"}, ""};
const ConfigInfo<std::string> MAIN_SD_PATH{{System::Main, "General", "WiiSDCardPath"}, ""};
} // namespace Config } // namespace Config

View File

@ -78,4 +78,10 @@ extern const ConfigInfo<bool> MAIN_DUMP_UCODE;
extern const ConfigInfo<std::string> MAIN_AUDIO_BACKEND; extern const ConfigInfo<std::string> MAIN_AUDIO_BACKEND;
extern const ConfigInfo<int> MAIN_AUDIO_VOLUME; extern const ConfigInfo<int> MAIN_AUDIO_VOLUME;
// Main.General
extern const ConfigInfo<std::string> MAIN_DUMP_PATH;
extern const ConfigInfo<std::string> MAIN_FS_PATH;
extern const ConfigInfo<std::string> MAIN_SD_PATH;
} // namespace Config } // namespace Config

View File

@ -98,21 +98,6 @@ void SConfig::SaveSettings()
Config::Save(); Config::Save();
} }
namespace
{
void CreateDumpPath(const std::string& path)
{
if (path.empty())
return;
File::SetUserPath(D_DUMP_IDX, path + '/');
File::CreateFullPath(File::GetUserPath(D_DUMPAUDIO_IDX));
File::CreateFullPath(File::GetUserPath(D_DUMPDSP_IDX));
File::CreateFullPath(File::GetUserPath(D_DUMPSSL_IDX));
File::CreateFullPath(File::GetUserPath(D_DUMPFRAMES_IDX));
File::CreateFullPath(File::GetUserPath(D_DUMPTEXTURES_IDX));
}
} // namespace
void SConfig::SaveGeneralSettings(IniFile& ini) void SConfig::SaveGeneralSettings(IniFile& ini)
{ {
IniFile::Section* general = ini.GetOrCreateSection("General"); IniFile::Section* general = ini.GetOrCreateSection("General");
@ -138,11 +123,7 @@ void SConfig::SaveGeneralSettings(IniFile& ini)
} }
general->Set("RecursiveISOPaths", m_RecursiveISOFolder); general->Set("RecursiveISOPaths", m_RecursiveISOFolder);
general->Set("NANDRootPath", m_NANDPath);
general->Set("DumpPath", m_DumpPath);
CreateDumpPath(m_DumpPath);
general->Set("WirelessMac", m_WirelessMac); general->Set("WirelessMac", m_WirelessMac);
general->Set("WiiSDCardPath", m_strWiiSDCardPath);
#ifdef USE_GDBSTUB #ifdef USE_GDBSTUB
#ifndef _WIN32 #ifndef _WIN32
@ -430,13 +411,7 @@ void SConfig::LoadGeneralSettings(IniFile& ini)
} }
general->Get("RecursiveISOPaths", &m_RecursiveISOFolder, false); general->Get("RecursiveISOPaths", &m_RecursiveISOFolder, false);
general->Get("NANDRootPath", &m_NANDPath);
File::SetUserPath(D_WIIROOT_IDX, m_NANDPath);
general->Get("DumpPath", &m_DumpPath);
CreateDumpPath(m_DumpPath);
general->Get("WirelessMac", &m_WirelessMac); general->Get("WirelessMac", &m_WirelessMac);
general->Get("WiiSDCardPath", &m_strWiiSDCardPath, File::GetUserPath(F_WIISDCARD_IDX));
File::SetUserPath(F_WIISDCARD_IDX, m_strWiiSDCardPath);
} }
void SConfig::LoadInterfaceSettings(IniFile& ini) void SConfig::LoadInterfaceSettings(IniFile& ini)
@ -799,7 +774,6 @@ void SConfig::LoadDefaults()
iBBDumpPort = -1; iBBDumpPort = -1;
bSyncGPU = false; bSyncGPU = false;
bFastDiscSpeed = false; bFastDiscSpeed = false;
m_strWiiSDCardPath = File::GetUserPath(F_WIISDCARD_IDX);
bEnableMemcardSdWriting = true; bEnableMemcardSdWriting = true;
SelectedLanguage = 0; SelectedLanguage = 0;
bOverrideGCLanguage = false; bOverrideGCLanguage = false;

View File

@ -185,7 +185,6 @@ struct SConfig
std::string m_strBootROM; std::string m_strBootROM;
std::string m_strSRAM; std::string m_strSRAM;
std::string m_strDefaultISO; std::string m_strDefaultISO;
std::string m_strWiiSDCardPath;
std::string m_perfDir; std::string m_perfDir;
@ -219,9 +218,6 @@ struct SConfig
static IniFile LoadLocalGameIni(const std::string& id, std::optional<u16> revision); static IniFile LoadLocalGameIni(const std::string& id, std::optional<u16> revision);
static IniFile LoadGameIni(const std::string& id, std::optional<u16> revision); static IniFile LoadGameIni(const std::string& id, std::optional<u16> revision);
std::string m_NANDPath;
std::string m_DumpPath;
std::string m_strMemoryCardA; std::string m_strMemoryCardA;
std::string m_strMemoryCardB; std::string m_strMemoryCardB;
std::string m_strGbaCartA; std::string m_strGbaCartA;

View File

@ -12,7 +12,8 @@
#include <QPushButton> #include <QPushButton>
#include <QVBoxLayout> #include <QVBoxLayout>
#include "Common/FileUtil.h" #include "Common/Config/Config.h"
#include "Core/Config/MainSettings.h"
#include "Core/ConfigManager.h" #include "Core/ConfigManager.h"
#include "DolphinQt2/Settings.h" #include "DolphinQt2/Settings.h"
@ -55,7 +56,7 @@ void PathPane::BrowseDefaultGame()
void PathPane::BrowseWiiNAND() void PathPane::BrowseWiiNAND()
{ {
QString dir = QDir::toNativeSeparators(QFileDialog::getExistingDirectory( QString dir = QDir::toNativeSeparators(QFileDialog::getExistingDirectory(
this, tr("Select Wii NAND Root"), QString::fromStdString(SConfig::GetInstance().m_NANDPath))); this, tr("Select Wii NAND Root"), QString::fromStdString(Config::Get(Config::MAIN_FS_PATH))));
if (!dir.isEmpty()) if (!dir.isEmpty())
{ {
m_nand_edit->setText(dir); m_nand_edit->setText(dir);
@ -65,21 +66,19 @@ void PathPane::BrowseWiiNAND()
void PathPane::BrowseDump() void PathPane::BrowseDump()
{ {
auto& dump_path = SConfig::GetInstance().m_DumpPath;
QString dir = QDir::toNativeSeparators(QFileDialog::getExistingDirectory( QString dir = QDir::toNativeSeparators(QFileDialog::getExistingDirectory(
this, tr("Select Dump Path"), QString::fromStdString(dump_path))); this, tr("Select Dump Path"), QString::fromStdString(Config::Get(Config::MAIN_DUMP_PATH))));
if (!dir.isEmpty()) if (!dir.isEmpty())
{ {
m_dump_edit->setText(dir); m_dump_edit->setText(dir);
dump_path = dir.toStdString(); Config::SetBase(Config::MAIN_DUMP_PATH, dir.toStdString());
} }
} }
void PathPane::BrowseSDCard() void PathPane::BrowseSDCard()
{ {
QString file = QDir::toNativeSeparators(QFileDialog::getOpenFileName( QString file = QDir::toNativeSeparators(QFileDialog::getOpenFileName(
this, tr("Select a SD Card Image"), this, tr("Select a SD Card Image"), QString::fromStdString(Config::Get(Config::MAIN_SD_PATH)),
QString::fromStdString(SConfig::GetInstance().m_strWiiSDCardPath),
tr("SD Card Image (*.raw);;" tr("SD Card Image (*.raw);;"
"All Files (*)"))); "All Files (*)")));
if (!file.isEmpty()) if (!file.isEmpty())
@ -91,18 +90,12 @@ void PathPane::BrowseSDCard()
void PathPane::OnSDCardPathChanged() void PathPane::OnSDCardPathChanged()
{ {
const auto sd_card_path = m_sdcard_edit->text().toStdString(); Config::SetBase(Config::MAIN_SD_PATH, m_sdcard_edit->text().toStdString());
SConfig::GetInstance().m_strWiiSDCardPath = sd_card_path;
File::SetUserPath(F_WIISDCARD_IDX, sd_card_path);
} }
void PathPane::OnNANDPathChanged() void PathPane::OnNANDPathChanged()
{ {
const auto nand_path = m_nand_edit->text().toStdString(); Config::SetBase(Config::MAIN_FS_PATH, m_nand_edit->text().toStdString());
SConfig::GetInstance().m_NANDPath = nand_path;
File::SetUserPath(D_WIIROOT_IDX, nand_path);
} }
QGroupBox* PathPane::MakeGameFolderBox() QGroupBox* PathPane::MakeGameFolderBox()
@ -170,7 +163,7 @@ QGridLayout* PathPane::MakePathsLayout()
layout->addWidget(m_game_edit, 0, 1); layout->addWidget(m_game_edit, 0, 1);
layout->addWidget(game_open, 0, 2); layout->addWidget(game_open, 0, 2);
m_nand_edit = new QLineEdit(QString::fromStdString(SConfig::GetInstance().m_NANDPath)); m_nand_edit = new QLineEdit(QString::fromStdString(Config::Get(Config::MAIN_FS_PATH)));
connect(m_nand_edit, &QLineEdit::editingFinished, this, &PathPane::OnNANDPathChanged); connect(m_nand_edit, &QLineEdit::editingFinished, this, &PathPane::OnNANDPathChanged);
QPushButton* nand_open = new QPushButton(QStringLiteral("...")); QPushButton* nand_open = new QPushButton(QStringLiteral("..."));
connect(nand_open, &QPushButton::pressed, this, &PathPane::BrowseWiiNAND); connect(nand_open, &QPushButton::pressed, this, &PathPane::BrowseWiiNAND);
@ -178,16 +171,16 @@ QGridLayout* PathPane::MakePathsLayout()
layout->addWidget(m_nand_edit, 1, 1); layout->addWidget(m_nand_edit, 1, 1);
layout->addWidget(nand_open, 1, 2); layout->addWidget(nand_open, 1, 2);
m_dump_edit = new QLineEdit(QString::fromStdString(SConfig::GetInstance().m_DumpPath)); m_dump_edit = new QLineEdit(QString::fromStdString(Config::Get(Config::MAIN_DUMP_PATH)));
connect(m_dump_edit, &QLineEdit::editingFinished, connect(m_dump_edit, &QLineEdit::editingFinished,
[=] { SConfig::GetInstance().m_DumpPath = m_dump_edit->text().toStdString(); }); [=] { Config::SetBase(Config::MAIN_DUMP_PATH, m_dump_edit->text().toStdString()); });
QPushButton* dump_open = new QPushButton(QStringLiteral("...")); QPushButton* dump_open = new QPushButton(QStringLiteral("..."));
connect(dump_open, &QPushButton::pressed, this, &PathPane::BrowseDump); connect(dump_open, &QPushButton::pressed, this, &PathPane::BrowseDump);
layout->addWidget(new QLabel(tr("Dump Path:")), 2, 0); layout->addWidget(new QLabel(tr("Dump Path:")), 2, 0);
layout->addWidget(m_dump_edit, 2, 1); layout->addWidget(m_dump_edit, 2, 1);
layout->addWidget(dump_open, 2, 2); layout->addWidget(dump_open, 2, 2);
m_sdcard_edit = new QLineEdit(QString::fromStdString(SConfig::GetInstance().m_strWiiSDCardPath)); m_sdcard_edit = new QLineEdit(QString::fromStdString(Config::Get(Config::MAIN_SD_PATH)));
connect(m_sdcard_edit, &QLineEdit::editingFinished, this, &PathPane::OnSDCardPathChanged); connect(m_sdcard_edit, &QLineEdit::editingFinished, this, &PathPane::OnSDCardPathChanged);
QPushButton* sdcard_open = new QPushButton(QStringLiteral("...")); QPushButton* sdcard_open = new QPushButton(QStringLiteral("..."));
connect(sdcard_open, &QPushButton::pressed, this, &PathPane::BrowseSDCard); connect(sdcard_open, &QPushButton::pressed, this, &PathPane::BrowseSDCard);

View File

@ -15,7 +15,8 @@
#include <wx/sizer.h> #include <wx/sizer.h>
#include <wx/stattext.h> #include <wx/stattext.h>
#include "Common/FileUtil.h" #include "Common/Config/Config.h"
#include "Core/Config/MainSettings.h"
#include "Core/ConfigManager.h" #include "Core/ConfigManager.h"
#include "Core/Core.h" #include "Core/Core.h"
#include "DolphinWX/Config/ConfigMain.h" #include "DolphinWX/Config/ConfigMain.h"
@ -101,9 +102,9 @@ void PathConfigPane::LoadGUIValues()
m_recursive_iso_paths_checkbox->SetValue(SConfig::GetInstance().m_RecursiveISOFolder); m_recursive_iso_paths_checkbox->SetValue(SConfig::GetInstance().m_RecursiveISOFolder);
m_default_iso_filepicker->SetPath(StrToWxStr(startup_params.m_strDefaultISO)); m_default_iso_filepicker->SetPath(StrToWxStr(startup_params.m_strDefaultISO));
m_nand_root_dirpicker->SetPath(StrToWxStr(SConfig::GetInstance().m_NANDPath)); m_nand_root_dirpicker->SetPath(StrToWxStr(Config::Get(Config::MAIN_FS_PATH)));
m_dump_path_dirpicker->SetPath(StrToWxStr(SConfig::GetInstance().m_DumpPath)); m_dump_path_dirpicker->SetPath(StrToWxStr(Config::Get(Config::MAIN_DUMP_PATH)));
m_wii_sdcard_filepicker->SetPath(StrToWxStr(SConfig::GetInstance().m_strWiiSDCardPath)); m_wii_sdcard_filepicker->SetPath(StrToWxStr(Config::Get(Config::MAIN_SD_PATH)));
// Update selected ISO paths // Update selected ISO paths
for (const std::string& folder : SConfig::GetInstance().m_ISOFolder) for (const std::string& folder : SConfig::GetInstance().m_ISOFolder)
@ -188,18 +189,12 @@ void PathConfigPane::OnDefaultISOChanged(wxCommandEvent& event)
void PathConfigPane::OnSdCardPathChanged(wxCommandEvent& event) void PathConfigPane::OnSdCardPathChanged(wxCommandEvent& event)
{ {
std::string sd_card_path = WxStrToStr(m_wii_sdcard_filepicker->GetPath()); Config::SetBase(Config::MAIN_SD_PATH, WxStrToStr(m_wii_sdcard_filepicker->GetPath()));
SConfig::GetInstance().m_strWiiSDCardPath = sd_card_path;
File::SetUserPath(F_WIISDCARD_IDX, sd_card_path);
} }
void PathConfigPane::OnNANDRootChanged(wxCommandEvent& event) void PathConfigPane::OnNANDRootChanged(wxCommandEvent& event)
{ {
std::string nand_path = SConfig::GetInstance().m_NANDPath = Config::SetBase(Config::MAIN_FS_PATH, WxStrToStr(m_nand_root_dirpicker->GetPath()));
WxStrToStr(m_nand_root_dirpicker->GetPath());
File::SetUserPath(D_WIIROOT_IDX, nand_path);
m_nand_root_dirpicker->SetPath(StrToWxStr(nand_path));
wxCommandEvent update_event{DOLPHIN_EVT_UPDATE_LOAD_WII_MENU_ITEM, GetId()}; wxCommandEvent update_event{DOLPHIN_EVT_UPDATE_LOAD_WII_MENU_ITEM, GetId()};
update_event.SetEventObject(this); update_event.SetEventObject(this);
@ -208,10 +203,7 @@ void PathConfigPane::OnNANDRootChanged(wxCommandEvent& event)
void PathConfigPane::OnDumpPathChanged(wxCommandEvent& event) void PathConfigPane::OnDumpPathChanged(wxCommandEvent& event)
{ {
std::string dump_path = SConfig::GetInstance().m_DumpPath = Config::SetBase(Config::MAIN_DUMP_PATH, WxStrToStr(m_dump_path_dirpicker->GetPath()));
WxStrToStr(m_dump_path_dirpicker->GetPath());
m_dump_path_dirpicker->SetPath(StrToWxStr(dump_path));
} }
void PathConfigPane::SaveISOPathChanges() void PathConfigPane::SaveISOPathChanges()

View File

@ -22,6 +22,7 @@
#include "Common/MsgHandler.h" #include "Common/MsgHandler.h"
#include "Common/StringUtil.h" #include "Common/StringUtil.h"
#include "Core/Config/MainSettings.h"
#include "Core/ConfigLoaders/BaseConfigLoader.h" #include "Core/ConfigLoaders/BaseConfigLoader.h"
#include "Core/ConfigManager.h" #include "Core/ConfigManager.h"
#include "Core/Core.h" #include "Core/Core.h"
@ -47,9 +48,31 @@
namespace UICommon namespace UICommon
{ {
static void CreateDumpPath(const std::string& path)
{
if (path.empty())
return;
File::SetUserPath(D_DUMP_IDX, path + '/');
File::CreateFullPath(File::GetUserPath(D_DUMPAUDIO_IDX));
File::CreateFullPath(File::GetUserPath(D_DUMPDSP_IDX));
File::CreateFullPath(File::GetUserPath(D_DUMPSSL_IDX));
File::CreateFullPath(File::GetUserPath(D_DUMPFRAMES_IDX));
File::CreateFullPath(File::GetUserPath(D_DUMPTEXTURES_IDX));
}
static void InitCustomPaths()
{
File::SetUserPath(D_WIIROOT_IDX, Config::Get(Config::MAIN_FS_PATH));
CreateDumpPath(Config::Get(Config::MAIN_DUMP_PATH));
const std::string sd_path = Config::Get(Config::MAIN_SD_PATH);
if (!sd_path.empty())
File::SetUserPath(F_WIISDCARD_IDX, sd_path);
}
void Init() void Init()
{ {
Config::Init(); Config::Init();
Config::AddConfigChangedCallback(InitCustomPaths);
Config::AddLayer(ConfigLoaders::GenerateBaseConfigLoader()); Config::AddLayer(ConfigLoaders::GenerateBaseConfigLoader());
SConfig::Init(); SConfig::Init();
LogManager::Init(); LogManager::Init();