mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 22:39:18 +02:00
Merge pull request #5083 from ctrlaltdavid/20551
CR for Job #20551 - Create a directory button that opens up the Directory. Similar to the marketplace
This commit is contained in:
commit
b32994b359
3 changed files with 94 additions and 1 deletions
|
@ -18,3 +18,4 @@ Script.load("notifications.js");
|
||||||
Script.load("users.js");
|
Script.load("users.js");
|
||||||
Script.load("grab.js");
|
Script.load("grab.js");
|
||||||
Script.load("pointer.js");
|
Script.load("pointer.js");
|
||||||
|
Script.load("directory.js");
|
||||||
|
|
92
examples/directory.js
Normal file
92
examples/directory.js
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
//
|
||||||
|
// directory.js
|
||||||
|
// examples
|
||||||
|
//
|
||||||
|
// Created by David Rowe on 8 Jun 2015
|
||||||
|
// Copyright 2015 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/globals.js");
|
||||||
|
|
||||||
|
var directory = (function () {
|
||||||
|
|
||||||
|
var DIRECTORY_URL = "https://metaverse.highfidelity.com/directory",
|
||||||
|
directoryWindow,
|
||||||
|
DIRECTORY_BUTTON_URL = HIFI_PUBLIC_BUCKET + "images/tools/directory.svg",
|
||||||
|
BUTTON_WIDTH = 50,
|
||||||
|
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 WebWindow('Directory', DIRECTORY_URL, 900, 700, false);
|
||||||
|
directoryWindow.setVisible(false);
|
||||||
|
|
||||||
|
directoryButton = Overlays.addOverlay("image", {
|
||||||
|
imageURL: DIRECTORY_BUTTON_URL,
|
||||||
|
width: BUTTON_WIDTH,
|
||||||
|
height: BUTTON_HEIGHT,
|
||||||
|
x: viewport.x - BUTTON_WIDTH - BUTTON_MARGIN,
|
||||||
|
y: BUTTON_MARGIN,
|
||||||
|
alpha: BUTTON_ALPHA,
|
||||||
|
visible: true
|
||||||
|
});
|
||||||
|
|
||||||
|
updateButtonPosition();
|
||||||
|
|
||||||
|
Controller.mousePressEvent.connect(onMousePressEvent);
|
||||||
|
Window.domainChanged.connect(onDomainChanged);
|
||||||
|
|
||||||
|
Script.update.connect(onScriptUpdate);
|
||||||
|
}
|
||||||
|
|
||||||
|
function tearDown() {
|
||||||
|
Overlays.deleteOverlay(directoryButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
setUp();
|
||||||
|
Script.scriptEnding.connect(tearDown);
|
||||||
|
}());
|
|
@ -31,7 +31,7 @@ WindowScriptingInterface::WindowScriptingInterface() :
|
||||||
_formResult(QDialog::Rejected)
|
_formResult(QDialog::Rejected)
|
||||||
{
|
{
|
||||||
const DomainHandler& domainHandler = DependencyManager::get<NodeList>()->getDomainHandler();
|
const DomainHandler& domainHandler = DependencyManager::get<NodeList>()->getDomainHandler();
|
||||||
connect(&domainHandler, &DomainHandler::hostnameChanged, this, &WindowScriptingInterface::domainChanged);
|
connect(&domainHandler, &DomainHandler::connectedToDomain, this, &WindowScriptingInterface::domainChanged);
|
||||||
connect(Application::getInstance(), &Application::svoImportRequested, this, &WindowScriptingInterface::svoImportRequested);
|
connect(Application::getInstance(), &Application::svoImportRequested, this, &WindowScriptingInterface::svoImportRequested);
|
||||||
connect(Application::getInstance(), &Application::domainConnectionRefused, this, &WindowScriptingInterface::domainConnectionRefused);
|
connect(Application::getInstance(), &Application::domainConnectionRefused, this, &WindowScriptingInterface::domainConnectionRefused);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue