]> Shamusworld >> Repos - virtualjaguar/blob - src/gui/configdialog.cpp
Fixed updated joystick handling, first major stab at gamepad profiles.
[virtualjaguar] / src / gui / configdialog.cpp
1 //
2 // configdialog.cpp - Configuration dialog
3 //
4 // by James Hammons
5 // (C) 2010 Underground Software
6 //
7 // JLH = James 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 // JLH  10/14/2011  Fixed possibly missing final slash in paths
14 //
15
16 #include "configdialog.h"
17
18 #include "alpinetab.h"
19 #include "controllertab.h"
20 #include "controllerwidget.h"
21 #include "generaltab.h"
22 #include "settings.h"
23
24
25 ConfigDialog::ConfigDialog(QWidget * parent/*= 0*/): QDialog(parent),
26         tabWidget(new QTabWidget),
27         generalTab(new GeneralTab(this)),
28         controllerTab1(new ControllerTab(this))
29 {
30 //      tabWidget = new QTabWidget;
31 //      generalTab = new GeneralTab(this);
32 //      controllerTab1 = new ControllerTab(this);
33 ////    controllerTab2 = new ControllerTab(this);
34
35 //      if (vjs.hardwareTypeAlpine)
36 //              alpineTab = new AlpineTab(this);
37
38         tabWidget->addTab(generalTab, tr("General"));
39         tabWidget->addTab(controllerTab1, tr("Controllers"));
40 //      tabWidget->addTab(controllerTab2, tr("Controller #2"));
41
42         if (vjs.hardwareTypeAlpine)
43         {
44                 alpineTab = new AlpineTab(this);
45                 tabWidget->addTab(alpineTab, tr("Alpine"));
46         }
47
48         buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
49
50         connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
51         connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
52
53         QVBoxLayout * mainLayout = new QVBoxLayout;
54         mainLayout->addWidget(tabWidget);
55         mainLayout->addWidget(buttonBox);
56         setLayout(mainLayout);
57
58         setWindowTitle(tr("Virtual Jaguar Settings"));
59         LoadDialogFromSettings();
60 }
61
62
63 ConfigDialog::~ConfigDialog()
64 {
65 }
66
67
68 void ConfigDialog::LoadDialogFromSettings(void)
69 {
70 //      generalTab->edit1->setText(vjs.jagBootPath);
71 //      generalTab->edit2->setText(vjs.CDBootPath);
72         generalTab->edit3->setText(vjs.EEPROMPath);
73         generalTab->edit4->setText(vjs.ROMPath);
74
75         generalTab->useBIOS->setChecked(vjs.useJaguarBIOS);
76         generalTab->useGPU->setChecked(vjs.GPUEnabled);
77         generalTab->useDSP->setChecked(vjs.DSPEnabled);
78         generalTab->useFullScreen->setChecked(vjs.fullscreen);
79 //      generalTab->useHostAudio->setChecked(vjs.audioEnabled);
80
81         if (vjs.hardwareTypeAlpine)
82         {
83                 alpineTab->edit1->setText(vjs.alpineROMPath);
84                 alpineTab->edit2->setText(vjs.absROMPath);
85                 alpineTab->writeROM->setChecked(vjs.allowWritesToROM);
86         }
87
88 #warning "!!! Need to load settings from controller profile !!!"
89 #if 0
90         for(int i=0; i<21; i++)
91         {
92 // We need to find the right profile and load it up here...
93                 controllerTab1->controllerWidget->keys[i] = vjs.p1KeyBindings[i];
94 //              controllerTab2->controllerWidget->keys[i] = vjs.p2KeyBindings[i];
95         }
96 #endif
97 }
98
99
100 void ConfigDialog::UpdateVJSettings(void)
101 {
102 //      strcpy(vjs.jagBootPath, generalTab->edit1->text().toAscii().data());
103 //      strcpy(vjs.CDBootPath,  generalTab->edit2->text().toAscii().data());
104         strcpy(vjs.EEPROMPath,  CheckForTrailingSlash(
105                 generalTab->edit3->text()).toAscii().data());
106         strcpy(vjs.ROMPath,     CheckForTrailingSlash(
107                 generalTab->edit4->text()).toAscii().data());
108
109         vjs.useJaguarBIOS = generalTab->useBIOS->isChecked();
110         vjs.GPUEnabled    = generalTab->useGPU->isChecked();
111         vjs.DSPEnabled    = generalTab->useDSP->isChecked();
112         vjs.fullscreen    = generalTab->useFullScreen->isChecked();
113 //      vjs.audioEnabled  = generalTab->useHostAudio->isChecked();
114
115         if (vjs.hardwareTypeAlpine)
116         {
117                 strcpy(vjs.alpineROMPath, alpineTab->edit1->text().toAscii().data());
118                 strcpy(vjs.absROMPath,    alpineTab->edit2->text().toAscii().data());
119                 vjs.allowWritesToROM = alpineTab->writeROM->isChecked();
120         }
121
122 #warning "!!! Need to save settings to controller profile !!!"
123         for(int i=0; i<21; i++)
124         {
125 // We need to find the right profile and load it up here...
126                 vjs.p1KeyBindings[i] = controllerTab1->controllerWidget->keys[i];
127 //              vjs.p2KeyBindings[i] = controllerTab2->controllerWidget->keys[i];
128         }
129 }
130
131
132 QString ConfigDialog::CheckForTrailingSlash(QString s)
133 {
134         if (!s.endsWith('/') && !s.endsWith('\\'))
135                 s.append('/');
136
137         return s;
138 }