configure_debug.cpp 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // Copyright 2016 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include <QDesktopServices>
  5. #include <QUrl>
  6. #include "common/fs/path_util.h"
  7. #include "common/logging/backend.h"
  8. #include "common/logging/filter.h"
  9. #include "common/settings.h"
  10. #include "core/core.h"
  11. #include "ui_configure_debug.h"
  12. #include "yuzu/configuration/configure_debug.h"
  13. #include "yuzu/debugger/console.h"
  14. #include "yuzu/uisettings.h"
  15. ConfigureDebug::ConfigureDebug(const Core::System& system_, QWidget* parent)
  16. : QWidget(parent), ui{std::make_unique<Ui::ConfigureDebug>()}, system{system_} {
  17. ui->setupUi(this);
  18. SetConfiguration();
  19. connect(ui->open_log_button, &QPushButton::clicked, []() {
  20. const auto path =
  21. QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::LogDir));
  22. QDesktopServices::openUrl(QUrl::fromLocalFile(path));
  23. });
  24. }
  25. ConfigureDebug::~ConfigureDebug() = default;
  26. void ConfigureDebug::SetConfiguration() {
  27. const bool runtime_lock = !system.IsPoweredOn();
  28. ui->toggle_console->setEnabled(runtime_lock);
  29. ui->toggle_console->setChecked(UISettings::values.show_console.GetValue());
  30. ui->log_filter_edit->setText(QString::fromStdString(Settings::values.log_filter.GetValue()));
  31. ui->homebrew_args_edit->setText(
  32. QString::fromStdString(Settings::values.program_args.GetValue()));
  33. ui->fs_access_log->setEnabled(runtime_lock);
  34. ui->fs_access_log->setChecked(Settings::values.enable_fs_access_log.GetValue());
  35. ui->reporting_services->setChecked(Settings::values.reporting_services.GetValue());
  36. ui->quest_flag->setChecked(Settings::values.quest_flag.GetValue());
  37. ui->use_debug_asserts->setChecked(Settings::values.use_debug_asserts.GetValue());
  38. ui->use_auto_stub->setChecked(Settings::values.use_auto_stub.GetValue());
  39. ui->enable_all_controllers->setChecked(Settings::values.enable_all_controllers.GetValue());
  40. ui->enable_graphics_debugging->setEnabled(runtime_lock);
  41. ui->enable_graphics_debugging->setChecked(Settings::values.renderer_debug.GetValue());
  42. ui->enable_shader_feedback->setEnabled(runtime_lock);
  43. ui->enable_shader_feedback->setChecked(Settings::values.renderer_shader_feedback.GetValue());
  44. ui->enable_cpu_debugging->setEnabled(runtime_lock);
  45. ui->enable_cpu_debugging->setChecked(Settings::values.cpu_debug_mode.GetValue());
  46. ui->enable_nsight_aftermath->setEnabled(runtime_lock);
  47. ui->enable_nsight_aftermath->setChecked(Settings::values.enable_nsight_aftermath.GetValue());
  48. ui->dump_shaders->setEnabled(runtime_lock);
  49. ui->dump_shaders->setChecked(Settings::values.dump_shaders.GetValue());
  50. ui->disable_macro_jit->setEnabled(runtime_lock);
  51. ui->disable_macro_jit->setChecked(Settings::values.disable_macro_jit.GetValue());
  52. ui->disable_loop_safety_checks->setEnabled(runtime_lock);
  53. ui->disable_loop_safety_checks->setChecked(
  54. Settings::values.disable_shader_loop_safety_checks.GetValue());
  55. ui->extended_logging->setChecked(Settings::values.extended_logging.GetValue());
  56. }
  57. void ConfigureDebug::ApplyConfiguration() {
  58. UISettings::values.show_console = ui->toggle_console->isChecked();
  59. Settings::values.log_filter = ui->log_filter_edit->text().toStdString();
  60. Settings::values.program_args = ui->homebrew_args_edit->text().toStdString();
  61. Settings::values.enable_fs_access_log = ui->fs_access_log->isChecked();
  62. Settings::values.reporting_services = ui->reporting_services->isChecked();
  63. Settings::values.quest_flag = ui->quest_flag->isChecked();
  64. Settings::values.use_debug_asserts = ui->use_debug_asserts->isChecked();
  65. Settings::values.use_auto_stub = ui->use_auto_stub->isChecked();
  66. Settings::values.enable_all_controllers = ui->enable_all_controllers->isChecked();
  67. Settings::values.renderer_debug = ui->enable_graphics_debugging->isChecked();
  68. Settings::values.renderer_shader_feedback = ui->enable_shader_feedback->isChecked();
  69. Settings::values.cpu_debug_mode = ui->enable_cpu_debugging->isChecked();
  70. Settings::values.enable_nsight_aftermath = ui->enable_nsight_aftermath->isChecked();
  71. Settings::values.dump_shaders = ui->dump_shaders->isChecked();
  72. Settings::values.disable_shader_loop_safety_checks =
  73. ui->disable_loop_safety_checks->isChecked();
  74. Settings::values.disable_macro_jit = ui->disable_macro_jit->isChecked();
  75. Settings::values.extended_logging = ui->extended_logging->isChecked();
  76. Debugger::ToggleConsole();
  77. Common::Log::Filter filter;
  78. filter.ParseFilterString(Settings::values.log_filter.GetValue());
  79. Common::Log::SetGlobalFilter(filter);
  80. }
  81. void ConfigureDebug::changeEvent(QEvent* event) {
  82. if (event->type() == QEvent::LanguageChange) {
  83. RetranslateUI();
  84. }
  85. QWidget::changeEvent(event);
  86. }
  87. void ConfigureDebug::RetranslateUI() {
  88. ui->retranslateUi(this);
  89. }