mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2024-12-28 02:26:07 +00:00
compatibility_data: various fixes (#1847)
* temporarily disable status column + various fixes * add configuration option to enable compatibility data * clang format
This commit is contained in:
parent
fb2c035c05
commit
0931802151
|
@ -64,6 +64,8 @@ static bool vkCrashDiagnostic = false;
|
||||||
static s16 cursorState = HideCursorState::Idle;
|
static s16 cursorState = HideCursorState::Idle;
|
||||||
static int cursorHideTimeout = 5; // 5 seconds (default)
|
static int cursorHideTimeout = 5; // 5 seconds (default)
|
||||||
static bool separateupdatefolder = false;
|
static bool separateupdatefolder = false;
|
||||||
|
static bool compatibilityData = false;
|
||||||
|
static bool checkCompatibilityOnStartup = false;
|
||||||
|
|
||||||
// Gui
|
// Gui
|
||||||
std::vector<std::filesystem::path> settings_install_dirs = {};
|
std::vector<std::filesystem::path> settings_install_dirs = {};
|
||||||
|
@ -224,6 +226,14 @@ bool getSeparateUpdateEnabled() {
|
||||||
return separateupdatefolder;
|
return separateupdatefolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool getCompatibilityEnabled() {
|
||||||
|
return compatibilityData;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool getCheckCompatibilityOnStartup() {
|
||||||
|
return checkCompatibilityOnStartup;
|
||||||
|
}
|
||||||
|
|
||||||
void setGpuId(s32 selectedGpuId) {
|
void setGpuId(s32 selectedGpuId) {
|
||||||
gpuId = selectedGpuId;
|
gpuId = selectedGpuId;
|
||||||
}
|
}
|
||||||
|
@ -344,6 +354,14 @@ void setSeparateUpdateEnabled(bool use) {
|
||||||
separateupdatefolder = use;
|
separateupdatefolder = use;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setCompatibilityEnabled(bool use) {
|
||||||
|
compatibilityData = use;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setCheckCompatibilityOnStartup(bool use) {
|
||||||
|
checkCompatibilityOnStartup = use;
|
||||||
|
}
|
||||||
|
|
||||||
void setMainWindowGeometry(u32 x, u32 y, u32 w, u32 h) {
|
void setMainWindowGeometry(u32 x, u32 y, u32 w, u32 h) {
|
||||||
main_window_geometry_x = x;
|
main_window_geometry_x = x;
|
||||||
main_window_geometry_y = y;
|
main_window_geometry_y = y;
|
||||||
|
@ -544,6 +562,9 @@ void load(const std::filesystem::path& path) {
|
||||||
isShowSplash = toml::find_or<bool>(general, "showSplash", true);
|
isShowSplash = toml::find_or<bool>(general, "showSplash", true);
|
||||||
isAutoUpdate = toml::find_or<bool>(general, "autoUpdate", false);
|
isAutoUpdate = toml::find_or<bool>(general, "autoUpdate", false);
|
||||||
separateupdatefolder = toml::find_or<bool>(general, "separateUpdateEnabled", false);
|
separateupdatefolder = toml::find_or<bool>(general, "separateUpdateEnabled", false);
|
||||||
|
compatibilityData = toml::find_or<bool>(general, "compatibilityEnabled", false);
|
||||||
|
checkCompatibilityOnStartup =
|
||||||
|
toml::find_or<bool>(general, "checkCompatibilityOnStartup", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.contains("Input")) {
|
if (data.contains("Input")) {
|
||||||
|
@ -656,6 +677,8 @@ void save(const std::filesystem::path& path) {
|
||||||
data["General"]["showSplash"] = isShowSplash;
|
data["General"]["showSplash"] = isShowSplash;
|
||||||
data["General"]["autoUpdate"] = isAutoUpdate;
|
data["General"]["autoUpdate"] = isAutoUpdate;
|
||||||
data["General"]["separateUpdateEnabled"] = separateupdatefolder;
|
data["General"]["separateUpdateEnabled"] = separateupdatefolder;
|
||||||
|
data["General"]["compatibilityEnabled"] = compatibilityData;
|
||||||
|
data["General"]["checkCompatibilityOnStartup"] = checkCompatibilityOnStartup;
|
||||||
data["Input"]["cursorState"] = cursorState;
|
data["Input"]["cursorState"] = cursorState;
|
||||||
data["Input"]["cursorHideTimeout"] = cursorHideTimeout;
|
data["Input"]["cursorHideTimeout"] = cursorHideTimeout;
|
||||||
data["Input"]["backButtonBehavior"] = backButtonBehavior;
|
data["Input"]["backButtonBehavior"] = backButtonBehavior;
|
||||||
|
@ -775,6 +798,8 @@ void setDefaultValues() {
|
||||||
m_language = 1;
|
m_language = 1;
|
||||||
gpuId = -1;
|
gpuId = -1;
|
||||||
separateupdatefolder = false;
|
separateupdatefolder = false;
|
||||||
|
compatibilityData = false;
|
||||||
|
checkCompatibilityOnStartup = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Config
|
} // namespace Config
|
||||||
|
|
|
@ -21,6 +21,8 @@ bool getPlayBGM();
|
||||||
int getBGMvolume();
|
int getBGMvolume();
|
||||||
bool getEnableDiscordRPC();
|
bool getEnableDiscordRPC();
|
||||||
bool getSeparateUpdateEnabled();
|
bool getSeparateUpdateEnabled();
|
||||||
|
bool getCompatibilityEnabled();
|
||||||
|
bool getCheckCompatibilityOnStartup();
|
||||||
|
|
||||||
std::string getLogFilter();
|
std::string getLogFilter();
|
||||||
std::string getLogType();
|
std::string getLogType();
|
||||||
|
@ -69,6 +71,8 @@ void setUserName(const std::string& type);
|
||||||
void setUpdateChannel(const std::string& type);
|
void setUpdateChannel(const std::string& type);
|
||||||
void setSeparateUpdateEnabled(bool use);
|
void setSeparateUpdateEnabled(bool use);
|
||||||
void setGameInstallDirs(const std::vector<std::filesystem::path>& settings_install_dirs_config);
|
void setGameInstallDirs(const std::vector<std::filesystem::path>& settings_install_dirs_config);
|
||||||
|
void setCompatibilityEnabled(bool use);
|
||||||
|
void setCheckCompatibilityOnStartup(bool use);
|
||||||
|
|
||||||
void setCursorState(s16 cursorState);
|
void setCursorState(s16 cursorState);
|
||||||
void setCursorHideTimeout(int newcursorHideTimeout);
|
void setCursorHideTimeout(int newcursorHideTimeout);
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QProgressDialog>
|
#include <QProgressDialog>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
#include "common/path_util.h"
|
#include "common/path_util.h"
|
||||||
#include "compatibility_info.h"
|
#include "compatibility_info.h"
|
||||||
|
@ -22,7 +23,8 @@ void CompatibilityInfoClass::UpdateCompatibilityDatabase(QWidget* parent) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QNetworkReply* reply = FetchPage(1);
|
QNetworkReply* reply = FetchPage(1);
|
||||||
WaitForReply(reply);
|
if (!WaitForReply(reply))
|
||||||
|
return;
|
||||||
|
|
||||||
QProgressDialog dialog(tr("Fetching compatibility data, please wait"), tr("Cancel"), 0, 0,
|
QProgressDialog dialog(tr("Fetching compatibility data, please wait"), tr("Cancel"), 0, 0,
|
||||||
parent);
|
parent);
|
||||||
|
@ -57,12 +59,17 @@ void CompatibilityInfoClass::UpdateCompatibilityDatabase(QWidget* parent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
future_watcher.setFuture(QtConcurrent::map(replies, WaitForReply));
|
future_watcher.setFuture(QtConcurrent::map(replies, WaitForReply));
|
||||||
connect(&future_watcher, &QFutureWatcher<QByteArray>::finished, [&]() {
|
connect(&future_watcher, &QFutureWatcher<void>::finished, [&]() {
|
||||||
for (int i = 0; i < remaining_pages; i++) {
|
for (int i = 0; i < remaining_pages; i++) {
|
||||||
if (replies[i]->error() == QNetworkReply::NoError) {
|
if (replies[i]->bytesAvailable()) {
|
||||||
ExtractCompatibilityInfo(replies[i]->readAll());
|
if (replies[i]->error() == QNetworkReply::NoError) {
|
||||||
|
ExtractCompatibilityInfo(replies[i]->readAll());
|
||||||
|
}
|
||||||
|
replies[i]->deleteLater();
|
||||||
|
} else {
|
||||||
|
// This means the request timed out
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
replies[i]->deleteLater();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QFile compatibility_file(m_compatibility_filename);
|
QFile compatibility_file(m_compatibility_filename);
|
||||||
|
@ -83,6 +90,16 @@ void CompatibilityInfoClass::UpdateCompatibilityDatabase(QWidget* parent) {
|
||||||
|
|
||||||
dialog.reset();
|
dialog.reset();
|
||||||
});
|
});
|
||||||
|
connect(&future_watcher, &QFutureWatcher<void>::canceled, [&]() {
|
||||||
|
// Cleanup if user cancels pulling data
|
||||||
|
for (int i = 0; i < remaining_pages; i++) {
|
||||||
|
if (!replies[i]->bytesAvailable()) {
|
||||||
|
replies[i]->deleteLater();
|
||||||
|
} else if (!replies[i]->isFinished()) {
|
||||||
|
replies[i]->abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
connect(&dialog, &QProgressDialog::canceled, &future_watcher, &QFutureWatcher<void>::cancel);
|
connect(&dialog, &QProgressDialog::canceled, &future_watcher, &QFutureWatcher<void>::cancel);
|
||||||
dialog.setRange(0, remaining_pages);
|
dialog.setRange(0, remaining_pages);
|
||||||
connect(&future_watcher, &QFutureWatcher<void>::progressValueChanged, &dialog,
|
connect(&future_watcher, &QFutureWatcher<void>::progressValueChanged, &dialog,
|
||||||
|
@ -105,20 +122,34 @@ QNetworkReply* CompatibilityInfoClass::FetchPage(int page_num) {
|
||||||
return reply;
|
return reply;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompatibilityInfoClass::WaitForReply(QNetworkReply* reply) {
|
bool CompatibilityInfoClass::WaitForReply(QNetworkReply* reply) {
|
||||||
|
// Returns true if reply succeeded, false if reply timed out
|
||||||
|
QTimer timer;
|
||||||
|
timer.setSingleShot(true);
|
||||||
|
|
||||||
QEventLoop loop;
|
QEventLoop loop;
|
||||||
connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
|
connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
|
||||||
|
connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
|
||||||
|
timer.start(5000);
|
||||||
loop.exec();
|
loop.exec();
|
||||||
return;
|
|
||||||
|
if (timer.isActive()) {
|
||||||
|
timer.stop();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
disconnect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
|
||||||
|
reply->abort();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
CompatibilityEntry CompatibilityInfoClass::GetCompatibilityInfo(const std::string& serial) {
|
CompatibilityEntry CompatibilityInfoClass::GetCompatibilityInfo(const std::string& serial) {
|
||||||
QString title_id = QString::fromStdString(serial);
|
QString title_id = QString::fromStdString(serial);
|
||||||
if (m_compatibility_database.contains(title_id)) {
|
if (m_compatibility_database.contains(title_id)) {
|
||||||
{
|
{
|
||||||
|
QJsonObject compatibility_obj = m_compatibility_database[title_id].toObject();
|
||||||
for (int os_int = 0; os_int != static_cast<int>(OSType::Last); os_int++) {
|
for (int os_int = 0; os_int != static_cast<int>(OSType::Last); os_int++) {
|
||||||
QString os_string = OSTypeToString.at(static_cast<OSType>(os_int));
|
QString os_string = OSTypeToString.at(static_cast<OSType>(os_int));
|
||||||
QJsonObject compatibility_obj = m_compatibility_database[title_id].toObject();
|
|
||||||
if (compatibility_obj.contains(os_string)) {
|
if (compatibility_obj.contains(os_string)) {
|
||||||
QJsonObject compatibility_entry_obj = compatibility_obj[os_string].toObject();
|
QJsonObject compatibility_entry_obj = compatibility_obj[os_string].toObject();
|
||||||
CompatibilityEntry compatibility_entry{
|
CompatibilityEntry compatibility_entry{
|
||||||
|
@ -133,7 +164,9 @@ CompatibilityEntry CompatibilityInfoClass::GetCompatibilityInfo(const std::strin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return CompatibilityEntry{CompatibilityStatus::Unknown};
|
|
||||||
|
return CompatibilityEntry{CompatibilityStatus::Unknown, "", QDateTime::currentDateTime(), "",
|
||||||
|
0};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CompatibilityInfoClass::LoadCompatibilityFile() {
|
bool CompatibilityInfoClass::LoadCompatibilityFile() {
|
||||||
|
|
|
@ -57,6 +57,7 @@ class CompatibilityInfoClass : public QObject {
|
||||||
public:
|
public:
|
||||||
// Please think of a better alternative
|
// Please think of a better alternative
|
||||||
inline static const std::unordered_map<QString, CompatibilityStatus> LabelToCompatStatus = {
|
inline static const std::unordered_map<QString, CompatibilityStatus> LabelToCompatStatus = {
|
||||||
|
{QStringLiteral("status-unknown"), CompatibilityStatus::Unknown},
|
||||||
{QStringLiteral("status-nothing"), CompatibilityStatus::Nothing},
|
{QStringLiteral("status-nothing"), CompatibilityStatus::Nothing},
|
||||||
{QStringLiteral("status-boots"), CompatibilityStatus::Boots},
|
{QStringLiteral("status-boots"), CompatibilityStatus::Boots},
|
||||||
{QStringLiteral("status-menus"), CompatibilityStatus::Menus},
|
{QStringLiteral("status-menus"), CompatibilityStatus::Menus},
|
||||||
|
@ -87,7 +88,7 @@ public:
|
||||||
bool LoadCompatibilityFile();
|
bool LoadCompatibilityFile();
|
||||||
CompatibilityEntry GetCompatibilityInfo(const std::string& serial);
|
CompatibilityEntry GetCompatibilityInfo(const std::string& serial);
|
||||||
void ExtractCompatibilityInfo(QByteArray response);
|
void ExtractCompatibilityInfo(QByteArray response);
|
||||||
static void WaitForReply(QNetworkReply* reply);
|
static bool WaitForReply(QNetworkReply* reply);
|
||||||
QNetworkReply* FetchPage(int page_num);
|
QNetworkReply* FetchPage(int page_num);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -80,6 +80,11 @@ GameListFrame::GameListFrame(std::shared_ptr<GameInfoClass> game_info_get,
|
||||||
QDesktopServices::openUrl(QUrl(m_game_info->m_games[row].compatibility.url));
|
QDesktopServices::openUrl(QUrl(m_game_info->m_games[row].compatibility.url));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Do not show status column if it is not enabled
|
||||||
|
if (!Config::getCompatibilityEnabled()) {
|
||||||
|
this->setColumnHidden(2, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameListFrame::onCurrentCellChanged(int currentRow, int currentColumn, int previousRow,
|
void GameListFrame::onCurrentCellChanged(int currentRow, int currentColumn, int previousRow,
|
||||||
|
|
|
@ -185,7 +185,9 @@ void MainWindow::CreateDockWindows() {
|
||||||
|
|
||||||
void MainWindow::LoadGameLists() {
|
void MainWindow::LoadGameLists() {
|
||||||
// Update compatibility database
|
// Update compatibility database
|
||||||
m_compat_info->UpdateCompatibilityDatabase(this);
|
if (Config::getCheckCompatibilityOnStartup()) {
|
||||||
|
m_compat_info->UpdateCompatibilityDatabase(this);
|
||||||
|
}
|
||||||
// Get game info from game folders.
|
// Get game info from game folders.
|
||||||
m_game_info->GetGameInfo(this);
|
m_game_info->GetGameInfo(this);
|
||||||
if (isTableList) {
|
if (isTableList) {
|
||||||
|
|
Loading…
Reference in a new issue