From e0a3f430ecbda85e5f0903011bf8ffeb01f10fe0 Mon Sep 17 00:00:00 2001 From: Shamus Hammons Date: Thu, 23 Jun 2011 21:07:07 +0000 Subject: [PATCH] First attempt at configuration dialog. --- Makefile | 7 +++- src/gui/configdialog.cpp | 63 ++++++++++++++++++++++++++++++++ src/gui/configdialog.h | 37 +++++++++++++++++++ src/gui/configwin.cpp | 16 --------- src/gui/configwin.h | 13 ------- src/gui/controllertab.cpp | 76 +++++++++++++++++++++++++++++++++++++++ src/gui/controllertab.h | 18 ++++++++++ src/gui/generaltab.cpp | 73 +++++++++++++++++++++++++++++++++++++ src/gui/generaltab.h | 21 +++++++++++ src/gui/mainwin.cpp | 17 +++++++++ src/gui/mainwin.h | 2 ++ src/gui/virtualjaguar.pro | 6 ++-- 12 files changed, 317 insertions(+), 32 deletions(-) create mode 100644 src/gui/configdialog.cpp create mode 100644 src/gui/configdialog.h delete mode 100644 src/gui/configwin.cpp delete mode 100644 src/gui/configwin.h create mode 100644 src/gui/controllertab.cpp create mode 100644 src/gui/controllertab.h create mode 100644 src/gui/generaltab.cpp create mode 100644 src/gui/generaltab.h diff --git a/Makefile b/Makefile index 73f27aa..17385f8 100644 --- a/Makefile +++ b/Makefile @@ -82,7 +82,12 @@ OBJS := \ \ obj/about.o \ obj/app.o \ - obj/configwin.o \ + obj/configdialog.o \ + obj/moc_configdialog.o \ + obj/generaltab.o \ + obj/moc_generaltab.o \ + obj/controllertab.o \ + obj/moc_controllertab.o \ obj/filepicker.o \ obj/moc_filepicker.o \ obj/filelistmodel.o \ diff --git a/src/gui/configdialog.cpp b/src/gui/configdialog.cpp new file mode 100644 index 0000000..f9b3fe4 --- /dev/null +++ b/src/gui/configdialog.cpp @@ -0,0 +1,63 @@ +// +// configdialog.cpp - Configuration dialog +// +// by James L. Hammons +// (C) 2010 Underground Software +// +// JLH = James L. Hammons +// +// Who When What +// --- ---------- ------------------------------------------------------------- +// JLH 01/29/2010 Created this file +// JLH 06/23/2011 Added initial implementation +// + +#include "configdialog.h" + +#include "generaltab.h" +#include "controllertab.h" +#include "settings.h" + + +ConfigDialog::ConfigDialog(QWidget * parent/*= 0*/): QDialog(parent) +{ + tabWidget = new QTabWidget; + generalTab = new GeneralTab(this); + controllerTab = new ControllerTab(this); + tabWidget->addTab(generalTab, tr("General")); + tabWidget->addTab(controllerTab, tr("Controller")); + + buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + + connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); + connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); + + QVBoxLayout * mainLayout = new QVBoxLayout; + mainLayout->addWidget(tabWidget); + mainLayout->addWidget(buttonBox); + setLayout(mainLayout); + + setWindowTitle(tr("Virtual Jaguar Settings")); + + LoadDialogFromSettings(); +} + +ConfigDialog::~ConfigDialog() +{ +} + +void ConfigDialog::LoadDialogFromSettings(void) +{ + generalTab->edit1->setText(vjs.jagBootPath); + generalTab->edit2->setText(vjs.CDBootPath); + generalTab->edit3->setText(vjs.EEPROMPath); + generalTab->edit4->setText(vjs.ROMPath); +} + +void ConfigDialog::UpdateVJSettings(void) +{ + strcpy(vjs.jagBootPath, generalTab->edit1->text().toAscii().data()); + strcpy(vjs.CDBootPath, generalTab->edit2->text().toAscii().data()); + strcpy(vjs.EEPROMPath, generalTab->edit3->text().toAscii().data()); + strcpy(vjs.ROMPath, generalTab->edit4->text().toAscii().data()); +} diff --git a/src/gui/configdialog.h b/src/gui/configdialog.h new file mode 100644 index 0000000..99d4e16 --- /dev/null +++ b/src/gui/configdialog.h @@ -0,0 +1,37 @@ +// +// configdialog.h - Configuration dialog +// +// by James L. Hammons +// (C) 2010 Underground Software +// + +#ifndef __CONFIGDIALOG_H__ +#define __CONFIGDIALOG_H__ + +#include + +class GeneralTab; +class ControllerTab; + +class ConfigDialog: public QDialog +{ + Q_OBJECT + + public: + ConfigDialog(QWidget * parent = 0); + ~ConfigDialog(); + void UpdateVJSettings(void); + + private: + void LoadDialogFromSettings(void); + + private: + QTabWidget * tabWidget; + QDialogButtonBox * buttonBox; + + public: + GeneralTab * generalTab; + ControllerTab * controllerTab; +}; + +#endif // __CONFIGDIALOG_H__ diff --git a/src/gui/configwin.cpp b/src/gui/configwin.cpp deleted file mode 100644 index f72c410..0000000 --- a/src/gui/configwin.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// -// configwin.cpp - Configuration window -// -// by James L. Hammons -// (C) 2010 Underground Software -// -// JLH = James L. Hammons -// -// Who When What -// --- ---------- ------------------------------------------------------------- -// JLH 01/29/2010 Created this file -// - -#include "configwin.h" - -#warning "!!! I NEED TO BE WRITTEN !!! PLEASE WRITE ME !!!" diff --git a/src/gui/configwin.h b/src/gui/configwin.h deleted file mode 100644 index 4f09095..0000000 --- a/src/gui/configwin.h +++ /dev/null @@ -1,13 +0,0 @@ -// -// configwin.h - Configuration window -// -// by James L. Hammons -// (C) 2010 Underground Software -// - -#ifndef __CONFIGWIN_H__ -#define __CONFIGWIN_H__ - - - -#endif // __CONFIGWIN_H__ diff --git a/src/gui/controllertab.cpp b/src/gui/controllertab.cpp new file mode 100644 index 0000000..036855f --- /dev/null +++ b/src/gui/controllertab.cpp @@ -0,0 +1,76 @@ +// +// controllertab.cpp: "Controller" tab on the config dialog +// +// Part of the Virtual Jaguar Project +// (C) 2011 Underground Software +// See the README and GPLv3 files for licensing and warranty information +// +// JLH = James L. Hammons +// +// WHO WHEN WHAT +// --- ---------- ------------------------------------------------------------ +// JLH 06/23/2011 Created this file + +#include "controllertab.h" + + +ControllerTab::ControllerTab(QWidget * parent/*= 0*/): QWidget(parent) +{ + QLabel * img = new QLabel; + img->setPixmap(QPixmap(":/res/controller.png")); + + QVBoxLayout * layout = new QVBoxLayout; + layout->addWidget(img); + setLayout(layout); +} + +ControllerTab::~ControllerTab() +{ +} + +#if 0 + // Keybindings in order of U, D, L, R, C, B, A, Op, Pa, 0-9, #, * + vjs.p1KeyBindings[BUTTON_U] = settings.value("p1k_up", Qt::Key_Up).toInt(); + vjs.p1KeyBindings[BUTTON_D] = settings.value("p1k_down", Qt::Key_Down).toInt(); + vjs.p1KeyBindings[BUTTON_L] = settings.value("p1k_left", Qt::Key_Left).toInt(); + vjs.p1KeyBindings[BUTTON_R] = settings.value("p1k_right", Qt::Key_Right).toInt(); + vjs.p1KeyBindings[BUTTON_C] = settings.value("p1k_c", Qt::Key_Z).toInt(); + vjs.p1KeyBindings[BUTTON_B] = settings.value("p1k_b", Qt::Key_X).toInt(); + vjs.p1KeyBindings[BUTTON_A] = settings.value("p1k_a", Qt::Key_C).toInt(); + vjs.p1KeyBindings[BUTTON_OPTION] = settings.value("p1k_option", Qt::Key_Apostrophe).toInt(); + vjs.p1KeyBindings[BUTTON_PAUSE] = settings.value("p1k_pause", Qt::Key_Return).toInt(); + vjs.p1KeyBindings[BUTTON_0] = settings.value("p1k_0", Qt::Key_0).toInt(); + vjs.p1KeyBindings[BUTTON_1] = settings.value("p1k_1", Qt::Key_1).toInt(); + vjs.p1KeyBindings[BUTTON_2] = settings.value("p1k_2", Qt::Key_2).toInt(); + vjs.p1KeyBindings[BUTTON_3] = settings.value("p1k_3", Qt::Key_3).toInt(); + vjs.p1KeyBindings[BUTTON_4] = settings.value("p1k_4", Qt::Key_4).toInt(); + vjs.p1KeyBindings[BUTTON_5] = settings.value("p1k_5", Qt::Key_5).toInt(); + vjs.p1KeyBindings[BUTTON_6] = settings.value("p1k_6", Qt::Key_6).toInt(); + vjs.p1KeyBindings[BUTTON_7] = settings.value("p1k_7", Qt::Key_7).toInt(); + vjs.p1KeyBindings[BUTTON_8] = settings.value("p1k_8", Qt::Key_8).toInt(); + vjs.p1KeyBindings[BUTTON_9] = settings.value("p1k_9", Qt::Key_9).toInt(); + vjs.p1KeyBindings[BUTTON_d] = settings.value("p1k_pound", Qt::Key_Slash).toInt(); + vjs.p1KeyBindings[BUTTON_s] = settings.value("p1k_star", Qt::Key_Asterisk).toInt(); + + vjs.p2KeyBindings[BUTTON_U] = settings.value("p2k_up", Qt::Key_Up).toInt(); + vjs.p2KeyBindings[BUTTON_D] = settings.value("p2k_down", Qt::Key_Down).toInt(); + vjs.p2KeyBindings[BUTTON_L] = settings.value("p2k_left", Qt::Key_Left).toInt(); + vjs.p2KeyBindings[BUTTON_R] = settings.value("p2k_right", Qt::Key_Right).toInt(); + vjs.p2KeyBindings[BUTTON_C] = settings.value("p2k_c", Qt::Key_Z).toInt(); + vjs.p2KeyBindings[BUTTON_B] = settings.value("p2k_b", Qt::Key_X).toInt(); + vjs.p2KeyBindings[BUTTON_A] = settings.value("p2k_a", Qt::Key_C).toInt(); + vjs.p2KeyBindings[BUTTON_OPTION] = settings.value("p2k_option", Qt::Key_Apostrophe).toInt(); + vjs.p2KeyBindings[BUTTON_PAUSE] = settings.value("p2k_pause", Qt::Key_Return).toInt(); + vjs.p2KeyBindings[BUTTON_0] = settings.value("p2k_0", Qt::Key_0).toInt(); + vjs.p2KeyBindings[BUTTON_1] = settings.value("p2k_1", Qt::Key_1).toInt(); + vjs.p2KeyBindings[BUTTON_2] = settings.value("p2k_2", Qt::Key_2).toInt(); + vjs.p2KeyBindings[BUTTON_3] = settings.value("p2k_3", Qt::Key_3).toInt(); + vjs.p2KeyBindings[BUTTON_4] = settings.value("p2k_4", Qt::Key_4).toInt(); + vjs.p2KeyBindings[BUTTON_5] = settings.value("p2k_5", Qt::Key_5).toInt(); + vjs.p2KeyBindings[BUTTON_6] = settings.value("p2k_6", Qt::Key_6).toInt(); + vjs.p2KeyBindings[BUTTON_7] = settings.value("p2k_7", Qt::Key_7).toInt(); + vjs.p2KeyBindings[BUTTON_8] = settings.value("p2k_8", Qt::Key_8).toInt(); + vjs.p2KeyBindings[BUTTON_9] = settings.value("p2k_9", Qt::Key_9).toInt(); + vjs.p2KeyBindings[BUTTON_d] = settings.value("p2k_pound", Qt::Key_Slash).toInt(); + vjs.p2KeyBindings[BUTTON_s] = settings.value("p2k_star", Qt::Key_Asterisk).toInt(); +#endif diff --git a/src/gui/controllertab.h b/src/gui/controllertab.h new file mode 100644 index 0000000..ceff5bf --- /dev/null +++ b/src/gui/controllertab.h @@ -0,0 +1,18 @@ +#ifndef __CONTROLLERTAB_H__ +#define __CONTROLLERTAB_H__ + +#include + +class ControllerTab: public QWidget +{ + Q_OBJECT + + public: + ControllerTab(QWidget * parent = 0); + ~ControllerTab(); + + public: + QCheckBox * antialiasChk; +}; + +#endif // __CONTROLLERTAB_H__ diff --git a/src/gui/generaltab.cpp b/src/gui/generaltab.cpp new file mode 100644 index 0000000..8cc7441 --- /dev/null +++ b/src/gui/generaltab.cpp @@ -0,0 +1,73 @@ +// +// generaltab.cpp: "General" tab on the settings dialog +// +// Part of the Virtual Jaguar Project +// (C) 2011 Underground Software +// See the README and GPLv3 files for licensing and warranty information +// +// JLH = James L. Hammons +// +// WHO WHEN WHAT +// --- ---------- ------------------------------------------------------------ +// JLH 06/23/2011 Created this file + +#include "generaltab.h" + + +GeneralTab::GeneralTab(QWidget * parent/*= 0*/): QWidget(parent) +{ +// antialiasChk = new QCheckBox(tr("Use Qt's built-in antialiasing")); + +// I'm thinking we should scan the bios folder for the 5 known BIOSes, and +// just present a radio button to choose between them... + QLabel * label1 = new QLabel("Boot ROM:"); + QLabel * label2 = new QLabel("CD Boot ROM:"); + QLabel * label3 = new QLabel("EEPROMs:"); + QLabel * label4 = new QLabel("Software:"); + + edit1 = new QLineEdit(""); + edit2 = new QLineEdit(""); + edit3 = new QLineEdit(""); + edit4 = new QLineEdit(""); + edit1->setPlaceholderText("Boot ROM location"); + edit2->setPlaceholderText("CD Boot ROM location"); + edit3->setPlaceholderText("EEPROM path"); + edit4->setPlaceholderText("Software path"); + + QVBoxLayout * layout1 = new QVBoxLayout; + layout1->addWidget(label1); + layout1->addWidget(label2); + layout1->addWidget(label3); + layout1->addWidget(label4); + + QVBoxLayout * layout2 = new QVBoxLayout; + layout2->addWidget(edit1); + layout2->addWidget(edit2); + layout2->addWidget(edit3); + layout2->addWidget(edit4); + + QHBoxLayout * layout3 = new QHBoxLayout; + layout3->addLayout(layout1); + layout3->addLayout(layout2); + + setLayout(layout3); +} + +GeneralTab::~GeneralTab() +{ +} + +#if 0 + vjs.useJoystick = settings.value("useJoystick", false).toBool(); + vjs.joyport = settings.value("joyport", 0).toInt(); + vjs.frameSkip = settings.value("frameSkip", 0).toInt(); + vjs.useJaguarBIOS = settings.value("useJaguarBIOS", false).toBool(); + vjs.DSPEnabled = settings.value("DSPEnabled", false).toBool(); + vjs.usePipelinedDSP = settings.value("usePipelinedDSP", false).toBool(); + vjs.fullscreen = settings.value("fullscreen", false).toBool(); + vjs.renderType = settings.value("renderType", 0).toInt(); + strcpy(vjs.jagBootPath, settings.value("JagBootROM", "./bios/[BIOS] Atari Jaguar (USA, Europe).zip").toString().toAscii().data()); + strcpy(vjs.CDBootPath, settings.value("CDBootROM", "./bios/jagcd.rom").toString().toAscii().data()); + strcpy(vjs.EEPROMPath, settings.value("EEPROMs", "./eeproms").toString().toAscii().data()); + strcpy(vjs.ROMPath, settings.value("ROMs", "./software").toString().toAscii().data()); +#endif diff --git a/src/gui/generaltab.h b/src/gui/generaltab.h new file mode 100644 index 0000000..07129dc --- /dev/null +++ b/src/gui/generaltab.h @@ -0,0 +1,21 @@ +#ifndef __GENERALTAB_H__ +#define __GENERALTAB_H__ + +#include + +class GeneralTab: public QWidget +{ + Q_OBJECT + + public: + GeneralTab(QWidget * parent = 0); + ~GeneralTab(); + + public: + QLineEdit * edit1; + QLineEdit * edit2; + QLineEdit * edit3; + QLineEdit * edit4; +}; + +#endif // __GENERALTAB_H__ diff --git a/src/gui/mainwin.cpp b/src/gui/mainwin.cpp index 1435d97..26488f8 100644 --- a/src/gui/mainwin.cpp +++ b/src/gui/mainwin.cpp @@ -32,6 +32,7 @@ #include "about.h" #include "settings.h" #include "filepicker.h" +#include "configdialog.h" #include "jaguar.h" #include "video.h" @@ -146,6 +147,10 @@ MainWin::MainWin(): running(false), powerButtonOn(false), showUntunedTankCircuit filePickAct->setStatusTip(tr("Insert a cartridge into Virtual Jaguar")); connect(filePickAct, SIGNAL(triggered()), this, SLOT(InsertCart())); + configAct = new QAction(QIcon(":/res/generic.png"), tr("&Configure"), this); + configAct->setStatusTip(tr("Configure options for Virtual Jaguar")); + connect(configAct, SIGNAL(triggered()), this, SLOT(Configure())); + // Misc. connections... connect(filePickWin, SIGNAL(RequestLoad(QString)), this, SLOT(LoadSoftware(QString))); @@ -155,6 +160,7 @@ MainWin::MainWin(): running(false), powerButtonOn(false), showUntunedTankCircuit fileMenu->addAction(filePickAct); fileMenu->addAction(powerAct); fileMenu->addAction(pauseAct); + fileMenu->addAction(configAct); fileMenu->addAction(quitAppAct); helpMenu = menuBar()->addMenu(tr("&Help")); @@ -294,6 +300,17 @@ void MainWin::Open(void) { } +void MainWin::Configure(void) +{ + // Call the configuration dialog and update settings + ConfigDialog dlg(this); + + if (dlg.exec() == false) + return; + + dlg.UpdateVJSettings(); +} + // // Here's the main emulator loop // diff --git a/src/gui/mainwin.h b/src/gui/mainwin.h index 2b332d3..52ae4cb 100644 --- a/src/gui/mainwin.h +++ b/src/gui/mainwin.h @@ -31,6 +31,7 @@ class MainWin: public QMainWindow private slots: void Open(void); + void Configure(void); void Timer(void); void TogglePowerState(void); void ToggleRunState(void); @@ -79,6 +80,7 @@ class MainWin: public QMainWindow QAction * blurAct; QAction * aboutAct; QAction * filePickAct; + QAction * configAct; }; #endif // __MAINWIN_H__ diff --git a/src/gui/virtualjaguar.pro b/src/gui/virtualjaguar.pro index ece4f81..8d937af 100644 --- a/src/gui/virtualjaguar.pro +++ b/src/gui/virtualjaguar.pro @@ -12,7 +12,8 @@ HEADERS += glwidget.h HEADERS += about.h HEADERS += filepicker.h HEADERS += filethread.h -HEADERS += configwin.h +HEADERS += configdialog.h +HEADERS += generaltab.h SOURCES += app.cpp SOURCES += mainwin.cpp @@ -20,7 +21,8 @@ SOURCES += glwidget.cpp SOURCES += about.cpp SOURCES += filepicker.cpp SOURCES += filethread.cpp -SOURCES += configwin.cpp +SOURCES += configdialog.cpp +SOURCES += generaltab.cpp RESOURCES += virtualjaguar.qrc -- 2.37.2