]> Shamusworld >> Repos - virtualjaguar/blob - src/gui/configdialog.cpp
Hooked up the UI/frontend controller #2 to the Jaguar core, final fixes to the
[virtualjaguar] / src / gui / configdialog.cpp
1 //
2 // configdialog.cpp - Configuration dialog
3 //
4 // by James L. Hammons
5 // (C) 2010 Underground Software
6 //
7 // JLH = James L. Hammons <jlhamm@acm.org>
8 //
9 // Who  When        What
10 // ---  ----------  -------------------------------------------------------------
11 // JLH  01/29/2010  Created this file
12 // JLH  06/23/2011  Added initial implementation
13 //
14
15 #include "configdialog.h"
16
17 #include "alpinetab.h"
18 #include "controllertab.h"
19 #include "controllerwidget.h"
20 #include "generaltab.h"
21 #include "settings.h"
22
23
24 ConfigDialog::ConfigDialog(QWidget * parent/*= 0*/): QDialog(parent)
25 {
26         tabWidget = new QTabWidget;
27         generalTab = new GeneralTab(this);
28         controllerTab1 = new ControllerTab(this);
29         controllerTab2 = new ControllerTab(this);
30
31         if (vjs.hardwareTypeAlpine)
32                 alpineTab = new AlpineTab(this);
33
34         tabWidget->addTab(generalTab, tr("General"));
35         tabWidget->addTab(controllerTab1, tr("Controller #1"));
36         tabWidget->addTab(controllerTab2, tr("Controller #2"));
37
38         if (vjs.hardwareTypeAlpine)
39                 tabWidget->addTab(alpineTab, tr("Alpine"));
40
41         buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
42
43         connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
44         connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
45
46         QVBoxLayout * mainLayout = new QVBoxLayout;
47         mainLayout->addWidget(tabWidget);
48         mainLayout->addWidget(buttonBox);
49         setLayout(mainLayout);
50
51         setWindowTitle(tr("Virtual Jaguar Settings"));
52
53         LoadDialogFromSettings();
54 //      controllerTab1->UpdateLabel();                          // Now it's safe to do this... ;-)
55 //      controllerTab2->UpdateLabel();                          // Now it's safe to do this... ;-)
56 }
57
58 ConfigDialog::~ConfigDialog()
59 {
60 }
61
62 void ConfigDialog::LoadDialogFromSettings(void)
63 {
64         generalTab->edit1->setText(vjs.jagBootPath);
65         generalTab->edit2->setText(vjs.CDBootPath);
66         generalTab->edit3->setText(vjs.EEPROMPath);
67         generalTab->edit4->setText(vjs.ROMPath);
68
69         generalTab->useBIOS->setChecked(vjs.useJaguarBIOS);
70         generalTab->useDSP->setChecked(vjs.DSPEnabled);
71         generalTab->useHostAudio->setChecked(vjs.audioEnabled);
72
73         if (vjs.hardwareTypeAlpine)
74         {
75                 alpineTab->edit1->setText(vjs.alpineROMPath);
76                 alpineTab->edit2->setText(vjs.absROMPath);
77                 alpineTab->writeROM->setChecked(vjs.allowWritesToROM);
78         }
79
80         for(int i=0; i<21; i++)
81         {
82 //              controllerTab1->p1Keys[i] = vjs.p1KeyBindings[i];
83 //              controllerTab2->p1Keys[i] = vjs.p2KeyBindings[i];
84                 controllerTab1->controllerWidget->keys[i] = vjs.p1KeyBindings[i];
85                 controllerTab2->controllerWidget->keys[i] = vjs.p2KeyBindings[i];
86         }
87 }
88
89 void ConfigDialog::UpdateVJSettings(void)
90 {
91         strcpy(vjs.jagBootPath, generalTab->edit1->text().toAscii().data());
92         strcpy(vjs.CDBootPath,  generalTab->edit2->text().toAscii().data());
93         strcpy(vjs.EEPROMPath,  generalTab->edit3->text().toAscii().data());
94         strcpy(vjs.ROMPath,     generalTab->edit4->text().toAscii().data());
95
96         vjs.useJaguarBIOS = generalTab->useBIOS->isChecked();
97         vjs.DSPEnabled    = generalTab->useDSP->isChecked();
98         vjs.audioEnabled  = generalTab->useHostAudio->isChecked();
99
100         if (vjs.hardwareTypeAlpine)
101         {
102                 strcpy(vjs.alpineROMPath, alpineTab->edit1->text().toAscii().data());
103                 strcpy(vjs.absROMPath,    alpineTab->edit2->text().toAscii().data());
104                 vjs.allowWritesToROM = alpineTab->writeROM->isChecked();
105         }
106
107         for(int i=0; i<21; i++)
108         {
109 //              vjs.p1KeyBindings[i] = controllerTab1->p1Keys[i];
110 //              vjs.p2KeyBindings[i] = controllerTab2->p1Keys[i];
111                 vjs.p1KeyBindings[i] = controllerTab1->controllerWidget->keys[i];
112                 vjs.p2KeyBindings[i] = controllerTab2->controllerWidget->keys[i];
113         }
114 }