void slot_button::update_rc(const logic_gui_context& context, const this_in_container& this_id) { const auto& step = context.get_step(); const auto& cosmos = step.get_cosmos(); const auto slot_id = cosmos[this_id.get_location().slot_id]; if (slot_id->always_allow_exactly_one_item) { this_id->set_flag(augs::gui::flag::ENABLE_DRAWING); if (slot_id.has_items()) { const_dereferenced_location<item_button_in_item> child_item_button = context.dereference_location(item_button_in_item{ slot_id.get_items_inside()[0].get_id() }); if (child_item_button->is_being_wholely_dragged_or_pending_finish(context, child_item_button)) { this_id->set_flag(augs::gui::flag::ENABLE_DRAWING); } else { this_id->unset_flag(augs::gui::flag::ENABLE_DRAWING); } } } this_id->slot_relative_pos = griddify(this_id->slot_relative_pos); this_id->user_drag_offset = griddify(this_id->user_drag_offset); vec2i absolute_pos = this_id->slot_relative_pos + this_id->user_drag_offset; if (context.get_rect_world().is_currently_dragging(this_id)) { absolute_pos += griddify(context.get_rect_world().current_drag_amount); } this_id->rc.set_position(absolute_pos); }
void slot_button::update_rc(const game_gui_context context, const this_in_container this_id) { const auto& cosm = context.get_cosmos(); const auto slot_handle = cosm[this_id.get_location().slot_id]; bool should_draw = false; const auto container_entity = slot_handle.get_container(); const bool is_capable = container_entity.has<components::item_slot_transfers>(); if (slot_handle->always_allow_exactly_one_item) { should_draw = false; if (slot_handle.has_items()) { const auto child_item_button = context.const_dereference_location(item_button_in_item{ slot_handle.get_items_inside()[0] }); if (child_item_button->is_being_wholely_dragged_or_pending_finish(context, child_item_button)) { should_draw = true; } } else { should_draw = true; } } else { should_draw = is_capable; } this_id->set_flag(augs::gui::flag::ENABLE_DRAWING, should_draw); this_id->user_drag_offset = griddify(this_id->user_drag_offset); vec2 inventory_root_offset; if (is_capable) { const auto ss = context.get_screen_size(); inventory_root_offset = ss; if (ss.x < 1800) { inventory_root_offset.x -= 300; inventory_root_offset.y -= 200; } else { inventory_root_offset.x -= 300; inventory_root_offset.y -= 100; } } const auto standard_relative_pos = ltrb(character_gui::get_rectangle_for_slot_function(this_id.get_location().slot_id.type)); vec2i absolute_pos = griddify(standard_relative_pos.get_position()) + this_id->user_drag_offset + inventory_root_offset; if (context.get_rect_world().is_currently_dragging(this_id)) { absolute_pos += griddify(context.get_rect_world().current_drag_amount); } this_id->rc.set_position(absolute_pos); this_id->rc.set_size(standard_relative_pos.get_size()); }