void gui_element::draw_tooltip_from_hover_or_world_highlight(vertex_triangle_buffer& output_buffer, const viewing_gui_context& context, const vec2i tooltip_pos) const { const auto& rect_world = context.get_rect_world(); auto& step = context.get_step(); const auto& cosmos = step.get_cosmos(); const auto maybe_hovered_item = context._dynamic_cast<item_button_in_item>(rect_world.rect_hovered); const auto maybe_hovered_slot = context._dynamic_cast<slot_button_in_container>(rect_world.rect_hovered); const auto maybe_hovered_hotbar_button = context._dynamic_cast<hotbar_button_in_gui_element>(rect_world.rect_hovered); gui::text::fstr tooltip_text; const auto description_style = text::style(assets::font_id::GUI_FONT, vslightgray); if (maybe_hovered_item) { tooltip_text = text::simple_bbcode(describe_entity(cosmos[maybe_hovered_item.get_location().item_id]), description_style); } else if (maybe_hovered_slot) { tooltip_text = text::simple_bbcode(describe_slot(cosmos[maybe_hovered_slot.get_location().slot_id]), text::style()); } else if (maybe_hovered_hotbar_button) { const auto assigned_entity = maybe_hovered_hotbar_button->get_assigned_entity(context.get_gui_element_entity()); if (assigned_entity.alive()) { tooltip_text = text::simple_bbcode(describe_entity(assigned_entity), description_style); } else { tooltip_text = text::format(L"Empty slot", description_style); } } else { const auto hovered = cosmos[get_hovered_world_entity(cosmos, step.camera.transform.pos + rect_world.last_state.mouse.pos - step.camera.visible_world_area / 2)]; if (hovered.alive()) { step.session.world_hover_highlighter.update(step.get_delta().in_milliseconds()); step.session.world_hover_highlighter.draw(step, hovered); tooltip_text = text::simple_bbcode(describe_entity(hovered), text::style(assets::font_id::GUI_FONT, vslightgray)); } } if (tooltip_text.size() > 0) { augs::gui::text_drawer description_drawer; description_drawer.set_text(tooltip_text); const auto tooltip_rect = ltrbi(tooltip_pos, description_drawer.get_bbox()).snap_to_bounds(ltrb(vec2(0, 0), get_screen_size())); augs::draw_rect_with_border( output_buffer, tooltip_rect, { 0, 0, 0, 120 }, slightly_visible_white ); description_drawer.pos = tooltip_rect.get_position(); description_drawer.draw(output_buffer); } }