From bcb373618f3a0fd7260c982f442d1c8c42aabe7b Mon Sep 17 00:00:00 2001 From: Alexander Ivash Date: Mon, 14 May 2018 23:54:13 +0300 Subject: [PATCH] navigation to market / my purchases from message dialog links --- interface/resources/qml/hifi/AvatarApp.qml | 8 ++++- .../qml/hifi/avatarapp/MessageBox.qml | 6 ++++ .../qml/hifi/avatarapp/MessageBoxes.qml | 28 +++++++++++++---- scripts/system/avatarapp.js | 31 ++++++++++--------- 4 files changed, 51 insertions(+), 22 deletions(-) diff --git a/interface/resources/qml/hifi/AvatarApp.qml b/interface/resources/qml/hifi/AvatarApp.qml index e78a138247..aa6cf4cb36 100644 --- a/interface/resources/qml/hifi/AvatarApp.qml +++ b/interface/resources/qml/hifi/AvatarApp.qml @@ -431,7 +431,10 @@ Rectangle { popup.showGetWearables(function() { emitSendToScript({'method' : 'navigate', 'url' : 'hifi://AvatarIsland'}) - }) + }, function(link) { + console.debug('link clicked', link); + emitSendToScript({'method' : 'navigate', 'url' : link}) + }); } } } @@ -675,6 +678,9 @@ Rectangle { onClicked: { popup.showBuyAvatars(function() { emitSendToScript({'method' : 'navigate', 'url' : 'hifi://BodyMart'}) + }, function(link) { + console.debug('link clicked', link); + emitSendToScript({'method' : 'navigate', 'url' : link}) }); } } diff --git a/interface/resources/qml/hifi/avatarapp/MessageBox.qml b/interface/resources/qml/hifi/avatarapp/MessageBox.qml index eef8ebcb07..c5711fe1ce 100644 --- a/interface/resources/qml/hifi/avatarapp/MessageBox.qml +++ b/interface/resources/qml/hifi/avatarapp/MessageBox.qml @@ -27,6 +27,7 @@ Rectangle { property var onButton2Clicked; property var onButton1Clicked; + property var onLinkClicked; function open() { visible = true; @@ -110,6 +111,11 @@ Rectangle { height: paintedHeight; verticalAlignment: Text.AlignTop; wrapMode: Text.WordWrap; + + onLinkActivated: { + if(onLinkClicked) + onLinkClicked(link); + } } Image { diff --git a/interface/resources/qml/hifi/avatarapp/MessageBoxes.qml b/interface/resources/qml/hifi/avatarapp/MessageBoxes.qml index 28a2e695d6..5ce7baca0b 100644 --- a/interface/resources/qml/hifi/avatarapp/MessageBoxes.qml +++ b/interface/resources/qml/hifi/avatarapp/MessageBoxes.qml @@ -18,12 +18,12 @@ MessageBox { property url getWearablesUrl: '../../../images/samples/hifi-place-77312e4b-6f48-4eb4-87e2-50444d8e56d1.png' - function showGetWearables(callback) { + function showGetWearables(callback, linkCallback) { popup.button2text = 'AvatarIsland' popup.button1text = 'CANCEL' popup.titleText = 'Get Wearables' - popup.bodyText = 'Buy wearables from Marketplace' + '\n' + - 'Wear wearable from My Purchases' + '\n' + + popup.bodyText = 'Buy wearables from Marketplace' + '\n' + + 'Wear wearable from My Purchases' + '\n' + 'You can visit the domain “AvatarIsland”' + '\n' + 'to get wearables' @@ -34,6 +34,14 @@ MessageBox { if(callback) callback(); } + + popup.onLinkClicked = function(link) { + popup.close(); + + if(linkCallback) + linkCallback(link); + } + popup.open(); } @@ -70,13 +78,13 @@ MessageBox { property url getAvatarsUrl: '../../../images/samples/hifi-place-get-avatars.png' - function showBuyAvatars(callback) { + function showBuyAvatars(callback, linkCallback) { popup.button2text = 'BodyMart' popup.button1text = 'CANCEL' popup.titleText = 'Get Avatars' - popup.bodyText = 'Buy avatars from Marketplace' + '\n' + - 'Wear avatars from My Purchases' + '\n' + + popup.bodyText = 'Buy avatars from Marketplace' + '\n' + + 'Wear avatars from My Purchases' + '\n' + 'You can visit the domain “BodyMart”' + '\n' + 'to get avatars' @@ -87,6 +95,14 @@ MessageBox { if(callback) callback(); } + + popup.onLinkClicked = function(link) { + popup.close(); + + if(linkCallback) + linkCallback(link); + } + popup.open(); } } diff --git a/scripts/system/avatarapp.js b/scripts/system/avatarapp.js index 53406bb48f..f126d69d99 100644 --- a/scripts/system/avatarapp.js +++ b/scripts/system/avatarapp.js @@ -47,20 +47,6 @@ function getMyAvatarWearables() { } return wearablesArray; - - /* - var getAttachedModelEntities = function() { - var resultEntities = []; - Entities.findEntitiesByType('Model', MyAvatar.position, 100).forEach(function(entityID) { - if (isEntityBeingWorn(entityID)) { - resultEntities.push({properties : entityID}); - } - }); - return resultEntities; - }; - - return getAttachedModelEntities(); - */ } function getMyAvatar() { @@ -114,6 +100,10 @@ var currentAvatar = null; var selectedAvatarEntityGrabbable = false; var selectedAvatarEntity = null; +var MARKETPLACE_PURCHASES_QML_PATH = "hifi/commerce/purchases/Purchases.qml"; +var MARKETPLACE_URL = Account.metaverseServerURL + "/marketplace"; +var MARKETPLACES_INJECT_SCRIPT_URL = Script.resolvePath("../html/js/marketplacesInject.js"); + function fromQml(message) { // messages are {method, params}, like json-rpc. See also sendToQml. console.debug('fromQml: message = ', JSON.stringify(message, null, '\t')) @@ -191,7 +181,18 @@ function fromQml(message) { // messages are {method, params}, like json-rpc. See break; case 'navigate': console.debug('avatarapp.js: navigate: ', message.url); - AddressManager.handleLookupString(message.url, false); + if(message.url.indexOf('app://') === 0) { + var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system") + + if(message.url === 'app://marketplace') { + tablet.gotoWebScreen(MARKETPLACE_URL, MARKETPLACES_INJECT_SCRIPT_URL); + } else if(message.url === 'app://purchases') { + tablet.pushOntoStack(MARKETPLACE_PURCHASES_QML_PATH); + } + + } else if(message.url.indexOf('hifi://') === 0) { + AddressManager.handleLookupString(message.url, false); + } break; default: print('Unrecognized message from AvatarApp.qml:', JSON.stringify(message));