mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-11-16 01:10:05 +00:00
Recognize main files in game list
This commit is contained in:
parent
17f3590d59
commit
94d27b1717
@ -3,6 +3,7 @@
|
|||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QDir>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
@ -363,6 +364,19 @@ static bool HasSupportedFileExtension(const std::string& file_name) {
|
|||||||
return GameList::supported_file_extensions.contains(file.suffix(), Qt::CaseInsensitive);
|
return GameList::supported_file_extensions.contains(file.suffix(), Qt::CaseInsensitive);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool IsExtractedNCAMain(const std::string& file_name) {
|
||||||
|
return QFileInfo(file_name.c_str()).fileName() == "main";
|
||||||
|
}
|
||||||
|
|
||||||
|
static QString FormatGameName(std::string physical_name) {
|
||||||
|
QFileInfo fileInfo(physical_name.c_str());
|
||||||
|
if (IsExtractedNCAMain(physical_name)) {
|
||||||
|
return fileInfo.dir().dirName();
|
||||||
|
} else {
|
||||||
|
return QString::fromStdString(physical_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GameList::RefreshGameDirectory() {
|
void GameList::RefreshGameDirectory() {
|
||||||
if (!UISettings::values.gamedir.isEmpty() && current_worker != nullptr) {
|
if (!UISettings::values.gamedir.isEmpty() && current_worker != nullptr) {
|
||||||
NGLOG_INFO(Frontend, "Change detected in the games directory. Reloading game list.");
|
NGLOG_INFO(Frontend, "Change detected in the games directory. Reloading game list.");
|
||||||
@ -380,7 +394,8 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign
|
|||||||
return false; // Breaks the callback loop.
|
return false; // Breaks the callback loop.
|
||||||
|
|
||||||
bool is_dir = FileUtil::IsDirectory(physical_name);
|
bool is_dir = FileUtil::IsDirectory(physical_name);
|
||||||
if (!is_dir && HasSupportedFileExtension(physical_name)) {
|
if (!is_dir &&
|
||||||
|
(HasSupportedFileExtension(physical_name) || IsExtractedNCAMain(physical_name))) {
|
||||||
std::unique_ptr<Loader::AppLoader> loader = Loader::GetLoader(physical_name);
|
std::unique_ptr<Loader::AppLoader> loader = Loader::GetLoader(physical_name);
|
||||||
if (!loader)
|
if (!loader)
|
||||||
return true;
|
return true;
|
||||||
@ -392,7 +407,7 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign
|
|||||||
loader->ReadProgramId(program_id);
|
loader->ReadProgramId(program_id);
|
||||||
|
|
||||||
emit EntryReady({
|
emit EntryReady({
|
||||||
new GameListItemPath(QString::fromStdString(physical_name), smdh, program_id),
|
new GameListItemPath(FormatGameName(physical_name), smdh, program_id),
|
||||||
new GameListItem(
|
new GameListItem(
|
||||||
QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType()))),
|
QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType()))),
|
||||||
new GameListItemSize(FileUtil::GetSize(physical_name)),
|
new GameListItemSize(FileUtil::GetSize(physical_name)),
|
||||||
|
Loading…
Reference in New Issue
Block a user