From 5ae2101f88e954b69876217e077092352165183c Mon Sep 17 00:00:00 2001 From: anonymous7002 Date: Thu, 15 Jul 2021 22:49:41 +0300 Subject: [PATCH] added a menu to set plugins --- mupen64plus-gui/mainwindow.cpp | 75 ++++++++++++++++++++-------- mupen64plus-gui/mainwindow.h | 4 +- mupen64plus-gui/mainwindow.ui | 14 ++++-- mupen64plus-gui/settingsdialog.cpp | 78 +++++++++++++++++++++++++++--- 4 files changed, 139 insertions(+), 32 deletions(-) diff --git a/mupen64plus-gui/mainwindow.cpp b/mupen64plus-gui/mainwindow.cpp index 698af5c88..9b71abc69 100644 --- a/mupen64plus-gui/mainwindow.cpp +++ b/mupen64plus-gui/mainwindow.cpp @@ -49,6 +49,31 @@ void MainWindow::updatePlugins() Filter.append(""); QStringList current; QString default_value; + + if (!settings->contains("gfxPlugin")) { + Filter.replace(0,"mupen64plus-video*"); + current = PluginDir.entryList(Filter); + default_value = "mupen64plus-video-parallel"; + default_value += OSAL_DLL_EXTENSION; + if (current.isEmpty()) + settings->setValue("gfxPlugin", "dummy"); + else if (current.indexOf(default_value) != -1) + settings->setValue("gfxPlugin", default_value); + else + settings->setValue("gfxPlugin", current.at(0)); + } + if (!settings->contains("audioPlugin")) { + Filter.replace(0,"mupen64plus-audio*"); + current = PluginDir.entryList(Filter); + default_value = "mupen64plus-audio-sdl2"; + default_value += OSAL_DLL_EXTENSION; + if (current.isEmpty()) + settings->setValue("audioPlugin", "dummy"); + else if (current.indexOf(default_value) != -1) + settings->setValue("audioPlugin", default_value); + else + settings->setValue("audioPlugin", current.at(0)); + } if (!settings->contains("inputPlugin")) { Filter.replace(0,"mupen64plus-input*"); @@ -62,8 +87,21 @@ void MainWindow::updatePlugins() else settings->setValue("inputPlugin", current.at(0)); } - - ui->actionController_Configuration->setEnabled(settings->value("inputPlugin").toString().contains("-qt")); + + if (!settings->contains("rspPlugin")) { + Filter.replace(0,"mupen64plus-rsp*"); + current = PluginDir.entryList(Filter); + default_value = "mupen64plus-rsp-parallel"; + default_value += OSAL_DLL_EXTENSION; + if (current.isEmpty()) + settings->setValue("rspPlugin", "dummy"); + else if (current.indexOf(default_value) != -1) + settings->setValue("rspPlugin", default_value); + else + settings->setValue("rspPlugin", current.at(0)); + } + + ui->actionInput_Configuration->setEnabled(settings->value("inputPlugin").toString().contains("-qt")); } void MainWindow::updatePIF(Ui::MainWindow *ui) @@ -908,7 +946,7 @@ void MainWindow::on_actionLoad_State_From_triggered() } } -void MainWindow::on_actionController_Configuration_triggered() +void MainWindow::on_actionInput_Configuration_triggered() { if (!coreLib) return; @@ -936,6 +974,14 @@ void MainWindow::on_actionView_Log_triggered() logViewer.show(); } +void MainWindow::on_actionVideo_Configuration_triggered() +{ + typedef void (*Config_Func)(); + Config_Func PluginConfig = (Config_Func) osal_dynlib_getproc(gfxPlugin, "PluginConfig"); + if (PluginConfig) + PluginConfig(); +} + void MainWindow::on_actionCreate_Room_triggered() { CreateRoom *createRoom = new CreateRoom(this); @@ -1104,11 +1150,7 @@ void MainWindow::loadPlugins() QString file_path; QString plugin_path; - - file_path = "mupen64plus-video-parallel"; - file_path += OSAL_DLL_EXTENSION; - plugin_path = QDir(pluginPath).filePath(file_path); - + res = osal_dynlib_open(&gfxPlugin, plugin_path.toUtf8().constData()); if (res != M64ERR_SUCCESS) { @@ -1116,14 +1158,9 @@ void MainWindow::loadPlugins() msgBox.exec(); return; } - PluginStartup = (ptr_PluginStartup) osal_dynlib_getproc(gfxPlugin, "PluginStartup"); (*PluginStartup)(coreLib, (char*)"Video", DebugCallback); - - file_path = "mupen64plus-audio-sdl2"; - file_path += OSAL_DLL_EXTENSION; - plugin_path = QDir(pluginPath).filePath(file_path); - + res = osal_dynlib_open(&audioPlugin, plugin_path.toUtf8().constData()); if (res != M64ERR_SUCCESS) { @@ -1135,7 +1172,8 @@ void MainWindow::loadPlugins() (*PluginStartup)(coreLib, (char*)"Audio", DebugCallback); res = osal_dynlib_open(&inputPlugin, QDir(pluginPath).filePath(settings->value("inputPlugin").toString()).toUtf8().constData()); - if (res != M64ERR_SUCCESS) + + if (res != M64ERR_SUCCESS) { msgBox.setText("Failed to load input plugin"); msgBox.exec(); @@ -1146,12 +1184,7 @@ void MainWindow::loadPlugins() (*PluginStartup)(coreLib, this, DebugCallback); else (*PluginStartup)(coreLib, (char*)"Input", DebugCallback); - - - file_path = "mupen64plus-rsp-parallel"; - file_path += OSAL_DLL_EXTENSION; - plugin_path = QDir(pluginPath).filePath(file_path); - + res = osal_dynlib_open(&rspPlugin, plugin_path.toUtf8().constData()); if (res != M64ERR_SUCCESS) { diff --git a/mupen64plus-gui/mainwindow.h b/mupen64plus-gui/mainwindow.h index 06712153d..b8194ca25 100644 --- a/mupen64plus-gui/mainwindow.h +++ b/mupen64plus-gui/mainwindow.h @@ -113,10 +113,12 @@ private slots: void on_actionLoad_State_From_triggered(); - void on_actionController_Configuration_triggered(); + void on_actionInput_Configuration_triggered(); void on_actionToggle_Speed_Limiter_triggered(); + void on_actionVideo_Configuration_triggered(); + void on_actionView_Log_triggered(); void on_actionCreate_Room_triggered(); diff --git a/mupen64plus-gui/mainwindow.ui b/mupen64plus-gui/mainwindow.ui index a3298476e..268ecc6d1 100644 --- a/mupen64plus-gui/mainwindow.ui +++ b/mupen64plus-gui/mainwindow.ui @@ -46,7 +46,8 @@ - + + @@ -101,7 +102,7 @@ - Core and Video Settings + Core Settings @@ -164,9 +165,14 @@ Toggle Fullscreen (Alt + Return) - + - Controller Configuration + Video Configuration + + + + + Input Configuration diff --git a/mupen64plus-gui/settingsdialog.cpp b/mupen64plus-gui/settingsdialog.cpp index 0104c49d3..a7a7f3e8f 100644 --- a/mupen64plus-gui/settingsdialog.cpp +++ b/mupen64plus-gui/settingsdialog.cpp @@ -26,8 +26,11 @@ void SettingsDialog::handlePluginButton() if (!fileName.isNull()) { pluginPath->setText(fileName); w->getSettings()->setValue("pluginDirPath", fileName); - - w->getSettings()->remove("inputPlugin"); + + w->getSettings()->remove("gfxPlugin"); + w->getSettings()->remove("audioPlugin"); + w->getSettings()->remove("inputPlugin"); + w->getSettings()->remove("rspPlugin"); w->updatePlugins(); } } @@ -58,8 +61,11 @@ void SettingsDialog::handleCoreEdit() void SettingsDialog::handlePluginEdit() { w->getSettings()->setValue("pluginDirPath", pluginPath->text()); - + + w->getSettings()->remove("gfxPlugin"); + w->getSettings()->remove("audioPlugin"); w->getSettings()->remove("inputPlugin"); + w->getSettings()->remove("rspPlugin"); w->updatePlugins(); } @@ -132,9 +138,49 @@ void SettingsDialog::initStuff() QStringList Filter; Filter.append(""); QStringList current; - + + QLabel *videoLabel = new QLabel("Video Plugin", this); + layout->addWidget(videoLabel,5,0); + QComboBox *videoChoice = new QComboBox(this); + Filter.replace(0,"mupen64plus-video*"); + current = PluginDir.entryList(Filter); + videoChoice->addItems(current); + QString qtVideoPlugin = w->getSettings()->value("gfxPlugin").toString(); + int video_index = videoChoice->findText(qtVideoPlugin); + if (video_index == -1) { + videoChoice->addItem(qtVideoPlugin); + video_index = videoChoice->findText(qtVideoPlugin); + } + videoChoice->setCurrentIndex(video_index); + connect(videoChoice, static_cast(&QComboBox::activated), + [=](const QString &text) { + w->getSettings()->setValue("gfxPlugin", text); + w->updatePlugins(); + }); + layout->addWidget(videoChoice,5,1); + + QLabel *audioLabel = new QLabel("Audio Plugin", this); + layout->addWidget(audioLabel,6,0); + QComboBox *audioChoice = new QComboBox(this); + Filter.replace(0,"mupen64plus-audio*"); + current = PluginDir.entryList(Filter); + audioChoice->addItems(current); + QString qtAudioPlugin = w->getSettings()->value("audioPlugin").toString(); + int audio_index = audioChoice->findText(qtAudioPlugin); + if (audio_index == -1) { + audioChoice->addItem(qtAudioPlugin); + audio_index = audioChoice->findText(qtAudioPlugin); + } + audioChoice->setCurrentIndex(audio_index); + connect(audioChoice, static_cast(&QComboBox::activated), + [=](const QString &text) { + w->getSettings()->setValue("audioPlugin", text); + w->updatePlugins(); + }); + layout->addWidget(audioChoice,6,1); + QLabel *inputLabel = new QLabel("Input Plugin", this); - layout->addWidget(inputLabel,5,0); + layout->addWidget(inputLabel,7,0); QComboBox *inputChoice = new QComboBox(this); Filter.replace(0,"mupen64plus-input*"); current = PluginDir.entryList(Filter); @@ -151,7 +197,27 @@ void SettingsDialog::initStuff() w->getSettings()->setValue("inputPlugin", text); w->updatePlugins(); }); - layout->addWidget(inputChoice,5,1); + layout->addWidget(inputChoice,7,1); + + QLabel *rspLabel = new QLabel("RSP Plugin", this); + layout->addWidget(rspLabel,8,0); + QComboBox *rspChoice = new QComboBox(this); + Filter.replace(0,"mupen64plus-rsp*"); + current = PluginDir.entryList(Filter); + rspChoice->addItems(current); + QString qtRSPPlugin = w->getSettings()->value("rspPlugin").toString(); + int rsp_index = rspChoice->findText(qtRSPPlugin); + if (rsp_index == -1) { + rspChoice->addItem(qtRSPPlugin); + rsp_index = rspChoice->findText(qtRSPPlugin); + } + rspChoice->setCurrentIndex(rsp_index); + connect(rspChoice, static_cast(&QComboBox::activated), + [=](const QString &text) { + w->getSettings()->setValue("rspPlugin", text); + w->updatePlugins(); + }); + layout->addWidget(rspChoice,8,1); setLayout(layout); }