From e3af341d5b077436d2d40d94ade8bc457bc05eb8 Mon Sep 17 00:00:00 2001 From: CaptV0rt3x Date: Wed, 29 Aug 2018 17:03:55 +0530 Subject: [PATCH 1/2] Better Title Bar Display --- src/common/CMakeLists.txt | 24 +++++++++++++++++++----- src/common/scm_rev.cpp.in | 4 ++++ src/common/scm_rev.h | 2 ++ src/yuzu/about_dialog.cpp | 2 +- src/yuzu/main.cpp | 4 ++-- 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index d9424ea91..f41946cc6 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -1,13 +1,16 @@ # Generate cpp with Git revision from template -# Also if this is a CI build, add the build name (ie: Nightly, Bleeding Edge) to the scm_rev file as well +# Also if this is a CI build, add the build name (ie: Nightly, Canary) to the scm_rev file as well set(REPO_NAME "") +set(BUILD_VERSION "0") if ($ENV{CI}) if ($ENV{TRAVIS}) set(BUILD_REPOSITORY $ENV{TRAVIS_REPO_SLUG}) + set(BUILD_TAG $ENV{TRAVIS_TAG}) elseif($ENV{APPVEYOR}) set(BUILD_REPOSITORY $ENV{APPVEYOR_REPO_NAME}) + set(BUILD_TAG $ENV{APPVEYOR_REPO_TAG_NAME}) endif() - # regex capture the string nightly or bleeding-edge into CMAKE_MATCH_1 + # regex capture the string nightly or canary into CMAKE_MATCH_1 string(REGEX MATCH "yuzu-emu/yuzu-?(.*)" OUTVAR ${BUILD_REPOSITORY}) if (${CMAKE_MATCH_COUNT} GREATER 0) # capitalize the first letter of each word in the repo name. @@ -16,10 +19,21 @@ if ($ENV{CI}) string(SUBSTRING ${WORD} 0 1 FIRST_LETTER) string(SUBSTRING ${WORD} 1 -1 REMAINDER) string(TOUPPER ${FIRST_LETTER} FIRST_LETTER) - # this leaves a trailing space on the last word, but we actually want that - # because of how it's styled in the title bar. - set(REPO_NAME "${REPO_NAME}${FIRST_LETTER}${REMAINDER} ") + set(REPO_NAME "${REPO_NAME}${FIRST_LETTER}${REMAINDER}") endforeach() + if (BUILD_TAG) + string(REGEX MATCH "${CMAKE_MATCH_1}-([0-9]+)" OUTVAR ${BUILD_TAG}) + if (${CMAKE_MATCH_COUNT} GREATER 0) + set(BUILD_VERSION ${CMAKE_MATCH_1}) + endif() + if (BUILD_VERSION) + # This leaves a trailing space on the last word, but we actually want that + # because of how it's styled in the title bar. + set(BUILD_FULLNAME "${REPO_NAME} #${BUILD_VERSION} ") + else() + set(BUILD_FULLNAME "") + endif() + endif() endif() endif() configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scm_rev.cpp.in" "${CMAKE_CURRENT_SOURCE_DIR}/scm_rev.cpp" @ONLY) diff --git a/src/common/scm_rev.cpp.in b/src/common/scm_rev.cpp.in index 4083095d5..2b1727769 100644 --- a/src/common/scm_rev.cpp.in +++ b/src/common/scm_rev.cpp.in @@ -9,6 +9,8 @@ #define GIT_DESC "@GIT_DESC@" #define BUILD_NAME "@REPO_NAME@" #define BUILD_DATE "@BUILD_DATE@" +#define BUILD_FULLNAME "@BUILD_FULLNAME@" +#define BUILD_VERSION "@BUILD_VERSION@" namespace Common { @@ -17,6 +19,8 @@ const char g_scm_branch[] = GIT_BRANCH; const char g_scm_desc[] = GIT_DESC; const char g_build_name[] = BUILD_NAME; const char g_build_date[] = BUILD_DATE; +const char g_build_fullname[] = BUILD_FULLNAME; +const char g_build_version[] = BUILD_VERSION; } // namespace diff --git a/src/common/scm_rev.h b/src/common/scm_rev.h index db0f4a947..af9a9daed 100644 --- a/src/common/scm_rev.h +++ b/src/common/scm_rev.h @@ -11,5 +11,7 @@ extern const char g_scm_branch[]; extern const char g_scm_desc[]; extern const char g_build_name[]; extern const char g_build_date[]; +extern const char g_build_fullname[]; +extern const char g_build_version[]; } // namespace Common diff --git a/src/yuzu/about_dialog.cpp b/src/yuzu/about_dialog.cpp index a81ad2888..3efa65a38 100644 --- a/src/yuzu/about_dialog.cpp +++ b/src/yuzu/about_dialog.cpp @@ -11,7 +11,7 @@ AboutDialog::AboutDialog(QWidget* parent) : QDialog(parent), ui(new Ui::AboutDia ui->setupUi(this); ui->labelLogo->setPixmap(QIcon::fromTheme("yuzu").pixmap(200)); ui->labelBuildInfo->setText( - ui->labelBuildInfo->text().arg(Common::g_build_name, Common::g_scm_branch, + ui->labelBuildInfo->text().arg(Common::g_build_fullname, Common::g_scm_branch, Common::g_scm_desc, QString(Common::g_build_date).left(10))); } diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index dbe5bd8a4..cb8135c42 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -136,11 +136,11 @@ GMainWindow::GMainWindow() ConnectMenuEvents(); ConnectWidgetEvents(); - LOG_INFO(Frontend, "yuzu Version: {} | {}-{}", Common::g_build_name, Common::g_scm_branch, + LOG_INFO(Frontend, "yuzu Version: {} | {}-{}", Common::g_build_fullname, Common::g_scm_branch, Common::g_scm_desc); setWindowTitle(QString("yuzu %1| %2-%3") - .arg(Common::g_build_name, Common::g_scm_branch, Common::g_scm_desc)); + .arg(Common::g_build_fullname, Common::g_scm_branch, Common::g_scm_desc)); show(); // Necessary to load titles from nand in gamelist. From 9382414b2036751f98d8e65a25f00517d9f46436 Mon Sep 17 00:00:00 2001 From: CaptV0rt3x Date: Wed, 29 Aug 2018 17:31:32 +0530 Subject: [PATCH 2/2] For SDL Frontend --- src/yuzu_cmd/emu_window/emu_window_sdl2.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp index e1f269d31..c87e96b2d 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp +++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp @@ -128,7 +128,7 @@ EmuWindow_SDL2::EmuWindow_SDL2(bool fullscreen) { SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0); - std::string window_title = fmt::format("yuzu {} | {}-{}", Common::g_build_name, + std::string window_title = fmt::format("yuzu {} | {}-{}", Common::g_build_fullname, Common::g_scm_branch, Common::g_scm_desc); render_window = SDL_CreateWindow(window_title.c_str(), @@ -167,7 +167,7 @@ EmuWindow_SDL2::EmuWindow_SDL2(bool fullscreen) { OnMinimalClientAreaChangeRequest(GetActiveConfig().min_client_area_size); SDL_PumpEvents(); SDL_GL_SetSwapInterval(false); - LOG_INFO(Frontend, "yuzu Version: {} | {}-{}", Common::g_build_name, Common::g_scm_branch, + LOG_INFO(Frontend, "yuzu Version: {} | {}-{}", Common::g_build_fullname, Common::g_scm_branch, Common::g_scm_desc); DoneCurrent();