Skip to content

Commit 4e5d913

Browse files
committed
fix: use settings manager to initialize the volume
move it to the first place in the threaded Initializers of the application, so that everyone after that can use the settings
1 parent 5e52a5c commit 4e5d913

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/executables/game/application.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,15 +264,18 @@ void Application::initialize() {
264264
const auto start_time = SDL_GetTicks64();
265265

266266
const std::future<void> load_everything = std::async(std::launch::async, [this] {
267+
this->m_settings_manager = std::make_unique<SettingsManager>();
268+
269+
const auto current_settings = this->m_settings_manager->settings();
270+
267271
this->m_music_manager = std::make_unique<MusicManager>(this, num_audio_channels);
272+
this->m_music_manager->set_volume(current_settings.volume, true, true);
268273

269274
this->m_input_manager = std::make_shared<input::InputManager>(this->m_window);
270275

271-
this->m_settings_manager = std::make_unique<SettingsManager>(this);
272-
273276
this->m_font_manager = std::make_unique<FontManager>();
274277

275-
if (auto api_url = this->m_settings_manager->settings().api_url; api_url.has_value()) {
278+
if (auto api_url = current_settings.api_url; api_url.has_value()) {
276279
auto maybe_api = lobby::API::get_api(api_url.value());
277280
if (maybe_api.has_value()) {
278281
m_api = std::make_unique<lobby::API>(std::move(maybe_api.value()));
@@ -295,7 +298,7 @@ void Application::initialize() {
295298
#endif
296299

297300
#if defined(_HAVE_DISCORD_SDK)
298-
if (m_settings_manager->settings().discord) {
301+
if (current_settings.discord) {
299302
auto discord_instance = DiscordInstance::initialize();
300303
if (not discord_instance.has_value()) {
301304
spdlog::warn(

src/executables/game/application.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ struct Application final : public EventListener, public ServiceProvider {
2929
std::optional<u32> m_target_framerate;
3030

3131
// these fields are initalized asynchronously in a separate thread
32+
std::unique_ptr<SettingsManager> m_settings_manager;
3233
std::unique_ptr<MusicManager> m_music_manager;
3334
std::shared_ptr<input::InputManager> m_input_manager;
34-
std::unique_ptr<SettingsManager> m_settings_manager;
3535
std::unique_ptr<FontManager> m_font_manager;
3636
std::unique_ptr<lobby::API> m_api;
3737

0 commit comments

Comments
 (0)