mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 21:17:01 +02:00
Lots of changes; marketplaces.js working now
This commit is contained in:
parent
de2548d926
commit
01073ca18d
7 changed files with 1747 additions and 1711 deletions
|
@ -252,12 +252,6 @@ bool ContextOverlayInterface::destroyContextOverlay(const EntityItemID& entityIt
|
|||
void ContextOverlayInterface::contextOverlays_mousePressOnOverlay(const OverlayID& overlayID, const PointerEvent& event) {
|
||||
if (overlayID == _contextOverlayID && event.getButton() == PointerEvent::PrimaryButton) {
|
||||
qCDebug(context_overlay) << "Clicked Context Overlay. Entity ID:" << _currentEntityWithContextOverlay << "Overlay ID:" << overlayID;
|
||||
Setting::Handle<bool> _settingSwitch{ "commerce", true };
|
||||
if (_settingSwitch.get()) {
|
||||
openInspectionCertificate();
|
||||
} else {
|
||||
openMarketplace();
|
||||
}
|
||||
emit contextOverlayClicked(_currentEntityWithContextOverlay);
|
||||
_contextOverlayJustClicked = true;
|
||||
}
|
||||
|
@ -390,34 +384,6 @@ void ContextOverlayInterface::requestOwnershipVerification(const QUuid& entityID
|
|||
}
|
||||
}
|
||||
|
||||
static const QString INSPECTION_CERTIFICATE_QML_PATH = "hifi/commerce/inspectionCertificate/InspectionCertificate.qml";
|
||||
void ContextOverlayInterface::openInspectionCertificate() {
|
||||
// lets open the tablet to the inspection certificate QML
|
||||
if (!_currentEntityWithContextOverlay.isNull() && _entityMarketplaceID.length() > 0) {
|
||||
setLastInspectedEntity(_currentEntityWithContextOverlay);
|
||||
auto tablet = dynamic_cast<TabletProxy*>(_tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
||||
tablet->loadQMLSource(INSPECTION_CERTIFICATE_QML_PATH);
|
||||
_hmdScriptingInterface->openTablet();
|
||||
}
|
||||
}
|
||||
|
||||
static const QString MARKETPLACE_BASE_URL = NetworkingConstants::METAVERSE_SERVER_URL().toString() + "/marketplace/items/";
|
||||
|
||||
void ContextOverlayInterface::openMarketplace() {
|
||||
// lets open the tablet and go to the current item in
|
||||
// the marketplace (if the current entity has a
|
||||
// marketplaceID)
|
||||
if (!_currentEntityWithContextOverlay.isNull() && _entityMarketplaceID.length() > 0) {
|
||||
auto tablet = dynamic_cast<TabletProxy*>(_tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
||||
// construct the url to the marketplace item
|
||||
QString url = MARKETPLACE_BASE_URL + _entityMarketplaceID;
|
||||
QString MARKETPLACES_INJECT_SCRIPT_PATH = "file:///" + qApp->applicationDirPath() + "/scripts/system/html/js/marketplacesInject.js";
|
||||
tablet->gotoWebScreen(url, MARKETPLACES_INJECT_SCRIPT_PATH);
|
||||
_hmdScriptingInterface->openTablet();
|
||||
_isInMarketplaceInspectionMode = true;
|
||||
}
|
||||
}
|
||||
|
||||
void ContextOverlayInterface::enableEntityHighlight(const EntityItemID& entityItemID) {
|
||||
_selectionScriptingInterface->addToSelectedItemsList("contextOverlayHighlightList", "entity", entityItemID);
|
||||
}
|
||||
|
|
|
@ -94,8 +94,6 @@ private:
|
|||
|
||||
bool _isInMarketplaceInspectionMode { false };
|
||||
|
||||
void openInspectionCertificate();
|
||||
void openMarketplace();
|
||||
void enableEntityHighlight(const EntityItemID& entityItemID);
|
||||
void disableEntityHighlight(const EntityItemID& entityItemID);
|
||||
|
||||
|
|
|
@ -38,46 +38,42 @@ function AppUi(properties) {
|
|||
that.tabletName = "com.highfidelity.interface.tablet.system";
|
||||
that.inject = "";
|
||||
that.graphicsDirectory = "icons/tablet-icons/"; // Where to look for button svgs. See below.
|
||||
that.additionalAppScreens = [];
|
||||
that.checkIsOpen = function checkIsOpen(type, tabletUrl) { // Are we active? Value used to set isOpen.
|
||||
return (type === that.type) && that.currentUrl && (tabletUrl.indexOf(that.currentUrl) >= 0); // Actual url may have prefix or suffix.
|
||||
// Actual url may have prefix or suffix.
|
||||
return (type === that.currentVisibleScreenType) &&
|
||||
that.currentVisibleUrl &&
|
||||
((that.home.indexOf(that.currentVisibleUrl) > -1) ||
|
||||
(that.additionalAppScreens.indexOf(that.currentVisibleUrl) > -1));
|
||||
};
|
||||
that.setCurrentData = function setCurrentData(url) {
|
||||
that.currentUrl = url;
|
||||
that.type = /.qml$/.test(url) ? 'QML' : 'Web';
|
||||
}
|
||||
that.open = function open(optionalUrl) { // How to open the app.
|
||||
that.setCurrentVisibleScreenMetadata = function setCurrentVisibleScreenMetadata(type, url) {
|
||||
that.currentVisibleScreenType = type;
|
||||
that.currentVisibleUrl = url;
|
||||
};
|
||||
that.open = function open(optionalUrl, optionalInject) { // How to open the app.
|
||||
var url = optionalUrl || that.home;
|
||||
that.setCurrentData(url);
|
||||
if (that.isQML()) {
|
||||
var inject = that.inject;
|
||||
if (optionalUrl && optionalInject) {
|
||||
inject = optionalInject;
|
||||
}
|
||||
|
||||
if (that.isQMLUrl(url)) {
|
||||
that.tablet.loadQMLSource(url);
|
||||
} else {
|
||||
that.tablet.gotoWebScreen(url, that.inject);
|
||||
that.tablet.gotoWebScreen(url, inject);
|
||||
}
|
||||
};
|
||||
that.openNewApp = function openNewApp(url, optionalInject) { // Opens some app and replaces the current app
|
||||
if (that.isQML(url)) {
|
||||
that.tablet.pushOntoStack(url);
|
||||
} else {
|
||||
if (optionalInject) {
|
||||
that.tablet.gotoWebScreen(url, optionalInject);
|
||||
} else {
|
||||
that.tablet.gotoWebScreen(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
that.openNewAppOnTop = function openNewAppOnTop(url, optionalInject) { // Opens some app on top of the current app (on desktop, opens new window)
|
||||
if (that.isQML(url)) {
|
||||
// Opens some app on top of the current app (on desktop, opens new window)
|
||||
that.openNewAppOnTop = function openNewAppOnTop(url, optionalInject) {
|
||||
var inject = optionalInject || "";
|
||||
if (that.isQMLUrl(url)) {
|
||||
that.tablet.loadQMLOnTop(url);
|
||||
} else {
|
||||
if (optionalInject) {
|
||||
that.tablet.loadWebScreenOnTop(url, optionalInject);
|
||||
} else {
|
||||
that.tablet.loadWebScreenOnTop(url);
|
||||
}
|
||||
}
|
||||
that.tablet.loadWebScreenOnTop(url, inject);
|
||||
}
|
||||
};
|
||||
that.close = function close() { // How to close the app.
|
||||
that.currentUrl = "";
|
||||
that.currentVisibleUrl = "";
|
||||
// for toolbar-mode: go back to home screen, this will close the window.
|
||||
that.tablet.gotoHomeScreen();
|
||||
};
|
||||
|
@ -91,15 +87,40 @@ function AppUi(properties) {
|
|||
activeIcon: isWaiting ? that.activeMessagesButton : that.activeButton
|
||||
});
|
||||
};
|
||||
that.isQML = function isQML(optionalUrl) { // We set type property in onClick.
|
||||
if (optionalUrl) {
|
||||
var type = /.qml$/.test(optionalUrl) ? 'QML' : 'Web';
|
||||
that.isQMLUrl = function isQMLUrl(url) {
|
||||
var type = /.qml$/.test(url) ? 'QML' : 'Web';
|
||||
return type === 'QML';
|
||||
}
|
||||
return that.type === 'QML';
|
||||
};
|
||||
that.eventSignal = function eventSignal() { // What signal to hook onMessage to.
|
||||
return that.isQML() ? that.tablet.fromQml : that.tablet.webEventReceived;
|
||||
that.isCurrentlyOnQMLScreen = function isCurrentlyOnQMLScreen() {
|
||||
return that.currentVisibleScreenType === 'QML';
|
||||
};
|
||||
|
||||
// Handlers
|
||||
that.onScreenChanged = function onScreenChanged(type, url) {
|
||||
// Set isOpen, wireEventBridge, set buttonActive as appropriate,
|
||||
// and finally call onOpened() or onClosed() IFF defined.
|
||||
that.setCurrentVisibleScreenMetadata(type, url);
|
||||
if (that.checkIsOpen(type, url)) {
|
||||
that.wireEventBridge(true);
|
||||
if (!that.isOpen) {
|
||||
that.buttonActive(true);
|
||||
if (that.onOpened) {
|
||||
that.onOpened();
|
||||
}
|
||||
that.isOpen = true;
|
||||
}
|
||||
} else { // Not us. Should we do something for type Home, Menu, and particularly Closed (meaning tablet hidden?
|
||||
that.wireEventBridge(false);
|
||||
if (that.isOpen) {
|
||||
that.buttonActive(false);
|
||||
if (that.onClosed) {
|
||||
that.onClosed();
|
||||
}
|
||||
that.isOpen = false;
|
||||
}
|
||||
}
|
||||
console.debug(that.buttonName + " app reports: Tablet screen changed.\nNew screen type: " + type +
|
||||
"\nNew screen URL: " + url + "\nCurrent app open status: " + that.isOpen + "\n");
|
||||
};
|
||||
|
||||
// Overwrite with the given properties:
|
||||
|
@ -126,65 +147,55 @@ function AppUi(properties) {
|
|||
}
|
||||
that.button = that.tablet.addButton(buttonOptions);
|
||||
that.ignore = function ignore() { };
|
||||
|
||||
// Handlers
|
||||
that.onScreenChanged = function onScreenChanged(type, url) {
|
||||
// Set isOpen, wireEventBridge, set buttonActive as appropriate,
|
||||
// and finally call onOpened() or onClosed() IFF defined.
|
||||
console.debug(that.buttonName, 'onScreenChanged', type, url, that.isOpen);
|
||||
if (that.checkIsOpen(type, url)) {
|
||||
if (!that.isOpen) {
|
||||
that.wireEventBridge(true);
|
||||
that.buttonActive(true);
|
||||
if (that.onOpened) {
|
||||
that.onOpened();
|
||||
}
|
||||
that.isOpen = true;
|
||||
}
|
||||
|
||||
} else { // Not us. Should we do something for type Home, Menu, and particularly Closed (meaning tablet hidden?
|
||||
if (that.isOpen) {
|
||||
that.wireEventBridge(false);
|
||||
that.buttonActive(false);
|
||||
if (that.onClosed) {
|
||||
that.onClosed();
|
||||
}
|
||||
that.isOpen = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
that.hasEventBridge = false;
|
||||
that.hasQmlEventBridge = false;
|
||||
that.hasHtmlEventBridge = false;
|
||||
// HTML event bridge uses strings, not objects. Here we abstract over that.
|
||||
// (Although injected javascript still has to use JSON.stringify/JSON.parse.)
|
||||
that.sendToHtml = function (messageObject) { that.tablet.emitScriptEvent(JSON.stringify(messageObject)); };
|
||||
that.fromHtml = function (messageString) { that.onMessage(JSON.parse(messageString)); };
|
||||
that.sendToHtml = function (messageObject) {
|
||||
that.tablet.emitScriptEvent(JSON.stringify(messageObject));
|
||||
};
|
||||
that.fromHtml = function (messageString) {
|
||||
var parsedMessage = JSON.parse(messageString);
|
||||
parsedMessage.messageSrc = "HTML";
|
||||
that.onMessage(parsedMessage);
|
||||
};
|
||||
that.sendMessage = that.ignore;
|
||||
that.wireEventBridge = function wireEventBridge(on) {
|
||||
// Uniquivocally sets that.sendMessage(messageObject) to do the right thing.
|
||||
// Sets hasEventBridge and wires onMessage to eventSignal as appropriate, IFF onMessage defined.
|
||||
var handler, isQml = that.isQML();
|
||||
// Sets has*EventBridge and wires onMessage to the proper event bridge as appropriate, IFF onMessage defined.
|
||||
var isCurrentlyOnQMLScreen = that.isCurrentlyOnQMLScreen();
|
||||
// Outbound (always, regardless of whether there is an inbound handler).
|
||||
if (on) {
|
||||
that.sendMessage = isQml ? that.tablet.sendToQml : that.sendToHtml;
|
||||
that.sendMessage = isCurrentlyOnQMLScreen ? that.tablet.sendToQml : that.sendToHtml;
|
||||
} else {
|
||||
that.sendMessage = that.ignore;
|
||||
}
|
||||
|
||||
if (!that.onMessage) { return; }
|
||||
if (!that.onMessage) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Inbound
|
||||
handler = isQml ? that.onMessage : that.fromHtml;
|
||||
if (on) {
|
||||
if (!that.hasEventBridge) {
|
||||
console.debug(that.buttonName, 'connecting', that.eventSignal());
|
||||
that.eventSignal().connect(handler);
|
||||
that.hasEventBridge = true;
|
||||
if (isCurrentlyOnQMLScreen && !that.hasQmlEventBridge) {
|
||||
console.debug(that.buttonName, 'connecting', that.tablet.fromQml);
|
||||
that.tablet.fromQml.connect(that.onMessage);
|
||||
that.hasQmlEventBridge = true;
|
||||
} else if (!isCurrentlyOnQMLScreen && !that.hasHtmlEventBridge) {
|
||||
console.debug(that.buttonName, 'connecting', that.tablet.webEventReceived);
|
||||
that.tablet.webEventReceived.connect(that.fromHtml);
|
||||
that.hasHtmlEventBridge = true;
|
||||
}
|
||||
} else {
|
||||
if (that.hasEventBridge) {
|
||||
console.debug(that.buttonName, 'disconnecting', that.eventSignal());
|
||||
that.eventSignal().disconnect(handler);
|
||||
that.hasEventBridge = false;
|
||||
if (that.hasQmlEventBridge) {
|
||||
console.debug(that.buttonName, 'disconnecting', that.tablet.fromQml);
|
||||
that.tablet.fromQml.disconnect(that.onMessage);
|
||||
that.hasQmlEventBridge = false;
|
||||
}
|
||||
if (that.hasHtmlEventBridge) {
|
||||
console.debug(that.buttonName, 'disconnecting', that.tablet.webEventReceived);
|
||||
that.tablet.webEventReceived.disconnect(that.fromHtml);
|
||||
that.hasHtmlEventBridge = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -341,9 +341,10 @@
|
|||
type: 'ParticleEffect'
|
||||
};
|
||||
|
||||
var MS_PER_SEC = 1000;
|
||||
function updateSendMoneyParticleEffect() {
|
||||
var timestampNow = Date.now();
|
||||
if ((timestampNow - particleEffectTimestamp) > (SEND_MONEY_PARTICLE_LIFETIME_SECONDS * 1000)) {
|
||||
if ((timestampNow - particleEffectTimestamp) > (SEND_MONEY_PARTICLE_LIFETIME_SECONDS * MS_PER_SEC)) {
|
||||
deleteSendMoneyParticleEffect();
|
||||
return;
|
||||
} else if ((timestampNow - particleEffectTimestamp) > SEND_MONEY_PARTICLE_EMITTING_DURATION) {
|
||||
|
@ -386,7 +387,6 @@
|
|||
// Description:
|
||||
// -Called when a message is received from SpectatorCamera.qml. The "message" argument is what is sent from the QML
|
||||
// in the format "{method, params}", like json-rpc. See also sendToQml().
|
||||
var isHmdPreviewDisabled = true;
|
||||
var MARKETPLACE_PURCHASES_QML_PATH = "hifi/commerce/purchases/Purchases.qml";
|
||||
var MARKETPLACES_INJECT_SCRIPT_URL = Script.resolvePath("../html/js/marketplacesInject.js");
|
||||
function fromQml(message) {
|
||||
|
@ -405,10 +405,10 @@
|
|||
case 'purchases':
|
||||
case 'marketplace cta':
|
||||
case 'mainPage':
|
||||
ui.openNewApp(MARKETPLACE_URL, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||
ui.open(MARKETPLACE_URL, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||
break;
|
||||
default: // User needs to return to an individual marketplace item URL
|
||||
ui.openNewApp(MARKETPLACE_URL + '/items/' + message.referrer, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||
ui.open(MARKETPLACE_URL + '/items/' + message.referrer, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -420,17 +420,17 @@
|
|||
case 'maybeEnableHmdPreview':
|
||||
break; // do nothing here, handled in marketplaces.js
|
||||
case 'transactionHistory_linkClicked':
|
||||
ui.openNewApp(message.marketplaceLink, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||
ui.open(message.marketplaceLink, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||
break;
|
||||
case 'goToPurchases_fromWalletHome':
|
||||
case 'goToPurchases':
|
||||
ui.openNewApp(MARKETPLACE_PURCHASES_QML_PATH);
|
||||
ui.open(MARKETPLACE_PURCHASES_QML_PATH);
|
||||
break;
|
||||
case 'goToMarketplaceMainPage':
|
||||
ui.openNewApp(MARKETPLACE_URL, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||
ui.open(MARKETPLACE_URL, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||
break;
|
||||
case 'goToMarketplaceItemPage':
|
||||
ui.openNewApp(MARKETPLACE_URL + '/items/' + message.itemId, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||
ui.open(MARKETPLACE_URL + '/items/' + message.itemId, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||
break;
|
||||
case 'refreshConnections':
|
||||
print('Refreshing Connections...');
|
||||
|
@ -502,7 +502,7 @@
|
|||
//
|
||||
var BUTTON_NAME = "WALLET";
|
||||
var WALLET_QML_SOURCE = "hifi/commerce/wallet/Wallet.qml";
|
||||
var walletEnabled = Settings.getValue("commerce", true);
|
||||
var ui;
|
||||
function startup() {
|
||||
ui = new AppUi({
|
||||
buttonName: BUTTON_NAME,
|
||||
|
@ -539,5 +539,4 @@
|
|||
//
|
||||
startup();
|
||||
Script.scriptEnding.connect(shutdown);
|
||||
|
||||
}()); // END LOCAL_SCOPE
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* global $, window, MutationObserver */
|
||||
|
||||
//
|
||||
// marketplacesInject.js
|
||||
//
|
||||
|
@ -11,7 +13,6 @@
|
|||
//
|
||||
|
||||
(function () {
|
||||
|
||||
// Event bridge messages.
|
||||
var CLARA_IO_DOWNLOAD = "CLARA.IO DOWNLOAD";
|
||||
var CLARA_IO_STATUS = "CLARA.IO STATUS";
|
||||
|
@ -33,7 +34,6 @@
|
|||
var messagesWaiting = false;
|
||||
|
||||
function injectCommonCode(isDirectoryPage) {
|
||||
|
||||
// Supporting styles from marketplaces.css.
|
||||
// Glyph font family, size, and spacing adjusted because HiFi-Glyphs cannot be used cross-domain.
|
||||
$("head").append(
|
||||
|
@ -74,7 +74,9 @@
|
|||
(document.referrer !== "") ? window.history.back() : window.location = (marketplaceBaseURL + "/marketplace?");
|
||||
});
|
||||
$("#all-markets").on("click", function () {
|
||||
EventBridge.emitWebEvent(GOTO_DIRECTORY);
|
||||
EventBridge.emitWebEvent(JSON.stringify({
|
||||
type: GOTO_DIRECTORY
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -94,11 +96,11 @@
|
|||
});
|
||||
}
|
||||
|
||||
emitWalletSetupEvent = function() {
|
||||
var emitWalletSetupEvent = function () {
|
||||
EventBridge.emitWebEvent(JSON.stringify({
|
||||
type: "WALLET_SETUP"
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
function maybeAddSetupWalletButton() {
|
||||
if (!$('body').hasClass("walletsetup-injected") && userIsLoggedIn && walletNeedsSetup) {
|
||||
|
@ -285,7 +287,7 @@
|
|||
$(this).closest('.col-xs-3').prev().attr("class", 'col-xs-6');
|
||||
$(this).closest('.col-xs-3').attr("class", 'col-xs-6');
|
||||
|
||||
var priceElement = $(this).find('.price')
|
||||
var priceElement = $(this).find('.price');
|
||||
priceElement.css({
|
||||
"padding": "3px 5px",
|
||||
"height": "40px",
|
||||
|
@ -355,12 +357,12 @@
|
|||
function injectAddScrollbarToCategories() {
|
||||
$('#categories-dropdown').on('show.bs.dropdown', function () {
|
||||
$('body > div.container').css('display', 'none')
|
||||
$('#categories-dropdown > ul.dropdown-menu').css({ 'overflow': 'auto', 'height': 'calc(100vh - 110px)' })
|
||||
$('#categories-dropdown > ul.dropdown-menu').css({ 'overflow': 'auto', 'height': 'calc(100vh - 110px)' });
|
||||
});
|
||||
|
||||
$('#categories-dropdown').on('hide.bs.dropdown', function () {
|
||||
$('body > div.container').css('display', '')
|
||||
$('#categories-dropdown > ul.dropdown-menu').css({ 'overflow': '', 'height': '' })
|
||||
$('body > div.container').css('display', '');
|
||||
$('#categories-dropdown > ul.dropdown-menu').css({ 'overflow': '', 'height': '' });
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -382,7 +384,6 @@
|
|||
mutations.forEach(function (mutation) {
|
||||
injectBuyButtonOnMainPage();
|
||||
});
|
||||
//observer.disconnect();
|
||||
});
|
||||
var config = { attributes: true, childList: true, characterData: true };
|
||||
observer.observe(target, config);
|
||||
|
@ -503,10 +504,11 @@
|
|||
$(".top-title .col-sm-4").append(downloadContainer);
|
||||
downloadContainer.append(downloadFBX);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Automatic download to High Fidelity.
|
||||
function startAutoDownload() {
|
||||
|
||||
// One file request at a time.
|
||||
if (isPreparing) {
|
||||
console.log("WARNING: Clara.io FBX: Prepare only one download at a time");
|
||||
|
@ -516,7 +518,9 @@
|
|||
// User must be able to write to Asset Server.
|
||||
if (!canWriteAssets) {
|
||||
console.log("ERROR: Clara.io FBX: File download cancelled because no permissions to write to Asset Server");
|
||||
EventBridge.emitWebEvent(WARN_USER_NO_PERMISSIONS);
|
||||
EventBridge.emitWebEvent(JSON.stringify({
|
||||
type: WARN_USER_NO_PERMISSIONS
|
||||
}));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -579,7 +583,10 @@
|
|||
|
||||
if (statusMessage !== "") {
|
||||
// Update the UI with the most recent status message.
|
||||
EventBridge.emitWebEvent(CLARA_IO_STATUS + " " + statusMessage);
|
||||
EventBridge.emitWebEvent(JSON.stringify({
|
||||
type: CLARA_IO_STATUS,
|
||||
status: statusMessage
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -601,13 +608,21 @@
|
|||
if (this.status !== HTTP_OK) {
|
||||
statusMessage = "Zip file request terminated with " + this.status + " " + this.statusText;
|
||||
console.log("ERROR: Clara.io FBX: " + statusMessage);
|
||||
EventBridge.emitWebEvent(CLARA_IO_STATUS + " " + statusMessage);
|
||||
EventBridge.emitWebEvent(JSON.stringify({
|
||||
type: CLARA_IO_STATUS,
|
||||
status: statusMessage
|
||||
}));
|
||||
} else if (zipFileURL.slice(-4) !== ".zip") {
|
||||
statusMessage = "Error creating zip file for download.";
|
||||
console.log("ERROR: Clara.io FBX: " + statusMessage + ": " + zipFileURL);
|
||||
EventBridge.emitWebEvent(CLARA_IO_STATUS + " " + statusMessage);
|
||||
EventBridge.emitWebEvent(JSON.stringify({
|
||||
type: CLARA_IO_STATUS,
|
||||
status: (statusMessage + ": " + zipFileURL)
|
||||
}));
|
||||
} else {
|
||||
EventBridge.emitWebEvent(CLARA_IO_DOWNLOAD + " " + zipFileURL);
|
||||
EventBridge.emitWebEvent(JSON.stringify({
|
||||
type: CLARA_IO_DOWNLOAD
|
||||
}));
|
||||
console.log("Clara.io FBX: File download initiated for " + zipFileURL);
|
||||
}
|
||||
|
||||
|
@ -617,14 +632,15 @@
|
|||
isPreparing = true;
|
||||
|
||||
console.log("Clara.io FBX: Request zip file for " + uuid);
|
||||
EventBridge.emitWebEvent(CLARA_IO_STATUS + " Initiating download");
|
||||
EventBridge.emitWebEvent(JSON.stringify({
|
||||
type: CLARA_IO_STATUS,
|
||||
status: "Initiating download"
|
||||
}));
|
||||
|
||||
xmlHttpRequest.open("POST", url, true);
|
||||
xmlHttpRequest.setRequestHeader("Accept", "text/event-stream");
|
||||
xmlHttpRequest.send();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function injectClaraCode() {
|
||||
|
||||
|
@ -663,7 +679,9 @@
|
|||
updateClaraCodeInterval = undefined;
|
||||
});
|
||||
|
||||
EventBridge.emitWebEvent(QUERY_CAN_WRITE_ASSETS);
|
||||
EventBridge.emitWebEvent(JSON.stringify({
|
||||
type: QUERY_CAN_WRITE_ASSETS
|
||||
}));
|
||||
}
|
||||
|
||||
function cancelClaraDownload() {
|
||||
|
@ -673,7 +691,9 @@
|
|||
xmlHttpRequest.abort();
|
||||
xmlHttpRequest = null;
|
||||
console.log("Clara.io FBX: File download cancelled");
|
||||
EventBridge.emitWebEvent(CLARA_IO_CANCELLED_DOWNLOAD);
|
||||
EventBridge.emitWebEvent(JSON.stringify({
|
||||
type: CLARA_IO_CANCELLED_DOWNLOAD
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -708,28 +728,24 @@
|
|||
|
||||
function onLoad() {
|
||||
EventBridge.scriptEventReceived.connect(function (message) {
|
||||
message = JSON.stringify(message);
|
||||
if (message.slice(0, CAN_WRITE_ASSETS.length) === CAN_WRITE_ASSETS) {
|
||||
canWriteAssets = message.slice(-4) === "true";
|
||||
} else if (message.slice(0, CLARA_IO_CANCEL_DOWNLOAD.length) === CLARA_IO_CANCEL_DOWNLOAD) {
|
||||
message = JSON.parse(message);
|
||||
if (message.type === CAN_WRITE_ASSETS) {
|
||||
canWriteAssets = message.canWriteAssets;
|
||||
} else if (message.type === CLARA_IO_CANCEL_DOWNLOAD) {
|
||||
cancelClaraDownload();
|
||||
} else {
|
||||
var parsedJsonMessage = JSON.parse(message);
|
||||
|
||||
if (parsedJsonMessage.type === "marketplaces") {
|
||||
if (parsedJsonMessage.action === "commerceSetting") {
|
||||
commerceMode = !!parsedJsonMessage.data.commerceMode;
|
||||
userIsLoggedIn = !!parsedJsonMessage.data.userIsLoggedIn;
|
||||
walletNeedsSetup = !!parsedJsonMessage.data.walletNeedsSetup;
|
||||
marketplaceBaseURL = parsedJsonMessage.data.metaverseServerURL;
|
||||
} else if (message.type === "marketplaces") {
|
||||
if (message.action === "commerceSetting") {
|
||||
commerceMode = !!message.data.commerceMode;
|
||||
userIsLoggedIn = !!message.data.userIsLoggedIn;
|
||||
walletNeedsSetup = !!message.data.walletNeedsSetup;
|
||||
marketplaceBaseURL = message.data.metaverseServerURL;
|
||||
if (marketplaceBaseURL.indexOf('metaverse.') !== -1) {
|
||||
marketplaceBaseURL = marketplaceBaseURL.replace('metaverse.', '');
|
||||
}
|
||||
messagesWaiting = parsedJsonMessage.data.messagesWaiting;
|
||||
messagesWaiting = message.data.messagesWaiting;
|
||||
injectCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Request commerce setting
|
||||
|
|
|
@ -26,7 +26,7 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
|||
var MARKETPLACE_CHECKOUT_QML_PATH = "hifi/commerce/checkout/Checkout.qml";
|
||||
var MARKETPLACE_PURCHASES_QML_PATH = "hifi/commerce/purchases/Purchases.qml";
|
||||
var MARKETPLACE_WALLET_QML_PATH = "hifi/commerce/wallet/Wallet.qml";
|
||||
var MARKETPLACE_INSPECTIONCERTIFICATE_QML_PATH = "commerce/inspectionCertificate/InspectionCertificate.qml";
|
||||
var MARKETPLACE_INSPECTIONCERTIFICATE_QML_PATH = "hifi/commerce/inspectionCertificate/InspectionCertificate.qml";
|
||||
var REZZING_SOUND = SoundCache.getSound(Script.resolvePath("../assets/sounds/rezzing.wav"));
|
||||
|
||||
// Event bridge messages.
|
||||
|
@ -52,13 +52,17 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
|||
if (id === messageBox && button === CANCEL_BUTTON) {
|
||||
isDownloadBeingCancelled = true;
|
||||
messageBox = null;
|
||||
ui.sendToHtml(CLARA_IO_CANCEL_DOWNLOAD);
|
||||
ui.sendToHtml({
|
||||
type: CLARA_IO_CANCEL_DOWNLOAD
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function onCanWriteAssetsChanged() {
|
||||
var message = CAN_WRITE_ASSETS + " " + Entities.canWriteAssets();
|
||||
ui.sendToHtml(message);
|
||||
ui.sendToHtml({
|
||||
type: CAN_WRITE_ASSETS,
|
||||
canWriteAssets: Entities.canWriteAssets()
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
@ -81,13 +85,46 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
|||
}
|
||||
|
||||
function openWallet() {
|
||||
ui.openNewApp(MARKETPLACE_WALLET_QML_PATH);
|
||||
ui.open(MARKETPLACE_WALLET_QML_PATH);
|
||||
}
|
||||
|
||||
// Function Name: wireQmlEventBridge()
|
||||
//
|
||||
// Description:
|
||||
// -Used to connect/disconnect the script's response to the tablet's "fromQml" signal. Set the "on" argument to enable or
|
||||
// disable to event bridge.
|
||||
//
|
||||
// Relevant Variables:
|
||||
// -hasEventBridge: true/false depending on whether we've already connected the event bridge.
|
||||
var hasEventBridge = false;
|
||||
function wireQmlEventBridge(on) {
|
||||
if (!ui.tablet) {
|
||||
print("Warning in wireQmlEventBridge(): 'tablet' undefined!");
|
||||
return;
|
||||
}
|
||||
if (on) {
|
||||
if (!hasEventBridge) {
|
||||
ui.tablet.fromQml.connect(onQmlMessageReceived);
|
||||
hasEventBridge = true;
|
||||
}
|
||||
} else {
|
||||
if (hasEventBridge) {
|
||||
ui.tablet.fromQml.disconnect(onQmlMessageReceived);
|
||||
hasEventBridge = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var contextOverlayEntity = "";
|
||||
function openInspectionCertificateQML(currentEntityWithContextOverlay) {
|
||||
ui.open(MARKETPLACE_INSPECTIONCERTIFICATE_QML_PATH);
|
||||
contextOverlayEntity = currentEntityWithContextOverlay;
|
||||
}
|
||||
|
||||
function setCertificateInfo(currentEntityWithContextOverlay, itemCertificateId) {
|
||||
ui.wireEventBridge(true);
|
||||
var certificateId = itemCertificateId || (Entities.getEntityProperties(currentEntityWithContextOverlay, ['certificateID']).certificateID);
|
||||
ui.sendMessage({
|
||||
var certificateId = itemCertificateId ||
|
||||
(Entities.getEntityProperties(currentEntityWithContextOverlay, ['certificateID']).certificateID);
|
||||
ui.tablet.sendToQml({
|
||||
method: 'inspectionCertificate_setCertificateId',
|
||||
entityId: currentEntityWithContextOverlay,
|
||||
certificateId: certificateId
|
||||
|
@ -96,7 +133,7 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
|||
|
||||
function onUsernameChanged() {
|
||||
if (onMarketplaceScreen) {
|
||||
ui.openNewApp(MARKETPLACE_URL_INITIAL, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||
ui.open(MARKETPLACE_URL_INITIAL, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,7 +179,6 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
|||
function color(selected, hovering) {
|
||||
var base = hovering ? HOVER_COLOR : selected ? SELECTED_COLOR : UNSELECTED_COLOR;
|
||||
function scale(component) {
|
||||
var delta = 0xFF - component;
|
||||
return component;
|
||||
}
|
||||
return { red: scale(base.red), green: scale(base.green), blue: scale(base.blue) };
|
||||
|
@ -285,7 +321,7 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
|||
method: 'updateSelectedRecipientUsername',
|
||||
userName: username === "" ? "unknown username" : username
|
||||
};
|
||||
ui.sendMessage(message);
|
||||
ui.tablet.sendToQml(message);
|
||||
}
|
||||
}
|
||||
function handleClick(pickRay) {
|
||||
|
@ -303,7 +339,7 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
|||
displayName: '"' + AvatarList.getAvatar(avatarId).sessionDisplayName + '"',
|
||||
userName: ''
|
||||
};
|
||||
ui.sendMessage(message);
|
||||
ui.tablet.sendToQml(message);
|
||||
|
||||
ExtendedOverlay.some(function (overlay) {
|
||||
var id = overlay.key;
|
||||
|
@ -406,7 +442,7 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
|||
{ x: 1, y: 0, z: 0 },
|
||||
{ x: 1, y: 0, z: 1 },
|
||||
{ x: 1, y: 1, z: 0 },
|
||||
{ x: 1, y: 1, z: 1 },
|
||||
{ x: 1, y: 1, z: 1 }
|
||||
];
|
||||
|
||||
// Go through all corners and find least (most negative) distance in front of position.
|
||||
|
@ -587,68 +623,66 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
|||
|
||||
var referrerURL; // Used for updating Purchases QML
|
||||
var filterText; // Used for updating Purchases QML
|
||||
function onMessage(message) {
|
||||
if (message === GOTO_DIRECTORY) {
|
||||
ui.openNewApp(MARKETPLACES_URL, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||
} else if (message === QUERY_CAN_WRITE_ASSETS) {
|
||||
function onWebEventReceived(message) {
|
||||
message = JSON.parse(message);
|
||||
if (message.type === GOTO_DIRECTORY) {
|
||||
ui.open(MARKETPLACES_URL, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||
} else if (message.type === QUERY_CAN_WRITE_ASSETS) {
|
||||
ui.sendToHtml(CAN_WRITE_ASSETS + " " + Entities.canWriteAssets());
|
||||
} else if (message === WARN_USER_NO_PERMISSIONS) {
|
||||
} else if (message.type === WARN_USER_NO_PERMISSIONS) {
|
||||
Window.alert(NO_PERMISSIONS_ERROR_MESSAGE);
|
||||
} else if (message.slice(0, CLARA_IO_STATUS.length) === CLARA_IO_STATUS) {
|
||||
} else if (message.type === CLARA_IO_STATUS) {
|
||||
if (isDownloadBeingCancelled) {
|
||||
return;
|
||||
}
|
||||
|
||||
var text = message.slice(CLARA_IO_STATUS.length);
|
||||
var text = message.status;
|
||||
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;
|
||||
} else if (message.slice(0, CLARA_IO_DOWNLOAD.length) === CLARA_IO_DOWNLOAD) {
|
||||
} else if (message.type === CLARA_IO_DOWNLOAD) {
|
||||
if (messageBox !== null) {
|
||||
Window.closeMessageBox(messageBox);
|
||||
messageBox = null;
|
||||
}
|
||||
return;
|
||||
} else if (message === CLARA_IO_CANCELLED_DOWNLOAD) {
|
||||
} else if (message.type === CLARA_IO_CANCELLED_DOWNLOAD) {
|
||||
isDownloadBeingCancelled = false;
|
||||
} else {
|
||||
var parsedJsonMessage = JSON.parse(message);
|
||||
if (parsedJsonMessage.type === "CHECKOUT") {
|
||||
ui.wireEventBridge(true);
|
||||
ui.openNewApp(MARKETPLACE_CHECKOUT_QML_PATH);
|
||||
ui.sendMessage({
|
||||
} else if (message.type === "CHECKOUT") {
|
||||
wireQmlEventBridge(true);
|
||||
ui.open(MARKETPLACE_CHECKOUT_QML_PATH);
|
||||
ui.tablet.sendToQml({
|
||||
method: 'updateCheckoutQML',
|
||||
params: parsedJsonMessage
|
||||
params: message
|
||||
});
|
||||
} else if (parsedJsonMessage.type === "REQUEST_SETTING") {
|
||||
} else if (message.type === "REQUEST_SETTING") {
|
||||
sendCommerceSettings();
|
||||
} else if (parsedJsonMessage.type === "PURCHASES") {
|
||||
referrerURL = parsedJsonMessage.referrerURL;
|
||||
} else if (message.type === "PURCHASES") {
|
||||
referrerURL = message.referrerURL;
|
||||
filterText = "";
|
||||
ui.openNewApp(MARKETPLACE_PURCHASES_QML_PATH);
|
||||
} else if (parsedJsonMessage.type === "LOGIN") {
|
||||
ui.open(MARKETPLACE_PURCHASES_QML_PATH);
|
||||
} else if (message.type === "LOGIN") {
|
||||
openLoginWindow();
|
||||
} else if (parsedJsonMessage.type === "WALLET_SETUP") {
|
||||
ui.wireEventBridge(true);
|
||||
ui.sendMessage({
|
||||
} else if (message.type === "WALLET_SETUP") {
|
||||
wireQmlEventBridge(true);
|
||||
ui.tablet.sendToQml({
|
||||
method: 'updateWalletReferrer',
|
||||
referrer: "marketplace cta"
|
||||
});
|
||||
openWallet();
|
||||
} else if (parsedJsonMessage.type === "MY_ITEMS") {
|
||||
} else if (message.type === "MY_ITEMS") {
|
||||
referrerURL = MARKETPLACE_URL_INITIAL;
|
||||
filterText = "";
|
||||
ui.openNewApp(MARKETPLACE_PURCHASES_QML_PATH);
|
||||
ui.wireEventBridge(true);
|
||||
ui.sendMessage({
|
||||
ui.open(MARKETPLACE_PURCHASES_QML_PATH);
|
||||
wireQmlEventBridge(true);
|
||||
ui.tablet.sendToQml({
|
||||
method: 'purchases_showMyItems'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
var sendAssetRecipient;
|
||||
var sendAssetParticleEffectUpdateTimer;
|
||||
var particleEffectTimestamp;
|
||||
|
@ -723,25 +757,21 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
|||
sendAssetRecipient = null;
|
||||
}
|
||||
|
||||
var savedDisablePreviewOptionLocked = false;
|
||||
var savedDisablePreviewOption = Menu.isOptionChecked("Disable Preview");;
|
||||
var savedDisablePreviewOption = Menu.isOptionChecked("Disable Preview");
|
||||
var UI_FADE_TIMEOUT_MS = 150;
|
||||
function maybeEnableHMDPreview() {
|
||||
// Set a small timeout to prevent sensitive data from being shown during
|
||||
// UI fade
|
||||
// Set a small timeout to prevent sensitive data from being shown during UI fade
|
||||
Script.setTimeout(function () {
|
||||
setTabletVisibleInSecondaryCamera(true);
|
||||
DesktopPreviewProvider.setPreviewDisabledReason("USER");
|
||||
Menu.setIsOptionChecked("Disable Preview", savedDisablePreviewOption);
|
||||
savedDisablePreviewOptionLocked = false;
|
||||
}, 150);
|
||||
}, UI_FADE_TIMEOUT_MS);
|
||||
}
|
||||
|
||||
// Function Name: fromQml()
|
||||
//
|
||||
// Description:
|
||||
// -Called when a message is received from Checkout.qml. The "message" argument is what is sent from the Checkout QML
|
||||
// in the format "{method, params}", like json-rpc.
|
||||
function fromQml(message) {
|
||||
var onQmlMessageReceived = function onQmlMessageReceived(message) {
|
||||
if (message.messageSrc === "HTML") {
|
||||
return;
|
||||
}
|
||||
switch (message.method) {
|
||||
case 'purchases_openWallet':
|
||||
case 'checkout_openWallet':
|
||||
|
@ -749,40 +779,40 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
|||
openWallet();
|
||||
break;
|
||||
case 'purchases_walletNotSetUp':
|
||||
ui.wireEventBridge(true);
|
||||
ui.sendMessage({
|
||||
wireQmlEventBridge(true);
|
||||
ui.tablet.sendToQml({
|
||||
method: 'updateWalletReferrer',
|
||||
referrer: "purchases"
|
||||
});
|
||||
openWallet();
|
||||
break;
|
||||
case 'checkout_walletNotSetUp':
|
||||
ui.wireEventBridge(true);
|
||||
ui.sendMessage({
|
||||
wireQmlEventBridge(true);
|
||||
ui.tablet.sendToQml({
|
||||
method: 'updateWalletReferrer',
|
||||
referrer: message.referrer === "itemPage" ? message.itemId : message.referrer
|
||||
});
|
||||
openWallet();
|
||||
break;
|
||||
case 'checkout_cancelClicked':
|
||||
ui.openNewApp(MARKETPLACE_URL + '/items/' + message.params, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||
ui.open(MARKETPLACE_URL + '/items/' + message.params, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||
break;
|
||||
case 'header_goToPurchases':
|
||||
case 'checkout_goToPurchases':
|
||||
referrerURL = MARKETPLACE_URL_INITIAL;
|
||||
filterText = message.filterText;
|
||||
ui.openNewApp(MARKETPLACE_PURCHASES_QML_PATH);
|
||||
ui.open(MARKETPLACE_PURCHASES_QML_PATH);
|
||||
break;
|
||||
case 'checkout_itemLinkClicked':
|
||||
ui.openNewApp(MARKETPLACE_URL + '/items/' + message.itemId, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||
ui.open(MARKETPLACE_URL + '/items/' + message.itemId, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||
break;
|
||||
case 'checkout_continueShopping':
|
||||
ui.openNewApp(MARKETPLACE_URL_INITIAL, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||
ui.open(MARKETPLACE_URL_INITIAL, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||
break;
|
||||
case 'purchases_itemInfoClicked':
|
||||
var itemId = message.itemId;
|
||||
if (itemId && itemId !== "") {
|
||||
ui.openNewApp(MARKETPLACE_URL + '/items/' + itemId, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||
ui.open(MARKETPLACE_URL + '/items/' + itemId, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||
}
|
||||
break;
|
||||
case 'checkout_rezClicked':
|
||||
|
@ -791,13 +821,13 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
|||
break;
|
||||
case 'header_marketplaceImageClicked':
|
||||
case 'purchases_backClicked':
|
||||
ui.openNewApp(message.referrerURL, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||
ui.open(message.referrerURL, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||
break;
|
||||
case 'purchases_goToMarketplaceClicked':
|
||||
ui.openNewApp(MARKETPLACE_URL_INITIAL, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||
ui.open(MARKETPLACE_URL_INITIAL, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||
break;
|
||||
case 'updateItemClicked':
|
||||
ui.openNewApp(message.upgradeUrl + "?edition=" + message.itemEdition,
|
||||
ui.open(message.upgradeUrl + "?edition=" + message.itemEdition,
|
||||
MARKETPLACES_INJECT_SCRIPT_URL);
|
||||
break;
|
||||
case 'giftAsset':
|
||||
|
@ -805,7 +835,7 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
|||
break;
|
||||
case 'passphrasePopup_cancelClicked':
|
||||
case 'needsLogIn_cancelClicked':
|
||||
ui.openNewApp(MARKETPLACE_URL_INITIAL, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||
ui.open(MARKETPLACE_URL_INITIAL, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||
break;
|
||||
case 'needsLogIn_loginClicked':
|
||||
openLoginWindow();
|
||||
|
@ -813,7 +843,6 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
|||
case 'disableHmdPreview':
|
||||
if (!savedDisablePreviewOption) {
|
||||
savedDisablePreviewOption = Menu.isOptionChecked("Disable Preview");
|
||||
savedDisablePreviewOptionLocked = true;
|
||||
}
|
||||
|
||||
if (!savedDisablePreviewOption) {
|
||||
|
@ -826,10 +855,11 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
|||
maybeEnableHMDPreview();
|
||||
break;
|
||||
case 'purchases_openGoTo':
|
||||
ui.openNewApp("hifi/tablet/TabletAddressDialog.qml");
|
||||
ui.open("hifi/tablet/TabletAddressDialog.qml");
|
||||
break;
|
||||
case 'purchases_itemCertificateClicked':
|
||||
setCertificateInfo("", message.itemCertificateId);
|
||||
contextOverlayEntity = "";
|
||||
setCertificateInfo(contextOverlayEntity, message.itemCertificateId);
|
||||
break;
|
||||
case 'inspectionCertificate_closeClicked':
|
||||
ui.close();
|
||||
|
@ -838,14 +868,14 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
|||
ContextOverlay.requestOwnershipVerification(message.entity);
|
||||
break;
|
||||
case 'inspectionCertificate_showInMarketplaceClicked':
|
||||
ui.openNewApp(message.marketplaceUrl, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||
ui.open(message.marketplaceUrl, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||
break;
|
||||
case 'header_myItemsClicked':
|
||||
referrerURL = MARKETPLACE_URL_INITIAL;
|
||||
filterText = "";
|
||||
ui.openNewApp(MARKETPLACE_PURCHASES_QML_PATH);
|
||||
ui.wireEventBridge(true);
|
||||
ui.sendMessage({
|
||||
ui.open(MARKETPLACE_PURCHASES_QML_PATH);
|
||||
wireQmlEventBridge(true);
|
||||
ui.tablet.sendToQml({
|
||||
method: 'purchases_showMyItems'
|
||||
});
|
||||
break;
|
||||
|
@ -890,7 +920,9 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
|||
var nearbyEntities = Entities.findEntitiesByType('Model', MyAvatar.position, ATTACHMENT_SEARCH_RADIUS);
|
||||
|
||||
for (var i = 0; i < nearbyEntities.length; i++) {
|
||||
var currentProperties = Entities.getEntityProperties(nearbyEntities[i], ['certificateID', 'editionNumber', 'parentID']);
|
||||
var currentProperties = Entities.getEntityProperties(
|
||||
nearbyEntities[i], ['certificateID', 'editionNumber', 'parentID']
|
||||
);
|
||||
if (currentProperties.parentID === MyAvatar.sessionUUID) {
|
||||
currentlyWornWearables.push({
|
||||
entityID: nearbyEntities[i],
|
||||
|
@ -900,13 +932,12 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
|||
}
|
||||
}
|
||||
|
||||
ui.sendMessage({ method: 'updateWearables', wornWearables: currentlyWornWearables });
|
||||
ui.tablet.sendToQml({ method: 'updateWearables', wornWearables: currentlyWornWearables });
|
||||
break;
|
||||
case 'sendAsset_sendPublicly':
|
||||
if (message.assetName !== "") {
|
||||
deleteSendAssetParticleEffect();
|
||||
sendAssetRecipient = message.recipient;
|
||||
var amount = message.amount;
|
||||
var props = SEND_ASSET_PARTICLE_PROPERTIES;
|
||||
props.parentID = MyAvatar.sessionUUID;
|
||||
props.position = MyAvatar.position;
|
||||
|
@ -917,7 +948,8 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
|||
sendAssetParticleEffect = Entities.addEntity(props, true);
|
||||
particleEffectTimestamp = Date.now();
|
||||
updateSendAssetParticleEffect();
|
||||
sendAssetParticleEffectUpdateTimer = Script.setInterval(updateSendAssetParticleEffect, SEND_ASSET_PARTICLE_TIMER_UPDATE);
|
||||
sendAssetParticleEffectUpdateTimer = Script.setInterval(updateSendAssetParticleEffect,
|
||||
SEND_ASSET_PARTICLE_TIMER_UPDATE);
|
||||
}
|
||||
break;
|
||||
case 'http.request':
|
||||
|
@ -928,7 +960,7 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
|||
default:
|
||||
print('Unrecognized message from Checkout.qml or Purchases.qml: ' + JSON.stringify(message));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Function Name: onTabletScreenChanged()
|
||||
//
|
||||
|
@ -938,29 +970,35 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
|||
var onMarketplaceScreen = false;
|
||||
var onWalletScreen = false;
|
||||
var onCommerceScreen = false;
|
||||
function onTabletScreenChanged(type, url) {
|
||||
var onInspectionCertificateScreen = false;
|
||||
var onTabletScreenChanged = function onTabletScreenChanged(type, url) {
|
||||
ui.setCurrentVisibleScreenMetadata(type, url);
|
||||
onMarketplaceScreen = type === "Web" && url.indexOf(MARKETPLACE_URL) !== -1;
|
||||
onInspectionCertificateScreen = type === "QML" && url.indexOf(MARKETPLACE_INSPECTIONCERTIFICATE_QML_PATH) !== -1;
|
||||
var onWalletScreenNow = url.indexOf(MARKETPLACE_WALLET_QML_PATH) !== -1;
|
||||
var onCommerceScreenNow = type === "QML" && (url.indexOf(MARKETPLACE_CHECKOUT_QML_PATH) !== -1 || url === MARKETPLACE_PURCHASES_QML_PATH
|
||||
|| url.indexOf(MARKETPLACE_INSPECTIONCERTIFICATE_QML_PATH) !== -1);
|
||||
var onCommerceScreenNow = type === "QML" &&
|
||||
(url.indexOf(MARKETPLACE_CHECKOUT_QML_PATH) !== -1 || url === MARKETPLACE_PURCHASES_QML_PATH ||
|
||||
onInspectionCertificateScreen);
|
||||
|
||||
if ((!onWalletScreenNow && onWalletScreen) || (!onCommerceScreenNow && onCommerceScreen)) { // exiting wallet or commerce screen
|
||||
// exiting wallet or commerce screen
|
||||
if ((!onWalletScreenNow && onWalletScreen) || (!onCommerceScreenNow && onCommerceScreen)) {
|
||||
maybeEnableHMDPreview();
|
||||
}
|
||||
|
||||
onCommerceScreen = onCommerceScreenNow;
|
||||
onWalletScreen = onWalletScreenNow;
|
||||
ui.wireEventBridge(onMarketplaceScreen || onCommerceScreen || onWalletScreen);
|
||||
wireQmlEventBridge(onMarketplaceScreen || onCommerceScreen || onWalletScreen);
|
||||
|
||||
if (url === MARKETPLACE_PURCHASES_QML_PATH) {
|
||||
ui.sendMessage({
|
||||
ui.tablet.sendToQml({
|
||||
method: 'updatePurchases',
|
||||
referrerURL: referrerURL,
|
||||
filterText: filterText
|
||||
});
|
||||
}
|
||||
|
||||
ui.buttonActive((onMarketplaceScreen || onCommerceScreen) && !onWalletScreen);
|
||||
ui.isOpen = (onMarketplaceScreen || onCommerceScreen) && !onWalletScreen;
|
||||
ui.buttonActive(ui.isOpen);
|
||||
|
||||
if (type === "Web" && url.indexOf(MARKETPLACE_URL) !== -1) {
|
||||
ContextOverlay.isInMarketplaceInspectionMode = true;
|
||||
|
@ -968,6 +1006,10 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
|||
ContextOverlay.isInMarketplaceInspectionMode = false;
|
||||
}
|
||||
|
||||
if (onInspectionCertificateScreen) {
|
||||
setCertificateInfo(contextOverlayEntity);
|
||||
}
|
||||
|
||||
if (onCommerceScreen) {
|
||||
if (!isWired) {
|
||||
Users.usernameFromIDReply.connect(usernameFromIDReply);
|
||||
|
@ -979,12 +1021,14 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
|||
isWired = true;
|
||||
Wallet.refreshWalletStatus();
|
||||
} else {
|
||||
ui.sendMessage({
|
||||
ui.tablet.sendToQml({
|
||||
method: 'inspectionCertificate_resetCert'
|
||||
});
|
||||
off();
|
||||
}
|
||||
}
|
||||
console.debug(ui.buttonName + " app reports: Tablet screen changed.\nNew screen type: " + type +
|
||||
"\nNew screen URL: " + url + "\nCurrent app open status: " + ui.isOpen + "\n");
|
||||
};
|
||||
|
||||
//
|
||||
// Manage the connection between the button and the window.
|
||||
|
@ -992,24 +1036,26 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
|||
var BUTTON_NAME = "MARKET";
|
||||
var MARKETPLACE_URL = METAVERSE_SERVER_URL + "/marketplace";
|
||||
var MARKETPLACE_URL_INITIAL = MARKETPLACE_URL + "?"; // Append "?" to signal injected script that it's the initial page.
|
||||
var ui;
|
||||
function startup() {
|
||||
ui = new AppUi({
|
||||
buttonName: BUTTON_NAME,
|
||||
sortOrder: 9,
|
||||
inject: MARKETPLACES_INJECT_SCRIPT_URL,
|
||||
home: MARKETPLACE_URL_INITIAL,
|
||||
onMessage: fromQml
|
||||
onScreenChanged: onTabletScreenChanged,
|
||||
onMessage: onQmlMessageReceived
|
||||
});
|
||||
|
||||
ContextOverlay.contextOverlayClicked.connect(setCertificateInfo);
|
||||
ContextOverlay.contextOverlayClicked.connect(openInspectionCertificateQML);
|
||||
Entities.canWriteAssetsChanged.connect(onCanWriteAssetsChanged);
|
||||
GlobalServices.myUsernameChanged.connect(onUsernameChanged);
|
||||
marketplaceButton.clicked.connect(onButtonClicked);
|
||||
ui.tablet.webEventReceived.connect(onWebEventReceived);
|
||||
Wallet.walletStatusChanged.connect(sendCommerceSettings);
|
||||
Window.messageBoxClosed.connect(onMessageBoxClosed);
|
||||
|
||||
Wallet.refreshWalletStatus();
|
||||
}
|
||||
|
||||
var isWired = false;
|
||||
var isUpdateOverlaysWired = false;
|
||||
function off() {
|
||||
|
@ -1033,12 +1079,13 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
|||
maybeEnableHMDPreview();
|
||||
deleteSendAssetParticleEffect();
|
||||
|
||||
ContextOverlay.contextOverlayClicked.disconnect(setCertificateInfo);
|
||||
Entities.canWriteAssetsChanged.disconnect(onCanWriteAssetsChanged);
|
||||
GlobalServices.myUsernameChanged.disconnect(onUsernameChanged);
|
||||
marketplaceButton.clicked.disconnect(onButtonClicked);
|
||||
Wallet.walletStatusChanged.disconnect(sendCommerceSettings);
|
||||
Window.messageBoxClosed.disconnect(onMessageBoxClosed);
|
||||
Wallet.walletStatusChanged.disconnect(sendCommerceSettings);
|
||||
ui.tablet.webEventReceived.disconnect(onWebEventReceived);
|
||||
GlobalServices.myUsernameChanged.disconnect(onUsernameChanged);
|
||||
Entities.canWriteAssetsChanged.disconnect(onCanWriteAssetsChanged);
|
||||
ContextOverlay.contextOverlayClicked.disconnect(openInspectionCertificateQML);
|
||||
|
||||
off();
|
||||
}
|
||||
|
||||
|
@ -1047,5 +1094,4 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
|||
//
|
||||
startup();
|
||||
Script.scriptEnding.connect(shutdown);
|
||||
|
||||
}()); // END LOCAL_SCOPE
|
||||
|
|
Loading…
Reference in a new issue