forked from ShuriZma/suyu
1
0
Fork 0

Merge pull request #4063 from FreddyFunk/game-version-in-title

Add game version to window title
This commit is contained in:
bunnei 2020-06-30 21:42:33 -04:00 committed by GitHub
commit 424540d9e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 13 deletions

View File

@ -1081,17 +1081,19 @@ void GMainWindow::BootGame(const QString& filename) {
const u64 title_id = Core::System::GetInstance().CurrentProcess()->GetTitleID(); const u64 title_id = Core::System::GetInstance().CurrentProcess()->GetTitleID();
std::string title_name; std::string title_name;
std::string title_version;
const auto res = Core::System::GetInstance().GetGameName(title_name); const auto res = Core::System::GetInstance().GetGameName(title_name);
if (res != Loader::ResultStatus::Success) {
const auto metadata = FileSys::PatchManager(title_id).GetControlMetadata();
if (metadata.first != nullptr)
title_name = metadata.first->GetApplicationName();
if (title_name.empty()) const auto metadata = FileSys::PatchManager(title_id).GetControlMetadata();
title_name = FileUtil::GetFilename(filename.toStdString()); if (metadata.first != nullptr) {
title_version = metadata.first->GetVersionString();
title_name = metadata.first->GetApplicationName();
} }
LOG_INFO(Frontend, "Booting game: {:016X} | {}", title_id, title_name); if (res != Loader::ResultStatus::Success || title_name.empty()) {
UpdateWindowTitle(QString::fromStdString(title_name)); title_name = FileUtil::GetFilename(filename.toStdString());
}
LOG_INFO(Frontend, "Booting game: {:016X} | {} | {}", title_id, title_name, title_version);
UpdateWindowTitle(title_name, title_version);
loading_screen->Prepare(Core::System::GetInstance().GetAppLoader()); loading_screen->Prepare(Core::System::GetInstance().GetAppLoader());
loading_screen->show(); loading_screen->show();
@ -2064,7 +2066,8 @@ void GMainWindow::OnCaptureScreenshot() {
OnStartGame(); OnStartGame();
} }
void GMainWindow::UpdateWindowTitle(const QString& title_name) { void GMainWindow::UpdateWindowTitle(const std::string& title_name,
const std::string& title_version) {
const auto full_name = std::string(Common::g_build_fullname); const auto full_name = std::string(Common::g_build_fullname);
const auto branch_name = std::string(Common::g_scm_branch); const auto branch_name = std::string(Common::g_scm_branch);
const auto description = std::string(Common::g_scm_desc); const auto description = std::string(Common::g_scm_desc);
@ -2073,7 +2076,7 @@ void GMainWindow::UpdateWindowTitle(const QString& title_name) {
const auto date = const auto date =
QDateTime::currentDateTime().toString(QStringLiteral("yyyy-MM-dd")).toStdString(); QDateTime::currentDateTime().toString(QStringLiteral("yyyy-MM-dd")).toStdString();
if (title_name.isEmpty()) { if (title_name.empty()) {
const auto fmt = std::string(Common::g_title_bar_format_idle); const auto fmt = std::string(Common::g_title_bar_format_idle);
setWindowTitle(QString::fromStdString(fmt::format(fmt.empty() ? "yuzu {0}| {1}-{2}" : fmt, setWindowTitle(QString::fromStdString(fmt::format(fmt.empty() ? "yuzu {0}| {1}-{2}" : fmt,
full_name, branch_name, description, full_name, branch_name, description,
@ -2081,8 +2084,8 @@ void GMainWindow::UpdateWindowTitle(const QString& title_name) {
} else { } else {
const auto fmt = std::string(Common::g_title_bar_format_running); const auto fmt = std::string(Common::g_title_bar_format_running);
setWindowTitle(QString::fromStdString( setWindowTitle(QString::fromStdString(
fmt::format(fmt.empty() ? "yuzu {0}| {3} | {1}-{2}" : fmt, full_name, branch_name, fmt::format(fmt.empty() ? "yuzu {0}| {3} | {6} | {1}-{2}" : fmt, full_name, branch_name,
description, title_name.toStdString(), date, build_id))); description, title_name, date, build_id, title_version)));
} }
} }

View File

@ -218,7 +218,8 @@ private slots:
private: private:
std::optional<u64> SelectRomFSDumpTarget(const FileSys::ContentProvider&, u64 program_id); std::optional<u64> SelectRomFSDumpTarget(const FileSys::ContentProvider&, u64 program_id);
void UpdateWindowTitle(const QString& title_name = {}); void UpdateWindowTitle(const std::string& title_name = {},
const std::string& title_version = {});
void UpdateStatusBar(); void UpdateStatusBar();
void HideMouseCursor(); void HideMouseCursor();
void ShowMouseCursor(); void ShowMouseCursor();