Add edat install support

This commit is contained in:
RipleyTom 2021-10-07 13:35:36 +02:00 committed by Megamouse
parent eb850681ee
commit 8e3112734e
3 changed files with 43 additions and 33 deletions

View File

@ -522,7 +522,7 @@ void main_window::BootRsxCapture(std::string path)
} }
} }
bool main_window::InstallRapFile(const QString& path, const std::string& filename) bool main_window::InstallFileInExData(const std::string& extension, const QString& path, const std::string& filename)
{ {
if (path.isEmpty() || filename.empty()) if (path.isEmpty() || filename.empty())
{ {
@ -531,7 +531,7 @@ bool main_window::InstallRapFile(const QString& path, const std::string& filenam
// Copy file atomically with thread/process-safe error checking for file size // Copy file atomically with thread/process-safe error checking for file size
fs::pending_file to(rpcs3::utils::get_hdd0_dir() + "/home/" + Emu.GetUsr() + "/exdata/" + filename.substr(0, filename.find_last_of('.')) + ".rap"); fs::pending_file to(rpcs3::utils::get_hdd0_dir() + "/home/" + Emu.GetUsr() + "/exdata/" + filename.substr(0, filename.find_last_of('.')) + "." + extension);
const fs::file from(sstr(path)); const fs::file from(sstr(path));
if (!to.file || !from) if (!to.file || !from)
@ -557,7 +557,7 @@ void main_window::InstallPackages(QStringList file_paths)
// If this function was called without a path, ask the user for files to install. // If this function was called without a path, ask the user for files to install.
const QString path_last_pkg = m_gui_settings->GetValue(gui::fd_install_pkg).toString(); const QString path_last_pkg = m_gui_settings->GetValue(gui::fd_install_pkg).toString();
const QStringList paths = QFileDialog::getOpenFileNames(this, tr("Select packages and/or rap files to install"), const QStringList paths = QFileDialog::getOpenFileNames(this, tr("Select packages and/or rap files to install"),
path_last_pkg, tr("All relevant (*.pkg *.PKG *.rap *.RAP);;Package files (*.pkg *.PKG);;Rap files (*.rap *.RAP);;All files (*.*)")); path_last_pkg, tr("All relevant (*.pkg *.PKG *.rap *.RAP *.edat *.EDAT);;Package files (*.pkg *.PKG);;Rap files (*.rap *.RAP);;Edat files (*.edat *.EDAT);;All files (*.*)"));
if (paths.isEmpty()) if (paths.isEmpty())
{ {
@ -625,25 +625,32 @@ void main_window::InstallPackages(QStringList file_paths)
} }
// Install rap files if available // Install rap files if available
int installed_rap_count = 0; int installed_rap_and_edat_count = 0;
for (const auto& rap : file_paths.filter(QRegExp(".*\\.rap", Qt::CaseInsensitive))) const auto install_filetype = [&installed_rap_and_edat_count, &file_paths](const std::string extension)
{ {
const QFileInfo file_info(rap); const QString pattern = QString(".*\\.%1").arg(QString::fromStdString(extension));
const std::string rapname = sstr(file_info.fileName()); for (const auto& file : file_paths.filter(QRegExp(pattern, Qt::CaseInsensitive)))
if (InstallRapFile(rap, rapname))
{ {
gui_log.success("Successfully copied rap file: %s", rapname); const QFileInfo file_info(file);
installed_rap_count++; const std::string filename = sstr(file_info.fileName());
}
else
{
gui_log.error("Could not copy rap file: %s", rapname);
}
}
if (installed_rap_count > 0) if (InstallFileInExData(extension, file, filename))
{
gui_log.success("Successfully copied %s file: %s", extension, filename);
installed_rap_and_edat_count++;
}
else
{
gui_log.error("Could not copy %s file: %s", extension, filename);
}
}
};
install_filetype("rap");
install_filetype("edat");
if (installed_rap_and_edat_count > 0)
{ {
// Refresh game list since we probably unlocked some games now. // Refresh game list since we probably unlocked some games now.
m_game_list_frame->Refresh(true); m_game_list_frame->Refresh(true);
@ -2845,14 +2852,14 @@ main_window::drop_type main_window::IsValidFile(const QMimeData& md, QStringList
drop_type = drop_type::drop_pkg; drop_type = drop_type::drop_pkg;
} }
else if (info.suffix().toLower() == "rap") else if (info.suffix().toLower() == "rap" || info.suffix().toLower() == "edat")
{ {
if (info.size() < 0x10 || (drop_type != drop_type::drop_rap && drop_type != drop_type::drop_error)) if (info.size() < 0x10 || (drop_type != drop_type::drop_rap_edat && drop_type != drop_type::drop_error))
{ {
return drop_type::drop_error; return drop_type::drop_error;
} }
drop_type = drop_type::drop_rap; drop_type = drop_type::drop_rap_edat;
} }
else if (list.size() == 1) else if (list.size() == 1)
{ {
@ -2899,30 +2906,33 @@ void main_window::dropEvent(QDropEvent* event)
InstallPup(drop_paths.first()); InstallPup(drop_paths.first());
break; break;
} }
case drop_type::drop_rap: // import rap files to exdata dir case drop_type::drop_rap_edat: // import rap files to exdata dir
{ {
int installed_rap_count = 0; int installed_count = 0;
for (const auto& rap : drop_paths) for (const auto& path : drop_paths)
{ {
const std::string rapname = sstr(QFileInfo(rap).fileName()); const QFileInfo file_info = path;
const std::string extension = file_info.suffix().toLower().toStdString();
const std::string filename = sstr(file_info.fileName());
if (InstallRapFile(rap, rapname)) if (InstallFileInExData(extension, path, filename))
{ {
gui_log.success("Successfully copied rap file by drop: %s", rapname); gui_log.success("Successfully copied %s file by drop: %s", extension, filename);
installed_rap_count++; installed_count++;
} }
else else
{ {
gui_log.error("Could not copy rap file by drop: %s", rapname); gui_log.error("Could not copy %s file by drop: %s", extension, filename);
} }
} }
if (installed_rap_count > 0) if (installed_count > 0)
{ {
// Refresh game list since we probably unlocked some games now. // Refresh game list since we probably unlocked some games now.
m_game_list_frame->Refresh(true); m_game_list_frame->Refresh(true);
} }
break; break;
} }
case drop_type::drop_psf: // Display PARAM.SFO content case drop_type::drop_psf: // Display PARAM.SFO content

View File

@ -74,7 +74,7 @@ class main_window : public QMainWindow
drop_error, drop_error,
drop_pkg, drop_pkg,
drop_pup, drop_pup,
drop_rap, drop_rap_edat,
drop_psf, drop_psf,
drop_dir, drop_dir,
drop_game, drop_game,
@ -143,7 +143,7 @@ private:
void EnableMenus(bool enabled) const; void EnableMenus(bool enabled) const;
void ShowTitleBars(bool show) const; void ShowTitleBars(bool show) const;
static bool InstallRapFile(const QString& path, const std::string& filename); static bool InstallFileInExData(const std::string& extension, const QString& path, const std::string& filename);
void HandlePackageInstallation(QStringList file_paths); void HandlePackageInstallation(QStringList file_paths);

View File

@ -406,7 +406,7 @@
</action> </action>
<action name="bootInstallPkgAct"> <action name="bootInstallPkgAct">
<property name="text"> <property name="text">
<string>Install Packages/Raps</string> <string>Install Packages/Raps/Edats</string>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>Install application from a .pkg file</string> <string>Install application from a .pkg file</string>