Skip to content

Commit 5fe9dad

Browse files
committed
fix: also take volume into account, when checking if the settings need to be saved
1 parent 06c9299 commit 5fe9dad

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/scenes/settings_menu/settings_menu.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,13 @@ namespace scenes {
7070
const auto value = service_provider->music_manager().get_volume();
7171
return value.has_value() ? value.value() : 0.0F;
7272
},
73-
[service_provider](double amount) {
73+
[service_provider, this](double amount) {
7474
const auto mapped_amount = amount <= 0.0F ? std::nullopt : std::optional<double>{ amount };
7575
service_provider->music_manager().set_volume(mapped_amount, false, false);
76+
77+
this->m_settings.volume = static_cast<float>(amount);
78+
79+
this->m_did_change_settings = true;
7680
},
7781
0.05F, std::pair<double, double>{ 0.6, 1.0 },
7882
ui::Alignment{ ui::AlignmentHorizontal::Middle, ui::AlignmentVertical::Center }
@@ -83,6 +87,15 @@ namespace scenes {
8387
[this, scroll_layout_index, slider_index](std::optional<double>) {
8488
auto* scroll_layout = this->m_main_layout.get<ui::ScrollLayout>(scroll_layout_index);
8589
scroll_layout->get<ui::Slider>(slider_index)->on_change();
90+
91+
if (auto volume = this->m_service_provider->music_manager().get_volume(); volume.has_value()) {
92+
this->m_settings.volume = static_cast<float>(volume.value());
93+
94+
} else {
95+
this->m_settings.volume = 0.0;
96+
}
97+
98+
this->m_did_change_settings = true;
8699
}
87100
);
88101

0 commit comments

Comments
 (0)