2 * File: SettingsForm.cpp
4 * Author: Petr Kubizňák
8 /* -------------------------------------------------------------------------- */
10 #include "SettingsForm.h"
11 #include "../../core/board.h"
13 /* -------------------------------------------------------------------------- */
15 SettingsForm::SettingsForm() {
18 QObject::connect(ui
.rookieRadio
, SIGNAL(clicked()), this, SLOT(rookieRadio_Clicked()));
19 QObject::connect(ui
.advancedRadio
, SIGNAL(clicked()), this, SLOT(advancedRadio_Clicked()));
20 QObject::connect(ui
.suicideRadio
, SIGNAL(clicked()), this, SLOT(suicideRadio_Clicked()));
21 QObject::connect(ui
.customRadio
, SIGNAL(clicked()), this, SLOT(customRadio_Clicked()));
23 QObject::connect(ui
.soundEffectsBtn
, SIGNAL(clicked()), this, SLOT(soundEffectsBtn_Clicked()));
24 QObject::connect(ui
.soundMusicBtn
, SIGNAL(clicked()), this, SLOT(soundMusicBtn_Clicked()));
27 /* -------------------------------------------------------------------------- */
29 SettingsForm::~SettingsForm() {
33 /* -------------------------------------------------------------------------- */
35 /* nastavi vsem 4 spinum stejnou hodnotu enabled, tu vraci */
36 bool SettingsForm::setSpinsEnabled(bool value
) {
37 ui
.layersSpinBox
->setEnabled(value
);
38 ui
.rowsSpinBox
->setEnabled(value
);
39 ui
.columnsSpinBox
->setEnabled(value
);
40 ui
.minesSpinBox
->setEnabled(value
);
44 /* -------------------------------------------------------------------------- */
46 /* nastavi vsem 4 spinum zadane hodnoty */
47 void SettingsForm::setSpinsValues(int layers
, int rows
, int columns
, int mines
) {
48 ui
.layersSpinBox
->setValue(layers
);
49 ui
.rowsSpinBox
->setValue(rows
);
50 ui
.columnsSpinBox
->setValue(columns
);
51 ui
.minesSpinBox
->setValue(mines
);
54 /* -------------------------------------------------------------------------- */
56 void SettingsForm::setSoundEffectsOn(bool value
) {
57 ui
.soundEffectsBtn
->setText(value
? "Effects On" : "Effects Off");
58 ui
.soundEffectsBtn
->setChecked(value
);
61 /* -------------------------------------------------------------------------- */
63 void SettingsForm::setSoundMusicType(EMusicType type
) {
68 ui
.soundMusicBtn
->setText("Music Off");
69 ui
.soundMusicBtn
->setChecked(false);
72 ui
.soundMusicBtn
->setText("Music 1");
73 ui
.soundMusicBtn
->setChecked(true);
76 ui
.soundMusicBtn
->setText("Music 2");
77 ui
.soundMusicBtn
->setChecked(true);
82 /* -------------------------------------------------------------------------- */
84 bool SettingsForm::getSoundEffectsOn(void) {
85 return ui
.soundEffectsBtn
->isChecked();
88 /* -------------------------------------------------------------------------- */
90 EMusicType
SettingsForm::getSoundMusicType(void) {
94 /* -------------------------------------------------------------------------- */
96 void SettingsForm::rookieRadio_Clicked(void) {
97 setSpinsEnabled(false);
98 setSpinsValues(PRESETS
[0][0], PRESETS
[0][1], PRESETS
[0][2], PRESETS
[0][3]);
101 /* -------------------------------------------------------------------------- */
103 void SettingsForm::advancedRadio_Clicked(void) {
104 setSpinsEnabled(false);
105 setSpinsValues(PRESETS
[1][0], PRESETS
[1][1], PRESETS
[1][2], PRESETS
[1][3]);
108 /* -------------------------------------------------------------------------- */
110 void SettingsForm::suicideRadio_Clicked(void) {
111 setSpinsEnabled(false);
112 setSpinsValues(PRESETS
[2][0], PRESETS
[2][1], PRESETS
[2][2], PRESETS
[2][3]);
115 /* -------------------------------------------------------------------------- */
117 void SettingsForm::customRadio_Clicked(void) {
118 setSpinsEnabled(true);
121 /* -------------------------------------------------------------------------- */
123 void SettingsForm::soundEffectsBtn_Clicked(void) {
124 setSoundEffectsOn(ui
.soundEffectsBtn
->isChecked());
127 /* -------------------------------------------------------------------------- */
129 void SettingsForm::soundMusicBtn_Clicked(void) {
131 case MUSIC_NO
: setSoundMusicType(MUSIC_1
); break;
132 case MUSIC_1
: setSoundMusicType(MUSIC_2
); break;
133 case MUSIC_2
: setSoundMusicType(MUSIC_NO
); break;
137 /* -------------------------------------------------------------------------- */