mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 03:58:07 +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: {
|
onWearableSelected: {
|
||||||
emitSendToScript({'method' : 'selectWearable', 'entityID' : id});
|
emitSendToScript({'method' : 'selectWearable', 'entityID' : id});
|
||||||
}
|
}
|
||||||
|
onAddWearable: {
|
||||||
|
emitSendToScript({'method' : 'addWearable', 'avatarName' : avatarName, 'url' : url});
|
||||||
|
}
|
||||||
|
|
||||||
z: 3
|
z: 3
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ Rectangle {
|
||||||
|
|
||||||
signal adjustWearablesOpened(var avatarName);
|
signal adjustWearablesOpened(var avatarName);
|
||||||
signal adjustWearablesClosed(bool status, var avatarName);
|
signal adjustWearablesClosed(bool status, var avatarName);
|
||||||
|
signal addWearable(string avatarName, string url);
|
||||||
|
|
||||||
property bool modified: false;
|
property bool modified: false;
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
@ -40,6 +41,8 @@ Rectangle {
|
||||||
|
|
||||||
function refresh(avatar) {
|
function refresh(avatar) {
|
||||||
wearablesCombobox.model.clear();
|
wearablesCombobox.model.clear();
|
||||||
|
wearablesCombobox.currentIndex = -1;
|
||||||
|
|
||||||
for(var i = 0; i < avatar.wearables.count; ++i) {
|
for(var i = 0; i < avatar.wearables.count; ++i) {
|
||||||
var wearable = avatar.wearables.get(i).properties;
|
var wearable = avatar.wearables.get(i).properties;
|
||||||
for(var j = (wearable.modelURL.length - 1); j >= 0; --j) {
|
for(var j = (wearable.modelURL.length - 1); j >= 0; --j) {
|
||||||
|
@ -167,6 +170,12 @@ Rectangle {
|
||||||
linkColor: hifi.colors.blueHighlight
|
linkColor: hifi.colors.blueHighlight
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
anchors.right: parent.right
|
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();
|
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'
|
property url getWearablesUrl: '../../../images/avatarapp/AvatarIsland.jpg'
|
||||||
|
|
||||||
function showGetWearables(callback, linkCallback) {
|
function showGetWearables(callback, linkCallback) {
|
||||||
|
|
|
@ -235,6 +235,33 @@ function fromQml(message) { // messages are {method, params}, like json-rpc. See
|
||||||
Messages.messageReceived.disconnect(handleWearableMessages);
|
Messages.messageReceived.disconnect(handleWearableMessages);
|
||||||
Messages.unsubscribe('Hifi-Object-Manipulation');
|
Messages.unsubscribe('Hifi-Object-Manipulation');
|
||||||
break;
|
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':
|
case 'selectWearable':
|
||||||
ensureWearableSelected(message.entityID);
|
ensureWearableSelected(message.entityID);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue