allow changing avatar scale without saving; revert on cancel

This commit is contained in:
Alexander Ivash 2018-05-22 04:51:27 +03:00
parent 67b2512a2a
commit b445cc6105
3 changed files with 41 additions and 2 deletions

View file

@ -253,8 +253,15 @@ Rectangle {
close();
}
onCancelClicked: function() {
emitSendToScript({'method' : 'revertScale', 'avatarScale' : avatarScaleBackup});
close();
}
onScaleChanged: {
console.debug('AvatarApp.qml: onScaleChanged: ', scale);
emitSendToScript({'method' : 'setScale', 'avatarScale' : scale})
}
}
AdjustWearables {

View file

@ -12,6 +12,8 @@ Rectangle {
color: 'white'
visible: false;
signal scaleChanged(real scale);
property alias onSaveClicked: dialogButtons.onYesClicked
property alias onCancelClicked: dialogButtons.onNoClicked
@ -21,10 +23,14 @@ Rectangle {
property alias avatarAnimationJSON: avatarAnimationUrlInputText.text
property alias avatarCollisionSoundUrl: avatarCollisionSoundUrlInputText.text
property real avatarScaleBackup;
function open(settings, avatarScale) {
console.debug('Settings.qml: open: ', JSON.stringify(settings, 0, 4));
avatarScaleBackup = avatarScale;
scaleSlider.notify = false;
scaleSlider.value = Math.round(avatarScale * 10);
scaleSlider.notify = true;;
if(settings.dominantHand === 'left') {
leftHandRadioButton.checked = true;
@ -96,8 +102,19 @@ Rectangle {
HifiControlsUit.Slider {
id: scaleSlider
property bool notify: false;
from: 1
to: 30
to: 40
onValueChanged: {
console.debug('value changed: ', value);
if(notify) {
console.debug('notifying.. ');
root.scaleChanged(value / 10);
}
}
anchors.verticalCenter: parent.verticalCenter
Layout.fillWidth: true

View file

@ -108,11 +108,14 @@ var currentAvatarWearablesBackup = null;
var currentAvatar = null;
var currentAvatarSettings = getMyAvatarSettings();
var notifyScaleChanged = true;
function onTargetScaleChanged() {
console.debug('onTargetScaleChanged: ', MyAvatar.getAvatarScale());
if(currentAvatar.scale !== MyAvatar.getAvatarScale()) {
currentAvatar.scale = MyAvatar.getAvatarScale();
sendToQml({'method' : 'scaleChanged', 'value' : currentAvatar.scale})
if(notifyScaleChanged) {
sendToQml({'method' : 'scaleChanged', 'value' : currentAvatar.scale})
}
}
}
@ -259,6 +262,18 @@ function fromQml(message) { // messages are {method, params}, like json-rpc. See
tablet.gotoWebScreen(message.url);
}
break;
case 'setScale':
console.debug('avatarapp.js: setScale: ', message.avatarScale);
notifyScaleChanged = false;
MyAvatar.setAvatarScale(message.avatarScale);
currentAvatar.avatarScale = message.avatarScale;
notifyScaleChanged = true;
break;
case 'revertScale':
console.debug('avatarapp.js: revertScale: ', message.avatarScale);
MyAvatar.setAvatarScale(message.avatarScale);
currentAvatar.avatarScale = message.avatarScale;
break;
case 'saveSettings':
console.debug('avatarapp.js: saveSettings: ', JSON.stringify(message.settings, 0, 4));