forked from eden-emu/eden
[common] Better approach to enabling and disabling the Web Applet (#2729)
This implements a better approach to enabling and disabling the Web Applet, whether compiled or not. Reviewed-on: eden-emu/eden#2729 Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Co-authored-by: MaranBr <maranbr@outlook.com> Co-committed-by: MaranBr <maranbr@outlook.com>
This commit is contained in:
parent
8ae7cfe96a
commit
053f4e95d4
5 changed files with 53 additions and 50 deletions
|
@ -735,6 +735,7 @@ struct Values {
|
|||
Setting<bool> enable_all_controllers{linkage, false, "enable_all_controllers",
|
||||
Category::Debugging};
|
||||
Setting<bool> perform_vulkan_check{linkage, true, "perform_vulkan_check", Category::Debugging};
|
||||
Setting<bool> disable_web_applet{linkage, true, "disable_web_applet", Category::Debugging};
|
||||
|
||||
// Miscellaneous
|
||||
Setting<std::string> log_filter{linkage, "*:Info", "log_filter", Category::Miscellaneous};
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "common/fs/fs.h"
|
||||
#include "common/fs/path_util.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "common/settings.h"
|
||||
#include "common/string_util.h"
|
||||
#include "core/core.h"
|
||||
#include "core/file_sys/content_archive.h"
|
||||
|
@ -71,6 +72,42 @@ std::string ResolveURL(const std::string& url) {
|
|||
return url.substr(0, index) + "lp1" + url.substr(index + 1);
|
||||
}
|
||||
|
||||
WebArgInputTLVMap ReadWebArgs(const std::vector<u8>& web_arg, WebArgHeader& web_arg_header) {
|
||||
std::memcpy(&web_arg_header, web_arg.data(), sizeof(WebArgHeader));
|
||||
|
||||
if (web_arg.size() == sizeof(WebArgHeader)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
WebArgInputTLVMap input_tlv_map;
|
||||
|
||||
u64 current_offset = sizeof(WebArgHeader);
|
||||
|
||||
for (std::size_t i = 0; i < web_arg_header.total_tlv_entries; ++i) {
|
||||
if (web_arg.size() < current_offset + sizeof(WebArgInputTLV)) {
|
||||
return input_tlv_map;
|
||||
}
|
||||
|
||||
WebArgInputTLV input_tlv;
|
||||
std::memcpy(&input_tlv, web_arg.data() + current_offset, sizeof(WebArgInputTLV));
|
||||
|
||||
current_offset += sizeof(WebArgInputTLV);
|
||||
|
||||
if (web_arg.size() < current_offset + input_tlv.arg_data_size) {
|
||||
return input_tlv_map;
|
||||
}
|
||||
|
||||
std::vector<u8> data(input_tlv.arg_data_size);
|
||||
std::memcpy(data.data(), web_arg.data() + current_offset, input_tlv.arg_data_size);
|
||||
|
||||
current_offset += input_tlv.arg_data_size;
|
||||
|
||||
input_tlv_map.insert_or_assign(input_tlv.input_tlv_type, std::move(data));
|
||||
}
|
||||
|
||||
return input_tlv_map;
|
||||
}
|
||||
|
||||
FileSys::VirtualFile GetOfflineRomFS(Core::System& system, u64 title_id,
|
||||
FileSys::ContentRecordType nca_type) {
|
||||
if (nca_type == FileSys::ContentRecordType::Data) {
|
||||
|
@ -111,43 +148,6 @@ FileSys::VirtualFile GetOfflineRomFS(Core::System& system, u64 title_id,
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef YUZU_USE_QT_WEB_ENGINE
|
||||
WebArgInputTLVMap ReadWebArgs(const std::vector<u8>& web_arg, WebArgHeader& web_arg_header) {
|
||||
std::memcpy(&web_arg_header, web_arg.data(), sizeof(WebArgHeader));
|
||||
|
||||
if (web_arg.size() == sizeof(WebArgHeader)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
WebArgInputTLVMap input_tlv_map;
|
||||
|
||||
u64 current_offset = sizeof(WebArgHeader);
|
||||
|
||||
for (std::size_t i = 0; i < web_arg_header.total_tlv_entries; ++i) {
|
||||
if (web_arg.size() < current_offset + sizeof(WebArgInputTLV)) {
|
||||
return input_tlv_map;
|
||||
}
|
||||
|
||||
WebArgInputTLV input_tlv;
|
||||
std::memcpy(&input_tlv, web_arg.data() + current_offset, sizeof(WebArgInputTLV));
|
||||
|
||||
current_offset += sizeof(WebArgInputTLV);
|
||||
|
||||
if (web_arg.size() < current_offset + input_tlv.arg_data_size) {
|
||||
return input_tlv_map;
|
||||
}
|
||||
|
||||
std::vector<u8> data(input_tlv.arg_data_size);
|
||||
std::memcpy(data.data(), web_arg.data() + current_offset, input_tlv.arg_data_size);
|
||||
|
||||
current_offset += input_tlv.arg_data_size;
|
||||
|
||||
input_tlv_map.insert_or_assign(input_tlv.input_tlv_type, std::move(data));
|
||||
}
|
||||
|
||||
return input_tlv_map;
|
||||
}
|
||||
|
||||
void ExtractSharedFonts(Core::System& system) {
|
||||
static constexpr std::array<const char*, 7> DECRYPTED_SHARED_FONTS{
|
||||
"FontStandard.ttf",
|
||||
|
@ -225,7 +225,6 @@ void ExtractSharedFonts(Core::System& system) {
|
|||
FileSys::VfsRawCopy(decrypted_font, out_file);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
|
||||
|
@ -237,7 +236,11 @@ WebBrowser::WebBrowser(Core::System& system_, std::shared_ptr<Applet> applet_,
|
|||
WebBrowser::~WebBrowser() = default;
|
||||
|
||||
void WebBrowser::Initialize() {
|
||||
#ifdef YUZU_USE_QT_WEB_ENGINE
|
||||
if (Settings::values.disable_web_applet) {
|
||||
LOG_INFO(Service_AM, "Web Browser Applet disabled, skipping.");
|
||||
return;
|
||||
}
|
||||
|
||||
FrontendApplet::Initialize();
|
||||
|
||||
LOG_INFO(Service_AM, "Initializing Web Browser Applet.");
|
||||
|
@ -290,7 +293,6 @@ void WebBrowser::Initialize() {
|
|||
ASSERT_MSG(false, "Invalid ShimKind={}", web_arg_header.shim_kind);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Result WebBrowser::GetStatus() const {
|
||||
|
@ -302,7 +304,11 @@ void WebBrowser::ExecuteInteractive() {
|
|||
}
|
||||
|
||||
void WebBrowser::Execute() {
|
||||
#ifdef YUZU_USE_QT_WEB_ENGINE
|
||||
if (Settings::values.disable_web_applet) {
|
||||
WebBrowserExit(WebExitReason::EndButtonPressed);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (web_arg_header.shim_kind) {
|
||||
case ShimKind::Shop:
|
||||
ExecuteShop();
|
||||
|
@ -330,10 +336,6 @@ void WebBrowser::Execute() {
|
|||
WebBrowserExit(WebExitReason::EndButtonPressed);
|
||||
break;
|
||||
}
|
||||
#else
|
||||
LOG_INFO(Service_AM, "Web Browser Applet disabled, skipping.");
|
||||
WebBrowserExit(WebExitReason::EndButtonPressed);
|
||||
#endif
|
||||
}
|
||||
|
||||
void WebBrowser::ExtractOfflineRomFS() {
|
||||
|
|
|
@ -139,7 +139,7 @@ struct Values {
|
|||
Settings::Specialization::Default,
|
||||
true,
|
||||
true};
|
||||
Setting<bool> disable_web_applet{linkage, true, "disable_web_applet", Category::Ui};
|
||||
|
||||
Setting<bool> check_for_updates{linkage, true, "check_for_updates", Category::UiGeneral};
|
||||
|
||||
// Discord RPC
|
||||
|
|
|
@ -81,7 +81,7 @@ void ConfigureDebug::SetConfiguration() {
|
|||
ui->perform_vulkan_check->setChecked(Settings::values.perform_vulkan_check.GetValue());
|
||||
|
||||
#ifdef YUZU_USE_QT_WEB_ENGINE
|
||||
ui->disable_web_applet->setChecked(UISettings::values.disable_web_applet.GetValue());
|
||||
ui->disable_web_applet->setChecked(Settings::values.disable_web_applet.GetValue());
|
||||
#else
|
||||
ui->disable_web_applet->setVisible(false);
|
||||
#endif
|
||||
|
@ -116,7 +116,7 @@ void ConfigureDebug::ApplyConfiguration() {
|
|||
Settings::values.disable_macro_hle = ui->disable_macro_hle->isChecked();
|
||||
Settings::values.extended_logging = ui->extended_logging->isChecked();
|
||||
Settings::values.perform_vulkan_check = ui->perform_vulkan_check->isChecked();
|
||||
UISettings::values.disable_web_applet = ui->disable_web_applet->isChecked();
|
||||
Settings::values.disable_web_applet = ui->disable_web_applet->isChecked();
|
||||
Debugger::ToggleConsole();
|
||||
Common::Log::Filter filter;
|
||||
filter.ParseFilterString(Settings::values.log_filter.GetValue());
|
||||
|
|
|
@ -934,7 +934,7 @@ void GMainWindow::WebBrowserOpenWebPage(const std::string& main_url,
|
|||
#ifdef YUZU_USE_QT_WEB_ENGINE
|
||||
|
||||
// Raw input breaks with the web applet, Disable web applets if enabled
|
||||
if (UISettings::values.disable_web_applet || Settings::values.enable_raw_input) {
|
||||
if (Settings::values.disable_web_applet || Settings::values.enable_raw_input) {
|
||||
emit WebBrowserClosed(Service::AM::Frontend::WebExitReason::WindowClosed,
|
||||
"http://localhost/");
|
||||
return;
|
||||
|
@ -1007,7 +1007,7 @@ void GMainWindow::WebBrowserOpenWebPage(const std::string& main_url,
|
|||
"applet?\n(This can be re-enabled in the Debug settings.)"),
|
||||
QMessageBox::Yes | QMessageBox::No);
|
||||
if (result == QMessageBox::Yes) {
|
||||
UISettings::values.disable_web_applet = true;
|
||||
Settings::values.disable_web_applet = true;
|
||||
web_applet->SetFinished(true);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue