configure_system.cpp 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // Copyright 2016 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include <QMessageBox>
  5. #include "core/core.h"
  6. #include "ui_configure_system.h"
  7. #include "yuzu/configuration/configure_system.h"
  8. #include "yuzu/ui_settings.h"
  9. static const std::array<int, 12> days_in_month = {{
  10. 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
  11. }};
  12. ConfigureSystem::ConfigureSystem(QWidget* parent) : QWidget(parent), ui(new Ui::ConfigureSystem) {
  13. ui->setupUi(this);
  14. connect(ui->combo_birthmonth,
  15. static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
  16. &ConfigureSystem::updateBirthdayComboBox);
  17. connect(ui->button_regenerate_console_id, &QPushButton::clicked, this,
  18. &ConfigureSystem::refreshConsoleID);
  19. this->setConfiguration();
  20. }
  21. ConfigureSystem::~ConfigureSystem() {}
  22. void ConfigureSystem::setConfiguration() {
  23. enabled = !Core::System::GetInstance().IsPoweredOn();
  24. }
  25. void ConfigureSystem::ReadSystemSettings() {}
  26. void ConfigureSystem::applyConfiguration() {
  27. if (!enabled)
  28. return;
  29. }
  30. void ConfigureSystem::updateBirthdayComboBox(int birthmonth_index) {
  31. if (birthmonth_index < 0 || birthmonth_index >= 12)
  32. return;
  33. // store current day selection
  34. int birthday_index = ui->combo_birthday->currentIndex();
  35. // get number of days in the new selected month
  36. int days = days_in_month[birthmonth_index];
  37. // if the selected day is out of range,
  38. // reset it to 1st
  39. if (birthday_index < 0 || birthday_index >= days)
  40. birthday_index = 0;
  41. // update the day combo box
  42. ui->combo_birthday->clear();
  43. for (int i = 1; i <= days; ++i) {
  44. ui->combo_birthday->addItem(QString::number(i));
  45. }
  46. // restore the day selection
  47. ui->combo_birthday->setCurrentIndex(birthday_index);
  48. }
  49. void ConfigureSystem::refreshConsoleID() {
  50. QMessageBox::StandardButton reply;
  51. QString warning_text = tr("This will replace your current virtual Switch with a new one. "
  52. "Your current virtual Switch will not be recoverable. "
  53. "This might have unexpected effects in games. This might fail, "
  54. "if you use an outdated config savegame. Continue?");
  55. reply = QMessageBox::critical(this, tr("Warning"), warning_text,
  56. QMessageBox::No | QMessageBox::Yes);
  57. if (reply == QMessageBox::No)
  58. return;
  59. u64 console_id{};
  60. ui->label_console_id->setText("Console ID: 0x" + QString::number(console_id, 16).toUpper());
  61. }