mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-04 15:21:32 +02:00
show real wearables from avatar in combobox
This commit is contained in:
parent
245ab7a309
commit
4fa72eab6d
4 changed files with 58 additions and 16 deletions
|
@ -46,6 +46,7 @@ FocusScope {
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
visible: true
|
visible: true
|
||||||
height: hifi.fontSizes.textFieldInput + 13 // Match height of TextField control.
|
height: hifi.fontSizes.textFieldInput + 13 // Match height of TextField control.
|
||||||
|
textRole: "text"
|
||||||
|
|
||||||
function previousItem() { root.currentHighLightedIndex = (root.currentHighLightedIndex + comboBox.count - 1) % comboBox.count; }
|
function previousItem() { root.currentHighLightedIndex = (root.currentHighLightedIndex + comboBox.count - 1) % comboBox.count; }
|
||||||
function nextItem() { root.currentHighLightedIndex = (root.currentHighLightedIndex + comboBox.count + 1) % comboBox.count; }
|
function nextItem() { root.currentHighLightedIndex = (root.currentHighLightedIndex + comboBox.count + 1) % comboBox.count; }
|
||||||
|
|
|
@ -19,10 +19,17 @@ Rectangle {
|
||||||
sendToScript(message);
|
sendToScript(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ListModel { // the only purpose of this model is to convert JS object to ListElement
|
||||||
|
id: currentAvatarModel
|
||||||
|
}
|
||||||
|
|
||||||
|
property var jointNames;
|
||||||
|
|
||||||
function fromScript(message) {
|
function fromScript(message) {
|
||||||
console.debug('AvatarApp.qml: fromScript: ', JSON.stringify(message, null, '\t'))
|
console.debug('AvatarApp.qml: fromScript: ', JSON.stringify(message, null, '\t'))
|
||||||
|
|
||||||
if(message.method === 'initialize') {
|
if(message.method === 'initialize') {
|
||||||
|
jointNames = message.reply.jointNames;
|
||||||
emitSendToScript({'method' : getAvatarsMethod});
|
emitSendToScript({'method' : getAvatarsMethod});
|
||||||
} else if(message.method === getAvatarsMethod) {
|
} else if(message.method === getAvatarsMethod) {
|
||||||
var getAvatarsReply = message.reply;
|
var getAvatarsReply = message.reply;
|
||||||
|
@ -32,7 +39,7 @@ Rectangle {
|
||||||
var avatarEntry = {
|
var avatarEntry = {
|
||||||
'name' : avatarName,
|
'name' : avatarName,
|
||||||
'url' : Qt.resolvedUrl(allAvatars.urls[i++ % allAvatars.urls.length]),
|
'url' : Qt.resolvedUrl(allAvatars.urls[i++ % allAvatars.urls.length]),
|
||||||
'wearables' : '',
|
'wearables' : getAvatarsReply.bookmarks[avatarName].avatarEntites ? getAvatarsReply.bookmarks[avatarName].avatarEntites : [],
|
||||||
'entry' : getAvatarsReply.bookmarks[avatarName],
|
'entry' : getAvatarsReply.bookmarks[avatarName],
|
||||||
'getMoreAvatars' : false
|
'getMoreAvatars' : false
|
||||||
};
|
};
|
||||||
|
@ -76,14 +83,18 @@ Rectangle {
|
||||||
console.debug('selectedAvatarIndex = -1, avatar is not favorite')
|
console.debug('selectedAvatarIndex = -1, avatar is not favorite')
|
||||||
|
|
||||||
if(selectedAvatarIndex === -1) {
|
if(selectedAvatarIndex === -1) {
|
||||||
var currentAvatarEntry = {
|
|
||||||
|
var currentAvatarEntry = {
|
||||||
'name' : '',
|
'name' : '',
|
||||||
'url' : Qt.resolvedUrl(allAvatars.urls[i++ % allAvatars.urls.length]),
|
'url' : Qt.resolvedUrl(allAvatars.urls[i++ % allAvatars.urls.length]),
|
||||||
'wearables' : '',
|
'wearables' : currentAvatar.avatarEntites ? currentAvatar.avatarEntites : [],
|
||||||
'entry' : currentAvatar,
|
'entry' : currentAvatar,
|
||||||
'getMoreAvatars' : false
|
'getMoreAvatars' : false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
currentAvatarModel.append(currentAvatarEntry);
|
||||||
|
currentAvatarEntry = allAvatars.get(allAvatars.count - 1);
|
||||||
|
|
||||||
selectedAvatar = currentAvatarEntry;
|
selectedAvatar = currentAvatarEntry;
|
||||||
view.setPage(0);
|
view.setPage(0);
|
||||||
|
|
||||||
|
@ -111,7 +122,7 @@ Rectangle {
|
||||||
|
|
||||||
property string avatarName: selectedAvatar ? selectedAvatar.name : ''
|
property string avatarName: selectedAvatar ? selectedAvatar.name : ''
|
||||||
property string avatarUrl: selectedAvatar ? selectedAvatar.url : null
|
property string avatarUrl: selectedAvatar ? selectedAvatar.url : null
|
||||||
property int avatarWearablesCount: selectedAvatar && selectedAvatar.wearables !== '' ? selectedAvatar.wearables.split('|').length : 0
|
property int avatarWearablesCount: selectedAvatar ? selectedAvatar.wearables.count : 0
|
||||||
property bool isAvatarInFavorites: selectedAvatar ? allAvatars.findAvatar(selectedAvatar.name) !== undefined : false
|
property bool isAvatarInFavorites: selectedAvatar ? allAvatars.findAvatar(selectedAvatar.name) !== undefined : false
|
||||||
|
|
||||||
property bool isInManageState: false
|
property bool isInManageState: false
|
||||||
|
@ -174,6 +185,7 @@ Rectangle {
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.top: header.bottom
|
anchors.top: header.bottom
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
|
jointNames: root.jointNames
|
||||||
|
|
||||||
z: 3
|
z: 3
|
||||||
}
|
}
|
||||||
|
@ -364,7 +376,8 @@ Rectangle {
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: {
|
onClicked: {
|
||||||
adjustWearables.open();
|
console.debug('adjustWearables.open');
|
||||||
|
adjustWearables.open(selectedAvatar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -395,7 +408,7 @@ Rectangle {
|
||||||
var avatar = {
|
var avatar = {
|
||||||
'url': Qt.resolvedUrl('../../images/samples/hifi-mp-e76946cc-c272-4adf-9bb6-02cde0a4b57d-2.png'),
|
'url': Qt.resolvedUrl('../../images/samples/hifi-mp-e76946cc-c272-4adf-9bb6-02cde0a4b57d-2.png'),
|
||||||
'name': 'Lexi' + (++debug_newAvatarIndex),
|
'name': 'Lexi' + (++debug_newAvatarIndex),
|
||||||
'wearables': ''
|
'wearables': []
|
||||||
};
|
};
|
||||||
|
|
||||||
allAvatars.append(avatar)
|
allAvatars.append(avatar)
|
||||||
|
@ -629,7 +642,7 @@ Rectangle {
|
||||||
imageUrl: url
|
imageUrl: url
|
||||||
border.color: container.highlighted ? style.colors.blueHighlight : 'transparent'
|
border.color: container.highlighted ? style.colors.blueHighlight : 'transparent'
|
||||||
border.width: container.highlighted ? 2 : 0
|
border.width: container.highlighted ? 2 : 0
|
||||||
wearablesCount: (!getMoreAvatars && wearables && wearables !== '') ? wearables.split('|').length : 0
|
wearablesCount: !getMoreAvatars ? wearables.count : 0
|
||||||
onWearablesCountChanged: {
|
onWearablesCountChanged: {
|
||||||
console.debug('delegate: AvatarThumbnail.wearablesCount: ', wearablesCount)
|
console.debug('delegate: AvatarThumbnail.wearablesCount: ', wearablesCount)
|
||||||
}
|
}
|
||||||
|
@ -882,7 +895,7 @@ Rectangle {
|
||||||
var avatar = {
|
var avatar = {
|
||||||
'url': Qt.resolvedUrl(url),
|
'url': Qt.resolvedUrl(url),
|
||||||
'name': 'Lexi' + (++newAvatarIndex),
|
'name': 'Lexi' + (++newAvatarIndex),
|
||||||
'wearables': 'hat|sunglasses|bracelet'
|
'wearables': []
|
||||||
};
|
};
|
||||||
|
|
||||||
allAvatars.append(avatar)
|
allAvatars.append(avatar)
|
||||||
|
|
|
@ -22,9 +22,30 @@ Rectangle {
|
||||||
|
|
||||||
property var onButton2Clicked;
|
property var onButton2Clicked;
|
||||||
property var onButton1Clicked;
|
property var onButton1Clicked;
|
||||||
|
property var jointNames;
|
||||||
|
|
||||||
|
function open(avatar) {
|
||||||
|
console.debug('AdjustWearables.qml: open');
|
||||||
|
|
||||||
function open() {
|
|
||||||
visible = true;
|
visible = true;
|
||||||
|
wearablesCombobox.model.clear();
|
||||||
|
|
||||||
|
console.debug('AdjustWearables.qml: avatar.wearables.count: ', avatar.wearables.count);
|
||||||
|
for(var i = 0; i < avatar.wearables.count; ++i) {
|
||||||
|
var wearable = avatar.wearables.get(i).properties;
|
||||||
|
console.debug('wearable: ', JSON.stringify(wearable, null, '\t'))
|
||||||
|
|
||||||
|
for(var j = (wearable.modelURL.length - 1); j >= 0; --j) {
|
||||||
|
if(wearable.modelURL[j] === '/') {
|
||||||
|
wearable.text = wearable.modelURL.substring(j + 1) + ' [%jointIndex%]'.replace('%jointIndex%', jointNames[wearable.parentJointIndex]);
|
||||||
|
console.debug('wearable.text = ', wearable.text);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wearablesCombobox.model.append(wearable);
|
||||||
|
}
|
||||||
|
|
||||||
|
wearablesCombobox.currentIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function close() {
|
function close() {
|
||||||
|
@ -51,14 +72,13 @@ Rectangle {
|
||||||
width: parent.width - 30 * 2
|
width: parent.width - 30 * 2
|
||||||
|
|
||||||
HifiControlsUit.ComboBox {
|
HifiControlsUit.ComboBox {
|
||||||
|
id: wearablesCombobox
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
comboBox.textRole: "text"
|
||||||
|
|
||||||
model: [
|
model: ListModel {
|
||||||
'Fedora.fbx [HeadTop_End]',
|
}
|
||||||
'Fedora1.fbx [HeadTop_End]',
|
|
||||||
'Fedora2.fbx [HeadTop_End]'
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
|
|
|
@ -21,7 +21,7 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
// constants from AvatarBookmarks.h
|
// constants from AvatarBookmarks.h
|
||||||
var ENTRY_AVATAR_URL = "avatarUrl";
|
var ENTRY_AVATAR_URL = "avatarUrl";
|
||||||
var ENTRY_AVATAR_ATTACHMENTS = "attachments";
|
var ENTRY_AVATAR_ATTACHMENTS = "attachments";
|
||||||
var ENTRY_AVATAR_ENTITIES = "avatarEntities";
|
var ENTRY_AVATAR_ENTITIES = "avatarEntites";
|
||||||
var ENTRY_AVATAR_SCALE = "avatarScale";
|
var ENTRY_AVATAR_SCALE = "avatarScale";
|
||||||
var ENTRY_VERSION = "version";
|
var ENTRY_VERSION = "version";
|
||||||
|
|
||||||
|
@ -134,7 +134,15 @@ function onTabletScreenChanged(type, url) {
|
||||||
button.editProperties({isActive: onAvatarAppScreen});
|
button.editProperties({isActive: onAvatarAppScreen});
|
||||||
|
|
||||||
if (onAvatarAppScreen) {
|
if (onAvatarAppScreen) {
|
||||||
sendToQml({'method' : 'initialize'})
|
|
||||||
|
var message = {
|
||||||
|
'method' : 'initialize',
|
||||||
|
'reply' : {
|
||||||
|
'jointNames' : MyAvatar.getJointNames()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
sendToQml(message)
|
||||||
}
|
}
|
||||||
|
|
||||||
console.debug('onAvatarAppScreen: ', onAvatarAppScreen);
|
console.debug('onAvatarAppScreen: ', onAvatarAppScreen);
|
||||||
|
|
Loading…
Reference in a new issue