mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 15:49:24 +02:00
Merge pull request #6798 from ericrius1/menuTweaks
separating out marketplace icon from edit toolbar and making directory icon from directory.js movable and persistent
This commit is contained in:
commit
ddd9b0826b
4 changed files with 234 additions and 97 deletions
|
@ -11,6 +11,7 @@
|
||||||
Script.load("away.js");
|
Script.load("away.js");
|
||||||
Script.load("progress.js");
|
Script.load("progress.js");
|
||||||
Script.load("edit.js");
|
Script.load("edit.js");
|
||||||
|
Script.load("marketplace.js");
|
||||||
Script.load("selectAudioDevice.js");
|
Script.load("selectAudioDevice.js");
|
||||||
Script.load("inspect.js");
|
Script.load("inspect.js");
|
||||||
Script.load("notifications.js");
|
Script.load("notifications.js");
|
||||||
|
|
|
@ -9,89 +9,118 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
Script.include("libraries/globals.js");
|
Script.include([
|
||||||
|
"libraries/toolBars.js",
|
||||||
|
]);
|
||||||
|
|
||||||
var directory = (function () {
|
HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
||||||
|
var toolIconUrl = HIFI_PUBLIC_BUCKET + "images/tools/";
|
||||||
|
|
||||||
var DIRECTORY_URL = "https://metaverse.highfidelity.com/directory",
|
var DIRECTORY_WINDOW_URL = "https://metaverse.highfidelity.com/directory";
|
||||||
directoryWindow,
|
var directoryWindow = new OverlayWebWindow({
|
||||||
DIRECTORY_BUTTON_URL = HIFI_PUBLIC_BUCKET + "images/tools/directory.svg",
|
title: 'directory',
|
||||||
BUTTON_WIDTH = 50,
|
source: "about:blank",
|
||||||
BUTTON_HEIGHT = 50,
|
|
||||||
BUTTON_ALPHA = 0.9,
|
|
||||||
BUTTON_MARGIN = 8,
|
|
||||||
directoryButton,
|
|
||||||
EDIT_TOOLBAR_BUTTONS = 10, // Number of buttons in edit.js toolbar
|
|
||||||
viewport;
|
|
||||||
|
|
||||||
function updateButtonPosition() {
|
|
||||||
Overlays.editOverlay(directoryButton, {
|
|
||||||
x: viewport.x - BUTTON_WIDTH - BUTTON_MARGIN,
|
|
||||||
y: (viewport.y - (EDIT_TOOLBAR_BUTTONS + 1) * (BUTTON_HEIGHT + BUTTON_MARGIN) - BUTTON_MARGIN) / 2 - 1
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function onMousePressEvent(event) {
|
|
||||||
var clickedOverlay;
|
|
||||||
|
|
||||||
clickedOverlay = Overlays.getOverlayAtPoint({ x: event.x, y: event.y });
|
|
||||||
|
|
||||||
if (clickedOverlay === directoryButton) {
|
|
||||||
if (directoryWindow.url !== DIRECTORY_URL) {
|
|
||||||
directoryWindow.setURL(DIRECTORY_URL);
|
|
||||||
}
|
|
||||||
directoryWindow.setVisible(true);
|
|
||||||
directoryWindow.raise();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onDomainChanged() {
|
|
||||||
directoryWindow.setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
function onScriptUpdate() {
|
|
||||||
var oldViewport = viewport;
|
|
||||||
|
|
||||||
viewport = Controller.getViewportDimensions();
|
|
||||||
|
|
||||||
if (viewport.x !== oldViewport.x || viewport.y !== oldViewport.y) {
|
|
||||||
updateButtonPosition();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function setUp() {
|
|
||||||
viewport = Controller.getViewportDimensions();
|
|
||||||
|
|
||||||
directoryWindow = new OverlayWebWindow({
|
|
||||||
title: 'Directory',
|
|
||||||
source: DIRECTORY_URL,
|
|
||||||
width: 900,
|
width: 900,
|
||||||
height: 700,
|
height: 700,
|
||||||
visible: false
|
visible: false
|
||||||
});
|
});
|
||||||
|
|
||||||
directoryButton = Overlays.addOverlay("image", {
|
var toolHeight = 50;
|
||||||
imageURL: DIRECTORY_BUTTON_URL,
|
var toolWidth = 50;
|
||||||
width: BUTTON_WIDTH,
|
|
||||||
height: BUTTON_HEIGHT,
|
|
||||||
x: viewport.x - BUTTON_WIDTH - BUTTON_MARGIN,
|
function showDirectory() {
|
||||||
y: BUTTON_MARGIN,
|
directoryWindow.setURL(DIRECTORY_WINDOW_URL);
|
||||||
alpha: BUTTON_ALPHA,
|
directoryWindow.setVisible(true);
|
||||||
visible: true
|
}
|
||||||
|
|
||||||
|
function hideDirectory() {
|
||||||
|
directoryWindow.setVisible(false);
|
||||||
|
directoryWindow.setURL("about:blank");
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleDirectory() {
|
||||||
|
if (directoryWindow.visible) {
|
||||||
|
hideDirectory();
|
||||||
|
} else {
|
||||||
|
showDirectory();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var toolBar = (function() {
|
||||||
|
var that = {},
|
||||||
|
toolBar,
|
||||||
|
browseDirectoryButton;
|
||||||
|
|
||||||
|
function initialize() {
|
||||||
|
ToolBar.SPACING = 16;
|
||||||
|
toolBar = new ToolBar(0, 0, ToolBar.VERTICAL, "highfidelity.directory.toolbar", function(windowDimensions, toolbar) {
|
||||||
|
return {
|
||||||
|
x: windowDimensions.x - 8 - toolbar.width,
|
||||||
|
y: 50
|
||||||
|
};
|
||||||
|
});
|
||||||
|
browseDirectoryButton = toolBar.addTool({
|
||||||
|
imageURL: toolIconUrl + "directory.svg",
|
||||||
|
width: toolWidth,
|
||||||
|
height: toolHeight,
|
||||||
|
alpha: 0.9,
|
||||||
|
visible: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
updateButtonPosition();
|
toolBar.showTool(browseDirectoryButton, true);
|
||||||
|
|
||||||
Controller.mousePressEvent.connect(onMousePressEvent);
|
|
||||||
Window.domainChanged.connect(onDomainChanged);
|
|
||||||
|
|
||||||
Script.update.connect(onScriptUpdate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function tearDown() {
|
var browseDirectoryButtonDown = false;
|
||||||
Overlays.deleteOverlay(directoryButton);
|
that.mousePressEvent = function(event) {
|
||||||
|
var clickedOverlay,
|
||||||
|
url,
|
||||||
|
file;
|
||||||
|
|
||||||
|
if (!event.isLeftButton) {
|
||||||
|
// if another mouse button than left is pressed ignore it
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
setUp();
|
clickedOverlay = Overlays.getOverlayAtPoint({
|
||||||
Script.scriptEnding.connect(tearDown);
|
x: event.x,
|
||||||
|
y: event.y
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (browseDirectoryButton === toolBar.clicked(clickedOverlay)) {
|
||||||
|
toggleDirectory();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
that.mouseReleaseEvent = function(event) {
|
||||||
|
var handled = false;
|
||||||
|
|
||||||
|
|
||||||
|
if (browseDirectoryButtonDown) {
|
||||||
|
var clickedOverlay = Overlays.getOverlayAtPoint({
|
||||||
|
x: event.x,
|
||||||
|
y: event.y
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
newModelButtonDown = false;
|
||||||
|
browseDirectoryButtonDown = false;
|
||||||
|
|
||||||
|
return handled;
|
||||||
|
}
|
||||||
|
|
||||||
|
that.cleanup = function() {
|
||||||
|
toolBar.cleanup();
|
||||||
|
};
|
||||||
|
|
||||||
|
initialize();
|
||||||
|
return that;
|
||||||
}());
|
}());
|
||||||
|
|
||||||
|
Controller.mousePressEvent.connect(toolBar.mousePressEvent)
|
||||||
|
Script.scriptEnding.connect(toolBar.cleanup);
|
||||||
|
|
|
@ -183,8 +183,7 @@ var toolBar = (function() {
|
||||||
newTextButton,
|
newTextButton,
|
||||||
newWebButton,
|
newWebButton,
|
||||||
newZoneButton,
|
newZoneButton,
|
||||||
newPolyVoxButton,
|
newPolyVoxButton;
|
||||||
browseMarketplaceButton;
|
|
||||||
|
|
||||||
function initialize() {
|
function initialize() {
|
||||||
toolBar = new ToolBar(0, 0, ToolBar.VERTICAL, "highfidelity.edit.toolbar", function(windowDimensions, toolbar) {
|
toolBar = new ToolBar(0, 0, ToolBar.VERTICAL, "highfidelity.edit.toolbar", function(windowDimensions, toolbar) {
|
||||||
|
@ -194,13 +193,7 @@ var toolBar = (function() {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
browseMarketplaceButton = toolBar.addTool({
|
|
||||||
imageURL: toolIconUrl + "marketplace.svg",
|
|
||||||
width: toolWidth,
|
|
||||||
height: toolHeight,
|
|
||||||
alpha: 0.9,
|
|
||||||
visible: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
activeButton = toolBar.addTool({
|
activeButton = toolBar.addTool({
|
||||||
imageURL: toolIconUrl + "edit-status.svg",
|
imageURL: toolIconUrl + "edit-status.svg",
|
||||||
|
@ -415,7 +408,6 @@ var toolBar = (function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
var newModelButtonDown = false;
|
var newModelButtonDown = false;
|
||||||
var browseMarketplaceButtonDown = false;
|
|
||||||
that.mousePressEvent = function(event) {
|
that.mousePressEvent = function(event) {
|
||||||
var clickedOverlay,
|
var clickedOverlay,
|
||||||
url,
|
url,
|
||||||
|
@ -443,10 +435,6 @@ var toolBar = (function() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (browseMarketplaceButton === toolBar.clicked(clickedOverlay)) {
|
|
||||||
toggleMarketplace();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newCubeButton === toolBar.clicked(clickedOverlay)) {
|
if (newCubeButton === toolBar.clicked(clickedOverlay)) {
|
||||||
createNewEntity({
|
createNewEntity({
|
||||||
|
@ -652,22 +640,10 @@ var toolBar = (function() {
|
||||||
}
|
}
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
} else if (browseMarketplaceButtonDown) {
|
|
||||||
var clickedOverlay = Overlays.getOverlayAtPoint({
|
|
||||||
x: event.x,
|
|
||||||
y: event.y
|
|
||||||
});
|
|
||||||
if (browseMarketplaceButton === toolBar.clicked(clickedOverlay)) {
|
|
||||||
url = Window.s3Browse(".*(fbx|FBX|obj|OBJ)");
|
|
||||||
if (url !== null && url !== "") {
|
|
||||||
addModel(url);
|
|
||||||
}
|
|
||||||
handled = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
newModelButtonDown = false;
|
newModelButtonDown = false;
|
||||||
browseMarketplaceButtonDown = false;
|
|
||||||
|
|
||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
131
examples/marketplace.js
Normal file
131
examples/marketplace.js
Normal file
|
@ -0,0 +1,131 @@
|
||||||
|
//
|
||||||
|
// marketplace.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
|
||||||
|
//
|
||||||
|
|
||||||
|
Script.include([
|
||||||
|
"libraries/toolBars.js",
|
||||||
|
]);
|
||||||
|
|
||||||
|
HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
||||||
|
var toolIconUrl = HIFI_PUBLIC_BUCKET + "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;
|
||||||
|
|
||||||
|
|
||||||
|
function showMarketplace(marketplaceID) {
|
||||||
|
var url = MARKETPLACE_URL;
|
||||||
|
if (marketplaceID) {
|
||||||
|
url = url + "/items/" + marketplaceID;
|
||||||
|
}
|
||||||
|
print("setting marketplace URL to " + url);
|
||||||
|
marketplaceWindow.setURL(url);
|
||||||
|
marketplaceWindow.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function hideMarketplace() {
|
||||||
|
marketplaceWindow.setVisible(false);
|
||||||
|
marketplaceWindow.setURL("about:blank");
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleMarketplace() {
|
||||||
|
if (marketplaceWindow.visible) {
|
||||||
|
hideMarketplace();
|
||||||
|
} else {
|
||||||
|
showMarketplace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var toolBar = (function() {
|
||||||
|
var that = {},
|
||||||
|
toolBar,
|
||||||
|
browseMarketplaceButton;
|
||||||
|
|
||||||
|
function initialize() {
|
||||||
|
ToolBar.SPACING = 16;
|
||||||
|
toolBar = new ToolBar(0, 0, ToolBar.VERTICAL, "highfidelity.marketplace.toolbar", function(windowDimensions, toolbar) {
|
||||||
|
return {
|
||||||
|
x: windowDimensions.x - 8 - toolbar.width,
|
||||||
|
y: 135
|
||||||
|
};
|
||||||
|
});
|
||||||
|
browseMarketplaceButton = toolBar.addTool({
|
||||||
|
imageURL: toolIconUrl + "marketplace.svg",
|
||||||
|
width: toolWidth,
|
||||||
|
height: toolHeight,
|
||||||
|
alpha: 0.9,
|
||||||
|
visible: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
toolBar.showTool(browseMarketplaceButton, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
var browseMarketplaceButtonDown = false;
|
||||||
|
that.mousePressEvent = function(event) {
|
||||||
|
var clickedOverlay,
|
||||||
|
url,
|
||||||
|
file;
|
||||||
|
|
||||||
|
if (!event.isLeftButton) {
|
||||||
|
// if another mouse button than left is pressed ignore it
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
clickedOverlay = Overlays.getOverlayAtPoint({
|
||||||
|
x: event.x,
|
||||||
|
y: event.y
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (browseMarketplaceButton === toolBar.clicked(clickedOverlay)) {
|
||||||
|
toggleMarketplace();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
that.mouseReleaseEvent = function(event) {
|
||||||
|
var handled = false;
|
||||||
|
|
||||||
|
|
||||||
|
if (browseMarketplaceButtonDown) {
|
||||||
|
var clickedOverlay = Overlays.getOverlayAtPoint({
|
||||||
|
x: event.x,
|
||||||
|
y: event.y
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
newModelButtonDown = false;
|
||||||
|
browseMarketplaceButtonDown = false;
|
||||||
|
|
||||||
|
return handled;
|
||||||
|
}
|
||||||
|
|
||||||
|
that.cleanup = function() {
|
||||||
|
toolBar.cleanup();
|
||||||
|
};
|
||||||
|
|
||||||
|
initialize();
|
||||||
|
return that;
|
||||||
|
}());
|
||||||
|
|
||||||
|
Controller.mousePressEvent.connect(toolBar.mousePressEvent)
|
||||||
|
Script.scriptEnding.connect(toolBar.cleanup);
|
Loading…
Reference in a new issue