void item_button::draw_proc(draw_info in, bool draw_inside, bool draw_border, bool draw_connector, bool decrease_alpha, bool decrease_border_alpha, bool draw_container_opened_mark) { if (is_inventory_root()) return; auto parent_slot = item->get<components::item>().current_slot; rgba inside_col = cyan; rgba border_col = cyan; if (parent_slot->for_categorized_items_only) { border_col = pink; inside_col = violet; } inside_col.a = 20; border_col.a = 190; if (detector.is_hovered) { inside_col.a = 30; border_col.a = 220; } if (detector.current_appearance == decltype(detector)::appearance::pushed) { inside_col.a = 60; border_col.a = 255; } if (decrease_alpha) { inside_col.a = 15; } if (decrease_border_alpha) { border_col = slightly_visible_white; } if (draw_inside) { draw_stretched_texture(in, augs::gui::material(assets::texture_id::BLANK, inside_col)); iterate_children_attachments(true, &in.v, border_col); auto& item_data = item->get<components::item>(); float bottom_number_val = -1.f; auto* container = item->find<components::container>(); bool append_x = false; auto label_color = border_col; if (item_data.charges > 1) { bottom_number_val = item_data.charges; append_x = true; } else if (DRAW_FREE_SPACE_INSIDE_CONTAINER_ICONS && item[slot_function::ITEM_DEPOSIT].alive()) { bottom_number_val = item[slot_function::ITEM_DEPOSIT].calculate_free_space_with_parent_containers(); if (item[slot_function::ITEM_DEPOSIT]->for_categorized_items_only) label_color.rgb() = pink.rgb(); else label_color.rgb() = cyan.rgb(); } if (bottom_number_val > -1.f) { std::wstring label_wstr; if (append_x) { label_wstr = L'x'; label_wstr += augs::to_wstring(bottom_number_val); } else label_wstr = augs::to_wstring(bottom_number_val, 2); // else label_wstr = L'{' + label_wstr + L'}'; auto bottom_number = augs::gui::text::format(label_wstr, augs::gui::text::style(assets::font_id::GUI_FONT, label_color)); charges_caption.set_text(bottom_number); charges_caption.bottom_right(get_rect_absolute()); charges_caption.draw(in); } } if (draw_border) { augs::gui::solid_stroke stroke; stroke.set_material(augs::gui::material(assets::texture_id::BLANK, border_col)); stroke.draw(in.v, *this); } if (draw_connector && get_meta(parent_slot).gui_element_entity != parent_slot.container_entity) { draw_pixel_line_connector(get_rect_absolute(), get_meta(parent_slot.container_entity).get_rect_absolute(), in, border_col); } if (draw_container_opened_mark) { if (item->find<components::container>()) { components::sprite container_status_sprite; if(is_container_open) container_status_sprite.set(assets::CONTAINER_OPEN_ICON, border_col); else container_status_sprite.set(assets::CONTAINER_CLOSED_ICON, border_col); shared::state_for_drawing_renderable state; state.screen_space_mode = true; state.overridden_target_buffer = &in.v; state.renderable_transform.pos.set(get_rect_absolute().r - container_status_sprite.size.x + 2, get_rect_absolute().t + 1 //- container_status_sprite.size.y + 2 ); container_status_sprite.draw(state); } } }
void slot_button::draw(const viewing_gui_context& context, const const_this_in_container& this_id, augs::gui::draw_info info) { if (!this_id->get_flag(augs::gui::flag::ENABLE_DRAWING)) { return; } const auto& step = context.get_step(); const auto& cosmos = step.get_cosmos(); const auto slot_id = cosmos[this_id.get_location().slot_id]; const bool is_hand_slot = slot_id.is_hand_slot(); const auto& detector = this_id->detector; rgba inside_col, border_col; if (slot_id->for_categorized_items_only) { inside_col = violet; } else { inside_col = cyan; } border_col = inside_col; inside_col.a = 4 * 5; border_col.a = 220; if (detector.is_hovered || detector.current_appearance == augs::gui::appearance_detector::appearance::pushed) { inside_col.a = 12 * 5; border_col.a = 255; } const auto inside_tex = assets::texture_id::ATTACHMENT_CIRCLE_FILLED; const auto border_tex = assets::texture_id::ATTACHMENT_CIRCLE_BORDER; const augs::gui::material inside_mat(inside_tex, inside_col); const augs::gui::material border_mat(border_tex, border_col); if (slot_id->always_allow_exactly_one_item) { draw_centered_texture(context, this_id, info, inside_mat); draw_centered_texture(context, this_id, info, border_mat); const auto slot_type = slot_id.get_id().type; if (slot_type == slot_function::PRIMARY_HAND) { draw_centered_texture(context, this_id, info, augs::gui::material(assets::texture_id::PRIMARY_HAND_ICON, border_col), vec2i(1, 0)); } if (slot_type == slot_function::SECONDARY_HAND) { draw_centered_texture(context, this_id, info, augs::gui::material(assets::texture_id::SECONDARY_HAND_ICON, border_col)); } if (slot_type == slot_function::SHOULDER_SLOT) { draw_centered_texture(context, this_id, info, augs::gui::material(assets::texture_id::SHOULDER_SLOT_ICON, border_col)); } if (slot_type == slot_function::TORSO_ARMOR_SLOT) { draw_centered_texture(context, this_id, info, augs::gui::material(assets::texture_id::ARMOR_SLOT_ICON, border_col)); } if (slot_type == slot_function::GUN_CHAMBER) { draw_centered_texture(context, this_id, info, augs::gui::material(assets::texture_id::CHAMBER_SLOT_ICON, border_col)); } if (slot_type == slot_function::GUN_MUZZLE) { draw_centered_texture(context, this_id, info, augs::gui::material(assets::texture_id::GUN_MUZZLE_SLOT_ICON, border_col)); } if (slot_type == slot_function::GUN_DETACHABLE_MAGAZINE) { draw_centered_texture(context, this_id, info, augs::gui::material(assets::texture_id::DETACHABLE_MAGAZINE_ICON, border_col)); } } else { draw_centered_texture(context, this_id, info, inside_mat); draw_centered_texture(context, this_id, info, border_mat); const auto space_available_text = augs::gui::text::format(to_wstring(slot_id.calculate_free_space_with_parent_containers() / long double(SPACE_ATOMS_PER_UNIT), 2, true) , augs::gui::text::style(assets::font_id::GUI_FONT, border_col)); augs::gui::text_drawer space_caption; space_caption.set_text(space_available_text); space_caption.center(context.get_tree_entry(this_id).get_absolute_rect()); space_caption.draw(info); draw_children(context, this_id, info); } if (slot_id.get_container().get_owning_transfer_capability() != slot_id.get_container()) { const_dereferenced_location<item_button_in_item> child_item_button = context.dereference_location(item_button_in_item{ slot_id.get_container().get_id() }); draw_pixel_line_connector(context.get_tree_entry(this_id).get_absolute_rect(), context.get_tree_entry(child_item_button).get_absolute_rect(), info, border_col); } }