예제 #1
0
void Inventory::touchRelease(Vector2 position)
{
	touchOffset.set(-1, -1);

	if (iconTouched != NULL){



		if (iconTouched->preview){
			
			Vector2 fieldCoords = playField->screenToFieldCoordinates(position);

			// check to see if fieldCoords is within character's radius
			float length = fieldCoords.distance(belongsTo->GetPosition());
			if (length < belongsTo->GetRadius())
				belongsTo->equipItem(iconTouched->item);
			else
				playField->putItemInTile(iconTouched->item, fieldCoords.x, fieldCoords.y);
			// remove the icon here
			removeItem(iconTouched);
		}
		else{
			// put the icon back where it belongs
			addItem(iconTouched
				, findClosestMatch(iconTouched));
		}
		iconTouched = NULL;
	}
	else{
		Vector2 menuPos(menuRec.x, menuRec.y);

		float dockLength = (menuPos - dockPosition).length();
		float outLength = (menuPos - outPosition).length();

		// check for a tap first
		if (outLength < TAP_LEEWAY && touchTimer < TAP_DURATION)
			slideTo(dockPosition, dockLength / dockToOutLength * SLIDE_TIME);
		else if (dockLength < TAP_LEEWAY && touchTimer < TAP_DURATION)
			slideTo(outPosition, outLength / dockToOutLength * SLIDE_TIME);
		// otherwise see if drug
		else if (menuPos != dockPosition && menuPos != outPosition){
		
			if (dockLength < outLength)
				slideTo(dockPosition, dockLength / dockToOutLength * SLIDE_TIME);
			else if(outLength < dockLength)
				slideTo(outPosition, outLength / dockToOutLength * SLIDE_TIME);
		}
	}


	touchTimer = 0;
}
    void insert(const QString &domain, const QString &user, const QString &password)
    {
        QNetworkAuthenticationCredential *closestMatch = findClosestMatch(domain);
        if (closestMatch && closestMatch->domain == domain) {
            // we're overriding the current credentials
            closestMatch->user = user;
            closestMatch->password = password;
        } else {
            QNetworkAuthenticationCredential newCredential;
            newCredential.domain = domain;
            newCredential.user = user;
            newCredential.password = password;

            if (closestMatch)
                QVector<QNetworkAuthenticationCredential>::insert(++closestMatch, newCredential);
            else
                QVector<QNetworkAuthenticationCredential>::insert(end(), newCredential);
        }
    }