Skip to content

Commit

Permalink
added a menu to set plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
lordlouckster committed Jul 15, 2021
1 parent e34e719 commit 5ae2101
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 32 deletions.
75 changes: 54 additions & 21 deletions mupen64plus-gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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*");
Expand All @@ -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)
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1104,26 +1150,17 @@ 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)
{
msgBox.setText("Failed to load video plugin");
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)
{
Expand All @@ -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();
Expand All @@ -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)
{
Expand Down
4 changes: 3 additions & 1 deletion mupen64plus-gui/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
14 changes: 10 additions & 4 deletions mupen64plus-gui/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
</property>
<addaction name="actionPlugin_Paths"/>
<addaction name="actionPlugin_Settings"/>
<addaction name="actionController_Configuration"/>
<addaction name="actionVideo_Configuration"/>
<addaction name="actionInput_Configuration"/>
</widget>
<widget class="QMenu" name="menuEmulation">
<property name="title">
Expand Down Expand Up @@ -101,7 +102,7 @@
</action>
<action name="actionPlugin_Settings">
<property name="text">
<string>Core and Video Settings</string>
<string>Core Settings</string>
</property>
</action>
<action name="actionOpen_Recent">
Expand Down Expand Up @@ -164,9 +165,14 @@
<string>Toggle Fullscreen (Alt + Return)</string>
</property>
</action>
<action name="actionController_Configuration">
<action name="actionVideo_Configuration">
<property name="text">
<string>Controller Configuration</string>
<string>Video Configuration</string>
</property>
</action>
<action name="actionInput_Configuration">
<property name="text">
<string>Input Configuration</string>
</property>
</action>
<action name="actionToggle_Speed_Limiter">
Expand Down
78 changes: 72 additions & 6 deletions mupen64plus-gui/settingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -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<void(QComboBox::*)(const QString &)>(&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<void(QComboBox::*)(const QString &)>(&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);
Expand All @@ -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<void(QComboBox::*)(const QString &)>(&QComboBox::activated),
[=](const QString &text) {
w->getSettings()->setValue("rspPlugin", text);
w->updatePlugins();
});
layout->addWidget(rspChoice,8,1);

setLayout(layout);
}
Expand Down

1 comment on commit 5ae2101

@RokkumanX
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anonymous7002

Holy s*** dude you really pulled this off didn't you.

5 thumbs up!

Thank you very much for this!!!

Please sign in to comment.