mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2025-06-24 15:47:55 -05:00
Avoid parsing RomFS to directory in NCA
This commit is contained in:
@ -11,6 +11,7 @@
|
||||
#include <QStandardItem>
|
||||
#include <QString>
|
||||
#include "common/string_util.h"
|
||||
#include "ui_settings.h"
|
||||
#include "yuzu/util/util.h"
|
||||
|
||||
/**
|
||||
@ -18,8 +19,7 @@
|
||||
* @param large If true, returns large icon (48x48), otherwise returns small icon (24x24)
|
||||
* @return QPixmap default icon
|
||||
*/
|
||||
static QPixmap GetDefaultIcon(bool large) {
|
||||
int size = large ? 48 : 24;
|
||||
static QPixmap GetDefaultIcon(u32 size) {
|
||||
QPixmap icon(size, size);
|
||||
icon.fill(Qt::transparent);
|
||||
return icon;
|
||||
@ -44,11 +44,25 @@ public:
|
||||
static const int FullPathRole = Qt::UserRole + 1;
|
||||
static const int TitleRole = Qt::UserRole + 2;
|
||||
static const int ProgramIdRole = Qt::UserRole + 3;
|
||||
static const int FileTypeRole = Qt::UserRole + 4;
|
||||
|
||||
GameListItemPath() = default;
|
||||
GameListItemPath(const QString& game_path, const std::vector<u8>& smdh_data, u64 program_id) {
|
||||
GameListItemPath(const QString& game_path, const std::vector<u8>& picture_data,
|
||||
const QString& game_name, const QString& game_type, u64 program_id)
|
||||
: GameListItem() {
|
||||
setData(game_path, FullPathRole);
|
||||
setData(game_name, TitleRole);
|
||||
setData(qulonglong(program_id), ProgramIdRole);
|
||||
setData(game_type, FileTypeRole);
|
||||
|
||||
QPixmap picture;
|
||||
u32 size = UISettings::values.icon_size;
|
||||
if (!picture.loadFromData(picture_data.data(), picture_data.size()))
|
||||
picture = GetDefaultIcon(size);
|
||||
|
||||
picture = picture.scaled(size, size);
|
||||
|
||||
setData(picture, Qt::DecorationRole);
|
||||
}
|
||||
|
||||
QVariant data(int role) const override {
|
||||
@ -57,7 +71,23 @@ public:
|
||||
Common::SplitPath(data(FullPathRole).toString().toStdString(), nullptr, &filename,
|
||||
nullptr);
|
||||
QString title = data(TitleRole).toString();
|
||||
return QString::fromStdString(filename) + (title.isEmpty() ? "" : "\n " + title);
|
||||
|
||||
std::vector<QString> row_data{
|
||||
QString::fromStdString(filename),
|
||||
data(FileTypeRole).toString(),
|
||||
QString::fromStdString(fmt::format("0x{:016X}", data(ProgramIdRole).toULongLong())),
|
||||
data(TitleRole).toString(),
|
||||
};
|
||||
|
||||
auto row1 = row_data.at(UISettings::values.row_1_text_id);
|
||||
auto row2 = row_data.at(UISettings::values.row_2_text_id);
|
||||
|
||||
if (row1.isEmpty() || row1 == row2)
|
||||
return row2;
|
||||
if (row2.isEmpty())
|
||||
return row1;
|
||||
|
||||
return row1 + "\n " + row2;
|
||||
} else {
|
||||
return GameListItem::data(role);
|
||||
}
|
||||
|
Reference in New Issue
Block a user