Skip to content

Commit

Permalink
fix: use settings manager to initialize the volume
Browse files Browse the repository at this point in the history
move it to the first place in the threaded Initializers of the application, so that everyone after that can use the settings
  • Loading branch information
Totto16 committed Oct 28, 2024
1 parent 5e52a5c commit 4e5d913
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/executables/game/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,15 +264,18 @@ void Application::initialize() {
const auto start_time = SDL_GetTicks64();

const std::future<void> load_everything = std::async(std::launch::async, [this] {
this->m_settings_manager = std::make_unique<SettingsManager>();

const auto current_settings = this->m_settings_manager->settings();

this->m_music_manager = std::make_unique<MusicManager>(this, num_audio_channels);
this->m_music_manager->set_volume(current_settings.volume, true, true);

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

this->m_settings_manager = std::make_unique<SettingsManager>(this);

this->m_font_manager = std::make_unique<FontManager>();

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

#if defined(_HAVE_DISCORD_SDK)
if (m_settings_manager->settings().discord) {
if (current_settings.discord) {
auto discord_instance = DiscordInstance::initialize();
if (not discord_instance.has_value()) {
spdlog::warn(
Expand Down
2 changes: 1 addition & 1 deletion src/executables/game/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ struct Application final : public EventListener, public ServiceProvider {
std::optional<u32> m_target_framerate;

// these fields are initalized asynchronously in a separate thread
std::unique_ptr<SettingsManager> m_settings_manager;
std::unique_ptr<MusicManager> m_music_manager;
std::shared_ptr<input::InputManager> m_input_manager;
std::unique_ptr<SettingsManager> m_settings_manager;
std::unique_ptr<FontManager> m_font_manager;
std::unique_ptr<lobby::API> m_api;

Expand Down

0 comments on commit 4e5d913

Please sign in to comment.