Browse Source

Improve sound and graphics menus

master
C. J. Howard 2 years ago
parent
commit
6299d2a41a
5 changed files with 301 additions and 149 deletions
  1. +12
    -0
      src/game/context.hpp
  2. +2
    -0
      src/game/fonts.cpp
  3. +18
    -3
      src/game/states/boot.cpp
  4. +70
    -52
      src/game/states/graphics-menu.cpp
  5. +199
    -94
      src/game/states/sound-menu.cpp

+ 12
- 0
src/game/context.hpp View File

@ -229,10 +229,19 @@ struct context
scene::text* sound_menu_ambience_volume_value_text;
scene::text* sound_menu_effects_volume_label_text;
scene::text* sound_menu_effects_volume_value_text;
scene::text* sound_menu_mono_audio_label_text;
scene::text* sound_menu_mono_audio_value_text;
scene::text* sound_menu_captions_label_text;
scene::text* sound_menu_captions_value_text;
scene::text* sound_menu_captions_size_label_text;
scene::text* sound_menu_captions_size_value_text;
scene::text* sound_menu_back_label_text;
std::vector<scene::text*> sound_menu_label_texts;
std::vector<scene::text*> sound_menu_value_texts;
int sound_menu_index;
std::vector<std::function<void()>> sound_menu_select_callbacks;
std::vector<std::function<void()>> sound_menu_left_callbacks;
std::vector<std::function<void()>> sound_menu_right_callbacks;
scene::text* graphics_menu_display_mode_label_text;
scene::text* graphics_menu_display_mode_value_text;
scene::text* graphics_menu_render_resolution_label_text;
@ -295,6 +304,9 @@ struct context
float master_volume;
float ambience_volume;
float effects_volume;
bool mono_audio;
bool captions;
float captions_size;
// Parallel processes
std::unordered_map<std::string, std::function<void(double, double)>> processes;

+ 2
- 0
src/game/fonts.cpp View File

@ -145,6 +145,8 @@ void load_fonts(game::context* ctx)
const float menu_font_size_px = (menu_font_size_pt * dpi) / 72.0f;
const float title_font_size_px = (title_font_size_pt * dpi) / 72.0f;
ctx->logger->log("font size: " + std::to_string(menu_font_size_px));
// Build debug font
if (auto it = ctx->typefaces.find("monospace"); it != ctx->typefaces.end())
{

+ 18
- 3
src/game/states/boot.cpp View File

@ -665,21 +665,36 @@ void setup_sound(game::context* ctx)
debug::logger* logger = ctx->logger;
logger->push_task("Setting up sound");
// Load master volume
// Load master volume config
ctx->master_volume = 1.0f;
if (ctx->config->contains("master_volume"))
ctx->master_volume = (*ctx->config)["master_volume"].get<float>();
// Load ambience volume
// Load ambience volume config
ctx->ambience_volume = 1.0f;
if (ctx->config->contains("ambience_volume"))
ctx->ambience_volume = (*ctx->config)["ambience_volume"].get<float>();
// Load effects volume
// Load effects volume config
ctx->effects_volume = 1.0f;
if (ctx->config->contains("effects_volume"))
ctx->effects_volume = (*ctx->config)["effects_volume"].get<float>();
// Load mono audio config
ctx->mono_audio = false;
if (ctx->config->contains("mono_audio"))
ctx->mono_audio = (*ctx->config)["mono_audio"].get<bool>();
// Load captions config
ctx->captions = false;
if (ctx->config->contains("captions"))
ctx->captions = (*ctx->config)["captions"].get<bool>();
// Load captions size config
ctx->captions_size = 1.0f;
if (ctx->config->contains("captions_size"))
ctx->captions_size = (*ctx->config)["captions_size"].get<float>();
logger->pop_task(EXIT_SUCCESS);
}

+ 70
- 52
src/game/states/graphics-menu.cpp View File

@ -54,6 +54,59 @@ static void update_text_color(game::context* ctx)
}
}
static void align_texts(game::context* ctx)
{
// Calculate menu width
float menu_width = 0.0f;
float menu_spacing = ctx->menu_font.get_glyph_metrics(U'M').width;
for (std::size_t i = 0; i < ctx->graphics_menu_label_texts.size(); ++i)
{
scene::text* label_text = ctx->graphics_menu_label_texts[i];
scene::text* value_text = ctx->graphics_menu_value_texts[i];
float row_width = 0.0f;
// Add label width to width
const auto& label_bounds = static_cast<const geom::aabb<float>&>(label_text->get_local_bounds());
row_width += label_bounds.max_point.x - label_bounds.min_point.x;
if (value_text != nullptr)
{
// Add value width to width
//const auto& value_bounds = static_cast<const geom::aabb<float>&>(value_text->get_local_bounds());
//row_width += value_bounds.max_point.x - value_bounds.min_point.x;
// Add spacing to row width
row_width += menu_spacing * 8.0f;
}
menu_width = std::max<float>(menu_width, row_width);
}
// Align texts
float menu_height = ctx->graphics_menu_label_texts.size() * ctx->menu_font.get_font_metrics().linespace;
float menu_x = -menu_width * 0.5f;
float menu_y = menu_height * 0.5f - ctx->menu_font.get_font_metrics().linespace;
for (std::size_t i = 0; i < ctx->graphics_menu_label_texts.size(); ++i)
{
scene::text* label_text = ctx->graphics_menu_label_texts[i];
float x = menu_x;
float y = menu_y - ctx->menu_font.get_font_metrics().linespace * i;
label_text->set_translation({std::round(x), std::round(y), 0.0f});
scene::text* value_text = ctx->graphics_menu_value_texts[i];
if (value_text)
{
const auto& value_bounds = static_cast<const geom::aabb<float>&>(value_text->get_local_bounds());
const float value_width = value_bounds.max_point.x - value_bounds.min_point.x;
x = menu_x + menu_width - value_width;
value_text->set_translation({std::round(x), std::round(y), 0.0f});
}
}
}
static void update_text_tweens(game::context* ctx)
{
for (std::size_t i = 0; i < ctx->graphics_menu_label_texts.size(); ++i)
@ -103,10 +156,10 @@ void enter(game::context* ctx)
float font_size = ctx->font_size;
bool dyslexia_font = ctx->dyslexia_font;
std::string string_fullscreen = (*ctx->strings)["graphics_menu_display_mode_fullscreen"];
std::string string_window = (*ctx->strings)["graphics_menu_display_mode_window"];
std::string string_on = (*ctx->strings)["on"];
std::string string_off = (*ctx->strings)["off"];
const std::string string_fullscreen = (*ctx->strings)["graphics_menu_display_mode_fullscreen"];
const std::string string_window = (*ctx->strings)["graphics_menu_display_mode_window"];
const std::string string_on = (*ctx->strings)["on"];
const std::string string_off = (*ctx->strings)["off"];
// Set text content
ctx->graphics_menu_display_mode_label_text->set_content((*ctx->strings)["graphics_menu_display_mode"]);
@ -153,55 +206,8 @@ void enter(game::context* ctx)
}
}
// Calculate menu width
float menu_width = 0.0f;
float menu_spacing = ctx->menu_font.get_glyph_metrics(U'M').width;
for (std::size_t i = 0; i < ctx->graphics_menu_label_texts.size(); ++i)
{
scene::text* label_text = ctx->graphics_menu_label_texts[i];
scene::text* value_text = ctx->graphics_menu_value_texts[i];
float row_width = 0.0f;
// Add label width to width
const auto& label_bounds = static_cast<const geom::aabb<float>&>(label_text->get_local_bounds());
row_width += label_bounds.max_point.x - label_bounds.min_point.x;
if (value_text != nullptr)
{
// Add value width to width
//const auto& value_bounds = static_cast<const geom::aabb<float>&>(value_text->get_local_bounds());
//row_width += value_bounds.max_point.x - value_bounds.min_point.x;
// Add spacing to row width
row_width += menu_spacing * 8.0f;
}
menu_width = std::max<float>(menu_width, row_width);
}
// Align texts
float menu_height = ctx->graphics_menu_label_texts.size() * ctx->menu_font.get_font_metrics().linespace;
float menu_x = -menu_width * 0.5f;
float menu_y = menu_height * 0.5f - ctx->menu_font.get_font_metrics().linespace;
for (std::size_t i = 0; i < ctx->graphics_menu_label_texts.size(); ++i)
{
scene::text* label_text = ctx->graphics_menu_label_texts[i];
float x = menu_x;
float y = menu_y - ctx->menu_font.get_font_metrics().linespace * i;
label_text->set_translation({std::round(x), std::round(y), 0.0f});
scene::text* value_text = ctx->graphics_menu_value_texts[i];
if (value_text)
{
const auto& value_bounds = static_cast<const geom::aabb<float>&>(value_text->get_local_bounds());
const float value_width = value_bounds.max_point.x - value_bounds.min_point.x;
x = menu_x + menu_width - value_width;
value_text->set_translation({std::round(x), std::round(y), 0.0f});
}
}
align_texts(ctx);
// Construct graphics menu callbacks
auto menu_back_callback = [ctx]()
@ -354,6 +360,10 @@ void enter(game::context* ctx)
// Refresh text
refresh_texts(ctx);
// Realign texts
align_texts(ctx);
update_text_tweens(ctx);
};
auto decrease_font_size_callback = [ctx]()
@ -388,6 +398,10 @@ void enter(game::context* ctx)
// Refresh text
refresh_texts(ctx);
// Realign texts
align_texts(ctx);
update_text_tweens(ctx);
};
auto toggle_vsync_callback = [ctx]()
@ -429,6 +443,10 @@ void enter(game::context* ctx)
// Refresh text
refresh_texts(ctx);
// Realign texts
align_texts(ctx);
update_text_tweens(ctx);
};
// Build list of graphics menu callbacks

+ 199
- 94
src/game/states/sound-menu.cpp View File

@ -53,6 +53,59 @@ static void update_text_color(game::context* ctx)
}
}
static void align_texts(game::context* ctx)
{
// Calculate menu width
float menu_width = 0.0f;
float menu_spacing = ctx->menu_font.get_glyph_metrics(U'M').width;
for (std::size_t i = 0; i < ctx->sound_menu_label_texts.size(); ++i)
{
scene::text* label_text = ctx->sound_menu_label_texts[i];
scene::text* value_text = ctx->sound_menu_value_texts[i];
float row_width = 0.0f;
// Add label width to width
const auto& label_bounds = static_cast<const geom::aabb<float>&>(label_text->get_local_bounds());
row_width += label_bounds.max_point.x - label_bounds.min_point.x;
if (value_text != nullptr)
{
// Add value width to width
//const auto& value_bounds = static_cast<const geom::aabb<float>&>(value_text->get_local_bounds());
//row_width += value_bounds.max_point.x - value_bounds.min_point.x;
// Add spacing to row width
row_width += menu_spacing * 4.0f;
}
menu_width = std::max<float>(menu_width, row_width);
}
// Align texts
float menu_height = ctx->sound_menu_label_texts.size() * ctx->menu_font.get_font_metrics().linespace;
float menu_x = -menu_width * 0.5f;
float menu_y = menu_height * 0.5f - ctx->menu_font.get_font_metrics().linespace;
for (std::size_t i = 0; i < ctx->sound_menu_label_texts.size(); ++i)
{
scene::text* label_text = ctx->sound_menu_label_texts[i];
float x = menu_x;
float y = menu_y - ctx->menu_font.get_font_metrics().linespace * i;
label_text->set_translation({std::round(x), std::round(y), 0.0f});
scene::text* value_text = ctx->sound_menu_value_texts[i];
if (value_text)
{
const auto& value_bounds = static_cast<const geom::aabb<float>&>(value_text->get_local_bounds());
const float value_width = value_bounds.max_point.x - value_bounds.min_point.x;
x = menu_x + menu_width - value_width;
value_text->set_translation({std::round(x), std::round(y), 0.0f});
}
}
}
static void update_text_tweens(game::context* ctx)
{
for (std::size_t i = 0; i < ctx->sound_menu_label_texts.size(); ++i)
@ -77,25 +130,46 @@ void enter(game::context* ctx)
ctx->sound_menu_ambience_volume_value_text = new scene::text();
ctx->sound_menu_effects_volume_label_text = new scene::text();
ctx->sound_menu_effects_volume_value_text = new scene::text();
ctx->sound_menu_mono_audio_label_text = new scene::text();
ctx->sound_menu_mono_audio_value_text = new scene::text();
ctx->sound_menu_captions_label_text = new scene::text();
ctx->sound_menu_captions_value_text = new scene::text();
ctx->sound_menu_captions_size_label_text = new scene::text();
ctx->sound_menu_captions_size_value_text = new scene::text();
ctx->sound_menu_back_label_text = new scene::text();
// Set text content
const std::string string_on = (*ctx->strings)["on"];
const std::string string_off = (*ctx->strings)["off"];
ctx->sound_menu_master_volume_label_text->set_content((*ctx->strings)["sound_menu_master_volume"]);
ctx->sound_menu_master_volume_value_text->set_content(std::to_string(static_cast<int>(ctx->master_volume * 100.0f + 0.5f)) + "%");
ctx->sound_menu_ambience_volume_label_text->set_content((*ctx->strings)["sound_menu_ambience_volume"]);
ctx->sound_menu_ambience_volume_value_text->set_content(std::to_string(static_cast<int>(ctx->ambience_volume * 100.0f + 0.5f)) + "%");
ctx->sound_menu_effects_volume_label_text->set_content((*ctx->strings)["sound_menu_effects_volume"]);
ctx->sound_menu_effects_volume_value_text->set_content(std::to_string(static_cast<int>(ctx->effects_volume * 100.0f + 0.5f)) + "%");
ctx->sound_menu_mono_audio_label_text->set_content((*ctx->strings)["sound_menu_mono_audio"]);
ctx->sound_menu_mono_audio_value_text->set_content((ctx->mono_audio) ? string_on : string_off);
ctx->sound_menu_captions_label_text->set_content((*ctx->strings)["sound_menu_captions"]);
ctx->sound_menu_captions_value_text->set_content((ctx->captions) ? string_on : string_off);
ctx->sound_menu_captions_size_label_text->set_content((*ctx->strings)["sound_menu_captions_size"]);
ctx->sound_menu_captions_size_value_text->set_content(std::to_string(static_cast<int>(ctx->captions_size * 100.0f + 0.5f)) + "%");
ctx->sound_menu_back_label_text->set_content((*ctx->strings)["back"]);
// Build lists of sound menu texts
ctx->sound_menu_label_texts.push_back(ctx->sound_menu_master_volume_label_text);
ctx->sound_menu_label_texts.push_back(ctx->sound_menu_ambience_volume_label_text);
ctx->sound_menu_label_texts.push_back(ctx->sound_menu_effects_volume_label_text);
ctx->sound_menu_label_texts.push_back(ctx->sound_menu_mono_audio_label_text);
ctx->sound_menu_label_texts.push_back(ctx->sound_menu_captions_label_text);
ctx->sound_menu_label_texts.push_back(ctx->sound_menu_captions_size_label_text);
ctx->sound_menu_label_texts.push_back(ctx->sound_menu_back_label_text);
ctx->sound_menu_value_texts.push_back(ctx->sound_menu_master_volume_value_text);
ctx->sound_menu_value_texts.push_back(ctx->sound_menu_ambience_volume_value_text);
ctx->sound_menu_value_texts.push_back(ctx->sound_menu_effects_volume_value_text);
ctx->sound_menu_value_texts.push_back(ctx->sound_menu_mono_audio_value_text);
ctx->sound_menu_value_texts.push_back(ctx->sound_menu_captions_value_text);
ctx->sound_menu_value_texts.push_back(ctx->sound_menu_captions_size_value_text);
ctx->sound_menu_value_texts.push_back(nullptr);
// Set text fonts
@ -113,55 +187,7 @@ void enter(game::context* ctx)
}
}
// Calculate menu width
float menu_width = 0.0f;
float menu_spacing = ctx->menu_font.get_glyph_metrics(U'M').width;
for (std::size_t i = 0; i < ctx->sound_menu_label_texts.size(); ++i)
{
scene::text* label_text = ctx->sound_menu_label_texts[i];
scene::text* value_text = ctx->sound_menu_value_texts[i];
float row_width = 0.0f;
// Add label width to width
const auto& label_bounds = static_cast<const geom::aabb<float>&>(label_text->get_local_bounds());
row_width += label_bounds.max_point.x - label_bounds.min_point.x;
if (value_text != nullptr)
{
// Add value width to width
//const auto& value_bounds = static_cast<const geom::aabb<float>&>(value_text->get_local_bounds());
//row_width += value_bounds.max_point.x - value_bounds.min_point.x;
// Add spacing to row width
row_width += menu_spacing * 4.0f;
}
menu_width = std::max<float>(menu_width, row_width);
}
// Align texts
float menu_height = ctx->sound_menu_label_texts.size() * ctx->menu_font.get_font_metrics().linespace;
float menu_x = -menu_width * 0.5f;
float menu_y = menu_height * 0.5f - ctx->menu_font.get_font_metrics().linespace;
for (std::size_t i = 0; i < ctx->sound_menu_label_texts.size(); ++i)
{
scene::text* label_text = ctx->sound_menu_label_texts[i];
float x = menu_x;
float y = menu_y - ctx->menu_font.get_font_metrics().linespace * i;
label_text->set_translation({std::round(x), std::round(y), 0.0f});
scene::text* value_text = ctx->sound_menu_value_texts[i];
if (value_text)
{
const auto& value_bounds = static_cast<const geom::aabb<float>&>(value_text->get_local_bounds());
const float value_width = value_bounds.max_point.x - value_bounds.min_point.x;
x = menu_x + menu_width - value_width;
value_text->set_translation({std::round(x), std::round(y), 0.0f});
}
}
align_texts(ctx);
// Construct sound menu callbacks
auto menu_back_callback = [ctx]()
@ -172,20 +198,8 @@ void enter(game::context* ctx)
next_state.exit = std::bind(game::state::options_menu::exit, ctx);
ctx->app->change_state(next_state);
};
auto increase_volume_callback = [ctx, menu_x, menu_width]()
auto increase_volume_callback = [ctx](float* volume, scene::text* value_text)
{
if (ctx->sound_menu_index > 2)
return;
// Find volume variable
float* volumes[] =
{
&ctx->master_volume,
&ctx->ambience_volume,
&ctx->effects_volume
};
float* volume = volumes[ctx->sound_menu_index];
// Increase volume
if (ctx->controls["menu_modifier"]->is_active())
*volume += 0.01f;
@ -197,30 +211,14 @@ void enter(game::context* ctx)
*volume = 1.0f;
// Update volume value text
scene::text* value_text = ctx->sound_menu_value_texts[ctx->sound_menu_index];
value_text->set_content(std::to_string(static_cast<int>((*volume) * 100.0f + 0.5f)) + "%");
value_text->set_content(std::to_string(static_cast<int>(std::round(*volume * 100.0f))) + "%");
// Realign value text
const auto& value_bounds = static_cast<const geom::aabb<float>&>(value_text->get_local_bounds());
const float value_width = value_bounds.max_point.x - value_bounds.min_point.x;
const float3& translation = value_text->get_translation();
value_text->set_translation(float3{std::round(menu_x + menu_width - value_width), translation.y, translation.z});
// Realign text
align_texts(ctx);
value_text->update_tweens();
};
auto decrease_volume_callback = [ctx, menu_x, menu_width]()
auto decrease_volume_callback = [ctx](float* volume, scene::text* value_text)
{
if (ctx->sound_menu_index > 2)
return;
// Find volume variable
float* volumes[] =
{
&ctx->master_volume,
&ctx->ambience_volume,
&ctx->effects_volume
};
float* volume = volumes[ctx->sound_menu_index];
// Decrease volume
if (ctx->controls["menu_modifier"]->is_active())
*volume -= 0.01f;
@ -232,17 +230,77 @@ void enter(game::context* ctx)
*volume = 0.0f;
// Update volume value text
scene::text* value_text = ctx->sound_menu_value_texts[ctx->sound_menu_index];
value_text->set_content(std::to_string(static_cast<int>((*volume) * 100.0f + 0.5f)) + "%");
value_text->set_content(std::to_string(static_cast<int>(std::round(*volume * 100.0f))) + "%");
// Realign value text
const auto& value_bounds = static_cast<const geom::aabb<float>&>(value_text->get_local_bounds());
const float value_width = value_bounds.max_point.x - value_bounds.min_point.x;
const float3& translation = value_text->get_translation();
value_text->set_translation(float3{std::round(menu_x + menu_width - value_width), translation.y, translation.z});
// Realign text
align_texts(ctx);
value_text->update_tweens();
};
auto toggle_mono_audio_callback = [ctx]()
{
ctx->mono_audio = !ctx->mono_audio;
const std::string string_on = (*ctx->strings)["on"];
const std::string string_off = (*ctx->strings)["off"];
ctx->sound_menu_mono_audio_value_text->set_content((ctx->mono_audio) ? string_on : string_off);
align_texts(ctx);
ctx->sound_menu_mono_audio_value_text->update_tweens();
};
auto toggle_captions_callback = [ctx]()
{
ctx->captions = !ctx->captions;
const std::string string_on = (*ctx->strings)["on"];
const std::string string_off = (*ctx->strings)["off"];
ctx->sound_menu_captions_value_text->set_content((ctx->captions) ? string_on : string_off);
align_texts(ctx);
ctx->sound_menu_captions_value_text->update_tweens();
};
auto increase_captions_size_callback = [ctx]()
{
// Increase size
if (ctx->controls["menu_modifier"]->is_active())
ctx->captions_size += 0.01f;
else
ctx->captions_size += 0.1f;
// Limit size
if (ctx->captions_size > 2.0f)
ctx->captions_size = 2.0f;
// Update volume value text
ctx->sound_menu_captions_size_value_text->set_content(std::to_string(static_cast<int>(std::round(ctx->captions_size * 100.0f))) + "%");
// Realign text
align_texts(ctx);
ctx->sound_menu_captions_size_value_text->update_tweens();
};
auto decrease_captions_size_callback = [ctx]()
{
// Decrease size
if (ctx->controls["menu_modifier"]->is_active())
ctx->captions_size -= 0.01f;
else
ctx->captions_size -= 0.1f;
// Limit size
if (ctx->captions_size < 0.1f)
ctx->captions_size = 0.1f;
// Update volume value text
ctx->sound_menu_captions_size_value_text->set_content(std::to_string(static_cast<int>(std::round(ctx->captions_size * 100.0f))) + "%");
// Realign text
align_texts(ctx);
ctx->sound_menu_captions_size_value_text->update_tweens();
};
ctx->controls["menu_down"]->set_activated_callback
(
[ctx]()
@ -265,18 +323,57 @@ void enter(game::context* ctx)
update_text_color(ctx);
}
);
ctx->controls["menu_left"]->set_activated_callback(decrease_volume_callback);
ctx->controls["menu_right"]->set_activated_callback(increase_volume_callback);
ctx->controls["menu_left"]->set_activated_callback
(
[ctx]()
{
if (ctx->sound_menu_left_callbacks[ctx->sound_menu_index])
ctx->sound_menu_left_callbacks[ctx->sound_menu_index]();
}
);
ctx->controls["menu_right"]->set_activated_callback
(
[ctx]()
{
if (ctx->sound_menu_right_callbacks[ctx->sound_menu_index])
ctx->sound_menu_right_callbacks[ctx->sound_menu_index]();
}
);
ctx->controls["menu_select"]->set_activated_callback
(
[ctx, menu_back_callback]()
[ctx]()
{
if (ctx->sound_menu_index == 3)
menu_back_callback();
if (ctx->sound_menu_select_callbacks[ctx->sound_menu_index])
ctx->sound_menu_select_callbacks[ctx->sound_menu_index]();
}
);
ctx->controls["menu_back"]->set_activated_callback(menu_back_callback);
// Build list of sound menu callbacks
ctx->sound_menu_select_callbacks.push_back(std::bind(increase_volume_callback, &ctx->master_volume, ctx->sound_menu_master_volume_value_text));
ctx->sound_menu_select_callbacks.push_back(std::bind(increase_volume_callback, &ctx->ambience_volume, ctx->sound_menu_ambience_volume_value_text));
ctx->sound_menu_select_callbacks.push_back(std::bind(increase_volume_callback, &ctx->effects_volume, ctx->sound_menu_effects_volume_value_text));
ctx->sound_menu_select_callbacks.push_back(toggle_mono_audio_callback);
ctx->sound_menu_select_callbacks.push_back(toggle_captions_callback);
ctx->sound_menu_select_callbacks.push_back(increase_captions_size_callback);
ctx->sound_menu_select_callbacks.push_back(menu_back_callback);
ctx->sound_menu_right_callbacks.push_back(std::bind(increase_volume_callback, &ctx->master_volume, ctx->sound_menu_master_volume_value_text));
ctx->sound_menu_right_callbacks.push_back(std::bind(increase_volume_callback, &ctx->ambience_volume, ctx->sound_menu_ambience_volume_value_text));
ctx->sound_menu_right_callbacks.push_back(std::bind(increase_volume_callback, &ctx->effects_volume, ctx->sound_menu_effects_volume_value_text));
ctx->sound_menu_right_callbacks.push_back(toggle_mono_audio_callback);
ctx->sound_menu_right_callbacks.push_back(toggle_captions_callback);
ctx->sound_menu_right_callbacks.push_back(increase_captions_size_callback);
ctx->sound_menu_right_callbacks.push_back(nullptr);
ctx->sound_menu_left_callbacks.push_back(std::bind(decrease_volume_callback, &ctx->master_volume, ctx->sound_menu_master_volume_value_text));
ctx->sound_menu_left_callbacks.push_back(std::bind(decrease_volume_callback, &ctx->ambience_volume, ctx->sound_menu_ambience_volume_value_text));
ctx->sound_menu_left_callbacks.push_back(std::bind(decrease_volume_callback, &ctx->effects_volume, ctx->sound_menu_effects_volume_value_text));
ctx->sound_menu_left_callbacks.push_back(toggle_mono_audio_callback);
ctx->sound_menu_left_callbacks.push_back(toggle_captions_callback);
ctx->sound_menu_left_callbacks.push_back(decrease_captions_size_callback);
ctx->sound_menu_left_callbacks.push_back(nullptr);
// Add text objects to UI
for (std::size_t i = 0; i < ctx->sound_menu_label_texts.size(); ++i)
{
@ -301,6 +398,11 @@ void exit(game::context* ctx)
ctx->controls["menu_select"]->set_activated_callback(nullptr);
ctx->controls["menu_back"]->set_activated_callback(nullptr);
// Clear menu callbacks
ctx->sound_menu_select_callbacks.clear();
ctx->sound_menu_left_callbacks.clear();
ctx->sound_menu_right_callbacks.clear();
// Destruct sound menu texts
for (std::size_t i = 0; i < ctx->sound_menu_label_texts.size(); ++i)
{
@ -322,6 +424,9 @@ void exit(game::context* ctx)
(*ctx->config)["master_volume"] = ctx->master_volume;
(*ctx->config)["ambience_volume"] = ctx->ambience_volume;
(*ctx->config)["effects_volume"] = ctx->effects_volume;
(*ctx->config)["mono_audio"] = ctx->mono_audio;
(*ctx->config)["captions"] = ctx->captions;
(*ctx->config)["captions_size"] = ctx->captions_size;
ctx->ui_clear_pass->set_cleared_buffers(false, true, false);
}

Loading…
Cancel
Save