mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2024-12-27 18:16:23 +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 int cursorHideTimeout = 5; // 5 seconds (default)
|
||||
static bool separateupdatefolder = false;
|
||||
static bool compatibilityData = false;
|
||||
static bool checkCompatibilityOnStartup = false;
|
||||
|
||||
// Gui
|
||||
std::vector<std::filesystem::path> settings_install_dirs = {};
|
||||
|
@ -224,6 +226,14 @@ bool getSeparateUpdateEnabled() {
|
|||
return separateupdatefolder;
|
||||
}
|
||||
|
||||
bool getCompatibilityEnabled() {
|
||||
return compatibilityData;
|
||||
}
|
||||
|
||||
bool getCheckCompatibilityOnStartup() {
|
||||
return checkCompatibilityOnStartup;
|
||||
}
|
||||
|
||||
void setGpuId(s32 selectedGpuId) {
|
||||
gpuId = selectedGpuId;
|
||||
}
|
||||
|
@ -344,6 +354,14 @@ void setSeparateUpdateEnabled(bool 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) {
|
||||
main_window_geometry_x = x;
|
||||
main_window_geometry_y = y;
|
||||
|
@ -544,6 +562,9 @@ void load(const std::filesystem::path& path) {
|
|||
isShowSplash = toml::find_or<bool>(general, "showSplash", true);
|
||||
isAutoUpdate = toml::find_or<bool>(general, "autoUpdate", 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")) {
|
||||
|
@ -656,6 +677,8 @@ void save(const std::filesystem::path& path) {
|
|||
data["General"]["showSplash"] = isShowSplash;
|
||||
data["General"]["autoUpdate"] = isAutoUpdate;
|
||||
data["General"]["separateUpdateEnabled"] = separateupdatefolder;
|
||||
data["General"]["compatibilityEnabled"] = compatibilityData;
|
||||
data["General"]["checkCompatibilityOnStartup"] = checkCompatibilityOnStartup;
|
||||
data["Input"]["cursorState"] = cursorState;
|
||||
data["Input"]["cursorHideTimeout"] = cursorHideTimeout;
|
||||
data["Input"]["backButtonBehavior"] = backButtonBehavior;
|
||||
|
@ -775,6 +798,8 @@ void setDefaultValues() {
|
|||
m_language = 1;
|
||||
gpuId = -1;
|
||||
separateupdatefolder = false;
|
||||
compatibilityData = false;
|
||||
checkCompatibilityOnStartup = false;
|
||||
}
|
||||
|
||||
} // namespace Config
|
||||
|
|
|
@ -21,6 +21,8 @@ bool getPlayBGM();
|
|||
int getBGMvolume();
|
||||
bool getEnableDiscordRPC();
|
||||
bool getSeparateUpdateEnabled();
|
||||
bool getCompatibilityEnabled();
|
||||
bool getCheckCompatibilityOnStartup();
|
||||
|
||||
std::string getLogFilter();
|
||||
std::string getLogType();
|
||||
|
@ -69,6 +71,8 @@ void setUserName(const std::string& type);
|
|||
void setUpdateChannel(const std::string& type);
|
||||
void setSeparateUpdateEnabled(bool use);
|
||||
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 setCursorHideTimeout(int newcursorHideTimeout);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <QFileInfo>
|
||||
#include <QMessageBox>
|
||||
#include <QProgressDialog>
|
||||
#include <QTimer>
|
||||
|
||||
#include "common/path_util.h"
|
||||
#include "compatibility_info.h"
|
||||
|
@ -22,7 +23,8 @@ void CompatibilityInfoClass::UpdateCompatibilityDatabase(QWidget* parent) {
|
|||
return;
|
||||
|
||||
QNetworkReply* reply = FetchPage(1);
|
||||
WaitForReply(reply);
|
||||
if (!WaitForReply(reply))
|
||||
return;
|
||||
|
||||
QProgressDialog dialog(tr("Fetching compatibility data, please wait"), tr("Cancel"), 0, 0,
|
||||
parent);
|
||||
|
@ -57,12 +59,17 @@ void CompatibilityInfoClass::UpdateCompatibilityDatabase(QWidget* parent) {
|
|||
}
|
||||
|
||||
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++) {
|
||||
if (replies[i]->bytesAvailable()) {
|
||||
if (replies[i]->error() == QNetworkReply::NoError) {
|
||||
ExtractCompatibilityInfo(replies[i]->readAll());
|
||||
}
|
||||
replies[i]->deleteLater();
|
||||
} else {
|
||||
// This means the request timed out
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
QFile compatibility_file(m_compatibility_filename);
|
||||
|
@ -83,6 +90,16 @@ void CompatibilityInfoClass::UpdateCompatibilityDatabase(QWidget* parent) {
|
|||
|
||||
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);
|
||||
dialog.setRange(0, remaining_pages);
|
||||
connect(&future_watcher, &QFutureWatcher<void>::progressValueChanged, &dialog,
|
||||
|
@ -105,20 +122,34 @@ QNetworkReply* CompatibilityInfoClass::FetchPage(int page_num) {
|
|||
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;
|
||||
connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
|
||||
connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
|
||||
timer.start(5000);
|
||||
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) {
|
||||
QString title_id = QString::fromStdString(serial);
|
||||
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++) {
|
||||
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)) {
|
||||
QJsonObject compatibility_entry_obj = compatibility_obj[os_string].toObject();
|
||||
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() {
|
||||
|
|
|
@ -57,6 +57,7 @@ class CompatibilityInfoClass : public QObject {
|
|||
public:
|
||||
// Please think of a better alternative
|
||||
inline static const std::unordered_map<QString, CompatibilityStatus> LabelToCompatStatus = {
|
||||
{QStringLiteral("status-unknown"), CompatibilityStatus::Unknown},
|
||||
{QStringLiteral("status-nothing"), CompatibilityStatus::Nothing},
|
||||
{QStringLiteral("status-boots"), CompatibilityStatus::Boots},
|
||||
{QStringLiteral("status-menus"), CompatibilityStatus::Menus},
|
||||
|
@ -87,7 +88,7 @@ public:
|
|||
bool LoadCompatibilityFile();
|
||||
CompatibilityEntry GetCompatibilityInfo(const std::string& serial);
|
||||
void ExtractCompatibilityInfo(QByteArray response);
|
||||
static void WaitForReply(QNetworkReply* reply);
|
||||
static bool WaitForReply(QNetworkReply* reply);
|
||||
QNetworkReply* FetchPage(int page_num);
|
||||
|
||||
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));
|
||||
}
|
||||
});
|
||||
|
||||
// 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,
|
||||
|
|
|
@ -185,7 +185,9 @@ void MainWindow::CreateDockWindows() {
|
|||
|
||||
void MainWindow::LoadGameLists() {
|
||||
// Update compatibility database
|
||||
if (Config::getCheckCompatibilityOnStartup()) {
|
||||
m_compat_info->UpdateCompatibilityDatabase(this);
|
||||
}
|
||||
// Get game info from game folders.
|
||||
m_game_info->GetGameInfo(this);
|
||||
if (isTableList) {
|
||||
|
|
Loading…
Reference in a new issue