From 065059f75ce999dbc95d81c1c90cc8eb3194911d Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Sat, 11 Jun 2022 22:06:59 +0200 Subject: [PATCH] early-access version 2773 --- README.md | 2 +- src/yuzu/CMakeLists.txt | 1 + src/yuzu/game_list.cpp | 14 +++++++++++- src/yuzu/game_list.h | 3 +++ src/yuzu/main.cpp | 47 ++++++++++++++++++++++++++++++++++++++--- 5 files changed, 62 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6c2b6d401..4f3834d3a 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 2770. +This is the source code for early-access 2773. ## Legal Notice diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt index 9259ca15e..242867a4f 100755 --- a/src/yuzu/CMakeLists.txt +++ b/src/yuzu/CMakeLists.txt @@ -244,6 +244,7 @@ elseif(WIN32) target_link_libraries(yuzu PRIVATE Qt5::WinMain) endif() if(MSVC) + target_link_libraries(yuzu PRIVATE version.lib) set_target_properties(yuzu PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS") elseif(MINGW) set_target_properties(yuzu PROPERTIES LINK_FLAGS_RELEASE "-Wl,--subsystem,windows") diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp index d13530a5b..6321afc83 100755 --- a/src/yuzu/game_list.cpp +++ b/src/yuzu/game_list.cpp @@ -870,7 +870,7 @@ GameListPlaceholder::GameListPlaceholder(GMainWindow* parent) : QWidget{parent} layout->setAlignment(Qt::AlignCenter); image->setPixmap(QIcon::fromTheme(QStringLiteral("plus_folder")).pixmap(200)); - text->setText(tr("Double-click to add a new folder to the game list")); + RetranslateUI(); QFont font = text->font(); font.setPointSize(20); text->setFont(font); @@ -891,3 +891,15 @@ void GameListPlaceholder::onUpdateThemedIcons() { void GameListPlaceholder::mouseDoubleClickEvent(QMouseEvent* event) { emit GameListPlaceholder::AddDirectory(); } + +void GameListPlaceholder::changeEvent(QEvent* event) { + if (event->type() == QEvent::LanguageChange) { + RetranslateUI(); + } + + QWidget::changeEvent(event); +} + +void GameListPlaceholder::RetranslateUI() { + text->setText(tr("Double-click to add a new folder to the game list")); +} diff --git a/src/yuzu/game_list.h b/src/yuzu/game_list.h index d19dbe4b0..464da98ad 100755 --- a/src/yuzu/game_list.h +++ b/src/yuzu/game_list.h @@ -166,6 +166,9 @@ protected: void mouseDoubleClickEvent(QMouseEvent* event) override; private: + void changeEvent(QEvent* event) override; + void RetranslateUI(); + QVBoxLayout* layout = nullptr; QLabel* image = nullptr; QLabel* text = nullptr; diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 4d7634184..27f23bcb0 100755 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -52,7 +52,6 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual #define QT_NO_OPENGL #include #include -#include #include #include #include @@ -60,6 +59,7 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual #include #include #include +#include #include #include #include @@ -199,6 +199,34 @@ static void RemoveCachedContents() { Common::FS::RemoveDirRecursively(offline_system_data); } +static void LogRuntimes() { +#ifdef _MSC_VER + // It is possible that the name of the dll will change. + // vcruntime140.dll is for 2015 and onwards + constexpr char runtime_dll_name[] = "vcruntime140.dll"; + UINT sz = GetFileVersionInfoSizeA(runtime_dll_name, nullptr); + bool runtime_version_inspection_worked = false; + if (sz > 0) { + std::vector buf(sz); + if (GetFileVersionInfoA(runtime_dll_name, 0, sz, buf.data())) { + VS_FIXEDFILEINFO* pvi; + sz = sizeof(VS_FIXEDFILEINFO); + if (VerQueryValueA(buf.data(), "\\", reinterpret_cast(&pvi), &sz)) { + if (pvi->dwSignature == VS_FFI_SIGNATURE) { + runtime_version_inspection_worked = true; + LOG_INFO(Frontend, "MSVC Compiler: {} Runtime: {}.{}.{}.{}", _MSC_VER, + pvi->dwProductVersionMS >> 16, pvi->dwProductVersionMS & 0xFFFF, + pvi->dwProductVersionLS >> 16, pvi->dwProductVersionLS & 0xFFFF); + } + } + } + } + if (!runtime_version_inspection_worked) { + LOG_INFO(Frontend, "Unable to inspect {}", runtime_dll_name); + } +#endif +} + static QString PrettyProductName() { #ifdef _WIN32 // After Windows 10 Version 2004, Microsoft decided to switch to a different notation: 20H2 @@ -269,6 +297,7 @@ GMainWindow::GMainWindow() const auto yuzu_build_version = override_build.empty() ? yuzu_build : override_build; LOG_INFO(Frontend, "yuzu Version: {}", yuzu_build_version); + LogRuntimes(); #ifdef ARCHITECTURE_x86_64 const auto& caps = Common::GetCPUCaps(); std::string cpu_string = caps.cpu_string; @@ -1044,7 +1073,7 @@ void GMainWindow::InitializeHotkeys() { void GMainWindow::SetDefaultUIGeometry() { // geometry: 53% of the window contents are in the upper screen half, 47% in the lower half - const QRect screenRect = QApplication::desktop()->screenGeometry(this); + const QRect screenRect = QGuiApplication::primaryScreen()->geometry(); const int w = screenRect.width() * 2 / 3; const int h = screenRect.height() * 2 / 3; @@ -2627,6 +2656,18 @@ void GMainWindow::ToggleFullscreen() { } } +// We're going to return the screen that the given window has the most pixels on +static QScreen* GuessCurrentScreen(QWidget* window) { + const QList screens = QGuiApplication::screens(); + return *std::max_element( + screens.cbegin(), screens.cend(), [window](const QScreen* left, const QScreen* right) { + const QSize left_size = left->geometry().intersected(window->geometry()).size(); + const QSize right_size = right->geometry().intersected(window->geometry()).size(); + return (left_size.height() * left_size.width()) < + (right_size.height() * right_size.width()); + }); +} + void GMainWindow::ShowFullscreen() { const auto show_fullscreen = [](QWidget* window) { if (Settings::values.fullscreen_mode.GetValue() == Settings::FullscreenMode::Exclusive) { @@ -2635,7 +2676,7 @@ void GMainWindow::ShowFullscreen() { } window->hide(); window->setWindowFlags(window->windowFlags() | Qt::FramelessWindowHint); - const auto screen_geometry = QApplication::desktop()->screenGeometry(window); + const auto screen_geometry = GuessCurrentScreen(window)->geometry(); window->setGeometry(screen_geometry.x(), screen_geometry.y(), screen_geometry.width(), screen_geometry.height() + 1); window->raise();