From 81446df89063ec41ee07044569c07f574c114828 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Wed, 26 Jul 2023 19:15:15 +0200 Subject: [PATCH] early-access version 3779 --- README.md | 2 +- src/common/logging/backend.cpp | 2 +- src/common/settings.cpp | 3 -- src/common/settings.h | 9 ++-- src/common/settings_common.cpp | 3 ++ src/yuzu/discord_impl.cpp | 82 +++++++++++++++++++--------------- src/yuzu/discord_impl.h | 7 +++ src/yuzu/uisettings.h | 29 +++++++++--- 8 files changed, 86 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index 8c4fc39f3..200a882d4 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 3778. +This is the source code for early-access 3779. ## Legal Notice diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index dc73c0b14..158007a7d 100755 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp @@ -108,7 +108,7 @@ public: using namespace Common::Literals; // Prevent logs from exceeding a set maximum size in the event that log entries are spammed. - const auto write_limit = Settings::values.extended_logging ? 1_GiB : 100_MiB; + const auto write_limit = Settings::values.extended_logging.GetValue() ? 1_GiB : 100_MiB; const bool write_limit_exceeded = bytes_written > write_limit; if (entry.log_level >= Level::Error || write_limit_exceeded) { if (write_limit_exceeded) { diff --git a/src/common/settings.cpp b/src/common/settings.cpp index f22c75a24..bb9610d6e 100755 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -152,9 +152,6 @@ float Volume() { return values.volume.GetValue() / static_cast(values.volume.GetDefault()); } -Linkage::Linkage(u32 initial_count) : count{initial_count} {} -Linkage::~Linkage() = default; - const char* TranslateCategory(Category category) { switch (category) { case Category::Audio: diff --git a/src/common/settings.h b/src/common/settings.h index 5d3cb7605..d1943a700 100755 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -134,9 +134,10 @@ struct Values { Specialization::RuntimeList}; Setting audio_input_device_id{linkage, "auto", "input_device", Category::Audio, Specialization::RuntimeList}; - SwitchableSetting sound_index{linkage, AudioMode::Stereo, - AudioMode::Mono, AudioMode::Surround, - "sound_index", Category::SystemAudio}; + SwitchableSetting sound_index{ + linkage, AudioMode::Stereo, AudioMode::Mono, AudioMode::Surround, + "sound_index", Category::SystemAudio, Specialization::Default, true, + true}; SwitchableSetting volume{linkage, 100, 0, @@ -147,7 +148,7 @@ struct Values { true, true}; Setting audio_muted{ - linkage, false, "audio_muted", Category::Audio, Specialization::Default, false}; + linkage, false, "audio_muted", Category::Audio, Specialization::Default, false, true}; Setting dump_audio_commands{ linkage, false, "dump_audio_commands", Category::Audio, Specialization::Default, false}; diff --git a/src/common/settings_common.cpp b/src/common/settings_common.cpp index 90842e797..dedf5ef90 100755 --- a/src/common/settings_common.cpp +++ b/src/common/settings_common.cpp @@ -52,4 +52,7 @@ const std::string& BasicSetting::GetLabel() const { return label; } +Linkage::Linkage(u32 initial_count) : count{initial_count} {} +Linkage::~Linkage() = default; + } // namespace Settings diff --git a/src/yuzu/discord_impl.cpp b/src/yuzu/discord_impl.cpp index 2e1a33123..ddb7e007c 100755 --- a/src/yuzu/discord_impl.cpp +++ b/src/yuzu/discord_impl.cpp @@ -3,9 +3,14 @@ #include #include + +#include +#include +#include + #include #include -#include + #include "common/common_types.h" #include "common/string_util.h" #include "core/core.h" @@ -31,7 +36,7 @@ void DiscordImpl::Pause() { Discord_ClearPresence(); } -static std::string GetGameString(const std::string& title) { +std::string DiscordImpl::GetGameString(const std::string& title) { // Convert to lowercase std::string icon_name = Common::ToLower(title); @@ -56,51 +61,56 @@ static std::string GetGameString(const std::string& title) { return icon_name; } -void DiscordImpl::Update() { +void DiscordImpl::UpdateGameStatus(bool use_default) { + const std::string default_text = "yuzu is an emulator for the Nintendo Switch"; + const std::string default_image = "yuzu_logo_ea"; + const std::string url = use_default ? default_image : game_url; s64 start_time = std::chrono::duration_cast( std::chrono::system_clock::now().time_since_epoch()) .count(); - const std::string default_text = "yuzu is an emulator for the Nintendo Switch"; - const std::string default_image = "yuzu_logo_ea"; - std::string game_cover_url = "https://yuzu-emu.org"; - std::string title; - DiscordRichPresence presence{}; + presence.largeImageKey = url.c_str(); + presence.largeImageText = game_title.c_str(); + presence.smallImageKey = default_image.c_str(); + presence.smallImageText = default_text.c_str(); + presence.state = game_title.c_str(); + presence.details = "Currently in game"; + presence.startTimestamp = start_time; + Discord_UpdatePresence(&presence); +} + +void DiscordImpl::Update() { + const std::string default_text = "yuzu is an emulator for the Nintendo Switch"; + const std::string default_image = "yuzu_logo_ea"; + if (system.IsPoweredOn()) { - system.GetAppLoader().ReadTitle(title); + system.GetAppLoader().ReadTitle(game_title); // Used to format Icon URL for yuzu website game compatibility page - std::string icon_name = GetGameString(title); + std::string icon_name = GetGameString(game_title); + game_url = fmt::format("https://yuzu-emu.org/images/game/boxart/{}.png", icon_name); - // New Check for game cover - httplib::Client cli(game_cover_url); - cli.set_connection_timeout(std::chrono::seconds(3)); - cli.set_read_timeout(std::chrono::seconds(3)); - - if (auto res = cli.Head(fmt::format("/images/game/boxart/{}.png", icon_name))) { - if (res->status == 200) { - game_cover_url += fmt::format("/images/game/boxart/{}.png", icon_name); - } else { - game_cover_url = "yuzu_logo_ea"; - } - } else { - game_cover_url = "yuzu_logo_ea"; - } - - presence.largeImageKey = game_cover_url.c_str(); - presence.largeImageText = title.c_str(); - - presence.smallImageKey = default_image.c_str(); - presence.smallImageText = default_text.c_str(); - presence.state = title.c_str(); - presence.details = "Currently in game"; - } else { - presence.largeImageKey = default_image.c_str(); - presence.largeImageText = default_text.c_str(); - presence.details = "Currently not in game"; + QNetworkAccessManager manager; + QNetworkRequest request; + request.setUrl(QUrl(QString::fromStdString(game_url))); + request.setTransferTimeout(3000); + QNetworkReply* reply = manager.head(request); + QEventLoop request_event_loop; + QObject::connect(reply, &QNetworkReply::finished, &request_event_loop, &QEventLoop::quit); + request_event_loop.exec(); + UpdateGameStatus(reply->error()); + return; } + s64 start_time = std::chrono::duration_cast( + std::chrono::system_clock::now().time_since_epoch()) + .count(); + + DiscordRichPresence presence{}; + presence.largeImageKey = default_image.c_str(); + presence.largeImageText = default_text.c_str(); + presence.details = "Currently not in game"; presence.startTimestamp = start_time; Discord_UpdatePresence(&presence); } diff --git a/src/yuzu/discord_impl.h b/src/yuzu/discord_impl.h index deb14b7b6..ff1c8dc10 100755 --- a/src/yuzu/discord_impl.h +++ b/src/yuzu/discord_impl.h @@ -19,6 +19,13 @@ public: void Pause() override; void Update() override; +private: + std::string GetGameString(const std::string& title); + void UpdateGameStatus(bool use_default); + + std::string game_url{}; + std::string game_title{}; + Core::System& system; }; diff --git a/src/yuzu/uisettings.h b/src/yuzu/uisettings.h index 671c64a1f..ee1b17abb 100755 --- a/src/yuzu/uisettings.h +++ b/src/yuzu/uisettings.h @@ -90,18 +90,35 @@ struct Values { Setting show_filter_bar{linkage, true, "showFilterBar", Category::Ui}; Setting show_status_bar{linkage, true, "showStatusBar", Category::Ui}; - Setting confirm_before_closing{linkage, true, "confirmClose", Category::UiGeneral}; + Setting confirm_before_closing{ + linkage, true, "confirmClose", Category::UiGeneral, Settings::Specialization::Default, + true, true}; Setting first_start{linkage, true, "firstStart", Category::Ui}; - Setting pause_when_in_background{linkage, false, "pauseWhenInBackground", - Category::UiGeneral}; - Setting mute_when_in_background{linkage, false, "muteWhenInBackground", Category::Ui}; - Setting hide_mouse{linkage, true, "hideInactiveMouse", Category::UiGeneral}; + Setting pause_when_in_background{linkage, + false, + "pauseWhenInBackground", + Category::UiGeneral, + Settings::Specialization::Default, + true, + true}; + Setting mute_when_in_background{ + linkage, false, "muteWhenInBackground", Category::Ui, Settings::Specialization::Default, + true, true}; + Setting hide_mouse{ + linkage, true, "hideInactiveMouse", Category::UiGeneral, Settings::Specialization::Default, + true, true}; Setting controller_applet_disabled{linkage, false, "disableControllerApplet", Category::UiGeneral}; // Set when Vulkan is known to crash the application bool has_broken_vulkan = false; - Setting select_user_on_boot{linkage, false, "select_user_on_boot", Category::UiGeneral}; + Setting select_user_on_boot{linkage, + false, + "select_user_on_boot", + Category::UiGeneral, + Settings::Specialization::Default, + true, + true}; Setting disable_web_applet{linkage, true, "disable_web_applet", Category::Ui}; // Discord RPC