mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-01 02:29:59 -06:00
VolumeWiiCrypted: Replace ChangePartition with a partition parameter
By removing mutable state in VolumeWiiCrypted, this change makes partition-related code simpler. It also gets rid of other ugly things, like ISOProperties's "over 9000" loop that creates a list of partitions by trying possible combinations, and DiscScrubber's volume swapping that recreates the entire volume when it needs to change partition.
This commit is contained in:
@ -33,32 +33,31 @@ namespace
|
||||
class WiiPartition final : public wxTreeItemData
|
||||
{
|
||||
public:
|
||||
WiiPartition(std::unique_ptr<DiscIO::IVolume> volume_,
|
||||
std::unique_ptr<DiscIO::IFileSystem> filesystem_)
|
||||
: volume{std::move(volume_)}, filesystem{std::move(filesystem_)}
|
||||
WiiPartition(std::unique_ptr<DiscIO::IFileSystem> filesystem_)
|
||||
: filesystem{std::move(filesystem_)}
|
||||
{
|
||||
}
|
||||
|
||||
std::unique_ptr<DiscIO::IVolume> volume;
|
||||
std::unique_ptr<DiscIO::IFileSystem> filesystem;
|
||||
};
|
||||
|
||||
class IntegrityCheckThread final : public wxThread
|
||||
{
|
||||
public:
|
||||
explicit IntegrityCheckThread(const WiiPartition& partition)
|
||||
: wxThread{wxTHREAD_JOINABLE}, m_partition{partition}
|
||||
explicit IntegrityCheckThread(const DiscIO::IVolume* volume, DiscIO::Partition partition)
|
||||
: wxThread{wxTHREAD_JOINABLE}, m_volume{volume}, m_partition{partition}
|
||||
{
|
||||
Create();
|
||||
}
|
||||
|
||||
ExitCode Entry() override
|
||||
{
|
||||
return reinterpret_cast<ExitCode>(m_partition.volume->CheckIntegrity());
|
||||
return reinterpret_cast<ExitCode>(m_volume->CheckIntegrity(m_partition));
|
||||
}
|
||||
|
||||
private:
|
||||
const WiiPartition& m_partition;
|
||||
const DiscIO::IVolume* const m_volume;
|
||||
const DiscIO::Partition m_partition;
|
||||
};
|
||||
|
||||
enum : int
|
||||
@ -156,9 +155,9 @@ WiiPartition* FindWiiPartition(wxTreeCtrl* tree_ctrl, const wxString& label)
|
||||
}
|
||||
} // Anonymous namespace
|
||||
|
||||
FilesystemPanel::FilesystemPanel(wxWindow* parent, wxWindowID id, const GameListItem& item,
|
||||
FilesystemPanel::FilesystemPanel(wxWindow* parent, wxWindowID id,
|
||||
const std::unique_ptr<DiscIO::IVolume>& opened_iso)
|
||||
: wxPanel{parent, id}, m_game_list_item{item}, m_opened_iso{opened_iso}
|
||||
: wxPanel{parent, id}, m_opened_iso{opened_iso}
|
||||
{
|
||||
CreateGUI();
|
||||
BindEvents();
|
||||
@ -217,7 +216,7 @@ void FilesystemPanel::PopulateFileSystemTree()
|
||||
|
||||
void FilesystemPanel::PopulateFileSystemTreeGC()
|
||||
{
|
||||
m_filesystem = DiscIO::CreateFileSystem(m_opened_iso.get());
|
||||
m_filesystem = DiscIO::CreateFileSystem(m_opened_iso.get(), DiscIO::PARTITION_NONE);
|
||||
if (!m_filesystem)
|
||||
return;
|
||||
|
||||
@ -226,34 +225,23 @@ void FilesystemPanel::PopulateFileSystemTreeGC()
|
||||
|
||||
void FilesystemPanel::PopulateFileSystemTreeWii() const
|
||||
{
|
||||
u32 partition_count = 0;
|
||||
|
||||
for (u32 group = 0; group < 4; group++)
|
||||
std::vector<DiscIO::Partition> partitions = m_opened_iso->GetPartitions();
|
||||
for (size_t i = 0; i < partitions.size(); ++i)
|
||||
{
|
||||
// yes, technically there can be OVER NINE THOUSAND partitions...
|
||||
for (u32 i = 0; i < 0xFFFFFFFF; i++)
|
||||
std::unique_ptr<DiscIO::IFileSystem> file_system(
|
||||
DiscIO::CreateFileSystem(m_opened_iso.get(), partitions[i]));
|
||||
if (file_system)
|
||||
{
|
||||
auto volume = DiscIO::CreateVolumeFromFilename(m_game_list_item.GetFileName(), group, i);
|
||||
if (volume == nullptr)
|
||||
break;
|
||||
wxTreeItemId partition_root = m_tree_ctrl->AppendItem(
|
||||
m_tree_ctrl->GetRootItem(), wxString::Format(_("Partition %i"), i), ICON_DISC);
|
||||
|
||||
auto file_system = DiscIO::CreateFileSystem(volume.get());
|
||||
if (file_system != nullptr)
|
||||
{
|
||||
auto* const partition = new WiiPartition(std::move(volume), std::move(file_system));
|
||||
WiiPartition* const partition = new WiiPartition(std::move(file_system));
|
||||
|
||||
const wxTreeItemId partition_root = m_tree_ctrl->AppendItem(
|
||||
m_tree_ctrl->GetRootItem(), wxString::Format(_("Partition %u"), partition_count),
|
||||
ICON_DISC);
|
||||
m_tree_ctrl->SetItemData(partition_root, partition);
|
||||
CreateDirectoryTree(m_tree_ctrl, partition_root, partition->filesystem->GetFileList());
|
||||
|
||||
m_tree_ctrl->SetItemData(partition_root, partition);
|
||||
CreateDirectoryTree(m_tree_ctrl, partition_root, partition->filesystem->GetFileList());
|
||||
|
||||
if (partition_count == 1)
|
||||
m_tree_ctrl->Expand(partition_root);
|
||||
|
||||
partition_count++;
|
||||
}
|
||||
if (i == 1)
|
||||
m_tree_ctrl->Expand(partition_root);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -382,8 +370,9 @@ void FilesystemPanel::OnCheckPartitionIntegrity(wxCommandEvent& WXUNUSED(event))
|
||||
wxPD_APP_MODAL | wxPD_ELAPSED_TIME | wxPD_SMOOTH);
|
||||
|
||||
const auto selection = m_tree_ctrl->GetSelection();
|
||||
|
||||
IntegrityCheckThread thread(*static_cast<WiiPartition*>(m_tree_ctrl->GetItemData(selection)));
|
||||
WiiPartition* partition =
|
||||
static_cast<WiiPartition*>(m_tree_ctrl->GetItemData(m_tree_ctrl->GetSelection()));
|
||||
IntegrityCheckThread thread(m_opened_iso.get(), partition->filesystem->GetPartition());
|
||||
thread.Run();
|
||||
|
||||
while (thread.IsAlive())
|
||||
|
@ -21,7 +21,7 @@ class IVolume;
|
||||
class FilesystemPanel final : public wxPanel
|
||||
{
|
||||
public:
|
||||
explicit FilesystemPanel(wxWindow* parent, wxWindowID id, const GameListItem& item,
|
||||
explicit FilesystemPanel(wxWindow* parent, wxWindowID id,
|
||||
const std::unique_ptr<DiscIO::IVolume>& opened_iso);
|
||||
~FilesystemPanel();
|
||||
|
||||
@ -69,7 +69,6 @@ private:
|
||||
|
||||
wxTreeCtrl* m_tree_ctrl;
|
||||
|
||||
const GameListItem& m_game_list_item;
|
||||
const std::unique_ptr<DiscIO::IVolume>& m_opened_iso;
|
||||
|
||||
std::unique_ptr<DiscIO::IFileSystem> m_filesystem;
|
||||
|
@ -433,9 +433,8 @@ void CISOProperties::CreateGUIControls()
|
||||
|
||||
if (m_open_iso->GetVolumeType() != DiscIO::Platform::WII_WAD)
|
||||
{
|
||||
m_Notebook->AddPage(
|
||||
new FilesystemPanel(m_Notebook, ID_FILESYSTEM, OpenGameListItem, m_open_iso),
|
||||
_("Filesystem"));
|
||||
m_Notebook->AddPage(new FilesystemPanel(m_Notebook, ID_FILESYSTEM, m_open_iso),
|
||||
_("Filesystem"));
|
||||
}
|
||||
|
||||
wxStdDialogButtonSizer* sButtons = CreateStdDialogButtonSizer(wxOK | wxNO_DEFAULT);
|
||||
|
@ -182,7 +182,7 @@ void InfoPanel::LoadISODetails()
|
||||
m_fst->SetValue(StrToWxStr(std::to_string(m_opened_iso->GetFSTSize())));
|
||||
if (m_ios_version)
|
||||
{
|
||||
const IOS::ES::TMDReader tmd = m_opened_iso->GetTMD();
|
||||
const IOS::ES::TMDReader tmd = m_opened_iso->GetTMD(m_opened_iso->GetGamePartition());
|
||||
if (tmd.IsValid())
|
||||
m_ios_version->SetValue(StringFromFormat("IOS%u", static_cast<u32>(tmd.GetIOSId())));
|
||||
}
|
||||
@ -223,7 +223,7 @@ wxStaticBoxSizer* InfoPanel::CreateISODetailsSizer()
|
||||
{_("Apploader Date:"), m_date},
|
||||
{_("FST Size:"), m_fst},
|
||||
}};
|
||||
if (m_opened_iso->GetTMD().IsValid())
|
||||
if (m_opened_iso->GetTMD(m_opened_iso->GetGamePartition()).IsValid())
|
||||
controls.emplace_back(_("IOS Version:"), m_ios_version);
|
||||
|
||||
const int space_10 = FromDIP(10);
|
||||
|
Reference in New Issue
Block a user