diff --git a/src/game/menu.hpp b/src/game/menu.hpp index 59e4382..c5e4223 100644 --- a/src/game/menu.hpp +++ b/src/game/menu.hpp @@ -25,6 +25,9 @@ namespace game { namespace menu { +/// Delay, in seconds, to when menu input should be activated. +static constexpr float input_delay = 0.01f; + /// RGBA color of active menu items. static constexpr float4 active_color{1.0f, 1.0f, 1.0f, 1.0f}; diff --git a/src/game/states/controls-menu.cpp b/src/game/states/controls-menu.cpp index 9117d22..68ac127 100644 --- a/src/game/states/controls-menu.cpp +++ b/src/game/states/controls-menu.cpp @@ -26,6 +26,7 @@ #include "render/passes/clear-pass.hpp" #include "debug/logger.hpp" #include "game/menu.hpp" +#include "animation/timeline.hpp" namespace game { namespace state { @@ -103,8 +104,10 @@ void enter(game::context* ctx) // Set menu back callback ctx->menu_back_callback = select_back_callback; - // Setup menu controls - game::menu::setup_controls(ctx); + // Schedule menu control setup + timeline* timeline = ctx->timeline; + float t = timeline->get_position(); + timeline->add_sequence({{t + game::menu::input_delay, std::bind(game::menu::setup_controls, ctx)}}); } void exit(game::context* ctx) diff --git a/src/game/states/graphics-menu.cpp b/src/game/states/graphics-menu.cpp index 1bbad2e..046776c 100644 --- a/src/game/states/graphics-menu.cpp +++ b/src/game/states/graphics-menu.cpp @@ -25,6 +25,7 @@ #include "debug/logger.hpp" #include "game/fonts.hpp" #include "game/menu.hpp" +#include "animation/timeline.hpp" namespace game { namespace state { @@ -304,8 +305,10 @@ void enter(game::context* ctx) // Set menu back callback ctx->menu_back_callback = select_back_callback; - // Setup menu controls - game::menu::setup_controls(ctx); + // Schedule menu control setup + timeline* timeline = ctx->timeline; + float t = timeline->get_position(); + timeline->add_sequence({{t + game::menu::input_delay, std::bind(game::menu::setup_controls, ctx)}}); } void exit(game::context* ctx) diff --git a/src/game/states/language-menu.cpp b/src/game/states/language-menu.cpp index 4352b18..6101ab1 100644 --- a/src/game/states/language-menu.cpp +++ b/src/game/states/language-menu.cpp @@ -25,6 +25,7 @@ #include "debug/logger.hpp" #include "game/fonts.hpp" #include "game/menu.hpp" +#include "animation/timeline.hpp" namespace game { namespace state { @@ -158,8 +159,10 @@ void enter(game::context* ctx) // Set menu back callback ctx->menu_back_callback = select_back_callback; - // Setup menu controls - game::menu::setup_controls(ctx); + // Schedule menu control setup + timeline* timeline = ctx->timeline; + float t = timeline->get_position(); + timeline->add_sequence({{t + game::menu::input_delay, std::bind(game::menu::setup_controls, ctx)}}); } void exit(game::context* ctx) diff --git a/src/game/states/main-menu.cpp b/src/game/states/main-menu.cpp index 9270d7f..7506cd5 100644 --- a/src/game/states/main-menu.cpp +++ b/src/game/states/main-menu.cpp @@ -148,8 +148,10 @@ void enter(game::context* ctx) // Set menu back callback ctx->menu_back_callback = menu_back_callback; - // Setup menu controls - game::menu::setup_controls(ctx); + // Schedule menu control setup + timeline* timeline = ctx->timeline; + float t = timeline->get_position(); + timeline->add_sequence({{t + game::menu::input_delay, std::bind(game::menu::setup_controls, ctx)}}); } void exit(game::context* ctx) diff --git a/src/game/states/options-menu.cpp b/src/game/states/options-menu.cpp index a3a303e..167ba74 100644 --- a/src/game/states/options-menu.cpp +++ b/src/game/states/options-menu.cpp @@ -28,6 +28,7 @@ #include "animation/ease.hpp" #include "animation/animation.hpp" #include "animation/animator.hpp" +#include "animation/timeline.hpp" #include "application.hpp" #include "scene/text.hpp" #include "render/passes/clear-pass.hpp" @@ -132,8 +133,10 @@ void enter(game::context* ctx) // Set menu back callback ctx->menu_back_callback = select_back_callback; - // Setup menu controls - game::menu::setup_controls(ctx); + // Schedule menu control setup + timeline* timeline = ctx->timeline; + float t = timeline->get_position(); + timeline->add_sequence({{t + game::menu::input_delay, std::bind(game::menu::setup_controls, ctx)}}); } void exit(game::context* ctx) diff --git a/src/game/states/sound-menu.cpp b/src/game/states/sound-menu.cpp index f7bd8b4..b27f345 100644 --- a/src/game/states/sound-menu.cpp +++ b/src/game/states/sound-menu.cpp @@ -24,6 +24,7 @@ #include "render/passes/clear-pass.hpp" #include "debug/logger.hpp" #include "game/menu.hpp" +#include "animation/timeline.hpp" namespace game { namespace state { @@ -214,8 +215,10 @@ void enter(game::context* ctx) // Set menu back callback ctx->menu_back_callback = select_back_callback; - // Setup menu controls - game::menu::setup_controls(ctx); + // Schedule menu control setup + timeline* timeline = ctx->timeline; + float t = timeline->get_position(); + timeline->add_sequence({{t + game::menu::input_delay, std::bind(game::menu::setup_controls, ctx)}}); } void exit(game::context* ctx)