-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.cpp
More file actions
39 lines (35 loc) · 1.18 KB
/
Copy pathsettings.cpp
File metadata and controls
39 lines (35 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "settings.h"
#include "ui_settings.h"
#include <QJsonObject>
#include <QJsonDocument>
Settings::Settings(SettingsManager *settingsManager,Game *game,QWidget *parent)
: QWidget(parent)
, ui(new Ui::Settings)
,settingsManager(settingsManager)
,game(game)
{
ui->setupUi(this);
QStringList themes = { "light", "dark", "cyberpunk", "forest" };
ui->themeComboBox->addItems(themes);
ui->volumeSlider->setValue(settingsManager->audioVolume());
QString currentTheme = settingsManager->theme();
int index = themes.indexOf(currentTheme);
if (index >= 0) {
ui->themeComboBox->setCurrentIndex(index);
}
connect(ui->themeComboBox, &QComboBox::currentTextChanged, this, [=](const QString &theme) {
settingsManager->setTheme(theme);
emit themeToggle();
});
connect(ui->menuBtn, &QPushButton::clicked, this, &Settings::backToMainMenu);
connect(ui->volumeSlider, &QSlider::valueChanged, this, [=](int val) {
float volume = val / 100.0f;
settingsManager->setAudioVolume(val);
game->setJumpSoundVolume(volume);
game->setMusicVolume(volume);
});
}
Settings::~Settings()
{
delete ui;
}