diff --git a/.eslintrc.js b/.eslintrc.js index a7f4291257..ecdae56594 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -40,6 +40,7 @@ module.exports = { "SoundCache": false, "Stats": false, "TextureCache": false, + "Toolbars": false, "Uuid": false, "UndoStack": false, "Vec3": false, diff --git a/scripts/defaultScripts.js b/scripts/defaultScripts.js index 6880de99b5..817d63582d 100644 --- a/scripts/defaultScripts.js +++ b/scripts/defaultScripts.js @@ -15,7 +15,7 @@ Script.load("system/users.js"); Script.load("system/mute.js"); Script.load("system/goto.js"); Script.load("system/hmd.js"); -Script.load("system/examples.js"); +Script.load("system/marketplace.js"); Script.load("system/edit.js"); Script.load("system/ignore.js"); Script.load("system/selectAudioDevice.js"); diff --git a/scripts/system/examples.js b/scripts/system/examples.js deleted file mode 100644 index 6fdb2a2874..0000000000 --- a/scripts/system/examples.js +++ /dev/null @@ -1,79 +0,0 @@ -// -// examples.js -// examples -// -// Created by Eric Levin on 8 Jan 2016 -// Copyright 2016 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -var toolIconUrl = Script.resolvePath("assets/images/tools/"); - -var EXAMPLES_URL = "https://metaverse.highfidelity.com/examples"; -var examplesWindow = new OverlayWebWindow({ - title: 'Examples', - source: "about:blank", - width: 900, - height: 700, - visible: false -}); - -var toolHeight = 50; -var toolWidth = 50; -var TOOLBAR_MARGIN_Y = 0; - - -function showExamples(marketplaceID) { - var url = EXAMPLES_URL; - if (marketplaceID) { - url = url + "/items/" + marketplaceID; - } - print("setting examples URL to " + url); - examplesWindow.setURL(url); - examplesWindow.setVisible(true); - - UserActivityLogger.openedMarketplace(); -} - -function hideExamples() { - examplesWindow.setVisible(false); - examplesWindow.setURL("about:blank"); -} - -function toggleExamples() { - if (examplesWindow.visible) { - hideExamples(); - } else { - showExamples(); - } -} - -var toolBar = Toolbars.getToolbar("com.highfidelity.interface.toolbar.system"); - -var browseExamplesButton = toolBar.addButton({ - imageURL: toolIconUrl + "market.svg", - objectName: "examples", - buttonState: 1, - defaultState: 1, - hoverState: 3, - alpha: 0.9 -}); - -function onExamplesWindowVisibilityChanged() { - browseExamplesButton.writeProperty('buttonState', examplesWindow.visible ? 0 : 1); - browseExamplesButton.writeProperty('defaultState', examplesWindow.visible ? 0 : 1); - browseExamplesButton.writeProperty('hoverState', examplesWindow.visible ? 2 : 3); -} -function onClick() { - toggleExamples(); -} -browseExamplesButton.clicked.connect(onClick); -examplesWindow.visibleChanged.connect(onExamplesWindowVisibilityChanged); - -Script.scriptEnding.connect(function () { - toolBar.removeButton("examples"); - browseExamplesButton.clicked.disconnect(onClick); - examplesWindow.visibleChanged.disconnect(onExamplesWindowVisibilityChanged); -}); diff --git a/scripts/system/marketplace.js b/scripts/system/marketplace.js new file mode 100644 index 0000000000..356ed8e8cf --- /dev/null +++ b/scripts/system/marketplace.js @@ -0,0 +1,77 @@ +// +// marketplace.js +// +// Created by Eric Levin on 8 Jan 2016 +// Copyright 2016 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +var toolIconUrl = Script.resolvePath("assets/images/tools/"); + +var MARKETPLACE_URL = "https://metaverse.highfidelity.com/marketplace"; +var marketplaceWindow = new OverlayWebWindow({ + title: "Marketplace", + source: "about:blank", + width: 900, + height: 700, + visible: false +}); + +var toolHeight = 50; +var toolWidth = 50; +var TOOLBAR_MARGIN_Y = 0; + + +function showMarketplace(marketplaceID) { + var url = MARKETPLACE_URL; + if (marketplaceID) { + url = url + "/items/" + marketplaceID; + } + marketplaceWindow.setURL(url); + marketplaceWindow.setVisible(true); + + UserActivityLogger.openedMarketplace(); +} + +function hideMarketplace() { + marketplaceWindow.setVisible(false); + marketplaceWindow.setURL("about:blank"); +} + +function toggleMarketplace() { + if (marketplaceWindow.visible) { + hideMarketplace(); + } else { + showMarketplace(); + } +} + +var toolBar = Toolbars.getToolbar("com.highfidelity.interface.toolbar.system"); + +var browseExamplesButton = toolBar.addButton({ + imageURL: toolIconUrl + "market.svg", + objectName: "marketplace", + buttonState: 1, + defaultState: 1, + hoverState: 3, + alpha: 0.9 +}); + +function onExamplesWindowVisibilityChanged() { + browseExamplesButton.writeProperty('buttonState', marketplaceWindow.visible ? 0 : 1); + browseExamplesButton.writeProperty('defaultState', marketplaceWindow.visible ? 0 : 1); + browseExamplesButton.writeProperty('hoverState', marketplaceWindow.visible ? 2 : 3); +} +function onClick() { + toggleMarketplace(); +} +browseExamplesButton.clicked.connect(onClick); +marketplaceWindow.visibleChanged.connect(onExamplesWindowVisibilityChanged); + +Script.scriptEnding.connect(function () { + toolBar.removeButton("marketplace"); + browseExamplesButton.clicked.disconnect(onClick); + marketplaceWindow.visibleChanged.disconnect(onExamplesWindowVisibilityChanged); +});