40 box_material = std::make_shared<render::material>();
43 box_material->set_variable(
"tint", std::make_shared<render::matvar_fvec4>(1,
math::fvec4{0.5f, 0.5f, 0.5f, 1}));
49 selection_material = std::make_shared<render::material>();
52 box_material->set_variable(
"tint", std::make_shared<render::matvar_fvec4>(1,
math::fvec4{1, 1, 1, 1}));
69 [&](
const auto&
event)
77 [&](
const auto&
event)
79 const auto& viewport_size =
ctx.
window->get_viewport_size();
82 static_cast<float>(
event.position.x()),
83 static_cast<float>(viewport_size.y() -
event.position.y() + 1)
86 if (box_bounds.contains(mouse_position))
88 int column =
static_cast<int>((mouse_position.
x() - box_bounds.min.x()) / selection_size);
89 int row =
static_cast<int>((box_bounds.max.y() - mouse_position.
y()) / selection_size);
91 if (column != selected_column || row != selected_row)
93 selected_column = column;
99 (box_bounds.min.x() + selection_size * 0.5f) + selection_size * selected_column,
100 (box_bounds.max.y() - selection_size * 0.5f) - selection_size * selected_row ,
105 debug::log_debug(
"selected colony: ({}, {})", selected_column, selected_row);
111 window_resized_subscription =
ctx.
window->get_resized_channel().subscribe
113 [&](
const auto&
event)
138 void collection_menu_state::resize_box()
140 const float padding = 64.0f;
143 box_bounds.min.x() = viewport_size.x() * 0.5f + padding;
144 box_bounds.max.x() = viewport_size.x() - padding;
146 selection_size = (box_bounds.max.x() - box_bounds.min.x()) /
static_cast<float>(column_count);
148 box_bounds.max.y() = viewport_size.y() - padding;
149 box_bounds.min.y() = std::max<float>(padding, box_bounds.max.y() - selection_size * row_count);
152 const math::fvec2 box_center = box_bounds.center();
155 box_billboard.
set_scale({box_size.
x() * 0.5f, box_size.
y() * 0.5f, 1.0f});
159 selection_billboard.
set_scale({selection_size * 0.5f, selection_size * 0.5f, 1.0f});
163 (box_bounds.min.x() + selection_size * 0.5f) + selection_size * selected_column,
164 (box_bounds.max.y() - selection_size * 0.5f) - selection_size * selected_row,
Abstract base class for game states.
std::unique_ptr< scene::collection > ui_scene
std::unique_ptr< screen_transition > fade_transition
std::unique_ptr< resource_manager > resource_manager
std::shared_ptr< app::window > window
std::unique_ptr< app::input_manager > input_manager
Template used to for generating one or more shader variants from a single source.
void set_material(std::shared_ptr< render::material > material)
Sets the billboard material.
void set_scale(const vector_type &scale)
Sets the scale of the object.
void set_translation(const vector_type &translation)
Sets the translation of the object.
log_message< log_message_severity::trace, Args... > log_trace
Formats and logs a trace message.
log_message< log_message_severity::debug, Args... > log_debug
Formats and logs a debug message.
Publish-subscribe messaging.
User-defined literals for compile-time string hashing.
@ translucent
Material is translucent.
Container for templated easing functions.
constexpr element_type & x() noexcept
Returns a reference to the first element.
constexpr element_type & y() noexcept
Returns a reference to the second element.