예제 #1
0
bool CPetInventoryGlyph::dragGlyph(const Point &topLeft, CMouseDragStartMsg *msg) {
	if (!_item)
		return false;

	if (_background) {
		_field34 = 0;
		stopMovie();
	}

	CPetControl *petControl = getPetControl();
	if (!petControl)
		return false;

	CGameObject *carryParcel = petControl->getHiddenObject("CarryParcel");

	if (petControl->isSuccUBusActive() && carryParcel) {
		petControl->removeFromInventory(_item, carryParcel, false, true);
		petControl->removeFromInventory(_item, false, false);

		carryParcel->setPosition(Point(msg->_mousePos.x - carryParcel->getBounds().width() / 2,
			msg->_mousePos.y - carryParcel->getBounds().height() / 2));
		_item->setPosition(Point(SCREEN_WIDTH, SCREEN_HEIGHT));
	} else {
		petControl->removeFromInventory(_item, false, true);

		_item->setPosition(Point(msg->_mousePos.x - carryParcel->getBounds().width() / 2,
			msg->_mousePos.y - carryParcel->getBounds().height() / 2));
		_item->setVisible(true);
	}

	msg->_handled = true;
	if (msg->execute(carryParcel)) {
		_item = nullptr;
		_background = nullptr;
		_field34 = 0;
		petControl->setAreaChangeType(1);
		return true;
	} else {
		petControl->addToInventory(carryParcel);
		return false;
	}
}