Qt: Allow to drop RAP&PKG together

This commit is contained in:
Eladash 2023-06-23 19:06:13 +03:00 committed by Ivan
parent 46350200d7
commit 2da78c6591
2 changed files with 6 additions and 36 deletions

View File

@ -3255,21 +3255,21 @@ main_window::drop_type main_window::IsValidFile(const QMimeData& md, QStringList
}
else if (info.suffix().toLower() == "pkg")
{
if (drop_type != drop_type::drop_pkg && drop_type != drop_type::drop_error)
if (drop_type != drop_type::drop_rap_edat_pkg && drop_type != drop_type::drop_error)
{
return drop_type::drop_error;
}
drop_type = drop_type::drop_pkg;
drop_type = drop_type::drop_rap_edat_pkg;
}
else if (info.suffix().toLower() == "rap" || info.suffix().toLower() == "edat")
{
if (info.size() < 0x10 || (drop_type != drop_type::drop_rap_edat && drop_type != drop_type::drop_error))
if (info.size() < 0x10 || (drop_type != drop_type::drop_rap_edat_pkg && drop_type != drop_type::drop_error))
{
return drop_type::drop_error;
}
drop_type = drop_type::drop_rap_edat;
drop_type = drop_type::drop_rap_edat_pkg;
}
else if (list.size() == 1)
{
@ -3309,7 +3309,7 @@ void main_window::dropEvent(QDropEvent* event)
event->ignore();
break;
}
case drop_type::drop_pkg: // install the packages
case drop_type::drop_rap_edat_pkg: // install the packages
{
InstallPackages(drop_paths);
break;
@ -3319,35 +3319,6 @@ void main_window::dropEvent(QDropEvent* event)
InstallPup(drop_paths.first());
break;
}
case drop_type::drop_rap_edat: // import rap files to exdata dir
{
int installed_count = 0;
for (const auto& path : drop_paths)
{
const QFileInfo file_info = path;
const std::string extension = file_info.suffix().toLower().toStdString();
const std::string filename = sstr(file_info.fileName());
if (InstallFileInExData(extension, path, filename))
{
gui_log.success("Successfully copied %s file by drop: %s", extension, filename);
installed_count++;
}
else
{
gui_log.error("Could not copy %s file by drop: %s", extension, filename);
}
}
if (installed_count > 0)
{
// Refresh game list since we probably unlocked some games now.
m_game_list_frame->Refresh(true);
}
break;
}
case drop_type::drop_psf: // Display PARAM.SFO content
{
for (const auto& psf : drop_paths)

View File

@ -71,9 +71,8 @@ class main_window : public QMainWindow
enum class drop_type
{
drop_error,
drop_pkg,
drop_rap_edat_pkg,
drop_pup,
drop_rap_edat,
drop_psf,
drop_dir,
drop_game,