817818ef72676c2423fc75e8cd0442e1903e73ab
[clinton/Virtual-Jaguar-Rx.git] / src / gui / generaltab.cpp
1 //
2 // generaltab.cpp: "General" tab on the settings dialog
3 //
4 // Part of the Virtual Jaguar Project
5 // (C) 2011 Underground Software
6 // See the README and GPLv3 files for licensing and warranty information
7 //
8 // JLH = James Hammons <jlhamm@acm.org>
9 // JPM = Jean-Paul Mari <djipi.mari@gmail.com>
10 //
11 // WHO WHEN WHAT
12 // --- ---------- ------------------------------------------------------------
13 // JLH 06/23/2011 Created this file
14 // JPM 09/03/2018 Added a Models & Bios tab
15 // JPM 09/03/2018 Depend the platform transform slashes or backslashes
16 //
17
18 #include "configdialog.h"
19 #include "generaltab.h"
20 #include "settings.h"
21
22
23 //
24 GeneralTab::GeneralTab(QWidget * parent/*= 0*/): QWidget(parent)
25 {
26 // I'm thinking we should scan the bios folder for the 5 known BIOSes, and
27 // just present a radio button to choose between them...
28 // (BIOS is built-in now...)
29 // QLabel * label1 = new QLabel("Boot ROM:");
30 // QLabel * label2 = new QLabel("CD Boot ROM:");
31 QLabel * label3 = new QLabel("EEPROMs:");
32 QLabel * label4 = new QLabel("Software:");
33
34 // edit1 = new QLineEdit("");
35 // edit2 = new QLineEdit("");
36 edit3 = new QLineEdit("");
37 edit4 = new QLineEdit("");
38 // edit1->setPlaceholderText("Boot ROM location");
39 // edit2->setPlaceholderText("CD Boot ROM location");
40 edit3->setPlaceholderText("EEPROM path");
41 edit4->setPlaceholderText("Software path");
42
43 QVBoxLayout * layout1 = new QVBoxLayout;
44 // layout1->addWidget(label1);
45 // layout1->addWidget(label2);
46 layout1->addWidget(label3);
47 layout1->addWidget(label4);
48
49 QVBoxLayout * layout2 = new QVBoxLayout;
50 // layout2->addWidget(edit1);
51 // layout2->addWidget(edit2);
52 layout2->addWidget(edit3);
53 layout2->addWidget(edit4);
54
55 QHBoxLayout * layout3 = new QHBoxLayout;
56 layout3->addLayout(layout1);
57 layout3->addLayout(layout2);
58
59 QVBoxLayout * layout4 = new QVBoxLayout;
60 layout4->addLayout(layout3);
61
62 // Checkboxes...
63 #ifndef NEWMODELSBIOSHANDLER
64 useBIOS = new QCheckBox(tr("Enable Jaguar BIOS"));
65 #endif
66 useGPU = new QCheckBox(tr("Enable GPU"));
67 useDSP = new QCheckBox(tr("Enable DSP"));
68 useFullScreen = new QCheckBox(tr("Start Virtual Jaguar in full screen"));
69 // useHostAudio = new QCheckBox(tr("Enable audio playback (requires DSP)"));
70 useUnknownSoftware = new QCheckBox(tr("Show all files in file chooser"));
71 useFastBlitter = new QCheckBox(tr("Use fast blitter"));
72
73 #ifndef NEWMODELSBIOSHANDLER
74 layout4->addWidget(useBIOS);
75 #endif
76 layout4->addWidget(useGPU);
77 layout4->addWidget(useDSP);
78 layout4->addWidget(useFullScreen);
79 // layout4->addWidget(useHostAudio);
80 layout4->addWidget(useUnknownSoftware);
81 layout4->addWidget(useFastBlitter);
82
83 setLayout(layout4);
84 }
85
86
87 //
88 GeneralTab::~GeneralTab()
89 {
90 }
91
92
93 // Load / Update the tabs dialog from the settings
94 void GeneralTab::GetSettings(void)
95 {
96 // generalTab->edit1->setText(vjs.jagBootPath);
97 // generalTab->edit2->setText(vjs.CDBootPath);
98 edit3->setText(vjs.EEPROMPath);
99 edit4->setText(vjs.ROMPath);
100 #ifndef NEWMODELSBIOSHANDLER
101 useBIOS->setChecked(vjs.useJaguarBIOS);
102 #endif
103 useGPU->setChecked(vjs.GPUEnabled);
104 useDSP->setChecked(vjs.DSPEnabled);
105 useFullScreen->setChecked(vjs.fullscreen);
106 // generalTab->useHostAudio->setChecked(vjs.audioEnabled);
107 useFastBlitter->setChecked(vjs.useFastBlitter);
108 }
109
110
111 // Save & Update the settings from the tabs dialog
112 void GeneralTab::SetSettings(void)
113 {
114 // strcpy(vjs.jagBootPath, generalTab->edit1->text().toAscii().data());
115 // strcpy(vjs.CDBootPath, generalTab->edit2->text().toAscii().data());
116 strcpy(vjs.EEPROMPath, CheckForTrailingSlash(edit3->text()).toUtf8().data());
117 strcpy(vjs.ROMPath, CheckForTrailingSlash(edit4->text()).toUtf8().data());
118
119 #ifndef NEWMODELSBIOSHANDLER
120 vjs.useJaguarBIOS = useBIOS->isChecked();
121 #endif
122 vjs.GPUEnabled = useGPU->isChecked();
123 vjs.DSPEnabled = useDSP->isChecked();
124 vjs.fullscreen = useFullScreen->isChecked();
125 // vjs.audioEnabled = generalTab->useHostAudio->isChecked();
126 vjs.useFastBlitter = useFastBlitter->isChecked();
127 }
128
129
130 // Append a slash or a backslash at the end of the string
131 // Depend the platform transform slashes or backslashes
132 QString GeneralTab::CheckForTrailingSlash(QString s)
133 {
134 if (!s.endsWith('/') && !s.endsWith('\\'))
135 {
136 s.append('/');
137 }
138 #ifdef _WIN32
139 s.replace(QString("/"), QString("\\"));
140 #else
141 s.replace(QString("\\"), QString("/"));
142 #endif
143 return s;
144 }
145
146
147 #if 0
148 vjs.useJoystick = settings.value("useJoystick", false).toBool();
149 vjs.joyport = settings.value("joyport", 0).toInt();
150 vjs.frameSkip = settings.value("frameSkip", 0).toInt();
151 vjs.useJaguarBIOS = settings.value("useJaguarBIOS", false).toBool();
152 vjs.DSPEnabled = settings.value("DSPEnabled", false).toBool();
153 vjs.usePipelinedDSP = settings.value("usePipelinedDSP", false).toBool();
154 vjs.fullscreen = settings.value("fullscreen", false).toBool();
155 vjs.renderType = settings.value("renderType", 0).toInt();
156 strcpy(vjs.jagBootPath, settings.value("JagBootROM", "./bios/[BIOS] Atari Jaguar (USA, Europe).zip").toString().toAscii().data());
157 strcpy(vjs.CDBootPath, settings.value("CDBootROM", "./bios/jagcd.rom").toString().toAscii().data());
158 strcpy(vjs.EEPROMPath, settings.value("EEPROMs", "./eeproms").toString().toAscii().data());
159 strcpy(vjs.ROMPath, settings.value("ROMs", "./software").toString().toAscii().data());
160 #endif