mirror of
https://git.eden-emu.dev/archive/citron
synced 2026-04-15 17:20:49 -04:00
Merge branch 'column_online' into 'main'
feat(ui): Online Column See merge request citron/emulator!80
This commit is contained in:
@@ -30,7 +30,7 @@
|
|||||||
#include "citron/util/controller_navigation.h"
|
#include "citron/util/controller_navigation.h"
|
||||||
|
|
||||||
GameListSearchField::KeyReleaseEater::KeyReleaseEater(GameList* gamelist_, QObject* parent)
|
GameListSearchField::KeyReleaseEater::KeyReleaseEater(GameList* gamelist_, QObject* parent)
|
||||||
: QObject(parent), gamelist{gamelist_} {}
|
: QObject(parent), gamelist{gamelist_} {}
|
||||||
|
|
||||||
// EventFilter in order to process systemkeys while editing the searchfield
|
// EventFilter in order to process systemkeys while editing the searchfield
|
||||||
bool GameListSearchField::KeyReleaseEater::eventFilter(QObject* obj, QEvent* event) {
|
bool GameListSearchField::KeyReleaseEater::eventFilter(QObject* obj, QEvent* event) {
|
||||||
@@ -45,36 +45,36 @@ bool GameListSearchField::KeyReleaseEater::eventFilter(QObject* obj, QEvent* eve
|
|||||||
// If no function key changes the searchfield's text the filter doesn't need to get reloaded
|
// If no function key changes the searchfield's text the filter doesn't need to get reloaded
|
||||||
if (edit_filter_text == edit_filter_text_old) {
|
if (edit_filter_text == edit_filter_text_old) {
|
||||||
switch (keyEvent->key()) {
|
switch (keyEvent->key()) {
|
||||||
// Escape: Resets the searchfield
|
// Escape: Resets the searchfield
|
||||||
case Qt::Key_Escape: {
|
case Qt::Key_Escape: {
|
||||||
if (edit_filter_text_old.isEmpty()) {
|
if (edit_filter_text_old.isEmpty()) {
|
||||||
return QObject::eventFilter(obj, event);
|
return QObject::eventFilter(obj, event);
|
||||||
} else {
|
} else {
|
||||||
gamelist->search_field->edit_filter->clear();
|
gamelist->search_field->edit_filter->clear();
|
||||||
edit_filter_text.clear();
|
edit_filter_text.clear();
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
// Return and Enter
|
||||||
}
|
// If the enter key gets pressed first checks how many and which entry is visible
|
||||||
// Return and Enter
|
// If there is only one result launch this game
|
||||||
// If the enter key gets pressed first checks how many and which entry is visible
|
case Qt::Key_Return:
|
||||||
// If there is only one result launch this game
|
case Qt::Key_Enter: {
|
||||||
case Qt::Key_Return:
|
if (gamelist->search_field->visible == 1) {
|
||||||
case Qt::Key_Enter: {
|
const QString file_path = gamelist->GetLastFilterResultItem();
|
||||||
if (gamelist->search_field->visible == 1) {
|
|
||||||
const QString file_path = gamelist->GetLastFilterResultItem();
|
|
||||||
|
|
||||||
// To avoid loading error dialog loops while confirming them using enter
|
// To avoid loading error dialog loops while confirming them using enter
|
||||||
// Also users usually want to run a different game after closing one
|
// Also users usually want to run a different game after closing one
|
||||||
gamelist->search_field->edit_filter->clear();
|
gamelist->search_field->edit_filter->clear();
|
||||||
edit_filter_text.clear();
|
edit_filter_text.clear();
|
||||||
emit gamelist->GameChosen(file_path);
|
emit gamelist->GameChosen(file_path);
|
||||||
} else {
|
} else {
|
||||||
return QObject::eventFilter(obj, event);
|
return QObject::eventFilter(obj, event);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
default:
|
||||||
}
|
return QObject::eventFilter(obj, event);
|
||||||
default:
|
|
||||||
return QObject::eventFilter(obj, event);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
edit_filter_text_old = edit_filter_text;
|
edit_filter_text_old = edit_filter_text;
|
||||||
@@ -139,9 +139,9 @@ GameListSearchField::GameListSearchField(GameList* parent) : QWidget{parent} {
|
|||||||
button_filter_close->setCursor(Qt::ArrowCursor);
|
button_filter_close->setCursor(Qt::ArrowCursor);
|
||||||
button_filter_close->setStyleSheet(
|
button_filter_close->setStyleSheet(
|
||||||
QStringLiteral("QToolButton{ border: none; padding: 0px; color: "
|
QStringLiteral("QToolButton{ border: none; padding: 0px; color: "
|
||||||
"#000000; font-weight: bold; background: #F0F0F0; }"
|
"#000000; font-weight: bold; background: #F0F0F0; }"
|
||||||
"QToolButton:hover{ border: none; padding: 0px; color: "
|
"QToolButton:hover{ border: none; padding: 0px; color: "
|
||||||
"#EEEEEE; font-weight: bold; background: #E81123}"));
|
"#EEEEEE; font-weight: bold; background: #E81123}"));
|
||||||
connect(button_filter_close, &QToolButton::clicked, parent, &GameList::OnFilterCloseClicked);
|
connect(button_filter_close, &QToolButton::clicked, parent, &GameList::OnFilterCloseClicked);
|
||||||
layout_filter->setSpacing(10);
|
layout_filter->setSpacing(10);
|
||||||
layout_filter->addWidget(label_filter);
|
layout_filter->addWidget(label_filter);
|
||||||
@@ -171,8 +171,8 @@ static bool ContainsAllWords(const QString& haystack, const QString& userinput)
|
|||||||
void GameList::OnItemExpanded(const QModelIndex& item) {
|
void GameList::OnItemExpanded(const QModelIndex& item) {
|
||||||
const auto type = item.data(GameListItem::TypeRole).value<GameListItemType>();
|
const auto type = item.data(GameListItem::TypeRole).value<GameListItemType>();
|
||||||
const bool is_dir = type == GameListItemType::CustomDir || type == GameListItemType::SdmcDir ||
|
const bool is_dir = type == GameListItemType::CustomDir || type == GameListItemType::SdmcDir ||
|
||||||
type == GameListItemType::UserNandDir ||
|
type == GameListItemType::UserNandDir ||
|
||||||
type == GameListItemType::SysNandDir;
|
type == GameListItemType::SysNandDir;
|
||||||
const bool is_fave = type == GameListItemType::Favorites;
|
const bool is_fave = type == GameListItemType::Favorites;
|
||||||
if (!is_dir && !is_fave) {
|
if (!is_dir && !is_fave) {
|
||||||
return;
|
return;
|
||||||
@@ -247,7 +247,7 @@ void GameList::FilterGridView(const QString& filter_text) {
|
|||||||
const QString file_name = file_path.mid(file_path.lastIndexOf(QLatin1Char{'/'}) + 1) + QLatin1Char{' '} + file_title;
|
const QString file_name = file_path.mid(file_path.lastIndexOf(QLatin1Char{'/'}) + 1) + QLatin1Char{' '} + file_title;
|
||||||
|
|
||||||
should_show = ContainsAllWords(file_name, filter_text) ||
|
should_show = ContainsAllWords(file_name, filter_text) ||
|
||||||
(file_program_id.size() == 16 && file_program_id.contains(filter_text));
|
(file_program_id.size() == 16 && file_program_id.contains(filter_text));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (should_show) {
|
if (should_show) {
|
||||||
@@ -260,7 +260,7 @@ void GameList::FilterGridView(const QString& filter_text) {
|
|||||||
// Fallback to filename if no title
|
// Fallback to filename if no title
|
||||||
std::string filename;
|
std::string filename;
|
||||||
Common::SplitPath(game_item->data(GameListItemPath::FullPathRole).toString().toStdString(),
|
Common::SplitPath(game_item->data(GameListItemPath::FullPathRole).toString().toStdString(),
|
||||||
nullptr, &filename, nullptr);
|
nullptr, &filename, nullptr);
|
||||||
game_title = QString::fromStdString(filename);
|
game_title = QString::fromStdString(filename);
|
||||||
}
|
}
|
||||||
cloned_item->setText(game_title);
|
cloned_item->setText(game_title);
|
||||||
@@ -316,11 +316,11 @@ void GameList::FilterTreeView(const QString& filter_text) {
|
|||||||
const auto program_id = child->data(GameListItemPath::ProgramIdRole).toULongLong();
|
const auto program_id = child->data(GameListItemPath::ProgramIdRole).toULongLong();
|
||||||
|
|
||||||
const QString file_path =
|
const QString file_path =
|
||||||
child->data(GameListItemPath::FullPathRole).toString().toLower();
|
child->data(GameListItemPath::FullPathRole).toString().toLower();
|
||||||
const QString file_title =
|
const QString file_title =
|
||||||
child->data(GameListItemPath::TitleRole).toString().toLower();
|
child->data(GameListItemPath::TitleRole).toString().toLower();
|
||||||
const QString file_program_id =
|
const QString file_program_id =
|
||||||
QStringLiteral("%1").arg(program_id, 16, 16, QLatin1Char{'0'});
|
QStringLiteral("%1").arg(program_id, 16, 16, QLatin1Char{'0'});
|
||||||
|
|
||||||
// Only items which filename in combination with its title contains all words
|
// Only items which filename in combination with its title contains all words
|
||||||
// that are in the searchfield will be visible in the gamelist
|
// that are in the searchfield will be visible in the gamelist
|
||||||
@@ -328,15 +328,15 @@ void GameList::FilterTreeView(const QString& filter_text) {
|
|||||||
// I decided not to use Qt::CaseInsensitive in containsAllWords to prevent
|
// I decided not to use Qt::CaseInsensitive in containsAllWords to prevent
|
||||||
// multiple conversions of edit_filter_text for each game in the gamelist
|
// multiple conversions of edit_filter_text for each game in the gamelist
|
||||||
const QString file_name =
|
const QString file_name =
|
||||||
file_path.mid(file_path.lastIndexOf(QLatin1Char{'/'}) + 1) + QLatin1Char{' '} +
|
file_path.mid(file_path.lastIndexOf(QLatin1Char{'/'}) + 1) + QLatin1Char{' '} +
|
||||||
file_title;
|
file_title;
|
||||||
if (ContainsAllWords(file_name, filter_text) ||
|
if (ContainsAllWords(file_name, filter_text) ||
|
||||||
(file_program_id.size() == 16 && file_program_id.contains(filter_text))) {
|
(file_program_id.size() == 16 && file_program_id.contains(filter_text))) {
|
||||||
tree_view->setRowHidden(j, folder_index, false);
|
tree_view->setRowHidden(j, folder_index, false);
|
||||||
++result_count;
|
++result_count;
|
||||||
} else {
|
} else {
|
||||||
tree_view->setRowHidden(j, folder_index, true);
|
tree_view->setRowHidden(j, folder_index, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
search_field->setFilterResult(result_count, children_total);
|
search_field->setFilterResult(result_count, children_total);
|
||||||
@@ -350,55 +350,55 @@ void GameList::OnUpdateThemedIcons() {
|
|||||||
const int icon_size = UISettings::values.folder_icon_size.GetValue();
|
const int icon_size = UISettings::values.folder_icon_size.GetValue();
|
||||||
|
|
||||||
switch (child->data(GameListItem::TypeRole).value<GameListItemType>()) {
|
switch (child->data(GameListItem::TypeRole).value<GameListItemType>()) {
|
||||||
case GameListItemType::SdmcDir:
|
case GameListItemType::SdmcDir:
|
||||||
child->setData(
|
child->setData(
|
||||||
QIcon::fromTheme(QStringLiteral("sd_card"))
|
QIcon::fromTheme(QStringLiteral("sd_card"))
|
||||||
.pixmap(icon_size)
|
.pixmap(icon_size)
|
||||||
.scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation),
|
.scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation),
|
||||||
Qt::DecorationRole);
|
Qt::DecorationRole);
|
||||||
break;
|
break;
|
||||||
case GameListItemType::UserNandDir:
|
case GameListItemType::UserNandDir:
|
||||||
child->setData(
|
child->setData(
|
||||||
QIcon::fromTheme(QStringLiteral("chip"))
|
QIcon::fromTheme(QStringLiteral("chip"))
|
||||||
.pixmap(icon_size)
|
.pixmap(icon_size)
|
||||||
.scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation),
|
.scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation),
|
||||||
Qt::DecorationRole);
|
Qt::DecorationRole);
|
||||||
break;
|
break;
|
||||||
case GameListItemType::SysNandDir:
|
case GameListItemType::SysNandDir:
|
||||||
child->setData(
|
child->setData(
|
||||||
QIcon::fromTheme(QStringLiteral("chip"))
|
QIcon::fromTheme(QStringLiteral("chip"))
|
||||||
.pixmap(icon_size)
|
.pixmap(icon_size)
|
||||||
.scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation),
|
.scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation),
|
||||||
Qt::DecorationRole);
|
Qt::DecorationRole);
|
||||||
break;
|
break;
|
||||||
case GameListItemType::CustomDir: {
|
case GameListItemType::CustomDir: {
|
||||||
const UISettings::GameDir& game_dir =
|
const UISettings::GameDir& game_dir =
|
||||||
UISettings::values.game_dirs[child->data(GameListDir::GameDirRole).toInt()];
|
UISettings::values.game_dirs[child->data(GameListDir::GameDirRole).toInt()];
|
||||||
const QString icon_name = QFileInfo::exists(QString::fromStdString(game_dir.path))
|
const QString icon_name = QFileInfo::exists(QString::fromStdString(game_dir.path))
|
||||||
? QStringLiteral("folder")
|
? QStringLiteral("folder")
|
||||||
: QStringLiteral("bad_folder");
|
: QStringLiteral("bad_folder");
|
||||||
child->setData(
|
child->setData(
|
||||||
QIcon::fromTheme(icon_name).pixmap(icon_size).scaled(
|
QIcon::fromTheme(icon_name).pixmap(icon_size).scaled(
|
||||||
icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation),
|
icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation),
|
||||||
Qt::DecorationRole);
|
Qt::DecorationRole);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GameListItemType::AddDir:
|
case GameListItemType::AddDir:
|
||||||
child->setData(
|
child->setData(
|
||||||
QIcon::fromTheme(QStringLiteral("list-add"))
|
QIcon::fromTheme(QStringLiteral("list-add"))
|
||||||
.pixmap(icon_size)
|
.pixmap(icon_size)
|
||||||
.scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation),
|
.scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation),
|
||||||
Qt::DecorationRole);
|
Qt::DecorationRole);
|
||||||
break;
|
break;
|
||||||
case GameListItemType::Favorites:
|
case GameListItemType::Favorites:
|
||||||
child->setData(
|
child->setData(
|
||||||
QIcon::fromTheme(QStringLiteral("star"))
|
QIcon::fromTheme(QStringLiteral("star"))
|
||||||
.pixmap(icon_size)
|
.pixmap(icon_size)
|
||||||
.scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation),
|
.scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation),
|
||||||
Qt::DecorationRole);
|
Qt::DecorationRole);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -407,11 +407,11 @@ void GameList::OnFilterCloseClicked() {
|
|||||||
main_window->filterBarSetChecked(false);
|
main_window->filterBarSetChecked(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
GameList::GameList(FileSys::VirtualFilesystem vfs_, FileSys::ManualContentProvider* provider_,
|
GameList::GameList(std::shared_ptr<FileSys::VfsFilesystem> vfs_, FileSys::ManualContentProvider* provider_,
|
||||||
PlayTime::PlayTimeManager& play_time_manager_, Core::System& system_,
|
PlayTime::PlayTimeManager& play_time_manager_, Core::System& system_,
|
||||||
GMainWindow* parent)
|
GMainWindow* parent)
|
||||||
: QWidget{parent}, vfs{std::move(vfs_)}, provider{provider_},
|
: QWidget{parent}, vfs{std::move(vfs_)}, provider{provider_},
|
||||||
play_time_manager{play_time_manager_}, system{system_} {
|
play_time_manager{play_time_manager_}, system{system_} {
|
||||||
watcher = new QFileSystemWatcher(this);
|
watcher = new QFileSystemWatcher(this);
|
||||||
connect(watcher, &QFileSystemWatcher::directoryChanged, this, &GameList::RefreshGameDirectory);
|
connect(watcher, &QFileSystemWatcher::directoryChanged, this, &GameList::RefreshGameDirectory);
|
||||||
|
|
||||||
@@ -505,6 +505,11 @@ GameList::GameList(FileSys::VirtualFilesystem vfs_, FileSys::ManualContentProvid
|
|||||||
|
|
||||||
// Set initial view mode
|
// Set initial view mode
|
||||||
SetViewMode(UISettings::values.game_list_grid_view.GetValue());
|
SetViewMode(UISettings::values.game_list_grid_view.GetValue());
|
||||||
|
|
||||||
|
// Set up the timer for automatic refresh
|
||||||
|
online_status_timer = new QTimer(this);
|
||||||
|
connect(online_status_timer, &QTimer::timeout, this, &GameList::UpdateOnlineStatus);
|
||||||
|
online_status_timer->start(5000); // Refresh every 5 seconds
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameList::UnloadController() {
|
void GameList::UnloadController() {
|
||||||
@@ -544,46 +549,92 @@ void GameList::AddDirEntry(GameListDir* entry_items) {
|
|||||||
item_model->invisibleRootItem()->appendRow(entry_items);
|
item_model->invisibleRootItem()->appendRow(entry_items);
|
||||||
tree_view->setExpanded(
|
tree_view->setExpanded(
|
||||||
entry_items->index(),
|
entry_items->index(),
|
||||||
UISettings::values.game_dirs[entry_items->data(GameListDir::GameDirRole).toInt()].expanded);
|
UISettings::values.game_dirs[entry_items->data(GameListDir::GameDirRole).toInt()].expanded);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameList::AddEntry(const QList<QStandardItem*>& entry_items, GameListDir* parent) {
|
void GameList::AddEntry(const QList<QStandardItem*>& entry_items, GameListDir* parent) {
|
||||||
parent->appendRow(entry_items);
|
parent->appendRow(entry_items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// THIS IS THE NEW REFRESH FUNCTION
|
||||||
|
void GameList::UpdateOnlineStatus() {
|
||||||
|
auto session = main_window->GetMultiplayerState()->GetSession();
|
||||||
|
if (!session || !item_model) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This part is the same as in the worker: fetch and count.
|
||||||
|
std::map<u64, std::pair<int, int>> online_stats; // Game ID -> {player_count, server_count}
|
||||||
|
AnnounceMultiplayerRoom::RoomList room_list = session->GetRoomList();
|
||||||
|
for (const auto& room : room_list) {
|
||||||
|
u64 game_id = room.information.preferred_game.id;
|
||||||
|
if (game_id != 0) {
|
||||||
|
online_stats[game_id].first += room.members.size();
|
||||||
|
online_stats[game_id].second++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now, iterate through the existing list and update the "Online" column.
|
||||||
|
for (int i = 0; i < item_model->rowCount(); ++i) {
|
||||||
|
QStandardItem* folder = item_model->item(i, 0);
|
||||||
|
if (!folder) continue;
|
||||||
|
|
||||||
|
for (int j = 0; j < folder->rowCount(); ++j) {
|
||||||
|
QStandardItem* game_item = folder->child(j, COLUMN_NAME);
|
||||||
|
if (!game_item) continue;
|
||||||
|
|
||||||
|
u64 program_id = game_item->data(GameListItemPath::ProgramIdRole).toULongLong();
|
||||||
|
QString online_text = QStringLiteral("N/A");
|
||||||
|
|
||||||
|
auto it_stats = online_stats.find(program_id);
|
||||||
|
if (it_stats != online_stats.end()) {
|
||||||
|
const auto& stats = it_stats->second;
|
||||||
|
online_text = QStringLiteral("Players: %1 | Servers: %2").arg(stats.first).arg(stats.second);
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is the efficient update. We find the item for the "Online" column and just change its text.
|
||||||
|
QStandardItem* online_item = folder->child(j, COLUMN_ONLINE);
|
||||||
|
if (online_item) {
|
||||||
|
online_item->setData(online_text, Qt::DisplayRole);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void GameList::ValidateEntry(const QModelIndex& item) {
|
void GameList::ValidateEntry(const QModelIndex& item) {
|
||||||
const auto selected = item.sibling(item.row(), 0);
|
const auto selected = item.sibling(item.row(), 0);
|
||||||
|
|
||||||
switch (selected.data(GameListItem::TypeRole).value<GameListItemType>()) {
|
switch (selected.data(GameListItem::TypeRole).value<GameListItemType>()) {
|
||||||
case GameListItemType::Game: {
|
case GameListItemType::Game: {
|
||||||
const QString file_path = selected.data(GameListItemPath::FullPathRole).toString();
|
const QString file_path = selected.data(GameListItemPath::FullPathRole).toString();
|
||||||
if (file_path.isEmpty())
|
if (file_path.isEmpty())
|
||||||
return;
|
return;
|
||||||
const QFileInfo file_info(file_path);
|
const QFileInfo file_info(file_path);
|
||||||
if (!file_info.exists())
|
if (!file_info.exists())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (file_info.isDir()) {
|
if (file_info.isDir()) {
|
||||||
const QDir dir{file_path};
|
const QDir dir{file_path};
|
||||||
const QStringList matching_main = dir.entryList({QStringLiteral("main")}, QDir::Files);
|
const QStringList matching_main = dir.entryList({QStringLiteral("main")}, QDir::Files);
|
||||||
if (matching_main.size() == 1) {
|
if (matching_main.size() == 1) {
|
||||||
emit GameChosen(dir.path() + QDir::separator() + matching_main[0]);
|
emit GameChosen(dir.path() + QDir::separator() + matching_main[0]);
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
|
const auto title_id = selected.data(GameListItemPath::ProgramIdRole).toULongLong();
|
||||||
|
|
||||||
|
// Users usually want to run a different game after closing one
|
||||||
|
search_field->clear();
|
||||||
|
emit GameChosen(file_path, title_id);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
case GameListItemType::AddDir:
|
||||||
const auto title_id = selected.data(GameListItemPath::ProgramIdRole).toULongLong();
|
emit AddDirectory();
|
||||||
|
break;
|
||||||
// Users usually want to run a different game after closing one
|
default:
|
||||||
search_field->clear();
|
break;
|
||||||
emit GameChosen(file_path, title_id);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case GameListItemType::AddDir:
|
|
||||||
emit AddDirectory();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -594,10 +645,10 @@ bool GameList::IsEmpty() const {
|
|||||||
|
|
||||||
if (!child->hasChildren() &&
|
if (!child->hasChildren() &&
|
||||||
(type == GameListItemType::SdmcDir || type == GameListItemType::UserNandDir ||
|
(type == GameListItemType::SdmcDir || type == GameListItemType::UserNandDir ||
|
||||||
type == GameListItemType::SysNandDir)) {
|
type == GameListItemType::SysNandDir)) {
|
||||||
item_model->invisibleRootItem()->removeRow(child->row());
|
item_model->invisibleRootItem()->removeRow(child->row());
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return !item_model->invisibleRootItem()->hasChildren();
|
return !item_model->invisibleRootItem()->hasChildren();
|
||||||
@@ -667,24 +718,24 @@ void GameList::PopupContextMenu(const QPoint& menu_location) {
|
|||||||
const auto selected = item.sibling(item.row(), 0);
|
const auto selected = item.sibling(item.row(), 0);
|
||||||
QMenu context_menu;
|
QMenu context_menu;
|
||||||
switch (selected.data(GameListItem::TypeRole).value<GameListItemType>()) {
|
switch (selected.data(GameListItem::TypeRole).value<GameListItemType>()) {
|
||||||
case GameListItemType::Game:
|
case GameListItemType::Game:
|
||||||
AddGamePopup(context_menu, selected.data(GameListItemPath::ProgramIdRole).toULongLong(),
|
AddGamePopup(context_menu, selected.data(GameListItemPath::ProgramIdRole).toULongLong(),
|
||||||
selected.data(GameListItemPath::FullPathRole).toString().toStdString());
|
selected.data(GameListItemPath::FullPathRole).toString().toStdString());
|
||||||
break;
|
break;
|
||||||
case GameListItemType::CustomDir:
|
case GameListItemType::CustomDir:
|
||||||
AddPermDirPopup(context_menu, selected);
|
AddPermDirPopup(context_menu, selected);
|
||||||
AddCustomDirPopup(context_menu, selected);
|
AddCustomDirPopup(context_menu, selected);
|
||||||
break;
|
break;
|
||||||
case GameListItemType::SdmcDir:
|
case GameListItemType::SdmcDir:
|
||||||
case GameListItemType::UserNandDir:
|
case GameListItemType::UserNandDir:
|
||||||
case GameListItemType::SysNandDir:
|
case GameListItemType::SysNandDir:
|
||||||
AddPermDirPopup(context_menu, selected);
|
AddPermDirPopup(context_menu, selected);
|
||||||
break;
|
break;
|
||||||
case GameListItemType::Favorites:
|
case GameListItemType::Favorites:
|
||||||
AddFavoritesPopup(context_menu);
|
AddFavoritesPopup(context_menu);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tree_view->isVisible()) {
|
if (tree_view->isVisible()) {
|
||||||
@@ -699,12 +750,12 @@ void GameList::AddGamePopup(QMenu& context_menu, u64 program_id, const std::stri
|
|||||||
context_menu.addSeparator();
|
context_menu.addSeparator();
|
||||||
QAction* start_game = context_menu.addAction(tr("Start Game"));
|
QAction* start_game = context_menu.addAction(tr("Start Game"));
|
||||||
QAction* start_game_global =
|
QAction* start_game_global =
|
||||||
context_menu.addAction(tr("Start Game without Custom Configuration"));
|
context_menu.addAction(tr("Start Game without Custom Configuration"));
|
||||||
context_menu.addSeparator();
|
context_menu.addSeparator();
|
||||||
QAction* open_save_location = context_menu.addAction(tr("Open Save Data Location"));
|
QAction* open_save_location = context_menu.addAction(tr("Open Save Data Location"));
|
||||||
QAction* open_mod_location = context_menu.addAction(tr("Open Mod Data Location"));
|
QAction* open_mod_location = context_menu.addAction(tr("Open Mod Data Location"));
|
||||||
QAction* open_transferable_shader_cache =
|
QAction* open_transferable_shader_cache =
|
||||||
context_menu.addAction(tr("Open Transferable Pipeline Cache"));
|
context_menu.addAction(tr("Open Transferable Pipeline Cache"));
|
||||||
context_menu.addSeparator();
|
context_menu.addSeparator();
|
||||||
QMenu* remove_menu = context_menu.addMenu(tr("Remove"));
|
QMenu* remove_menu = context_menu.addMenu(tr("Remove"));
|
||||||
QAction* remove_update = remove_menu->addAction(tr("Remove Installed Update"));
|
QAction* remove_update = remove_menu->addAction(tr("Remove Installed Update"));
|
||||||
@@ -723,13 +774,13 @@ void GameList::AddGamePopup(QMenu& context_menu, u64 program_id, const std::stri
|
|||||||
QAction* verify_integrity = context_menu.addAction(tr("Verify Integrity"));
|
QAction* verify_integrity = context_menu.addAction(tr("Verify Integrity"));
|
||||||
QAction* copy_tid = context_menu.addAction(tr("Copy Title ID to Clipboard"));
|
QAction* copy_tid = context_menu.addAction(tr("Copy Title ID to Clipboard"));
|
||||||
QAction* navigate_to_gamedb_entry = context_menu.addAction(tr("Navigate to GameDB entry"));
|
QAction* navigate_to_gamedb_entry = context_menu.addAction(tr("Navigate to GameDB entry"));
|
||||||
// TODO: Implement shortcut creation for macOS
|
// TODO: Implement shortcut creation for macOS
|
||||||
#if !defined(__APPLE__)
|
#if !defined(__APPLE__)
|
||||||
QMenu* shortcut_menu = context_menu.addMenu(tr("Create Shortcut"));
|
QMenu* shortcut_menu = context_menu.addMenu(tr("Create Shortcut"));
|
||||||
QAction* create_desktop_shortcut = shortcut_menu->addAction(tr("Add to Desktop"));
|
QAction* create_desktop_shortcut = shortcut_menu->addAction(tr("Add to Desktop"));
|
||||||
QAction* create_applications_menu_shortcut =
|
QAction* create_applications_menu_shortcut =
|
||||||
shortcut_menu->addAction(tr("Add to Applications Menu"));
|
shortcut_menu->addAction(tr("Add to Applications Menu"));
|
||||||
#endif
|
#endif
|
||||||
context_menu.addSeparator();
|
context_menu.addSeparator();
|
||||||
QAction* properties = context_menu.addAction(tr("Properties"));
|
QAction* properties = context_menu.addAction(tr("Properties"));
|
||||||
|
|
||||||
@@ -800,22 +851,22 @@ void GameList::AddGamePopup(QMenu& context_menu, u64 program_id, const std::stri
|
|||||||
connect(navigate_to_gamedb_entry, &QAction::triggered, [this, program_id]() {
|
connect(navigate_to_gamedb_entry, &QAction::triggered, [this, program_id]() {
|
||||||
emit NavigateToGamedbEntryRequested(program_id, compatibility_list);
|
emit NavigateToGamedbEntryRequested(program_id, compatibility_list);
|
||||||
});
|
});
|
||||||
// TODO: Implement shortcut creation for macOS
|
// TODO: Implement shortcut creation for macOS
|
||||||
#if !defined(__APPLE__)
|
#if !defined(__APPLE__)
|
||||||
connect(create_desktop_shortcut, &QAction::triggered, [this, program_id, path]() {
|
connect(create_desktop_shortcut, &QAction::triggered, [this, program_id, path]() {
|
||||||
emit CreateShortcut(program_id, path, GameListShortcutTarget::Desktop);
|
emit CreateShortcut(program_id, path, GameListShortcutTarget::Desktop);
|
||||||
});
|
});
|
||||||
connect(create_applications_menu_shortcut, &QAction::triggered, [this, program_id, path]() {
|
connect(create_applications_menu_shortcut, &QAction::triggered, [this, program_id, path]() {
|
||||||
emit CreateShortcut(program_id, path, GameListShortcutTarget::Applications);
|
emit CreateShortcut(program_id, path, GameListShortcutTarget::Applications);
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
connect(properties, &QAction::triggered,
|
connect(properties, &QAction::triggered,
|
||||||
[this, path]() { emit OpenPerGameGeneralRequested(path); });
|
[this, path]() { emit OpenPerGameGeneralRequested(path); });
|
||||||
};
|
};
|
||||||
|
|
||||||
void GameList::AddCustomDirPopup(QMenu& context_menu, QModelIndex selected) {
|
void GameList::AddCustomDirPopup(QMenu& context_menu, QModelIndex selected) {
|
||||||
UISettings::GameDir& game_dir =
|
UISettings::GameDir& game_dir =
|
||||||
UISettings::values.game_dirs[selected.data(GameListDir::GameDirRole).toInt()];
|
UISettings::values.game_dirs[selected.data(GameListDir::GameDirRole).toInt()];
|
||||||
|
|
||||||
QAction* deep_scan = context_menu.addAction(tr("Scan Subfolders"));
|
QAction* deep_scan = context_menu.addAction(tr("Scan Subfolders"));
|
||||||
QAction* delete_dir = context_menu.addAction(tr("Remove Game Directory"));
|
QAction* delete_dir = context_menu.addAction(tr("Remove Game Directory"));
|
||||||
@@ -955,6 +1006,7 @@ void GameList::RetranslateUI() {
|
|||||||
item_model->setHeaderData(COLUMN_FILE_TYPE, Qt::Horizontal, tr("File type"));
|
item_model->setHeaderData(COLUMN_FILE_TYPE, Qt::Horizontal, tr("File type"));
|
||||||
item_model->setHeaderData(COLUMN_SIZE, Qt::Horizontal, tr("Size"));
|
item_model->setHeaderData(COLUMN_SIZE, Qt::Horizontal, tr("Size"));
|
||||||
item_model->setHeaderData(COLUMN_PLAY_TIME, Qt::Horizontal, tr("Play time"));
|
item_model->setHeaderData(COLUMN_PLAY_TIME, Qt::Horizontal, tr("Play time"));
|
||||||
|
item_model->setHeaderData(COLUMN_ONLINE, Qt::Horizontal, tr("Online"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameListSearchField::changeEvent(QEvent* event) {
|
void GameListSearchField::changeEvent(QEvent* event) {
|
||||||
@@ -992,7 +1044,7 @@ void GameList::PopulateAsync(QVector<UISettings::GameDir>& game_dirs) {
|
|||||||
search_field->clear();
|
search_field->clear();
|
||||||
|
|
||||||
current_worker = std::make_unique<GameListWorker>(vfs, provider, game_dirs, compatibility_list,
|
current_worker = std::make_unique<GameListWorker>(vfs, provider, game_dirs, compatibility_list,
|
||||||
play_time_manager, system);
|
play_time_manager, system, main_window->GetMultiplayerState()->GetSession());
|
||||||
|
|
||||||
// Get events from the worker as data becomes available
|
// Get events from the worker as data becomes available
|
||||||
connect(current_worker.get(), &GameListWorker::DataAvailable, this, &GameList::WorkerEvent,
|
connect(current_worker.get(), &GameListWorker::DataAvailable, this, &GameList::WorkerEvent,
|
||||||
@@ -1022,46 +1074,46 @@ const QStringList GameList::supported_file_extensions = {
|
|||||||
QStringLiteral("nso"), QStringLiteral("nro"), QStringLiteral("nca"),
|
QStringLiteral("nso"), QStringLiteral("nro"), QStringLiteral("nca"),
|
||||||
QStringLiteral("xci"), QStringLiteral("nsp"), QStringLiteral("kip")};
|
QStringLiteral("xci"), QStringLiteral("nsp"), QStringLiteral("kip")};
|
||||||
|
|
||||||
void GameList::RefreshGameDirectory() {
|
void GameList::RefreshGameDirectory() {
|
||||||
if (!UISettings::values.game_dirs.empty() && current_worker != nullptr) {
|
if (!UISettings::values.game_dirs.empty() && current_worker != nullptr) {
|
||||||
LOG_INFO(Frontend, "Change detected in the games directory. Reloading game list.");
|
LOG_INFO(Frontend, "Change detected in the games directory. Reloading game list.");
|
||||||
PopulateAsync(UISettings::values.game_dirs);
|
PopulateAsync(UISettings::values.game_dirs);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameList::ToggleFavorite(u64 program_id) {
|
|
||||||
if (!UISettings::values.favorited_ids.contains(program_id)) {
|
|
||||||
tree_view->setRowHidden(0, item_model->invisibleRootItem()->index(),
|
|
||||||
!search_field->filterText().isEmpty());
|
|
||||||
UISettings::values.favorited_ids.append(program_id);
|
|
||||||
AddFavorite(program_id);
|
|
||||||
item_model->sort(tree_view->header()->sortIndicatorSection(),
|
|
||||||
tree_view->header()->sortIndicatorOrder());
|
|
||||||
} else {
|
|
||||||
UISettings::values.favorited_ids.removeOne(program_id);
|
|
||||||
RemoveFavorite(program_id);
|
|
||||||
if (UISettings::values.favorited_ids.size() == 0) {
|
|
||||||
tree_view->setRowHidden(0, item_model->invisibleRootItem()->index(), true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update grid view if it's currently active
|
void GameList::ToggleFavorite(u64 program_id) {
|
||||||
if (list_view->isVisible()) {
|
if (!UISettings::values.favorited_ids.contains(program_id)) {
|
||||||
PopulateGridView();
|
tree_view->setRowHidden(0, item_model->invisibleRootItem()->index(),
|
||||||
|
!search_field->filterText().isEmpty());
|
||||||
|
UISettings::values.favorited_ids.append(program_id);
|
||||||
|
AddFavorite(program_id);
|
||||||
|
item_model->sort(tree_view->header()->sortIndicatorSection(),
|
||||||
|
tree_view->header()->sortIndicatorOrder());
|
||||||
|
} else {
|
||||||
|
UISettings::values.favorited_ids.removeOne(program_id);
|
||||||
|
RemoveFavorite(program_id);
|
||||||
|
if (UISettings::values.favorited_ids.size() == 0) {
|
||||||
|
tree_view->setRowHidden(0, item_model->invisibleRootItem()->index(), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update grid view if it's currently active
|
||||||
|
if (list_view->isVisible()) {
|
||||||
|
PopulateGridView();
|
||||||
|
}
|
||||||
|
|
||||||
|
SaveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
SaveConfig();
|
void GameList::AddFavorite(u64 program_id) {
|
||||||
}
|
auto* favorites_row = item_model->item(0);
|
||||||
|
|
||||||
void GameList::AddFavorite(u64 program_id) {
|
for (int i = 1; i < item_model->rowCount() - 1; i++) {
|
||||||
auto* favorites_row = item_model->item(0);
|
const auto* folder = item_model->item(i);
|
||||||
|
for (int j = 0; j < folder->rowCount(); j++) {
|
||||||
for (int i = 1; i < item_model->rowCount() - 1; i++) {
|
if (folder->child(j)->data(GameListItemPath::ProgramIdRole).toULongLong() ==
|
||||||
const auto* folder = item_model->item(i);
|
program_id) {
|
||||||
for (int j = 0; j < folder->rowCount(); j++) {
|
QList<QStandardItem*> list;
|
||||||
if (folder->child(j)->data(GameListItemPath::ProgramIdRole).toULongLong() ==
|
|
||||||
program_id) {
|
|
||||||
QList<QStandardItem*> list;
|
|
||||||
for (int k = 0; k < COLUMN_COUNT; k++) {
|
for (int k = 0; k < COLUMN_COUNT; k++) {
|
||||||
list.append(folder->child(j, k)->clone());
|
list.append(folder->child(j, k)->clone());
|
||||||
}
|
}
|
||||||
@@ -1071,149 +1123,149 @@ void GameList::AddFavorite(u64 program_id) {
|
|||||||
|
|
||||||
favorites_row->appendRow(list);
|
favorites_row->appendRow(list);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void GameList::RemoveFavorite(u64 program_id) {
|
void GameList::RemoveFavorite(u64 program_id) {
|
||||||
auto* favorites_row = item_model->item(0);
|
auto* favorites_row = item_model->item(0);
|
||||||
|
|
||||||
for (int i = 0; i < favorites_row->rowCount(); i++) {
|
for (int i = 0; i < favorites_row->rowCount(); i++) {
|
||||||
const auto* game = favorites_row->child(i);
|
const auto* game = favorites_row->child(i);
|
||||||
if (game->data(GameListItemPath::ProgramIdRole).toULongLong() == program_id) {
|
if (game->data(GameListItemPath::ProgramIdRole).toULongLong() == program_id) {
|
||||||
favorites_row->removeRow(i);
|
favorites_row->removeRow(i);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
GameListPlaceholder::GameListPlaceholder(GMainWindow* parent) : QWidget{parent} {
|
GameListPlaceholder::GameListPlaceholder(GMainWindow* parent) : QWidget{parent} {
|
||||||
connect(parent, &GMainWindow::UpdateThemedIcons, this,
|
connect(parent, &GMainWindow::UpdateThemedIcons, this,
|
||||||
&GameListPlaceholder::onUpdateThemedIcons);
|
&GameListPlaceholder::onUpdateThemedIcons);
|
||||||
|
|
||||||
layout = new QVBoxLayout;
|
layout = new QVBoxLayout;
|
||||||
image = new QLabel;
|
image = new QLabel;
|
||||||
text = new QLabel;
|
text = new QLabel;
|
||||||
layout->setAlignment(Qt::AlignCenter);
|
layout->setAlignment(Qt::AlignCenter);
|
||||||
image->setPixmap(QIcon::fromTheme(QStringLiteral("plus_folder")).pixmap(200));
|
image->setPixmap(QIcon::fromTheme(QStringLiteral("plus_folder")).pixmap(200));
|
||||||
|
|
||||||
RetranslateUI();
|
|
||||||
QFont font = text->font();
|
|
||||||
font.setPointSize(20);
|
|
||||||
text->setFont(font);
|
|
||||||
text->setAlignment(Qt::AlignHCenter);
|
|
||||||
image->setAlignment(Qt::AlignHCenter);
|
|
||||||
|
|
||||||
layout->addWidget(image);
|
|
||||||
layout->addWidget(text);
|
|
||||||
setLayout(layout);
|
|
||||||
}
|
|
||||||
|
|
||||||
GameListPlaceholder::~GameListPlaceholder() = default;
|
|
||||||
|
|
||||||
void GameListPlaceholder::onUpdateThemedIcons() {
|
|
||||||
image->setPixmap(QIcon::fromTheme(QStringLiteral("plus_folder")).pixmap(200));
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameListPlaceholder::mouseDoubleClickEvent(QMouseEvent* event) {
|
|
||||||
emit GameListPlaceholder::AddDirectory();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameListPlaceholder::changeEvent(QEvent* event) {
|
|
||||||
if (event->type() == QEvent::LanguageChange) {
|
|
||||||
RetranslateUI();
|
RetranslateUI();
|
||||||
|
QFont font = text->font();
|
||||||
|
font.setPointSize(20);
|
||||||
|
text->setFont(font);
|
||||||
|
text->setAlignment(Qt::AlignHCenter);
|
||||||
|
image->setAlignment(Qt::AlignHCenter);
|
||||||
|
|
||||||
|
layout->addWidget(image);
|
||||||
|
layout->addWidget(text);
|
||||||
|
setLayout(layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget::changeEvent(event);
|
GameListPlaceholder::~GameListPlaceholder() = default;
|
||||||
}
|
|
||||||
|
|
||||||
void GameListPlaceholder::RetranslateUI() {
|
void GameListPlaceholder::onUpdateThemedIcons() {
|
||||||
text->setText(tr("Double-click to add a new folder to the game list"));
|
image->setPixmap(QIcon::fromTheme(QStringLiteral("plus_folder")).pixmap(200));
|
||||||
}
|
|
||||||
|
|
||||||
void GameList::SetViewMode(bool grid_view) {
|
|
||||||
if (grid_view) {
|
|
||||||
// Create a flat model for grid view showing only games
|
|
||||||
PopulateGridView();
|
|
||||||
tree_view->setVisible(false);
|
|
||||||
list_view->setVisible(true);
|
|
||||||
// Only set current index if the model has items
|
|
||||||
if (list_view->model() && list_view->model()->rowCount() > 0) {
|
|
||||||
list_view->setCurrentIndex(list_view->model()->index(0, 0));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Restore the hierarchical model for tree view
|
|
||||||
list_view->setVisible(false);
|
|
||||||
tree_view->setVisible(true);
|
|
||||||
// Only set current index if the model has items
|
|
||||||
if (item_model && item_model->rowCount() > 0) {
|
|
||||||
tree_view->setCurrentIndex(item_model->index(0, 0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameList::PopulateGridView() {
|
|
||||||
// Store the current hierarchical model
|
|
||||||
QStandardItemModel* hierarchical_model = item_model;
|
|
||||||
|
|
||||||
// Delete the previous flat model if it exists to prevent memory leaks
|
|
||||||
if (QAbstractItemModel* old_model = list_view->model()) {
|
|
||||||
if (old_model != item_model) {
|
|
||||||
old_model->deleteLater();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new flat model for grid view
|
void GameListPlaceholder::mouseDoubleClickEvent(QMouseEvent* event) {
|
||||||
QStandardItemModel* flat_model = new QStandardItemModel(this);
|
emit GameListPlaceholder::AddDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
// Collect all games from the hierarchical model
|
void GameListPlaceholder::changeEvent(QEvent* event) {
|
||||||
for (int i = 0; i < hierarchical_model->rowCount(); ++i) {
|
if (event->type() == QEvent::LanguageChange) {
|
||||||
QStandardItem* folder = hierarchical_model->item(i, 0);
|
RetranslateUI();
|
||||||
if (!folder) continue;
|
|
||||||
|
|
||||||
// Skip non-game folders in grid view, but include favorites
|
|
||||||
const auto folder_type = folder->data(GameListItem::TypeRole).value<GameListItemType>();
|
|
||||||
if (folder_type == GameListItemType::AddDir) {
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add games from this folder to the flat model
|
QWidget::changeEvent(event);
|
||||||
for (int j = 0; j < folder->rowCount(); ++j) {
|
}
|
||||||
QStandardItem* game_item = folder->child(j, 0);
|
|
||||||
if (!game_item) continue;
|
|
||||||
|
|
||||||
const auto game_type = game_item->data(GameListItem::TypeRole).value<GameListItemType>();
|
void GameListPlaceholder::RetranslateUI() {
|
||||||
if (game_type == GameListItemType::Game) {
|
text->setText(tr("Double-click to add a new folder to the game list"));
|
||||||
// Clone the game item for the flat model
|
}
|
||||||
QStandardItem* cloned_item = game_item->clone();
|
|
||||||
|
|
||||||
// Set display text to just the game title for grid view
|
void GameList::SetViewMode(bool grid_view) {
|
||||||
QString game_title = game_item->data(GameListItemPath::TitleRole).toString();
|
if (grid_view) {
|
||||||
if (game_title.isEmpty()) {
|
// Create a flat model for grid view showing only games
|
||||||
// Fallback to filename if no title
|
PopulateGridView();
|
||||||
std::string filename;
|
tree_view->setVisible(false);
|
||||||
Common::SplitPath(game_item->data(GameListItemPath::FullPathRole).toString().toStdString(),
|
list_view->setVisible(true);
|
||||||
nullptr, &filename, nullptr);
|
// Only set current index if the model has items
|
||||||
game_title = QString::fromStdString(filename);
|
if (list_view->model() && list_view->model()->rowCount() > 0) {
|
||||||
}
|
list_view->setCurrentIndex(list_view->model()->index(0, 0));
|
||||||
cloned_item->setText(game_title);
|
}
|
||||||
|
} else {
|
||||||
flat_model->appendRow(cloned_item);
|
// Restore the hierarchical model for tree view
|
||||||
|
list_view->setVisible(false);
|
||||||
|
tree_view->setVisible(true);
|
||||||
|
// Only set current index if the model has items
|
||||||
|
if (item_model && item_model->rowCount() > 0) {
|
||||||
|
tree_view->setCurrentIndex(item_model->index(0, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the flat model for the list view
|
void GameList::PopulateGridView() {
|
||||||
list_view->setModel(flat_model);
|
// Store the current hierarchical model
|
||||||
|
QStandardItemModel* hierarchical_model = item_model;
|
||||||
|
|
||||||
// Update grid size based on icon size
|
// Delete the previous flat model if it exists to prevent memory leaks
|
||||||
const u32 icon_size = UISettings::values.game_icon_size.GetValue();
|
if (QAbstractItemModel* old_model = list_view->model()) {
|
||||||
list_view->setGridSize(QSize(icon_size + 60, icon_size + 80)); // More padding for round icons and text
|
if (old_model != item_model) {
|
||||||
}
|
old_model->deleteLater();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GameList::ToggleViewMode() {
|
// Create a new flat model for grid view
|
||||||
bool current_grid_view = UISettings::values.game_list_grid_view.GetValue();
|
QStandardItemModel* flat_model = new QStandardItemModel(this);
|
||||||
UISettings::values.game_list_grid_view.SetValue(!current_grid_view);
|
|
||||||
SetViewMode(!current_grid_view);
|
// Collect all games from the hierarchical model
|
||||||
}
|
for (int i = 0; i < hierarchical_model->rowCount(); ++i) {
|
||||||
|
QStandardItem* folder = hierarchical_model->item(i, 0);
|
||||||
|
if (!folder) continue;
|
||||||
|
|
||||||
|
// Skip non-game folders in grid view, but include favorites
|
||||||
|
const auto folder_type = folder->data(GameListItem::TypeRole).value<GameListItemType>();
|
||||||
|
if (folder_type == GameListItemType::AddDir) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add games from this folder to the flat model
|
||||||
|
for (int j = 0; j < folder->rowCount(); ++j) {
|
||||||
|
QStandardItem* game_item = folder->child(j, 0);
|
||||||
|
if (!game_item) continue;
|
||||||
|
|
||||||
|
const auto game_type = game_item->data(GameListItem::TypeRole).value<GameListItemType>();
|
||||||
|
if (game_type == GameListItemType::Game) {
|
||||||
|
// Clone the game item for the flat model
|
||||||
|
QStandardItem* cloned_item = game_item->clone();
|
||||||
|
|
||||||
|
// Set display text to just the game title for grid view
|
||||||
|
QString game_title = game_item->data(GameListItemPath::TitleRole).toString();
|
||||||
|
if (game_title.isEmpty()) {
|
||||||
|
// Fallback to filename if no title
|
||||||
|
std::string filename;
|
||||||
|
Common::SplitPath(game_item->data(GameListItemPath::FullPathRole).toString().toStdString(),
|
||||||
|
nullptr, &filename, nullptr);
|
||||||
|
game_title = QString::fromStdString(filename);
|
||||||
|
}
|
||||||
|
cloned_item->setText(game_title);
|
||||||
|
|
||||||
|
flat_model->appendRow(cloned_item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the flat model for the list view
|
||||||
|
list_view->setModel(flat_model);
|
||||||
|
|
||||||
|
// Update grid size based on icon size
|
||||||
|
const u32 icon_size = UISettings::values.game_icon_size.GetValue();
|
||||||
|
list_view->setGridSize(QSize(icon_size + 60, icon_size + 80)); // More padding for round icons and text
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameList::ToggleViewMode() {
|
||||||
|
bool current_grid_view = UISettings::values.game_list_grid_view.GetValue();
|
||||||
|
UISettings::values.game_list_grid_view.SetValue(!current_grid_view);
|
||||||
|
SetViewMode(!current_grid_view);
|
||||||
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include <QListView>
|
#include <QListView>
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QTimer>
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
@@ -23,7 +24,7 @@
|
|||||||
#include "citron/play_time_manager.h"
|
#include "citron/play_time_manager.h"
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
class System;
|
class System;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ControllerNavigation;
|
class ControllerNavigation;
|
||||||
@@ -35,8 +36,8 @@ enum class AmLaunchType;
|
|||||||
enum class StartGameType;
|
enum class StartGameType;
|
||||||
|
|
||||||
namespace FileSys {
|
namespace FileSys {
|
||||||
class ManualContentProvider;
|
class ManualContentProvider;
|
||||||
class VfsFilesystem;
|
class VfsFilesystem;
|
||||||
} // namespace FileSys
|
} // namespace FileSys
|
||||||
|
|
||||||
enum class GameListOpenTarget {
|
enum class GameListOpenTarget {
|
||||||
@@ -79,6 +80,7 @@ public:
|
|||||||
COLUMN_FILE_TYPE,
|
COLUMN_FILE_TYPE,
|
||||||
COLUMN_SIZE,
|
COLUMN_SIZE,
|
||||||
COLUMN_PLAY_TIME,
|
COLUMN_PLAY_TIME,
|
||||||
|
COLUMN_ONLINE,
|
||||||
COLUMN_COUNT, // Number of columns
|
COLUMN_COUNT, // Number of columns
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -139,6 +141,7 @@ private slots:
|
|||||||
void OnTextChanged(const QString& new_text);
|
void OnTextChanged(const QString& new_text);
|
||||||
void OnFilterCloseClicked();
|
void OnFilterCloseClicked();
|
||||||
void OnUpdateThemedIcons();
|
void OnUpdateThemedIcons();
|
||||||
|
void UpdateOnlineStatus();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class GameListWorker;
|
friend class GameListWorker;
|
||||||
@@ -183,6 +186,7 @@ private:
|
|||||||
QFileSystemWatcher* watcher = nullptr;
|
QFileSystemWatcher* watcher = nullptr;
|
||||||
ControllerNavigation* controller_navigation = nullptr;
|
ControllerNavigation* controller_navigation = nullptr;
|
||||||
CompatibilityList compatibility_list;
|
CompatibilityList compatibility_list;
|
||||||
|
QTimer* online_status_timer;
|
||||||
|
|
||||||
friend class GameListSearchField;
|
friend class GameListSearchField;
|
||||||
|
|
||||||
|
|||||||
@@ -278,6 +278,26 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class GameListItemOnline : public GameListItem {
|
||||||
|
public:
|
||||||
|
static constexpr int OnlineRole = SortRole;
|
||||||
|
|
||||||
|
GameListItemOnline() {
|
||||||
|
|
||||||
|
setData(QStringLiteral("N/A"), Qt::DisplayRole);
|
||||||
|
setData(QStringLiteral("N/A"), OnlineRole);
|
||||||
|
}
|
||||||
|
|
||||||
|
explicit GameListItemOnline(const QString& online_status) {
|
||||||
|
setData(online_status, Qt::DisplayRole);
|
||||||
|
setData(online_status, OnlineRole);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator<(const QStandardItem& other) const override {
|
||||||
|
return data(OnlineRole).toString() < other.data(OnlineRole).toString();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class GameListDir : public GameListItem {
|
class GameListDir : public GameListItem {
|
||||||
public:
|
public:
|
||||||
static constexpr int GameDirRole = Qt::UserRole + 2;
|
static constexpr int GameDirRole = Qt::UserRole + 2;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -191,12 +192,12 @@ QString FormatPatchNameVersions(const FileSys::PatchManager& patch_manager,
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QStandardItem*> MakeGameListEntry(const std::string& path, const std::string& name,
|
QList<QStandardItem*> MakeGameListEntry(
|
||||||
const std::size_t size, const std::vector<u8>& icon,
|
const std::string& path, const std::string& name, const std::size_t size,
|
||||||
Loader::AppLoader& loader, u64 program_id,
|
const std::vector<u8>& icon, Loader::AppLoader& loader, u64 program_id,
|
||||||
const CompatibilityList& compatibility_list,
|
const CompatibilityList& compatibility_list, const PlayTime::PlayTimeManager& play_time_manager,
|
||||||
const PlayTime::PlayTimeManager& play_time_manager,
|
const FileSys::PatchManager& patch,
|
||||||
const FileSys::PatchManager& patch) {
|
const std::map<u64, std::pair<int, int>>& online_stats) {
|
||||||
const auto it = FindMatchingCompatibilityEntry(compatibility_list, program_id);
|
const auto it = FindMatchingCompatibilityEntry(compatibility_list, program_id);
|
||||||
|
|
||||||
// The game list uses this as compatibility number for untested games
|
// The game list uses this as compatibility number for untested games
|
||||||
@@ -208,6 +209,13 @@ QList<QStandardItem*> MakeGameListEntry(const std::string& path, const std::stri
|
|||||||
const auto file_type = loader.GetFileType();
|
const auto file_type = loader.GetFileType();
|
||||||
const auto file_type_string = QString::fromStdString(Loader::GetFileTypeString(file_type));
|
const auto file_type_string = QString::fromStdString(Loader::GetFileTypeString(file_type));
|
||||||
|
|
||||||
|
QString online_text = QStringLiteral("N/A");
|
||||||
|
auto it_stats = online_stats.find(program_id);
|
||||||
|
if (it_stats != online_stats.end()) {
|
||||||
|
const auto& stats = it_stats->second;
|
||||||
|
online_text = QStringLiteral("Players: %1 | Servers: %2").arg(stats.first).arg(stats.second);
|
||||||
|
}
|
||||||
|
|
||||||
QList<QStandardItem*> list{
|
QList<QStandardItem*> list{
|
||||||
new GameListItemPath(FormatGameName(path), icon, QString::fromStdString(name),
|
new GameListItemPath(FormatGameName(path), icon, QString::fromStdString(name),
|
||||||
file_type_string, program_id),
|
file_type_string, program_id),
|
||||||
@@ -215,7 +223,7 @@ QList<QStandardItem*> MakeGameListEntry(const std::string& path, const std::stri
|
|||||||
new GameListItem(file_type_string),
|
new GameListItem(file_type_string),
|
||||||
new GameListItemSize(size),
|
new GameListItemSize(size),
|
||||||
new GameListItemPlayTime(play_time_manager.GetPlayTime(program_id)),
|
new GameListItemPlayTime(play_time_manager.GetPlayTime(program_id)),
|
||||||
};
|
new GameListItemOnline(online_text)};
|
||||||
|
|
||||||
const auto patch_versions = GetGameListCachedObject(
|
const auto patch_versions = GetGameListCachedObject(
|
||||||
fmt::format("{:016X}", patch.GetTitleID()), "pv.txt", [&patch, &loader] {
|
fmt::format("{:016X}", patch.GetTitleID()), "pv.txt", [&patch, &loader] {
|
||||||
@@ -227,15 +235,16 @@ QList<QStandardItem*> MakeGameListEntry(const std::string& path, const std::stri
|
|||||||
}
|
}
|
||||||
} // Anonymous namespace
|
} // Anonymous namespace
|
||||||
|
|
||||||
GameListWorker::GameListWorker(FileSys::VirtualFilesystem vfs_,
|
GameListWorker::GameListWorker(std::shared_ptr<FileSys::VfsFilesystem> vfs_,
|
||||||
FileSys::ManualContentProvider* provider_,
|
FileSys::ManualContentProvider* provider_,
|
||||||
QVector<UISettings::GameDir>& game_dirs_,
|
QVector<UISettings::GameDir>& game_dirs_,
|
||||||
const CompatibilityList& compatibility_list_,
|
const CompatibilityList& compatibility_list_,
|
||||||
const PlayTime::PlayTimeManager& play_time_manager_,
|
const PlayTime::PlayTimeManager& play_time_manager_,
|
||||||
Core::System& system_)
|
Core::System& system_,
|
||||||
|
std::shared_ptr<Core::AnnounceMultiplayerSession> session_)
|
||||||
: vfs{std::move(vfs_)}, provider{provider_}, game_dirs{game_dirs_},
|
: vfs{std::move(vfs_)}, provider{provider_}, game_dirs{game_dirs_},
|
||||||
compatibility_list{compatibility_list_}, play_time_manager{play_time_manager_}, system{
|
compatibility_list{compatibility_list_}, play_time_manager{play_time_manager_},
|
||||||
system_} {
|
system{system_}, session{session_} {
|
||||||
// We want the game list to manage our lifetime.
|
// We want the game list to manage our lifetime.
|
||||||
setAutoDelete(false);
|
setAutoDelete(false);
|
||||||
}
|
}
|
||||||
@@ -282,7 +291,7 @@ void GameListWorker::RecordEvent(F&& func) {
|
|||||||
emit DataAvailable();
|
emit DataAvailable();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameListWorker::AddTitlesToGameList(GameListDir* parent_dir) {
|
void GameListWorker::AddTitlesToGameList(GameListDir* parent_dir, const std::map<u64, std::pair<int, int>>& online_stats) {
|
||||||
using namespace FileSys;
|
using namespace FileSys;
|
||||||
|
|
||||||
const auto& cache = system.GetContentProviderUnion();
|
const auto& cache = system.GetContentProviderUnion();
|
||||||
@@ -329,14 +338,14 @@ void GameListWorker::AddTitlesToGameList(GameListDir* parent_dir) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto entry = MakeGameListEntry(file->GetFullPath(), name, file->GetSize(), icon, *loader,
|
auto entry = MakeGameListEntry(file->GetFullPath(), name, file->GetSize(), icon, *loader,
|
||||||
program_id, compatibility_list, play_time_manager, patch);
|
program_id, compatibility_list, play_time_manager, patch, online_stats);
|
||||||
RecordEvent([=](GameList* game_list) { game_list->AddEntry(entry, parent_dir); });
|
RecordEvent([=](GameList* game_list) { game_list->AddEntry(entry, parent_dir); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameListWorker::ScanFileSystem(ScanTarget target, const std::string& dir_path, bool deep_scan,
|
void GameListWorker::ScanFileSystem(ScanTarget target, const std::string& dir_path, bool deep_scan,
|
||||||
GameListDir* parent_dir) {
|
GameListDir* parent_dir, const std::map<u64, std::pair<int, int>>& online_stats) {
|
||||||
const auto callback = [this, target, parent_dir](const std::filesystem::path& path) -> bool {
|
const auto callback = [this, target, parent_dir, &online_stats](const std::filesystem::path& path) -> bool {
|
||||||
if (stop_requested) {
|
if (stop_requested) {
|
||||||
// Breaks the callback loop.
|
// Breaks the callback loop.
|
||||||
return false;
|
return false;
|
||||||
@@ -406,7 +415,7 @@ void GameListWorker::ScanFileSystem(ScanTarget target, const std::string& dir_pa
|
|||||||
|
|
||||||
auto entry = MakeGameListEntry(
|
auto entry = MakeGameListEntry(
|
||||||
physical_name, name, Common::FS::GetSize(physical_name), icon, *loader,
|
physical_name, name, Common::FS::GetSize(physical_name), icon, *loader,
|
||||||
id, compatibility_list, play_time_manager, patch);
|
id, compatibility_list, play_time_manager, patch, online_stats);
|
||||||
|
|
||||||
RecordEvent(
|
RecordEvent(
|
||||||
[=](GameList* game_list) { game_list->AddEntry(entry, parent_dir); });
|
[=](GameList* game_list) { game_list->AddEntry(entry, parent_dir); });
|
||||||
@@ -423,7 +432,7 @@ void GameListWorker::ScanFileSystem(ScanTarget target, const std::string& dir_pa
|
|||||||
|
|
||||||
auto entry = MakeGameListEntry(
|
auto entry = MakeGameListEntry(
|
||||||
physical_name, name, Common::FS::GetSize(physical_name), icon, *loader,
|
physical_name, name, Common::FS::GetSize(physical_name), icon, *loader,
|
||||||
program_id, compatibility_list, play_time_manager, patch);
|
program_id, compatibility_list, play_time_manager, patch, online_stats);
|
||||||
|
|
||||||
RecordEvent(
|
RecordEvent(
|
||||||
[=](GameList* game_list) { game_list->AddEntry(entry, parent_dir); });
|
[=](GameList* game_list) { game_list->AddEntry(entry, parent_dir); });
|
||||||
@@ -445,6 +454,18 @@ void GameListWorker::ScanFileSystem(ScanTarget target, const std::string& dir_pa
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GameListWorker::run() {
|
void GameListWorker::run() {
|
||||||
|
std::map<u64, std::pair<int, int>> online_stats; // Game ID -> {player_count, server_count}
|
||||||
|
if (session) {
|
||||||
|
AnnounceMultiplayerRoom::RoomList room_list = session->GetRoomList();
|
||||||
|
for (const auto& room : room_list) {
|
||||||
|
u64 game_id = room.information.preferred_game.id;
|
||||||
|
if (game_id != 0) {
|
||||||
|
online_stats[game_id].first += room.members.size();
|
||||||
|
online_stats[game_id].second++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
watch_list.clear();
|
watch_list.clear();
|
||||||
provider->ClearAllEntries();
|
provider->ClearAllEntries();
|
||||||
|
|
||||||
@@ -460,23 +481,23 @@ void GameListWorker::run() {
|
|||||||
if (game_dir.path == std::string("SDMC")) {
|
if (game_dir.path == std::string("SDMC")) {
|
||||||
auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::SdmcDir);
|
auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::SdmcDir);
|
||||||
DirEntryReady(game_list_dir);
|
DirEntryReady(game_list_dir);
|
||||||
AddTitlesToGameList(game_list_dir);
|
AddTitlesToGameList(game_list_dir, online_stats);
|
||||||
} else if (game_dir.path == std::string("UserNAND")) {
|
} else if (game_dir.path == std::string("UserNAND")) {
|
||||||
auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::UserNandDir);
|
auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::UserNandDir);
|
||||||
DirEntryReady(game_list_dir);
|
DirEntryReady(game_list_dir);
|
||||||
AddTitlesToGameList(game_list_dir);
|
AddTitlesToGameList(game_list_dir, online_stats);
|
||||||
} else if (game_dir.path == std::string("SysNAND")) {
|
} else if (game_dir.path == std::string("SysNAND")) {
|
||||||
auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::SysNandDir);
|
auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::SysNandDir);
|
||||||
DirEntryReady(game_list_dir);
|
DirEntryReady(game_list_dir);
|
||||||
AddTitlesToGameList(game_list_dir);
|
AddTitlesToGameList(game_list_dir, online_stats);
|
||||||
} else {
|
} else {
|
||||||
watch_list.append(QString::fromStdString(game_dir.path));
|
watch_list.append(QString::fromStdString(game_dir.path));
|
||||||
auto* const game_list_dir = new GameListDir(game_dir);
|
auto* const game_list_dir = new GameListDir(game_dir);
|
||||||
DirEntryReady(game_list_dir);
|
DirEntryReady(game_list_dir);
|
||||||
ScanFileSystem(ScanTarget::FillManualContentProvider, game_dir.path, game_dir.deep_scan,
|
ScanFileSystem(ScanTarget::FillManualContentProvider, game_dir.path, game_dir.deep_scan,
|
||||||
game_list_dir);
|
game_list_dir, online_stats);
|
||||||
ScanFileSystem(ScanTarget::PopulateGameList, game_dir.path, game_dir.deep_scan,
|
ScanFileSystem(ScanTarget::PopulateGameList, game_dir.path, game_dir.deep_scan,
|
||||||
game_list_dir);
|
game_list_dir, online_stats);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@@ -7,6 +8,8 @@
|
|||||||
#include <deque>
|
#include <deque>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <map> // Required for the online_stats map
|
||||||
|
#include <utility> // Required for std::pair
|
||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
@@ -16,17 +19,21 @@
|
|||||||
#include "common/thread.h"
|
#include "common/thread.h"
|
||||||
#include "citron/compatibility_list.h"
|
#include "citron/compatibility_list.h"
|
||||||
#include "citron/play_time_manager.h"
|
#include "citron/play_time_manager.h"
|
||||||
|
#include "citron/multiplayer/state.h"
|
||||||
|
#include "network/announce_multiplayer_session.h"
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
class System;
|
class System;
|
||||||
}
|
}
|
||||||
|
|
||||||
class GameList;
|
class GameList;
|
||||||
|
class GameListDir; // Forward declare GameListDir
|
||||||
class QStandardItem;
|
class QStandardItem;
|
||||||
|
|
||||||
namespace FileSys {
|
namespace FileSys {
|
||||||
class NCA;
|
class NCA;
|
||||||
class VfsFilesystem;
|
class VfsFilesystem;
|
||||||
|
class ManualContentProvider;
|
||||||
} // namespace FileSys
|
} // namespace FileSys
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,12 +44,18 @@ class GameListWorker : public QObject, public QRunnable {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
enum class ScanTarget {
|
||||||
|
FillManualContentProvider,
|
||||||
|
PopulateGameList,
|
||||||
|
};
|
||||||
|
|
||||||
explicit GameListWorker(std::shared_ptr<FileSys::VfsFilesystem> vfs_,
|
explicit GameListWorker(std::shared_ptr<FileSys::VfsFilesystem> vfs_,
|
||||||
FileSys::ManualContentProvider* provider_,
|
FileSys::ManualContentProvider* provider_,
|
||||||
QVector<UISettings::GameDir>& game_dirs_,
|
QVector<UISettings::GameDir>& game_dirs_,
|
||||||
const CompatibilityList& compatibility_list_,
|
const CompatibilityList& compatibility_list_,
|
||||||
const PlayTime::PlayTimeManager& play_time_manager_,
|
const PlayTime::PlayTimeManager& play_time_manager_,
|
||||||
Core::System& system_);
|
Core::System& system_,
|
||||||
|
std::shared_ptr<Core::AnnounceMultiplayerSession> session_);
|
||||||
~GameListWorker() override;
|
~GameListWorker() override;
|
||||||
|
|
||||||
/// Starts the processing of directory tree information.
|
/// Starts the processing of directory tree information.
|
||||||
@@ -66,15 +79,12 @@ private:
|
|||||||
void RecordEvent(F&& func);
|
void RecordEvent(F&& func);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void AddTitlesToGameList(GameListDir* parent_dir);
|
void AddTitlesToGameList(GameListDir* parent_dir,
|
||||||
|
const std::map<u64, std::pair<int, int>>& online_stats);
|
||||||
enum class ScanTarget {
|
|
||||||
FillManualContentProvider,
|
|
||||||
PopulateGameList,
|
|
||||||
};
|
|
||||||
|
|
||||||
void ScanFileSystem(ScanTarget target, const std::string& dir_path, bool deep_scan,
|
void ScanFileSystem(ScanTarget target, const std::string& dir_path, bool deep_scan,
|
||||||
GameListDir* parent_dir);
|
GameListDir* parent_dir,
|
||||||
|
const std::map<u64, std::pair<int, int>>& online_stats);
|
||||||
|
|
||||||
std::shared_ptr<FileSys::VfsFilesystem> vfs;
|
std::shared_ptr<FileSys::VfsFilesystem> vfs;
|
||||||
FileSys::ManualContentProvider* provider;
|
FileSys::ManualContentProvider* provider;
|
||||||
@@ -91,4 +101,5 @@ private:
|
|||||||
Common::Event processing_completed;
|
Common::Event processing_completed;
|
||||||
|
|
||||||
Core::System& system;
|
Core::System& system;
|
||||||
|
std::shared_ptr<Core::AnnounceMultiplayerSession> session;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -72,59 +72,59 @@ enum class StartGameType {
|
|||||||
};
|
};
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
enum class SystemResultStatus : u32;
|
enum class SystemResultStatus : u32;
|
||||||
class System;
|
class System;
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
|
||||||
namespace Core::Frontend {
|
namespace Core::Frontend {
|
||||||
struct CabinetParameters;
|
struct CabinetParameters;
|
||||||
struct ControllerParameters;
|
struct ControllerParameters;
|
||||||
struct InlineAppearParameters;
|
struct InlineAppearParameters;
|
||||||
struct InlineTextParameters;
|
struct InlineTextParameters;
|
||||||
struct KeyboardInitializeParameters;
|
struct KeyboardInitializeParameters;
|
||||||
struct ProfileSelectParameters;
|
struct ProfileSelectParameters;
|
||||||
} // namespace Core::Frontend
|
} // namespace Core::Frontend
|
||||||
|
|
||||||
namespace DiscordRPC {
|
namespace DiscordRPC {
|
||||||
class DiscordInterface;
|
class DiscordInterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace PlayTime {
|
namespace PlayTime {
|
||||||
class PlayTimeManager;
|
class PlayTimeManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace FileSys {
|
namespace FileSys {
|
||||||
class ContentProvider;
|
class ContentProvider;
|
||||||
class ManualContentProvider;
|
class ManualContentProvider;
|
||||||
class VfsFilesystem;
|
class VfsFilesystem;
|
||||||
} // namespace FileSys
|
} // namespace FileSys
|
||||||
|
|
||||||
namespace InputCommon {
|
namespace InputCommon {
|
||||||
class InputSubsystem;
|
class InputSubsystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Service::AM {
|
namespace Service::AM {
|
||||||
struct FrontendAppletParameters;
|
struct FrontendAppletParameters;
|
||||||
enum class AppletId : u32;
|
enum class AppletId : u32;
|
||||||
} // namespace Service::AM
|
} // namespace Service::AM
|
||||||
|
|
||||||
namespace Service::AM::Frontend {
|
namespace Service::AM::Frontend {
|
||||||
enum class SwkbdResult : u32;
|
enum class SwkbdResult : u32;
|
||||||
enum class SwkbdTextCheckResult : u32;
|
enum class SwkbdTextCheckResult : u32;
|
||||||
enum class SwkbdReplyType : u32;
|
enum class SwkbdReplyType : u32;
|
||||||
enum class WebExitReason : u32;
|
enum class WebExitReason : u32;
|
||||||
} // namespace Service::AM::Frontend
|
} // namespace Service::AM::Frontend
|
||||||
|
|
||||||
namespace Service::NFC {
|
namespace Service::NFC {
|
||||||
class NfcDevice;
|
class NfcDevice;
|
||||||
} // namespace Service::NFC
|
} // namespace Service::NFC
|
||||||
|
|
||||||
namespace Service::NFP {
|
namespace Service::NFP {
|
||||||
enum class CabinetMode : u8;
|
enum class CabinetMode : u8;
|
||||||
} // namespace Service::NFP
|
} // namespace Service::NFP
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class EmulatedDirectoryTarget {
|
enum class EmulatedDirectoryTarget {
|
||||||
@@ -133,7 +133,7 @@ enum class EmulatedDirectoryTarget {
|
|||||||
};
|
};
|
||||||
|
|
||||||
namespace VkDeviceInfo {
|
namespace VkDeviceInfo {
|
||||||
class Record;
|
class Record;
|
||||||
}
|
}
|
||||||
|
|
||||||
class VolumeButton : public QPushButton {
|
class VolumeButton : public QPushButton {
|
||||||
@@ -183,6 +183,13 @@ public:
|
|||||||
bool DropAction(QDropEvent* event);
|
bool DropAction(QDropEvent* event);
|
||||||
void AcceptDropEvent(QDropEvent* event);
|
void AcceptDropEvent(QDropEvent* event);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the new function to provide access to the MultiplayerState.
|
||||||
|
*/
|
||||||
|
MultiplayerState* GetMultiplayerState() {
|
||||||
|
return multiplayer_state;
|
||||||
|
}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -326,16 +333,16 @@ private:
|
|||||||
std::string CreateTASFramesString(
|
std::string CreateTASFramesString(
|
||||||
std::array<size_t, InputCommon::TasInput::PLAYER_NUMBER> frames) const;
|
std::array<size_t, InputCommon::TasInput::PLAYER_NUMBER> frames) const;
|
||||||
|
|
||||||
#ifdef __unix__
|
#ifdef __unix__
|
||||||
void SetupSigInterrupts();
|
void SetupSigInterrupts();
|
||||||
static void HandleSigInterrupt(int);
|
static void HandleSigInterrupt(int);
|
||||||
void OnSigInterruptNotifierActivated();
|
void OnSigInterruptNotifierActivated();
|
||||||
void SetGamemodeEnabled(bool state);
|
void SetGamemodeEnabled(bool state);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Service::AM::FrontendAppletParameters ApplicationAppletParameters();
|
Service::AM::FrontendAppletParameters ApplicationAppletParameters();
|
||||||
Service::AM::FrontendAppletParameters LibraryAppletParameters(u64 program_id,
|
Service::AM::FrontendAppletParameters LibraryAppletParameters(u64 program_id,
|
||||||
Service::AM::AppletId applet_id);
|
Service::AM::AppletId applet_id);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void OnStartGame();
|
void OnStartGame();
|
||||||
@@ -495,7 +502,7 @@ private:
|
|||||||
*/
|
*/
|
||||||
bool question(QWidget* parent, const QString& title, const QString& text,
|
bool question(QWidget* parent, const QString& title, const QString& text,
|
||||||
QMessageBox::StandardButtons buttons =
|
QMessageBox::StandardButtons buttons =
|
||||||
QMessageBox::StandardButtons(QMessageBox::Yes | QMessageBox::No),
|
QMessageBox::StandardButtons(QMessageBox::Yes | QMessageBox::No),
|
||||||
QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);
|
QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);
|
||||||
|
|
||||||
std::unique_ptr<Ui::MainWindow> ui;
|
std::unique_ptr<Ui::MainWindow> ui;
|
||||||
@@ -598,10 +605,10 @@ private:
|
|||||||
// True if TAS recording dialog is visible
|
// True if TAS recording dialog is visible
|
||||||
bool is_tas_recording_dialog_active{};
|
bool is_tas_recording_dialog_active{};
|
||||||
|
|
||||||
#ifdef __unix__
|
#ifdef __unix__
|
||||||
QSocketNotifier* sig_interrupt_notifier;
|
QSocketNotifier* sig_interrupt_notifier;
|
||||||
static std::array<int, 3> sig_interrupt_fds;
|
static std::array<int, 3> sig_interrupt_fds;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void dropEvent(QDropEvent* event) override;
|
void dropEvent(QDropEvent* event) override;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2018 Citra Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2018 Citra Emulator Project
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@@ -15,7 +16,7 @@ class DirectConnectWindow;
|
|||||||
class ClickableLabel;
|
class ClickableLabel;
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
class System;
|
class System;
|
||||||
}
|
}
|
||||||
|
|
||||||
class MultiplayerState : public QWidget {
|
class MultiplayerState : public QWidget {
|
||||||
@@ -33,6 +34,13 @@ public:
|
|||||||
QAction* show_room, Core::System& system_);
|
QAction* show_room, Core::System& system_);
|
||||||
~MultiplayerState();
|
~MultiplayerState();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the new function to safely access the multiplayer session.
|
||||||
|
*/
|
||||||
|
std::shared_ptr<Core::AnnounceMultiplayerSession> GetSession() {
|
||||||
|
return announce_multiplayer_session;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close all open multiplayer related dialogs
|
* Close all open multiplayer related dialogs
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user