mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:24:00 +02:00
Merge pull request #9413 from hyperlogic/tablet-ui
clara.io marketplace works on tablet
This commit is contained in:
commit
0abb41ca2d
4 changed files with 63 additions and 107 deletions
|
@ -10,8 +10,9 @@ Item {
|
|||
loader.source = url;
|
||||
}
|
||||
|
||||
function loadWebUrl(url) {
|
||||
function loadWebUrl(url, injectedJavaScriptUrl) {
|
||||
loader.item.url = url;
|
||||
loader.item.scriptURL = injectedJavaScriptUrl;
|
||||
}
|
||||
|
||||
SoundEffect {
|
||||
|
@ -35,6 +36,13 @@ Item {
|
|||
// propogate eventBridge to WebEngineView
|
||||
if (loader.item.hasOwnProperty("eventBridge")) {
|
||||
loader.item.eventBridge = eventBridge;
|
||||
|
||||
// Hook up callback for clara.io download from the marketplace.
|
||||
eventBridge.webEventReceived.connect(function (event) {
|
||||
if (event.slice(0, 17) === "CLARA.IO DOWNLOAD") {
|
||||
ApplicationInterface.addAssetToWorldFromURL(event.slice(18));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,6 +117,10 @@ void TabletProxy::gotoHomeScreen() {
|
|||
}
|
||||
|
||||
void TabletProxy::gotoWebScreen(const QString& url) {
|
||||
gotoWebScreen(url, "");
|
||||
}
|
||||
|
||||
void TabletProxy::gotoWebScreen(const QString& url, const QString& injectedJavaScriptUrl) {
|
||||
if (_qmlTabletRoot) {
|
||||
if (_state == State::Home) {
|
||||
removeButtonsFromHomeScreen();
|
||||
|
@ -125,7 +129,8 @@ void TabletProxy::gotoWebScreen(const QString& url) {
|
|||
QMetaObject::invokeMethod(_qmlTabletRoot, "loadSource", Q_ARG(const QVariant&, QVariant(WEB_VIEW_SOURCE_URL)));
|
||||
_state = State::Web;
|
||||
}
|
||||
QMetaObject::invokeMethod(_qmlTabletRoot, "loadWebUrl", Q_ARG(const QVariant&, QVariant(url)));
|
||||
QMetaObject::invokeMethod(_qmlTabletRoot, "loadWebUrl", Q_ARG(const QVariant&, QVariant(url)),
|
||||
Q_ARG(const QVariant&, QVariant(injectedJavaScriptUrl)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -75,9 +75,11 @@ public:
|
|||
/**jsdoc
|
||||
* show the specified web url on the tablet.
|
||||
* @function TabletProxy#gotoWebScreen
|
||||
* @param url {string}
|
||||
* @param url {string} url of web page.
|
||||
* @param [injectedJavaScriptUrl] {string} optional url to an additional JS script to inject into the web page.
|
||||
*/
|
||||
Q_INVOKABLE void gotoWebScreen(const QString& url);
|
||||
Q_INVOKABLE void gotoWebScreen(const QString& url, const QString& injectedJavaScriptUrl);
|
||||
|
||||
/**jsdoc
|
||||
* Creates a new button, adds it to this and returns it.
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
/* global WebTablet Tablet */
|
||||
/* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */
|
||||
|
||||
(function() { // BEGIN LOCAL_SCOPE
|
||||
|
||||
/* global WebTablet */
|
||||
Script.include("../libraries/WebTablet.js");
|
||||
|
||||
var toolIconUrl = Script.resolvePath("../assets/images/tools/");
|
||||
|
||||
var MARKETPLACE_URL = "https://metaverse.highfidelity.com/marketplace";
|
||||
var MARKETPLACE_URL_INITIAL = MARKETPLACE_URL + "?"; // Append "?" to signal injected script that it's the initial page.
|
||||
var MARKETPLACES_URL = Script.resolvePath("../html/marketplaces.html");
|
||||
|
@ -39,112 +39,60 @@ var NO_BUTTON = 0; // QMessageBox::NoButton
|
|||
|
||||
var NO_PERMISSIONS_ERROR_MESSAGE = "Cannot download model because you can't write to \nthe domain's Asset Server.";
|
||||
|
||||
var marketplaceWindow = new OverlayWebWindow({
|
||||
title: "Marketplace",
|
||||
source: "about:blank",
|
||||
width: 900,
|
||||
height: 700,
|
||||
visible: false
|
||||
});
|
||||
marketplaceWindow.setScriptURL(MARKETPLACES_INJECT_SCRIPT_URL);
|
||||
|
||||
function onWebEventReceived(message) {
|
||||
if (message === GOTO_DIRECTORY) {
|
||||
var url = MARKETPLACES_URL;
|
||||
marketplaceWindow.setURL(url);
|
||||
return;
|
||||
}
|
||||
if (message === QUERY_CAN_WRITE_ASSETS) {
|
||||
var canWriteAssets = CAN_WRITE_ASSETS + " " + Entities.canWriteAssets();
|
||||
marketplaceWindow.emitScriptEvent(canWriteAssets);
|
||||
return;
|
||||
}
|
||||
if (message === WARN_USER_NO_PERMISSIONS) {
|
||||
Window.alert(NO_PERMISSIONS_ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.slice(0, CLARA_IO_STATUS.length) === CLARA_IO_STATUS) {
|
||||
if (isDownloadBeingCancelled) {
|
||||
return;
|
||||
}
|
||||
|
||||
var text = message.slice(CLARA_IO_STATUS.length);
|
||||
if (messageBox === null) {
|
||||
messageBox = Window.openMessageBox(CLARA_DOWNLOAD_TITLE, text, CANCEL_BUTTON, NO_BUTTON);
|
||||
} else {
|
||||
Window.updateMessageBox(messageBox, CLARA_DOWNLOAD_TITLE, text, CANCEL_BUTTON, NO_BUTTON);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.slice(0, CLARA_IO_DOWNLOAD.length) === CLARA_IO_DOWNLOAD) {
|
||||
if (messageBox !== null) {
|
||||
Window.closeMessageBox(messageBox);
|
||||
messageBox = null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (message === CLARA_IO_CANCELLED_DOWNLOAD) {
|
||||
isDownloadBeingCancelled = false;
|
||||
}
|
||||
}
|
||||
|
||||
marketplaceWindow.webEventReceived.connect(onWebEventReceived);
|
||||
|
||||
function onMessageBoxClosed(id, button) {
|
||||
if (id === messageBox && button === CANCEL_BUTTON) {
|
||||
isDownloadBeingCancelled = true;
|
||||
messageBox = null;
|
||||
marketplaceWindow.emitScriptEvent(CLARA_IO_CANCEL_DOWNLOAD);
|
||||
tablet.emitScriptEvent(CLARA_IO_CANCEL_DOWNLOAD);
|
||||
}
|
||||
}
|
||||
|
||||
Window.messageBoxClosed.connect(onMessageBoxClosed);
|
||||
|
||||
var toolHeight = 50;
|
||||
var toolWidth = 50;
|
||||
var TOOLBAR_MARGIN_Y = 0;
|
||||
var marketplaceVisible = false;
|
||||
var marketplaceWebTablet;
|
||||
|
||||
// We persist clientOnly data in the .ini file, and reconstitute it on restart.
|
||||
// To keep things consistent, we pickle the tablet data in Settings, and kill any existing such on restart and domain change.
|
||||
var persistenceKey = "io.highfidelity.lastDomainTablet";
|
||||
|
||||
function showMarketplace() {
|
||||
tablet.gotoWebScreen(MARKETPLACE_URL_INITIAL);
|
||||
// if (shouldShowWebTablet()) {
|
||||
// updateButtonState(true);
|
||||
// marketplaceWebTablet = new WebTablet(MARKETPLACE_URL_INITIAL, null, null, true);
|
||||
// Settings.setValue(persistenceKey, marketplaceWebTablet.pickle());
|
||||
// marketplaceWebTablet.setScriptURL(MARKETPLACES_INJECT_SCRIPT_URL);
|
||||
// marketplaceWebTablet.getOverlayObject().webEventReceived.connect(onWebEventReceived);
|
||||
// } else {
|
||||
// marketplaceWindow.setURL(MARKETPLACE_URL_INITIAL);
|
||||
// marketplaceWindow.setVisible(true);
|
||||
// }
|
||||
tablet.gotoWebScreen(MARKETPLACE_URL_INITIAL, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||
|
||||
marketplaceVisible = true;
|
||||
UserActivityLogger.openedMarketplace();
|
||||
|
||||
// FIXME - the code to support the following is not yet implented
|
||||
/*tablet.setScriptURL(MARKETPLACES_INJECT_SCRIPT_URL);
|
||||
tablet.webEventRecieved.connect(function (message) {
|
||||
if (message === GOTO_DIRECTORY) {
|
||||
tablet.gotoWebScreen(MARKETPLACE_URL_INITIAL);
|
||||
}
|
||||
tablet.webEventReceived.connect(function (message) {
|
||||
if (message === GOTO_DIRECTORY) {
|
||||
tablet.gotoWebScreen(MARKETPLACES_URL);
|
||||
}
|
||||
|
||||
if (message === QUERY_CAN_WRITE_ASSESTS) {
|
||||
tablet.emitScriptEvent(CAN_WRITE_ASSETS + " " + Entities.canWriteAssets());
|
||||
}
|
||||
if (message === QUERY_CAN_WRITE_ASSETS) {
|
||||
tablet.emitScriptEvent(CAN_WRITE_ASSETS + " " + Entities.canWriteAssets());
|
||||
}
|
||||
|
||||
if (message === WARN_USER_NO_PERMISSIONS) {
|
||||
Window.alert(NO_PERMISSIONS_ERROR_MESSAGE);
|
||||
}
|
||||
if (message === WARN_USER_NO_PERMISSIONS) {
|
||||
Window.alert(NO_PERMISSIONS_ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
});*/
|
||||
if (message.slice(0, CLARA_IO_STATUS.length) === CLARA_IO_STATUS) {
|
||||
if (isDownloadBeingCancelled) {
|
||||
return;
|
||||
}
|
||||
|
||||
var text = message.slice(CLARA_IO_STATUS.length);
|
||||
if (messageBox === null) {
|
||||
messageBox = Window.openMessageBox(CLARA_DOWNLOAD_TITLE, text, CANCEL_BUTTON, NO_BUTTON);
|
||||
} else {
|
||||
Window.updateMessageBox(messageBox, CLARA_DOWNLOAD_TITLE, text, CANCEL_BUTTON, NO_BUTTON);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.slice(0, CLARA_IO_DOWNLOAD.length) === CLARA_IO_DOWNLOAD) {
|
||||
if (messageBox !== null) {
|
||||
Window.closeMessageBox(messageBox);
|
||||
messageBox = null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (message === CLARA_IO_CANCELLED_DOWNLOAD) {
|
||||
isDownloadBeingCancelled = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function toggleMarketplace() {
|
||||
|
@ -153,32 +101,25 @@ function toggleMarketplace() {
|
|||
|
||||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||
|
||||
var browseExamplesButton = tablet.addButton({
|
||||
var marketplaceButton = tablet.addButton({
|
||||
icon: "icons/tablet-icons/market-i.svg",
|
||||
text: "MARKET"
|
||||
});
|
||||
|
||||
function onCanWriteAssetsChanged() {
|
||||
var message = CAN_WRITE_ASSETS + " " + Entities.canWriteAssets();
|
||||
if (marketplaceWindow.visible) {
|
||||
marketplaceWindow.emitScriptEvent(message);
|
||||
}
|
||||
if (marketplaceWebTablet) {
|
||||
marketplaceWebTablet.getOverlayObject().emitScriptEvent(message);
|
||||
}
|
||||
tablet.emitScriptEvent(message);
|
||||
}
|
||||
|
||||
function onClick() {
|
||||
toggleMarketplace();
|
||||
}
|
||||
|
||||
browseExamplesButton.clicked.connect(onClick);
|
||||
marketplaceButton.clicked.connect(onClick);
|
||||
Entities.canWriteAssetsChanged.connect(onCanWriteAssetsChanged);
|
||||
|
||||
Script.scriptEnding.connect(function () {
|
||||
browseExamplesButton.clicked.disconnect(onClick);
|
||||
tablet.removeButton(browseExamplesButton);
|
||||
marketplaceWindow.visibleChanged.disconnect(onMarketplaceWindowVisibilityChanged);
|
||||
tablet.removeButton(marketplaceButton);
|
||||
Entities.canWriteAssetsChanged.disconnect(onCanWriteAssetsChanged);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue