From f8658d8d93b66bb17db0cd0a844d57be90f9819a Mon Sep 17 00:00:00 2001 From: Rosalie Wanders Date: Sun, 1 Nov 2020 20:34:26 +0100 Subject: [PATCH] more work for settings window --- Source/RMG/M64P/Wrapper/Core.cpp | 7 +- .../UserInterface/Dialog/SettingsDialog.cpp | 18 +- .../UserInterface/Dialog/SettingsDialog.ui | 195 ++++++++++++++---- Source/RMG/UserInterface/MainWindow.cpp | 10 +- 4 files changed, 190 insertions(+), 40 deletions(-) diff --git a/Source/RMG/M64P/Wrapper/Core.cpp b/Source/RMG/M64P/Wrapper/Core.cpp index 6e173b89..6e5bcf65 100644 --- a/Source/RMG/M64P/Wrapper/Core.cpp +++ b/Source/RMG/M64P/Wrapper/Core.cpp @@ -239,10 +239,11 @@ bool Core::SetPlugin(Plugin_t plugin) bool Core::GetRomInfo(QString file, RomInfo_t *info) { m64p_error ret; + bool inEmulation = this->emulation_IsRunning() || this->emulation_IsPaused(); - if (!this->rom_Open(file)) + if (!inEmulation && !this->rom_Open(file)) return false; - + ret = M64P::Core.DoCommand(M64CMD_ROM_GET_HEADER, sizeof(m64p_rom_header), &info->Header); if (ret != M64ERR_SUCCESS) { @@ -263,7 +264,7 @@ bool Core::GetRomInfo(QString file, RomInfo_t *info) info->FileName = file; - if (!this->rom_Close()) + if (!inEmulation && !this->rom_Close()) return false; return true; diff --git a/Source/RMG/UserInterface/Dialog/SettingsDialog.cpp b/Source/RMG/UserInterface/Dialog/SettingsDialog.cpp index 08a49079..a20f3fba 100644 --- a/Source/RMG/UserInterface/Dialog/SettingsDialog.cpp +++ b/Source/RMG/UserInterface/Dialog/SettingsDialog.cpp @@ -8,6 +8,7 @@ * along with this program. If not, see . */ #include "SettingsDialog.hpp" +#include "../../Globals.hpp" using namespace UserInterface::Dialog; @@ -16,7 +17,22 @@ SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent, Qt::WindowSyst this->setupUi(this); // TODO - this->treeWidget->topLevelItem(0)->setSelected(true); + this->treeWidget->topLevelItem(1)->setSelected(true); + + if (!g_EmuThread->isRunning()) + { + this->treeWidget->topLevelItem(1)->setDisabled(true); + } + else + { + M64P::Wrapper::RomInfo_t info; + g_MupenApi.Core.GetRomInfo("", &info); + + this->lineEdit->setText(info.Settings.goodname); + this->comboBox->setCurrentIndex(info.Settings.disableextramem == 1 ? 0 : 1); + this->comboBox_2->setCurrentIndex(info.Settings.savetype); + this->comboBox_3->setCurrentIndex(info.Settings.countperop); + } } SettingsDialog::~SettingsDialog(void) diff --git a/Source/RMG/UserInterface/Dialog/SettingsDialog.ui b/Source/RMG/UserInterface/Dialog/SettingsDialog.ui index 622b3fa0..0db52637 100644 --- a/Source/RMG/UserInterface/Dialog/SettingsDialog.ui +++ b/Source/RMG/UserInterface/Dialog/SettingsDialog.ui @@ -79,53 +79,178 @@ 0 - + - -10 + 0 0 - 324 + 321 321 - - - 0 + + + + + + + 170 + 10 + 141 + 32 + - - QLayout::SetDefaultConstraint + + true + + + + + + 10 + 10 + 161 + 31 + + + + Good Name + + + + + + 10 + 50 + 161 + 31 + + + + Memory Size + + + + + + 10 + 90 + 161 + 31 + + + + Save Type + + + + + + 10 + 130 + 161 + 31 + + + + Counter Factor + + + + + + 170 + 50 + 141 + 32 + - - - - - TextLabel - - - - - - - + + 4 MB + - - - Qt::Vertical - - - QSizePolicy::Expanding - - - - 20 - 40 - - - + + 8 MB + - + + + + + 170 + 90 + 141 + 32 + + + + + 4 KB EEPROM + + + + + 16 KB EEPROM + + + + + SRAM + + + + + Flash RAM + + + + + Controller pack + + + + + None + + + + + + + 170 + 130 + 141 + 32 + + + + + 1 + + + + + 2 + + + + + 3 + + + + + 4 + + + + + 5 + + + diff --git a/Source/RMG/UserInterface/MainWindow.cpp b/Source/RMG/UserInterface/MainWindow.cpp index 60df849a..21abe47c 100644 --- a/Source/RMG/UserInterface/MainWindow.cpp +++ b/Source/RMG/UserInterface/MainWindow.cpp @@ -229,7 +229,7 @@ void MainWindow::menuBar_Setup(bool inEmulation, bool isPaused) this->menuBar_Menu->addSeparator(); // TODO: Add language support - QMenu* langMenu = new QMenu("Language", this); + QMenu *langMenu = new QMenu("Language", this); langMenu->addAction("English"); this->menuBar_Menu->addMenu(langMenu); @@ -755,8 +755,16 @@ void MainWindow::on_Action_Options_ConfigControl(void) void MainWindow::on_Action_Options_Settings(void) { + bool isPaused = g_MupenApi.Core.isEmulationPaused(); + + if (!isPaused) + this->on_Action_System_Pause(); + Dialog::SettingsDialog dialog(this); dialog.exec(); + + if (!isPaused) + this->on_Action_System_Pause(); } void MainWindow::on_Action_Help_Support(void)