From 3ebdc59071b8d9a23ef176e3e62c03337219815f Mon Sep 17 00:00:00 2001 From: Kasen IO Date: Thu, 9 Apr 2020 03:12:51 -0400 Subject: [PATCH] Add serverless item support. --- scripts/system/inventory/public/inventory.js | 15 +++++++--- scripts/system/inventory/src/App.vue | 29 ++++++++++++++------ 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/scripts/system/inventory/public/inventory.js b/scripts/system/inventory/public/inventory.js index 362c8a1a36..e22ee7b1ad 100644 --- a/scripts/system/inventory/public/inventory.js +++ b/scripts/system/inventory/public/inventory.js @@ -165,12 +165,15 @@ function useItem(item) { //TODO: Add animation support for avatars, add JSON loading...? + // Convert the item.type before checking it... + item.type = item.type.toUpperCase(); + // Depending on the type, we decide how to load this item. - if (item.type == "script") { + if (item.type == "SCRIPT") { ScriptDiscoveryService.loadScript(item.url, true, false, false, true, false); // See SDS.loadScript in APIDocs for more. } - if (item.type == "model") { + if (item.type == "MODEL") { var entityID = Entities.addEntity({ type: "Model", position: Vec3.sum(MyAvatar.position, Vec3.multiplyQbyV(MyAvatar.orientation, { x: 0, y: 0, z: -3 })), @@ -180,11 +183,15 @@ function useItem(item) { }); } - if (item.type == "avatar") { + if (item.type == "AVATAR") { MyAvatar.useFullAvatarURL(item.url); } - if (item.type == "unknown") { + if (item.type == "SERVERLESS") { + location.handleLookupString(item.url, true); // https://apidocs.vircadia.dev/location.html#.handleLookupString + } + + if (item.type == "UNKNOWN") { // We don't know how to handle this yet. Window.alert("Unknown item type, unable to use."); } diff --git a/scripts/system/inventory/src/App.vue b/scripts/system/inventory/src/App.vue index 100a61ec74..b9a465d7a2 100644 --- a/scripts/system/inventory/src/App.vue +++ b/scripts/system/inventory/src/App.vue @@ -1,4 +1,4 @@ - - {{displayIcon(item.type)}} + {{getIcon(item.type)}} @@ -256,7 +256,7 @@ dark v-on="on" > - {{displayIcon(item.type)}} + {{getIcon(item.type)}} - {{displayIcon(item.type)}} + {{getIcon(item.type)}} @@ -895,8 +895,8 @@ export default { "uuid": "54254354980-7667jt353", }, { - "type": "model", - "name": "3D MODEL", + "type": "serverless", + "name": "SERVERLESS DOMAIN", "url": "https://googleee.com/vr.fbx", "uuid": "542543sg45s4gg54353", }, @@ -914,6 +914,10 @@ export default { "icon": "mdi-account-convert", "color": "purple", }, + "serverless": { + "icon": "mdi-earth", + "color": "#0097A7", // cyan darken-2 + }, "unknown": { "icon": "mdi-help", "color": "grey", @@ -1092,6 +1096,9 @@ export default { case "script": detectedItemType = "script"; break; + case "serverless": + detectedItemType = "serverless"; + break; } if (detectedItemType == null) { @@ -1207,7 +1214,11 @@ export default { }); }, acceptItem: function() { - this.pushToItems(this.checkItemType(this.receiveDialog.data.type), this.receiveDialog.data.name, this.receiveDialog.data.url); + this.pushToItems( + this.checkItemType(this.receiveDialog.data.type), + this.receiveDialog.data.name, + this.receiveDialog.data.url + ); }, useItem: function(type, url) { this.sendAppMessage("use-item", { @@ -1271,7 +1282,7 @@ export default { this.settings = receivedSettings; } }, - displayIcon: function(itemType) { + getIcon: function(itemType) { return this.iconType[itemType].icon; }, getIconColor: function(itemType) {