Add UI and accessors for Rescaling profiles
This commit is contained in:
committed by
FernandoS27
parent
f3777b5697
commit
a9f741ac6e
@@ -19,6 +19,10 @@ namespace VideoCommon::Resolution {
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
std::string GetBaseDir() {
|
||||
return FileUtil::GetUserPath(FileUtil::UserPath::RescalingDir);
|
||||
}
|
||||
|
||||
ScalingDatabase::ScalingDatabase(Core::System& system) : database{}, blacklist{}, system{system} {
|
||||
title_id = 0;
|
||||
}
|
||||
@@ -63,6 +67,11 @@ void ScalingDatabase::LoadDatabase() {
|
||||
}
|
||||
|
||||
void ScalingDatabase::SaveDatabase() {
|
||||
std::string dir = GetBaseDir();
|
||||
if (!FileUtil::CreateDir(dir)) {
|
||||
LOG_ERROR(HW_GPU, "Failed to create directory={}", dir);
|
||||
return;
|
||||
}
|
||||
json out;
|
||||
out["version"] = DBVersion;
|
||||
auto entries = json::array();
|
||||
@@ -102,10 +111,6 @@ void ScalingDatabase::Unregister(const PixelFormat format, const u32 width, cons
|
||||
blacklist.insert(key);
|
||||
}
|
||||
|
||||
std::string GetBaseDir() {
|
||||
return FileUtil::GetUserPath(FileUtil::UserPath::RescalingDir);
|
||||
}
|
||||
|
||||
std::string ScalingDatabase::GetTitleID() const {
|
||||
return fmt::format("{:016X}", title_id);
|
||||
}
|
||||
|
||||
@@ -471,6 +471,7 @@ void GameList::AddGamePopup(QMenu& context_menu, u64 program_id, std::string pat
|
||||
QAction* open_lfs_location = context_menu.addAction(tr("Open Mod Data Location"));
|
||||
QAction* open_transferable_shader_cache =
|
||||
context_menu.addAction(tr("Open Transferable Shader Cache"));
|
||||
QAction* open_rescaling_profile_cache = context_menu.addAction(tr("Open Rescaling Profile"));
|
||||
context_menu.addSeparator();
|
||||
QAction* dump_romfs = context_menu.addAction(tr("Dump RomFS"));
|
||||
QAction* copy_tid = context_menu.addAction(tr("Copy Title ID to Clipboard"));
|
||||
@@ -490,6 +491,8 @@ void GameList::AddGamePopup(QMenu& context_menu, u64 program_id, std::string pat
|
||||
});
|
||||
connect(open_transferable_shader_cache, &QAction::triggered,
|
||||
[this, program_id]() { emit OpenTransferableShaderCacheRequested(program_id); });
|
||||
connect(open_rescaling_profile_cache, &QAction::triggered,
|
||||
[&]() { emit OpenResolutionProfileRequested(program_id); });
|
||||
connect(dump_romfs, &QAction::triggered,
|
||||
[this, program_id, path]() { emit DumpRomFSRequested(program_id, path); });
|
||||
connect(copy_tid, &QAction::triggered,
|
||||
|
||||
@@ -75,6 +75,7 @@ signals:
|
||||
void ShouldCancelWorker();
|
||||
void OpenFolderRequested(u64 program_id, GameListOpenTarget target);
|
||||
void OpenTransferableShaderCacheRequested(u64 program_id);
|
||||
void OpenResolutionProfileRequested(u64 program_id);
|
||||
void DumpRomFSRequested(u64 program_id, const std::string& game_path);
|
||||
void CopyTIDRequested(u64 program_id);
|
||||
void NavigateToGamedbEntryRequested(u64 program_id,
|
||||
|
||||
@@ -681,6 +681,8 @@ void GMainWindow::ConnectWidgetEvents() {
|
||||
connect(game_list, &GameList::OpenFolderRequested, this, &GMainWindow::OnGameListOpenFolder);
|
||||
connect(game_list, &GameList::OpenTransferableShaderCacheRequested, this,
|
||||
&GMainWindow::OnTransferableShaderCacheOpenFile);
|
||||
connect(game_list, &GameList::OpenResolutionProfileRequested, this,
|
||||
&GMainWindow::OnResolutionProfileOpenFile);
|
||||
connect(game_list, &GameList::DumpRomFSRequested, this, &GMainWindow::OnGameListDumpRomFS);
|
||||
connect(game_list, &GameList::CopyTIDRequested, this, &GMainWindow::OnGameListCopyTID);
|
||||
connect(game_list, &GameList::NavigateToGamedbEntryRequested, this,
|
||||
@@ -1180,6 +1182,36 @@ void GMainWindow::OnTransferableShaderCacheOpenFile(u64 program_id) {
|
||||
#endif
|
||||
}
|
||||
|
||||
void GMainWindow::OnResolutionProfileOpenFile(u64 program_id) {
|
||||
ASSERT(program_id != 0);
|
||||
|
||||
const QString rescaling_dir =
|
||||
QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::RescalingDir));
|
||||
const QString rescaling_profile_file_path =
|
||||
rescaling_dir + QString::fromStdString(fmt::format("{:016X}.json", program_id));
|
||||
|
||||
if (!QFile::exists(rescaling_profile_file_path)) {
|
||||
QMessageBox::warning(this, tr("Error Opening Rescaling Profile"),
|
||||
tr("A rescaling profile for this title does not exist."));
|
||||
return;
|
||||
}
|
||||
|
||||
// Windows supports opening a folder with selecting a specified file in explorer. On every other
|
||||
// OS we just open the transferable shader cache folder without preselecting the transferable
|
||||
// shader cache file for the selected game.
|
||||
#if defined(Q_OS_WIN)
|
||||
const QString explorer = QStringLiteral("explorer");
|
||||
QStringList param;
|
||||
if (!QFileInfo(rescaling_profile_file_path).isDir()) {
|
||||
param << QStringLiteral("/select,");
|
||||
}
|
||||
param << QDir::toNativeSeparators(rescaling_profile_file_path);
|
||||
QProcess::startDetached(explorer, param);
|
||||
#else
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(rescaling_dir));
|
||||
#endif
|
||||
}
|
||||
|
||||
static std::size_t CalculateRomFSEntrySize(const FileSys::VirtualDir& dir, bool full) {
|
||||
std::size_t out = 0;
|
||||
|
||||
|
||||
@@ -185,6 +185,7 @@ private slots:
|
||||
void OnGameListLoadFile(QString game_path);
|
||||
void OnGameListOpenFolder(u64 program_id, GameListOpenTarget target);
|
||||
void OnTransferableShaderCacheOpenFile(u64 program_id);
|
||||
void OnResolutionProfileOpenFile(u64 program_id);
|
||||
void OnGameListDumpRomFS(u64 program_id, const std::string& game_path);
|
||||
void OnGameListCopyTID(u64 program_id);
|
||||
void OnGameListNavigateToGamedbEntry(u64 program_id,
|
||||
|
||||
Reference in New Issue
Block a user