From 4ce8e29d97ec268ff8be8b2a95625dbf132308f5 Mon Sep 17 00:00:00 2001
From: Alexander Ivash <elderorb@gmail.com>
Date: Mon, 14 May 2018 22:46:49 +0300
Subject: [PATCH] navigate to BodyMart / AvatarIsland on 'get avatars' / 'get
 wearables'

---
 interface/resources/qml/hifi/AvatarApp.qml | 76 +---------------------
 scripts/system/avatarapp.js                | 21 +++---
 2 files changed, 14 insertions(+), 83 deletions(-)

diff --git a/interface/resources/qml/hifi/AvatarApp.qml b/interface/resources/qml/hifi/AvatarApp.qml
index e866b1c56e..e78a138247 100644
--- a/interface/resources/qml/hifi/AvatarApp.qml
+++ b/interface/resources/qml/hifi/AvatarApp.qml
@@ -430,7 +430,7 @@ Rectangle {
                     }
 
                     popup.showGetWearables(function() {
-                        gotoAvatarAppPanel.visible = true;
+                        emitSendToScript({'method' : 'navigate', 'url' : 'hifi://AvatarIsland'})
                     })
                 }
             }
@@ -674,7 +674,7 @@ Rectangle {
 
                                 onClicked: {
                                     popup.showBuyAvatars(function() {
-                                        gotoAvatarAppPanel.visible = true;
+                                        emitSendToScript({'method' : 'navigate', 'url' : 'hifi://BodyMart'})
                                     });
                                 }
                             }
@@ -742,76 +742,4 @@ Rectangle {
     CreateFavoriteDialog {
         id: createFavorite
     }
-
-    Rectangle {
-        id: gotoAvatarAppPanel
-        anchors.fill: parent
-        anchors.leftMargin: 19
-        anchors.rightMargin: 19
-
-        // color: 'green'
-        visible: false
-
-        Rectangle {
-            width: 442
-            height: 447
-            // color: 'yellow'
-
-            anchors.bottom: parent.bottom
-            anchors.bottomMargin: 259
-
-            TextStyle1 {
-                anchors.fill: parent
-                horizontalAlignment: "AlignHCenter"
-                wrapMode: "WordWrap"
-                text: "You are teleported to “AvatarIsland” VR world and you buy a hat, sunglasses and a bracelet."
-            }
-        }
-
-        Rectangle {
-            width: 442
-            height: 177
-            // color: 'yellow'
-
-            anchors.bottom: parent.bottom
-            anchors.bottomMargin: 40
-
-            TextStyle1 {
-                anchors.fill: parent
-                horizontalAlignment: "AlignHCenter"
-                wrapMode: "WordWrap"
-                text: '<a href="https://fake.link">Click here to open the Avatar app.</a>'
-
-                MouseArea {
-                    anchors.fill: parent
-                    property int newAvatarIndex: 0
-
-                    onClicked: {
-                        gotoAvatarAppPanel.visible = false;
-
-                        var i = allAvatars.count + 1;
-
-                        var avatar = {
-                            'url': '',
-                            'name': 'Lexi' + (++newAvatarIndex),
-                            'wearables': []
-                        };
-
-                        allAvatars.append(avatar)
-
-                        if(pageOfAvatars.hasGetAvatars())
-                            pageOfAvatars.removeGetAvatars();
-
-                        if(pageOfAvatars.count !== view.itemsPerPage)
-                            pageOfAvatars.append(avatar);
-
-                        if(pageOfAvatars.count !== view.itemsPerPage)
-                            pageOfAvatars.appendGetAvatars();
-
-                        console.debug('avatar appended: allAvatars.count: ', allAvatars.count, 'pageOfAvatars.count: ', pageOfAvatars.count);
-                    }
-                }
-            }
-        }
-    }
 }
diff --git a/scripts/system/avatarapp.js b/scripts/system/avatarapp.js
index e318a4bfd3..53406bb48f 100644
--- a/scripts/system/avatarapp.js
+++ b/scripts/system/avatarapp.js
@@ -128,15 +128,6 @@ function fromQml(message) { // messages are {method, params}, like json-rpc. See
         console.debug('avatarapp.js: currentAvatar: ', JSON.stringify(message.reply.currentAvatar, null, '\t'))
         sendToQml(message)
         break;
-    case 'adjustWearable':
-        if(message.properties.localRotationAngles) {
-            message.properties.localRotation = Quat.fromVec3Degrees(message.properties.localRotationAngles)
-        }
-
-        console.debug('Entities.editEntity(message.entityID, message.properties)'.replace('message.entityID', message.entityID).replace('message.properties', JSON.stringify(message.properties)));
-        Entities.editEntity(message.entityID, message.properties);
-        sendToQml({'method' : 'wearableUpdated', 'wearable' : message.entityID, wearableIndex : message.wearableIndex, properties : message.properties})
-        break;
     case 'selectAvatar':
         console.debug('avatarapp.js: selecting avatar: ', message.name);
         AvatarBookmarks.loadBookmark(message.name);
@@ -149,6 +140,14 @@ function fromQml(message) { // messages are {method, params}, like json-rpc. See
         console.debug('avatarapp.js: saving avatar: ', message.name);
         AvatarBookmarks.addBookmark(message.name);
         break;
+    case 'adjustWearable':
+        if(message.properties.localRotationAngles) {
+            message.properties.localRotation = Quat.fromVec3Degrees(message.properties.localRotationAngles)
+        }
+        console.debug('Entities.editEntity(message.entityID, message.properties)'.replace('message.entityID', message.entityID).replace('message.properties', JSON.stringify(message.properties)));
+        Entities.editEntity(message.entityID, message.properties);
+        sendToQml({'method' : 'wearableUpdated', 'wearable' : message.entityID, wearableIndex : message.wearableIndex, properties : message.properties})
+        break;
     case 'adjustWearablesOpened':
         console.debug('avatarapp.js: adjustWearablesOpened');
 
@@ -190,6 +189,10 @@ function fromQml(message) { // messages are {method, params}, like json-rpc. See
             UserActivityLogger.palAction("display_name_change", message.displayName);
         }
         break;
+    case 'navigate':
+        console.debug('avatarapp.js: navigate: ', message.url);
+        AddressManager.handleLookupString(message.url, false);
+        break;
     default:
         print('Unrecognized message from AvatarApp.qml:', JSON.stringify(message));
     }