From b05b0faeea1674eec557785a4d765d96732ccf15 Mon Sep 17 00:00:00 2001 From: Rosalie Wanders Date: Sun, 16 Feb 2025 00:50:32 +0100 Subject: [PATCH] RMG-Input: use ROM header and settings in CorePluginsOpenROMConfig() --- Source/RMG-Input/UserInterface/MainDialog.cpp | 4 ++-- Source/RMG-Input/UserInterface/MainDialog.hpp | 5 ++++- .../UserInterface/Widget/ControllerWidget.cpp | 13 ++++++++----- .../UserInterface/Widget/ControllerWidget.hpp | 6 +++++- Source/RMG-Input/main.cpp | 4 ++-- 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/Source/RMG-Input/UserInterface/MainDialog.cpp b/Source/RMG-Input/UserInterface/MainDialog.cpp index f19aebc1..d7eb34a9 100644 --- a/Source/RMG-Input/UserInterface/MainDialog.cpp +++ b/Source/RMG-Input/UserInterface/MainDialog.cpp @@ -20,7 +20,7 @@ Q_DECLARE_METATYPE(SDLDevice); using namespace UserInterface; -MainDialog::MainDialog(QWidget* parent, Thread::SDLThread* sdlThread, bool romConfig) : QDialog(parent) +MainDialog::MainDialog(QWidget* parent, Thread::SDLThread* sdlThread, bool romConfig, CoreRomHeader romHeader, CoreRomSettings romSettings) : QDialog(parent) { qRegisterMetaType(); @@ -45,7 +45,7 @@ MainDialog::MainDialog(QWidget* parent, Thread::SDLThread* sdlThread, bool romCo for (int i = 0; i < this->tabWidget->count(); i++) { Widget::ControllerWidget* widget = new Widget::ControllerWidget(this, this->eventFilter); - widget->SetOnlyLoadGameProfile(romConfig); + widget->SetOnlyLoadGameProfile(romConfig, romHeader, romSettings); widget->SetSettingsSection("Player " + QString::number(i + 1), "Rosalie's Mupen GUI - Input Plugin Profile " + QString::number(i)); widget->LoadSettings(); this->tabWidget->widget(i)->layout()->addWidget(widget); diff --git a/Source/RMG-Input/UserInterface/MainDialog.hpp b/Source/RMG-Input/UserInterface/MainDialog.hpp index 9d8eeaff..91cbeceb 100644 --- a/Source/RMG-Input/UserInterface/MainDialog.hpp +++ b/Source/RMG-Input/UserInterface/MainDialog.hpp @@ -19,6 +19,9 @@ #include "ui_MainDialog.h" +#include +#include + namespace UserInterface { class MainDialog : public QDialog, private Ui::MainDialog @@ -48,7 +51,7 @@ private: void closeInputDevice(); public: - MainDialog(QWidget *parent, Thread::SDLThread*, bool); + MainDialog(QWidget *parent, Thread::SDLThread*, bool, CoreRomHeader, CoreRomSettings); ~MainDialog(void); public slots: diff --git a/Source/RMG-Input/UserInterface/Widget/ControllerWidget.cpp b/Source/RMG-Input/UserInterface/Widget/ControllerWidget.cpp index 624a4050..13d5dddc 100644 --- a/Source/RMG-Input/UserInterface/Widget/ControllerWidget.cpp +++ b/Source/RMG-Input/UserInterface/Widget/ControllerWidget.cpp @@ -1454,9 +1454,11 @@ bool ControllerWidget::IsPluggedIn() return this->inputDeviceComboBox->currentData().toInt() != (int)InputDeviceType::None; } -void ControllerWidget::SetOnlyLoadGameProfile(bool value) +void ControllerWidget::SetOnlyLoadGameProfile(bool value, CoreRomHeader romHeader, CoreRomSettings romSettings) { this->onlyLoadGameProfile = value; + this->gameRomHeader = romHeader; + this->gameRomSettings = romSettings; // update UI element this->addProfileButton->setDisabled(value); @@ -1496,10 +1498,11 @@ void ControllerWidget::LoadSettings() // try to retrieve the current rom's settings & header, // if that succeeds, we know we're ingame // and then we'll add a game specific profile to the combobox - CoreRomSettings romSettings; - CoreRomHeader romHeader; - if (CoreGetCurrentRomSettings(romSettings) && - CoreGetCurrentRomHeader(romHeader)) + CoreRomSettings romSettings = this->gameRomSettings; + CoreRomHeader romHeader = this->gameRomHeader; + if (this->onlyLoadGameProfile || + (CoreGetCurrentRomSettings(romSettings) && + CoreGetCurrentRomHeader(romHeader))) { this->gameSection = section + " Game " + QString::fromStdString(romSettings.MD5); diff --git a/Source/RMG-Input/UserInterface/Widget/ControllerWidget.hpp b/Source/RMG-Input/UserInterface/Widget/ControllerWidget.hpp index db43e78c..62bbe4ad 100644 --- a/Source/RMG-Input/UserInterface/Widget/ControllerWidget.hpp +++ b/Source/RMG-Input/UserInterface/Widget/ControllerWidget.hpp @@ -24,6 +24,8 @@ using namespace UserInterface::Widget; #include +#include +#include #include namespace UserInterface @@ -110,6 +112,8 @@ private: int previousProfileComboBoxIndex = -1; bool onlyLoadGameProfile = false; + CoreRomHeader gameRomHeader; + CoreRomSettings gameRomSettings; HotkeysDialog* currentHotkeysDialog = nullptr; @@ -128,7 +132,7 @@ public: void GetCurrentInputDevice(SDLDevice& device, bool ignoreDeviceNotFound = false); bool IsPluggedIn(); - void SetOnlyLoadGameProfile(bool value); + void SetOnlyLoadGameProfile(bool value, CoreRomHeader romHeader, CoreRomSettings romSettings); void SetSettingsSection(QString profile, QString section); void SetInitialized(bool value); diff --git a/Source/RMG-Input/main.cpp b/Source/RMG-Input/main.cpp index 1b7c0b8a..132290c6 100644 --- a/Source/RMG-Input/main.cpp +++ b/Source/RMG-Input/main.cpp @@ -1086,7 +1086,7 @@ void PluginDebugMessage(int level, std::string message) // Custom Plugin Functions // -EXPORT m64p_error CALL PluginConfig2(void* parent, int romConfig) +EXPORT m64p_error CALL PluginConfig2(void* parent, int romConfig, CoreRomHeader* romHeader, CoreRomSettings* romSettings) { if (l_SDLThread == nullptr) { @@ -1100,7 +1100,7 @@ EXPORT m64p_error CALL PluginConfig2(void* parent, int romConfig) l_SDLThread->SetAction(SDLThreadAction::SDLPumpEvents); - UserInterface::MainDialog dialog((QWidget*)parent, l_SDLThread, romConfig); + UserInterface::MainDialog dialog((QWidget*)parent, l_SDLThread, romConfig, *romHeader, *romSettings); dialog.exec(); // when PluginShutdown() is called during PluginConfig2(),