aboutsummaryrefslogtreecommitdiff
path: root/src/frontend
diff options
context:
space:
mode:
authorAdrian Siekierka <kontakt@asie.pl>2021-10-02 20:16:27 +0200
committerGitHub <noreply@github.com>2021-10-02 20:16:27 +0200
commitd378b0252f0f8ea7a97889e35320a49b9192affc (patch)
tree90b378c11ba35cc37d26cb75c919264e5704e018 /src/frontend
parentb92622b765c6a94d050aaa16b6b30d59325fe495 (diff)
Generate a simple non-bootable firmware when not provided. (v2) (#1175)
* Generate a simple non-bootable firmware when not provided. * Expose Username and Language into settings dialog. * Add firmware overrides for more settings. Also make override optionals when a firmware is provided. * Refactor firmware settings into separate dialog. * use usernameLength instead of u16Username.length() (#3) * Fix curly braces code-style. * LoadUserSettingsFromConfig: convert from UTF-8 to UTF-16 via wstring_convert * Fix firmware username capitalization. * cleanup firmware backup logic * Put brace where it should be Co-authored-by: Rayyan Ansari <68647953+RayyanAnsari@users.noreply.github.com> Co-authored-by: Filippo Scognamiglio <flscogna@gmail.com> Co-authored-by: kyandora <71771686+kyandora@users.noreply.github.com> Co-authored-by: Filippo Scognamiglio <filippo.scognamiglio@felgo.com> Co-authored-by: RSDuck <RSDuck@users.noreply.github.com> Co-authored-by: Rayyan Ansari <68647953+RayyanAnsari@users.noreply.github.com>
Diffstat (limited to 'src/frontend')
-rw-r--r--src/frontend/Util_ROM.cpp2
-rw-r--r--src/frontend/qt_sdl/CMakeLists.txt1
-rw-r--r--src/frontend/qt_sdl/EmuSettingsDialog.cpp2
-rw-r--r--src/frontend/qt_sdl/FirmwareSettingsDialog.cpp72
-rw-r--r--src/frontend/qt_sdl/FirmwareSettingsDialog.h92
-rw-r--r--src/frontend/qt_sdl/FirmwareSettingsDialog.ui144
-rw-r--r--src/frontend/qt_sdl/main.cpp12
-rw-r--r--src/frontend/qt_sdl/main.h3
8 files changed, 327 insertions, 1 deletions
diff --git a/src/frontend/Util_ROM.cpp b/src/frontend/Util_ROM.cpp
index 4d55299..29247e4 100644
--- a/src/frontend/Util_ROM.cpp
+++ b/src/frontend/Util_ROM.cpp
@@ -165,7 +165,7 @@ int VerifyDSFirmware()
long len;
f = Platform::OpenLocalFile(Config::FirmwarePath, "rb");
- if (!f) return Load_FirmwareMissing;
+ if (!f) return Load_FirmwareNotBootable;
fseek(f, 0, SEEK_END);
len = ftell(f);
diff --git a/src/frontend/qt_sdl/CMakeLists.txt b/src/frontend/qt_sdl/CMakeLists.txt
index 61a2d20..cb81049 100644
--- a/src/frontend/qt_sdl/CMakeLists.txt
+++ b/src/frontend/qt_sdl/CMakeLists.txt
@@ -10,6 +10,7 @@ SET(SOURCES_QT_SDL
InputConfig/resources/ds.qrc
VideoSettingsDialog.cpp
AudioSettingsDialog.cpp
+ FirmwareSettingsDialog.cpp
WifiSettingsDialog.cpp
InterfaceSettingsDialog.cpp
ROMInfoDialog.cpp
diff --git a/src/frontend/qt_sdl/EmuSettingsDialog.cpp b/src/frontend/qt_sdl/EmuSettingsDialog.cpp
index b7de274..31e2e52 100644
--- a/src/frontend/qt_sdl/EmuSettingsDialog.cpp
+++ b/src/frontend/qt_sdl/EmuSettingsDialog.cpp
@@ -19,6 +19,8 @@
#include <stdio.h>
#include <QFileDialog>
#include <QMessageBox>
+#include <QList>
+#include <QDateEdit>
#include "types.h"
#include "Platform.h"
diff --git a/src/frontend/qt_sdl/FirmwareSettingsDialog.cpp b/src/frontend/qt_sdl/FirmwareSettingsDialog.cpp
new file mode 100644
index 0000000..7857cdc
--- /dev/null
+++ b/src/frontend/qt_sdl/FirmwareSettingsDialog.cpp
@@ -0,0 +1,72 @@
+/*
+ Copyright 2016-2020 Arisotura
+
+ This file is part of melonDS.
+
+ melonDS is free software: you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or (at your option)
+ any later version.
+
+ melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with melonDS. If not, see http://www.gnu.org/licenses/.
+*/
+
+#include "Config.h"
+#include "FirmwareSettingsDialog.h"
+#include "ui_FirmwareSettingsDialog.h"
+
+FirmwareSettingsDialog* FirmwareSettingsDialog::currentDlg = nullptr;
+
+FirmwareSettingsDialog::FirmwareSettingsDialog(QWidget* parent) : QDialog(parent), ui(new Ui::FirmwareSettingsDialog)
+{
+ ui->setupUi(this);
+ setAttribute(Qt::WA_DeleteOnClose);
+
+ ui->usernameEdit->setText(Config::FirmwareUsername);
+
+ ui->languageBox->addItems(languages);
+ ui->languageBox->setCurrentIndex(Config::FirmwareLanguage);
+
+ QDate birthDate = QDate(QDate::currentDate().year(), Config::FirmwareBirthdayMonth, Config::FirmwareBirthdayDay);
+ ui->birthdayEdit->setDate(birthDate);
+
+ ui->colorsEdit->addItems(colours);
+ ui->colorsEdit->setCurrentIndex(Config::FirmwareFavouriteColour);
+
+ ui->messageEdit->setText(Config::FirmwareMessage);
+
+ ui->overrideFirmwareBox->setChecked(Config::FirmwareOverrideSettings);
+}
+
+FirmwareSettingsDialog::~FirmwareSettingsDialog()
+{
+ delete ui;
+}
+
+void FirmwareSettingsDialog::on_dialogButtons_accepted()
+{
+ std::string newName = ui->usernameEdit->text().toStdString();
+ strncpy(Config::FirmwareUsername, newName.c_str(), 63); Config::FirmwareUsername[63] = '\0';
+
+ Config::FirmwareLanguage = ui->languageBox->currentIndex();
+ Config::FirmwareFavouriteColour = ui->colorsEdit->currentIndex();
+ Config::FirmwareBirthdayDay = ui->birthdayEdit->date().day();
+ Config::FirmwareBirthdayMonth = ui->birthdayEdit->date().month();
+ Config::FirmwareOverrideSettings = ui->overrideFirmwareBox->isChecked();
+
+ std::string newMessage = ui->messageEdit->text().toStdString();
+ strncpy(Config::FirmwareMessage, newMessage.c_str(), 1023); Config::FirmwareMessage[1023] = '\0';
+ Config::Save();
+
+ closeDlg();
+}
+
+void FirmwareSettingsDialog::on_dialogButtons_rejected()
+{
+ closeDlg();
+}
diff --git a/src/frontend/qt_sdl/FirmwareSettingsDialog.h b/src/frontend/qt_sdl/FirmwareSettingsDialog.h
new file mode 100644
index 0000000..5f8e5ff
--- /dev/null
+++ b/src/frontend/qt_sdl/FirmwareSettingsDialog.h
@@ -0,0 +1,92 @@
+/*
+ Copyright 2016-2020 Arisotura
+
+ This file is part of melonDS.
+
+ melonDS is free software: you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or (at your option)
+ any later version.
+
+ melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with melonDS. If not, see http://www.gnu.org/licenses/.
+*/
+
+#ifndef FIRMWARESETTINGSDIALOG_H
+#define FIRMWARESETTINGSDIALOG_H
+
+#include <QDialog>
+#include <QWidget>
+
+namespace Ui { class FirmwareSettingsDialog; }
+class FirmwareSettingsDialog;
+
+class FirmwareSettingsDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ const QStringList colours
+ {
+ "Greyish Blue",
+ "Brown",
+ "Red",
+ "Light Pink",
+ "Orange",
+ "Yellow",
+ "Lime",
+ "Light Green",
+ "Dark Green",
+ "Turqoise",
+ "Light Blue",
+ "Blue",
+ "Dark Blue",
+ "Dark Purple",
+ "Light Purple",
+ "Dark Pink"
+ };
+
+ const QStringList languages
+ {
+ "Japanese",
+ "English",
+ "French",
+ "German",
+ "Italian",
+ "Spanish"
+ };
+
+ explicit FirmwareSettingsDialog(QWidget* parent);
+ ~FirmwareSettingsDialog();
+
+ static FirmwareSettingsDialog* currentDlg;
+ static FirmwareSettingsDialog* openDlg(QWidget* parent)
+ {
+ if (currentDlg)
+ {
+ currentDlg->activateWindow();
+ return currentDlg;
+ }
+
+ currentDlg = new FirmwareSettingsDialog(parent);
+ currentDlg->show();
+ return currentDlg;
+ }
+ static void closeDlg()
+ {
+ currentDlg = nullptr;
+ }
+
+private slots:
+ void on_dialogButtons_accepted();
+ void on_dialogButtons_rejected();
+
+private:
+ Ui::FirmwareSettingsDialog* ui;
+};
+
+#endif // FIRMWARESETTINGSDIALOG_H
diff --git a/src/frontend/qt_sdl/FirmwareSettingsDialog.ui b/src/frontend/qt_sdl/FirmwareSettingsDialog.ui
new file mode 100644
index 0000000..2e27946
--- /dev/null
+++ b/src/frontend/qt_sdl/FirmwareSettingsDialog.ui
@@ -0,0 +1,144 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>FirmwareSettingsDialog</class>
+ <widget class="QDialog" name="FirmwareSettingsDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>511</width>
+ <height>272</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="windowTitle">
+ <string>Firmware settings - melonDS</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <property name="sizeConstraint">
+ <enum>QLayout::SetFixedSize</enum>
+ </property>
+ <item>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="usernameLabel">
+ <property name="text">
+ <string>Username</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="usernameEdit">
+ <property name="text">
+ <string>MelonDS</string>
+ </property>
+ <property name="maxLength">
+ <number>10</number>
+ </property>
+ <property name="clearButtonEnabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Language</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QComboBox" name="languageBox"/>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>Birthday</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QDateEdit" name="birthdayEdit"/>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Color</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QComboBox" name="colorsEdit"/>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Message</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QLineEdit" name="messageEdit"/>
+ </item>
+ <item row="5" column="0" colspan="2">
+ <widget class="QCheckBox" name="overrideFirmwareBox">
+ <property name="text">
+ <string>Override firmware settings</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="dialogButtons">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>dialogButtons</sender>
+ <signal>accepted()</signal>
+ <receiver>FirmwareSettingsDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>255</x>
+ <y>250</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>255</x>
+ <y>135</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>dialogButtons</sender>
+ <signal>rejected()</signal>
+ <receiver>FirmwareSettingsDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>255</x>
+ <y>250</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>255</x>
+ <y>135</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/src/frontend/qt_sdl/main.cpp b/src/frontend/qt_sdl/main.cpp
index d6acc91..fb1caea 100644
--- a/src/frontend/qt_sdl/main.cpp
+++ b/src/frontend/qt_sdl/main.cpp
@@ -55,6 +55,7 @@
#include "InputConfig/InputConfigDialog.h"
#include "VideoSettingsDialog.h"
#include "AudioSettingsDialog.h"
+#include "FirmwareSettingsDialog.h"
#include "WifiSettingsDialog.h"
#include "InterfaceSettingsDialog.h"
#include "ROMInfoDialog.h"
@@ -1411,6 +1412,9 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
actInterfaceSettings = menu->addAction("Interface settings");
connect(actInterfaceSettings, &QAction::triggered, this, &MainWindow::onOpenInterfaceSettings);
+ actFirmwareSettings = menu->addAction("Firmware settings");
+ connect(actFirmwareSettings, &QAction::triggered, this, &MainWindow::onOpenFirmwareSettings);
+
{
QMenu* submenu = menu->addMenu("Savestate settings");
@@ -2446,6 +2450,14 @@ void MainWindow::onOpenAudioSettings()
connect(dlg, &AudioSettingsDialog::finished, this, &MainWindow::onAudioSettingsFinished);
}
+void MainWindow::onOpenFirmwareSettings()
+{
+ FirmwareSettingsDialog* dlg = FirmwareSettingsDialog::openDlg(this);
+ connect(dlg, &FirmwareSettingsDialog::finished, this, &MainWindow::onFirmwareSettingsFinished);
+}
+
+void MainWindow::onFirmwareSettingsFinished(int res) {}
+
void MainWindow::onUpdateAudioSettings()
{
SPU::SetInterpolation(Config::AudioInterp);
diff --git a/src/frontend/qt_sdl/main.h b/src/frontend/qt_sdl/main.h
index 1378417..0f9034f 100644
--- a/src/frontend/qt_sdl/main.h
+++ b/src/frontend/qt_sdl/main.h
@@ -256,10 +256,12 @@ private slots:
void onInputConfigFinished(int res);
void onOpenVideoSettings();
void onOpenAudioSettings();
+ void onOpenFirmwareSettings();
void onUpdateAudioSettings();
void onAudioSettingsFinished(int res);
void onOpenWifiSettings();
void onWifiSettingsFinished(int res);
+ void onFirmwareSettingsFinished(int res);
void onOpenInterfaceSettings();
void onInterfaceSettingsFinished(int res);
void onUpdateMouseTimer();
@@ -331,6 +333,7 @@ public:
QAction* actVideoSettings;
QAction* actAudioSettings;
QAction* actWifiSettings;
+ QAction* actFirmwareSettings;
QAction* actInterfaceSettings;
QAction* actSavestateSRAMReloc;
QAction* actScreenSize[4];