mirror of
https://github.com/overte-org/overte.git
synced 2025-06-20 20:00:09 +02:00
allow changing avatar scale without saving; revert on cancel
This commit is contained in:
parent
67b2512a2a
commit
b445cc6105
3 changed files with 41 additions and 2 deletions
|
@ -253,8 +253,15 @@ Rectangle {
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
onCancelClicked: function() {
|
onCancelClicked: function() {
|
||||||
|
emitSendToScript({'method' : 'revertScale', 'avatarScale' : avatarScaleBackup});
|
||||||
|
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onScaleChanged: {
|
||||||
|
console.debug('AvatarApp.qml: onScaleChanged: ', scale);
|
||||||
|
emitSendToScript({'method' : 'setScale', 'avatarScale' : scale})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AdjustWearables {
|
AdjustWearables {
|
||||||
|
|
|
@ -12,6 +12,8 @@ Rectangle {
|
||||||
color: 'white'
|
color: 'white'
|
||||||
visible: false;
|
visible: false;
|
||||||
|
|
||||||
|
signal scaleChanged(real scale);
|
||||||
|
|
||||||
property alias onSaveClicked: dialogButtons.onYesClicked
|
property alias onSaveClicked: dialogButtons.onYesClicked
|
||||||
property alias onCancelClicked: dialogButtons.onNoClicked
|
property alias onCancelClicked: dialogButtons.onNoClicked
|
||||||
|
|
||||||
|
@ -21,10 +23,14 @@ Rectangle {
|
||||||
property alias avatarAnimationJSON: avatarAnimationUrlInputText.text
|
property alias avatarAnimationJSON: avatarAnimationUrlInputText.text
|
||||||
property alias avatarCollisionSoundUrl: avatarCollisionSoundUrlInputText.text
|
property alias avatarCollisionSoundUrl: avatarCollisionSoundUrlInputText.text
|
||||||
|
|
||||||
|
property real avatarScaleBackup;
|
||||||
function open(settings, avatarScale) {
|
function open(settings, avatarScale) {
|
||||||
console.debug('Settings.qml: open: ', JSON.stringify(settings, 0, 4));
|
console.debug('Settings.qml: open: ', JSON.stringify(settings, 0, 4));
|
||||||
|
avatarScaleBackup = avatarScale;
|
||||||
|
|
||||||
|
scaleSlider.notify = false;
|
||||||
scaleSlider.value = Math.round(avatarScale * 10);
|
scaleSlider.value = Math.round(avatarScale * 10);
|
||||||
|
scaleSlider.notify = true;;
|
||||||
|
|
||||||
if(settings.dominantHand === 'left') {
|
if(settings.dominantHand === 'left') {
|
||||||
leftHandRadioButton.checked = true;
|
leftHandRadioButton.checked = true;
|
||||||
|
@ -96,8 +102,19 @@ Rectangle {
|
||||||
|
|
||||||
HifiControlsUit.Slider {
|
HifiControlsUit.Slider {
|
||||||
id: scaleSlider
|
id: scaleSlider
|
||||||
|
property bool notify: false;
|
||||||
|
|
||||||
from: 1
|
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
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
||||||
|
|
|
@ -108,13 +108,16 @@ var currentAvatarWearablesBackup = null;
|
||||||
var currentAvatar = null;
|
var currentAvatar = null;
|
||||||
var currentAvatarSettings = getMyAvatarSettings();
|
var currentAvatarSettings = getMyAvatarSettings();
|
||||||
|
|
||||||
|
var notifyScaleChanged = true;
|
||||||
function onTargetScaleChanged() {
|
function onTargetScaleChanged() {
|
||||||
console.debug('onTargetScaleChanged: ', MyAvatar.getAvatarScale());
|
console.debug('onTargetScaleChanged: ', MyAvatar.getAvatarScale());
|
||||||
if(currentAvatar.scale !== MyAvatar.getAvatarScale()) {
|
if(currentAvatar.scale !== MyAvatar.getAvatarScale()) {
|
||||||
currentAvatar.scale = MyAvatar.getAvatarScale();
|
currentAvatar.scale = MyAvatar.getAvatarScale();
|
||||||
|
if(notifyScaleChanged) {
|
||||||
sendToQml({'method' : 'scaleChanged', 'value' : currentAvatar.scale})
|
sendToQml({'method' : 'scaleChanged', 'value' : currentAvatar.scale})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function onDominantHandChanged(dominantHand) {
|
function onDominantHandChanged(dominantHand) {
|
||||||
console.debug('onDominantHandChanged: ', dominantHand);
|
console.debug('onDominantHandChanged: ', dominantHand);
|
||||||
|
@ -259,6 +262,18 @@ function fromQml(message) { // messages are {method, params}, like json-rpc. See
|
||||||
tablet.gotoWebScreen(message.url);
|
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;
|
break;
|
||||||
case 'saveSettings':
|
case 'saveSettings':
|
||||||
console.debug('avatarapp.js: saveSettings: ', JSON.stringify(message.settings, 0, 4));
|
console.debug('avatarapp.js: saveSettings: ', JSON.stringify(message.settings, 0, 4));
|
||||||
|
|
Loading…
Reference in a new issue