25 #include <engine/config.hpp>
67 name->set_color(
color);
69 value->set_color(
color);
78 const math::fvec2 viewport_center = viewport_size * 0.5f;
80 const float viewport_padding = viewport_size.
y() * (1.0f / 9.0f);
84 float column_spacing = m_width * 2.0f;
85 const float min_two_column_row_width = m_width * 18.0f;
86 float menu_width = 0.0f;
90 float row_width = 0.0f;
93 const auto& name_bounds = name->get_bounds();
94 row_width += name_bounds.max.x() - name_bounds.min.x();
99 const auto& value_bounds = value->get_bounds();
100 row_width += value_bounds.max.x() - value_bounds.min.x();
103 row_width += column_spacing;
105 row_width = std::max<float>(min_two_column_row_width, row_width);
108 menu_width = std::max<float>(menu_width, row_width);
118 float menu_x = viewport_center.
x() - menu_width * 0.5f;
129 y = viewport_padding;
134 const auto& name_bounds = name->get_bounds();
135 const float name_width = name_bounds.max.x() - name_bounds.min.x();
136 x = viewport_center.
x() - name_width * 0.5f;
143 const auto& value_bounds = value->get_bounds();
144 const float value_width = value_bounds.max.x() - value_bounds.min.x();
147 x = viewport_center.
x() - value_width * 0.5f;
149 x = menu_x + menu_width - value_width;
182 ctx.
ui_scene->remove_object(*value);
213 [&ctx](
int channel,
const float& opacity)
223 name->set_color(
color);
225 value->set_color(
color);
233 void fade_in(::
game& ctx,
const std::function<
void()>& end_callback)
239 opacity_channel->
insert_keyframe({config::menu_fade_in_duration, 1.0f});
251 name->set_color(
color);
255 value->set_color(
color);
269 opacity_channel->
insert_keyframe({config::menu_fade_out_duration, 0.0f});
Single channel in a keyframe animation.
void remove_keyframes(float start, float end)
Removes all keyframes on [start, end).
void insert_keyframe(const keyframe &k)
Adds a keyframe to the animation.
std::unique_ptr< scene::collection > ui_scene
std::unique_ptr< animation< float > > menu_bg_fade_in_animation
std::vector< std::function< void()> > menu_left_callbacks
std::vector< std::function< void()> > menu_right_callbacks
std::unique_ptr< animator > animator
std::vector< std::function< void()> > menu_select_callbacks
type::bitmap_font menu_font
std::vector< std::tuple< scene::text *, scene::text * > > menu_item_texts
std::unique_ptr< animation< float > > menu_bg_fade_out_animation
std::shared_ptr< app::window > window
std::unordered_map< hash::fnv1a32_t, int > menu_item_indices
std::shared_ptr< render::material > menu_font_material
std::unique_ptr< animation< float > > menu_fade_animation
std::function< void()> menu_back_callback
virtual const glyph_metrics & get_glyph_metrics(char32_t code) const
Returns metrics describing a glyph.
const font_metrics & get_font_metrics() const
Returns metrics describing the font.
constexpr vector< T, N > round(const vector< T, N > &x)
Performs a element-wise round operation.
Container for templated easing functions.
32-bit FNV-1a hash value.
constexpr element_type & x() noexcept
Returns a reference to the first element.
constexpr element_type & y() noexcept
Returns a reference to the second element.
float linespace
Baseline-to-baseline distance, computed as ascent - descent + linegap.
float linegap
Distance that must be placed between two lines of text.
float size
Vertical size of the font.
float width
Horizontal extent of the glyph.