Beispiel #1
0
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);
}
Beispiel #2
0
void drag_and_drop_target_drop_item::rebuild_layouts(const logic_gui_context& context, const this_pointer& this_id) {
	const auto& world = context.get_rect_world();
	const_dereferenced_location<item_button_in_item> dragged_item = context._dynamic_cast<item_button_in_item>(world.rect_held_by_lmb);

	if (dragged_item != nullptr && world.held_rect_is_dragged) {
		this_id->set_flag(augs::gui::flag::ENABLE_DRAWING);
	}
	else {
		this_id->unset_flag(augs::gui::flag::ENABLE_DRAWING);
	}

	this_id->rc.set_position(context.get_gui_element_component().get_initial_position_for(*this_id) - vec2(20, 20));
	this_id->rc.set_size((*this_id->mat.tex).get_size() + vec2(40, 40));
}