| 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 | // JPM = Jean-Paul Mari <djipi.mari@gmail.com> |
| 9 | // |
| 10 | // Who When What |
| 11 | // --- ---------- ------------------------------------------------------------ |
| 12 | // JLH 01/29/2010 Created this file |
| 13 | // JLH 06/23/2011 Added initial implementation |
| 14 | // JLH 10/14/2011 Fixed possibly missing final slash in paths |
| 15 | // JPM 06/06/2016 Visual Studio support |
| 16 | // JPM 06/19/2016 Soft debugger support |
| 17 | // |
| 18 | |
| 19 | #include "configdialog.h" |
| 20 | |
| 21 | #include "alpinetab.h" |
| 22 | #include "debugger/debuggertab.h" |
| 23 | #include "controllertab.h" |
| 24 | #include "controllerwidget.h" |
| 25 | #include "generaltab.h" |
| 26 | #include "settings.h" |
| 27 | |
| 28 | |
| 29 | ConfigDialog::ConfigDialog(QWidget * parent/*= 0*/): QDialog(parent), |
| 30 | tabWidget(new QTabWidget), |
| 31 | generalTab(new GeneralTab(this)), |
| 32 | controllerTab1(new ControllerTab(this)) |
| 33 | { |
| 34 | // tabWidget = new QTabWidget; |
| 35 | // generalTab = new GeneralTab(this); |
| 36 | // controllerTab1 = new ControllerTab(this); |
| 37 | //// controllerTab2 = new ControllerTab(this); |
| 38 | |
| 39 | // if (vjs.hardwareTypeAlpine) |
| 40 | // alpineTab = new AlpineTab(this); |
| 41 | |
| 42 | tabWidget->addTab(generalTab, tr("General")); |
| 43 | tabWidget->addTab(controllerTab1, tr("Controllers")); |
| 44 | // tabWidget->addTab(controllerTab2, tr("Controller #2")); |
| 45 | |
| 46 | if (vjs.hardwareTypeAlpine || vjs.softTypeDebugger) |
| 47 | { |
| 48 | alpineTab = new AlpineTab(this); |
| 49 | tabWidget->addTab(alpineTab, tr("Alpine")); |
| 50 | } |
| 51 | |
| 52 | if (vjs.softTypeDebugger) |
| 53 | { |
| 54 | debuggerTab = new DebuggerTab(this); |
| 55 | tabWidget->addTab(debuggerTab, tr("Debugger")); |
| 56 | } |
| 57 | |
| 58 | buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); |
| 59 | |
| 60 | connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); |
| 61 | connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); |
| 62 | |
| 63 | QVBoxLayout * mainLayout = new QVBoxLayout; |
| 64 | mainLayout->addWidget(tabWidget); |
| 65 | mainLayout->addWidget(buttonBox); |
| 66 | setLayout(mainLayout); |
| 67 | |
| 68 | setWindowTitle(tr("Virtual Jaguar Settings")); |
| 69 | LoadDialogFromSettings(); |
| 70 | } |
| 71 | |
| 72 | |
| 73 | ConfigDialog::~ConfigDialog() |
| 74 | { |
| 75 | } |
| 76 | |
| 77 | |
| 78 | void ConfigDialog::LoadDialogFromSettings(void) |
| 79 | { |
| 80 | // generalTab->edit1->setText(vjs.jagBootPath); |
| 81 | // generalTab->edit2->setText(vjs.CDBootPath); |
| 82 | generalTab->edit3->setText(vjs.EEPROMPath); |
| 83 | generalTab->edit4->setText(vjs.ROMPath); |
| 84 | |
| 85 | generalTab->useBIOS->setChecked(vjs.useJaguarBIOS); |
| 86 | generalTab->useGPU->setChecked(vjs.GPUEnabled); |
| 87 | generalTab->useDSP->setChecked(vjs.DSPEnabled); |
| 88 | generalTab->useFullScreen->setChecked(vjs.fullscreen); |
| 89 | // generalTab->useHostAudio->setChecked(vjs.audioEnabled); |
| 90 | generalTab->useFastBlitter->setChecked(vjs.useFastBlitter); |
| 91 | |
| 92 | if (vjs.hardwareTypeAlpine || vjs.softTypeDebugger) |
| 93 | { |
| 94 | QVariant v(vjs.refresh); |
| 95 | alpineTab->edit1->setText(vjs.alpineROMPath); |
| 96 | alpineTab->edit2->setText(vjs.absROMPath); |
| 97 | alpineTab->edit3->setText(v.toString()); |
| 98 | alpineTab->writeROM->setChecked(vjs.allowWritesToROM); |
| 99 | } |
| 100 | |
| 101 | if (vjs.softTypeDebugger) |
| 102 | { |
| 103 | QVariant v(vjs.nbrdisasmlines); |
| 104 | //debuggerTab->edit1->setText(vjs.debuggerROMPath); |
| 105 | //debuggerTab->edit2->setText(vjs.absROMPath); |
| 106 | debuggerTab->edit3->setText(v.toString()); |
| 107 | //debuggerTab->writeROM->setChecked(vjs.allowWritesToROM |
| 108 | debuggerTab->displayHWlabels->setChecked(vjs.displayHWlabels); |
| 109 | debuggerTab->disasmopcodes->setChecked(vjs.disasmopcodes); |
| 110 | debuggerTab->displayFullSourceFilename->setChecked(vjs.displayFullSourceFilename); |
| 111 | } |
| 112 | |
| 113 | #ifdef _MSC_VER |
| 114 | #pragma message("Warning: !!! Need to load settings from controller profile !!!") |
| 115 | #else |
| 116 | #warning "!!! Need to load settings from controller profile !!!" |
| 117 | #endif // _MSC_VER |
| 118 | // We do this now, but not here. Need to fix this... |
| 119 | #if 0 |
| 120 | for(int i=0; i<21; i++) |
| 121 | { |
| 122 | // We need to find the right profile and load it up here... |
| 123 | controllerTab1->controllerWidget->keys[i] = vjs.p1KeyBindings[i]; |
| 124 | // controllerTab2->controllerWidget->keys[i] = vjs.p2KeyBindings[i]; |
| 125 | } |
| 126 | #endif |
| 127 | } |
| 128 | |
| 129 | |
| 130 | void ConfigDialog::UpdateVJSettings(void) |
| 131 | { |
| 132 | bool ok; |
| 133 | |
| 134 | // strcpy(vjs.jagBootPath, generalTab->edit1->text().toAscii().data()); |
| 135 | // strcpy(vjs.CDBootPath, generalTab->edit2->text().toAscii().data()); |
| 136 | strcpy(vjs.EEPROMPath, CheckForTrailingSlash( |
| 137 | generalTab->edit3->text()).toUtf8().data()); |
| 138 | strcpy(vjs.ROMPath, CheckForTrailingSlash( |
| 139 | generalTab->edit4->text()).toUtf8().data()); |
| 140 | |
| 141 | vjs.useJaguarBIOS = generalTab->useBIOS->isChecked(); |
| 142 | vjs.GPUEnabled = generalTab->useGPU->isChecked(); |
| 143 | vjs.DSPEnabled = generalTab->useDSP->isChecked(); |
| 144 | vjs.fullscreen = generalTab->useFullScreen->isChecked(); |
| 145 | // vjs.audioEnabled = generalTab->useHostAudio->isChecked(); |
| 146 | vjs.useFastBlitter = generalTab->useFastBlitter->isChecked(); |
| 147 | |
| 148 | if (vjs.hardwareTypeAlpine || vjs.softTypeDebugger) |
| 149 | { |
| 150 | strcpy(vjs.alpineROMPath, alpineTab->edit1->text().toUtf8().data()); |
| 151 | strcpy(vjs.absROMPath, alpineTab->edit2->text().toUtf8().data()); |
| 152 | vjs.refresh = alpineTab->edit3->text().toUInt(&ok, 10); |
| 153 | vjs.allowWritesToROM = alpineTab->writeROM->isChecked(); |
| 154 | } |
| 155 | |
| 156 | if (vjs.softTypeDebugger) |
| 157 | { |
| 158 | //strcpy(vjs.debuggerROMPath, debuggerTab->edit1->text().toUtf8().data()); |
| 159 | //strcpy(vjs.absROMPath, debuggerTab->edit2->text().toUtf8().data()); |
| 160 | vjs.nbrdisasmlines = debuggerTab->edit3->text().toUInt(&ok, 10); |
| 161 | //vjs.allowWritesToROM = debuggerTab->writeROM->isChecked(); |
| 162 | vjs.displayHWlabels = debuggerTab->displayHWlabels->isChecked(); |
| 163 | vjs.disasmopcodes = debuggerTab->disasmopcodes->isChecked(); |
| 164 | vjs.displayFullSourceFilename = debuggerTab->displayFullSourceFilename->isChecked(); |
| 165 | } |
| 166 | |
| 167 | #ifdef _MSC_VER |
| 168 | #pragma message("Warning: !!! Need to save settings to controller profile !!!") |
| 169 | #else |
| 170 | #warning "!!! Need to save settings to controller profile !!!" |
| 171 | #endif // _MSC_VER |
| 172 | // We do this now, but not here. Need to fix this... |
| 173 | #if 0 |
| 174 | for(int i=0; i<21; i++) |
| 175 | { |
| 176 | // We need to find the right profile and load it up here... |
| 177 | vjs.p1KeyBindings[i] = controllerTab1->controllerWidget->keys[i]; |
| 178 | // vjs.p2KeyBindings[i] = controllerTab2->controllerWidget->keys[i]; |
| 179 | } |
| 180 | #endif |
| 181 | } |
| 182 | |
| 183 | |
| 184 | QString ConfigDialog::CheckForTrailingSlash(QString s) |
| 185 | { |
| 186 | if (!s.endsWith('/') && !s.endsWith('\\')) |
| 187 | s.append('/'); |
| 188 | |
| 189 | return s; |
| 190 | } |