mirror of
https://github.com/overte-org/overte.git
synced 2025-07-23 14:04:23 +02:00
clara.io marketplace works on tablet
This commit is contained in:
parent
c212fc93c9
commit
56fc42a2bd
4 changed files with 63 additions and 107 deletions
|
@ -10,8 +10,9 @@ Item {
|
||||||
loader.source = url;
|
loader.source = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadWebUrl(url) {
|
function loadWebUrl(url, injectedJavaScriptUrl) {
|
||||||
loader.item.url = url;
|
loader.item.url = url;
|
||||||
|
loader.item.scriptURL = injectedJavaScriptUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundEffect {
|
SoundEffect {
|
||||||
|
@ -35,6 +36,13 @@ Item {
|
||||||
// propogate eventBridge to WebEngineView
|
// propogate eventBridge to WebEngineView
|
||||||
if (loader.item.hasOwnProperty("eventBridge")) {
|
if (loader.item.hasOwnProperty("eventBridge")) {
|
||||||
loader.item.eventBridge = 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) {
|
void TabletProxy::gotoWebScreen(const QString& url) {
|
||||||
|
gotoWebScreen(url, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
void TabletProxy::gotoWebScreen(const QString& url, const QString& injectedJavaScriptUrl) {
|
||||||
if (_qmlTabletRoot) {
|
if (_qmlTabletRoot) {
|
||||||
if (_state == State::Home) {
|
if (_state == State::Home) {
|
||||||
removeButtonsFromHomeScreen();
|
removeButtonsFromHomeScreen();
|
||||||
|
@ -125,7 +129,8 @@ void TabletProxy::gotoWebScreen(const QString& url) {
|
||||||
QMetaObject::invokeMethod(_qmlTabletRoot, "loadSource", Q_ARG(const QVariant&, QVariant(WEB_VIEW_SOURCE_URL)));
|
QMetaObject::invokeMethod(_qmlTabletRoot, "loadSource", Q_ARG(const QVariant&, QVariant(WEB_VIEW_SOURCE_URL)));
|
||||||
_state = State::Web;
|
_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
|
/**jsdoc
|
||||||
* show the specified web url on the tablet.
|
* show the specified web url on the tablet.
|
||||||
* @function TabletProxy#gotoWebScreen
|
* @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);
|
||||||
|
Q_INVOKABLE void gotoWebScreen(const QString& url, const QString& injectedJavaScriptUrl);
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Creates a new button, adds it to this and returns it.
|
* 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
|
// 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
|
(function() { // BEGIN LOCAL_SCOPE
|
||||||
|
|
||||||
/* global WebTablet */
|
|
||||||
Script.include("../libraries/WebTablet.js");
|
Script.include("../libraries/WebTablet.js");
|
||||||
|
|
||||||
var toolIconUrl = Script.resolvePath("../assets/images/tools/");
|
|
||||||
|
|
||||||
var MARKETPLACE_URL = "https://metaverse.highfidelity.com/marketplace";
|
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 MARKETPLACE_URL_INITIAL = MARKETPLACE_URL + "?"; // Append "?" to signal injected script that it's the initial page.
|
||||||
var MARKETPLACES_URL = Script.resolvePath("../html/marketplaces.html");
|
var MARKETPLACES_URL = Script.resolvePath("../html/marketplaces.html");
|
||||||
|
@ -39,29 +39,32 @@ 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 NO_PERMISSIONS_ERROR_MESSAGE = "Cannot download model because you can't write to \nthe domain's Asset Server.";
|
||||||
|
|
||||||
var marketplaceWindow = new OverlayWebWindow({
|
function onMessageBoxClosed(id, button) {
|
||||||
title: "Marketplace",
|
if (id === messageBox && button === CANCEL_BUTTON) {
|
||||||
source: "about:blank",
|
isDownloadBeingCancelled = true;
|
||||||
width: 900,
|
messageBox = null;
|
||||||
height: 700,
|
tablet.emitScriptEvent(CLARA_IO_CANCEL_DOWNLOAD);
|
||||||
visible: false
|
}
|
||||||
});
|
}
|
||||||
marketplaceWindow.setScriptURL(MARKETPLACES_INJECT_SCRIPT_URL);
|
|
||||||
|
|
||||||
function onWebEventReceived(message) {
|
Window.messageBoxClosed.connect(onMessageBoxClosed);
|
||||||
|
|
||||||
|
function showMarketplace() {
|
||||||
|
tablet.gotoWebScreen(MARKETPLACE_URL_INITIAL, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||||
|
|
||||||
|
UserActivityLogger.openedMarketplace();
|
||||||
|
|
||||||
|
tablet.webEventReceived.connect(function (message) {
|
||||||
if (message === GOTO_DIRECTORY) {
|
if (message === GOTO_DIRECTORY) {
|
||||||
var url = MARKETPLACES_URL;
|
tablet.gotoWebScreen(MARKETPLACES_URL);
|
||||||
marketplaceWindow.setURL(url);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message === QUERY_CAN_WRITE_ASSETS) {
|
if (message === QUERY_CAN_WRITE_ASSETS) {
|
||||||
var canWriteAssets = CAN_WRITE_ASSETS + " " + Entities.canWriteAssets();
|
tablet.emitScriptEvent(CAN_WRITE_ASSETS + " " + Entities.canWriteAssets());
|
||||||
marketplaceWindow.emitScriptEvent(canWriteAssets);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message === WARN_USER_NO_PERMISSIONS) {
|
if (message === WARN_USER_NO_PERMISSIONS) {
|
||||||
Window.alert(NO_PERMISSIONS_ERROR_MESSAGE);
|
Window.alert(NO_PERMISSIONS_ERROR_MESSAGE);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.slice(0, CLARA_IO_STATUS.length) === CLARA_IO_STATUS) {
|
if (message.slice(0, CLARA_IO_STATUS.length) === CLARA_IO_STATUS) {
|
||||||
|
@ -89,62 +92,7 @@ function onWebEventReceived(message) {
|
||||||
if (message === CLARA_IO_CANCELLED_DOWNLOAD) {
|
if (message === CLARA_IO_CANCELLED_DOWNLOAD) {
|
||||||
isDownloadBeingCancelled = false;
|
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
// }
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (message === QUERY_CAN_WRITE_ASSESTS) {
|
|
||||||
tablet.emitScriptEvent(CAN_WRITE_ASSETS + " " + Entities.canWriteAssets());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (message === WARN_USER_NO_PERMISSIONS) {
|
|
||||||
Window.alert(NO_PERMISSIONS_ERROR_MESSAGE);
|
|
||||||
}
|
|
||||||
|
|
||||||
});*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleMarketplace() {
|
function toggleMarketplace() {
|
||||||
|
@ -153,32 +101,25 @@ function toggleMarketplace() {
|
||||||
|
|
||||||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||||
|
|
||||||
var browseExamplesButton = tablet.addButton({
|
var marketplaceButton = tablet.addButton({
|
||||||
icon: "icons/tablet-icons/market-i.svg",
|
icon: "icons/tablet-icons/market-i.svg",
|
||||||
text: "MARKET"
|
text: "MARKET"
|
||||||
});
|
});
|
||||||
|
|
||||||
function onCanWriteAssetsChanged() {
|
function onCanWriteAssetsChanged() {
|
||||||
var message = CAN_WRITE_ASSETS + " " + Entities.canWriteAssets();
|
var message = CAN_WRITE_ASSETS + " " + Entities.canWriteAssets();
|
||||||
if (marketplaceWindow.visible) {
|
tablet.emitScriptEvent(message);
|
||||||
marketplaceWindow.emitScriptEvent(message);
|
|
||||||
}
|
|
||||||
if (marketplaceWebTablet) {
|
|
||||||
marketplaceWebTablet.getOverlayObject().emitScriptEvent(message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onClick() {
|
function onClick() {
|
||||||
toggleMarketplace();
|
toggleMarketplace();
|
||||||
}
|
}
|
||||||
|
|
||||||
browseExamplesButton.clicked.connect(onClick);
|
marketplaceButton.clicked.connect(onClick);
|
||||||
Entities.canWriteAssetsChanged.connect(onCanWriteAssetsChanged);
|
Entities.canWriteAssetsChanged.connect(onCanWriteAssetsChanged);
|
||||||
|
|
||||||
Script.scriptEnding.connect(function () {
|
Script.scriptEnding.connect(function () {
|
||||||
browseExamplesButton.clicked.disconnect(onClick);
|
tablet.removeButton(marketplaceButton);
|
||||||
tablet.removeButton(browseExamplesButton);
|
|
||||||
marketplaceWindow.visibleChanged.disconnect(onMarketplaceWindowVisibilityChanged);
|
|
||||||
Entities.canWriteAssetsChanged.disconnect(onCanWriteAssetsChanged);
|
Entities.canWriteAssetsChanged.disconnect(onCanWriteAssetsChanged);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue