mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-07 02:33:23 +02:00
add possibility to add wearable from external url
This commit is contained in:
parent
9234813e08
commit
90fb0d7be6
4 changed files with 59 additions and 0 deletions
|
@ -285,6 +285,9 @@ Rectangle {
|
|||
onWearableSelected: {
|
||||
emitSendToScript({'method' : 'selectWearable', 'entityID' : id});
|
||||
}
|
||||
onAddWearable: {
|
||||
emitSendToScript({'method' : 'addWearable', 'avatarName' : avatarName, 'url' : url});
|
||||
}
|
||||
|
||||
z: 3
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ Rectangle {
|
|||
|
||||
signal adjustWearablesOpened(var avatarName);
|
||||
signal adjustWearablesClosed(bool status, var avatarName);
|
||||
signal addWearable(string avatarName, string url);
|
||||
|
||||
property bool modified: false;
|
||||
Component.onCompleted: {
|
||||
|
@ -40,6 +41,8 @@ Rectangle {
|
|||
|
||||
function refresh(avatar) {
|
||||
wearablesCombobox.model.clear();
|
||||
wearablesCombobox.currentIndex = -1;
|
||||
|
||||
for(var i = 0; i < avatar.wearables.count; ++i) {
|
||||
var wearable = avatar.wearables.get(i).properties;
|
||||
for(var j = (wearable.modelURL.length - 1); j >= 0; --j) {
|
||||
|
@ -167,6 +170,12 @@ Rectangle {
|
|||
linkColor: hifi.colors.blueHighlight
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.right: parent.right
|
||||
onLinkActivated: {
|
||||
popup.showSpecifyWearableUrl(function(url) {
|
||||
console.debug('popup.showSpecifyWearableUrl: ', url);
|
||||
addWearable(root.avatarName, url);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,26 @@ MessageBox {
|
|||
popup.inputText.forceActiveFocus();
|
||||
}
|
||||
|
||||
function showSpecifyWearableUrl(callback) {
|
||||
popup.button2text = 'CONFIRM'
|
||||
popup.button1text = 'CANCEL'
|
||||
popup.titleText = 'Specify Wearable URL'
|
||||
popup.bodyText = 'If you want to add a custom wearable, you can specify the URL of the wearable file here.'
|
||||
|
||||
popup.inputText.visible = true;
|
||||
popup.inputText.placeholderText = 'Enter Wearable URL';
|
||||
|
||||
popup.onButton2Clicked = function() {
|
||||
if(callback)
|
||||
callback(popup.inputText.text);
|
||||
|
||||
popup.close();
|
||||
}
|
||||
|
||||
popup.open();
|
||||
popup.inputText.forceActiveFocus();
|
||||
}
|
||||
|
||||
property url getWearablesUrl: '../../../images/avatarapp/AvatarIsland.jpg'
|
||||
|
||||
function showGetWearables(callback, linkCallback) {
|
||||
|
|
|
@ -235,6 +235,33 @@ function fromQml(message) { // messages are {method, params}, like json-rpc. See
|
|||
Messages.messageReceived.disconnect(handleWearableMessages);
|
||||
Messages.unsubscribe('Hifi-Object-Manipulation');
|
||||
break;
|
||||
case 'addWearable':
|
||||
|
||||
var joints = MyAvatar.getJointNames();
|
||||
var hipsIndex = -1;
|
||||
|
||||
for(var i = 0; i < joints.length; ++i) {
|
||||
if(joints[i] === 'Hips') {
|
||||
hipsIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var properties = {
|
||||
name: "Custom wearable",
|
||||
type: "Model",
|
||||
modelURL: message.url,
|
||||
parentID: MyAvatar.sessionUUID,
|
||||
relayParentJoints: false,
|
||||
parentJointIndex: hipsIndex
|
||||
};
|
||||
|
||||
var entityID = Entities.addEntity(properties, true);
|
||||
updateAvatarWearables(currentAvatar, message.avatarName);
|
||||
executeLater(function() {
|
||||
onSelectedEntity(entityID);
|
||||
});
|
||||
break;
|
||||
case 'selectWearable':
|
||||
ensureWearableSelected(message.entityID);
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue