mirror of
https://github.com/libretro/FBNeo.git
synced 2024-12-02 14:56:50 +00:00
[Qt] Implements "Map game inputs" (partially)
This commit is contained in:
parent
9db7cf5745
commit
baece5ce9c
@ -761,6 +761,7 @@ SOURCES += \
|
||||
../../src/cpu/tlcs90/tlcs90.cpp \
|
||||
../../src/cpu/tlcs90_intf.cpp \
|
||||
../../src/burn/devices/kaneko_tmap.cpp \
|
||||
../../src/burner/qt/inputdialog.cpp
|
||||
|
||||
|
||||
HEADERS += \
|
||||
@ -932,6 +933,7 @@ HEADERS += \
|
||||
../../src/dep/libs/zlib/zutil.h \
|
||||
../../src/burn/devices/nmk004.h \
|
||||
../../src/burn/devices/kaneko_tmap.h \
|
||||
../../src/burner/qt/inputdialog.h
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Linux only drivers
|
||||
@ -951,4 +953,5 @@ FORMS += \
|
||||
../../src/burner/qt/rominfodialog.ui \
|
||||
../../src/burner/qt/romscandialog.ui \
|
||||
../../src/burner/qt/selectdialog.ui \
|
||||
../../src/burner/qt/supportdirsdialog.ui
|
||||
../../src/burner/qt/supportdirsdialog.ui \
|
||||
../../src/burner/qt/inputdialog.ui
|
||||
|
112
src/burner/qt/inputdialog.cpp
Normal file
112
src/burner/qt/inputdialog.cpp
Normal file
@ -0,0 +1,112 @@
|
||||
#include <QtWidgets>
|
||||
#include "inputdialog.h"
|
||||
#include "ui_inputdialog.h"
|
||||
#include "burner.h"
|
||||
|
||||
InputDialog::InputDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::InputDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->tvInputs->setColumnWidth(0, 200);
|
||||
ui->tvInputs->setColumnWidth(1, 200);
|
||||
|
||||
setWindowTitle("Map Game Inputs");
|
||||
|
||||
m_timer = new QTimer(this);
|
||||
connect(m_timer, SIGNAL(timeout()), this, SLOT(updateInputs()));
|
||||
m_timer->setInterval(30);
|
||||
}
|
||||
|
||||
InputDialog::~InputDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
int InputDialog::exec()
|
||||
{
|
||||
makeList();
|
||||
m_timer->start();
|
||||
QDialog::exec();
|
||||
m_timer->stop();
|
||||
}
|
||||
|
||||
void InputDialog::updateInputs()
|
||||
{
|
||||
InputMake(true);
|
||||
|
||||
for (int i = 0; i < ui->tvInputs->topLevelItemCount(); i++) {
|
||||
QTreeWidgetItem *item = ui->tvInputs->topLevelItem(i);
|
||||
struct GameInp *pgi = GameInp;
|
||||
|
||||
pgi += item->data(0, Qt::UserRole).toInt();
|
||||
|
||||
if (pgi->nType == 0)
|
||||
continue;
|
||||
|
||||
int value = pgi->Input.nVal;
|
||||
int lastValue = item->data(2, Qt::UserRole).toInt();
|
||||
|
||||
if (value == lastValue)
|
||||
continue;
|
||||
|
||||
switch (pgi->nType) {
|
||||
case BIT_DIGITAL:
|
||||
if (value)
|
||||
item->setText(2, "ON");
|
||||
else
|
||||
item->setText(2, "");
|
||||
break;
|
||||
}
|
||||
item->setData(2, Qt::UserRole, value);
|
||||
}
|
||||
}
|
||||
|
||||
void InputDialog::makeList()
|
||||
{
|
||||
static const QColor dipColor(255, 255, 210);
|
||||
clear();
|
||||
|
||||
struct GameInp *pgi = GameInp;
|
||||
|
||||
// Add all the input names to the list
|
||||
for (unsigned int i = 0; i < nGameInpCount; i++) {
|
||||
struct BurnInputInfo bii;
|
||||
|
||||
// Get the name of the input
|
||||
bii.szName = nullptr;
|
||||
BurnDrvGetInputInfo(&bii, i);
|
||||
|
||||
// skip unused inputs
|
||||
if (bii.pVal == nullptr)
|
||||
continue;
|
||||
|
||||
if (bii.szName == nullptr)
|
||||
bii.szName = "";
|
||||
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem();
|
||||
item->setData(0, Qt::UserRole, i);
|
||||
item->setData(2, Qt::UserRole, 0);
|
||||
|
||||
if (pgi->nType == BIT_DIPSWITCH) {
|
||||
for (int j = 0; j < ui->tvInputs->columnCount(); j++)
|
||||
item->setBackgroundColor(j, dipColor);
|
||||
}
|
||||
|
||||
item->setText(0, bii.szName);
|
||||
|
||||
if (pgi->Input.pVal != nullptr) {
|
||||
auto value = InpToDesc(pgi);
|
||||
item->setText(1, value);
|
||||
}
|
||||
|
||||
ui->tvInputs->addTopLevelItem(item);
|
||||
pgi++;
|
||||
}
|
||||
}
|
||||
|
||||
void InputDialog::clear()
|
||||
{
|
||||
while (ui->tvInputs->topLevelItemCount() > 0)
|
||||
ui->tvInputs->takeTopLevelItem(0);
|
||||
}
|
30
src/burner/qt/inputdialog.h
Normal file
30
src/burner/qt/inputdialog.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef INPUTDIALOG_H
|
||||
#define INPUTDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QTimer>
|
||||
|
||||
namespace Ui {
|
||||
class InputDialog;
|
||||
}
|
||||
|
||||
class InputDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit InputDialog(QWidget *parent = 0);
|
||||
~InputDialog();
|
||||
|
||||
public slots:
|
||||
int exec();
|
||||
void updateInputs();
|
||||
|
||||
private:
|
||||
void makeList();
|
||||
void clear();
|
||||
Ui::InputDialog *ui;
|
||||
QTimer *m_timer;
|
||||
};
|
||||
|
||||
#endif // INPUTDIALOG_H
|
100
src/burner/qt/inputdialog.ui
Normal file
100
src/burner/qt/inputdialog.ui
Normal file
@ -0,0 +1,100 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>InputDialog</class>
|
||||
<widget class="QDialog" name="InputDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>573</width>
|
||||
<height>443</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Double-click an input to change its mapping</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTreeWidget" name="tvInputs">
|
||||
<property name="rootIsDecorated">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="uniformRowHeights">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="headerStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Game input</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Mapped to</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>State</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnOk">
|
||||
<property name="text">
|
||||
<string>Ok</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>btnOk</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>InputDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>495</x>
|
||||
<y>421</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>440</x>
|
||||
<y>435</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@ -156,6 +156,7 @@ void MainWindow::createMenus()
|
||||
setupInputInterfaces();
|
||||
|
||||
m_menuInput->addAction(m_actionDipswitch);
|
||||
m_menuInput->addAction(m_actionMapGameInputs);
|
||||
|
||||
m_menuMisc = menuBar()->addMenu(tr("Misc"));
|
||||
m_menuMisc->addAction(m_actionConfigureRomPaths);
|
||||
@ -179,6 +180,7 @@ void MainWindow::createControls()
|
||||
m_supportPathDlg = new SupportDirsDialog(this);
|
||||
m_aboutDlg = new AboutDialog(this);
|
||||
m_dipSwitchDlg = new DipswitchDialog(this);
|
||||
m_inputDlg = new InputDialog(this);
|
||||
|
||||
extern void ProgressSetParent(QWidget *);
|
||||
ProgressSetParent(this);
|
||||
@ -200,6 +202,8 @@ void MainWindow::createActions()
|
||||
m_actionAbout = new QAction(tr("About FBA"), this);
|
||||
m_actionDipswitch = new QAction(tr("Configure DIPs"), this);
|
||||
m_actionDipswitch->setEnabled(false);
|
||||
m_actionMapGameInputs = new QAction(tr("Map game inputs"), this);
|
||||
m_actionMapGameInputs->setEnabled(false);
|
||||
}
|
||||
|
||||
void MainWindow::connectActions()
|
||||
@ -214,18 +218,22 @@ void MainWindow::connectActions()
|
||||
connect(m_scutToogleMenu, SIGNAL(activated()), this, SLOT(toogleMenu()));
|
||||
connect(m_scutToogleFullscreen, SIGNAL(activated()), this, SLOT(toogleFullscreen()));
|
||||
connect(m_actionDipswitch, SIGNAL(triggered()), m_dipSwitchDlg, SLOT(exec()));
|
||||
connect(m_actionMapGameInputs, SIGNAL(triggered()), m_inputDlg, SLOT(exec()));
|
||||
}
|
||||
|
||||
void MainWindow::enableInGame()
|
||||
{
|
||||
m_actionCloseGame->setEnabled(true);
|
||||
m_actionDipswitch->setEnabled(true);
|
||||
m_actionMapGameInputs->setEnabled(true);
|
||||
}
|
||||
|
||||
void MainWindow::disableInGame()
|
||||
{
|
||||
m_actionCloseGame->setEnabled(false);
|
||||
m_actionDipswitch->setEnabled(false);
|
||||
m_actionMapGameInputs->setEnabled(false);
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::drawLogo()
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "supportdirsdialog.h"
|
||||
#include "aboutdialog.h"
|
||||
#include "dipswitchdialog.h"
|
||||
#include "inputdialog.h"
|
||||
#include "emuworker.h"
|
||||
#include "burner.h"
|
||||
|
||||
@ -57,6 +58,7 @@ private:
|
||||
SupportDirsDialog *m_supportPathDlg;
|
||||
AboutDialog *m_aboutDlg;
|
||||
DipswitchDialog *m_dipSwitchDlg;
|
||||
InputDialog *m_inputDlg;
|
||||
QMenu *m_menuGame;
|
||||
QMenu *m_menuMisc;
|
||||
QMenu *m_menuHelp;
|
||||
@ -70,6 +72,7 @@ private:
|
||||
QAction *m_actionCloseGame;
|
||||
QAction *m_actionToogleMenu;
|
||||
QAction *m_actionDipswitch;
|
||||
QAction *m_actionMapGameInputs;
|
||||
QShortcut *m_scutToogleMenu;
|
||||
QShortcut *m_scutToogleFullscreen;
|
||||
QImage m_logo;
|
||||
|
Loading…
Reference in New Issue
Block a user