| 1 |
/* |
| 2 |
* Copyright (C) 2018-2021 Rerrah |
| 3 |
* |
| 4 |
* Permission is hereby granted, free of charge, to any person |
| 5 |
* obtaining a copy of this software and associated documentation |
| 6 |
* files (the "Software"), to deal in the Software without |
| 7 |
* restriction, including without limitation the rights to use, |
| 8 |
* copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 9 |
* copies of the Software, and to permit persons to whom the |
| 10 |
* Software is furnished to do so, subject to the following |
| 11 |
* conditions: |
| 12 |
* |
| 13 |
* The above copyright notice and this permission notice shall be |
| 14 |
* included in all copies or substantial portions of the Software. |
| 15 |
* |
| 16 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 17 |
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
| 18 |
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 19 |
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
| 20 |
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
| 21 |
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 22 |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 23 |
* OTHER DEALINGS IN THE SOFTWARE. |
| 24 |
*/ |
| 25 |
|
| 26 |
#include "s98_export_settings_dialog.hpp" |
| 27 |
#include "ui_s98_export_settings_dialog.h" |
| 28 |
#include "io/export_io.hpp" |
| 29 |
|
| 30 |
S98ExportSettingsDialog::S98ExportSettingsDialog(QWidget *parent) |
| 31 |
: QDialog(parent), |
| 32 |
ui(new Ui::S98ExportSettingsDialog) |
| 33 |
{ |
| 34 |
ui->setupUi(this); |
| 35 |
|
| 36 |
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); |
| 37 |
|
| 38 |
for (QRadioButton *button : { |
| 39 |
ui->ym2608RadioButton, ui->ym2612RadioButton, ui->ym2203RadioButton, ui->noneFmRadioButton, |
| 40 |
ui->internalSsgRadioButton, ui->ay8910PsgRadioButton }) |
| 41 |
connect(button, &QAbstractButton::toggled, |
| 42 |
this, &S98ExportSettingsDialog::updateSupportInformation); |
| 43 |
|
| 44 |
updateSupportInformation(); |
| 45 |
} |
| 46 |
|
| 47 |
S98ExportSettingsDialog::~S98ExportSettingsDialog() |
| 48 |
{ |
| 49 |
delete ui; |
| 50 |
} |
| 51 |
|
| 52 |
int S98ExportSettingsDialog::getResolution() const |
| 53 |
{ |
| 54 |
return ui->resSpinBox->value(); |
| 55 |
} |
| 56 |
|
| 57 |
bool S98ExportSettingsDialog::enabledTag() const |
| 58 |
{ |
| 59 |
return ui->tagGroupBox->isChecked(); |
| 60 |
} |
| 61 |
|
| 62 |
io::S98Tag S98ExportSettingsDialog::getS98Tag() const |
| 63 |
{ |
| 64 |
io::S98Tag tag; |
| 65 |
tag.title = ui->titleLineEdit->text().toUtf8().toStdString(); |
| 66 |
tag.artist = ui->artistLineEdit->text().toUtf8().toStdString(); |
| 67 |
tag.game = ui->gameLineEdit->text().toUtf8().toStdString(); |
| 68 |
tag.year = ui->yearLineEdit->text().toUtf8().toStdString(); |
| 69 |
tag.genre = ui->genreLineEdit->text().toUtf8().toStdString(); |
| 70 |
tag.comment = ui->commentLineEdit->text().toUtf8().toStdString(); |
| 71 |
tag.copyright = ui->copyrightLineEdit->text().toUtf8().toStdString(); |
| 72 |
tag.s98by = ui->s98byLineEdit->text().toUtf8().toStdString(); |
| 73 |
tag.system = ui->systemLineEdit->text().toUtf8().toStdString(); |
| 74 |
return tag; |
| 75 |
} |
| 76 |
|
| 77 |
int S98ExportSettingsDialog::getExportTarget() const |
| 78 |
{ |
| 79 |
int target = 0; |
| 80 |
|
| 81 |
if (ui->ym2608RadioButton->isChecked()) |
| 82 |
target |= io::Export_YM2608; |
| 83 |
else if (ui->ym2612RadioButton->isChecked()) |
| 84 |
target |= io::Export_YM2612; |
| 85 |
else if (ui->ym2203RadioButton->isChecked()) |
| 86 |
target |= io::Export_YM2203; |
| 87 |
|
| 88 |
if (ui->ay8910PsgRadioButton->isChecked()) |
| 89 |
target |= io::Export_AY8910Psg; |
| 90 |
else if (ui->ym2149PsgRadioButton->isChecked()) |
| 91 |
target |= io::Export_YM2149Psg; |
| 92 |
|
| 93 |
return target; |
| 94 |
} |
| 95 |
|
| 96 |
void S98ExportSettingsDialog::updateSupportInformation() |
| 97 |
{ |
| 98 |
int target = getExportTarget(); |
| 99 |
int channels; |
| 100 |
|
| 101 |
int fm = target & io::Export_FmMask; |
| 102 |
int ssg = target & io::Export_SsgMask; |
| 103 |
|
| 104 |
switch (fm) { |
| 105 |
default: |
| 106 |
channels = 6; |
| 107 |
break; |
| 108 |
case io::Export_YM2203: |
| 109 |
channels = 3; |
| 110 |
break; |
| 111 |
case io::Export_NoneFm: |
| 112 |
channels = 0; |
| 113 |
break; |
| 114 |
} |
| 115 |
|
| 116 |
bool haveSsg = fm == io::Export_YM2608 || fm == io::Export_YM2203 || ssg != io::Export_InternalSsg; |
| 117 |
bool haveRhythm = fm == io::Export_YM2608; |
| 118 |
bool haveAdpcm = fm == io::Export_YM2608; |
| 119 |
|
| 120 |
ui->supportFmChannelsLabel->setText(QString::number(channels)); |
| 121 |
ui->supportSsgLabel->setText(haveSsg ? tr("Yes") : tr("No")); |
| 122 |
ui->supportRhythmLabel->setText(haveRhythm ? tr("Yes") : tr("No")); |
| 123 |
ui->supportAdpcmLabel->setText(haveAdpcm ? tr("Yes") : tr("No")); |
| 124 |
|
| 125 |
QPalette normalPalette = palette(); |
| 126 |
QPalette warnPalette = normalPalette; |
| 127 |
warnPalette.setColor(QPalette::WindowText, QColor(0xef2929)); |
| 128 |
|
| 129 |
ui->supportFmChannelsLabel->setPalette((channels == 6) ? normalPalette : warnPalette); |
| 130 |
ui->supportSsgLabel->setPalette(haveSsg ? normalPalette : warnPalette); |
| 131 |
ui->supportRhythmLabel->setPalette(haveRhythm ? normalPalette : warnPalette); |
| 132 |
ui->supportAdpcmLabel->setPalette(haveAdpcm ? normalPalette : warnPalette); |
| 133 |
} |